Commit d2d4909deeb33c5a4351d2f349027a4a26fee614

Authored by nbm
1 parent 9a86e7ed

Be aware that folders may not have any document type restrictions, and

simplify the display of the document types that are allowed.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3685 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/editUI.inc
1 <?php 1 <?php
2 -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");  
3 /** 2 /**
4 * $Id$ 3 * $Id$
5 * 4 *
@@ -26,6 +25,9 @@ require_once(&quot;$default-&gt;fileSystemRoot/lib/documentmanagement/Document.inc&quot;); @@ -26,6 +25,9 @@ require_once(&quot;$default-&gt;fileSystemRoot/lib/documentmanagement/Document.inc&quot;);
26 * @package foldermanagement 25 * @package foldermanagement
27 */ 26 */
28 27
  28 +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  29 +require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc');
  30 +
29 function getFolderPath($iFolderID) { 31 function getFolderPath($iFolderID) {
30 global $default; 32 global $default;
31 global $default; 33 global $default;
@@ -105,27 +107,31 @@ function getFolderRouting($iFolderID, $sDivName, $bCollaboration) { @@ -105,27 +107,31 @@ function getFolderRouting($iFolderID, $sDivName, $bCollaboration) {
105 } 107 }
106 108
107 function getFolderDocTypes($iFolderID, $sDivName) { 109 function getFolderDocTypes($iFolderID, $sDivName) {
108 - global $default;  
109 - /*ok*/ $sQuery = array("SELECT FDL.id, FDL.folder_id, FDL.document_type_id, DTL.name, 'Remove' AS del " .  
110 - "FROM $default->folder_doctypes_table AS FDL INNER JOIN $default->document_types_table AS DTL ON FDL.document_type_id = DTL.id " .  
111 - "WHERE FDL.folder_id = ? " .  
112 - "ORDER BY DTL.name ASC", $iFolderID);  
113 -  
114 - $aColumns = array("name", "del");  
115 - $aColumnHeaders = array("","");  
116 - $aColumnTypes = array(1,3,3);  
117 - $aDBColumnArray = array("id","folder_id");  
118 - $aQueryStringVariableNames = array("fFolderDocTypeID", "fFolderID");  
119 - $aLinkURLs = array(1=>"$default->rootUrl/control.php?action=deleteFolderDocType");  
120 -  
121 - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "610", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);  
122 - $oPatternTableSqlQuery->setTableHeading(_("Document Types"));  
123 - $oPatternTableSqlQuery->setDisplayColumnHeadings(true);  
124 -  
125 - $sToRender .= "<table>";  
126 - $sToRender .= "<tr><td>" . $oPatternTableSqlQuery->render() . "</td></tr>";  
127 - $sToRender .= "<tr><td><a href=\"$default->rootUrl/control.php?action=addFolderDocType&fFolderID=$iFolderID\"><img src=\"" . KTHtml::getAddButton() . "\" border=\"0\" /></a></td></tr>";  
128 - $sToRender .= "</table>"; 110 + $sTable = KTUtil::getTableName('folder_doctypes');
  111 + $aQuery = array(
  112 + "SELECT document_type_id FROM $sTable WHERE folder_id = ?",
  113 + array($iFolderID),
  114 + );
  115 + $aSelectedIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id');
  116 +
  117 + $sToRender = '<h2>Document Types</h2>';
  118 +
  119 + $oFolder =& Folder::get($iFolderID);
  120 + if ($oFolder->getRestrictDocumentTypes()) {
  121 + $sToRender .= '<h3>Document types are restricted to the following:</h3>';
  122 + $sToRender .= '<ul>';
  123 + foreach ($aSelectedIds as $iId) {
  124 + $oDocumentType =& DocumentType::get($iId);
  125 + $sToRender .= '<li>' . $oDocumentType->getName() . '</li>';
  126 + }
  127 + $sToRender .= '</ul>';
  128 + } else {
  129 + $sToRender .= '<h3>Document types are not restricted on this folder</h3>';
  130 + }
  131 + $sToRender .= sprintf(
  132 + '<a href="%s/control.php?action=editFolderDocType&fFolderId=%d"><img src="%s" border="0" /></a>',
  133 + $default->rootUrl, $iFolderID, KTHtml::getEditButton());
  134 +
129 return renderSectionDiv($sDivName, $sToRender); 135 return renderSectionDiv($sDivName, $sToRender);
130 } 136 }
131 137