1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * eGroupWare - Contacts Center * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Storage Object Classes * |
---|
6 | * Written by: * |
---|
7 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
8 | * sponsored by Thyamad - http://www.thyamad.com * |
---|
9 | * ------------------------------------------------------------------------- * |
---|
10 | * This program is free software; you can redistribute it and/or modify it * |
---|
11 | * under the terms of the GNU General Public License as published by the * |
---|
12 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
13 | * option) any later version. * |
---|
14 | \***************************************************************************/ |
---|
15 | |
---|
16 | |
---|
17 | include_once("class.so_main.inc.php"); |
---|
18 | |
---|
19 | class so_city extends so_main { |
---|
20 | |
---|
21 | function so_city ( $id = false ) |
---|
22 | { |
---|
23 | $this->init(); |
---|
24 | |
---|
25 | $this->main_fields = array( |
---|
26 | 'id_city' => array( |
---|
27 | 'name' => 'id_city', |
---|
28 | 'type' => 'primary', |
---|
29 | 'state' => 'empty', |
---|
30 | 'value' => &$this->id |
---|
31 | ), |
---|
32 | 'id_state' => array( |
---|
33 | 'name' => 'id_state', |
---|
34 | 'type' => 'foreign', |
---|
35 | 'association' => array( |
---|
36 | 'table' => 'phpgw_cc_state', |
---|
37 | 'field' => 'id_state' |
---|
38 | ), |
---|
39 | 'state' => 'empty', |
---|
40 | 'value' => false |
---|
41 | ), |
---|
42 | 'id_country' => array( |
---|
43 | 'name' => 'id_country', |
---|
44 | 'type' => 'foreign', |
---|
45 | 'association' => array( |
---|
46 | 'table' => 'phpgw_common_country_list', |
---|
47 | 'field' => 'id_country' |
---|
48 | ), |
---|
49 | 'state' => 'empty', |
---|
50 | 'value' => false |
---|
51 | ), |
---|
52 | 'city_name' => array( |
---|
53 | 'name' => 'city_name', |
---|
54 | 'type' => false, |
---|
55 | 'state' => 'empty', |
---|
56 | 'value' => false |
---|
57 | ), |
---|
58 | 'city_timezone' => array( |
---|
59 | 'name' => 'city_timezone', |
---|
60 | 'type' => false, |
---|
61 | 'state' => 'empty', |
---|
62 | 'value' => false |
---|
63 | ), |
---|
64 | 'city_geo_location' => array( |
---|
65 | 'name' => 'city_geo_location', |
---|
66 | 'type' => false, |
---|
67 | 'state' => 'empty', |
---|
68 | 'value' => false |
---|
69 | ) |
---|
70 | ); |
---|
71 | |
---|
72 | $this->db_tables = array( |
---|
73 | 'phpgw_cc_city' => array( |
---|
74 | 'type' => 'main', |
---|
75 | 'keys' => array( |
---|
76 | 'primary' => array(&$this->main_fields['id_city']), |
---|
77 | 'foreign' => array(&$this->main_fields['id_state']) |
---|
78 | ), |
---|
79 | 'fields' => & $this->main_fields |
---|
80 | ) |
---|
81 | ); |
---|
82 | |
---|
83 | if($id) |
---|
84 | { |
---|
85 | if (!$this->checkout($id)) |
---|
86 | { |
---|
87 | $this->reset_values(); |
---|
88 | $this->state = 'new'; |
---|
89 | } |
---|
90 | } |
---|
91 | else |
---|
92 | { |
---|
93 | $this->state = 'new'; |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | |
---|
98 | /*********************************************************************\ |
---|
99 | * Methods to Get Information * |
---|
100 | \*********************************************************************/ |
---|
101 | |
---|
102 | /*! |
---|
103 | |
---|
104 | @function get_id_state |
---|
105 | @abstract Returns the ID of the State where this |
---|
106 | city is located |
---|
107 | @author Raphael Derosso Pereira |
---|
108 | |
---|
109 | */ |
---|
110 | function get_id_state ( ) |
---|
111 | { |
---|
112 | return $this->main_fields['id_state']['value']; |
---|
113 | } |
---|
114 | |
---|
115 | /*! |
---|
116 | |
---|
117 | @function get_id_country |
---|
118 | @abstract Returns the ID of the Country where this |
---|
119 | city is located |
---|
120 | @author Raphael Derosso Pereira |
---|
121 | |
---|
122 | */ |
---|
123 | function get_id_country ( ) |
---|
124 | { |
---|
125 | return $this->main_fields['id_country']['value']; |
---|
126 | } |
---|
127 | |
---|
128 | /*! |
---|
129 | |
---|
130 | @function get_city_name |
---|
131 | @abstract Returns the Name of the City |
---|
132 | @author Raphael Derosso Pereira |
---|
133 | |
---|
134 | */ |
---|
135 | function get_city_name ( ) |
---|
136 | { |
---|
137 | return $this->main_fields['city_name']['value']; |
---|
138 | } |
---|
139 | |
---|
140 | /*! |
---|
141 | |
---|
142 | @function get_city_timezone |
---|
143 | @abstract Returns the City Timezone |
---|
144 | @author Raphael Derosso Pereira |
---|
145 | |
---|
146 | */ |
---|
147 | function get_city_timezone ( ) |
---|
148 | { |
---|
149 | return $this->main_fields['city_timezone']['value']; |
---|
150 | } |
---|
151 | |
---|
152 | /*! |
---|
153 | |
---|
154 | @function get_city_geo_location |
---|
155 | @abstract Returns the City Geographic Location as stablished |
---|
156 | by ISO 6709 standard |
---|
157 | @author Raphael Derosso Pereira |
---|
158 | |
---|
159 | */ |
---|
160 | function get_city_geo_location ( ) |
---|
161 | { |
---|
162 | return $this->main_fields['city_geo_location']['value']; |
---|
163 | } |
---|
164 | |
---|
165 | |
---|
166 | /*********************************************************************\ |
---|
167 | * Methods to Alter Information * |
---|
168 | \*********************************************************************/ |
---|
169 | |
---|
170 | /*! |
---|
171 | |
---|
172 | @function set_id_country |
---|
173 | @abstract Sets the City's Country ID |
---|
174 | @author Raphael Derosso Pereira |
---|
175 | |
---|
176 | @param integer $id_country The Country ID |
---|
177 | */ |
---|
178 | function set_id_country ( $id_country ) |
---|
179 | { |
---|
180 | $this->main_fields['id_country']['value'] = $id_country; |
---|
181 | $this->manage_fields($this->main_fields['id_country'], 'changed'); |
---|
182 | } |
---|
183 | |
---|
184 | /*! |
---|
185 | |
---|
186 | @function set_id_state |
---|
187 | @abstract Sets the City's State ID |
---|
188 | @author Raphael Derosso Pereira |
---|
189 | |
---|
190 | @param integer $id_state The State ID |
---|
191 | */ |
---|
192 | function set_id_state ( $id_state ) |
---|
193 | { |
---|
194 | $this->main_fields['id_state']['value'] = $id_state; |
---|
195 | $this->manage_fields($this->main_fields['id_state'], 'changed'); |
---|
196 | } |
---|
197 | |
---|
198 | /*! |
---|
199 | |
---|
200 | @function set_city_name |
---|
201 | @abstract Sets the City's Name |
---|
202 | @author Raphael Derosso Pereira |
---|
203 | |
---|
204 | @param string $name The City Name |
---|
205 | */ |
---|
206 | function set_city_name ( $name ) |
---|
207 | { |
---|
208 | $this->main_fields['city_name']['value'] = $name; |
---|
209 | $this->manage_fields($this->main_fields['city_name'], 'changed'); |
---|
210 | } |
---|
211 | |
---|
212 | /*! |
---|
213 | |
---|
214 | @function set_city_timezone |
---|
215 | @abstract Sets the City's Timezone |
---|
216 | @author Raphael Derosso Pereira |
---|
217 | |
---|
218 | @param string $timezone The City Timezone |
---|
219 | */ |
---|
220 | function set_city_timezone ( $timezone ) |
---|
221 | { |
---|
222 | $this->main_fields['city_timezone']['value'] = $timezone; |
---|
223 | $this->manage_fields($this->main_fields['city_timezone'], 'changed'); |
---|
224 | } |
---|
225 | |
---|
226 | /*! |
---|
227 | |
---|
228 | @function set_city_geo_location |
---|
229 | @abstract Sets the City's Geographic Location as defined |
---|
230 | by ISO 6709 standard |
---|
231 | @author Raphael Derosso Pereira |
---|
232 | |
---|
233 | @param string $geo The City Geographic Location |
---|
234 | */ |
---|
235 | function set_city_geo_location ( $geo ) |
---|
236 | { |
---|
237 | $this->main_fields['city_geo_location']['value'] = $geo; |
---|
238 | $this->manage_fields($this->main_fields['city_geo_location'], 'changed'); |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | ?> |
---|