.

UserBaseController Class Reference
[Usermanagement]

Basic user controller, offers log in, logout etc. More...

Inheritance diagram for UserBaseController:
ControllerBase IController IEventSink

List of all members.

Public Member Functions

  action_dashboard ($page_data)
  Show dashboard, depending on user logged in.
  action_login ($page_data)
  Builds and process login page.
  action_logout ($page_data)
  Logs out.
  action_lost_password ($page_data)
  Lost password page.
  action_register ($page_data)
  Builds and process the register page.
  action_resend_registration_mail ($page_data)
  Page for resending registration e-mail.
  action_user_delete_account ($page_data)
  Deletes account.
  action_users_confirm ($page_data)
  Confirm account settings.
  action_users_confirm_mail ($page_data)
  Showe page stating email verification mail has been sent.
  action_users_create ($page_data)
  Create user.
  action_users_edit ($page_data, $id)
  Edit account settings.
  action_users_edit_self ($page_data)
  Edit account settings.
  action_users_list_all ($page_data)
  List all user data.
  action_users_list_confirmations ($page_data)
  List all unconfirmed users.
  before_action ()
  Activates includes before action to reduce cache memory.
  get_routes ()
  Return array of IDispatchToken this controller takes responsability.
  on_event ($name, $params, &$result)
  Process events.
  preprocess ($page_data)
  Invoked after setting data and before actions are processed.

Public Attributes

const  ALL_FEATURES = 255
const  ALLOW_LOGIN = 8
const  ALLOW_LOST_PASSWORD = 2
const  ALLOW_REGISTER = 1
const  ALLOW_RESEND_REGISTRATION = 4
const  SUPPORT_CONFIRM_DATA = 32
  Force user to confirm data, if TOS or email is not up to date.
const  SUPPORT_DASHBOARD = 16
const  SUPPORT_TOS = 64
  Display a TOS checkbox on register.

Protected Member Functions

  check_login_preconditions ()
  Check if cookies are enabled and if user is not logged in.
  create_dashboards ($user)
  Create a dashboard for given user.
  create_user_block_menu_list ($user)
  Returns menu list.
  create_user_block_postfix ($user)
  Postfix text of block.
  create_user_block_prefix ($user)
  Prefix text of block.
  do_confirm ($formhandler, $user, $page_data)
  Change account data of current user.
  do_create ($formhandler, $page_data)
  Do create a user.
  do_delete_account ($formhandler, $page_data)
  Process delete account request.
  do_edit ($formhandler, $user, $page_data)
  Change account data of user.
  do_edit_self ($formhandler, $user, $page_data)
  Change account data of current user.
  do_login ($formhandler, $page_data)
  Does the login, as a result of a POST request.
  do_lost_password ($formhandler, $page_data)
  Processes the lost_password POST request.
  do_register ($formhandler, $page_data)
  Processes the register POST request.
  do_resend_registration_mail (FormHandler $formhandler, PageData $page_data)
  Processes the resend_registration_mail POST request.
  do_user_block ()
  Build the user block.
  get_block_title ($user)
  Returns title for user block.
  get_features_policy ()
  Returns a set of bitflags defining the features supported.
  has_feature ($feature)
  prepare_confirm_view ($view, $formhandler, $user)
  Prepare confirmation view.
  process_confirm_data (&$params, $tos, $user, &$validate_email_cmd)
  validate_email_change ($params, $user, $pwd)
  Validate password for email change.
  validate_password (&$arr_post)
  Validate if password is set and if it is confirmed.

Protected Attributes

  $dashboards = null

Detailed Description

Basic user controller, offers log in, logout etc.

Attention:
You must subclass this to enable user management.

Overload get_features_policy() to enable or disable featured

Author:
Gerd Riesselmann

Definition at line 12 of file user.basecontroller.php.


Member Function Documentation

UserBaseController::action_dashboard ( page_data  ) 

Show dashboard, depending on user logged in.

Definition at line 381 of file user.basecontroller.php.

00381                                                      {
00382                 if (Users::is_logged_in() == false) {
00383                         return CONTROLLER_ACCESS_DENIED;
00384                 }
00385                 
00386                 $dashboards = $this->create_dashboards(Users::get_current_user());
00387                 if ($dashboards) {
00388                         $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/dashboard', $page_data);
00389                         $view->assign('dashboards', $dashboards);
00390                         $view->render();
00391                 }
00392                 else {
00393                         return CONTROLLER_INTERNAL_ERROR;
00394                 }
00395         }
UserBaseController::action_login ( page_data  ) 

