Commit e19f3da7922b3226bca52d31a2d935ba248e04fd

Authored by Michael Joseph
1 parent bafcbe92

renamed link.inc to Link.inc


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2563 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 0 additions and 255 deletions
lib/links/link.inc deleted
1 -<?php  
2 -/**  
3 -* Represents a Link as per the database table Links  
4 -*  
5 -* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
6 -* @date 23 January 2003  
7 -* @package lib.Links  
8 -*  
9 -*/  
10 -  
11 -class Link {  
12 -  
13 - /** primary key of current object */  
14 - var $iId;  
15 - /** Link name */  
16 - var $sName;  
17 - /** url link */  
18 - var $sUrl;  
19 - /** rank of website */  
20 - var $iRank;  
21 -  
22 -  
23 - function Link($sNewName, $sNewUrl, $iNewRank) {  
24 - $this->iId = -1;  
25 - $this->sName = $sNewName;  
26 - $this->sUrl = $sNewUrl;  
27 - $this->iRank = $iNewRank;  
28 - }  
29 -  
30 - function getUrl() {  
31 - return $this->sUrl;  
32 - }  
33 -  
34 - function setUrl($sNewValue) {  
35 - $this->sUrl = $sNewValue;  
36 - }  
37 -  
38 - function getRank() {  
39 - return $this->iRank;  
40 - }  
41 -  
42 - function setRank($sNewValue) {  
43 - $this->iRank = $sNewValue;  
44 - }  
45 -  
46 - function getName() {  
47 - return $this->sName;  
48 - }  
49 -  
50 - function setName($sNewValue) {  
51 - $this->sName = $sNewValue;  
52 - }  
53 -  
54 - /**  
55 - * Create the current object in the database  
56 - *  
57 - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"]  
58 - *  
59 - */  
60 - function create() {  
61 - global $default, $lang_err_database, $lang_err_object_exists;  
62 - //if the object hasn't been created  
63 - if ($this->iId < 0) {  
64 - //check to see if name exsits  
65 - $sql = $default->db;  
66 - $query = "SELECT name FROM ". $default->owl_links_table ." WHERE name = '" . $this->sName . "'";  
67 - $sql->query($query);  
68 - $rows = $sql->num_rows($sql);  
69 -  
70 - if ($rows > 0){  
71 - // duplicate username  
72 - $_SESSION["errorMessage"] = "Link::The Link name " . $this->sName . " is already in use!";  
73 - return false;  
74 -  
75 - }else{  
76 - $sql = $default->db;  
77 - $query = "SELECT rank FROM ". $default->owl_links_table ." WHERE rank = '" . $this->iRank . "'";  
78 - $sql->query($query);  
79 - $rows = $sql->num_rows($sql);  
80 -  
81 - if ($rows > 0){  
82 - // duplicate username  
83 - $_SESSION["errorMessage"] = "Link::The Rank " . $this->iRank . " is already in use!";  
84 - return false;  
85 -  
86 - }else{  
87 - $sql = $default->db;  
88 - $result = $sql->query("INSERT INTO " . $default->owl_links_table . " (name, url, rank) VALUES ('" . addslashes($this->sName) . "', '" . ($this->sUrl) . "', " . ($this->iRank) . ")");  
89 - if ($result) {  
90 - $this->iId = $sql->insert_id();  
91 - return true;  
92 - }  
93 - $_SESSION["errorMessage"] = $lang_err_database;  
94 - return false;  
95 - }  
96 - }  
97 - }  
98 - $_SESSION["errorMessage"] = $lang_err_object_exists . "id = " . $this->iId . " table = document_fields";  
99 - return false;  
100 - }  
101 -  
102 - /**  
103 - * Update the values in the database table with the object's current values  
104 - *  
105 - * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"]  
106 - *  
107 - */  
108 - function update() {  
109 - global $default, $lang_err_database, $lang_err_object_key;  
110 - //only update if the object has been stored  
111 - if ($this->iId > 0) {  
112 - $sql = $default->db;  
113 - $result = $sql->query("UPDATE " . $default->owl_links_table . " SET name = '" . addslashes($this->sName) . "', url = '" . ($this->sUrl) . "', rank = " . ($this->iRank) . " WHERE id = $this->iId");  
114 - if ($result) {  
115 - return true;  
116 - }  
117 - $_SESSION["errorMessage"] = $lang_err_database;  
118 - return false;  
119 - }  
120 - $_SESSION["errorMessage"] = $lang_err_object_key;  
121 - return false;  
122 - }  
123 -  
124 - /**  
125 - * Delete the current object from the database  
126 - *  
127 - * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"]  
128 - *  
129 - */  
130 - function delete() {  
131 - global $default, $lang_err_database, $lang_err_object_key;  
132 - //only delete the object if it exists in the database  
133 - if ($this->iId >= 0) {  
134 - $sql = $default->db;  
135 - $result = $sql->query("DELETE FROM $default->owl_links_table WHERE id = $this->iId");  
136 - if ($result) {  
137 - return true;  
138 - }  
139 - $_SESSION["errorMessage"] = $lang_err_database;  
140 - return false;  
141 -  
142 - }  
143 - $_SESSION["errorMessage"] = $lang_err_object_key;  
144 - return false;  
145 - }  
146 -  
147 - /**  
148 - * Static function.  
149 - * Given a Links primary key it will create a  
150 - * Link object and populate it with the  
151 - * corresponding database values  
152 - *  
153 - * @return Link populated Link object on successful query, false otherwise and set $_SESSION["errorMessage"]  
154 - */  
155 - function & get($iLinkID) {  
156 - global $default;  
157 - $sql = $default->db;  
158 - $result = $sql->query("SELECT * FROM $default->owl_links_table WHERE id = $iLinkID");  
159 - if ($result) {  
160 - if ($sql->next_record()) {  
161 - $oLink = & new Link(stripslashes($sql->f("name")), $sql->f("url"), $sql->f("rank"));  
162 - $oLink->iId = $iLinkID;  
163 - return $oLink;  
164 - }  
165 - $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iLinkID . " table = $default->owl_links_table";  
166 - return false;  
167 - }  
168 - $_SESSION["errorMessage"] = $lang_err_database;  
169 - return false;  
170 - }  
171 -  
172 -/**  
173 - * Static function  
174 - * Get a list ocuments  
175 - *  
176 - * @param String Where clause (not required)  
177 - *  
178 - * @return Array array of Link objects, false otherwise and set $_SESSION["errorMessage"]  
179 - */  
180 - function getList($sWhereClause = null) {  
181 - global $default, $lang_err_database;  
182 - $aLinkArray;  
183 - settype($aLinkArray, "array");  
184 - $sql = $default->db;  
185 - $result = $sql->query("SELECT * FROM " . $default->owl_links_table . (isset($sWhereClause) ? " " . $sWhereClause : ""));  
186 - if ($result) {  
187 - $iCount = 0;  
188 - while ($sql->next_record()) {  
189 - $oLink = & Link::get($sql->f("id"));  
190 - $aLinkArray[$iCount] = $oLink;  
191 - $iCount++;  
192 - }  
193 - return $aLinkArray;  
194 - }  
195 - $_SESSION["errorMessage"] = $lang_err_database;  
196 - return false;  
197 - }  
198 -  
199 -  
200 -}  
201 -/*  
202 - * static function  
203 - *  
204 - * gets the name of a unit using their id  
205 - *  
206 - * @param String  
207 - * The name  
208 - *  
209 - */  
210 -  
211 - function getLinkName($id)  
212 - {  
213 - global $default;  
214 -  
215 - $name = lookupField("$default->owl_links_table", "name", "id", $id );  
216 -  
217 - $this->sName= $name;  
218 - }  
219 -  
220 - /*  
221 - * static function  
222 - *  
223 - * gets the name of a unit using their id  
224 - *  
225 - * @param String  
226 - * The name  
227 - *  
228 - */  
229 -  
230 - function getLinkUrl($id)  
231 - {  
232 - global $default;  
233 -  
234 - $url = lookupField("$default->owl_links_table", "url", "id", $id );  
235 -  
236 - $this->sName= $url;  
237 - }  
238 -  
239 -  
240 -  
241 -/**  
242 -* Static function  
243 -*  
244 -* Creates a Link object from an array  
245 -*  
246 -* @param Array Array of parameters. Must match order of parameters in constructor  
247 -*  
248 -* @return User user object  
249 -*/  
250 -function & linkCreateFromArray($aParameters) {  
251 - $oLink = & new Link($aParameters[0], $aParameters[1], $aParameters[2], $aParameters[3], $aParameters[4], $aParameters[5], $aParameters[6], $aParameters[7], $aParameters[8], $aParameters[9], $aParameters[10]);  
252 - return $oLink;  
253 -}  
254 -  
255 -?>