Commit 3fb08d75bdd159f3a16b241a38c10289a72ff19c

Authored by rob
1 parent 8a54a2db

Initial revision. View dependant documents for a folder collaboration

step


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1851 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* Business logic for linking document creation to a folder collaboration step
  5 +*
  6 +* Expected variables:
  7 +* $fFolderCollaborationID: primary key of folder collaboration to check
  8 +* $fFolderID: folder we are currently editing
  9 +*
  10 +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  11 +* @date 14 May 2003
  12 +* @package presentation.lookAndFeel.knowledgeTree.foldermanagement
  13 +*/
  14 +
  15 +require_once("../../../../config/dmsDefaults.php");
  16 +
  17 +if (checkSession()) {
  18 + if (isset($fFolderID) && isset($fFolderCollaborationID)) {
  19 + require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  20 + require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
  21 + require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  22 + require_once("$default->fileSystemRoot/presentation/Html.inc");
  23 + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  24 + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  25 + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  26 + require_once("viewDependantDocumentsUI.inc");
  27 +
  28 + //folder and collaboration are selected
  29 + $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID);
  30 + if ($oFolderCollaboration->hasDocumentInProcess()) {
  31 + //can't add document links if a document is currently undergoing the
  32 + //collaboration process
  33 + echo "in here";
  34 +
  35 + } if (isset($fForAdd)) {
  36 + //we are adding a new dependant document
  37 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  38 + $oPatternCustom = & new PatternCustom();
  39 + $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : "")));
  40 + $main->setCentralPayload($oPatternCustom);
  41 + $main->setFormAction("document.MainForm.action = " . $_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1;document.MainForm.submit();");
  42 + $main->render();
  43 + } else {
  44 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  45 +
  46 + $oPatternCustom = & new PatternCustom();
  47 + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID));
  48 + $main->setCentralPayload($oPatternCustom);
  49 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
  50 + $main->render();
  51 + }
  52 +
  53 + }
  54 +
  55 +}
  56 +
  57 +?>
