/** * 设置用户组权限 * * @param PwUserPermissionDm $dm * @return bool */ public function setPermission(PwUserPermissionDm $dm) { if (!($data = $dm->getData())) { return false; } $result = $this->_getGroupPermissionDao()->setGroupPermission($data); PwSimpleHook::getInstance('PwUserGroupPermission_update')->runDo($dm); return $result; }
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'); }
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; }
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); }
/** * * 保存用户组权限设置 * */ 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); }
/** * 通过监测数据更新字段,自动更新权限缓存 (hook) */ public function updatePermissionCacheByHook(PwUserPermissionDm $dm) { $gkey = array_keys($dm->getPermission()); if (empty($gkey)) { return; } $this->updateGroupCache(array($dm->getGid())); $this->updateGroupRightCache($gkey); }