1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Expresso - Expresso Messenger * |
---|
4 | * - Alexandre Correia / Rodrigo Souza * |
---|
5 | * - JETI - http://jeti-im.org/ * |
---|
6 | * ------------------------------------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \***************************************************************************/ |
---|
12 | |
---|
13 | define('PHPGW_INCLUDE_ROOT','../'); |
---|
14 | define('PHPGW_API_INC','../phpgwapi/inc'); |
---|
15 | require_once(PHPGW_API_INC . '/class.db.inc.php'); |
---|
16 | require_once "class.fileDefine.inc.php"; |
---|
17 | |
---|
18 | class db_im |
---|
19 | { |
---|
20 | private $db; |
---|
21 | private $db_name; |
---|
22 | private $db_host; |
---|
23 | private $db_port; |
---|
24 | private $db_user; |
---|
25 | private $db_pass; |
---|
26 | private $db_type; |
---|
27 | private $user_id; |
---|
28 | private $fileD; |
---|
29 | |
---|
30 | public final function __construct() |
---|
31 | { |
---|
32 | $this->fileD = new fileDefine(); |
---|
33 | $this->db_name = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']; |
---|
34 | $this->db_host = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']; |
---|
35 | $this->db_port = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_port']; |
---|
36 | $this->db_user = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_user']; |
---|
37 | $this->db_pass = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_pass']; |
---|
38 | $this->db_type = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_type']; |
---|
39 | $this->user_id = $_SESSION['phpgw_info']['jabberit_messenger']['user_id']; |
---|
40 | $this->connectDB(); |
---|
41 | } |
---|
42 | |
---|
43 | private final function connectDB() |
---|
44 | { |
---|
45 | $this->db = new db(); |
---|
46 | $this->db_name = ( !$this->db_name ) ? $_SESSION['phpgwinfo']['db_name'] : $this->db_name; |
---|
47 | $this->db_host = ( !$this->db_host ) ? $_SESSION['phpgwinfo']['db_host'] : $this->db_host; |
---|
48 | $this->db_port = ( !$this->db_port ) ? $_SESSION['phpgwinfo']['db_port'] : $this->db_port; |
---|
49 | $this->db_user = ( !$this->db_user ) ? $_SESSION['phpgwinfo']['db_user'] : $this->db_user; |
---|
50 | $this->db_pass = ( !$this->db_pass ) ? $_SESSION['phpgwinfo']['db_pass'] : $this->db_pass; |
---|
51 | $this->db_type = ( !$this->db_type ) ? $_SESSION['phpgwinfo']['db_type'] : $this->db_type; |
---|
52 | |
---|
53 | $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type); |
---|
54 | } |
---|
55 | |
---|
56 | public final function editHostJabber($pItem) |
---|
57 | { |
---|
58 | $hostsJabber = unserialize($this->getHostsJabber()); |
---|
59 | $findHosts = explode(":", $pItem['item']); |
---|
60 | $return = ""; |
---|
61 | |
---|
62 | for( $i = 0 ; $i < count($hostsJabber); $i++ ) |
---|
63 | if( $hostsJabber[$i]['org'] == $findHosts[0] && $hostsJabber[$i]['jabberName'] == $findHosts[1] ) |
---|
64 | { |
---|
65 | $return = "org:" . $hostsJabber[$i]['org'] . ";" . |
---|
66 | "jabberName:" . $hostsJabber[$i]['jabberName'] . ";" . |
---|
67 | "serverLdap:" . $hostsJabber[$i]['serverLdap'] . ";" . |
---|
68 | "contextLdap:" . $hostsJabber[$i]['contextLdap'] . ";" . |
---|
69 | "user:" . $hostsJabber[$i]['user'] . ";" . |
---|
70 | "password:" . $hostsJabber[$i]['password'] ; |
---|
71 | } |
---|
72 | |
---|
73 | return trim($return); |
---|
74 | } |
---|
75 | |
---|
76 | public final function getApplicationsEnabled() |
---|
77 | { |
---|
78 | |
---|
79 | $this->db->query("SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"); |
---|
80 | if($this->db->num_rows()) |
---|
81 | { |
---|
82 | $tmp = ""; |
---|
83 | while($this->db->next_record()) |
---|
84 | { |
---|
85 | $tmp[]= $this->db->row(); |
---|
86 | } |
---|
87 | return $tmp[0]['config_value']; |
---|
88 | } |
---|
89 | return false; |
---|
90 | } |
---|
91 | |
---|
92 | public final function getApplicationsList() |
---|
93 | { |
---|
94 | $this->db->query("SELECT * FROM phpgw_applications WHERE app_enabled = '1' order by app_name"); |
---|
95 | if($this->db->num_rows()) |
---|
96 | { |
---|
97 | while ($this->db->next_record()) |
---|
98 | { |
---|
99 | $app = $this->db->f('app_name'); |
---|
100 | $title = @$GLOBALS['phpgw_info']['apps'][$app]['title']; |
---|
101 | if (empty($title)) |
---|
102 | { |
---|
103 | $title = lang($app) == $app.'*' ? $app : lang($app); |
---|
104 | } |
---|
105 | $apps[$app] = array( |
---|
106 | 'title' => $title, |
---|
107 | 'name' => $app, |
---|
108 | 'status' => $this->db->f('app_enabled') |
---|
109 | ); |
---|
110 | } |
---|
111 | } |
---|
112 | return $apps; |
---|
113 | } |
---|
114 | |
---|
115 | public final function get_accounts_acl() |
---|
116 | { |
---|
117 | $query = "select acl_account from phpgw_acl where acl_location in (select cast(acl_account as varchar) from phpgw_acl where acl_appname = 'jabberit_messenger') "; |
---|
118 | $query .= "union select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger'"; |
---|
119 | |
---|
120 | |
---|
121 | if( $this->db->query($query) ) |
---|
122 | { |
---|
123 | $users = array(); |
---|
124 | $new_users = array(); |
---|
125 | while($this->db->next_record()) |
---|
126 | $users[] = $this->db->row(); |
---|
127 | |
---|
128 | if(is_array($users)) |
---|
129 | foreach($users as $tmp) |
---|
130 | $new_users[] = $tmp['acl_account']; |
---|
131 | |
---|
132 | return $new_users; |
---|
133 | } |
---|
134 | |
---|
135 | return false; |
---|
136 | } |
---|
137 | |
---|
138 | public final function getGroupsBlocked() |
---|
139 | { |
---|
140 | $return = ""; |
---|
141 | |
---|
142 | if( $this->db ) |
---|
143 | { |
---|
144 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
145 | |
---|
146 | if($this->db->query($query)) |
---|
147 | { |
---|
148 | |
---|
149 | if ( $this->db->query($query) ) |
---|
150 | { |
---|
151 | while($this->db->next_record()) |
---|
152 | $result[] = $this->db->row(); |
---|
153 | } |
---|
154 | |
---|
155 | if( count($result) > 0 ) |
---|
156 | $return = $result[0]['config_value']; |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | return $return; |
---|
161 | } |
---|
162 | |
---|
163 | public final function getHostsJabber() |
---|
164 | { |
---|
165 | $return = ""; |
---|
166 | |
---|
167 | if( $this->db ) |
---|
168 | { |
---|
169 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
170 | |
---|
171 | if($this->db->query($query)) |
---|
172 | { |
---|
173 | while($this->db->next_record()) |
---|
174 | $result[] = $this->db->row(); |
---|
175 | } |
---|
176 | |
---|
177 | if( count($result) > 0 ) |
---|
178 | $return = $result[0]['config_value']; |
---|
179 | } |
---|
180 | |
---|
181 | return $return; |
---|
182 | } |
---|
183 | |
---|
184 | public final function getPreferences() |
---|
185 | { |
---|
186 | $result = array(); |
---|
187 | $query = "select * from phpgw_preferences where preference_owner = '".$this->user_id."' and preference_app = 'jabberit_messenger'"; |
---|
188 | |
---|
189 | if ( $this->db->query($query) ) |
---|
190 | { |
---|
191 | while($this->db->next_record()) |
---|
192 | $result[] = $this->db->row(); |
---|
193 | |
---|
194 | if(count($result) > 0) |
---|
195 | return unserialize($result[0]['preference_value']); |
---|
196 | } |
---|
197 | |
---|
198 | return "openWindowJabberit:true;openWindowJabberitPopUp:false;flagAwayIM:5"; |
---|
199 | } |
---|
200 | |
---|
201 | public final function setPreferences($pParam) |
---|
202 | { |
---|
203 | $preferences = $pParam['preferences1']; |
---|
204 | |
---|
205 | if(isset($pParam['preferences2'])) |
---|
206 | $preferences .= ";". $pParam['preferences2']; |
---|
207 | |
---|
208 | if(isset($pParam['preferences3'])) |
---|
209 | $preferences .= ";". $pParam['preferences3']; |
---|
210 | |
---|
211 | $user_id = $this->user_id; |
---|
212 | |
---|
213 | $query = "insert into phpgw_preferences values('".$user_id."','jabberit_messenger','".serialize($preferences)."')"; |
---|
214 | |
---|
215 | if($this->db->query($query)) |
---|
216 | { |
---|
217 | return "true"; |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='jabberit_messenger' and preference_owner='".$user_id."'"; |
---|
222 | |
---|
223 | if($this->db->query($query)) |
---|
224 | return "true"; |
---|
225 | else |
---|
226 | return "false"; |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | public final function setApplications($pApplications) |
---|
231 | { |
---|
232 | $apps = serialize($pApplications); |
---|
233 | |
---|
234 | if( $this->db ) |
---|
235 | { |
---|
236 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"; |
---|
237 | |
---|
238 | $this->db->query($query); |
---|
239 | |
---|
240 | if(!$this->db->next_record()) |
---|
241 | { |
---|
242 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')"; |
---|
243 | $this->db->query($query); |
---|
244 | return true; |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'"; |
---|
249 | $this->db->query($query); |
---|
250 | return true; |
---|
251 | } |
---|
252 | } |
---|
253 | return false; |
---|
254 | } |
---|
255 | |
---|
256 | public final function setAttributesLdap($pAttributes) |
---|
257 | { |
---|
258 | $values = $pAttributes['conf']; |
---|
259 | $attributesOrg = ""; |
---|
260 | |
---|
261 | if( $this->db ) |
---|
262 | { |
---|
263 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
264 | |
---|
265 | if ( $this->db->query($query) ) |
---|
266 | { |
---|
267 | while($this->db->next_record()) |
---|
268 | $result[] = $this->db->row(); |
---|
269 | |
---|
270 | if(count($result) > 0) |
---|
271 | $attributesOrg = $result[0]['config_value']; |
---|
272 | } |
---|
273 | |
---|
274 | if( trim($attributesOrg) == "" ) |
---|
275 | { |
---|
276 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','attributes_org_ldap_jabberit','".$values."')"; |
---|
277 | $this->db->query($query); |
---|
278 | |
---|
279 | $attr = explode(";", $values); |
---|
280 | $values = "<return><ou attr='".$attr[1]."'>".$attr[0]."</ou></return>"; |
---|
281 | return $values; |
---|
282 | } |
---|
283 | else |
---|
284 | { |
---|
285 | $org = explode(",", $attributesOrg); |
---|
286 | $newValue = explode(";", $values); |
---|
287 | |
---|
288 | foreach( $org as $tmp ) |
---|
289 | { |
---|
290 | $attr = explode(";",$tmp); |
---|
291 | if( strtolower(trim($attr[0])) == strtolower(trim($newValue[0])) ) |
---|
292 | return false; |
---|
293 | } |
---|
294 | |
---|
295 | $values = $values . "," . $attributesOrg; |
---|
296 | $query = "UPDATE phpgw_config SET config_value = '".$values."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
297 | $this->db->query($query); |
---|
298 | |
---|
299 | $return = explode(",",$values); |
---|
300 | natcasesort($return); |
---|
301 | |
---|
302 | $values = "<return>"; |
---|
303 | |
---|
304 | foreach($return as $tmp) |
---|
305 | { |
---|
306 | $attr = explode(";", $tmp); |
---|
307 | $values .= "<ou attr='" . $attr[1] . "'>" . $attr[0] . "</ou>"; |
---|
308 | } |
---|
309 | |
---|
310 | $values .= "</return>"; |
---|
311 | |
---|
312 | return $values; |
---|
313 | } |
---|
314 | } |
---|
315 | return false; |
---|
316 | } |
---|
317 | |
---|
318 | public final function setGroupsLocked($pGroups) |
---|
319 | { |
---|
320 | $groups = ""; |
---|
321 | |
---|
322 | if( is_array($pGroups) ) |
---|
323 | { |
---|
324 | foreach($pGroups as $tmp) |
---|
325 | if(trim($tmp) != "") |
---|
326 | $groups .= $tmp . ";"; |
---|
327 | |
---|
328 | $groups = substr($groups, 0, strlen($groups) - 1 ); |
---|
329 | } |
---|
330 | |
---|
331 | if( $this->db ) |
---|
332 | { |
---|
333 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
334 | |
---|
335 | if($this->db->query($query)) |
---|
336 | { |
---|
337 | |
---|
338 | if ( $this->db->query($query) ) |
---|
339 | { |
---|
340 | while($this->db->next_record()) |
---|
341 | $result[] = $this->db->row(); |
---|
342 | } |
---|
343 | |
---|
344 | if( count($result) == 0 ) |
---|
345 | { |
---|
346 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','groups_locked_jabberit','".$groups."');"; |
---|
347 | $this->db->query($query); |
---|
348 | return true; |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
353 | $this->db->query($query); |
---|
354 | return true; |
---|
355 | } |
---|
356 | } |
---|
357 | } |
---|
358 | |
---|
359 | return false; |
---|
360 | } |
---|
361 | |
---|
362 | public final function setHostJabber($pParam) |
---|
363 | { |
---|
364 | $confHostsJabber = array(); |
---|
365 | |
---|
366 | foreach($pParam as $key => $itens) |
---|
367 | $confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens; |
---|
368 | |
---|
369 | if( $this->db ) |
---|
370 | { |
---|
371 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
372 | |
---|
373 | if( $this->db->query($query) ) |
---|
374 | { |
---|
375 | while($this->db->next_record()) |
---|
376 | $result[] = $this->db->row(); |
---|
377 | } |
---|
378 | |
---|
379 | if( count($result) == 0 ) |
---|
380 | { |
---|
381 | $return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>"; |
---|
382 | $hostsJabber[0] = $confHostsJabber; |
---|
383 | |
---|
384 | $this->fileD->ldapExternal($hostsJabber); |
---|
385 | |
---|
386 | $query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')"; |
---|
387 | $this->db->query($query); |
---|
388 | } |
---|
389 | else |
---|
390 | { |
---|
391 | $resultQuery = unserialize($result[0]['config_value']); |
---|
392 | $foundOrg = false; |
---|
393 | |
---|
394 | foreach($resultQuery as $key => $itens) |
---|
395 | { |
---|
396 | $foundString = array_search($confHostsJabber['org'], $itens); |
---|
397 | if( $foundString ) |
---|
398 | { |
---|
399 | $foundOrg = $foundString; |
---|
400 | $ky = $key; |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | if( ! $foundOrg ) |
---|
405 | $resultQuery[] = $confHostsJabber; |
---|
406 | else |
---|
407 | $resultQuery[$ky] = $confHostsJabber; |
---|
408 | |
---|
409 | $return = "<return>"; |
---|
410 | |
---|
411 | foreach( $resultQuery as $itens ) |
---|
412 | $return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>"; |
---|
413 | |
---|
414 | $return .= "</return>"; |
---|
415 | |
---|
416 | $this->fileD->ldapExternal($resultQuery); |
---|
417 | |
---|
418 | $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
419 | $this->db->query($query); |
---|
420 | } |
---|
421 | return $return; |
---|
422 | } |
---|
423 | return false; |
---|
424 | } |
---|
425 | |
---|
426 | public final function setOuGroupsLocked($pGroup) |
---|
427 | { |
---|
428 | $group = $pGroup['group']; |
---|
429 | $gidnumber = $pGroup['gidnumber']; |
---|
430 | $organization = strtoupper($pGroup['ou']); |
---|
431 | |
---|
432 | if( $this->db ) |
---|
433 | { |
---|
434 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
435 | |
---|
436 | if($this->db->query($query)) |
---|
437 | { |
---|
438 | |
---|
439 | if ( $this->db->query($query) ) |
---|
440 | { |
---|
441 | while($this->db->next_record()) |
---|
442 | $result[] = $this->db->row(); |
---|
443 | } |
---|
444 | |
---|
445 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
446 | |
---|
447 | foreach( $groupsLocked as $tmp ) |
---|
448 | { |
---|
449 | $aux = explode(":", $tmp); |
---|
450 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
451 | { |
---|
452 | if( $aux[2] ) |
---|
453 | { |
---|
454 | $ou_groups = explode(",",$aux[2]); |
---|
455 | natcasesort($ou_groups); |
---|
456 | $key = array_search($organization, $ou_groups); |
---|
457 | |
---|
458 | if( $key === false ) |
---|
459 | array_push($ou_groups, $organization); |
---|
460 | |
---|
461 | $groups .= $group.":".$gidnumber.":"; |
---|
462 | |
---|
463 | $return = "<return>"; |
---|
464 | |
---|
465 | foreach($ou_groups as $tmp) |
---|
466 | { |
---|
467 | $return .= "<ou attr='".$tmp."'>".$tmp."</ou>"; |
---|
468 | $groups .= $tmp .","; |
---|
469 | } |
---|
470 | |
---|
471 | $return .= "</return>"; |
---|
472 | |
---|
473 | $groups = substr($groups,0,strlen($groups)-1); |
---|
474 | $groups .= ";"; |
---|
475 | } |
---|
476 | else |
---|
477 | { |
---|
478 | $groups .= $group.":".$gidnumber.":".$organization.";"; |
---|
479 | $return = "<return><ou attr='".$organization."'>".$organization."</ou></return>"; |
---|
480 | } |
---|
481 | } |
---|
482 | else |
---|
483 | $groups .= $tmp . ";" ; |
---|
484 | } |
---|
485 | |
---|
486 | $groups = substr($groups,0,strlen($groups)-1); |
---|
487 | |
---|
488 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
489 | $this->db->query($query); |
---|
490 | |
---|
491 | return $return; |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | return false; |
---|
496 | } |
---|
497 | |
---|
498 | public final function removeAttributesLdap($pOrg) |
---|
499 | { |
---|
500 | $organization = $pOrg['org']; |
---|
501 | |
---|
502 | if( $this->db ) |
---|
503 | { |
---|
504 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
505 | |
---|
506 | if ( $this->db->query($query) ) |
---|
507 | { |
---|
508 | while( $this->db->next_record() ) |
---|
509 | $result[] = $this->db->row(); |
---|
510 | |
---|
511 | if( count($result) > 0 ) |
---|
512 | $attributesOrg = $result[0]['config_value']; |
---|
513 | } |
---|
514 | |
---|
515 | $attributesOrg = explode(",", $attributesOrg); |
---|
516 | $newValue = ""; |
---|
517 | foreach($attributesOrg as $tmp) |
---|
518 | { |
---|
519 | $attr = explode(";",$tmp); |
---|
520 | |
---|
521 | if( strtolower(trim($attr[0])) != strtolower(trim($organization))) |
---|
522 | { |
---|
523 | $newValue .= $attr[0] . ";" . $attr[1] . ","; |
---|
524 | } |
---|
525 | } |
---|
526 | |
---|
527 | $newValue = substr($newValue, 0,(strlen($newValue) -1 )); |
---|
528 | |
---|
529 | if( trim($newValue) != "") |
---|
530 | $query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
531 | else |
---|
532 | $query = "DELETE from phpgw_config where config_name = 'attributes_org_ldap_jabberit'"; |
---|
533 | |
---|
534 | if( $this->db->query($query)) |
---|
535 | return true; |
---|
536 | else |
---|
537 | return false; |
---|
538 | } |
---|
539 | return false; |
---|
540 | } |
---|
541 | |
---|
542 | public final function removeHostsJabber($pItem) |
---|
543 | { |
---|
544 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
545 | |
---|
546 | if( $this->db ) |
---|
547 | { |
---|
548 | if($this->db->query($query)) |
---|
549 | { |
---|
550 | while($this->db->next_record()) |
---|
551 | $result[] = $this->db->row(); |
---|
552 | |
---|
553 | if( count($result) > 0 ) |
---|
554 | { |
---|
555 | $confHostsOrgs = unserialize($result[0]['config_value']); |
---|
556 | $hosts = explode(":", $pItem['item']); |
---|
557 | $key = ""; |
---|
558 | |
---|
559 | if( count($confHostsOrgs) > 0 ) |
---|
560 | { |
---|
561 | for( $i = 0; $i < count($confHostsOrgs); $i++) |
---|
562 | if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1]) |
---|
563 | $key = $i; |
---|
564 | |
---|
565 | array_splice($confHostsOrgs, $key, 1); |
---|
566 | |
---|
567 | if(count($confHostsOrgs) > 0) |
---|
568 | { |
---|
569 | $this->fileD->ldapExternal($confHostsOrgs); |
---|
570 | $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
571 | } |
---|
572 | else |
---|
573 | { |
---|
574 | $this->fileD->ldapExternal(""); |
---|
575 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
576 | } |
---|
577 | } |
---|
578 | else |
---|
579 | { |
---|
580 | $this->fileD->ldapExternal(""); |
---|
581 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
582 | } |
---|
583 | |
---|
584 | if( $this->db->query($query) ) |
---|
585 | return "true"; |
---|
586 | } |
---|
587 | } |
---|
588 | } |
---|
589 | return "false"; |
---|
590 | } |
---|
591 | |
---|
592 | public final function removeOuGroupsLocked($pGroup) |
---|
593 | { |
---|
594 | $group = $pGroup['group']; |
---|
595 | $gidnumber = $pGroup['gidnumber']; |
---|
596 | $organization = strtoupper($pGroup['ou']); |
---|
597 | $return = false; |
---|
598 | |
---|
599 | if( $this->db ) |
---|
600 | { |
---|
601 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
602 | |
---|
603 | if($this->db->query($query)) |
---|
604 | { |
---|
605 | |
---|
606 | if ( $this->db->query($query) ) |
---|
607 | { |
---|
608 | while($this->db->next_record()) |
---|
609 | $result[] = $this->db->row(); |
---|
610 | } |
---|
611 | |
---|
612 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
613 | |
---|
614 | foreach( $groupsLocked as $tmp ) |
---|
615 | { |
---|
616 | $aux = explode(":",$tmp); |
---|
617 | |
---|
618 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
619 | { |
---|
620 | $ous = explode(",", $aux[2]); |
---|
621 | $key = array_search($organization, $ous); |
---|
622 | |
---|
623 | if( $key !== false ) |
---|
624 | unset($ous[$key]); |
---|
625 | |
---|
626 | $groups .= $group.":".$gidnumber.":"; |
---|
627 | |
---|
628 | foreach($ous as $ouTmp) |
---|
629 | $groups .= $ouTmp .","; |
---|
630 | |
---|
631 | $groups = substr($groups,0,strlen($groups)-1); |
---|
632 | $groups .= ";"; |
---|
633 | } |
---|
634 | else |
---|
635 | $groups .= $tmp . ";" ; |
---|
636 | } |
---|
637 | |
---|
638 | $groups = substr($groups,0,strlen($groups)-1); |
---|
639 | |
---|
640 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
641 | |
---|
642 | if( $this->db->query($query)) |
---|
643 | $return = true; |
---|
644 | } |
---|
645 | } |
---|
646 | |
---|
647 | return $return; |
---|
648 | } |
---|
649 | |
---|
650 | } |
---|
651 | ?> |
---|