Commit 257ca738b330c26946812a4c2bbf54ee3d1191c6
1 parent
31e1d05b
Initial revision. Object that represents groups_folders_approval_link table in database
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@411 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
246 additions
and
0 deletions
lib/groups/GroupFolderApprovalLink.inc
0 → 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | +* Class GroupFolderApprovalLink | |
| 4 | +* Represents a group/folder/approval link as per the groups_folders_approval_link | |
| 5 | +* | |
| 6 | +* groups_folders_approval_link are used to set the approval workflow for a document | |
| 7 | +* The precedence_id determines the order of the workflow | |
| 8 | +* | |
| 9 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 10 | +* @date 20 January 2003 | |
| 11 | +* @package lib.groups | |
| 12 | +*/ | |
| 13 | + | |
| 14 | +class GroupFolderApprovalLink { | |
| 15 | + | |
| 16 | + /** primary key of object */ | |
| 17 | + var $iId; | |
| 18 | + /** primary key of folder to which role is assigned */ | |
| 19 | + var $iFolderID; | |
| 20 | + /** primary key of group to which role is assigned */ | |
| 21 | + var $iGroupID; | |
| 22 | + /** link precedence (1 = highest) */ | |
| 23 | + var $iPrecedence; | |
| 24 | + /** primary key of role assigned to group */ | |
| 25 | + var $iRoleID; | |
| 26 | + | |
| 27 | + function GroupFolderApprovalLink($iNewFolderID, $iNewGroupID, $iNewPrecedence, $iNewRoleID) { | |
| 28 | + //object not created in database yet | |
| 29 | + $this->iId = -1; | |
| 30 | + $this->iFolderID = $iNewFolderID; | |
| 31 | + $this->iGroupID = $iNewGroupID; | |
| 32 | + $this->iPrecedence = $iNewPrecedence; | |
| 33 | + $this->iRoleID = $iNewRoleID; | |
| 34 | + } | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * Get the object's primary key | |
| 38 | + * | |
| 39 | + * @return int object's primary key | |
| 40 | + * | |
| 41 | + */ | |
| 42 | + function getID() { | |
| 43 | + return $this->iId; | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Get the primary key of the folder to which the group is assigned | |
| 48 | + * | |
| 49 | + * @return int primary key of folder to which the group is assigned | |
| 50 | + * | |
| 51 | + */ | |
| 52 | + function getFolderID() { | |
| 53 | + return $this->iFolderID; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Set the primary key of the folder to which the group is assigned | |
| 58 | + * | |
| 59 | + * @param int Primary key of folder to which the group is assigned | |
| 60 | + * | |
| 61 | + */ | |
| 62 | + function setFolderID($iNewValue) { | |
| 63 | + $this->iFolderID = $iNewValue; | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Get the primary key of the group to which the role is assigned | |
| 68 | + * | |
| 69 | + * @return int primary key of group to which the role is assigned | |
| 70 | + * | |
| 71 | + */ | |
| 72 | + function getGroupID() { | |
| 73 | + return $this->iGroupID; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Set the primary key of the group to which the role is assigned | |
| 78 | + * | |
| 79 | + * @param int Primary key of group to which the role is assigned | |
| 80 | + * | |
| 81 | + */ | |
| 82 | + function setGroupID($iNewValue) { | |
| 83 | + $this->iGroupID = $iNewValue; | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Get the precedence order for the GroupApprovalLink | |
| 88 | + * | |
| 89 | + * @return int precedence order for the GroupApprovalLink | |
| 90 | + * | |
| 91 | + */ | |
| 92 | + function getPrecedence() { | |
| 93 | + return $this->iPrecedence; | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Set the precedence order for the GroupApprovalLink | |
| 98 | + * | |
| 99 | + * @param int Precedence order for the GroupApprovalLink | |
| 100 | + * | |
| 101 | + */ | |
| 102 | + function setPrecedence($iNewValue) { | |
| 103 | + $this->iPrecedence = $iNewValue; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Get the primary key of the role assigned to the group | |
| 108 | + * | |
| 109 | + * @return int primary key of role assigned to group | |
| 110 | + * | |
| 111 | + */ | |
| 112 | + function getRoleID() { | |
| 113 | + return $this->iRoleID; | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Set the primary key of the role assigned to the group | |
| 118 | + * | |
| 119 | + * @param int Primary key of role assigned to the group | |
| 120 | + * | |
| 121 | + */ | |
| 122 | + function setRoleID($iNewValue) { | |
| 123 | + $this->iRoleID = $iNewValue; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Create the current object in the database | |
| 128 | + * | |
| 129 | + * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"] | |
| 130 | + * | |
| 131 | + */ | |
| 132 | + function create() { | |
| 133 | + global $default, $lang_err_database, $lang_err_object_exists; | |
| 134 | + //if the object hasn't been created | |
| 135 | + if ($this->iId < 0) { | |
| 136 | + $sql = new Owl_DB(); | |
| 137 | + $result = $sql->query("INSERT INTO " . $default->owl_groups_folders_approval_table . " (folder_id, group_id, precedence, role_id) VALUES ($this->iFolderID, $this->iGroupID, $this->iPrecedence, $this->iRoleID)"); | |
| 138 | + if ($result) { | |
| 139 | + $this->iId = $sql->insert_id(); | |
| 140 | + return true; | |
| 141 | + } | |
| 142 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 143 | + return false; | |
| 144 | + } | |
| 145 | + $_SESSION["errorMessage"] = $lang_err_object_exists . "id = " . $this->iId . " table = document_fields"; | |
| 146 | + return false; | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * Update the values in the database table with the object's current values | |
| 151 | + * | |
| 152 | + * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"] | |
| 153 | + * | |
| 154 | + */ | |
| 155 | + function update() { | |
| 156 | + global $default, $lang_err_database, $lang_err_object_key; | |
| 157 | + //only update if the object has been stored | |
| 158 | + if ($this->iId > 0) { | |
| 159 | + $sql = new Owl_DB(); | |
| 160 | + $result = $sql->query("UPDATE " . $default->owl_groups_folders_approval_table . " SET folder_id = $this->iFolderID, group_id = $this->iGroupID, precedence = $this->iPrecedence, role_id = $this->iRoleID WHERE id = $this->iId"); | |
| 161 | + if ($result) { | |
| 162 | + return true; | |
| 163 | + } | |
| 164 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + $_SESSION["errorMessage"] = $lang_err_object_key; | |
| 168 | + return false; | |
| 169 | + } | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * Delete the current object from the database | |
| 173 | + * | |
| 174 | + * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] | |
| 175 | + * | |
| 176 | + */ | |
| 177 | + function delete() { | |
| 178 | + global $default, $lang_err_database, $lang_err_object_key; | |
| 179 | + //only delete the object if it exists in the database | |
| 180 | + if ($this->iId >= 0) { | |
| 181 | + $sql = new Owl_DB(); | |
| 182 | + $result = $sql->query("DELETE FROM $default->owl_groups_folders_approval_table WHERE id = $this->iId"); | |
| 183 | + if ($result) { | |
| 184 | + return true; | |
| 185 | + } | |
| 186 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 187 | + return false; | |
| 188 | + } | |
| 189 | + $_SESSION["errorMessage"] = $lang_err_object_key; | |
| 190 | + return false; | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Static function. | |
| 195 | + * Given a web_documents primary key it will create a | |
| 196 | + * GroupFolderApprovalLink object and populate it with the | |
| 197 | + * corresponding database values | |
| 198 | + * | |
| 199 | + * @return GroupFolderApprovalLink populated GroupFolderApprovalLink object on successful query, false otherwise and set $_SESSION["errorMessage"] | |
| 200 | + */ | |
| 201 | + function & get($iGroupFolderLinkID) { | |
| 202 | + global $default; | |
| 203 | + $sql = new Owl_DB(); | |
| 204 | + $result = $sql->query("SELECT * FROM $default->owl_groups_folders_approval_table WHERE id = $iGroupFolderLinkID"); | |
| 205 | + if ($result) { | |
| 206 | + if ($sql->next_record()) { | |
| 207 | + $oGroupFolderApprovalLink = & new GroupFolderApprovalLink($sql->f("folder_id"), $sql->f("group_id"), $sql->f("precedence"), $sql->f("role_id"), $sql->f("datetime")); | |
| 208 | + $oGroupFolderApprovalLink->iId = $iGroupFolderLinkID; | |
| 209 | + return $oGroupFolderApprovalLink; | |
| 210 | + } | |
| 211 | + $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iGroupFolderLinkID . " table = $default-owl_groups_folders_approval_table"; | |
| 212 | + return false; | |
| 213 | + } | |
| 214 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 215 | + return false; | |
| 216 | + } | |
| 217 | + | |
| 218 | +/** | |
| 219 | + * Static function | |
| 220 | + * Get a list of groups_folders_approval_link | |
| 221 | + * | |
| 222 | + * @param String Where clause (not required) | |
| 223 | + * | |
| 224 | + * @return Array array of GroupFolderApprovalLink objects, false otherwise and set $_SESSION["errorMessage"] | |
| 225 | + */ | |
| 226 | + function getList($sWhereClause = null) { | |
| 227 | + global $default, $lang_err_database; | |
| 228 | + $aGroupFolderApprovalLinkArray; | |
| 229 | + settype($aGroupFolderApprovalLinkArray, "array"); | |
| 230 | + $sql = new Owl_DB(); | |
| 231 | + $result = $sql->query("SELECT * FROM " . $default->owl_groups_folders_approval_table . (isset($sWhereClause) ? " " . $sWhereClause : "")); | |
| 232 | + if ($result) { | |
| 233 | + $iCount = 0; | |
| 234 | + while ($sql->next_record()) { | |
| 235 | + $oGroupFolderApprovalLink = & GroupFolderApprovalLink::get($sql->f("id")); | |
| 236 | + $aGroupFolderApprovalLinkArray[$iCount] = $oGroupFolderApprovalLink; | |
| 237 | + $iCount++; | |
| 238 | + } | |
| 239 | + return $aGroupFolderApprovalLinkArray; | |
| 240 | + } | |
| 241 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 242 | + return false; | |
| 243 | + } | |
| 244 | + | |
| 245 | +} | |
| 246 | +?> | ... | ... |