changeUserRole() public static method

Upgrades / downgrades the user's account. Currently it's just the field user_account_type in the database that can be 1 or 2 (maybe "basic" or "premium"). Put some more complex stuff in here, maybe a pay-process or whatever you like.
public static changeUserRole ( $type ) : boolean
$type
return boolean
Exemplo n.º 1
0
 /**
  * Perform the account-type changing
  * Auth::checkAuthentication() makes sure that only logged in users can use this action
  * POST-request
  */
 public function changeUserRole_action()
 {
     Auth::checkAuthentication();
     if (Request::post('user_account_upgrade')) {
         // "2" is quick & dirty account type 2, something like "premium user" maybe. you got the idea :)
         UserRoleModel::changeUserRole(2);
     }
     if (Request::post('user_account_downgrade')) {
         // "1" is quick & dirty account type 1, something like "basic user" maybe.
         UserRoleModel::changeUserRole(1);
     }
     Redirect::to('login/changeUserRole');
 }