예제 #1
0
 /**
  * Register the user in session and with the user tables in the database
  * and then forwards them to the return url
  * 
  * @param User $user  [optional] user object
  */
 public function register(User $user = null)
 {
     // if passed in externally
     if ($user != null) {
         $this->user = $user;
     }
     // data map
     $datamap_users = new Users();
     $datamap_records = new SavedRecords();
     // if the user was previously active under a local username
     // then reassign any saved records to the new username
     $old_username = $this->request->getSessionData("username");
     $old_role = $this->request->getSessionData("role");
     if ($old_role == "local") {
         $datamap_records->reassignRecords($old_username, $this->user->username);
     }
     // add or update user in the database
     // get any values in the db not specified here and populates user
     $this->user = $datamap_users->touchUser($this->user);
     // @todo: reconcile this code with User code
     // should we just save user object in session?
     // set main properties in session
     $admins = explode(',', $this->registry->getConfig('ADMIN_USERS'));
     if (in_array($this->user->username, $admins)) {
         $this->request->setSessionData("user_admin", true);
     }
     $this->request->setSessionData("username", $this->user->username);
     $this->request->setSessionData("role", $this->role);
     // store user's additional properties in session, so they can be used by
     // controller, and included in xml for views.
     $this->request->setSessionData("user_properties", $this->user->properties());
     // groups too empty array not null please.
     $this->request->setSessionData("user_groups", $this->user->usergroups);
     // set this object's id in session
     $this->request->setSessionData("auth", $this->id);
     // now forward them to the return url
     return $this->redirectTo($this->return_url);
 }
예제 #2
0
파일: Scheme.php 프로젝트: navtis/xerxes
 /**
  * Registers the user in session and with the user tables in the database
  * and then forwards them to the return url
  */
 public function register()
 {
     // data map
     $datamap_users = new Users();
     $datamap_records = new SavedRecords();
     // if the user was previously active under a local username
     // then reassign any saved records to the new username
     $old_username = $this->request->getSessionData("username");
     $old_role = $this->request->getSessionData("role");
     if ($old_role == "local") {
         $datamap_records->reassignRecords($old_username, $this->user->username);
     }
     // add or update user in the database
     // get any values in the db not specified here and populates user
     $this->user = $datamap_users->touchUser($this->user);
     // @todo: should we just save user object in session?
     // set main properties in session
     $this->request->setSessionData("username", $this->user->username);
     $this->request->setSessionData("role", $this->role);
     // store user's additional properties in session, so they can be used by
     // controller, and included in xml for views.
     $this->request->setSessionData("user_properties", $this->user->properties());
     // groups too empty array not null please.
     $this->request->setSessionData("user_groups", $this->user->usergroups);
     // set this object's id in session
     $this->request->setSessionData("auth", $this->id);
     // now forward them to the return url
     $this->setRedirect($this->return_url);
     return self::SUCCESS;
 }