Builds and process login page.

Parameters:
PageData  $page_data

Definition at line 260 of file user.basecontroller.php.

00260                                                  {
00261                 $err = $this->check_login_preconditions();
00262                 if ($err->is_error()) {
00263                         $page_data->error($err);
00264                         return;
00265                 }
00266 
00267                 $formhandler = new FormHandler('login');
00268                 if ($page_data->has_post_data()) {
00269                         $this->do_login($formhandler, $page_data);
00270                 }
00271 
00272                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'core::users/login', $page_data);
00273                 $formhandler->prepare_view($view);
00274                 $view->assign('goto', Session::peek('login_goto'));
00275                 $view->render();
00276 
00277                 $page_data->in_history = false;
00278         }
UserBaseController::action_logout ( page_data  ) 

Logs out.

Definition at line 283 of file user.basecontroller.php.

00283                                                   {
00284                 Users::logout();
00285                 History::go_to(0, new Message(tr('You have been logged out', 'users')), Config::get_url(Config::URL_DEFAULT_PAGE));
00286                 exit;
00287         }
UserBaseController::action_lost_password ( page_data  ) 

Lost password page.

Definition at line 337 of file user.basecontroller.php.

00337                                                          {
00338                 $err = $this->check_login_preconditions();
00339                 if ($err->is_error()) {
00340                         $page_data->error($err);
00341                         return;
00342                 }
00343 
00344                 $formhandler = new FormHandler('lost_password');
00345                 if ($page_data->has_post_data()) {
00346                         $this->do_lost_password($formhandler, $page_data);
00347                 }
00348 
00349                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/lost_password', $page_data);
00350                 $formhandler->prepare_view($view);
00351                 $view->render();
00352 
00353                 $page_data->in_history = false;
00354         }
UserBaseController::action_register ( page_data  ) 

Builds and process the register page.

Definition at line 312 of file user.basecontroller.php.

00312                                                     {
00313                 $err = $this->check_login_preconditions();
00314                 if ($err->is_error()) {
00315                         $page_data->error($err);
00316                         return;
00317                 }
00318 
00319                 $formhandler = new FormHandler('register');
00320                 if ($page_data->has_post_data()) {
00321                         $this->do_register($formhandler, $page_data);
00322                 }
00323 
00324                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/register', $page_data);
00325                 $view->assign('feature_resend', $this->has_feature(self::ALLOW_RESEND_REGISTRATION));
00326                 $view->assign('feature_tos', $this->has_feature(self::SUPPORT_TOS));
00327 
00328                 $formhandler->prepare_view($view);
00329                 $view->render();
00330 
00331                 $page_data->in_history = false;
00332         }
UserBaseController::action_resend_registration_mail ( page_data  ) 

Page for resending registration e-mail.

Definition at line 359 of file user.basecontroller.php.

00359                                                                     {
00360                 $err = $this->check_login_preconditions();
00361                 if ($err->is_error()) {
00362                         $page_data->error($err);
00363                         return;
00364                 }
00365 
00366                 $formhandler = new FormHandler('resend_registration');
00367                 if ($page_data->has_post_data()) {
00368                         $this->do_resend_registration_mail($formhandler, $page_data);
00369                 }
00370 
00371                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/resend_registration_mail', $page_data);
00372                 $formhandler->prepare_view($view);
00373                 $view->render();
00374 
00375                 $page_data->in_history = false;
00376         }
UserBaseController::action_user_delete_account ( page_data  ) 

Deletes account.

Definition at line 292 of file user.basecontroller.php.

00292                                                                {
00293                 if (Users::current_has_role(USER_ROLE_USER) == false) {
00294                         return self::ACCESS_DENIED;
00295                 }
00296                 
00297                 $formhandler = new FormHandler('delete_account');
00298                 if ($page_data->has_post_data()) {
00299                         $this->do_delete_account($formhandler, $page_data);
00300                 }
00301 
00302                 $view = content_view_create('user_delete_account', $page_data);
00303                 $formhandler->prepare_view($view);
00304                 $view->render();
00305 
00306                 $page_data->in_history = false;
00307         } 
UserBaseController::action_users_confirm ( page_data  ) 

Confirm account settings.

Definition at line 571 of file user.basecontroller.php.

