/** * Get user group object * */ function getUserType() { $o = new UserTypeModel(); if ($this->user_type_id > 0) { $o->load($this->user_type_id); } return $o; }
function ChangeAccessAction() { $request = Project::getRequest(); $group_model = new UserTypeModel(); $group_data = $group_model->load($request->gid); if (!count($group_data)) { // Bad request:: group not exists return; } $controller_model = new ControllerModel(); $controller_data = $controller_model->load($request->cid); if (!count($controller_data)) { // Bad request:: controller not exists return; } $action_model = new ActionModel(); $action_data = $action_model->load($request->id); if (!count($action_data)) { // Bad request:: action not exists return; } $right_model = new UserRightModel(); $right_data = $right_model->loadByTypeControllerAction($request->gid, $request->cid, $request->id); if (!count($right_data)) { $right_model->user_type_id = $request->gid; $right_model->controller_id = $request->cid; $right_model->action_id = $request->id; $right_model->access = 1; } else { $right_model->access = 1 - (int) $right_model->access; } $right_model->save(); }
public function getAllUserTypes() { try { $_modelUserTypes = new UserTypeModel(); $rs = $_modelUserTypes->fetchAll('id > 1')->toArray(); return $rs; } catch (Exception $e) { throw $e; } }
function SaveAction() { $request = Project::getRequest(); $user_id = (int) Project::getUser()->getDbUser()->id; $model = new UserModel(); $model->load($request->id); $do_save = true; $this->_view->clearFlashMessages(); if (!strlen(trim($request->login))) { $this->_view->addFlashMessage(FM::ERROR, "Не заполнено поле логин"); $do_save = false; } if ($request->unbann) { $ban_model = new BanHistoryModel(); $ban_model->unban($request->id, $user_id); } if ($request->bann) { if (strlen($request->warning)) { $ban_date = $request->ban_date; if (strlen($ban_date) && strtotime($ban_date) > time()) { $warning_model = new WarningModel(); $warning_id = $warning_model->add($request->id, $request->warning); $ban_model = new BanHistoryModel(); $ban_model->ban($request->id, $user_id, $warning_id, $request->ban_date); } else { $this->_view->addFlashMessage(FM::ERROR, "Неверная дата бана"); $do_save = false; } } else { $this->_view->addFlashMessage(FM::ERROR, "Не заполнено предупреждение"); $do_save = false; } } if ($do_save) { $this->_view->clearFlashMessages(); $model->login = $request->login; $model->user_type_id = $request->user_group; if ($request->bann) { $model->banned = 1; $model->banned_date = strtotime($request->ban_date); } else { $model->banned = 0; } $ban_date = $request->ban_date; if (strlen($ban_date)) { //$ban_model = new Ban } $id = $model->save(); $model = new UserTypeModel(); $info = array(); $info['group_list'] = $model->loadAll(); $info['edit_controller'] = null; $info['edit_action'] = 'Edit'; $this->makeUserList($info); $this->_view->AjaxList($info); } $this->_view->ajax(); }