Commit a7735a5e3b4fabb9072a030be3e2b03b239d501a
1 parent
a5af1010
Remove GroupUserLink - rather use hasMember/addMember/removeMember, &c.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3429 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
0 additions
and
246 deletions
lib/groups/GroupUserLink.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Represents a group, unit link as per the database table groups_units_link. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package lib.groups | |
| 26 | - */ | |
| 27 | -class GroupUserLink extends KTEntity { | |
| 28 | - | |
| 29 | - /** primary key of object */ | |
| 30 | - var $iId; | |
| 31 | - /** primary key of group to which unit is linked */ | |
| 32 | - var $iGroupID; | |
| 33 | - /** primary key of unit to which group is linked */ | |
| 34 | - var $iUserID; | |
| 35 | - | |
| 36 | - function GroupUserLink($iNewGroupID, $iNewUserID) { | |
| 37 | - //object not created in database yet | |
| 38 | - $this->iId = -1; | |
| 39 | - $this->iGroupID = $iNewGroupID; | |
| 40 | - $this->iUserID = $iNewUserID; | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * Get the object's primary key | |
| 45 | - * | |
| 46 | - * @return int object's primary key | |
| 47 | - * | |
| 48 | - */ | |
| 49 | - function getID() { | |
| 50 | - return $this->iId; | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Get the primary key of the group to which the unit is linked | |
| 55 | - * | |
| 56 | - * @return int primary key of group to which unit is linked | |
| 57 | - * | |
| 58 | - */ | |
| 59 | - function getGroupID() { | |
| 60 | - return $this->iGroupID; | |
| 61 | - } | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * Set the primary key of the group to which the unit is linked | |
| 65 | - * | |
| 66 | - * @param int Primary key of group to which unit is ilinked | |
| 67 | - * | |
| 68 | - */ | |
| 69 | - function setGroupID($iNewValue) { | |
| 70 | - $this->iGroupID = $iNewValue; | |
| 71 | - } | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * Get the prijmary key of the unit to which the group is linked | |
| 75 | - * | |
| 76 | - * @return int primary key of unit to which the group is linked | |
| 77 | - * | |
| 78 | - */ | |
| 79 | - function getUserID() { | |
| 80 | - return $this->iUserID; | |
| 81 | - } | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * Set the primary key of the unit to which the group is linked | |
| 85 | - * | |
| 86 | - * @param int Primary key of unit to which the group is linked | |
| 87 | - * | |
| 88 | - */ | |
| 89 | - function setUserID($iNewValue) { | |
| 90 | - $this->iUserID = $iNewValue; | |
| 91 | - } | |
| 92 | - | |
| 93 | - function _fieldValues () { | |
| 94 | - return array( | |
| 95 | - 'group_id' => $this->iGroupID, | |
| 96 | - 'user_id' => $this->iUserID, | |
| 97 | - ); | |
| 98 | - } | |
| 99 | - | |
| 100 | - function _table () { | |
| 101 | - global $default; | |
| 102 | - return $default->users_groups_table; | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Create the current object in the database | |
| 107 | - * | |
| 108 | - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"] | |
| 109 | - * | |
| 110 | - */ | |
| 111 | - function create() { | |
| 112 | - global $default, $lang_err_database, $lang_err_object_exists; | |
| 113 | - //if the object hasn't been created | |
| 114 | - if ($this->iId < 0) { | |
| 115 | - $sql = $default->db; | |
| 116 | - $query = "SELECT user_id, group_id FROM ". $default->users_groups_table ." WHERE user_id = ? and group_id = ?";/*ok*/ | |
| 117 | - $aParams = array($this->iUserID, $this->iGroupID); | |
| 118 | - $sql->query(array($query, $aParams)); | |
| 119 | - $rows = $sql->num_rows($sql); | |
| 120 | - | |
| 121 | - if ($rows > 0) { | |
| 122 | - $_SESSION["errorMessage"] = "GroupUserLink::The id " . $this->iUnitID . " already exists!"; | |
| 123 | - return false; | |
| 124 | - } | |
| 125 | - } | |
| 126 | - $res = parent::create(); | |
| 127 | - if (($res === false) || (PEAR::isError($res))) { | |
| 128 | - return $res; | |
| 129 | - } | |
| 130 | - $this->updateSearchPermissions(); | |
| 131 | - return $res; | |
| 132 | - } | |
| 133 | - | |
| 134 | - function delete() { | |
| 135 | - $res = parent::delete(); | |
| 136 | - if (($res === false) || (PEAR::isError($res))) { | |
| 137 | - return $res; | |
| 138 | - } | |
| 139 | - $this->updateSearchPermissions(); | |
| 140 | - return $res; | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * Static function. | |
| 145 | - * Given a groups_units_link primary key it will create a | |
| 146 | - * GroupUserLink object and populate it with the | |
| 147 | - * corresponding database values | |
| 148 | - * | |
| 149 | - * @return GroupUserLink populated GroupUserLink object on successful query, false otherwise and set $_SESSION["errorMessage"] | |
| 150 | - */ | |
| 151 | - function & get($iGroupUserLinkID) { | |
| 152 | - global $default; | |
| 153 | - $sql = $default->db; | |
| 154 | - $result = $sql->query(array("SELECT * FROM $default->users_groups_table WHERE id = ?", $iGroupUserLinkID));/*ok*/ | |
| 155 | - if ($result) { | |
| 156 | - if ($sql->next_record()) { | |
| 157 | - $oGroupUserLink = & new GroupUserLink($sql->f("group_id"), $sql->f("user_id")); | |
| 158 | - $oGroupUserLink->iId = $iGroupUserLinkID; | |
| 159 | - return $oGroupUserLink; | |
| 160 | - } | |
| 161 | - $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iGroupUserLinkID . " table = $default->users_groups_table"; | |
| 162 | - return false; | |
| 163 | - } | |
| 164 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 165 | - return false; | |
| 166 | - } | |
| 167 | - | |
| 168 | - /** | |
| 169 | - * Static function | |
| 170 | - * Get a list of web documents | |
| 171 | - * | |
| 172 | - * @param String Where clause (not required) | |
| 173 | - * | |
| 174 | - * @return Array array of GroupUserLink objects, false otherwise and set $_SESSION["errorMessage"] | |
| 175 | - */ | |
| 176 | - function getList($sWhereClause = null) { | |
| 177 | - return KTEntityUtil::getList(GroupUserLink::_table(), 'GroupUserLink', $sWhereClause); | |
| 178 | - } | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * Updates the search permissions for a group | |
| 182 | - */ | |
| 183 | - function updateSearchPermissions() { | |
| 184 | - Permission::updateSearchPermissionsForUser($this->getUserID()); | |
| 185 | - } | |
| 186 | - | |
| 187 | - function getGroups($iUserID) { | |
| 188 | - global $default, $lang_err_database; | |
| 189 | - $aGroupUserLink; | |
| 190 | - settype($aGroupUserLink, "array"); | |
| 191 | - $sql = $default->db; | |
| 192 | - $result = $sql->query(array("SELECT group_id FROM " . $default->users_groups_table . " Where user_id = ?", $iUserID));/*ok*/ | |
| 193 | - if ($result) { | |
| 194 | - $iCount = 0; | |
| 195 | - while ($sql->next_record()) { | |
| 196 | - //$oGroupUserLink = & GroupUserLink::get($sql->f("id")); | |
| 197 | - $aGroupUserLink[$iCount] = $sql->f("group_id"); | |
| 198 | - $iCount++; | |
| 199 | - } | |
| 200 | - return $aGroupUserLink; | |
| 201 | - } | |
| 202 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 203 | - return false; | |
| 204 | - } | |
| 205 | - | |
| 206 | - /** | |
| 207 | - * static function | |
| 208 | - * test to see if group exists already | |
| 209 | - * | |
| 210 | - * @param false or a value | |
| 211 | - */ | |
| 212 | - function userBelongsToGroup($iUserID){ | |
| 213 | - global $default; | |
| 214 | - $value = lookupField("$default->users_groups_table", "group_id", "user_id", $iUserID ); | |
| 215 | - return $value; | |
| 216 | - } | |
| 217 | - | |
| 218 | - /** | |
| 219 | - * static function | |
| 220 | - * sets the id of the groupunit using their groupid | |
| 221 | - * | |
| 222 | - * @param String | |
| 223 | - * The unit_ID | |
| 224 | - */ | |
| 225 | - | |
| 226 | - function setUserGroupID($iGroupId, $iUserId) { | |
| 227 | - global $default; | |
| 228 | - $sql = $default->db; | |
| 229 | - $sQuery = "SELECT id FROM $default->users_groups_table WHERE user_id = ? and group_id = ?";/*ok*/ | |
| 230 | - $aParams = array($iUserId, $iGroupId); | |
| 231 | - $result = $sql->query(array($sQuery, $aParams)); | |
| 232 | - if ($result) { | |
| 233 | - if ($sql->next_record()) { | |
| 234 | - $id = $sql->f("id"); | |
| 235 | - } else{ | |
| 236 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 237 | - return false; | |
| 238 | - } | |
| 239 | - } else{ | |
| 240 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 241 | - return false; | |
| 242 | - } | |
| 243 | - $this->iId = $id; | |
| 244 | - } | |
| 245 | -} | |
| 246 | -?> |