00571                                                          {
00572                 $page_data->in_history = false;
00573                 
00574                 // User exists, since Route is for logged in only
00575                 Users::reload_current();
00576                 $user = Users::get_current_user();
00577                 $formhandler = new FormHandler('users_confirm');
00578                 if ($page_data->has_post_data()) {
00579                         $this->do_confirm($formhandler, $user, $page_data);
00580                 }
00581                 
00582                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/confirm', $page_data);
00583                 $this->prepare_confirm_view($view, $formhandler, $user);
00584                 $view->render();
00585         }
UserBaseController::action_users_confirm_mail ( page_data  ) 

Showe page stating email verification mail has been sent.

Definition at line 658 of file user.basecontroller.php.

00658                                                               {
00659                 // User exists, since Route is for logged in only
00660                 $page_data->in_history = false;
00661                 Users::reload_current();
00662                 $user = Users::get_current_user();
00663                 if ($user->confirmed_email()) {
00664                         History::go_to(0);
00665                 }
00666                 else {
00667                         $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/confirm_mail', $page_data);
00668                         $view->assign('user' , $user);
00669                         $view->render();
00670                 }
00671         }       
UserBaseController::action_users_create ( page_data  ) 

Create user.

Definition at line 400 of file user.basecontroller.php.

00400                                                         {
00401                 $formhandler = new FormHandler('user_create');
00402                 if ($page_data->has_post_data()) {
00403                         $this->do_create($formhandler, $page_data);
00404                 }
00405 
00406                 $page_data->in_history = false;
00407                 
00408                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/create', $page_data);    
00409                 $roleOptions = Users::get_user_roles();
00410                 $view->assign('role_options', $roleOptions);    
00411                 $view->assign('user', $user);
00412                 $formhandler->prepare_view($view, $user);
00413                 
00414                 $view->render();
00415         }
UserBaseController::action_users_edit ( page_data,
id  
)

Edit account settings.

Definition at line 440 of file user.basecontroller.php.

00440                                                            {
00441                 $user = Users::get($id);
00442                 if ($user == false) {
00443                         return self::NOT_FOUND;
00444                 }
00445                 foreach($user->get_roles() as $role) {
00446                         $user->roles[] = $role->id;
00447                 }       
00448                 
00449                 $formhandler = new FormHandler('edit_account');
00450                 if ($page_data->has_post_data()) {
00451                         $this->do_edit($formhandler, $user, $page_data);
00452                 }
00453 
00454                 $page_data->in_history = false;
00455                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/edit', $page_data);      
00456                                         
00457                 //smarty option list for user role
00458                 $roleOptions = Users::get_user_roles();
00459                 $view->assign('role_options', $roleOptions);    
00460                 $view->assign('user', $user);
00461                 
00462                 $formhandler->prepare_view($view, $user);
00463                 
00464                 $view->render();
00465         }
UserBaseController::action_users_edit_self ( page_data  ) 

Edit account settings.

Definition at line 513 of file user.basecontroller.php.

00513                                                            {
00514                 // User exists, since Route is for logged in only
00515                 Users::reload_current();
00516                 $user = Users::get_current_user();
00517                 $formhandler = new FormHandler('edit_account_self');
00518                 if ($page_data->has_post_data()) {
00519                         $this->do_edit_self($formhandler, $user, $page_data);
00520                 }
00521 
00522                 $page_data->in_history = false;
00523                 
00524                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/edit_self', $page_data);
00525                 $formhandler->prepare_view($view, $user);
00526                 $view->assign('user', $user);
00527                 $view->render();
00528         }
UserBaseController::action_users_list_all ( page_data  ) 

List all user data.

Definition at line 676 of file user.basecontroller.php.

00676                                                           {
00677                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'users/list', $page_data);
00678                 $users = Users::create_all_user_adapter();
00679                 
00680                 Load::tools(array('sorter', 'filter', 'filterusername', 'pager'));
00681                 $sorter = new Sorter($page_data, $users->get_sortable_columns(), $users->get_sort_default_column());
00682                 $sorter->apply($users);
00683                 $sorter->prepare_view($view);
00684                 
00685                 $filter = new Filter($page_data, $users->get_filters());
00686                 $filter->apply($users);
00687                 $filter->prepare_view($view);
00688 
00689                 $filtertext = new FilterUsername($page_data);
00690                 $filtertext->apply($users);
00691                 $filtertext->prepare_view($view);
00692                 
00693                 $count_users = $users->count();
00694                 $pager = new Pager($page_data, $count_users, Config::get_value(Config::ITEMS_PER_PAGE));
00695                 $pager->apply($users);
00696                 $pager->prepare_view($view);
00697 
00698                 $view->assign('users', $users->execute());      
00699                 $view->render();
00700         }
UserBaseController::action_users_list_confirmations ( page_data  ) 

