diff --git a/lib/actions/actionregistry.inc.php b/lib/actions/actionregistry.inc.php index a15006f..e8dee35 100644 --- a/lib/actions/actionregistry.inc.php +++ b/lib/actions/actionregistry.inc.php @@ -6,7 +6,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -17,9 +17,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -31,14 +31,15 @@ class KTActionRegistry { var $actions = array(); - // {{{ getSingleton - function &getSingleton () { - if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTActionRegistry')) { - $GLOBALS['_KT_PLUGIN']['oKTActionRegistry'] = new KTActionRegistry; - } - return $GLOBALS['_KT_PLUGIN']['oKTActionRegistry']; + + static function &getSingleton () { + static $singleton=null; + if (is_null($singleton)) + { + $singleton = new KTActionRegistry(); + } + return $singleton; } - // }}} function registerAction($slot, $name, $nsname, $path = '', $sPlugin = null) { $this->actions[$slot] = KTUtil::arrayGet($this->actions, $slot, array()); @@ -62,11 +63,11 @@ class KTActionRegistry { $oPluginRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oPluginRegistry->getPlugin($sPlugin); - $oAction =& new $sClassName($oUser, $oPlugin); + $oAction =new $sClassName($oUser, $oPlugin); return $oAction; } - + } diff --git a/lib/actions/bulkaction.php b/lib/actions/bulkaction.php index 10a35a6..d40210c 100644 --- a/lib/actions/bulkaction.php +++ b/lib/actions/bulkaction.php @@ -7,7 +7,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -18,9 +18,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -49,7 +49,7 @@ class KTBulkAction extends KTStandardDispatcher { var $_sDisablePermission; var $bAllowInAdminMode = false; - var $sHelpPage = 'ktcore/browse.html'; + var $sHelpPage = 'ktcore/browse.html'; var $sSection = 'view_details'; @@ -71,7 +71,7 @@ class KTBulkAction extends KTStandardDispatcher { $this->aBreadcrumbs = array( array('action' => 'browse', 'name' => _kt('Browse')), ); - + $this->persistParams('fEntityListCode'); parent::KTStandardDispatcher(); } @@ -115,7 +115,7 @@ class KTBulkAction extends KTStandardDispatcher { 'url' => $url, 'icon_class' => $this->sIconClass, ); - + $aInfo = $this->customiseInfo($aInfo); return $aInfo; } @@ -159,7 +159,7 @@ class KTBulkAction extends KTStandardDispatcher { $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1); $this->oFolder = Folder::get($iFolderId); //$this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); - + $aOptions = array( 'final' => false, 'documentaction' => 'viewDocument', @@ -172,7 +172,7 @@ class KTBulkAction extends KTStandardDispatcher { return true; } - + // check the entire entity list. this needn't be overrided at any point function check_entities() { $aFailed = array('documents' => array(), 'folders' => array()); @@ -184,7 +184,7 @@ class KTBulkAction extends KTStandardDispatcher { foreach($this->oEntityList->getDocumentIds() as $iId) { $oDocument =& Document::get($iId); - + if(PEAR::isError($oDocument)) { $aFailed['documents'][] = array($iId, _kt('No such document')); } else { @@ -207,10 +207,10 @@ class KTBulkAction extends KTStandardDispatcher { foreach($this->oEntityList->getFolderIds() as $iId) { $oFolder =& Folder::get($iId); - + if(PEAR::isError($oFolder)) { $aFailed['folders'][] = array($iId, _kt('No such folder')); - } else { + } else { $res = $this->check_entity($oFolder); if(PEAR::isError($res)) { @@ -221,7 +221,7 @@ class KTBulkAction extends KTStandardDispatcher { $aSucceeded['folders'][] = $oFolder->getId(); } } - } + } $this->oActiveEntityList = new KTEntityList($aSucceeded['documents'], $aSucceeded['folders']); $this->aFailed = $aFailed; @@ -242,7 +242,7 @@ class KTBulkAction extends KTStandardDispatcher { } $res = $this->perform_action($oDocument); - + if(PEAR::isError($res)) { $this->aActionResults['documents'][] = array($sName, $res->getMessage()); } else { @@ -259,12 +259,12 @@ class KTBulkAction extends KTStandardDispatcher { } $res = $this->perform_action($oFolder); - + if(PEAR::isError($res)) { $this->aActionResults['folders'][] = array($sName, $res->getMessage()); } else { $this->aActionResults['folders'][] = array($sName, _kt('Success')); - } + } } } @@ -284,7 +284,7 @@ class KTBulkAction extends KTStandardDispatcher { function store_lists() { $this->persistParams(array('fListCode', 'fActiveListCode', 'fFolderId', 'fReturnData', 'fReturnAction')); } - + @@ -302,7 +302,7 @@ class KTBulkAction extends KTStandardDispatcher { 'action' => 'collectinfo', 'fail_action' => 'main', 'noframe' => true, - 'extraargs' => array('fListCode' => $sListCode, + 'extraargs' => array('fListCode' => $sListCode, 'fActiveListCode' => $sActiveListCode, 'fFolderId' => $this->oFolder->getId(), 'fReturnAction' => KTUtil::arrayGet($_REQUEST, 'fReturnAction'), @@ -323,7 +323,7 @@ class KTBulkAction extends KTStandardDispatcher { if ($sReturnData == '') { $sReturnData = KTUtil::arrayGet($_REQUEST, 'fFolderId'); - } + } $sTargetUrl = KTBrowseUtil::getUrlForFolder(Folder::get($sReturnData)); } else if($sReturnAction == 'simpleSearch') { $sTargetUrl = KTBrowseUtil::getSimpleSearchBaseUrl(); @@ -356,13 +356,13 @@ class KTBulkAction extends KTStandardDispatcher { $this->oEntityList = new KTEntityList($aDocuments, $aFolders); // gives us $this->aFailed - $iActiveCount = $this->check_entities(); + $iActiveCount = $this->check_entities(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/bulk_action_listing'); - - $this->store_lists(); - + + $this->store_lists(); + return $oTemplate->render(array('context' => $this, 'form' => $this->form_listing(), 'failed' => $this->aFailed, @@ -411,7 +411,7 @@ class KTBulkAction extends KTStandardDispatcher { // parent implementation function check_entity($oEntity) { $oPermission =& KTPermission::getByName($this->_sPermission); - if(PEAR::isError($oPermission)) { + if(PEAR::isError($oPermission)) { return true; } @@ -419,7 +419,7 @@ class KTBulkAction extends KTStandardDispatcher { // TODO: check if this is appropriate // should probably store the 'equivalent' action (ie. document.delete) - // and check that, rather than add a new list of actions to the workflow + // and check that, rather than add a new list of actions to the workflow // section if(is_a($oEntity, 'Document')) { if(!KTWorkflowUtil::actionEnabledForDocument($oEntity, $this->sName)) { @@ -430,14 +430,14 @@ class KTBulkAction extends KTStandardDispatcher { return PEAR::raiseError(_kt('Document is archived or deleted')); } } - + // admin check if($this->bAllowInAdminMode) { if(KTBrowseUtil::inAdminMode($this->oUser, null)) { return true; } } - + if(!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $oEntity)) { return PEAR::raiseError(_kt('You do not have the required permissions')); } @@ -452,7 +452,7 @@ class KTBulkDocumentAction extends KTBulkAction { function check_entity($oEntity) { if(!is_a($oEntity, 'Document')) { return false; - } + } return parent::check_entity($oEntity); } } @@ -461,7 +461,7 @@ class KTBulkFolderAction extends KTBulkAction { function check_entity($oEntity) { if(!is_a($oEntity, 'Folder')) { return false; - } + } return parent::check_entity($oEntity); } } @@ -486,7 +486,7 @@ class KTBulkActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName(null, null, $oPlugin); + $aObjects[] = new $sClassName(null, null, $oPlugin); } return $aObjects; } @@ -503,7 +503,7 @@ class KTBulkActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName(null, $oUser, $oPlugin); + $aObjects[] = new $sClassName(null, $oUser, $oPlugin); } return $aObjects; } diff --git a/lib/actions/documentaction.inc.php b/lib/actions/documentaction.inc.php index 208804b..384b288 100644 --- a/lib/actions/documentaction.inc.php +++ b/lib/actions/documentaction.inc.php @@ -6,7 +6,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -17,9 +17,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -42,13 +42,13 @@ class KTDocumentAction extends KTStandardDispatcher { var $_sShowPermission = 'ktcore.permissions.read'; var $_sDisablePermission; var $bAllowInAdminMode = false; - var $sHelpPage = 'ktcore/browse.html'; + var $sHelpPage = 'ktcore/browse.html'; var $sSection = 'view_details'; var $_bMutator = false; var $_bMutationAllowedByAdmin = true; - + var $sIconClass; function KTDocumentAction($oDocument = null, $oUser = null, $oPlugin = null) { @@ -58,7 +58,7 @@ class KTDocumentAction extends KTStandardDispatcher { $this->aBreadcrumbs = array( array('action' => 'browse', 'name' => _kt('Browse')), ); - + $this->persistParams('fDocumentId'); parent::KTStandardDispatcher(); @@ -87,7 +87,7 @@ class KTDocumentAction extends KTStandardDispatcher { return false; } } - + if ($this->_bAdminAlwaysAvailable) { if (Permission::userIsSystemAdministrator($this->oUser->getId())) { return true; @@ -105,13 +105,13 @@ class KTDocumentAction extends KTStandardDispatcher { } // be nasty in archive/delete status. $status = $this->oDocument->getStatusID(); - if (($status == DELETED) || ($status == ARCHIVED)) { return false; } + if (($status == DELETED) || ($status == ARCHIVED)) { return false; } if ($this->bAllowInAdminMode) { // check if this user is in admin mode - if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { - return true; - } - } + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { + return true; + } + } return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument); } @@ -142,7 +142,7 @@ class KTDocumentAction extends KTStandardDispatcher { 'url' => $url, 'icon_class' => $this->sIconClass, ); - + $aInfo = $this->customiseInfo($aInfo); return $aInfo; } @@ -169,7 +169,7 @@ class KTDocumentAction extends KTStandardDispatcher { $this->oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']); if (!$this->_show()) { return false; } - + $aOptions = array('final' => false, 'documentaction' => 'viewDocument', 'folderaction' => 'browse', @@ -180,15 +180,15 @@ class KTDocumentAction extends KTStandardDispatcher { $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser, 'documentinfo'); $oPortlet = new KTActionPortlet(sprintf(_kt('Document info'))); $oPortlet->setActions($actions, $this->sName); - $this->oPage->addPortlet($oPortlet); + $this->oPage->addPortlet($oPortlet); $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); $oPortlet = new KTActionPortlet(sprintf(_kt('Document actions'))); $oPortlet->setActions($actions, $this->sName); - $this->oPage->addPortlet($oPortlet); - - $this->oPage->setSecondaryTitle($this->oDocument->getName()); - + $this->oPage->addPortlet($oPortlet); + + $this->oPage->setSecondaryTitle($this->oDocument->getName()); + return true; } @@ -212,7 +212,7 @@ class KTDocumentActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName($oDocument, $oUser, $oPlugin); + $aObjects[] = new $sClassName($oDocument, $oUser, $oPlugin); } return $aObjects; } @@ -228,7 +228,7 @@ class KTDocumentActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName($oDocument, $oUser, $oPlugin); + $aObjects[] = new $sClassName($oDocument, $oUser, $oPlugin); } return $aObjects; } @@ -245,7 +245,7 @@ class KTDocumentActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName($oDocument, $oUser, $oPlugin); + $aObjects[] = new $sClassName($oDocument, $oUser, $oPlugin); } return $aObjects; } diff --git a/lib/actions/folderaction.inc.php b/lib/actions/folderaction.inc.php index d4c6d67..4de6481 100644 --- a/lib/actions/folderaction.inc.php +++ b/lib/actions/folderaction.inc.php @@ -6,7 +6,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -17,9 +17,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -40,14 +40,14 @@ class KTFolderAction extends KTStandardDispatcher { var $_sShowPermission = 'ktcore.permissions.folder_details'; var $_sDisablePermission; - var $sHelpPage = 'ktcore/browse.html'; - + var $sHelpPage = 'ktcore/browse.html'; + var $_bAdminAlwaysAvailable = false; var $sSection = 'browse'; function KTFolderAction($oFolder = null, $oUser = null, $oPlugin = null) { - parent::KTStandardDispatcher(); + parent::KTStandardDispatcher(); $this->oFolder =& $oFolder; $this->oUser =& $oUser; $this->oPlugin =& $oPlugin; @@ -80,7 +80,7 @@ class KTFolderAction extends KTStandardDispatcher { return true; } } - + return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oFolder); } @@ -131,9 +131,9 @@ class KTFolderAction extends KTStandardDispatcher { function check() { $this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); - + if (!$this->_show()) { return false; } - + $aOptions = array( 'final' => false, 'documentaction' => 'viewDocument', @@ -143,15 +143,15 @@ class KTFolderAction extends KTStandardDispatcher { KTBrowseUtil::breadcrumbsForFolder($this->oFolder, $aOptions)); $portlet = new KTActionPortlet(sprintf(_kt('About this folder'))); - $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser); + $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser); $portlet->setActions($aActions,$this->sName); - $this->oPage->addPortlet($portlet); + $this->oPage->addPortlet($portlet); $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder'))); - $aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $this->oUser); + $aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $this->oUser); $portlet->setActions($aActions,$this->sName); - $this->oPage->addPortlet($portlet); - + $this->oPage->addPortlet($portlet); + if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $this->oFolder)) { $this->oPage->setSecondaryTitle($this->oFolder->getName()); } else { @@ -161,7 +161,7 @@ class KTFolderAction extends KTStandardDispatcher { $this->oPage->setSecondaryTitle('...'); } } - + return true; } @@ -179,7 +179,7 @@ class KTFolderActionUtil { function getFolderInfoActions() { $oRegistry =& KTActionRegistry::getSingleton(); return $oRegistry->getActions('folderinfo'); - } + } function &getFolderActionsForFolder($oFolder, $oUser) { $aObjects = array(); foreach (KTFolderActionUtil::getFolderActions() as $aAction) { @@ -189,7 +189,7 @@ class KTFolderActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName($oFolder, $oUser, $oPlugin); + $aObjects[] =new $sClassName($oFolder, $oUser, $oPlugin); } return $aObjects; } @@ -202,10 +202,10 @@ class KTFolderActionUtil { if (!empty($sPath)) { require_once($sPath); } - $aObjects[] =& new $sClassName($oFolder, $oUser, $oPlugin); + $aObjects[] =new $sClassName($oFolder, $oUser, $oPlugin); } return $aObjects; - } + } } ?> diff --git a/lib/actions/portletregistry.inc.php b/lib/actions/portletregistry.inc.php index 218df05..c6ca21c 100644 --- a/lib/actions/portletregistry.inc.php +++ b/lib/actions/portletregistry.inc.php @@ -6,7 +6,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -17,9 +17,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -32,11 +32,13 @@ class KTPortletRegistry { var $actions = array(); // {{{ getSingleton - function &getSingleton () { - if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPortletRegistry')) { - $GLOBALS['_KT_PLUGIN']['oKTPortletRegistry'] =& new KTPortletRegistry; - } - return $GLOBALS['_KT_PLUGIN']['oKTPortletRegistry']; + static function &getSingleton () { + static $singleton=null; + if (is_null($singleton)) + { + $singleton = new KTPortletRegistry(); + } + return $singleton; } // }}} @@ -84,7 +86,7 @@ class KTPortletRegistry { if (file_exists($sPortletFile)) { require_once($sPortletFile); } - $oPortlet =& new $sPortletClass; + $oPortlet =new $sPortletClass; $oPortlet->setPlugin($oPlugin); array_push($aReturn, $oPortlet); }