Commit 8f9aa69d319fc5b70b8f06a21351cb8929009f0e
1 parent
5db6c042
Simplified folder -> document type setting system (including the ability
to say that the folder doesn't have any restrictions) git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3681 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
92 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/foldermanagement/folderDocumentTypes.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once('../../../../config/dmsDefaults.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc'); | |
| 6 | +require_once(KT_LIB_DIR . '/foldermanagement/FolderDocTypeLink.inc'); | |
| 7 | + | |
| 8 | +$sectionName = "Administration"; | |
| 9 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 10 | + | |
| 11 | +class KTFolderDocumentTypeDispatcher extends KTStandardDispatcher { | |
| 12 | + function check () { | |
| 13 | + if (empty($_REQUEST['fFolderId'])) { | |
| 14 | + $this->permissionDenied(); | |
| 15 | + exit(0); | |
| 16 | + } | |
| 17 | + $oPermission = KTPermission::getByName('ktcore.permissions.write'); | |
| 18 | + $this->oFolder =& Folder::get($_REQUEST['fFolderId']); | |
| 19 | + $oUser =& User::get($_SESSION['userID']); | |
| 20 | + if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPermission, $this->oFolder)) { | |
| 21 | + $this->permissionDenied(); | |
| 22 | + exit(0); | |
| 23 | + } | |
| 24 | + return true; | |
| 25 | + } | |
| 26 | + | |
| 27 | + function do_main() { | |
| 28 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 29 | + $oTemplate = $oTemplating->loadTemplate('ktcore/documenttypes/folderassign'); | |
| 30 | + | |
| 31 | + $sTable = KTUtil::getTableName('folder_doctypes'); | |
| 32 | + $aQuery = array( | |
| 33 | + "SELECT document_type_id FROM $sTable WHERE folder_id = ?", | |
| 34 | + array($this->oFolder->getId()), | |
| 35 | + ); | |
| 36 | + $aSelectedIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); | |
| 37 | + | |
| 38 | + $oTemplate->setData(array( | |
| 39 | + 'oFolder' => $this->oFolder, | |
| 40 | + 'document_types' => DocumentType::getList(), | |
| 41 | + 'selected_types' => $aSelectedIds, | |
| 42 | + )); | |
| 43 | + return $oTemplate; | |
| 44 | + } | |
| 45 | + | |
| 46 | + function do_assign() { | |
| 47 | + if (empty($_REQUEST['restricted'])) { | |
| 48 | + $this->oFolder->setRestrictDocumentTypes(false); | |
| 49 | + } else { | |
| 50 | + $this->oFolder->setRestrictDocumentTypes(true); | |
| 51 | + } | |
| 52 | + | |
| 53 | + $sTable = KTUtil::getTableName('folder_doctypes'); | |
| 54 | + $res = DBUtil::runQuery(array( | |
| 55 | + "DELETE FROM $sTable WHERE folder_id = ?", | |
| 56 | + array($this->oFolder->getId()), | |
| 57 | + )); | |
| 58 | + foreach ($_REQUEST['document_types'] as $iDocumentTypeId) { | |
| 59 | + $oLink = new FolderDocTypeLink($this->oFolder->getId(), $iDocumentTypeId); | |
| 60 | + $oLink->create(); | |
| 61 | + } | |
| 62 | + $this->oFolder->update(); | |
| 63 | + $this->errorRedirectToMain('Changes made', 'fFolderId=' . | |
| 64 | + $this->oFolder->getId()); | |
| 65 | + exit(0); | |
| 66 | + } | |
| 67 | +} | |
| 68 | + | |
| 69 | +$d =& new KTFolderDocumentTypeDispatcher; | |
| 70 | +$d->dispatch(); | |
| 71 | + | |
| 72 | +?> | ... | ... |
templates/ktcore/documenttypes/folderassign.smarty
0 → 100644
| 1 | +<h1>Document types</h1> | |
| 2 | + | |
| 3 | +<p>Select document types allowed in folder:</p> | |
| 4 | + | |
| 5 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 6 | +<input type="hidden" name="action" value="assign"> | |
| 7 | +<input type="hidden" name="fFolderId" value="{$oFolder->getId()}"> | |
| 8 | +<table class="prettysw" cellspacing="0" cellpadding="0"> | |
| 9 | +<tr><th>Folder</th><td>{$oFolder->getName()}</td></tr> | |
| 10 | +<tr><th>Restrict document types</th><td>{boolean_checkbox name="restricted" bool=$oFolder->getRestrictDocumentTypes() }</td></tr> | |
| 11 | +<tr><th>Document Types</th><td> | |
| 12 | +{entity_select entities=$document_types selected=$selected_types name="document_types[]" multiple="yes"} | |
| 13 | +</td></tr> | |
| 14 | +</table> | |
| 15 | + | |
| 16 | +<input type="submit" name="submit" value="Assign"> | |
| 17 | +</form> | |
| 18 | + | |
| 19 | +{assign var="iFolderId" value=$oFolder->getId()} | |
| 20 | +<a href="{"editFolder"|generateControllerUrl:"fFolderID=$iFolderId"}">Back to folder</a> | ... | ... |