List all unconfirmed users.

This is a placeholder for a filtered user list, and gets redircted to user_list_all

Definition at line 707 of file user.basecontroller.php.

00707                                                                     {
00708                 Load::tools(array('sorter', 'filter', 'filtertext', 'pager'));
00709                 $url = Url::current()->set_path(ActionMapper::get_path('users_list_all'));
00710                 Filter::apply_to_url($url, 'unconfirmed', 'status');
00711                 $url->redirect();
00712         }
UserBaseController::before_action (  ) 

Activates includes before action to reduce cache memory.

Reimplemented from ControllerBase.

Definition at line 127 of file user.basecontroller.php.

00127                                         {
00128                 Load::tools(array('formhandler', 'filtertext'));
00129         }
UserBaseController::check_login_preconditions (  )  [protected]

Check if cookies are enabled and if user is not logged in.

Definition at line 717 of file user.basecontroller.php.

00717                                                        {
00718                 $ret = new Status();
00719                 //if (Session::cookies_enabled() == false) {
00720                 //      $ret->append('Bitte schalte in den Browsereinstellungen Cookies ein.');
00721                 //}
00722                 if (Users::is_logged_in()) {
00723                         $ret->append(tr('Already logged in', 'users'));
00724                 }
00725                 return $ret;
00726         }
UserBaseController::create_dashboards ( user  )  [protected]

Create a dashboard for given user.

Parameters:
DAOUsers  $user
Returns:
IDashboard

Definition at line 91 of file user.basecontroller.php.

00091                                                     {
00092                 if (empty($user) || !$this->has_feature(self::SUPPORT_DASHBOARD)) {
00093                         return null;
00094                 }
00095                 
00096                 $ret = array();
00097 
00098                 foreach ($user->get_role_names() as $role) {
00099                         $role = String::plain_ascii($role);
00100                         $dashboard_file = 'controller/tools/dashboards/' .  $role . '.dashboard.php';
00101                         $dashboard_class = ucfirst($role) . 'Dashboard';
00102                         $found = Load::first_file($dashboard_file);
00103                         if ($found) {
00104                                 $ret[] = new $dashboard_class($user);
00105                         }
00106                 }
00107                 
00108                 // Add default dashboard
00109                 $dashboard_file =  'controller/tools/dashboards/default.dashboard.php';
00110                 Load::first_file($dashboard_file);
00111                 $ret[] = new DefaultDashboard($user);
00112 
00113                 return $ret;
00114         }
UserBaseController::create_user_block_menu_list ( user  )  [protected]

Returns menu list.

Parameters:
DAOUsers  $user NULL if logged out
Returns:
array

Definition at line 198 of file user.basecontroller.php.

00198                                                               {
00199                 $li = array();
00200                 if ($user) {
00201                         if ($this->dashboards) {
00202                                 $li[] = html::a(
00203                                         tr('Your personal site', 'users'), 
00204                                         ActionMapper::get_url('dashboard', $user),
00205                                         ''
00206                                 );
00207                                 foreach($this->dashboards as $dashboard) {
00208                                         $li = array_merge($li, $dashboard->get_user_menu_entries());
00209                                 }
00210                         }
00211                 }
00212                 else {
00213                         if ($this->has_feature(self::ALLOW_LOGIN)) {
00214                                 $li[] = html::a(
00215                                         tr('Login', 'users'), 
00216                                         ActionMapper::get_url('login'), 
00217                                         tr('Log into %app%', 'users', array('%app%' => Config::get_value(Config::TITLE)))
00218                                 );
00219                         }
00220                         if ($this->has_feature(self::ALLOW_REGISTER)) {
00221                                 $li[] = html::a(
00222                                         tr('Register', 'users'), 
00223                                         ActionMapper::get_url('register'), 
00224                                         tr('Registered user can add and edit entries', 'users')
00225                                 );
00226                         }
00227                         
00228                 }               
00229                 return $li;
00230         }
UserBaseController::create_user_block_postfix ( user  )  [protected]

Postfix text of block.

Parameters:
DAOUsers  $user NULL if logged out
Returns:
string

Definition at line 238 of file user.basecontroller.php.

00238                                                             {
00239                 $ret = '';
00240                 if ($user) {
00241                         $ret .= html::form(
00242                                 'frmlogout', 
00243                                 ActionMapper::get_url('logout'), 
00244                                 html::submit(
00245                                         tr('Logout', 'users'),
00246                                         'btnlogout', 
00247                                         tr('Quit %app%', 'users', array('%app%' => Config::get_value(Config::TITLE)))
00248                                 )
00249                         );
00250                 }
00251                 return $ret;                            
00252         }
UserBaseController::create_user_block_prefix ( user  )  [protected]

