From ac69880992a4f694e8aaf1d34f1fbaee16d18a18 Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Thu, 20 Sep 2007 15:09:13 +0000 Subject: [PATCH] KTS-2358 "php5 migration" Updated. Removed & from &new. Added statics. --- lib/documentmanagement/DocumentLink.inc | 24 ++++++++++++------------ lib/documentmanagement/DocumentTransaction.inc | 64 ++++++++++++++++++++++++++++++++-------------------------------- lib/documentmanagement/DocumentType.inc | 52 ++++++++++++++++++++++++++-------------------------- lib/documentmanagement/LinkType.inc | 26 +++++++++++++------------- lib/documentmanagement/MetaData.inc | 36 ++++++++++++++++++------------------ lib/documentmanagement/PhysicalDocumentManager.inc | 2 +- 6 files changed, 102 insertions(+), 102 deletions(-) diff --git a/lib/documentmanagement/DocumentLink.inc b/lib/documentmanagement/DocumentLink.inc index 01d5d0c..65217bd 100644 --- a/lib/documentmanagement/DocumentLink.inc +++ b/lib/documentmanagement/DocumentLink.inc @@ -1,4 +1,4 @@ -getParentDocumentId()); } - + /** * get child document */ @@ -97,7 +97,7 @@ class DocumentLink extends KTEntity { $oDocument = Document::get($this->getChildDocumentId()); return $oDocument; } - + /** * get link type */ @@ -124,12 +124,12 @@ class DocumentLink extends KTEntity { // static boilerplate function & get($iDocumentLinkID) { global $default; - + $sql = $default->db; $result = $sql->query(array("SELECT * FROM $default->document_link_table WHERE id = ?", $iDocumentLinkID));/*ok*/ if ($result) { if ($sql->next_record()) { - $oDocumentLink = & new DocumentLink($sql->f("parent_document_id"), $sql->f("child_document_id"), $sql->f("link_type_id")); + $oDocumentLink = new DocumentLink($sql->f("parent_document_id"), $sql->f("child_document_id"), $sql->f("link_type_id")); $oDocumentLink->iId = $sql->f("id"); return $oDocumentLink; } @@ -155,7 +155,7 @@ class DocumentLink extends KTEntity { function getLinksFromDocument($iDocumentId) { return KTEntityUtil::getList2('DocumentLink', sprintf("parent_document_id = %d", $iDocumentId)); } - + /** * Static function * Get a list of DocumentLinks where iDocumentId is the child diff --git a/lib/documentmanagement/DocumentTransaction.inc b/lib/documentmanagement/DocumentTransaction.inc index 666dd4e..dc2f436 100644 --- a/lib/documentmanagement/DocumentTransaction.inc +++ b/lib/documentmanagement/DocumentTransaction.inc @@ -3,14 +3,14 @@ * $Id$ * * Represents a document transaction as per the database table document_transaction. - * No delete or update functions are provided. Once a transaction has been stored + * No delete or update functions are provided. Once a transaction has been stored * in the database it may not be changed. * * The contents of this file are subject to the KnowledgeTree Public * 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 @@ -21,9 +21,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 @@ -33,15 +33,15 @@ */ require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); - -require_once(KT_LIB_DIR . '/users/User.inc'); -require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransactionType.inc.php'); - -require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); -require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); - + +require_once(KT_LIB_DIR . '/users/User.inc'); +require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransactionType.inc.php'); + +require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); + class DocumentTransaction extends KTEntity { - + /** primary key of document transaction */ var $iId = -1; var $iDocumentID; @@ -53,14 +53,14 @@ class DocumentTransaction extends KTEntity { var $sComment; var $sTransactionNS; var $bAdminMode = 0; - + /** * Constructor * * @param Primary key of document on which transaction was performed * @param User comment associated with transaction * @param Primary key of transaction type - * + * */ function DocumentTransaction($oDocument, $sNewComment, $sTransactionNS, $aOptions = null) { if (is_null($aOptions)) { @@ -68,7 +68,7 @@ class DocumentTransaction extends KTEntity { } //object not stored yet, id = -1 $this->iId = -1; - + $this->iDocumentID = $oDocument->getID(); $this->sComment = $sNewComment; $this->sTransactionNS = $sTransactionNS; @@ -78,19 +78,19 @@ class DocumentTransaction extends KTEntity { if (PEAR::isError($oFolder) || ($oFolder == false)) { $this->sFileName = '.../' . $oDocument->getName(); } else { - $this->sFileName = addslashes($oFolder->sFullPath . "/" . $oFolder->getName() . "/" . $oDocument->getName()); + $this->sFileName = addslashes($oFolder->sFullPath . "/" . $oFolder->getName() . "/" . $oDocument->getName()); } - + $this->iUserID = $_SESSION["userID"]; $this->iSessionId = $_SESSION["sessionID"]; $oUser = KTUtil::arrayGet($aOptions, 'user'); - + if (!(PEAR::isError($oUser) || ($oUser == false))) { $this->iUserID = $oUser->getID(); } - $this->dDateTime = getCurrentDateTime(); + $this->dDateTime = getCurrentDateTime(); $this->sIP = KTUtil::arrayGet($_SERVER, "REMOTE_ADDR", '0.0.0.0'); - + $oFolder = Folder::get($oDocument->getFolderID()); // head off the certain breakage down the line. if (PEAR::isError($oFolder) || ($oFolder === false)) { @@ -100,14 +100,14 @@ class DocumentTransaction extends KTEntity { $this->bAdminMode = 1; } else { $this->bAdminMode = 0; - } + } } } - + function getVersion() { return $this->sVersion; } function getComment() { return $this->sComment; } function _table() { return KTUtil::getTableName('document_transactions'); } - + // some of these can throw a PEAR::error function & getUser() { return User::get($this->iUserID); } function getFilename() { return $this->sFileName; } @@ -117,10 +117,10 @@ class DocumentTransaction extends KTEntity { $oType = $this->getTransactionType(); $action = _kt('Unknown Action'); if (!PEAR::isError($oType)) { $action = $oType->getName(); } - + return $action; } - + /** * Create the document transaction in the database * @@ -158,9 +158,9 @@ class DocumentTransaction extends KTEntity { $_SESSION["errorMessage"] = $lang_err_object_exists; return false; } - + } - + function delete() { global $default, $lang_err_database, $lang_err_object_key; if ($this->iId >= 0) { @@ -177,7 +177,7 @@ class DocumentTransaction extends KTEntity { $_SESSION["errorMessage"] = $lang_err_object_key; return false; } - + /** * Static function. Given a document transaction primary key will create * a document transaction object and populate it with the corresponding @@ -190,12 +190,12 @@ class DocumentTransaction extends KTEntity { if (strlen($iDocumentTransactionID) > 0) { $sql = $default->db; $sql->query(array("SELECT * FROM $default->document_transactions_table WHERE id = ?", $iDocumentTransactionID));/*ok*/ - if ($sql->next_record()) { - $oDocumentTransaction = & new DocumentTransaction(Document::get($sql->f("document_id")), $sql->f("comment"), $sql->f("transaction_namespace")); - $oDocumentTransaction->iId = $sql->f("id"); + if ($sql->next_record()) { + $oDocumentTransaction = new DocumentTransaction(Document::get($sql->f("document_id")), $sql->f("comment"), $sql->f("transaction_namespace")); + $oDocumentTransaction->iId = $sql->f("id"); $oDocumentTransaction->sVersion = $sql->f("version"); $oDocumentTransaction->iUserID = $sql->f("user_id"); - $oDocumentTransaction->dDateTime = $sql->f("datetime"); + $oDocumentTransaction->dDateTime = $sql->f("datetime"); $oDocumentTransaction->sIP = $sql->f("ip"); $oDocumentTransaction->sFileName = $sql->f("filename"); $oDocumentTransaction->bAdminMode = $sql->f("admin_mode"); diff --git a/lib/documentmanagement/DocumentType.inc b/lib/documentmanagement/DocumentType.inc index a277063..63df033 100644 --- a/lib/documentmanagement/DocumentType.inc +++ b/lib/documentmanagement/DocumentType.inc @@ -8,7 +8,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 @@ -19,9 +19,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 @@ -33,7 +33,7 @@ require_once(KT_LIB_DIR . "/util/sanitize.inc"); class DocumentType extends KTEntity { - + /** primary key value */ var $iId; /** document type name */ @@ -46,7 +46,7 @@ class DocumentType extends KTEntity { 'sName' => 'name', 'bDisabled' => 'disabled' ); - + /** * Default constructor * @@ -60,7 +60,7 @@ class DocumentType extends KTEntity { $this->sName = $sNewName; $this->bDisabled = false; } - + function getID() { return $this->iId; } function getName() { return sanitizeForSQLtoHTML($this->sName); } function setName($sNewValue) { $this->sName = sanitizeForSQL($sNewValue); } @@ -75,7 +75,7 @@ class DocumentType extends KTEntity { } function _table () { return KTUtil::getTableName('document_types'); } - + function delete() { if ($this->isUsed()) { return PEAR::raiseError(_kt('Document type still in use')); @@ -98,7 +98,7 @@ class DocumentType extends KTEntity { return false; } - /* + /* Get the fieldsets associated with this document type. Simplifies listing associated fieldsets in doctypes displays. */ @@ -106,7 +106,7 @@ class DocumentType extends KTEntity { function &getFieldsets() { return KTFieldset::getForDocumentType($this); } - + /** * Get the document types associated with a document */ @@ -114,17 +114,17 @@ class DocumentType extends KTEntity { $sTable = KTUtil::getTableName('document_metadata_version'); $sQuery = "SELECT DISTINCT(document_type_id) FROM {$sTable}"; $aDocTypes = DBUtil::getResultArray($sQuery); - + $aTypes = array(); if(!empty($aDocTypes)){ foreach($aDocTypes as $type){ $aTypes[] = $type['document_type_id']; } } - + return $aTypes; } - + /** * Check if a type is associated with any documents */ @@ -135,7 +135,7 @@ class DocumentType extends KTEntity { return TRUE; } } - + /** * Static- Get a list document types; * @@ -148,7 +148,7 @@ class DocumentType extends KTEntity { $aOptions = array('orderby' => 'name'); return KTEntityUtil::getList2('DocumentType', $sWhereClause, $aOptions); } - + /* alternative for use in creation: delegate for user and location */ function &getListForUserAndFolder($oUser, $oFolder) { $src =& KTDocumentTypeManager::getSingleton(); @@ -158,10 +158,10 @@ class DocumentType extends KTEntity { function &createFromArray($aArray) { return KTEntityUtil::createFromArray('DocumentType', $aArray); } - + function &get($iId) { return KTEntityUtil::get('DocumentType', $iId); } - - + + } @@ -176,7 +176,7 @@ class DocumentType extends KTEntity { * @return User user object */ function & documenttypeCreateFromArray($aParameters) { - $oDocType = & new DocumentType($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); + $oDocType = new DocumentType($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); return $oDocType; } @@ -184,11 +184,11 @@ function & documenttypeCreateFromArray($aParameters) { class DemoDelegation { var $handler_ns = 'brad.oddhandler'; var $handler_name = null; - + function DemoDelegation() { $this->handler_name = _kt('Demo Delegator'); } - + function &getListForUserAndFolder($oUser, $oFolder) { $list =& DocumentType::getList(); $finallist = array(); @@ -213,7 +213,7 @@ class KTDocumentTypeManager { } return $GLOBALS['oKTDocumentTypeManager']; } - + function &getListForUserAndFolder($oUser, $oFolder) { $this->checkActiveHandler(); if (is_null($this->_active_handler)) { @@ -222,7 +222,7 @@ class KTDocumentTypeManager { } else { $l = (array) $this->_active_handler->getListForUserAndFolder($oUser, $oFolder); } - + $final = array(); foreach ($l as $oType) { if (PEAR::isError($oType) || ($oType->getDisabled())) { @@ -232,12 +232,12 @@ class KTDocumentTypeManager { } return $final; } - + function checkActiveHandler() { if ($this->_checked) { return ; } // not perfect - see workflow-delegator for explanation. $res = KTUtil::getSystemSetting('documenttypehandler'); - + if (empty($res) || PEAR::isError($res)) { // just fail silently - don't degrade the system $this->_active_handler = null; } else { @@ -245,10 +245,10 @@ class KTDocumentTypeManager { $this->_active_handler = KTUtil::arrayGet($this->_handlers, $ns); } $this->_checked = true; - + return ; } - + function registerHandler($oHandler) { $this->_handlers[$oHandler->handler_ns] = $oHandler; } diff --git a/lib/documentmanagement/LinkType.inc b/lib/documentmanagement/LinkType.inc index 70a1e04..1cab703 100644 --- a/lib/documentmanagement/LinkType.inc +++ b/lib/documentmanagement/LinkType.inc @@ -8,7 +8,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 @@ -19,9 +19,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 @@ -36,7 +36,7 @@ require_once(KT_LIB_DIR . "/util/sanitize.inc"); class LinkType extends KTEntity { var $sName; var $sDescription; - + var $_aFieldToSelect = array( 'iId' => 'id', 'sName' => 'name', @@ -48,35 +48,35 @@ class LinkType extends KTEntity { $this->sName = $sName; $this->sDescription = $sDescription; } - + function getDescription() { return sanitizeForSQLtoHTML($this->sDescription); } - + function setDescription($sNewValue) { $this->sDescription = sanitizeForSQL($sNewValue); } - + function getName() { return sanitizeForSQLtoHTML($this->sName); } - + function setName($sNewValue) { $this->sName = sanitizeForSQL($sNewValue); } - + function _fieldValues () { return array( 'name' => sanitizeForSQLtoHTML($this->sName), 'description' => sanitizeForSQLtoHTML($this->sDescription), ); } - + function _table () { global $default; return $default->document_link_types_table; } - + function getList($sWhereClause = null) { return KTEntityUtil::getList(LinkType::_table(), 'LinkType', $sWhereClause); } @@ -93,7 +93,7 @@ class LinkType extends KTEntity { // XXX: No such key exception type return $res; } - $oLinkType =& new LinkType($res['name'], $res['description']); + $oLinkType =new LinkType($res['name'], $res['description']); $oLinkType->iId = $res['id']; return $oLinkType; } @@ -107,7 +107,7 @@ class LinkType extends KTEntity { } function &linktypecreateFromArray($aParameters) { - $oLinkType = & new LinkType($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); + $oLinkType = new LinkType($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); return $oLinkType; } diff --git a/lib/documentmanagement/MetaData.inc b/lib/documentmanagement/MetaData.inc index a89cc99..8a44405 100644 --- a/lib/documentmanagement/MetaData.inc +++ b/lib/documentmanagement/MetaData.inc @@ -8,7 +8,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 @@ -19,9 +19,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 @@ -33,7 +33,7 @@ require_once(KT_LIB_DIR . "/util/sanitize.inc"); class MetaData extends KTEntity { - + /** primary key value */ var $iId = -1; //document field id @@ -58,7 +58,7 @@ class MetaData extends KTEntity { 'bDisabled' => 'disabled', 'bIsStuck' => 'is_stuck', ); - + /** * Default constructor * @@ -72,7 +72,7 @@ class MetaData extends KTEntity { $this->sName = $sNewName; $this->iTreeParent = $iNewParent; } - + function getID() { return $this->iId; } function getName() { return sanitizeForSQLtoHTML($this->sName); } function setName($sNewValue) { $this->sName = sanitizeForSQL($sNewValue); } @@ -89,23 +89,23 @@ class MetaData extends KTEntity { global $default; return $default->metadata_table; } - + function & get($iId) { return KTEntityUtil::get('MetaData', $iId); } - + // FIXME this function makes no sense. function setMetaDataID($iDocFieldId, $sMetaDataName) { $sTable = KTUtil::getTableName('metadata'); $sQuery = "SELECT id FROM $sTable WHERE document_field_id = ? and name = ?"; - $aParams = array($iDocFieldId, $sMetaDataName); + $aParams = array($iDocFieldId, $sMetaDataName); $res = DBUtil::getResultArray(array($sQuery, $aParams)); - + if (PEAR::isError($res)) { return false; // return $res; - } - + } + if (count($res) != 0) { $this->iId = $id; return $res[0]['id']; @@ -144,7 +144,7 @@ class MetaData extends KTEntity { 'multi' => 'true', 'ids' => true, 'idfield' => 'name', - 'orderby' => 'name ASC', + 'orderby' => 'name ASC', )); } @@ -159,7 +159,7 @@ class MetaData extends KTEntity { 'disabled' => false, ), array( 'multi' => 'true', - 'orderby' => 'name ASC', + 'orderby' => 'name ASC', )); } @@ -170,7 +170,7 @@ class MetaData extends KTEntity { 'disabled' => true, ), array( 'multi' => true, - 'orderby' => 'name ASC', + 'orderby' => 'name ASC', )); } @@ -183,7 +183,7 @@ class MetaData extends KTEntity { 'multi' => 'true', 'ids' => true, 'idfield' => 'name', - 'orderby' => 'name ASC', + 'orderby' => 'name ASC', )); } @@ -196,7 +196,7 @@ class MetaData extends KTEntity { 'multi' => 'true', 'ids' => true, 'idfield' => 'name', - 'orderby' => 'name ASC', + 'orderby' => 'name ASC', )); } @@ -223,7 +223,7 @@ class MetaData extends KTEntity { * @return User user object */ function & metadataCreateFromArray($aParameters) { - $oMetaData = & new MetaData($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); + $oMetaData = new MetaData($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]); return $oMetaData; } diff --git a/lib/documentmanagement/PhysicalDocumentManager.inc b/lib/documentmanagement/PhysicalDocumentManager.inc index 727de2d..f8b5f50 100644 --- a/lib/documentmanagement/PhysicalDocumentManager.inc +++ b/lib/documentmanagement/PhysicalDocumentManager.inc @@ -376,7 +376,7 @@ class PhysicalDocumentManager { */ function & createDocumentFromUploadedFile($aFileArray, $iFolderID) { //get the uploaded document information and put it into a document object - $oDocument = & new Document($aFileArray['name'], $aFileArray['name'], $aFileArray['size'], $_SESSION["userID"], KTMime::getMimeTypeID($aFileArray['type'], $aFileArray['name']), $iFolderID); + $oDocument = new Document($aFileArray['name'], $aFileArray['name'], $aFileArray['size'], $_SESSION["userID"], KTMime::getMimeTypeID($aFileArray['type'], $aFileArray['name']), $iFolderID); return $oDocument; } } -- libgit2 0.21.4