예제 #1
0
파일: Auth.php 프로젝트: wuwenhan/huoqiwang
 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.'));
         }
     }
 }
예제 #2
0
파일: Authen.php 프로젝트: csclq/niuren
 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);
     }
 }
예제 #3
0
파일: User.php 프로젝트: wuwenhan/huoqiwang
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     $labels = parent::attributeLabels();
     return array_merge($labels, ['password' => \App::t('app', 'Password'), 'repassword' => \App::t('app', 'Repassword')]);
 }
예제 #4
0
 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();
     }
 }