Prefix text of block.

Parameters:
DAOUsers  $user NULL if logged out
Returns:
string

Definition at line 179 of file user.basecontroller.php.

00179                                                            {
00180                 $ret = '';
00181                 if ($user) {
00182                         $block_text = tr(
00183                                 'Logged in as %user%', 
00184                                 'users', 
00185                                 array('%user%' => html::span($user->name, 'logged_in_as'))
00186                         );
00187                         $ret = html::p($block_text, 'logged_in_as');
00188                 }
00189                 return $ret;            
00190         }
UserBaseController::do_confirm ( formhandler,
user,
page_data  
) [protected]

Change account data of current user.

Parameters:
FormHandler  $formhandler
DAOUsers  $user
PageData  $page_data

Definition at line 608 of file user.basecontroller.php.

00608                                                                        {
00609                 $validate_email_cmd = false;
00610                 $err = $formhandler->validate();
00611                 if ($err->is_ok()) {
00612                         $post = $page_data->get_post();
00613                         $err->merge($this->process_confirm_data($post->get_array(), $post->get_item('tos'), $user, $validate_email_cmd));
00614                         
00615                         // Update
00616                         if ($err->is_ok()) {
00617                                 $err->merge(Users::update($user, $params));
00618                         }                        
00619                         
00620                         if ($validate_email_cmd && $err->is_ok()) {
00621                                 $err->merge($validate_email_cmd->execute());    
00622                         }
00623                 }
00624                 $formhandler->finish($err, tr('Your changes have been saved', 'users'));
00625         }
UserBaseController::do_create ( formhandler,
page_data  
) [protected]

Do create a user.

Parameters:
FormHandler  $formhandler
PageData  $page_data

Definition at line 423 of file user.basecontroller.php.

00423                                                                {
00424                 $err = $formhandler->validate();
00425                 if ($err->is_ok()) {
00426                         // Validate
00427                         $params = $page_data->get_post()->get_array();
00428                         $err->merge($this->validate_password($params));
00429                         if ($err->is_ok()) {
00430                                 $dummy = false;
00431                                 $err->merge(Users::create($params, $dummy));
00432                         }
00433                 }
00434                 $formhandler->finish($err, tr('The new user has been created', 'users'));
00435         }
UserBaseController::do_delete_account ( formhandler,
page_data  
) [protected]

Process delete account request.

Definition at line 760 of file user.basecontroller.php.

00760                                                                        {
00761                 $err = $formhandler->validate();
00762                 if ($err->is_ok()) {
00763                         // Validate
00764                         $cmd = CommandsFactory::create_command(Users::get_current_user(), 'status', USER_STATUS_DELETED);
00765                         $err->merge($cmd->execute());
00766 
00767                         if ($err->is_ok()) {
00768                                 // Back to where we came from
00769                                 Users::logout();
00770                                 $msg = new Message(tr('Your account has been deleted', 'users'));
00771                                 $msg->persist();
00772                                 Url::create(Config::get_url(Config::URL_BASEURL))->redirect();
00773                                 exit;
00774                         }
00775                 }
00776                 // At this point we habe an error. Do post fix (redirects)
00777                 $formhandler->fix_post_history($err);
00778                 exit;           
00779         } 
UserBaseController::do_edit ( formhandler,
user,
page_data  
) [protected]

Change account data of user.

Parameters:
FormHandler  $formhandler
DAOUsers  $user
PageData  $page_data

Definition at line 497 of file user.basecontroller.php.

00497                                                                     {
00498                 $err = $formhandler->validate();
00499                 if ($err->is_ok()) {
00500                         // Validate
00501                         $params = $page_data->get_post()->get_array();
00502                         $err->merge($this->validate_password($params));
00503                         if ($err->is_ok()) {
00504                                 $err->merge(Users::update($user, $params));
00505                         }
00506                 }
00507                 $formhandler->finish($err, tr('Your changes have been saved', 'users'));
00508         }
UserBaseController::do_edit_self ( formhandler,
user,
page_data  
) [protected]

Change account data of current user.

Parameters:
FormHandler  $formhandler
DAOUsers  $user
PageData  $page_data

Definition at line 537 of file user.basecontroller.php.

