/** * @see \wcf\data\IPermissionObject::getPermission() */ public function getPermission($permission) { if ($this->permissions === null) { $this->permissions = CategoryPermissionHandler::getInstance()->getPermissions($this->getDecoratedObject()); } if (isset($this->permissions[$permission])) { return $this->permissions[$permission]; } return true; }
/** * @param string $permission * @return bool */ public function getPermission($permission) { if ($this->permissions === null) { $this->permissions = CategoryPermissionHandler::getInstance()->getPermissions($this->getDecoratedObject()); } if (array_key_exists($permission, $this->permissions)) { return $this->permissions[$permission]; } return WCF::getSession()->getPermission('user.' . self::PERMISSION_PREFIX . $permission) || WCF::getSession()->getPermission('mod.' . self::PERMISSION_PREFIX . $permission) || WCF::getSession()->getPermission('admin.' . self::PERMISSION_PREFIX . $permission); }
public function getPermission($permission) { if ($this->permissions === null) { $this->permissions = CategoryPermissionHandler::getInstance()->getPermissions($this->getDecoratedObject()); } if (isset($this->permissions[$permission])) { return $this->permissions[$permission]; } return WCF::getSession()->getPermission('user.cms.news.' . $permission) || WCF::getSession()->getPermission('mod.cms.news.' . $permission) || WCF::getSession()->getPermission('admin.cms.news.' . $permission); }
/** * @see wcf\form\IForm::save() */ public function save() { AbstractForm::save(); // handle description if ($this->objectType->getProcessor()->hasDescription()) { $this->description = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.description.category'.$this->category->categoryID; if (I18nHandler::getInstance()->isPlainValue('description')) { I18nHandler::getInstance()->remove($this->description, $this->packageID); $this->description = I18nHandler::getInstance()->getValue('description'); } else { I18nHandler::getInstance()->save('description', $this->description, $this->objectType->getProcessor()->getDescriptionLangVarCategory(), $this->packageID); } } // handle title $this->title = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.title.category'.$this->category->categoryID; if (I18nHandler::getInstance()->isPlainValue('title')) { I18nHandler::getInstance()->remove($this->title, $this->packageID); $this->title = I18nHandler::getInstance()->getValue('title'); } else { I18nHandler::getInstance()->save('title', $this->title, $this->objectType->getProcessor()->getTitleLangVarCategory(), $this->packageID); } // update category $this->objectAction = new CategoryAction(array($this->category), 'update', array( 'data' => array( 'additionalData' => serialize($this->additionalData), 'description' => $this->description, 'isDisabled' => $this->isDisabled, 'parentCategoryID' => $this->parentCategoryID, 'showOrder' => $this->showOrder, 'title' => $this->title ) )); $this->objectAction->executeAction(); // update acl if ($this->aclObjectTypeID) { ACLHandler::getInstance()->save($this->category->categoryID, $this->aclObjectTypeID); CategoryPermissionHandler::getInstance()->resetCache(); } // reload cache CategoryHandler::getInstance()->reloadCache(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see \wcf\data\IPermissionObject::getPermission() */ public function getPermission($permission, User $user = null) { if ($user === null) { $user = WCF::getUser(); } if (!isset($this->userPermissions[$user->userID])) { $this->userPermissions[$user->userID] = CategoryPermissionHandler::getInstance()->getPermissions($this, $user); if ($user->userID == WCF::getUser()->userID) { $this->permissions = $this->userPermissions[$user->userID]; } } if (isset($this->userPermissions[$user->userID][$permission])) { return $this->userPermissions[$user->userID][$permission]; } if ($this->getParentCategory()) { return $this->getParentCategory()->getPermission($permission, $user); } if ($this->getObjectType()->defaultpermission !== null) { return $this->getObjectType()->defaultpermission ? true : false; } return $this->defaultPermission; }
/** * @see wcf\page\IForm::save() */ public function save() { parent::save(); $this->objectAction = new CategoryAction(array(), 'create', array( 'data' => array( 'additionalData' => serialize($this->additionalData), 'description' => $this->description, 'isDisabled' => $this->isDisabled, 'objectTypeID' => $this->objectType->objectTypeID, 'parentCategoryID' => $this->parentCategoryID, 'showOrder' => $this->showOrder > 0 ? $this->showOrder : null, 'title' => $this->title ) )); $this->objectAction->executeAction(); $returnValues = $this->objectAction->getReturnValues(); if (($this->objectType->getProcessor()->hasDescription() && !I18nHandler::getInstance()->isPlainValue('description')) || !I18nHandler::getInstance()->isPlainValue('title')) { $categoryID = $returnValues['returnValues']->categoryID; $updateData = array(); if ($this->objectType->getProcessor()->hasDescription() && !I18nHandler::getInstance()->isPlainValue('description')) { $updateData['description'] = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.description.category'.$categoryID; I18nHandler::getInstance()->save('description', $updateData['description'], $this->objectType->getProcessor()->getDescriptionLangVarCategory(), $this->packageID); } if (!I18nHandler::getInstance()->isPlainValue('title')) { $updateData['title'] = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.title.category'.$categoryID; I18nHandler::getInstance()->save('title', $updateData['title'], $this->objectType->getProcessor()->getTitleLangVarCategory(), $this->packageID); } // update description/title $editor = new CategoryEditor($returnValues['returnValues']); $editor->update($updateData); } // save acl if ($this->aclObjectTypeID) { ACLHandler::getInstance()->save($returnValues['returnValues']->categoryID, $this->aclObjectTypeID); ACLHandler::getInstance()->disableAssignVariables(); CategoryPermissionHandler::getInstance()->resetCache(); } // reload cache CategoryHandler::getInstance()->reloadCache(); $this->readCategories(); // reset values $this->parentCategoryID = 0; $this->showOrder = 0; $this->saved(); // disable assignment of i18n values I18nHandler::getInstance()->disableAssignValueVariables(); // show success message WCF::getTPL()->assign('success', true); }