0 58 \ No newline at end of file
... ...
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc 0 → 100644
  1 +<?php
  2 +
  3 +
  4 +function renderHeading($sHeading) {
  5 + global $default;
  6 + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
  7 + $sColor = $default->siteMap->getSectionColour($sSectionName, "th");
  8 + $sToRender = "<table border=\"0\" width=\"600\">\n";
  9 + $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">$sHeading</th></tr>\n";
  10 + $sToRender .= "<tr/>\n";
  11 + $sToRender .= "<tr/>\n";
  12 + $sToRender .= "</table>\n";
  13 + return $sToRender;
  14 +}
  15 +
  16 +function getFolderPath($iFolderID) {
  17 + global $default;
  18 + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
  19 + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
  20 + $sFolderPathLink = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse");
  21 + return "<table border=\"0\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sFolderPathLink</td></tr></table>\n";
  22 +}
  23 +
  24 +function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
  25 + global $default;
  26 + $sQuery = "SELECT DDT.id, U.name AS username, DDT.document_title, D.name AS template_document_name, DDT.group_folder_approval_link_id, 'Edit' AS edit " .
  27 + "FROM dependant_document_template AS DDT INNER JOIN groups_folders_approval_link AS GFAL ON DDT.group_folder_approval_link_id = GFAL.id " .
  28 + "INNER JOIN users AS U ON U.id = DDT.default_user_id " .
  29 + "LEFT OUTER JOIN documents AS D ON D.id = DDT.template_document_id " .
  30 + "WHERE DDT.group_folder_approval_link_id = $iFolderCollaborationID";
  31 +
  32 + //echo $sQuery;
  33 + $aColumns = array("document_title", "username", "template_document_name","edit");
  34 + $aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit");
  35 + $aColumnTypes = array(1,1,1,3);
  36 + $aDBColumnArray = array("id","group_folder_approval_link_id");
  37 + $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID");
  38 + $aLinkURLs = array(3=>"$default->rootUrl/control.php?action=linkDocFolderCollaboration");
  39 +
  40 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);
  41 + $oPatternTableSqlQuery->setTableHeading("Linked Documents");
  42 + $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
  43 + $oPatternTableSqlQuery->setEmptyTableMessage("No dependant documents");
  44 +
  45 + return $oPatternTableSqlQuery->render();
  46 +
  47 +
  48 +}
  49 +
  50 +function getViewPage($iFolderCollaborationID, $iFolderID) {
  51 + global $default;
  52 + $sToRender = renderHeading("Dependant documents");
  53 + $sToRender .= getFolderPath($iFolderID);
  54 + $sToRender .= "<table border=\"0\" width=\"100%\">\n";
  55 + $sToRender .= "<tr>\n";
  56 + $sToRender .= "<td>" . getDocumentLinkFolderCollaborationData($iFolderCollaborationID) . "</td>\n";
  57 + $sToRender .= "</tr>\n";
  58 + $sToRender .= "<tr>\n";
  59 + $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/></td><td></td></tr></table>\n";
  60 + $sToRender .= "</tr>\n";
  61 + $sToRender .= "</table>\n";
  62 +
  63 + return $sToRender;
  64 +}
  65 +
  66 +function getEditPage() {
  67 +
  68 +}
  69 +
  70 +function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle) {
  71 + global $default;
  72 + $sToRender = renderHeading("Dependant documents");
  73 + $sToRender .= getFolderPath($iFolderID);
  74 + $sToRender .= "<table border=\"0\" width=\"100%\">\n";
  75 + $sToRender .= "<tr>\n";
  76 + $sToRender .= "<td>Document title</td><td><input type=\"text\" name=\"fDocumentTitle\" value=\"$sDocumentTitle\" /></td>\n";
  77 + $sToRender .= "</tr>\n";
  78 + $sToRender .= "<tr>\n";
  79 + $sToRender .= "<td>User's Unit</td><td>" . getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID) . "</td>\n";
  80 + $sToRender .= "</tr>\n";
  81 + $sToRender .= "<tr>\n";
  82 + $sToRender .= "<td>User</td><td>" . getUserDropDown($iUnitID) . "</td>\n";
  83 + $sToRender .= "</tr>\n";
  84 + $sToRender .= "<tr>\n";
  85 + $sToRender .= "<td>Template document</td><td><input type=\"text\" /></td>\n";
  86 + $sToRender .= "</tr>\n";
  87 + $sToRender .= "<tr>\n";
  88 + $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/></td><td></td></tr></table>\n";
  89 + $sToRender .= "</tr>\n";
  90 + $sToRender .= "</table>\n";
  91 +
  92 + return $sToRender;
  93 +}
  94 +
  95 +function getUserDropDown($iUnitID) {
  96 + global $default;
  97 + $oPatternListBox = & new PatternListBox($default->owl_users_table, "Name", "id", "fUserID", "GUL.unit_id = $iUnitID");
  98 + $sFromClause = "INNER join users_groups_link AS UGL ON UGL.user_id = ST.id " .
  99 + "INNER JOIN groups_units_link AS GUL ON GUL.group_id = UGL.group_id ";
  100 + $oPatternListBox->setFromClause($sFromClause);
  101 + return $oPatternListBox->render();
  102 +
  103 +
  104 +}
  105 +
  106 +function getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID) {
  107 + global $default;
  108 + $oPatternListBox = & new PatternListBox($default->owl_units_table, "Name", "id", "fUnitID");
  109 + $oPatternListBox->setPostBackOnChange(true);
  110 + $oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID&fForAdd=1')");
  111 + $oPatternListBox->setSelectedValue($iUnitID);
  112 + return $oPatternListBox->render();
  113 +}
  114 +
  115 +
  116 +?>
0 117 \ No newline at end of file
... ...