Commit 05ad4ad2c56631f30507c5aea4c6f46f19872d71

Authored by rob
1 parent b5d83118

Require/include fields update. Some syntax correction


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@212 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentLib.inc
@@ -20,10 +20,10 @@ class DocumentLib { @@ -20,10 +20,10 @@ class DocumentLib {
20 global $lang_err_doc_no_folder; 20 global $lang_err_doc_no_folder;
21 $sql = new Owl_DB(); 21 $sql = new Owl_DB();
22 $sql->query("SELECT folder_id from " . $default->owl_documents_table . " WHERE id = " . $iDocumentID); 22 $sql->query("SELECT folder_id from " . $default->owl_documents_table . " WHERE id = " . $iDocumentID);
23 - if (sql->next_record()) {  
24 - return sql->f("folder_id"); 23 + if ($sql->next_record()) {
  24 + return $sql->f("folder_id");
25 } 25 }
26 - $_SESSION["errorMessage"] = $lang_err_doc_no_folder 26 + $_SESSION["errorMessage"] = $lang_err_doc_no_folder . "document id " . $iDocumentID;
27 return false; 27 return false;
28 } 28 }
29 29
lib/documentmanagement/documentManager.inc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 /** 3 /**
4 * Class DocumentManager 4 * Class DocumentManager
5 * 5 *
6 -* Contains all functions required for document management, 6 +* Contains static functions required for document management,
7 * such as the creation/deletion/removal of document types. 7 * such as the creation/deletion/removal of document types.
8 * 8 *
9 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa 9 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
@@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
13 * 13 *
14 */ 14 */
15 15
16 -require_once ("$default->owl_root_url/lib/owl.lib.php");  
17 -require_once("./phpmailer/class.phpmailer.php"); // for emailing 16 +//require_once ($default->owl_root_fs . "/lib/owl.lib.php");
  17 +require_once($default->owl_fs_root . "/phpmailer/class.phpmailer.php"); // for emailing
