Exemplo n.º 1
0
 /**
  * remove users photo
  * @param  object $p json decoded object
  * @return array  json responce
  */
 public function removePhoto($p)
 {
     if (!$this->isVerified()) {
         return array('success' => false, 'verify' => true);
     }
     if (!is_numeric($p['id'])) {
         return array('success' => false, 'msg' => L\get('Wrong_id'));
     }
     if (!Security::canEditUser($p['id'])) {
         throw new \Exception(L\get('Access_denied'));
     }
     /* delete photo file*/
     $r = DM\Users::read($p['id']);
     if (!empty($r['photo'])) {
         @unlink(Config::get('photos_path') . $r['photo']);
     }
     /* enddelete photo file */
     // update db record
     DM\Users::update(array('id' => $p['id'], 'photo' => null));
     return array('success' => true);
 }
Exemplo n.º 2
0
 /**
  * clear user sessions
  * @param  int     $userId
  * @return boolean
  */
 public static function clearUserSessions($userId)
 {
     if (!Security::canEditUser($userId)) {
         return false;
     }
     DB\dbQuery('DELETE FROM sessions WHERE user_id = $1', $userId) or die(DB\dbQueryError());
     return true;
 }
Exemplo n.º 3
0
 /**
  * Rename group
  */
 public function renameGroup($p)
 {
     if (!User::isVerified()) {
         return array('success' => false, 'verify' => true);
     }
     $title = Purify::humanName($p['title']);
     if (empty($title)) {
         throw new \Exception(L\get('Wrong_input_data'));
     }
     $id = $this->extractId($p['id']);
     if (!Security::canEditUser($id)) {
         throw new \Exception(L\get('Access_denied'));
     }
     DB\dbQuery('UPDATE users_groups
         SET name = $2, uid = $3
         WHERE id = $1 AND type = 1', array($id, $title, $_SESSION['user']['id'])) or die(DB\dbQueryError());
     return array('success' => true, 'title' => $title);
 }
Exemplo n.º 4
0
 /**
  * clear user sessions
  * @param  int     $userId
  * @return boolean
  */
 public static function clearUserSessions($userId)
 {
     if (!Security::canEditUser($userId)) {
         return false;
     }
     DM\Sessions::deleteByUserId($userId);
     return true;
 }