diff --git a/.htaccess b/.htaccess index b1b6218..0997791 100644 --- a/.htaccess +++ b/.htaccess @@ -72,6 +72,7 @@ php_value post_max_size 2000M php_value memory_limit -1 php_value max_input_time -1 php_value max_execution_time 0 +php_value error_reporting 5 php_value upload_max_filesize -1 @@ -79,6 +80,7 @@ php_value post_max_size 2000M php_value memory_limit -1 php_value max_input_time -1 php_value max_execution_time 0 +php_value error_reporting 5 diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc index 45c3929..e7b48f5 100644 --- a/lib/documentmanagement/Document.inc +++ b/lib/documentmanagement/Document.inc @@ -1,4 +1,4 @@ -_oDocumentMetadataVersion =& $this->_oDocumentMetadataVersion->newCopy(); + if (PEAR::isError($this->_oDocumentMetadataVersion)) { + return $this->_oDocumentMetadataVersion; + } $this->_oDocumentMetadataVersion->bumpMetadataVersion(); $this->_oDocumentMetadataVersion->setVersionCreated(getCurrentDateTime()); $this->_oDocumentMetadataVersion->setVersionCreatorId($iUserId); @@ -554,6 +550,12 @@ class Document { $iUserId = KTUtil::getId($oUser); $this->_oDocumentContentVersion =& $this->_oDocumentContentVersion->newCopy(); $this->_oDocumentMetadataVersion =& $this->_oDocumentMetadataVersion->newCopy(); + if (PEAR::isError($this->_oDocumentContentVersion)) { + return $this->_oDocumentContentVersion; + } + if (PEAR::isError($this->_oDocumentMetadataVersion)) { + return $this->_oDocumentMetadataVersion; + } $this->_oDocumentMetadataVersion->bumpMetadataVersion(); $this->_oDocumentMetadataVersion->setVersionCreated(getCurrentDateTime()); $this->_oDocumentMetadataVersion->setVersionCreatorId($iUserId); diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 3895195..916f5b8 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -45,9 +45,9 @@ require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); require_once(KT_LIB_DIR . '/filelike/filelikeutil.inc.php'); require_once(KT_LIB_DIR . '/metadata/metadatautil.inc.php'); require_once(KT_LIB_DIR . '/metadata/fieldset.inc.php'); -require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); +require_once(KT_LIB_DIR . '/subscriptions/subscriptions.inc.php'); require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php'); -require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); +require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); // WORKFLOW require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); @@ -67,7 +67,7 @@ class KTDocumentUtil { KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion); if (!$oStorage->upload($oDocument, $sFilename)) { - return PEAR::raiseError(_kt("An error occurred while storing the new file")); + return PEAR::raiseError(_kt('An error occurred while storing the new file')); } $oDocument->setLastModifiedDate(getCurrentDateTime()); @@ -89,7 +89,7 @@ class KTDocumentUtil { if(strlen($sFilename)) { global $default; $oDocument->setFileName($sFilename); - $default->log->info("renamed document " . $oDocument->getId() . " to " . $sFilename); + $default->log->info('renamed document ' . $oDocument->getId() . ' to ' . $sFilename); } } @@ -102,7 +102,7 @@ class KTDocumentUtil { if (PEAR::isError($bSuccess)) { return $bSuccess; } - return PEAR::raiseError(_kt("An error occurred while storing this document in the database")); + return PEAR::raiseError(_kt('An error occurred while storing this document in the database')); } // create the document transaction record @@ -152,7 +152,7 @@ class KTDocumentUtil { $oDocument->setIsCheckedOut(true); $oDocument->setCheckedOutUserID($oUser->getId()); - if (!$oDocument->update()) { return PEAR::raiseError(_kt("There was a problem checking out the document.")); } + if (!$oDocument->update()) { return PEAR::raiseError(_kt('There was a problem checking out the document.')); } $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('checkout', 'postValidate'); @@ -160,7 +160,7 @@ class KTDocumentUtil { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger; $aInfo = array( - "document" => $oDocument, + 'document' => $oDocument, ); $oTrigger->setInfo($aInfo); $ret = $oTrigger->postValidate(); @@ -195,7 +195,7 @@ class KTDocumentUtil { } else { $iDocumentTypeId = 1; } - $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Creating database entry"))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating database entry'))); $oDocument =& Document::createFromArray(array( 'name' => $sDescription, 'description' => $sDescription, @@ -209,13 +209,13 @@ class KTDocumentUtil { } if (is_null($oContents)) { - $res = KTDocumentUtil::setIncomplete($oDocument, "contents"); + $res = KTDocumentUtil::setIncomplete($oDocument, 'contents'); if (PEAR::isError($res)) { $oDocument->delete(); return $res; } } else { - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Storing contents"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Storing contents'))); $res = KTDocumentUtil::storeContents($oDocument, $oContents, $aOptions); if (PEAR::isError($res)) { $oDocument->delete(); @@ -224,13 +224,13 @@ class KTDocumentUtil { } if (is_null($aMetadata)) { - $res = KTDocumentUtil::setIncomplete($oDocument, "metadata"); + $res = KTDocumentUtil::setIncomplete($oDocument, 'metadata'); if (PEAR::isError($res)) { $oDocument->delete(); return $res; } } else { - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Saving metadata"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Saving metadata'))); $res = KTDocumentUtil::saveMetadata($oDocument, $aMetadata, $aOptions); if (PEAR::isError($res)) { $oDocument->delete(); @@ -267,7 +267,7 @@ class KTDocumentUtil { if ($oField->getIsMandatory() && !$isRealConditional) { if (empty($v)) { // XXX: What I'd do for a setdefault... - $aFailed["field"][$oField->getId()] = 1; + $aFailed['field'][$oField->getId()] = 1; } } if (!empty($v)) { @@ -280,7 +280,7 @@ class KTDocumentUtil { if ($res) { foreach ($res as $aMDSet) { if ($aMDSet['field']->getIsMandatory()) { - $aFailed["fieldset"][$oFieldset->getId()] = 1; + $aFailed['fieldset'][$oFieldset->getId()] = 1; } } } @@ -295,7 +295,7 @@ class KTDocumentUtil { // {{{ saveMetadata function saveMetadata(&$oDocument, $aMetadata, $aOptions = null) { - $table = "document_fields_link"; + $table = 'document_fields_link'; $bNoValidate = KTUtil::arrayGet($aOptions, 'novalidate', false); if ($bNoValidate !== true) { $res = KTDocumentUtil::validateMetadata($oDocument, $aMetadata); @@ -317,15 +317,15 @@ class KTDocumentUtil { continue; } $res = DBUtil::autoInsert($table, array( - "metadata_version_id" => $iMetadataVersionId, - "document_field_id" => $oMetadata->getID(), - "value" => $sValue, + 'metadata_version_id' => $iMetadataVersionId, + 'document_field_id' => $oMetadata->getID(), + 'value' => $sValue, )); if (PEAR::isError($res)) { return $res; } } - KTDocumentUtil::setComplete($oDocument, "metadata"); + KTDocumentUtil::setComplete($oDocument, 'metadata'); KTDocumentUtil::updateSearchableText($oDocument); DocumentFieldLink::clearAllCaches(); return true; @@ -347,14 +347,14 @@ class KTDocumentUtil { // {{{ setIncomplete function setIncomplete(&$oDocument, $reason) { $oDocument->setStatusID(STATUS_INCOMPLETE); - $table = "document_incomplete"; + $table = 'document_incomplete'; $iId = $oDocument->getId(); $aIncomplete = DBUtil::getOneResult(array("SELECT * FROM $table WHERE id = ?", array($iId))); if (PEAR::isError($aIncomplete)) { return $aIncomplete; } if (is_null($aIncomplete)) { - $aIncomplete = array("id" => $iId); + $aIncomplete = array('id' => $iId); } $aIncomplete[$reason] = true; $res = DBUtil::autoDelete($table, $iId); @@ -371,7 +371,7 @@ class KTDocumentUtil { // {{{ setComplete function setComplete(&$oDocument, $reason) { - $table = "document_incomplete"; + $table = 'document_incomplete'; $iId = $oDocument->getID(); $aIncomplete = DBUtil::getOneResult(array("SELECT * FROM $table WHERE id = ?", array($iId))); if (PEAR::isError($aIncomplete)) { @@ -388,7 +388,7 @@ class KTDocumentUtil { $bIncomplete = false; foreach ($aIncomplete as $k => $v) { - if ($k === "id") { continue; } + if ($k === 'id') { continue; } if ($v) { $bIncomplete = true; @@ -428,12 +428,12 @@ class KTDocumentUtil { if (KTDocumentUtil::fileExists($oFolder, $sFilename)) { $oDoc = Document::getByFilenameAndFolder($sFilename, $oFolder->getId()); if (PEAR::isError($oDoc)) { - return PEAR::raiseError(_kt("Document with that filename already exists in this folder, and appears to be invalid. Please contact the system administrator.")); + return PEAR::raiseError(_kt('Document with that filename already exists in this folder, and appears to be invalid. Please contact the system administrator.')); } else { if ($oDoc->getStatusID() != LIVE) { - $sError = _kt("Document with that filename already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename."); + $sError = _kt('Document with that filename already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename.'); } else { - $sError = _kt("Document with that filename already exists in this folder."); + $sError = _kt('Document with that filename already exists in this folder.'); } $sError .= _kt(' Document') . ': ' . $oDoc->getName() . ' (ID:' . $oDoc->getId() . ')'; @@ -444,12 +444,12 @@ class KTDocumentUtil { if (KTDocumentUtil::nameExists($oFolder, $sName)) { $oDoc = Document::getByNameAndFolder($sName, $oFolder->getId()); if (PEAR::isError($oDoc)) { - return PEAR::raiseError(_kt("Document with that title already exists in this folder, and appears to be invalid. Please contact the system administrator.")); + return PEAR::raiseError(_kt('Document with that title already exists in this folder, and appears to be invalid. Please contact the system administrator.')); } else { if ($oDoc->getStatusID != LIVE) { - return PEAR::raiseError(_kt("Document with that title already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename.")); + return PEAR::raiseError(_kt('Document with that title already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename.')); } else { - return PEAR::raiseError(_kt("Document with that title already exists in this folder.")); + return PEAR::raiseError(_kt('Document with that title already exists in this folder.')); } } @@ -458,12 +458,12 @@ class KTDocumentUtil { $oUploadChannel =& KTUploadChannel::getSingleton(); $oUploadChannel->sendMessage(new KTUploadNewFile($sFilename)); $oDocument =& KTDocumentUtil::_add($oFolder, $sFilename, $oUser, $aOptions); - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Document created"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Document created'))); if (PEAR::isError($oDocument)) { return $oDocument; } - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Scanning file"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Scanning file'))); $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'scan'); $iTrigger = 0; @@ -479,7 +479,7 @@ class KTDocumentUtil { } } - $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Transforming file"))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Transforming file'))); $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); foreach ($aTriggers as $aTrigger) { @@ -493,7 +493,7 @@ class KTDocumentUtil { $oTrigger->transform(); } - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Creating transaction"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating transaction'))); $aOptions = array('user' => $oUser); //create the document transaction record $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document created'), 'ktcore.transactions.create', $aOptions); @@ -503,7 +503,7 @@ class KTDocumentUtil { return $res; } - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("Sending subscriptions"))); + // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Sending subscriptions'))); // fire subscription alerts for the checked in document $oSubscriptionEvent = new SubscriptionEvent(); $oFolder = Folder::get($oDocument->getFolderID()); @@ -516,7 +516,7 @@ class KTDocumentUtil { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger; $aInfo = array( - "document" => $oDocument, + 'document' => $oDocument, 'aOptions' => $aOrigOptions, ); $oTrigger->setInfo($aInfo); @@ -525,7 +525,7 @@ class KTDocumentUtil { } KTDocumentUtil::updateSearchableText($oDocument, true); - $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt("All done..."))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('All done...'))); return $oDocument; } @@ -555,7 +555,7 @@ class KTDocumentUtil { $oStorage =& KTStorageManagerUtil::getSingleton(); $oKTConfig =& KTConfig::getSingleton(); - $sBasedir = $oKTConfig->get("urls/tmpDirectory"); + $sBasedir = $oKTConfig->get('urls/tmpDirectory'); $sFilename = tempnam($sBasedir, 'kt_storecontents'); $oOutputFile = new KTFSFileLike($sFilename); @@ -570,12 +570,12 @@ class KTDocumentUtil { $oDocument->setMimeTypeId($iMimeTypeId); $res = $oStorage->upload($oDocument, $sFilename); if ($res === false) { - return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), _kt("No reason given"))); + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), _kt('No reason given'))); } if (PEAR::isError($res)) { return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); } - KTDocumentUtil::setComplete($oDocument, "contents"); + KTDocumentUtil::setComplete($oDocument, 'contents'); if ($aOptions['cleanup_initial_file']) { unlink($oContents->sFilename); @@ -600,8 +600,8 @@ class KTDocumentUtil { return $res; } $aInsert = array( - "document_id" => $iDocumentId, - "document_text" => $sAllComments, + 'document_id' => $iDocumentId, + 'document_text' => $sAllComments, ); return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); } @@ -612,7 +612,7 @@ class KTDocumentUtil { if (isset($GLOBALS['_IN_ADD']) && empty($bOverride)) { return; } - $sMetadata = KTUtil::arrayGet( $_REQUEST, "metadata_2"); + $sMetadata = KTUtil::arrayGet( $_REQUEST, 'metadata_2'); $oDocument = KTUtil::getObject('Document', $oDocument); $iDocumentId = $oDocument->getId(); $sTable = KTUtil::getTableName('document_transaction_text'); @@ -628,18 +628,18 @@ class KTDocumentUtil { foreach ($aFieldLinks as $oFieldLink) { $aFieldValues[] = $oFieldLink->getValue(); } - $sAllFieldText = join(" ", $aFieldValues); + $sAllFieldText = join(' ', $aFieldValues); $sDocumentFilename = $oDocument->getFilename(); $sDocumentTitle = $oDocument->getName(); - $sSearchableText = $sAllDocumentText . " " . $sAllFieldText . " " . $sAllComments . " " . $sDocumentFilename . " " . $sDocumentTitle . " " . $sMetadata; + $sSearchableText = $sAllDocumentText . ' ' . $sAllFieldText . ' ' . $sAllComments . ' ' . $sDocumentFilename . ' ' . $sDocumentTitle . ' ' . $sMetadata; $sTable = KTUtil::getTableName('document_searchable_text'); $aDelete = array( - "document_id" => $iDocumentId, + 'document_id' => $iDocumentId, ); DBUtil::whereDelete($sTable, $aDelete); $aInsert = array( - "document_id" => $iDocumentId, - "document_text" => $sSearchableText, + 'document_id' => $iDocumentId, + 'document_text' => $sSearchableText, ); return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); } @@ -688,17 +688,17 @@ class KTDocumentUtil { if (PEAR::isError($res) || ($res == false)) { DBUtil::rollback(); - return PEAR::raiseError(_kt("There was a problem deleting the document from the database.")); + return PEAR::raiseError(_kt('There was a problem deleting the document from the database.')); } // now move the document to the delete folder $res = $oStorageManager->delete($oDocument); if (PEAR::isError($res) || ($res == false)) { //could not delete the document from the file system - $default->log->error("Deletion: Filesystem error deleting document " . - $oDocument->getFileName() . " from folder " . + $default->log->error('Deletion: Filesystem error deleting document ' . + $oDocument->getFileName() . ' from folder ' . Folder::getFolderPath($oDocument->getFolderID()) . - " id=" . $oDocument->getFolderID()); + ' id=' . $oDocument->getFolderID()); // we use a _real_ transaction here ... @@ -710,7 +710,7 @@ class KTDocumentUtil { $oDocument->update(); */ - return PEAR::raiseError(_kt("There was a problem deleting the document from storage.")); + return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); } $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document deleted: ') . $sReason, 'ktcore.transactions.delete'); @@ -734,7 +734,7 @@ class KTDocumentUtil { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger; $aInfo = array( - "document" => $oDocument, + 'document' => $oDocument, ); $oTrigger->setInfo($aInfo); $ret = $oTrigger->postValidate(); @@ -888,7 +888,7 @@ class KTDocumentUtil { $res = $oStorage->renameDocument($oDocument, $oOldContentVersion, $sNewFilename); if (!$res) { - return PEAR::raiseError(_kt("An error occurred while storing the new file")); + return PEAR::raiseError(_kt('An error occurred while storing the new file')); } $oDocument->setLastModifiedDate(getCurrentDateTime()); @@ -900,7 +900,7 @@ class KTDocumentUtil { if (PEAR::isError($bSuccess)) { return $bSuccess; } - return PEAR::raiseError(_kt("An error occurred while storing this document in the database")); + return PEAR::raiseError(_kt('An error occurred while storing this document in the database')); } // create the document transaction record @@ -966,9 +966,9 @@ class KTDocumentUtil { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger; $aInfo = array( - "document" => $oDocument, - "old_folder" => $oOriginalFolder, - "new_folder" => $oFolder, + 'document' => $oDocument, + 'old_folder' => $oOriginalFolder, + 'new_folder' => $oFolder, ); $oTrigger->setInfo($aInfo); $ret = $oTrigger->postValidate(); diff --git a/lib/foldermanagement/folderutil.inc.php b/lib/foldermanagement/folderutil.inc.php index f8c01dd..d8fd6f8 100644 --- a/lib/foldermanagement/folderutil.inc.php +++ b/lib/foldermanagement/folderutil.inc.php @@ -31,7 +31,7 @@ */ require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); -require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); +require_once(KT_LIB_DIR . '/subscriptions/subscriptions.inc.php'); require_once(KT_LIB_DIR . '/permissions/permission.inc.php'); require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); @@ -97,7 +97,7 @@ class KTFolderUtil { function move($oFolder, $oNewParentFolder, $oUser, $sReason=null) { if (KTFolderUtil::exists($oNewParentFolder, $oFolder->getName())) { - return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder")); + return PEAR::raiseError(_kt('Folder with the same name already exists in the new parent folder')); } $oStorage =& KTStorageManagerUtil::getSingleton(); @@ -106,13 +106,13 @@ class KTFolderUtil { if (empty($iOriginalParentFolderId)) { // If we have no parent, then we're the root. If we're the // root - how do we move inside something? - return PEAR::raiseError(_kt("Folder has no parent")); + return PEAR::raiseError(_kt('Folder has no parent')); } $oOriginalParentFolder = Folder::get($iOriginalParentFolderId); if (PEAR::isError($oOriginalParentFolder)) { // If we have no parent, then we're the root. If we're the // root - how do we move inside something? - return PEAR::raiseError(_kt("Folder parent does not exist")); + return PEAR::raiseError(_kt('Folder parent does not exist')); } $iOriginalParentPermissionObjectId = $oOriginalParentFolder->getPermissionObjectId(); $iTargetPermissionObjectId = $oFolder->getPermissionObjectId(); @@ -126,11 +126,11 @@ class KTFolderUtil { // First, deal with SQL, as it, at least, is guaranteed to be atomic - $table = "folders"; + $table = 'folders'; if ($oNewParentFolder->getId() == 1) { $sNewParentFolderPath = $oNewParentFolder->getName(); - $sNewParentFolderIds = ""; + $sNewParentFolderIds = ''; } else { $sNewParentFolderPath = sprintf("%s/%s", $oNewParentFolder->getFullPath(), $oNewParentFolder->getName()); $sNewParentFolderIds = sprintf("%s,%s", $oNewParentFolder->getParentFolderIDs(), $oNewParentFolder->getID()); @@ -175,7 +175,7 @@ class KTFolderUtil { return $res; } - $table = "documents"; + $table = 'documents'; $sQuery = "UPDATE $table SET full_path = CONCAT(?, SUBSTRING(full_path FROM ?)), parent_folder_ids = CONCAT(?, SUBSTRING(parent_folder_ids FROM ?)) WHERE full_path LIKE ?"; $aParams = array( sprintf("%s", $sNewParentFolderPath), @@ -194,9 +194,9 @@ class KTFolderUtil { return $res; } - $sComment = sprintf("Folder moved from %s to %s", $sOldPath, $sNewParentFolderPath); + $sComment = sprintf(_kt("Folder moved from %s to %s"), $sOldPath, $sNewParentFolderPath); if($sReason !== null) { - $sComment .= sprintf(" (reason: %s)", $sReason); + $sComment .= sprintf(_kt(" (reason: %s)"), $sReason); } $oTransaction = KTFolderTransaction::createFromArray(array( diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index 0d9916d..8efcce1 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -1199,7 +1199,7 @@ class KTDocumentCopyAction extends KTDocumentAction { } //$aOptions = array('user' => $oUser); - //$oDocumentTransaction = & new DocumentTransaction($oNewDoc, "Document copied from old version.", 'ktcore.transactions.create', $aOptions); + //$oDocumentTransaction = & new DocumentTransaction($oNewDoc, 'Document copied from old version.', 'ktcore.transactions.create', $aOptions); //$res = $oDocumentTransaction->create(); $_SESSION['KTInfoMessage'][] = _kt('Document copied.'); diff --git a/plugins/ktcore/admin/deletedDocuments.php b/plugins/ktcore/admin/deletedDocuments.php index 53efa70..03a30a6 100755 --- a/plugins/ktcore/admin/deletedDocuments.php +++ b/plugins/ktcore/admin/deletedDocuments.php @@ -37,8 +37,8 @@ require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); -require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); -require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); +require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php'); +require_once(KT_LIB_DIR . '/templating/kt3template.inc.php'); class DeletedDocumentsDispatcher extends KTAdminDispatcher { var $sHelpPage = 'ktcore/admin/deleted documents.html'; @@ -47,7 +47,7 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; $this->oPage->setBreadcrumbDetails(_kt('view')); - $aDocuments =& Document::getList("status_id=" . DELETED); + $aDocuments =& Document::getList('status_id=' . DELETED); if(!empty($aDocuments)){ $items = count($aDocuments); @@ -160,7 +160,7 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; if (!$oStorage->expunge($oDoc)) { $aErrorDocuments[] = $oDoc->getDisplayPath(); } else { - $oDocumentTransaction = & new DocumentTransaction($oDoc, "Document expunged", 'ktcore.transactions.expunge'); + $oDocumentTransaction = & new DocumentTransaction($oDoc, _kt('Document expunged'), 'ktcore.transactions.expunge'); $oDocumentTransaction->create(); // delete this from the db now @@ -259,7 +259,8 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; // create a doc-transaction. // FIXME does this warrant a transaction-type? - $oTransaction = new DocumentTransaction($oDoc, _kt('Restored from deleted state by ') . $this->oUser->getName(), 'ktcore.transactions.update'); + $oTransaction = new DocumentTransaction($oDoc, sprintf(_kt("Restored from deleted state by %s"), $this->oUser->getName()), 'ktcore.transactions.update'); + if (!$oTransaction->create()) { ; // do nothing? the state of physicaldocumentmanager... } diff --git a/plugins/ktcore/admin/documentCheckout.php b/plugins/ktcore/admin/documentCheckout.php index 7f6e460..2499a60 100644 --- a/plugins/ktcore/admin/documentCheckout.php +++ b/plugins/ktcore/admin/documentCheckout.php @@ -44,15 +44,15 @@ class KTCheckoutAdminDispatcher extends KTAdminDispatcher { function do_main() { $this->aBreadcrumbs[] = array('name' => _kt('Document Checkout')); - $this->oPage->setBreadcrumbDetails(_kt("list checked out documents")); + $this->oPage->setBreadcrumbDetails(_kt('list checked out documents')); - $aDocuments = Document::getList("is_checked_out = 1"); + $aDocuments = Document::getList('is_checked_out = 1'); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/checkoutlisting'); $oTemplate->setData(array( - "context" => $this, - "documents" => $aDocuments, + 'context' => $this, + 'documents' => $aDocuments, )); return $oTemplate; } @@ -60,7 +60,7 @@ class KTCheckoutAdminDispatcher extends KTAdminDispatcher { function do_confirm() { $this->aBreadcrumbs[] = array('name' => _kt('Document Checkout')); - $this->oPage->setBreadcrumbDetails(_kt("confirm forced check-in")); + $this->oPage->setBreadcrumbDetails(_kt('confirm forced check-in')); $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (empty($document_id)) { @@ -82,9 +82,9 @@ class KTCheckoutAdminDispatcher extends KTAdminDispatcher { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/force_checkin_confirm'); $oTemplate->setData(array( - "context" => $this, - "document" => $oDocument, - "checkout_user" => $oUser, + 'context' => $this, + 'document' => $oDocument, + 'checkout_user' => $oUser, )); return $oTemplate; diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php index ab9aced..a5de966 100644 --- a/plugins/ktcore/document/edit.php +++ b/plugins/ktcore/document/edit.php @@ -1,5 +1,4 @@ oFolder->getId() == 1) { return null; } return parent::getInfo(); } @@ -76,15 +75,17 @@ class KTFolderRenameAction extends KTFolderAction { $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); $sOldFolderName = $this->oFolder->getName(); - $oParentFolder =& Folder::get($this->oFolder->getParentID()); - if(PEAR::isError($oParentFolder)) { - $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); - exit(0); - } + if ($this->oFolder->getId() != 1) { + $oParentFolder =& Folder::get($this->oFolder->getParentID()); + if(PEAR::isError($oParentFolder)) { + $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } - if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { - $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); - exit(0); + if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } } $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); diff --git a/plugins/ktstandard/KTEmail.php b/plugins/ktstandard/KTEmail.php index f02fed4..190e44a 100644 --- a/plugins/ktstandard/KTEmail.php +++ b/plugins/ktstandard/KTEmail.php @@ -31,16 +31,16 @@ require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); -require_once(KT_LIB_DIR . "/email/Email.inc"); -require_once(KT_LIB_DIR . "/users/User.inc"); -require_once(KT_LIB_DIR . "/groups/Group.inc"); -require_once(KT_LIB_DIR . "/documentmanagement/DocumentTransaction.inc"); -require_once(KT_LIB_DIR . "/documentmanagement/Document.inc"); +require_once(KT_LIB_DIR . '/email/Email.inc'); +require_once(KT_LIB_DIR . '/users/User.inc'); +require_once(KT_LIB_DIR . '/groups/Group.inc'); +require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); +require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); /** * Sends emails to the selected groups */ -function sendGroupEmails($aGroupIDs, $oDocument, $sComment = "", $bAttachDocument, &$aEmailErrors) { +function sendGroupEmails($aGroupIDs, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { global $default; // loop through groups @@ -55,7 +55,7 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = "", $bAttachDocumen } $aDestinationGroups[] = $oDestGroup; - $default->log->info("sendingEmail to group " . $oDestGroup->getName()); + $default->log->info('sendingEmail to group ' . $oDestGroup->getName()); // for each group, retrieve all the users foreach($aDestinationGroups as $oGroup){ $aUsers = array_merge($aUsers, $oGroup->getUsers()); @@ -63,21 +63,21 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = "", $bAttachDocumen // FIXME: this should send one email with multiple To: users for ($j=0; $jlog->info("sendingEmail to group-member " . $aUsers[$j]->getName() . " with email " . $aUsers[$j]->getEmail()); + $default->log->info('sendingEmail to group-member ' . $aUsers[$j]->getName() . ' with email ' . $aUsers[$j]->getEmail()); // the user has an email address and has email notification enabled if (strlen($aUsers[$j]->getEmail())>0 && $aUsers[$j]->getEmailNotification()) { //if the to address is valid, send the mail if (validateEmailAddress($aUsers[$j]->getEmail())) { sendEmail($aUsers[$j]->getEmail(), $aUsers[$j]->getName(), $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); } else { - $default->log->error("email validation failed for " . $aUsers[$j]->getEmail()); + $default->log->error('email validation failed for ' . $aUsers[$j]->getEmail()); } } else { - $default->log->info("either " . $aUsers[$j]->getUserName() . " has no email address, or notification is not enabled"); + $default->log->info('either ' . $aUsers[$j]->getUserName() . ' has no email address, or notification is not enabled'); } } } else { - $default->log->info("filtered group id=" . $aGroupIDs[$i]); + $default->log->info('filtered group id=' . $aGroupIDs[$i]); } } } @@ -85,14 +85,14 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = "", $bAttachDocumen /** * Sends emails to the selected users */ -function sendUserEmails($aUserIDs, $oDocument, $sComment = "", $bAttachDocument, &$aEmailErrors) { +function sendUserEmails($aUserIDs, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { global $default; // loop through users for ($i=0; $i 0) { $oDestUser = User::get($aUserIDs[$i]); - $default->log->info("sendingEmail to user " . $oDestUser->getName() . " with email " . $oDestUser->getEmail()); + $default->log->info('sendingEmail to user ' . $oDestUser->getName() . ' with email ' . $oDestUser->getEmail()); // the user has an email address and has email notification enabled if (strlen($oDestUser->getEmail())>0 && $oDestUser->getEmailNotification()) { //if the to address is valid, send the mail @@ -100,10 +100,10 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "", $bAttachDocument, sendEmail($oDestUser->getEmail(), $oDestUser->getName(), $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); } } else { - $default->log->info("either " . $oDestUser->getUserName() . " has no email address, or notification is not enabled"); + $default->log->info('either ' . $oDestUser->getUserName() . ' has no email address, or notification is not enabled'); } } else { - $default->log->info("filtered user id=" . $aUserIDs[$i]); + $default->log->info('filtered user id=' . $aUserIDs[$i]); } } } @@ -111,12 +111,12 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "", $bAttachDocument, /** * Sends emails to the manually entered email addresses */ -function sendManualEmails($aEmailAddresses, $oDocument, $sComment = "", $bAttachDocument, &$aEmailErrors) { +function sendManualEmails($aEmailAddresses, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { global $default; // loop through users foreach ($aEmailAddresses as $sEmailAddress) { - $default->log->info("sendingEmail to address " . $sEmailAddress); + $default->log->info('sendingEmail to address ' . $sEmailAddress); if (validateEmailAddress($sEmailAddress)) { sendEmail($sEmailAddress, $sEmailAddress, $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); } @@ -136,12 +136,12 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentN function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentName, $sComment, &$aEmailErrors) { global $default; - $oSendingUser = User::get($_SESSION["userID"]); + $oSendingUser = User::get($_SESSION['userID']); $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the attached document entitled '%s'."), $oSendingUser->getName(), $sDocumentName); $sMessage .= "\n\n"; if (strlen($sComment) > 0) { - $sMessage .= "

" . _kt("Comments:") . "
" . $sComment; + $sMessage .= '

' . _kt('Comments:') . '
' . $sComment; } $sTitle = sprintf(_kt("Document: %s from %s"), $sDocumentName, $oSendingUser->getName()); @@ -179,7 +179,7 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD } // emailed link transaction - $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document copy emailed to ') . $sDestEmailAddress, 'ktcore.transactions.email_attachment'); + $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt("Document copy emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_attachement'); if ($oDocumentTransaction->create()) { $default->log->debug("emailBL.php created email link document transaction for document ID=$iDocumentID"); } else { @@ -189,22 +189,22 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD function sendEmailHyperlink($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentName, $sComment, &$aEmailErrors) { global $default; - $oSendingUser = User::get($_SESSION["userID"]); + $oSendingUser = User::get($_SESSION['userID']); - $sMessage = ""; + $sMessage = ''; if ($sDestUserName) { - $sMessage .= $sDestUserName . ",

"; + $sMessage .= $sDestUserName . ',

'; } $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the document entitled '%s'."), $oSendingUser->getName(), $sDocumentName); $sMessage .= " \n"; - $sMessage .= _kt("Click on the hyperlink below to view it."); + $sMessage .= _kt('Click on the hyperlink below to view it.'); // add the link to the document to the mail - $sMessage .= "
" . generateControllerLink("viewDocument", "fDocumentID=$iDocumentID", $sDocumentName, true); + $sMessage .= '
' . generateControllerLink('viewDocument', "fDocumentID=$iDocumentID", $sDocumentName, true); // add optional comment if (strlen($sComment) > 0) { - $sMessage .= "

" . _kt("Comments:") . "
" . $sComment; + $sMessage .= '

' . _kt('Comments:') . '
' . $sComment; } - $sMessage .= "
"; + $sMessage .= '
'; $sTitle = sprintf(_kt("Link: %s from %s"), $sDocumentName, $oSendingUser->getName()); //email the hyperlink // @@ -234,8 +234,9 @@ function sendEmailHyperlink($sDestEmailAddress, $sDestUserName, $iDocumentID, $s // need a document to do this. $oDocument =& Document::get($iDocumentID); - $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document link emailed to ') . $sDestEmailAddress, 'ktcore.transactions.email_link'); - if ($oDocumentTransaction->create()) { + $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt("Document link emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_link'); + + if ($oDocumentTransaction->create()) { $default->log->debug("emailBL.php created email link document transaction for document ID=$iDocumentID"); } else { $default->log->error("emailBL.php couldn't create email link document transaction for document ID=$iDocumentID"); @@ -244,8 +245,8 @@ function sendEmailHyperlink($sDestEmailAddress, $sDestUserName, $iDocumentID, $s function validateEmailAddress($sEmailAddress) { $aEmailAddresses = array(); - if (strpos($sEmailAddress, ";")) { - $aEmailAddresses = explode(";", $sEmailAddress); + if (strpos($sEmailAddress, ';')) { + $aEmailAddresses = explode(';', $sEmailAddress); } else { $aEmailAddresses[] = $sEmailAddress; } @@ -302,20 +303,20 @@ class KTDocumentEmailAction extends KTDocumentAction { if ($bAttachment) { - $fields[] = new KTCheckboxWidget(_kt("Attach document"), - _kt("By default, documents are sent as links into the document management system. Select this option if you want the document contents to be sent as an attachment in the email."), + $fields[] = new KTCheckboxWidget(_kt('Attach document'), + _kt('By default, documents are sent as links into the document management system. Select this option if you want the document contents to be sent as an attachment in the email.'), 'fAttachDocument', null, $this->oPage); } if ($bEmailAddresses) { - $fields[] = new KTTextWidget(_kt("Email addresses"), - _kt("Add extra email addresses here"), - 'fEmailAddresses', "", $this->oPage, + $fields[] = new KTTextWidget(_kt('Email addresses'), + _kt('Add extra email addresses here'), + 'fEmailAddresses', '', $this->oPage, false, null, null, array('cols' => 60, 'rows' => 5)); } - $fields[] = new KTTextWidget(_kt("Comment"), - _kt("A message for those who receive the document"), - 'fComment', "", $this->oPage, + $fields[] = new KTTextWidget(_kt('Comment'), + _kt('A message for those who receive the document'), + 'fComment', '', $this->oPage, true, null, null, array('cols' => 60, 'rows' => 5)); @@ -406,13 +407,13 @@ class KTDocumentEmailAction extends KTDocumentAction { $aUserIDs = array(); $aEmailAddresses = array(); if (!empty($groupNewRight)) { - $aGroupIDs = explode(",", $groupNewRight); + $aGroupIDs = explode(',', $groupNewRight); } if (!empty($userNewRight)) { - $aUserIDs = explode(",", $userNewRight); + $aUserIDs = explode(',', $userNewRight); } if (!empty($fEmailAddresses)) { - $aEmailAddresses = explode(" ", $fEmailAddresses); + $aEmailAddresses = explode(' ', $fEmailAddresses); } $oConfig = KTConfig::getSingleton(); @@ -443,17 +444,17 @@ class KTDocumentEmailAction extends KTDocumentAction { sendManualEmails($aEmailAddresses, $this->oDocument, $fComment, (boolean)$fAttachDocument, $aEmailErrors); if (count($aEmailErrors)) { - $_SESSION['KTErrorMessage'][] = join("
\n", $aEmailErrors); + $_SESSION['KTErrorMessage'][] = join('
\n', $aEmailErrors); } - $_SESSION['KTInfoMessage'][] = _kt("Email sent"); + $_SESSION['KTInfoMessage'][] = _kt('Email sent'); //go back to the document view page - controllerRedirect("viewDocument", sprintf("fDocumentId=%d", $this->oDocument->getId())); + controllerRedirect('viewDocument', sprintf("fDocumentId=%d", $this->oDocument->getId())); } } class KTEmailPlugin extends KTPlugin { - var $sNamespace = "ktstandard.email.plugin"; + var $sNamespace = 'ktstandard.email.plugin'; function KTEmailPlugin($sFilename = null) { $res = parent::KTPlugin($sFilename); diff --git a/sql/mysql/upgrade/2.0.9/storagemanager.sql b/sql/mysql/upgrade/2.0.9/storagemanager.sql index c95be7d..3af690b 100644 --- a/sql/mysql/upgrade/2.0.9/storagemanager.sql +++ b/sql/mysql/upgrade/2.0.9/storagemanager.sql @@ -1,3 +1,4 @@ ALTER TABLE `documents` ADD `storage_path` VARCHAR( 250 ) ; ALTER TABLE `documents` ADD INDEX ( `storage_path` ) ; -UPDATE `documents` SET storage_path = CONCAT(full_path, "/", filename) WHERE storage_path IS NULL; +UPDATE `documents` d SET storage_path = (select CONCAT(CONCAT(CONCAT(CONCAT(f.full_path, "/"), f.name), "/"), filename) from folders f where f.id=d.folder_id) WHERE storage_path IS NULL; +UPDATE `documents` d SET storage_path=CONCAT(CONCAT(CONCAT("Deleted/", d.id), "-"), d.filename) where status_id=3;