Commit 8a9ef2151b3098db2a7b2ab9ab02a9eb948bd120

Authored by rob
1 parent dcba4f2f

Moved functionality into Folder.inc


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@356 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/foldermanagement/FolderLib.inc deleted
1 -<?php  
2 -  
3 -/**  
4 -* Class FolderLib  
5 -*  
6 -* Contains static miscellaneous functions used for folder management  
7 -*/  
8 -  
9 -class FolderLib {  
10 -  
11 - /**  
12 - * Check if the folder is a public folder  
13 - *  
14 - * @param $iFolderID Primary key of folder to check  
15 - *  
16 - * @return boolean true if folder is public, false otherwise and set $_SESSION["errorMessage"]  
17 - */  
18 - function isPublicFolder($iFolderID) {  
19 - global $default, $lang_err_database;  
20 - if (FolderManager::folderExistsID($iFolderID)) {  
21 - $sql = new Owl_DB();  
22 - $sql->query("SELECT is_public FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
23 - if ($sql->next_record()) {  
24 - return $sql->f("is_public");  
25 - }  
26 - $_SESSION["errorMessage"] = $lang_err_database;  
27 - return false;  
28 - }  
29 - //error message set by FolderManager::folderExists  
30 - return false;  
31 - }  
32 -  
33 - /**  
34 - * Get the document type for a folder  
35 - *  
36 - * @param $iFolderID  
37 - *  
38 - * @return integer document type primary key, false otherwise and set $_SESSION["errorMessage"]  
39 - */  
40 - function getFolderDocumentType($iFolderID) {  
41 - global $default, $lang_err_database;  
42 - if (FolderManager::folderExistsID($iFolderID)) {  
43 - $sql = new Owl_DB();  
44 - $sql->query("SELECT document_type_id FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
45 - if ($sql->next_record()) {  
46 - return $sql->f("document_type_id");  
47 - }  
48 - $_SESSION["errorMessage"] = $lang_err_database;  
49 -  
50 - }  
51 - //error message set by FolderManager::folderExists  
52 - return false;  
53 - }  
54 -  
55 - /**  
56 - * Get the folder name using the primary key  
57 - *  
58 - * @param $iFolderID Primary key of folder to get name for  
59 - *  
60 - * @return String name on success, false otherwise and set $_SESSION["errorMessage"]  
61 - */  
62 - function getFolderName($iFolderID) {  
63 - global $default, $lang_err_database;  
64 - $sql = new Owl_DB();  
65 - $sql->query("SELECT name FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
66 - if ($sql->next_record()) {  
67 - return stripslashes($sql->f("name"));  
68 - }  
69 - $_SESSION["errorMessage"] = $lang_err_database;  
70 - return false;  
71 - }  
72 -  
73 - /**  
74 - * Get the primary key of the parent folder  
75 - *  
76 - * @param $iFolderID Primary key of folder to get parent for  
77 - *  
78 - * @return integer primary key of parent folder  
79 - */  
80 - function getParentFolderID($iFolderID) {  
81 - global $default;  
82 - $sql = new Owl_DB();  
83 - $sql->query("SELECT parent_id FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
84 - $sql->next_record();  
85 - return $sql->f("parent_id");  
86 - }  
87 -  
88 - /**  
89 - * Get the full path for a folder  
90 - *  
91 - * @param Primary key of folder to generate path for  
92 - *  
93 - * @return String full path of folder  
94 - */  
95 - function getFolderPath($iFolderID) {  
96 - global $default;  
97 - //if the folder has a parent  
98 - if (FolderLib::getParentFolderID($iFolderID) != 0) {  
99 - $sCurrentPath = FolderLib::getFolderPath(FolderLib::getParentFolderID($iFolderID), FolderLib::getFolderName($iFolderID)) . "/" . $sCurremtPath;  
100 - }  
101 - return $default->owl_FileDir . "/" . FolderLib::getFolderName($iFolderID);  
102 -  
103 - }  
104 -}  
105 -?>  
lib/foldermanagement/FolderManager.inc deleted
1 -<?php  
2 -  
3 -/**  
4 -* Class FolderManager  
5 -*  
6 -* Contains static functions concerned with the insert, update and deletion of folders in  
7 -* the database.  
8 -*  
9 -* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
10 -* @date 15 January 2003  
11 -*/  
12 -  
13 -class FolderManager {  
14 -  
15 -  
16 - /**  
17 - * Insert a new folder into the database  
18 - *  
19 - * @param $sName Folder name  
20 - * @param $sDescription Short description of folder  
21 - * @param $iParentID Primary key of parent folder  
22 - * @param $iCreatorID ID of user who created the folder  
23 - * @param $iDocumentTypeID Document type this folder will store  
24 - * @param $iUnitID Unit to which the folder belongs  
25 - * @param $bIsPublic Is the folder public (default = false);  
26 - *  
27 - * @return true on sucessful insertion, false otherwise and set $_SESSION["errorMessage"]  
28 - */  
29 - function createFolder($sName, $sDescription, $iParentID, $iCreatorID, $iDocumentTypeID, $iUnitID, $bIsPublic = false) {  
30 - $sName = addslashes($sName);  
31 - $sDescription = addslashes($sDescription);  
32 - global $default, $lang_err_database;  
33 - //if the folder doesn't exist  
34 - if (!(FolderManager::folderExistsName($sName, $iParentID))) {  
35 - $sql = new Owl_DB();  
36 - $result = $sql->query("INSERT INTO " . $default->owl_folders_table . " (name, description, parent_id, creator_id, document_type_id, unit_id, is_public) " .  
37 - "VALUES ('" . $sName . "', '" . $sDescription . "', " . $iParentID . ", " . $iCreatorID . ", " . $iDocumentTypeID . ", " . $iUnitID . ", " . $bIsPublic . ")");  
38 - if (!$result) {  
39 - $_SESSION["errorMessage"] = $lang_err_database;  
40 - return false;  
41 - }  
42 - return true;  
43 - }  
44 - //error message set in folderExistsName  
45 - return false;  
46 -  
47 - }  
48 -  
49 - /**  
50 - * Delete and existing folder  
51 - *  
52 - * $iFolderID Primary key of folder to delete  
53 - *  
54 - * @return true on successfuly deletion, false otherwise and set $_SESSION["errorMessage"]  
55 - */  
56 - function deleteFolder($iFolderID) {  
57 - global $default,$lang_err_folder_not_exist;  
58 - //if the folder exists  
59 - if (FolderManager::folderExistsID($iFolderID)) {  
60 - $sql = new Owl_DB();  
61 - $result = $sql->query("DELETE FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
62 - if (!$result) {  
63 - $_SESSION["errorMessage"] = $lang_err_database;  
64 - return false;  
65 - }  
66 - return true;  
67 - }  
68 - $_SESSION["errorMessage"] = $lang_err_folder_not_exist . "id " . $iFolderID;  
69 - return false;  
70 - }  
71 -  
72 -  
73 - /**  
74 - * Checks if a given folder already exists using the folder name  
75 - *  
76 - * @param $sName Name of folder  
77 - * @param $iParentID Primary key of parent folder  
78 - *  
79 - * @return true if the folder exists, false otherwise and set $_SESSION["errorMessage"]  
80 - */  
81 - function folderExistsName($sName, $iParentID) {  
82 - $sName = addslashes($sName);  
83 - global $default, $lang_err_folder_exist;  
84 - $sql = new Owl_DB();  
85 - $sql->query("SELECT * FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " . $iParentID);  
86 - if ($sql->next_record()) {  
87 - return true;  
88 - }  
89 - $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName . " parent_id " . $iParentID;  
90 - return false;  
91 - }  
92 -  
93 - /**  
94 - * Checks if a given folder already exists using the folder name  
95 - *  
96 - * @param $iFolderID Primary key of folder  
97 - *  
98 - * @return true if the folder exists, false otherwise and set $_SESSION["errorMessage"]  
99 - */  
100 - function folderExistsID($iFolderID) {  
101 - global $default, $lang_err_folder_exist;  
102 - $sql = new Owl_DB();  
103 - $sql->query("SELECT * FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);  
104 - if ($sql->next_record()) {  
105 - return true;  
106 - }  
107 - $_SESSION["errorMessage"] =$lang_err_folder_exist . "id " . $iFolderID;  
108 - return false;  
109 - }  
110 -  
111 - /**  
112 - * Get a folder's primary key using the folder name and the parent id  
113 - *  
114 - * @param $sName Name of folder  
115 - * @param $iParentID Primary key of parent folder  
116 - *  
117 - * @return id integer on successful lookup, false otherwise and set $_SESSION["errorMessage"]  
118 - *  
119 - */  
120 - function getFolderID($sName, $iParentID) {  
121 - $sName = addslashes($sName);  
122 - global $default, $lang_err_folder_exist;  
123 - $sql = new Owl_DB();  
124 - $sql->query("SELECT id FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " . $iParentID);  
125 - if ($sql->next_record()) {  
126 - return $sql->f("id");  
127 - }  
128 - $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName;  
129 - return false;  
130 - }  
131 -}  
132 -?>