public function deleteAction() { $id = $this->getRequest()->getParam('id'); if (!$id) { $this->getResponse()->setStatus(0)->setBody(__('user does not exist'))->toJson(); } $user_rs = Admin_UsersModel::get(array('id' => $id)); if (!$user_rs) { $this->getResponse()->setStatus(0)->setBody(__('user does not exist'))->toJson(); } if (is_null($this->getRequest()->getPost('confirmed'))) { $this->getResponse()->setStatus(2)->setBody(__('Are you sure?'))->toJson(); } if ($id != s()->user->id && $user_rs->is_developer) { $this->getResponse()->setStatus(0)->setBody('how about no?')->toJson(); } Admin_UsersModel::delete(array('id' => $id)); // Refresh the user's session if ($id == s()->user->id) { Cms_UserData::refresh(array(Cms_UserData::ATTR_ALL)); } else { Cms_UserData::injectRefresh($id, array(Cms_UserData::ATTR_ALL)); } $this->getResponse()->setStatus(1)->setBody(__('user deleted'))->toJson(); }
public static function login($user_id, $persistent = false) { s()->flush(); if ($persistent) { s()->setPersistent(); } // Load user data s()->user->id = $user_id; // Set user session Admin_UsersModel::set(array('session_id' => s()->getId()), array('id' => s()->user->id)); Admin_LogsModel::insert(array('user_id' => $user_id, 'ip' => Core_Request::getInstance()->getServer('REMOTE_ADDR')), Admin_LogsModel::USER_LOGIN); Cms_UserData::refresh(array(Cms_UserData::ATTR_ALL)); return s()->user->id ? true : false; }