Exemple #1
0
 /**
  * 管理组录入
  *
  */
 public function actionGroupCreate()
 {
     parent::_acl('admin_group_create');
     $model = new AdminGroup();
     if (isset($_POST['AdminGroup'])) {
         $model->attributes = $_POST['AdminGroup'];
         $acl = Yii::app()->request->getPost('acl');
         if (is_array($acl)) {
             $model->acl = implode(',', array_unique($acl));
         } else {
             $model->acl = 'administrator';
         }
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入管理员组' . $model->group_name));
             $this->redirect(array('group'));
         }
     }
     $this->render('group_create', array('model' => $model));
 }
Exemple #2
0
 private function groupEdite($data = null)
 {
     if (XUtils::method() == 'POST') {
         if (!empty($_POST['gname']) && !empty($_POST['auth'])) {
             $gid = reqPost('gid', null);
             $auth = '|' . implode('|', array_keys($_POST['auth'])) . '|';
             $sis = !empty($_POST['sis']) && $_POST['sis'] == 'Y' ? 'Y' : 'N';
             $attr = array('group_name' => $_POST['gname'], 'acl' => $auth, 'status_is' => $_POST['sis']);
             if (!empty($gid)) {
                 $attr['id'] = $gid;
             } else {
                 $attr['create_time'] = time();
             }
             empty($data) && ($data = new AdminGroup());
             $data->attributes = $attr;
             //            ppr($data);
             //            ppr($attr);
             //            ppr($_POST,1);
             if ($data->save()) {
                 //更新权限缓存
                 !empty($gid) && cacheDelete('_backendAcl' . $gid, '');
                 parent::_backendLogger(array('catalog' => 'create', 'intro' => '编辑管理员组及权限' . $data->group_name));
                 XXcache::refresh('_adminGroup');
                 $this->redirect(array('group'));
             }
         } else {
             $gid = reqPostNum('gid');
             if ($gid > 0) {
                 XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/groupCreate', array('id' => $gid)));
             } else {
                 XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/group'));
             }
         }
     }
 }