[pLog-svn] r6509 - plog/branches/lifetype-1.2/class/action/admin

mark at devel.lifetype.net mark at devel.lifetype.net
Sun Jun 8 00:09:00 EDT 2008


Author: mark
Date: 2008-06-08 00:08:59 -0400 (Sun, 08 Jun 2008)
New Revision: 6509

Modified:
   plog/branches/lifetype-1.2/class/action/admin/adminupdateuserprofileaction.class.php
Log:
1. Actually, we don't need to validate checkbox. If we really want to validate it, IntegerValidator or StringValidator are okay for it. But we need to convert it 0 or 1 before we save it to DB.

2. For ArrayValidator, we can pass another validator for validate array element. I modified ArrayValidator long time ago for this purpose.

Modified: plog/branches/lifetype-1.2/class/action/admin/adminupdateuserprofileaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminupdateuserprofileaction.class.php	2008-06-08 02:37:10 UTC (rev 6508)
+++ plog/branches/lifetype-1.2/class/action/admin/adminupdateuserprofileaction.class.php	2008-06-08 04:08:59 UTC (rev 6509)
@@ -8,6 +8,7 @@
     lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteuserslistview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );	
+    lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );	
     lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
     lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
 
@@ -33,20 +34,17 @@
         	$this->AdminAction( $actionInfo, $request );
 			
 			// data validation
-			$this->registerFieldValidator( "userFullName", new StringValidator() );
-			$this->registerFieldValidator( "userEmail", new EmailValidator());
-			$this->registerFieldValidator( "userPictureId", new IntegerValidator());
-			$this->registerFieldValidator( "userId", new IntegerValidator());
-			$this->registerFieldValidator( "userAbout", new StringValidator() );
-                // TODO: what validator?
-			$this->registerField( "properties" );
-                // TODO: I am not sure if this is an integer
-			$this->registerFieldValidator( "userIsSiteAdmin", new IntegerValidator() );
+			$this->registerFieldValidator( "userFullName", new StringValidator(),true );
+			$this->registerFieldValidator( "userEmail", new EmailValidator() );
+			$this->registerFieldValidator( "userPictureId", new IntegerValidator() );
+			$this->registerFieldValidator( "userId", new IntegerValidator() );
+			$this->registerFieldValidator( "userAbout", new StringValidator(), true );
+			$this->registerFieldValidator( "userIsSiteAdmin", new IntegerValidator(), true );
 			$this->registerFieldValidator( "userName", new UsernameValidator());
-                // TODO: what validator?
-			$this->registerField( "userPermissions" );
+			$this->registerFieldValidator( "userPermissions", new ArrayValidator( new IntegerValidator() ), true );
 			$this->registerFieldValidator( "userProfilePassword", new PasswordValidator(), true );
 			$this->registerFieldValidator( "userStatus", new IntegerValidator());
+
 			$view = new AdminEditSiteUserView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("error_updating_user"));
 			$this->setValidationErrorView( $view );
@@ -62,8 +60,7 @@
             $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue( "userEmail" ));
             $this->_userAbout = Textfilter::filterAllHTML($this->_request->getValue( "userAbout" ));
             $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue( "userFullName" ));
-            $this->_adminPrivs = $this->_request->getValue( "userIsSiteAdmin" );
-			$this->_userProperties = $this->_request->getValue( "properties" );
+            $this->_adminPrivs = ( $this->_request->getValue( "userIsSiteAdmin" ) != "" );
 			$this->_userStatus = $this->_request->getValue( "userStatus" );
 			$this->_perms = $this->_request->getValue( "userPermissions" );
 
@@ -84,7 +81,6 @@
             $user->setAboutMyself( $this->_userAbout );
             $user->setSiteAdmin( $this->_adminPrivs );
             $user->setFullName( $this->_userFullName );
-			$user->setProperties( $this->_userProperties );
 			$user->setStatus( $this->_userStatus );
             if( $this->_userPassword != "" )
             	$user->setPassword( $this->_userPassword );



More information about the pLog-svn mailing list