/** * 判断用户的某个模块权限 * @param int $uid * @param int $moduleid * @param int $pageid */ public function getPermissionsForModule($uid, $moduleid, $pageid = 0) { $ds = Wekit::load('design.PwDesignPermissions'); Wind::import('SRV:design.srv.vo.PwDesignPermissionsSo'); $vo = new PwDesignPermissionsSo(); $vo->setDesignType(PwDesignPermissions::TYPE_MODULE)->setDesignId($moduleid)->setUid($uid); $permissions = $ds->searchPermissions($vo); if ($permissions) { $permissions = array_shift($permissions); if (isset($permissions['permissions'])) { return $permissions['permissions']; } } if ($pageid) { return $this->getPermissionsForPage($uid, $pageid); } return $this->getPermissionsForUserGroup($uid); }
public function doeditAction() { $designId = (int) $this->getInput('design_id', 'post'); $designType = (int) $this->getInput('design_type', 'post'); $new_permissions = $this->getInput('new_permissions', 'post'); $new_username = $this->getInput('new_username', 'post'); $ids = $this->getInput('ids', 'post'); $permissions = $this->getInput('permissions', 'post'); $fail = 0; $ds = $this->_getPermissionsDs(); //添加新用户 前端已修改为单用户提交 if ($new_username) { Wind::import('SRV:design.srv.vo.PwDesignPermissionsSo'); Wind::import('SRV:user.bo.PwUserBo'); $service = $this->_getPermissionsService(); foreach ($new_username as $k => $name) { if (!$name) { continue; } $user = Wekit::load('user.PwUser')->getUserByName($name); $new_uid = isset($user['uid']) ? $user['uid'] : 0; if ($new_uid < 1) { $this->showError("DESIGN:user.name.error"); } $vo = new PwDesignPermissionsSo(); $vo->setDesignId($designId)->setDesignType($designType)->setUid($new_uid); $list = $ds->searchPermissions($vo); if ($list) { $this->showError("DESIGN:user.already.permissions"); } if ($service->getPermissionsForUserGroup($new_uid) < 0) { $this->showError("DESIGN:user.group.error"); } $userBo = new PwUserBo($new_uid); $designPermission = $userBo->getPermission('design_allow_manage.push'); if ($designPermission < 1) { $this->showError("DESIGN:user.group.error"); } $resource = $ds->addInfo($designType, $designId, $new_uid, $new_permissions[$k]); if (!$resource) { $fail++; } } } foreach ($ids as $k => $id) { $resource = $ds->updatePermissions($id, $permissions[$k]); if (!$resource) { $fail++; } } $this->showMessage("operate.success"); }
public function searchPermissions(PwDesignPermissionsSo $vo) { return $this->_getDao()->search($vo->getData()); }