Commit 164558408611bb4318c5b2bdf4146aef58f8dbb6

Authored by nbm
1 parent b95af0da

Add bRestrictDocumentTypes, which tells if this folder restricts the

document types of the documents put in it (defaults to no).


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3679 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 18 additions and 6 deletions
lib/foldermanagement/Folder.inc
@@ -51,10 +51,12 @@ class Folder extends KTEntity { @@ -51,10 +51,12 @@ class Folder extends KTEntity {
51 var $iPermissionObjectID; 51 var $iPermissionObjectID;
52 /** lookup accelerator id */ 52 /** lookup accelerator id */
53 var $iPermissionLookupID; 53 var $iPermissionLookupID;
  54 + /** whether to restrict to only certain document types */
  55 + var $bRestrictDocumentTypes;
54 56
55 // {{{ KTEntity stuff 57 // {{{ KTEntity stuff
56 var $_aFieldToSelect = array( 58 var $_aFieldToSelect = array(
57 - 'iID' => 'id', 59 + 'iId' => 'id',
58 'sName' => 'name', 60 'sName' => 'name',
59 'sDescription' => 'description', 61 'sDescription' => 'description',
60 'iParentID' => 'parent_id', 62 'iParentID' => 'parent_id',
@@ -65,6 +67,7 @@ class Folder extends KTEntity { @@ -65,6 +67,7 @@ class Folder extends KTEntity {
65 'sParentFolderIDs' => 'parent_folder_ids', 67 'sParentFolderIDs' => 'parent_folder_ids',
66 'iPermissionObjectID' => 'permission_object_id', 68 'iPermissionObjectID' => 'permission_object_id',
67 'iPermissionLookupID' => 'permission_lookup_id', 69 'iPermissionLookupID' => 'permission_lookup_id',
  70 + 'bRestrictDocumentTypes' => 'restrict_document_types',
68 ); 71 );
69 // }}} 72 // }}}
70 73
@@ -111,6 +114,9 @@ class Folder extends KTEntity { @@ -111,6 +114,9 @@ class Folder extends KTEntity {
111 function getPermissionLookupID() { return $this->iPermissionLookupID; } 114 function getPermissionLookupID() { return $this->iPermissionLookupID; }
112 function setPermissionLookupID($iPermissionLookupID) { $this->iPermissionLookupID = $iPermissionLookupID; } 115 function setPermissionLookupID($iPermissionLookupID) { $this->iPermissionLookupID = $iPermissionLookupID; }
113 116
  117 + function getRestrictDocumentTypes() { return $this->bRestrictDocumentTypes; }
  118 + function setRestrictDocumentTypes($bRestrictDocumentTypes) { $this->bRestrictDocumentTypes = $bRestrictDocumentTypes; }
  119 +
114 // {{{ create() 120 // {{{ create()
115 function create () { 121 function create () {
116 $oParentFolder =& Folder::get($this->iParentID); 122 $oParentFolder =& Folder::get($this->iParentID);
@@ -181,6 +187,7 @@ class Folder extends KTEntity { @@ -181,6 +187,7 @@ class Folder extends KTEntity {
181 function _fieldValues () { 187 function _fieldValues () {
182 $this->sFullPath = $this->generateFolderPath($this->iParentID); 188 $this->sFullPath = $this->generateFolderPath($this->iParentID);
183 $this->sParentFolderIDs = $this->generateFolderIDs($this->iParentID); 189 $this->sParentFolderIDs = $this->generateFolderIDs($this->iParentID);
  190 + return parent::_fieldValues();
184 return array( 191 return array(
185 'name' => $this->sName, 192 'name' => $this->sName,
186 'description' => $this->sDescription, 193 'description' => $this->sDescription,
@@ -226,11 +233,11 @@ class Folder extends KTEntity { @@ -226,11 +233,11 @@ class Folder extends KTEntity {
226 * the paths of the children in the database 233 * the paths of the children in the database
227 * 234 *
228 */ 235 */
229 - function updateChildPaths($iID) { 236 + function updateChildPaths($iId) {
230 global $default; 237 global $default;
231 //get the direct children 238 //get the direct children
232 $sql = $default->db; 239 $sql = $default->db;
233 - $sql->query(array("SELECT id from $default->folders_table WHERE parent_id = ?", $iID));/*ok*/ 240 + $sql->query(array("SELECT id from $default->folders_table WHERE parent_id = ?", $iId));/*ok*/
234 while ($sql->next_record()) { 241 while ($sql->next_record()) {
235 //force an update, this will cause this child's children to be updated 242 //force an update, this will cause this child's children to be updated
236 $oFolder = Folder::get($sql->f("id")); 243 $oFolder = Folder::get($sql->f("id"));
@@ -246,8 +253,8 @@ class Folder extends KTEntity { @@ -246,8 +253,8 @@ class Folder extends KTEntity {
246 * update(). 253 * update().
247 */ 254 */
248 255
249 - function updateDocumentPaths($iID) {  
250 - $aDocuments = Document::getList(array('folder_id = ?', $iID)); 256 + function updateDocumentPaths($iId) {
  257 + $aDocuments = Document::getList(array('folder_id = ?', $iId));
251 if (PEAR::isError($aDocuments)) { 258 if (PEAR::isError($aDocuments)) {
252 return $aDocuments; 259 return $aDocuments;
253 } 260 }
@@ -303,10 +310,11 @@ class Folder extends KTEntity { @@ -303,10 +310,11 @@ class Folder extends KTEntity {
303 * 310 *
304 * @return Folder folder object on successful retrieval, false otherwise and set $_SESSION["errorMessage"] 311 * @return Folder folder object on successful retrieval, false otherwise and set $_SESSION["errorMessage"]
305 */ 312 */
  313 + /*
306 function get($iFolderID) { 314 function get($iFolderID) {
307 global $default, $lang_err_object_not_exist; 315 global $default, $lang_err_object_not_exist;
308 $sql = $default->db; 316 $sql = $default->db;
309 - $sql->query(array("SELECT * FROM " . $default->folders_table . " WHERE id = ?", $iFolderID));/*ok*/ 317 + $sql->query(array("SELECT * FROM " . $default->folders_table . " WHERE id = ?", $iFolderID));
310 if ($sql->next_record()) { 318 if ($sql->next_record()) {
311 $oFolder = & new Folder($sql->f("name"), $sql->f("description"), $sql->f("parent_id"), $sql->f("creator_id"), $sql->f("unit_id"), $sql->f("is_public")); 319 $oFolder = & new Folder($sql->f("name"), $sql->f("description"), $sql->f("parent_id"), $sql->f("creator_id"), $sql->f("unit_id"), $sql->f("is_public"));
312 $oFolder->iId = $iFolderID; 320 $oFolder->iId = $iFolderID;
@@ -319,6 +327,10 @@ class Folder extends KTEntity { @@ -319,6 +327,10 @@ class Folder extends KTEntity {
319 $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iFolderID . " table = folders"; 327 $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iFolderID . " table = folders";
320 return false; 328 return false;
321 } 329 }
  330 + */
  331 + function &get($iFolderID) {
  332 + return KTEntityUtil::get('Folder', $iFolderID);
  333 + }
322 334
323 /** 335 /**
324 * Checks if a folder with the same name and parent exists in the database already 336 * Checks if a folder with the same name and parent exists in the database already