00537                                                                          {
00538                 $err = $formhandler->validate();
00539                 if ($err->is_ok()) {
00540                         // Validate
00541                         $params = $user->unset_internals($page_data->get_post()->get_array());
00542                         $err->merge($this->validate_email_change($params, $user, $page_data->get_post()->get_item('pwd_mail')));
00543                         $err->merge($this->validate_password($params));
00544                         if ($err->is_ok()) {
00545                                 $err->merge(Users::update($user, $params));
00546                         }
00547                 }
00548                 $formhandler->finish($err, tr('Your changes have been saved', 'users'));
00549         }
UserBaseController::do_login ( formhandler,
page_data  
) [protected]

Does the login, as a result of a POST request.

Returns:
Status Error

Definition at line 733 of file user.basecontroller.php.

00733                                                               {
00734                 $err = $formhandler->validate();
00735                 if ($err->is_ok()) {
00736                         $post = $page_data->get_post();
00737                         $permanent = $post->get_item('stayloggedin', false) != false;
00738 
00739                         $err->merge(Users::login($post->get_array(), $permanent));
00740                         if ($err->is_ok()) {
00741                                 $goto = $post->get_item('goto', '');
00742                                 if ($goto) {
00743                                         // Go to specific URL (force it to be same domain, though!)
00744                                         $goto_url = Url::create($goto)->set_host(Config::get_value(Config::URL_DOMAIN));
00745                                         History::push($goto_url->build(Url::ABSOLUTE));
00746                                 }
00747                                 else if ($this->has_feature(self::SUPPORT_DASHBOARD)) {
00748                                         History::push(Config::get_url(ConfigUsermanagement::DEFAULT_PAGE));
00749                                 }
00750                                 Session::pull('login_goto');
00751                         }
00752                 }
00753                 $formhandler->finish($err, tr('Welcome! You are now logged in.', 'users'));
00754                 exit;
00755         }
UserBaseController::do_lost_password ( formhandler,
page_data  
) [protected]

Processes the lost_password POST request.

Definition at line 813 of file user.basecontroller.php.

00813                                                                       {
00814                 $err = $formhandler->validate();
00815                 if ($err->is_ok()) {
00816                         // Validate
00817                         $post = $page_data->get_post();;
00818                         $email = $post->get_item('email');
00819                         $err->merge(Users::lost_password($email));
00820                 }
00821                 $formhandler->finish($err, tr('Your one time login request has been created', 'users'));
00822                 exit;
00823         }
UserBaseController::do_register ( formhandler,
page_data  
) [protected]

Processes the register POST request.

Sets Session::Status on error

Definition at line 786 of file user.basecontroller.php.

00786                                                                  {
00787                 $err = $formhandler->validate();
00788                 if ($err->is_ok()) {
00789                         // Validate
00790                         $post = $page_data->get_post();;
00791                         $pwd1 = $post->get_item('pwd1');
00792                         $pwd2 = $post->get_item('pwd2');
00793                         if ($pwd1 != $pwd2) {
00794                                 $err->append(tr('Password and password confirmation are different', 'users'));
00795                         }
00796                         
00797                         if ($this->has_feature(self::SUPPORT_TOS) && !$post->get_item('tos')) {
00798                                 $err->append(tr('Please agree to the Terms of Service.', 'users'));
00799                         }
00800                         
00801                         if ($err->is_ok()) {
00802                                 $result = false;
00803                                 $err->merge(Users::register(trim($post->get_item('name')), $pwd1, trim($post->get_item('email')), $result));
00804                         }
00805                 }
00806                 $formhandler->finish($err, tr('Your registration request has been created', 'users'));
00807                 exit;
00808         }
UserBaseController::do_resend_registration_mail ( FormHandler formhandler,
PageData page_data  
) [protected]

Processes the resend_registration_mail POST request.

Definition at line 828 of file user.basecontroller.php.

00828                                                                                                       {
00829                 $err = $formhandler->validate();
00830                 if ($err->is_ok()) {
00831                         // Validate
00832                         $post = $page_data->get_post();;
00833                         $email = $post->get_item('email');
00834                         $err->merge(Users::resend_registration_mail($email));
00835                 }
00836                 // At this point we habe an error. Do post fix (redirects)
00837                 $formhandler->finish($err, tr('Your activation information mail has been send to you again', 'users'));
00838                 exit;
00839         }
UserBaseController::do_user_block (  )  [protected]

Build the user block.

Returns:
BlockBase

Definition at line 148 of file user.basecontroller.php.

