NewsNewsFeaturesDownloadsDevelopmentSupportForumDocumentsAbout Us

AdminAddUserAction 類別 參考文件
[Action]

類別AdminAddUserAction的繼承圖:

SiteAdminAction AdminAction Action Object 全部成員列表

公開方法(Public Methods)

 AdminAddUserAction ($actionInfo, $request)
 perform ()

公開屬性

 $_userName
 $_userPassword
 $_userEmail
 $_userBlog
 $_userFullName
 $_properties
 $_userStatus

詳細描述

Adds a new user to the database.

定義在 adminadduseraction.class.php 檔案之第 20 行.


建構子與解構子說明文件

AdminAddUserAction::AdminAddUserAction actionInfo,
request
 

定義在 adminadduseraction.class.php 檔案之第 31 行.

參考 $request, Action::registerField(), Action::registerFieldValidator(), Action::setValidationErrorView(), 及 SiteAdminAction::SiteAdminAction().

00032         {
00033             $this->SiteAdminAction( $actionInfo, $request );
00034             
00035             // for data validation purposes
00036             $this->registerFieldValidator( "userName", new UsernameValidator());
00037             $this->registerFieldValidator( "newUserPassword", new PasswordValidator());
00038             $this->registerFieldValidator( "userEmail", new EmailValidator());
00039             $this->registerFieldValidator( "userStatus", new IntegerValidator());
00040             $this->registerField( "userFullName" );
00041             $this->registerField( "userBlog", new IntegerValidator());
00042             $view = new AdminAddUserView( $this->_blogInfo );
00043             $this->setValidationErrorView( $view );
00044         }


函式成員說明文件

AdminAddUserAction::perform  ) 
 

Receives the HTTP request from the client as parameter, so that we can extract the parameters and perform our business logic.

The result of this will be a view, which will normally be the output of the processing we just did or for example an error view showing an error message. Once we have completed processing, the controller will call the getView() method to get the resulting view and send it back to the customer.

傳回值:
Returns nothing

依據Action重新實作.

定義在 adminadduseraction.class.php 檔案之第 46 行.

參考 $result, $user, $userInfo, $users, AdminAction::notifyEvent(), 及 AdminAction::setCommonData().

00047         {
00048             // fetch the validated data
00049             $this->_userName = Textfilter::filterAllHTML($this->_request->getValue( "userName" ));
00050             $this->_userPassword = $this->_request->getValue( "newUserPassword" );
00051             $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue( "userEmail" ));
00052             $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue( "userFullName" ));
00053             $this->_userStatus = $this->_request->getValue( "userStatus" );
00054             $this->_userBlog = $this->_request->getValue( "userBlog" );
00055             
00056             // now that we have validated the data, we can proceed to create the user, making
00057             // sure that it doesn't already exists
00058             $users = new Users();
00059             $userInfo = $users->userExists( $this->_userName );
00060             if( $userInfo ) {
00061                 $this->_form->setFieldValidationStatus( "userName", false );                
00062                 $this->_view = new AdminAddUserView( $this->_blogInfo );
00063                 $this->setCommonData( true );
00064                 return false;
00065             }
00066 
00067             // otherwise, we can create a new one
00068             $user = new UserInfo( $this->_userName, 
00069                                   $this->_userPassword, 
00070                                   $this->_userEmail, 
00071                                   "", 
00072                                   $this->_userFullName,
00073                                   0,
00074                                   $this->_properties );
00075             $user->setStatus( $this->_userStatus );
00076             $this->notifyEvent( EVENT_PRE_USER_ADD, Array( "user" => &$user ));
00077             $newUserId = $users->addUser( $user );
00078             
00079             if( !$newUserId ) {
00080                 $this->_view = new AdminAddUserView( $this->_blogInfo );
00081                 $this->_form->setFieldValidationStatus( "userName", false );
00082                 $this->setCommonData( true );
00083                 return false;
00084             }
00085             
00086             // if the userBlog parameter is different than 0, we have to add a relationship
00087             // between that user and the blog
00088             if( $this->_userBlog > 0 ) {
00089                 $permissions = new UserPermissions();
00090                 $result = $permissions->grantPermission( $newUserId, $this->_userBlog, PERMISSION_BLOG_USER );
00091             }
00092             
00093             $this->notifyEvent( EVENT_POST_USER_ADD, Array( "user" => &$user ));
00094 
00095             $this->_view = new AdminSiteUsersListView( $this->_blogInfo );
00096             $this->_view->setSuccessMessage( $this->_locale->pr("user_added_ok", $user->getUsername()));
00097             $this->setCommonData();
00098 
00099             return true;
00100         }


資料成員說明文件

AdminAddUserAction::$_properties
 

定義在 adminadduseraction.class.php 檔案之第 28 行.

AdminAddUserAction::$_userBlog
 

定義在 adminadduseraction.class.php 檔案之第 26 行.

AdminAddUserAction::$_userEmail
 

定義在 adminadduseraction.class.php 檔案之第 25 行.

AdminAddUserAction::$_userFullName
 

定義在 adminadduseraction.class.php 檔案之第 27 行.

AdminAddUserAction::$_userName
 

定義在 adminadduseraction.class.php 檔案之第 23 行.

AdminAddUserAction::$_userPassword
 

定義在 adminadduseraction.class.php 檔案之第 24 行.

AdminAddUserAction::$_userStatus
 

定義在 adminadduseraction.class.php 檔案之第 29 行.


此類別(class) 文件是由下列檔案中產生: