コード例 #1
0
ファイル: ManageController.php プロジェクト: fanqimeng/4tweb
 public function dogroupAction()
 {
     $view = $this->getInput('view', 'post');
     $groups = $this->_getUserGroupsDs()->getAllGroups();
     Wind::import('SRV:usergroup.dm.PwUserPermissionDm');
     foreach ($groups as $value) {
         $dm = new PwUserPermissionDm($value['gid']);
         $dm->setPermission('allow_add_vote', in_array($value['gid'], $view['allow_add_vote']) ? 1 : 0);
         $dm->setPermission('allow_participate_vote', in_array($value['gid'], $view['allow_participate_vote']) ? 1 : 0);
         $dm->setPermission('allow_view_vote', in_array($value['gid'], $view['allow_view_vote']) ? 1 : 0);
         $this->_getUserPermissionDs()->setPermission($dm);
     }
     $this->showMessage('ADMIN:success');
 }
コード例 #2
0
 public function setConfig($config)
 {
     if (!is_array($config) || empty($config)) {
         return false;
     }
     Wind::import('SRV:usergroup.dm.PwUserPermissionDm');
     foreach ($config as $gid => $value) {
         $gid = intval($gid);
         $value = intval($value);
         $dm = new PwUserPermissionDm($gid);
         $dm->setPermission($this->configKey, $value);
         $this->_getPwUserPermissionDs()->setPermission($dm);
     }
     return true;
 }
コード例 #3
0
 public function dosetrightAction()
 {
     list($rkey, $gpermission) = $this->getInput(array('rkey', 'gpermission'), 'post');
     $permissionService = Wekit::load('usergroup.PwUserPermission');
     Wind::import('SRV:usergroup.dm.PwUserPermissionDm');
     foreach ($gpermission as $key => $value) {
         $dm = new PwUserPermissionDm($key);
         $dm->setPermission($rkey, $value);
         $permissionService->setPermission($dm);
     }
     $this->showMessage('USER:groups.permission.edit.success', 'u/groups/setright/?rkey=' . $rkey, true);
 }
コード例 #4
0
ファイル: GroupsController.php プロジェクト: fanqimeng/4tweb
 /**
  * 
  * 保存用户组权限设置
  *
  */
 public function doeditAction()
 {
     list($mainGid, $category, $gpermission, $groupname) = $this->getInput(array('gid', 'category', 'gpermission', 'groupname'), 'post');
     $permissionService = Wekit::load('usergroup.PwUserPermission');
     Wind::import('SRV:usergroup.dm.PwUserPermissionDm');
     //$permissionKeys = $this->_getPermissionService()->getPermissionKeysByCategory($category);
     $isManage = stripos($category, 'manage_') === 0;
     $permissionKeys = $this->_getPermissionService()->getPermissionKeys($isManage);
     //$deleteKeys = array();
     //copy groups
     list($copyGroups, $copyItems) = $this->getInput(array('copy_groups', 'copy_items'), 'post');
     $gids = array($mainGid);
     $copyGroups && ($gids = array_merge($gids, $copyGroups));
     foreach ($gids as $gid) {
         $flag = $mainGid == $gid;
         $permissionModel = new PwUserPermissionDm($gid);
         foreach ($permissionKeys as $k) {
             if (!$flag && !isset($copyItems[$k])) {
                 continue;
             }
             if (isset($gpermission[$k])) {
                 $permissionModel->setPermission($k, $gpermission[$k]);
             } else {
                 //$deleteKeys[] = $k;
                 $permissionModel->setPermission($k, '');
             }
         }
         $permissionService->setPermission($permissionModel);
         //group info
         if ($flag) {
             $group = $this->_getGroupDs()->getGroupByGid($gid);
             if ($groupname && $groupname != $group['name']) {
                 Wind::import('SRV:usergroup.dm.PwUserGroupDm');
                 $dm = new PwUserGroupDm($gid);
                 $dm->setGroupName($groupname);
                 $this->_getGroupDs()->updateGroup($dm);
             }
         }
     }
     //$deleteKeys && $permissionService->batchDeletePermissionByGidAndKeys($gid,$deleteKeys);
     $this->showMessage('USER:groups.permission.edit.success', 'u/groups/edit/?gid=' . $mainGid . '&manage=' . intval($isManage), true);
 }