00148                                            {
00149                 $user = Users::is_logged_in() ? Users::get_current_user() : NULL;
00150                 $block = new BlockBase('user', $this->get_block_title($user), '');
00151                 
00152                 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'users/blocks/menu');
00153                 $view->assign('user', $user);
00154                 $view->assign('prefix', $this->create_user_block_prefix($user));
00155                 $view->assign('menu_list', $this->create_user_block_menu_list($user));
00156                 $view->assign('postfix', $this->create_user_block_postfix($user));
00157                 $view->assign('block', $block);
00158                 
00159                 $block->set_content($view->render());
00160                 return $block;
00161         } 
UserBaseController::get_block_title ( user  )  [protected]

Returns title for user block.

Parameters:
DAOUsers  $user
Returns:
string

Definition at line 169 of file user.basecontroller.php.

00169                                                   {
00170                  return tr('User Menu', 'users');
00171         }
UserBaseController::get_features_policy (  )  [protected]

Returns a set of bitflags defining the features supported.

Returns:
int

Definition at line 77 of file user.basecontroller.php.

00077                                                  {
00078                 return self::ALL_FEATURES ^ self::SUPPORT_TOS;
00079         }
UserBaseController::get_routes (  ) 

Return array of IDispatchToken this controller takes responsability.

Reimplemented from ControllerBase.

Definition at line 40 of file user.basecontroller.php.

00040                                      {
00041                 $ret = array(
00042                         'logout' => new ExactMatchRoute('https://logout', $this, 'logout', new NoCacheCacheManager()),
00043                         'edit_self' => new ExactMatchRoute('https://user/edit', $this, 'users_edit_self', new AccessRenderDecorator()),
00044                         'delete_account' => new ExactMatchRoute('https://user/delete_account', $this, 'users_delete_account', new AccessRenderDecorator()),
00045                         'create' => new ExactMatchRoute('https://user/create', $this, 'users_create', new AccessRenderDecorator(USER_ROLE_ADMIN)),
00046                         'edit' => new ParameterizedRoute('https://user/{id:ui>}/edit', $this, 'users_edit', new AccessRenderDecorator(USER_ROLE_ADMIN)),
00047                         'list_all' => new ExactMatchRoute('https://user/list', $this, 'users_list_all', new AccessRenderDecorator(USER_ROLE_ADMIN)),
00048                         'list_confirmations' => new ExactMatchRoute('https://user/confirmations', $this, 'users_list_confirmations', new AccessRenderDecorator(USER_ROLE_ADMIN)),
00049                 );
00050                 if ($this->has_feature(self::ALLOW_LOGIN)) {
00051                         $ret['login'] = new ExactMatchRoute('https://login', $this, 'login', new NoCacheCacheManager());
00052                 }
00053                 if ($this->has_feature(self::ALLOW_REGISTER)) {
00054                         $ret['register'] = new ExactMatchRoute('https://register', $this, 'register', new NoCacheCacheManager());
00055                 }
00056                 if ($this->has_feature(self::ALLOW_LOST_PASSWORD)) {
00057                         $ret['lost_password'] = new ExactMatchRoute('https://lost-password', $this, 'lost_password', new NoCacheCacheManager());
00058                 }
00059                 if ($this->has_feature(self::ALLOW_REGISTER | self::ALLOW_RESEND_REGISTRATION)) {
00060                         $ret['resend_registration_mail'] = new ExactMatchRoute('https://resend-registration-mail', $this, 'resend_registration_mail', new NoCacheCacheManager());
00061                 }
00062                 if ($this->has_feature(self::SUPPORT_DASHBOARD)) {
00063                         $ret['dashboard'] = new ExactMatchRoute('https://user', $this, 'dashboard', new AccessRenderDecorator());
00064                 }
00065                 if ($this->has_feature(self::SUPPORT_CONFIRM_DATA)) {
00066                         $ret['confirm'] = new ExactMatchRoute('https://user/confirm', $this, 'users_confirm', new AccessRenderDecorator());
00067                         $ret['confirm_mail'] = new ExactMatchRoute('https://user/confirm/mail', $this, 'users_confirm_mail', new AccessRenderDecorator());
00068                 }
00069                 return $ret;
00070         }
UserBaseController::has_feature ( feature  )  [protected]

Definition at line 81 of file user.basecontroller.php.

00081                                                  {
00082                 return Common::flag_is_set($this->get_features_policy(), $feature);
00083         }
UserBaseController::on_event ( name,
params,
&$  result  
)

Process events.

Events processed are:

  • cron with param "orders": Prepares orders of newly requested categores for entries

Reimplemented from ControllerBase.

Definition at line 137 of file user.basecontroller.php.

