'browse', 'name' => 'Browse'), ); function KTFolderAction($oFolder = null, $oUser = null, $oPlugin = null) { $this->oFolder =& $oFolder; $this->oUser =& $oUser; $this->oPlugin =& $oPlugin; parent::KTStandardDispatcher(); } function setFolder(&$oFolder) { $this->oFolder =& $oFolder; } function setUser(&$oUser) { $this->oUser =& $oUser; } function _show() { if (is_null($this->_sShowPermission)) { return true; } $oPermission =& KTPermission::getByName($this->_sShowPermission); if (PEAR::isError($oPermission)) { return true; } return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oFolder); } function _disable() { if ($this->_bDisabled === true) { return true; } if (is_null($this->_sDisablePermission)) { return false; } $oPermission =& KTPermission::getByName($this->_sDisablePermission); if (PEAR::isError($oPermission)) { return false; } $bResult = KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oFolder); if ($bResult === false) { $this->_sDisabledText = "Insufficient privileges"; } return !$bResult; } function getURL() { return sprintf("%s/action.php/%s?fFolderId=%d", $GLOBALS['KTRootUrl'], $this->sName, $this->oFolder->getID()); } function getInfo() { if ($this->_show() === false) { return null; } $aInfo = array( 'disabled' => $this->_disable(), 'description' => $this->sDescription, 'name' => $this->sDisplayName, 'url' => $this->getURL(), 'disabled_text' => $this->_sDisabledText, ); return $this->customiseInfo($aInfo); } function getName() { return $this->sName; } function getDisplayName() { return $this->sDisplayName; } function getDescription() { return $this->sDescription; } function customiseInfo($aInfo) { return $aInfo; } function check() { $this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); if (!is_null($this->_sShowPermission)) { $oPermission =& KTPermission::getByName($this->_sShowPermission); if (!PEAR::isError($oPermission)) { $res = KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oFolder); if (!$res) { return false; } } } $aOptions = array( "final" => false, "documentaction" => "viewDocument", "folderaction" => "browse", ); $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($this->oFolder, $aOptions)); return true; } function do_main() { return _("Dispatcher component of action not implemented."); } } class KTFolderActionUtil { function getFolderActions() { $oRegistry =& KTActionRegistry::getSingleton(); return $oRegistry->getActions('folderaction'); } function &getFolderActionsForFolder($oFolder, $oUser) { $aObjects = array(); foreach (KTFolderActionUtil::getFolderActions() as $aAction) { list($sClassName, $sPath, $sPlugin) = $aAction; $oRegistry = KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin($sPlugin); if (!empty($sPath)) { require_once($sPath); } $aObjects[] =& new $sClassName($oFolder, $oUser, $oPlugin); } return $aObjects; } } ?>