public function validatePermission() { if (!$this->hasErrors()) { $auth = \App::$app->getAuthManager(); if ($this->isNewRecord && $auth->getPermission($this->name)) { $this->addError('name', \App::t('auth', 'This name already exists.')); } if ($this->isNewRecord && $auth->getRole($this->name)) { $this->addError('name', \App::t('auth', 'This name already exists.')); } } }
private function getAccess() { if ($GLOBALS['config']['superadmin'] == $_SESSION['username']) { $this->accesslist = Common::infinate(App::find()->toArray()); } else { $arr = array(); $acc = Permission::find('did=' . $this->depart); if ($acc) { foreach ($acc as $v) { array_push($arr, $v->app->toArray()); } } $this->accesslist = Common::infinate($arr); } }
/** * @inheritdoc */ public function attributeLabels() { $labels = parent::attributeLabels(); return array_merge($labels, ['password' => \App::t('app', 'Password'), 'repassword' => \App::t('app', 'Repassword')]); }
public function addappAction() { //添加新应用 if ($this->request->isPost()) { $this->view->disable(); $post = json_decode(file_get_contents("php://input"), true); $app = new App(); $app->setName(htmlspecialchars(trim($post['name']))); $app->setRemark(htmlspecialchars(trim($post['remark']))); $app->setPid(intval($post['pid'])); $app->setShow(intval($post['show'])); $app->setLevel(intval($post['pid']) > 0 ? 2 : 1); $app->setAddTime(); $app->setAddIp(); $app->save(); } }