diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php deleted file mode 100644 index 16ace55..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php +++ /dev/null @@ -1,283 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); - -require_once("$default->fileSystemRoot/lib/email/Email.inc"); - -require_once("$default->fileSystemRoot/lib/users/User.inc"); - -require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc"); - -require_once("$default->fileSystemRoot/lib/archiving/ArchivingSettings.inc"); -require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiving.inc"); -require_once("$default->fileSystemRoot/lib/archiving/TimePeriod.inc"); - -require_once("$default->fileSystemRoot/lib/foldermanagement/FolderUserRole.inc"); -require_once("$default->fileSystemRoot/lib/roles/Role.inc"); -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); - -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); - -require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); - -require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); -require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); - -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/restoreArchivedDocumentUI.inc"); -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc"); -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); -require_once("$default->fileSystemRoot/presentation/Html.inc"); - -if (checkSession()) { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - if (isset($fDocumentID)) { - $oDocument = & Document::get($fDocumentID); - if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($oDocument)) { - //return value from collaborationBL.php. User attempted to edit - //a step in the document collaboration process that is currently being - //executed - $sStatusMessage = _("You cannot edit a document collaboration step that is completed or currently underway"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - $main->setDHTMLScrolling(false); - } else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($oDocument)) { - //begin the collaboration process - //first ensure that all steps in the collaboration process are assigned - $aFolderCollaboration = FolderCollaboration::getList(array("WHERE folder_id = ?", $oDocument->getFolderID()));/*ok*/ - if (count($aFolderCollaboration) > 0) { - //if the the folder has collaboration steps set up - $aFolderUserRoles = FolderUserRole::getList(array("document_id = ?", $fDocumentID));/*ok*/ - if (count($aFolderCollaboration) == count($aFolderUserRoles)) { - //if all the roles have been assigned we can start the collaboration process - - //TODO: check if this collaboration has already occured, and then reset all the steps before beginning it again - //DocumentCollaboration::resetDocumentCollaborationSteps($fDocumentID); - - $oDocument->beginCollaborationProcess(); - $sStatusMessage = _("Document collaboration successfully started"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } else { - // check that default users have been assigned to the routing steps before using them - - if (FolderCollaboration::defaultUsersAssigned($aFolderCollaboration)) { - //not all the roles have actual users assigned to them, so we must assign the - //default users and then proceed - - FolderUserRole::createDefaultFolderUserRoles($oDocument); - $oDocument->beginCollaborationProcess(); - $sStatusMessage = _("Document collaboration successfully started"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } else { - // the folder does not have default users assigned for the routing steps - $sStatusMessage = _("Default users have not been assigned at the folder level. Please set these up, or choose specific users for this document before attempting to start collaboration."); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } - } - } else { - //the folder has no collaboration set up yet, so we can't start document collaboration - $sStatusMessage = _("The collaboration steps for the folder must be set up before collaboration can begin"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } - $main->setDHTMLScrolling(false); - - } else if ((isset($fCollaborationStepComplete)) && (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($fDocumentID))) { - //the user has signled that they have completed their step in the collaboration process - if (DocumentCollaboration::isLastStepInCollaborationProcess($fDocumentID)) { - //the last step in the collaboration process has been performed- email the document creator - $oDocument->endCollaborationProcess(); - - // on the last collaboration step- trigger a major revision - // major version number rollover - $oDocument->setMajorVersionNumber($oDocument->getMajorVersionNumber()+1); - // reset minor version number - $oDocument->setMinorVersionNumber(0); - $oDocument->update(); - // TODO: create a transaction? - - $oUser = User::get($oDocument->getCreatorID()); - $sBody = $oUser->getName() . ", the collaboration process for the document, '" . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=" . $oDocument->getID(), $oDocument->getName()) . "', has been completed. "; - $oEmail = & new Email(); - $oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody); - - // collaboration accepted transaction - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document collaboration step accepted", COLLAB_ACCEPT); - if ($oDocumentTransaction->create()) { - $default->log->debug("viewBL.php created collaboration accepted document transaction for document ID=$fDocumentID"); - } else { - $default->log->error("viewBL.php couldn't create collaboration accepted document transaction for document ID=$fDocumentID"); - } - - //possibly set the document up for web publishing???? - $sStatusMessage = _("Document collaboration complete. The document initiator has been notified"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } else { - //start the next steps if all criteria are met - DocumentCollaboration::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]); - // collaboration accepted transaction - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document collaboration step accepted", COLLAB_ACCEPT); - if ($oDocumentTransaction->create()) { - $default->log->debug("viewBL.php created collaboration accepted document transaction for document ID=$fDocumentID"); - } else { - $default->log->error("viewBL.php couldn't create collaboration accepted document transaction for document ID=$fDocumentID"); - } - $sStatusMessage = _("The next steps in the collaboration process have been started"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } - $main->setDHTMLScrolling(false); - - } else if (isset($fForPublish) && - !DocumentCollaboration::documentIsPublished($fDocumentID) && - !DocumentCollaboration::documentIsPendingWebPublishing($fDocumentID)) { - - if ($fSubmit) { - // user wishes to publish document - $oWebDocument = WebDocument::get(lookupID($default->web_documents_table, "document_id", $fDocumentID)); - $default->log->info("retrieved web document=" . arrayToString($oWebDocument)); - if ($oWebDocument) { - if ($fWebSiteID) { - $oWebDocument->setStatusID(PENDING); - $oWebDocument->setWebSiteID($fWebSiteID); - $oWebDocument->setDateTime(getCurrentDateTime()); - } else { - $oWebDocument->setStatusID(PUBLISHED); - $oWebDocument->setWebSiteID(-1); - $oWebDocument->setDateTime(getCurrentDateTime()); - } - - if ($oWebDocument->update()) { - $default->log->info("updated status=" . arrayToString($oWebDocument)); - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE); - $oDocumentTransaction->create(); - if ((strlen($fWebSiteID) > 0)) { - DocumentCollaboration::notifyWebMaster($fDocumentID, $fComment); - } - if ($fWebSiteID) { - $sStatusMessage = _("The document has been marked as pending publishing and the web publisher has been notified"); - } else { - $sStatusMessage = _("The document has been published"); - } - $default->log->info("printing page"); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } else { - $sStatusMessage = _("An error occured while attempting to update the document for publishing. Please try again later."); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } - } else { - $sStatusMessage = _("An error occured while attempting to update the document for publishing. Please try again later."); - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); - } - } else { - // prompt for the website to publish to - $oPatternCustom->setHtml(getWebPublishPage($oDocument)); - $main->setFormAction($_SERVER['PHP_SELF']); - } - $main->setDHTMLScrolling(false); - - } else if (Permission::userHasDocumentWritePermission($oDocument) || Permission::userHasDocumentReadPermission($oDocument)) { - - // check subscription flag - // ?? - if (isset($fFireSubscription)) { - // fire subscription alerts for the modified document - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"), - SubscriptionConstants::subscriptionType("DocumentSubscription"), - array( "folderID" => $oDocument->getFolderID(), - "modifiedDocumentName" => $oDocument->getName())); - $default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName"); - } - - if ($oDocument->isLive()) { - if (Permission::userHasDocumentWritePermission($oDocument)) { - $oPatternCustom->setHtml(getPage($oDocument, true)); - } else if (Permission::userHasDocumentReadPermission($oDocument)) { - $oPatternCustom->setHtml(getPage($oDocument, false)); - } - $main->setDHTMLScrolling(false); - - $sJavaScript = "switchDiv('" . (isset($fShowSection) ? $fShowSection : "documentData") . "', 'document');"; - if ($fCheckedOut) { - $sCheckOutMessage = _("You have now checked out this document. No one else can make updates to the document while you have it checked out. Save the document, make your changes and check it back in as soon as you finish working on it."); - $sJavaScript .= "redirectLink('$sCheckOutMessage', '" . generateControllerUrl("downloadDocument", "fDocumentID=$fDocumentID") . "')"; - } - $main->setOnLoadJavaScript($sJavaScript); - } else if ($oDocument->isArchived()) { - - // allow admins to restore the document - if (Permission::userIsSystemAdministrator() || Permission::userIsUnitAdministrator()) { - $oPatternCustom->setHtml(getRestoreArchivedDocumentPage($oDocument)); - } else { - // and ordinary users to request that the document be restored - $oPatternCustom->setHtml(getRequestRestoreDocumentPage($oDocument)); - } - } else { - $oPatternCustom->setHtml("\n"); - $main->setErrorMessage(_("The document you have chosen no longer exists in the DMS.")); - } - $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID()); - } else { - if ($oDocument) { - $oPatternCustom->setHtml("\n"); - } else { - $oPatternCustom->setHtml("\n"); - } - $main->setErrorMessage(_("Either you do not have permission to view this document, or the document you have chosen no longer exists on the file system.")); - } - - } else { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom->setHtml("\n"); - $main->setErrorMessage(_("You have not chosen a document to view")); - } - $main->setCentralPayload($oPatternCustom); - $main->render(); -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc deleted file mode 100644 index 4da80f9..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc +++ /dev/null @@ -1,652 +0,0 @@ -siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > "; - // #3425 for consistency - if ($bDisplayActions) { - $sDocumentPath .= "" . $oDocument->getFileName() . ""; - } else { - $sDocumentPath .= $oDocument->getFileName(); - } - return "" . ($bDisplayActions ? "" : "") . "
" . $sDocumentPath . "Actions
\n"; -} - -function renderDocumentData($oDocument, $bEditable, $sStatusMessage = "") { - global $default; - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); - $aDocuments = array($oDocument->getID()); - if (!empty($iVersionID)) { - $aDocuments[] = $iVersionID; - } - $sWhere = DBUtil::paramArray($aDocuments); - /*ok*/ $sQuery = "SELECT D.id, D.name, D.modified, D.created, D.size, U.name AS initiator, D.metadata_version, CONCAT(CONCAT(D.major_version, '.'), D.minor_version) AS version, DTL.name AS document_type, D.is_checked_out, COALESCE(U2.name, '') AS c_user " . - "FROM $default->documents_table AS D " . - "LEFT JOIN $default->users_table AS U ON U.id = D.creator_id " . - "LEFT OUTER JOIN $default->document_types_table AS DTL ON DTL.id = D.document_type_id " . - "LEFT OUTER JOIN $default->users_table AS U2 ON U2.id = D.checked_out_user_id " . - "WHERE D.id = ?"; - - // $aColumns = array("metadata_version", "name", "modified", "created", "size", "initiator", "document_type", "c_user", "id", "version"); - $aColumns = array( - "metadata_version" =>_("Metadata Version"), - "name" => _("Document title"), - "modified" => _("Last updated"), - "created" => _("Created"), - "size" => _("File Size"), - "initiator" => _("Document initiator"), - "document_type" => _("Document Type"), - "c_user" => _("Checked out by"), - "id" => _("ID"), - "document_version" => _("Document Version"), - ); - - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document_generic_metadata'); - - $iDocumentsLen = count($aDocuments); - $map = array(); - $iDocumentCount = 0; - foreach ($aDocuments as $iDocumentID) { - $oThisDocument =& Document::get($iDocumentID); - if (PEAR::isError($oThisDocument)) { - continue; - } - if ($oThisDocument === false) { - continue; - } - $aRow = DBUtil::getOneResult(array($sQuery, array($iDocumentID))); - foreach ($aColumns as $dbname => $prettyname) { - $newarray = KTUtil::arrayGet($map, $prettyname, array_fill(0, $iDocumentsLen, null)); - $newarray[$iDocumentCount] = $aRow[$dbname]; - $map[$prettyname] = $newarray; - } - $oState =& KTWorkflowState::getByDocument($oThisDocument); - $map['Workflow state'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); - if ($oState) { - $map['Workflow state'][$iDocumentCount] = $oState->getHumanName(); - } else { - $map['Workflow state'][$iDocumentCount] = "Not in workflow"; - } - $iDocumentCount++; - } - - $oTemplate->setData(array( - 'map' => $map, - )); - - return $oTemplate->render(); -} - - -function renderGenericMetaData($oDocument, $bEditable) { - global $default; - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); - $aDocuments = array($oDocument->getID()); - if (!empty($iVersionID)) { - $aDocuments[] = $iVersionID; - } - /*ok*/ $sQuery = "SELECT DF.name AS name, DFL.value as value " . - "FROM $default->documents_table AS D INNER JOIN $default->document_fields_link_table AS DFL ON D.id = DFL.document_id " . - "INNER JOIN $default->document_fields_table AS DF ON DF.id = DFL.document_field_id " . - "WHERE document_id = ? " . - "AND DF.is_generic = 1"; - - - $iDocumentsLen = count($aDocuments); - $map = array(); - $iDocumentCount = 0; - foreach ($aDocuments as $iDocumentID) { - $map['Metadata Version'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); - $oThisDocument =& Document::get($iDocumentID); - if (PEAR::isError($oThisDocument)) { - continue; - } - if ($oThisDocument === false) { - continue; - } - $map['Metadata Version'][$iDocumentCount] = $oThisDocument->getMetadataVersion(); - $aTDRows = DBUtil::getResultArray(array($sQuery, array($iDocumentID))); - foreach ($aTDRows as $aRow) { - $newarray = KTUtil::arrayGet($map, $aRow['name'], array_fill(0, $iDocumentsLen, null)); - $newarray[$iDocumentCount] = $aRow['value']; - $map[$aRow['name']] = $newarray; - } - $iDocumentCount++; - } - - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document_generic_metadata'); - if ($bEditable) { - $editable = "rootUrl/control.php?action=modifyDocumentGenericMetaData&fDocumentID=" . $oDocument->getID() . "\">"; - } else { - $editable = ""; - } - $sToRender .= $oTemplate->render(array( - 'map' => $map, - 'editable' => $editable, - )); - - return $sToRender; -} - -function renderTypeSpecificMetaData($oDocument, $bEditable) { - global $default; - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); - $aDocuments = array($oDocument->getID()); - if (!empty($iVersionID)) { - $aDocuments[] = $iVersionID; - } - - $sParam = DBUtil::paramArray($aDocuments); - $sQuery = "SELECT D.id AS document_id, DF.id AS field_id, DFL.value AS value, F.id AS fieldset_id " . - "FROM $default->documents_table AS D INNER JOIN document_fields_link AS DFL ON D.id = DFL.document_id " . - "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . - "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . - "WHERE D.id IN ($sParam) " . - "AND DF.name NOT LIKE 'Category' " . - "AND DF.is_generic = 0"; - $aParam = $aDocuments; - - $aResults = DBUtil::getResultArray(array($sQuery, $aParam)); - - $aMap = array(); - foreach ($aResults as $aResult) { - $fieldset_id = $aResult['fieldset_id']; - $field_id = $aResult['field_id']; - $document_id = $aResult['document_id']; - $aMyFieldset = KTUtil::arrayGet($aMap, $fieldset_id); - if (empty($aMyFieldset)) { - $aMap[$fieldset_id]["fieldset"] = KTFieldset::get($fieldset_id); - $aMap[$fieldset_id]["fields"] = array(); - } - $aMyField = KTUtil::arrayGet($aMap[$fieldset_id]['fields'], $field_id); - if (empty($aMyField)) { - $aMap[$fieldset_id]['fields'][$field_id] = array(); - $aMap[$fieldset_id]['fields'][$field_id]['field'] = DocumentField::get($field_id); - $aMap[$fieldset_id]['fields'][$field_id]['values'] = array(); - } - $aMap[$fieldset_id]['fields'][$field_id]['values'][$document_id] = $aResult['value']; - } - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata'); - $sToRender = $oTemplate->render(array( - 'aDocumentIds' => $aDocuments, - 'map' => $aMap, - )); - return $sToRender; - - print "
";
-    foreach ($aMap as $k => $v) {
-        print $v['fieldset']->getName() . "\n";
-        foreach ($v['fields'] as $k => $aField) {
-            print $aField['field']->getName() . ": ";
-            foreach ($aField['values'] as $document_id => $sValue) {
-                print "$document_id => $sValue";
-            }
-            print "\n";
-        }
-        print "\n\n";
-    }
-    exit(0);
-
-
-    $oTemplating =& KTTemplating::getSingleton();
-    $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata');
-    if ($bEditable) {
-        $editable = "rootUrl/control.php?action=modifyDocumentTypeMetaData&fDocumentID=" . $oDocument->getID() . "\">";
-    } else {
-        $editable = "";
-    }
-    $sToRender = $oTemplate->render(array(
-        'map' => $map,
-        'editable' => $editable,
-    ));
-
-    return $sToRender;
-}
-
-function renderDocumentArchiveSettingsDetails($oDocument, $bEditable) {
-	global $default;
-	
-	// retrieve the appropriate settings given the document id
-	$oDocumentArchiving = DocumentArchiving::getFromDocumentID($oDocument->getID());
-	if ($oDocumentArchiving) {
-		// retrieve the settings
-		$oArchiveSettings = ArchivingSettings::get($oDocumentArchiving->getArchivingSettingsID());  			
-		// switch on archiving type
-		$sArchivingType = lookupName($default->archiving_type_lookup_table, $oArchiveSettings->getArchivingTypeID());
-		$oTimePeriod = TimePeriod::get($oArchiveSettings->getTimePeriodID());
-			
-		$sDisplayText = "";
-		switch ($sArchivingType) {
-			case "Date" : 
-				$sDisplayText  .= _("Expiration Date") . ": " . $oArchiveSettings->getExpirationDate();
-				if ($oTimePeriod) {
-					$sDisplayText .= "
Expires after " . $oTimePeriod->getUnits() . " "; - $sDisplayText .= lookupName($default->time_unit_lookup_table, $oTimePeriod->getTimeUnitID()) . " from document creation date"; - } - break; - case "Utilisation" : - $sDisplayText .= "Archive document " . $oTimePeriod->getUnits() . " "; - $sDisplayText .= lookupName($default->time_unit_lookup_table, $oTimePeriod->getTimeUnitID()); - $sDisplayText .= " after the last " . lookupName($default->transaction_types_table, $oArchiveSettings->getDocumentTransactionID()) . " transaction"; - break; - } - $sDisplayText .= "" . ($bEditable ? "" . generateControllerLink("modifyDocumentArchiveSettings", "fDocumentID=" . $oDocument->getID(), "Edit") . "" : ""); - $sArchivingType = _("Archiving Type") . ": " . $sArchivingType; - } else { - $sArchivingType = ""; - $sDisplayText = _("No archiving settings"); - } - - $sToRender = ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= $sDisplayText; - $sToRender .= ""; - $sToRender .= "
" . _("Archiving Settings") . "
" . $sArchivingType . "
"; - return $sToRender; -} - -function renderDocumentArchiveSettings($oDocument, $bEditable) { - global $default; - - $sToRender .= "\t\n"; - $sToRender .= "\t\n"; - - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - if ($bEditable) { - $sToRender .= "\t\n"; - // if there are no archiving settings then allow their addition - $oDocumentArchiving = DocumentArchiving::getFromDocumentID($oDocument->getID()); - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - } - $sToRender .= "\t
" . renderDocumentArchiveSettingsDetails($oDocument, $bEditable) . "
" . ($oDocumentArchiving ? "" : generateControllerLink("addDocumentArchiveSettings", "fDocumentID=" . $oDocument->getID(), "")) . "
\n"; - - return $sToRender; -} - -function renderEditableLinkedDocuments($oDocument) { - global $default; - - /*ok*/ $sQuery = array("SELECT D.id AS child_document_id, D.name, DL.id as document_link_id, " . - "DL.parent_document_id AS parent_document_id, DLT.name AS link_type, 'Unlink' AS unlink " . - "FROM $default->documents_table AS D INNER JOIN $default->document_link_table AS DL ON D.id = DL.child_document_id " . - "INNER JOIN $default->document_link_types_table AS DLT ON DL.link_type_id = DLT.id " . - "WHERE DL.parent_document_id = ?", $oDocument->getID()); - - $aColumns = array("name", "link_type", "unlink"); - $aColumnHeaders = array(_("Document"), _("Document Link Type")); - $aColumnTypes = array(3,3,3); - $aDBColumnArray = array("parent_document_id", "child_document_id","document_link_id", "child_document_id"); - $aQueryStringVariableNames = array("fParentDocumentID","fChildDocumentID", "fDocumentLinkID", "fDocumentID"); - $aLinkURLs = array(0=>"$default->rootUrl/control.php?action=viewDocument", 2=>"$default->rootUrl/control.php?action=removeDocumentLink"); - - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); - $oPatternTableSqlQuery->setTableHeading(_("Linked documents")); - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); - - $sToRender .= "\t\n"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\n"; - $sToRender .= "\n"; - $sToRender .= "\t"; - $sToRender .= "\t
" . $oPatternTableSqlQuery->render() . "
rootUrl/control.php?action=addDocumentLink&fDocumentID=" . $oDocument->getID() ."\">
\n"; - return $sToRender; -} - -function renderNonEditableLinkedDocuments($oDocument) { - global $default; - - /*ok*/ $sQuery = array("SELECT D.id, D.name " . - "FROM $default->documents_table AS D INNER JOIN $default->document_link_table AS DL ON D.id = DL.child_document_id " . - "WHERE DL.parent_document_id = ?", $oDocument->getID()); - - $aColumns = array("name"); - $aColumnHeaders = array(_("Document")); - $aColumnTypes = array(3); - $aDBColumnArray = array("id"); - $aQueryStringVariableNames = array("fDocumentID"); - $aLinkURLs = array(0=>"$default->rootUrl/control.php?action=viewDocument"); - - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); - $oPatternTableSqlQuery->setTableHeading(_("Linked documents")); - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); - - $sToRender .= "\t\n"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t
" . $oPatternTableSqlQuery->render() . "
\n"; - return $sToRender; -} - -function renderDependantDocuments($oDocument, $bEdit) { - global $default; - // FIXME: only allow escalation if you have write access and are the same user that requested the - // dependant document? - /*ok*/ $sQuery = array("SELECT DDI.id AS instance_id, DDI.document_title, U.name AS user_name, 'Escalate' AS escalate " . - "FROM $default->dependant_document_instance_table DDI " . - "INNER JOIN $default->users_table AS U ON DDI.user_id = U.id " . - "WHERE DDI.parent_document_id = ?", $oDocument->getID()); - - $aColumns = array("document_title", "user_name", "escalate"); - $aColumnHeaders = array(_("Document Title"), _("User")); - $aColumnTypes = array(1,1,3); - $aDBColumnArray = array("instance_id"); - $aQueryStringVariableNames = array("fInstanceID"); - $aLinkURLs = array(2=>generateControllerUrl("escalateDependantDocument")); - - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); - $oPatternTableSqlQuery->setTableHeading(_("Dependant documents")); - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); - - $sToRender .= "\t\n"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\n"; - $sToRender .= "\n"; - $sToRender .= "\t"; - $sToRender .= "\t
" . $oPatternTableSqlQuery->render() . "
rootUrl/control.php?action=createDependantDocument&fDocumentID=" . $oDocument->getID() ."\">
\n"; - return $sToRender; -} - -function renderDocumentVersions ($oDocument) { - $aVersions = Document::getByLiveDocument($oDocument); - $sToRender = "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $iDocumentID = $oDocument->getID(); - $sLink = generateControllerLink('viewDocument', "fDocumentID=$iDocumentID"); - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID"); - $sToRender .= sprintf('%s', $sLink, $oDocument->getMetadataVersion(), $oDocument->getLastModifiedDate(), $sDocumentLink, $oDocument->getVersion(), "\n"); - foreach ($aVersions as $oVersion) { - $iDocumentVersionID = $oVersion->getVersion(); - if ($iDocumentVersionID == $oDocument->getVersion()) { - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID"); - } else { - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID&fVersion=$iDocumentVersionID"); - } - $sToRender .= "\n"; - $iVersionID = $oVersion->getID(); - $sLink = generateControllerLink('viewDocument', "fDocumentID=$iDocumentID&fVersionID=$iVersionID"); - $sToRender .= sprintf('%s', $sLink, $oVersion->getMetadataVersion(), "\n"); - $sToRender .= sprintf('%s', $oVersion->getLastModifiedDate(), "\n"); - $sToRender .= sprintf('%s', $sDocumentLink, $oVersion->getVersion(), "\n"); - $sToRender .= "\n"; - } - $sToRender .= "\n"; - $sToRender .= "
Metadata VersionModified dateDocument Version
%s (Live)%s%s
%s%s%s
\n"; - return $sToRender; -} - -// This array exists only to give gettext a hint that these buttons -// should be added to the .po file. - -$aTranslatedButtons = array( - _("View"), - _("Email"), - _("Checkout"), - _("Delete"), - _("History"), - _("Move"), - _("Subscribe"), - _("Unsubscribe"), - _("Discussion"), - _("Archive"), - _("Link New Doc"), - _("Publish"), -); - - -$aImageNameToLabel = array( - "dependentdoc" => "Link new doc", -); - -function displayButton($sAction, $sQueryString, $sImageName, $sDisabledText = "", $sJS = "") { - global $default; - global $aImageNameToLabel; - // the active is active if there is no disabled text - $bActive = !strlen($sDisabledText) > 0; - if ($default->useTextButtons === false) { - $sImage = "graphicsUrl/widgets/docactions/"; - if ($bActive) { - $sImage .= "$sImageName.gif\""; - } else { - $sImage .= "disabled-$sImageName.gif\" title=\"$sDisabledText\""; - } - $sImage .= "/>"; - } else { - if (array_key_exists($sImageName, $aImageNameToLabel)) { - $sLabel = $aImageNameToLabel[$sImageName]; - } else { - $sLabel = $sImageName; - } - $sTranslatedWords = _(ucwords($sLabel)); - $sLabel = strtoupper($sTranslatedWords); - if ($bActive) { - $sClass = "button"; - $sJS = $sJS . " onMouseOver=\"javascript:this.style.backgroundColor='#EEEEEE';\" onMouseOut=\"javascript:this.style.backgroundColor='#FFFFFF';\""; - } else { - $sClass = "disabledbutton"; - } - $sImage = "$sLabel"; - } - if ($bActive) { - return generateControllerLink($sAction, $sQueryString, $sImage); - } else { - return $sImage; - } -} - -/** - * Displays document action buttons - */ - -function displayActionButtons($oDocument, $bEdit) { - require_once(KT_LIB_DIR . '/actions/documentaction.inc.php'); - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document_action'); - - $sToRender = ""; - - // XXX: Anonymous/Guest interaction - $oUser =& User::get($_SESSION["userID"]); - - foreach (KTDocumentActionUtil::getDocumentActionsForDocument($oDocument, $oUser) as $oAction) { - $aInfo = $oAction->getInfo(); - if (is_null($aInfo)) { - continue; - } - $sToRender .= $oTemplate->render($aInfo); - } - - return $sToRender; -} - -function renderSectionDiv($sDivName, $sHtml) { - global $default; - return "
$sHtml
"; -} - -function renderDocumentSection($sSectionName, $sHeadingText, $bDisplayLink, $iDocumentID) { - if ($bDisplayLink) { - $sLink = generateControllerLink("viewDocument", "fDocumentID=$iDocumentID&fShowSection=$sSectionName", $sHeadingText); - } else { - $sLink = "$sHeadingText"; - } - return '' . $sLink . '' . "\n"; -} - -function getPage($oDocument, $bEdit, $sStatusMessage = "") { - global $default; - - $sToRender .= renderHeading(_("Document Detail")); - $sToRender .= renderDocumentPath($oDocument, true) . "\n\n"; - $sToRender .= ""; - $sToRender .= ""; - - $sToRender .= ""; - $sToRender .= "
"; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= "
"; - - // if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable - // ie. effectively removes statusMessage on next click - $bDisplayLink = ($sStatusMessage) ? true : false; - - $sToRender .= renderDocumentSection("documentData", _("Document Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("genericMetaData", _("Generic Meta Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("typeSpecificMetaData", _("Type Specific Meta Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("archiveSettings", _("Archive Settings"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("linkedDocuments", _("Linked Documents"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("metadataVersions", _("Metadata Versions"), $bDisplayLink, $oDocument->getID()); - - $sToRender .= "
"; - $sToRender .= '
'; - $sToRender .= "\n"; - $sToRender .= displayActionButtons($oDocument, $bEdit); - $sToRender .= "
\n"; - $sToRender .= "
"; - - $sToRender .= '
'; - $sToRender .= renderSectionDiv("documentData", renderDocumentData($oDocument, $bEdit, $sStatusMessage)); - $sToRender .= renderSectionDiv("genericMetaData", renderGenericMetaData($oDocument, $bEdit)); - $sToRender .= renderSectionDiv("typeSpecificMetaData", renderTypeSpecificMetaData($oDocument, $bEdit)); - $sToRender .= renderSectionDiv("archiveSettings", renderDocumentArchiveSettings($oDocument, $bEdit)); - if ($bEdit) { - $sToRender .= renderSectionDiv("linkedDocuments", renderEditableLinkedDocuments($oDocument) . renderDependantDocuments($oDocument, $bEdit)); - } else { - $sToRender .= renderSectionDiv("linkedDocuments", renderNonEditableLinkedDocuments($oDocument, $bEdit) . renderDependantDocuments($oDocument, $bEdit)); - } - $sToRender .= renderSectionDiv("metadataVersions", renderDocumentVersions($oDocument)); - - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= "
"; - return $sToRender; -} - -function getStatusPage($oDocument, $sStatusMessage) { - global $default; - - $sToRender = "
"; - $sToRender .= renderHeading(_("Document Detail")); - $sToRender .= renderDocumentPath($oDocument, false) . "\n\n"; - $sToRender .= ""; - - // if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable - // ie. effectively removes statusMessage on next click - $bDisplayLink = ($sStatusMessage) ? true : false; - - $sToRender .= renderDocumentSection("documentData", _("Document Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("genericMetaData", _("Generic Meta Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("typeSpecificMetaData", _("Type Specific Meta Data"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("archiveSettings", _("Archive Settings"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("linkedDocuments", _("Linked Documents"), $bDisplayLink, $oDocument->getID()); - $sToRender .= renderDocumentSection("metadataVersions", _("Document Versions"), $bDisplayLink, $oDocument->getID()); - $sToRender .= "
"; - $sToRender .= "
"; - $sToRender .= renderDocumentData($oDocument, false, $sStatusMessage); - return $sToRender; -} - -function getWebPublishPage($oDocument) { - global $default; - - $oPatternListBox = & new PatternListBox($default->web_sites_table, "web_site_name", "id", "fWebSiteID"); - - $sToRender .= renderHeading(_("Document Detail")); - $sToRender .= renderDocumentPath($oDocument, false) . "\n\n"; - - $sToRender .= "\n"; - $sToRender .= "\t"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t\n"; - $sToRender .= "\t\t\n"; - $sToRender .= "\t"; - $sToRender .= "
" . _("Choose the website to publish to:") . "
" . $oPatternListBox->render() . "
" . _("Enter a comment for the web master:") . "
"; - $sToRender .= "\t\trootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\">
\n"; - - $sToRender .= "\n\n\n\n"; - - $sToRender .= renderDocumentData($oDocument, $bEdit); - - return $sToRender; -} - -function wrapInTable($sHtml) { - return "\n\t\t\t
$sHtml
\n"; -} -?>