/** * create the user */ function createUser() { // all data is already correct $this->userName = $this->_request->getValue("userName"); $this->userFullName = $this->_request->getValue("userFullName"); $this->userPassword = $this->_request->getValue("userPassword"); $this->userEmail = $this->_request->getValue("userEmail"); $users = new Users(); $user = new UserInfo($this->userName, $this->userPassword, $this->userEmail, "", $this->userFullName); // if user registration need email confirm, that is // user must active his account if ($this->need_confirm == true) { $user->setStatus(USER_STATUS_UNCONFIRMED); } else { $user->setStatus(USER_STATUS_ACTIVE); } $userId = $users->addUser($user); if (!$userId) { $this->_view = new SummaryView("registererror"); $this->_view->setErrorMessage($this->_locale->tr("error_adding_user")); $this->setCommonData(true); return false; } return $userId; }
function perform() { // fetch the validated data $this->_userName = Textfilter::filterAllHTML($this->_request->getValue("userName")); $this->_userPassword = $this->_request->getValue("newUserPassword"); $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue("userEmail")); $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue("userFullName")); $this->_userStatus = $this->_request->getValue("userStatus"); $this->_userBlog = $this->_request->getValue("userBlog"); // now that we have validated the data, we can proceed to create the user, making // sure that it doesn't already exists $users = new Users(); $userInfo = $users->userExists($this->_userName); if ($userInfo) { $this->_form->setFieldValidationStatus("userName", false); $this->_view = new AdminAddUserView($this->_blogInfo); $this->setCommonData(true); return false; } // otherwise, we can create a new one $user = new UserInfo($this->_userName, $this->_userPassword, $this->_userEmail, "", $this->_userFullName, 0, $this->_properties); $user->setStatus($this->_userStatus); $this->notifyEvent(EVENT_PRE_USER_ADD, array("user" => &$user)); $newUserId = $users->addUser($user); if (!$newUserId) { $this->_view = new AdminAddUserView($this->_blogInfo); $this->_form->setFieldValidationStatus("userName", false); $this->setCommonData(true); return false; } // if the userBlog parameter is different than 0, we have to add a relationship // between that user and the blog if ($this->_userBlog > 0) { $permissions = new UserPermissions(); $result = $permissions->grantPermission($newUserId, $this->_userBlog, PERMISSION_BLOG_USER); } $this->notifyEvent(EVENT_POST_USER_ADD, array("user" => &$user)); $this->_view = new AdminSiteUsersListView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->pr("user_added_ok", $user->getUsername())); $this->setCommonData(); return true; }
/** * Given a result record from a Execute call, it will fill in the * fields of the object, so that we don't have to repeat the same * code too many times */ function _fillUserInformation($query_result, $extraInfo = false) { $userInfo = new UserInfo($query_result["user"], $query_result["password"], $query_result["email"], $query_result["about"], $query_result["full_name"], $query_result["resource_picture_id"], unserialize($query_result["properties"]), $query_result["id"]); if ($extraInfo) { // load this data if explicitely required! $userBlogs = $this->getUsersBlogs($userInfo->getId()); $userInfo->setBlogs($userBlogs); } // set some permissions //$userInfo->setSiteAdmin($this->perms->isSiteAdmin( $userInfo->getId())); $userInfo->setSiteAdmin($query_result["site_admin"]); $userInfo->setStatus($query_result["status"]); return $userInfo; }