18 18
19 class DocumentManager { 19 class DocumentManager {
20 20
@@ -31,9 +31,9 @@ class DocumentManager { @@ -31,9 +31,9 @@ class DocumentManager {
31 //Get hold of the global error string 31 //Get hold of the global error string
32 global $default; 32 global $default;
33 //if the document type doesn't exist 33 //if the document type doesn't exist
34 - if (!($this->documentTypeExists($sName))) { 34 + if (!(DocumentManager::documentTypeExists($sName))) {
35 $sql = new Owl_DB(); 35 $sql = new Owl_DB();
36 - $result = $sql->query("INSERT INTO " . $default->owl_document_types_table . " (name) values ('" . $sName . "')"); 36 + $result = $sql->query("INSERT INTO " . $default->owl_document_types_table . " (name) values ('" . $sName . "')");
37 if (!$result) { 37 if (!$result) {
38 $_SESSION["errorMessage"] = "Database Error. Failed to insert document type " . $sName; 38 $_SESSION["errorMessage"] = "Database Error. Failed to insert document type " . $sName;
39 return false; 39 return false;
@@ -57,7 +57,7 @@ class DocumentManager { @@ -57,7 +57,7 @@ class DocumentManager {
57 //Get hold of the global error string 57 //Get hold of the global error string
58 global $default; 58 global $default;
59 //only remove the document type if it exists 59 //only remove the document type if it exists
60 - if ($this->documentTypeExists($sName)) { 60 + if (DocumentManager::documentTypeExists($sName)) {
61 $sql = new Owl_DB(); 61 $sql = new Owl_DB();
62 $result = $sql->query("DELETE FROM " . $default->owl_document_types_table . " WHERE name = '" . $sName . "'"); 62 $result = $sql->query("DELETE FROM " . $default->owl_document_types_table . " WHERE name = '" . $sName . "'");
63 if (!$result) { 63 if (!$result) {
@@ -95,7 +95,7 @@ class DocumentManager { @@ -95,7 +95,7 @@ class DocumentManager {
95 //escape special characters that may interfere with the db query 95 //escape special characters that may interfere with the db query
96 $sName = addslashes($sName); 96 $sName = addslashes($sName);
97 97
98 - if ($this->documentTypeExists($sName)) { 98 + if (DocumentManager::documentTypeExists($sName)) {
99 $sql = new Owl_DB(); 99 $sql = new Owl_DB();
100 $sql->query("SELECT ID FROM " . $default->owl_document_types_table . " WHERE name = '" . $sName . "'"); 100 $sql->query("SELECT ID FROM " . $default->owl_document_types_table . " WHERE name = '" . $sName . "'");
101 $sql->next_record(); 101 $sql->next_record();
@@ -136,7 +136,7 @@ class DocumentManager { @@ -136,7 +136,7 @@ class DocumentManager {
136 //Get hold of the global error string 136 //Get hold of the global error string
137 global $default; 137 global $default;
138 //if the document field type is not associated with the document 138 //if the document field type is not associated with the document
139 - if (!($this->documentTypeFieldExistsForDocumentType($iDocumentTypeID, $iDocumentTypeFieldID))) { 139 + if (!(DocumentManager::documentTypeFieldExistsForDocumentType($iDocumentTypeID, $iDocumentTypeFieldID))) {
140 $sql = new Owl_DB(); 140 $sql = new Owl_DB();
141 $result = $sql->query("INSERT INTO " . $default->owl_document_type_fields_table . " (document_type_id, field_id, is_mandatory) VALUES (" . $iDocumentTypeID . ", " . $iDocumentTypeFieldID . ", " . $bIsMandatory . ")"); 141 $result = $sql->query("INSERT INTO " . $default->owl_document_type_fields_table . " (document_type_id, field_id, is_mandatory) VALUES (" . $iDocumentTypeID . ", " . $iDocumentTypeFieldID . ", " . $bIsMandatory . ")");
142 if (!$result) { 142 if (!$result) {
@@ -159,7 +159,7 @@ class DocumentManager { @@ -159,7 +159,7 @@ class DocumentManager {
159 global $default; 159 global $default;
160 //Get hold of the global error string 160 //Get hold of the global error string
161 global $default; 161 global $default;
162 - if ($this->documentTypeFieldExistsForDocumentType($iDocumentTypeID, $iDocumentTypeFieldID)) { 162 + if (DocumentManager::documentTypeFieldExistsForDocumentType($iDocumentTypeID, $iDocumentTypeFieldID)) {
163 $sql = new Owl_DB(); 163 $sql = new Owl_DB();
164 $result = $sql->query("DELETE FROM " . $default->owl_document_type_fields_table . " where document_type_id = " . $iDocumentTypeID . " AND field_id = " . $iDocumentTypeFieldID); 164 $result = $sql->query("DELETE FROM " . $default->owl_document_type_fields_table . " where document_type_id = " . $iDocumentTypeID . " AND field_id = " . $iDocumentTypeFieldID);
165 if (!result) { 165 if (!result) {
@@ -203,7 +203,7 @@ class DocumentManager { @@ -203,7 +203,7 @@ class DocumentManager {
203 $sDataType = addslashes($sDataType); 203 $sDataType = addslashes($sDataType);
204 //Get hold of the global error string 204 //Get hold of the global error string
205 global $default; 205 global $default;
206 - if (!$this->documentTypeFieldExists($sName)) { 206 + if (!DocumentManager::documentTypeFieldExists($sName)) {
207 $sql = new Owl_DB(); 207 $sql = new Owl_DB();
208 $result = $sql->query("INSERT INTO " . $default->owl_fields_table . " (name, data_type) VALUES ('" . $sName . "', '" . $sDataType . "')"); 208 $result = $sql->query("INSERT INTO " . $default->owl_fields_table . " (name, data_type) VALUES ('" . $sName . "', '" . $sDataType . "')");
209 if (!$result) { 209 if (!$result) {
@@ -228,7 +228,7 @@ class DocumentManager { @@ -228,7 +228,7 @@ class DocumentManager {
228 $sName = addslashes($sName); 228 $sName = addslashes($sName);
229 //Get hold of the global error string 229 //Get hold of the global error string
230 global $default; 230 global $default;
231 - if ($this->documentTypeFieldExists($sName)) { 231 + if (DocumentManager::documentTypeFieldExists($sName)) {
232 $sql = new Owl_DB(); 232 $sql = new Owl_DB();
233 $result = $sql->query("DELETE FROM " . $default->owl_fields_table . " WHERE Name = '" . $sName . "'"); 233 $result = $sql->query("DELETE FROM " . $default->owl_fields_table . " WHERE Name = '" . $sName . "'");
234 if (!$result) { 234 if (!$result) {
@@ -251,7 +251,7 @@ class DocumentManager { @@ -251,7 +251,7 @@ class DocumentManager {
251 function & getDocumentTypeFieldID($sName) { 251 function & getDocumentTypeFieldID($sName) {
252 global $lang_err_document_type_field_does_not_exist, $default; 252 global $lang_err_document_type_field_does_not_exist, $default;
253 $sName = addslashes($sName); 253 $sName = addslashes($sName);
254 - if ($this->documentTypeFieldExists($sName)) { 254 + if (DocumentManager::documentTypeFieldExists($sName)) {
255 $sql = new Owl_DB(); 255 $sql = new Owl_DB();
256 $sql->query("SELECT id FROM " . $default->owl_fields_table . " WHERE name = '" . $sName . "'"); 256 $sql->query("SELECT id FROM " . $default->owl_fields_table . " WHERE name = '" . $sName . "'");
257 $sql->next_record(); 257 $sql->next_record();
lib/foldermanagement/FolderManager.inc
@@ -28,12 +28,13 @@ class FolderManager { @@ -28,12 +28,13 @@ class FolderManager {
28 */ 28 */
29 function insertFolder($sName, $sDescription, $iParentID, $iCreatorID, $iDocumentTypeID, $iUnitID, $bIsPublic = false) { 29 function insertFolder($sName, $sDescription, $iParentID, $iCreatorID, $iDocumentTypeID, $iUnitID, $bIsPublic = false) {
30 $sName = addslashes($sName); 30 $sName = addslashes($sName);
  31 + $sDescription = addslashes($sDescription);
31 global $default, $lang_err_database; 32 global $default, $lang_err_database;
32 //if the folder doesn't exist 33 //if the folder doesn't exist
33 - if (!(FolderNamager::folderExistsName($sName, $iParentID)) { 34 + if (!(FolderManager::folderExistsName($sName, $iParentID))) {
34 $sql = new Owl_DB(); 35 $sql = new Owl_DB();
35 $result = $sql->query("INSERT INTO " . $default->owl_folders_table . " (name, description, parent_id, creator_id, document_type_id, unit_id, is_public) " . 36 $result = $sql->query("INSERT INTO " . $default->owl_folders_table . " (name, description, parent_id, creator_id, document_type_id, unit_id, is_public) " .
36 - "VALUES (" . $sName . . $sDescription . . $iParentID . . $iCreatorID .. $iDocumentTypeID .. $UnitID .. $bIsPublice")"); 37 + "VALUES ('" . $sName . "', '" . $sDescription . "', " . $iParentID . ", " . $iCreatorID . ", " . $iDocumentTypeID . ", " . $iUnitID . ", " . $bIsPublic . ")");
37 if (!$result) { 38 if (!$result) {
38 $_SESSION["errorMessage"] = $lang_err_database; 39 $_SESSION["errorMessage"] = $lang_err_database;
39 return false; 40 return false;
@@ -55,7 +56,7 @@ class FolderManager { @@ -55,7 +56,7 @@ class FolderManager {
55 function deleteFolder($iFolderID) { 56 function deleteFolder($iFolderID) {
56 global $default,$lang_err_folder_not_exist; 57 global $default,$lang_err_folder_not_exist;
57 //if the folder exists 58 //if the folder exists
58 - if (folderExistsID($iFolderID)) { 59 + if (FolderManager::folderExistsID($iFolderID)) {
59 $sql = new Owl_DB(); 60 $sql = new Owl_DB();
60 $result = $sql->query("DELETE FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID); 61 $result = $sql->query("DELETE FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
61 if (!$result) { 62 if (!$result) {
@@ -118,19 +119,15 @@ class FolderManager { @@ -118,19 +119,15 @@ class FolderManager {
118 */ 119 */
119 function getFolderID($sName, $iParentID) { 120 function getFolderID($sName, $iParentID) {
120 $sName = addslashes($sName); 121 $sName = addslashes($sName);
121 - gobal $default, $lang_err_folder_exist; 122 + global $default, $lang_err_folder_exist;
122 $sql = new Owl_DB(); 123 $sql = new Owl_DB();
123 - $sql->query("SELECT id FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " $iParentID); 124 + $sql->query("SELECT id FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " . $iParentID);
124 if ($sql->next_record()) { 125 if ($sql->next_record()) {
125 return $sql->f("id"); 126 return $sql->f("id");
126 } 127 }
127 $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName; 128 $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName;
128 return false; 129 return false;
129 } 130 }
130 -  
131 -  
132 -  
133 } 131 }
134 -  
135 ?> 132 ?>
136 133