FolderLib.inc
2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Class FolderLib
*
* Contains static miscellaneous functions used for folder management
*/
class FolderLib {
/**
* Check if the folder is a public folder
*
* @param $iFolderID Primary key of folder to check
*
* @return boolean true if folder is public, false otherwise and set $_SESSION["errorMessage"]
*/
function isPublicFolder($iFolderID) {
global $default, $lang_err_database;
if (FolderManager::folderExistsID($iFolderID)) {
$sql = new Owl_DB();
$sql->query("SELECT is_public FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
if ($sql->next_record()) {
return $sql->f("is_public");
}
$_SESSION["errorMessage"] = $lang_err_database;
return false;
}
//error message set by FolderManager::folderExists
return false;
}
/**
* Get the document type for a folder
*
* @param $iFolderID
*
* @return integer document type primary key, false otherwise and set $_SESSION["errorMessage"]
*/
function getFolderDocumentType($iFolderID) {
global $default, $lang_err_database;
if (FolderManager::folderExistsID($iFolderID)) {
$sql = new Owl_DB();
$sql->query("SELECT document_type_id FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
if ($sql->next_record()) {
return $sql->f("document_type_id");
}
$_SESSION["errorMessage"] = $lang_err_database;
}
//error message set by FolderManager::folderExists
return false;
}
/**
* Get the folder name using the primary key
*
* @param $iFolderID Primary key of folder to get name for
*
* @return String name on success, false otherwise and set $_SESSION["errorMessage"]
*/
function getFolderName($iFolderID) {
global $default, $lang_err_database;
$sql = new Owl_DB();
$sql->query("SELECT name FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
if ($sql->next_record()) {
return stripslashes($sql->f("name"));
}
$_SESSION["errorMessage"] = $lang_err_database;
return false;
}
/**
* Get the primary key of the parent folder
*
* @param $iFolderID Primary key of folder to get parent for
*
* @return integer primary key of parent folder
*/
function getParentFolderID($iFolderID) {
global $default;
$sql = new Owl_DB();
$sql->query("SELECT parent_id FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
$sql->next_record();
return $sql->f("parent_id");
}
/**
* Get the full path for a folder
*
* @param Primary key of folder to generate path for
*
* @return String full path of folder
*/
function getFolderPath($iFolderID) {
global $default;
//if the folder has a parent
if (FolderLib::getParentFolderID($iFolderID) != 0) {
$sCurrentPath = FolderLib::getFolderPath(FolderLib::getParentFolderID($iFolderID), FolderLib::getFolderName($iFolderID)) . "/" . $sCurremtPath;
}
return $default->owl_FileDir . "/" . FolderLib::getFolderName($iFolderID);
}
}
?>