Commit b1d194f99cb6b82bc16514b492a2a74d34d4d810

Authored by nbm
1 parent 87171ba0

Not used anymore.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5101 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/unitmanagement/UnitOrganisationLink.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Represents a unit, organisation link as per the database table units_organisations_link.  
6 - *  
7 - * Copyright (c) 2006 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; using version 2 of the License.  
12 - *  
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.unitmanagement  
26 - */  
27 -class UnitOrganisationLink extends KTEntity {  
28 -  
29 - /** primary key of object */  
30 - var $iId;  
31 - /** primary key of unit to which unit is linked */  
32 - var $iUnitID;  
33 - /** primary key of group to which group is linked */  
34 - var $iOrgID;  
35 -  
36 -  
37 - function UnitOrganisationLink($iNewUnitID,$iNewOrgID) {  
38 - //object not created in database yet  
39 - $this->iId = -1;  
40 - $this->iOrgID = $iNewOrgID;  
41 - $this->iUnitID = $iNewUnitID;  
42 - }  
43 -  
44 - /**  
45 - * Get the object's primary key  
46 - *  
47 - * @return int object's primary key  
48 - *  
49 - */  
50 - function getID() {  
51 - return $this->iId;  
52 - }  
53 -  
54 - /**  
55 - * Get the primary key of the org to which the unit is linked  
56 - *  
57 - * @return int primary key of org to which unit is linked  
58 - *  
59 - */  
60 - function getOrgID() {  
61 - return $this->iOrgID;  
62 - }  
63 -  
64 - /**  
65 - * Set the primary key of the org to which the unit is linked  
66 - *  
67 - * @param int Primary key of group to which unit is ilinked  
68 - *  
69 - */  
70 - function setOrgID($iNewValue) {  
71 - $this->iOrgID = $iNewValue;  
72 - }  
73 -  
74 - /**  
75 - * Get the primary key of the unit to which the org is linked  
76 - *  
77 - * @return int primary key of unit to which the org is linked  
78 - *  
79 - */  
80 - function getUnitID() {  
81 - return $this->iUnitID;  
82 - }  
83 -  
84 - /**  
85 - * Set the primary key of the unit to which the org is linked  
86 - *  
87 - * @param int Primary key of unit to which the org is linked  
88 - *  
89 - */  
90 - function setUnitID($iNewValue) {  
91 - $this->iUnitID = $iNewValue;  
92 - }  
93 -  
94 - function _fieldValues () {  
95 - return array(  
96 - 'unit_id' => $this->iUnitID,  
97 - 'organisation_id' => $this->iOrgID,  
98 - );  
99 - }  
100 -  
101 - function _table () {  
102 - global $default;  
103 - return $default->units_organisations_table;  
104 - }  
105 -  
106 - /**  
107 - * Create the current object in the database  
108 - *  
109 - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"]  
110 - *  
111 - */  
112 - function create() {  
113 - global $default, $lang_err_database, $lang_err_object_exists;  
114 - //if the object hasn't been created  
115 - if ($this->iId < 0) {  
116 -  
117 - $sql = $default->db;  
118 - $query = "SELECT unit_id FROM $default->units_organisations_table WHERE unit_id = ? AND organisation_id = ?";/*ok*/  
119 - $params = array($this->iUnitID, $this->iOrgID);  
120 - $sql->query(array($query, $params));  
121 - $rows = $sql->num_rows($sql);  
122 -  
123 - if ($rows > 0) {  
124 - $_SESSION["errorMessage"] = "UnitOrganisationlink::The id " . $this->iUnitID . " is already exist!";  
125 - return false;  
126 - }  
127 - }  
128 - return parent::create();  
129 - }  
130 -  
131 - /**  
132 - * Static function.  
133 - * Given a groups_units_link primary key it will create a  
134 - * UnitsOrganisationsLink object and populate it with the  
135 - * corresponding database values  
136 - *  
137 - * @return UnitsOrganisationsLink populated UnitsOrganisationLink object on successful query, false otherwise and set $_SESSION["errorMessage"]  
138 - */  
139 - function & get($iUnitOrganisationLinkID) {  
140 - global $default;  
141 - $sql = $default->db;  
142 - $result = $sql->query(array("SELECT * FROM $default->units_organisations_table WHERE id = ?", $iUnitOrganisationLinkID));/*ok*/  
143 - if ($result) {  
144 - if ($sql->next_record()) {  
145 - $oUnitOrganisationLink = & new UnitOrganisationLink($sql->f("unit_id"),$sql->f("organisation_id") );  
146 - $oUnitOrganisationLink->iId = $iUnitOrganisationLinkID;  
147 - return $oUnitOrganisationLink;  
148 - }  
149 - return false;  
150 - }  
151 - $_SESSION["errorMessage"] = $lang_err_database;  
152 - return false;  
153 - }  
154 -  
155 -/**  
156 - * Static function  
157 - * Get a list of web documents  
158 - *  
159 - * @param String Where clause (not required)  
160 - *  
161 - * @return Array array of UnitOrganisationLink objects, false otherwise and set $_SESSION["errorMessage"]  
162 - */  
163 - function getList($sWhereClause = null) {  
164 - return KTEntityUtil::getList(UnitOrganisationLink::_table(), 'UnitOrganisationLink', $sWhereClause);  
165 - }  
166 -  
167 - /**  
168 - * static function  
169 - *  
170 - * test to see if unit belongs to org  
171 - *  
172 - * @param false or a value  
173 - */  
174 - function unitBelongsToOrg($unitId) {  
175 - global $default;  
176 - return lookupField("$default->units_organisations_table", "organisation_id", "unit_id", $unitId );  
177 - }  
178 -  
179 - /*  
180 - * static function  
181 - *  
182 - * sets the id of the unitorg using their unit id  
183 - *  
184 - * @param String  
185 - * The unit_ID  
186 - *  
187 - */  
188 - function setUnitOrgID($unitId) {  
189 - global $default;  
190 - $id = lookupID($default->units_organisations_table, "unit_id", $unitId);  
191 - $this->iId= $id;  
192 - }  
193 -  
194 - function getByUnitID($unitId) {  
195 - global $default;  
196 - $sql = $default->db;  
197 - $result = $sql->query(array("SELECT * FROM $default->units_organisations_table WHERE unit_id = ?", $unitId));/*ok*/  
198 - if ($result) {  
199 - if ($sql->next_record()) {  
200 - $oUnitOrganisationLink = & UnitOrganisationLink::get($sql->f("id"));  
201 - return $oUnitOrganisationLink;  
202 - } else {  
203 - return false;  
204 - }  
205 - } else {  
206 - return false;  
207 - }  
208 - }  
209 -}  
210 -?>