This class contains everything that is related to up- and downgrading accounts.
Exemplo n.º 1
0
 /**
  * @param $user_id
  * @param $removed_perm
  */
 public static function removePerm($user_id, $removed_perm)
 {
     $original = UserRoleModel::getPerms($user_id);
     $being_removed = array_search($removed_perm, $original);
     unset($original[$being_removed]);
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "UPDATE users SET perms = :new WHERE user_id = :user_id";
     $query = $database->prepare($sql);
     $query->execute(array(':new' => json_encode($original), ':user_id' => $user_id));
 }
Exemplo n.º 2
0
 /**
  * Remove A user permission
  * @param $user_id
  * @param $removed_perm
  */
 public static function removePerm($user_id, $removed_perm)
 {
     if (self::$removePermQuery === null) {
         self::$removePermQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE users SET perms = :new WHERE user_id = :user_id");
     }
     $original = UserRoleModel::getPerms($user_id);
     $being_removed = array_search($removed_perm, $original);
     unset($original[$being_removed]);
     self::$removePermQuery->execute(array(':new' => json_encode($original), ':user_id' => $user_id));
     Session::add('feedback_positive', 'Removed that permission!');
 }
Exemplo n.º 3
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');
 }