00137                                                            {
00138                 if ($name == 'block' && $params['name'] === 'user') {
00139                         $result[] = $this->do_user_block(); 
00140                 }
00141         }
UserBaseController::prepare_confirm_view ( view,
formhandler,
user  
) [protected]

Prepare confirmation view.

Parameters:
IView  $view
FormHandler  $formhandler
DAOUsers  $user

Definition at line 594 of file user.basecontroller.php.

00594                                                                             {
00595                 $formhandler->prepare_view($view, $user);
00596                 $view->assign('user', $user);
00597                 $view->assign('do_tos', $this->has_feature(self::SUPPORT_TOS) && !$user->confirmed_tos());
00598                 $view->assign('do_email', !$user->confirmed_email());           
00599         }
UserBaseController::preprocess ( page_data  ) 

Invoked after setting data and before actions are processed.

Reimplemented from ControllerBase.

Definition at line 119 of file user.basecontroller.php.

00119                                                {
00120                 $this->dashboards = $this->create_dashboards(Users::get_current_user());
00121                 parent::preprocess($page_data);
00122         }
UserBaseController::process_confirm_data ( &$  params,
tos,
user,
&$  validate_email_cmd  
) [protected]

Definition at line 627 of file user.basecontroller.php.

00627                                                                                              {
00628                 $err = new Status();
00629                 
00630                 // Check for TOS
00631                 if($this->has_feature(self::SUPPORT_TOS) && !$user->confirmed_tos() && !$tos) {
00632                         $err->append(tr('Please agree to the Terms of Service.', 'users'));                             
00633                 }
00634                 // Validate
00635                 $params = $user->unset_internals($params);
00636                 $params['tos_version'] = Config::get_value(ConfigUsermanagement::TOS_VERSION);
00637                 $err->merge($this->validate_password($params));
00638                 
00639                 // If email is not validated, validate it
00640                 $email = Arr::get_item($params, 'email', '');
00641                 if (!$user->confirmed_email() && ($user->email == $email) && Validation::is_email($email)) {
00642                         // Send email validation request
00643                         $params = array(
00644                                 'id_item' => $user->id,
00645                                 'action' => 'validateemail',
00646                                 'data' => $email
00647                         );
00648                         Session::push('user_confirm_mail_send', true);
00649                         $validate_email_cmd = CommandsFactory::create_command('confirmations', 'create', $params);
00650                 }
00651                 
00652                 return $err;
00653         }
UserBaseController::validate_email_change ( params,
user,
pwd  
) [protected]

Validate password for email change.

Parameters:
array  $params
DAOUsers  $user
string  $pwd

Definition at line 558 of file user.basecontroller.php.

00558                                                                        {
00559                 $err = new Status();
00560                 if (Config::has_feature(ConfigUsermanagement::ENABLE_PWD_ON_EMAILCHANGE) && $params['email'] != $user->email) {
00561                         if (!Users::get_current_user()->password_match($pwd)) {
00562                                 $err->append(tr('The password entered for email change confirmation is not correct. Please try again.', 'users'));      
00563                         }
00564                 }       
00565                 return $err;    
00566         }
UserBaseController::validate_password ( &$  arr_post  )  [protected]

Validate if password is set and if it is confirmed.

Parameters:
array  $arr_post
Returns:
Status

Definition at line 473 of file user.basecontroller.php.

00473                                                          {
00474                 $ret = new Status();
00475                 // Validate
00476                 $pwd1 = Arr::get_item($arr_post, 'pwd1', '');
00477                 $pwd2 = Arr::get_item($arr_post, 'pwd2', '');
00478                 if ($pwd1 != $pwd2) {
00479                         $ret->append(tr('Password and password confirmation are different', 'users'));
00480                 }
00481                 
00482                 if ($ret->is_ok()) {
00483                         if ($pwd1 !== '') {
00484                                 $arr_post['password'] = $pwd1;
00485                         }
00486                 }
00487                 return $ret;                    
00488         }

Member Data Documentation

UserBaseController::$dashboards = null [protected]

Definition at line 35 of file user.basecontroller.php.

Definition at line 28 of file user.basecontroller.php.

Definition at line 16 of file user.basecontroller.php.

Definition at line 13 of file user.basecontroller.php.

Force user to confirm data, if TOS or email is not up to date.

Definition at line 22 of file user.basecontroller.php.

Definition at line 17 of file user.basecontroller.php.

Display a TOS checkbox on register.

Definition at line 26 of file user.basecontroller.php.


The documentation for this class was generated from the following file: