source: branches/2.2/jabberit_messenger/inc/class.db_im.inc.php @ 3102

Revision 3102, 20.6 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
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
13define('PHPGW_INCLUDE_ROOT','../');     
14define('PHPGW_API_INC','../phpgwapi/inc');
15require_once(PHPGW_API_INC . '/class.db.inc.php');
16require_once "class.fileDefine.inc.php";
17       
18class 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                if( $this->db->query($query) ) 
121                {
122                        $users = array();
123                        $new_users = array();
124                        while($this->db->next_record())
125                                $users[] = $this->db->row();
126
127                        if(is_array($users))
128                                foreach($users as $tmp)
129                                        $new_users[] = $tmp['acl_account'];
130                       
131                        return $new_users;
132                }
133               
134                return false;
135        }
136       
137        public final function getGroupsBlocked()
138        {
139                $return = "";
140               
141                if( $this->db )
142                {
143                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";       
144                       
145                        if($this->db->query($query))
146                        {
147
148                                if ( $this->db->query($query) )
149                                {       
150                                        while($this->db->next_record())
151                                                $result[] = $this->db->row();
152                                }
153                               
154                                if( count($result) > 0 )
155                                        $return = $result[0]['config_value'];
156                        }
157                }
158               
159                return $return;
160        }
161
162        public final function getGroupsJmessenger()
163        {
164                $return = "";
165       
166                if( $this->db )
167                {
168                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_jmessenger_jabberit';";
169                       
170                        if($this->db->query($query))
171                        {
172                                while($this->db->next_record())
173                                        $result[] = $this->db->row();                           
174                        }
175
176                        if( count($result) > 0 )
177                                $return = $result[0]['config_value'];
178                }
179               
180                return $return;
181               
182        }
183
184        public final function getGroupsSearch()
185        {
186                $return = "";
187       
188                if( $this->db )
189                {
190                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_search_jabberit';";
191                       
192                        if($this->db->query($query))
193                        {
194                                while($this->db->next_record())
195                                        $result[] = $this->db->row();                           
196                        }
197
198                        if( count($result) > 0 )
199                                $return = $result[0]['config_value'];
200                }
201               
202                return $return;
203        }
204       
205        public final function getHostsJabber()
206        {
207                $return = "";
208       
209                if( $this->db )
210                {
211                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';";
212                       
213                        if($this->db->query($query))
214                        {
215                                while($this->db->next_record())
216                                        $result[] = $this->db->row();                           
217                        }
218
219                        if( count($result) > 0 )
220                                $return = $result[0]['config_value'];
221                }
222               
223                return $return;
224        }
225       
226        public final function getPreferences()
227        {
228                $result = array();
229                $query = "SELECT * FROM phpgw_preferences WHERE preference_owner = '".$this->user_id."' AND preference_app = 'jabberit_messenger'";
230               
231                if ( $this->db->query($query) )
232                {       
233                        while($this->db->next_record())
234                                $result[] = $this->db->row();
235       
236                        if( count($result) > 0 )
237                        {
238                                $_return = unserialize($result[0]['preference_value']);
239                               
240                                if( is_array($_return) )
241                                        return $_return['preferences'];
242                                else
243                                        return $_return;
244                        }
245                }
246
247                return "openWindowJabberit:true;openWindowJabberitPopUp:false;flagAwayIM:5";
248        }
249
250        public final function setApplications($pApplications)
251        {
252                $apps = serialize($pApplications);
253               
254                if( $this->db )
255                {
256                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'";
257                               
258                        $this->db->query($query);
259                                       
260                        if(!$this->db->next_record())
261                        {
262                                $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')";
263                                $this->db->query($query);
264                                return true;
265                        }
266                        else
267                        {
268                                $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'";
269                                $this->db->query($query);
270                                return true;
271                        }
272                }
273                return false;   
274        }
275       
276        public final function setAttributesLdap($pAttributes)
277        {
278                $values = $pAttributes['conf'];
279                $attributesOrg = "";           
280
281                if( $this->db )
282                {
283                        $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'";
284
285                        if ( $this->db->query($query) )
286                        {       
287                                while($this->db->next_record())
288                                        $result[] = $this->db->row();
289               
290                                if(count($result) > 0)
291                                        $attributesOrg = $result[0]['config_value'];
292                        }
293
294                        if( trim($attributesOrg) == "" )
295                        {
296                                $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','attributes_org_ldap_jabberit','".$values."')";
297                                $this->db->query($query);
298                               
299                                $attr = explode(";", $values);
300                                $values = "<return><ou attr='".$attr[1]."'>".$attr[0]."</ou></return>";
301                                return $values;
302                        }
303                        else
304                        {
305                                $org = explode(",", $attributesOrg);
306                                $newValue = explode(";", $values);
307                               
308                                foreach( $org as $tmp )
309                                {
310                                        $attr = explode(";",$tmp);
311                                        if( strtolower(trim($attr[0])) == strtolower(trim($newValue[0])) )
312                                                return false;
313                                }
314
315                                $values = $values . "," . $attributesOrg;
316                                $query = "UPDATE phpgw_config SET config_value = '".$values."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'";
317                                $this->db->query($query);
318
319                                $return = explode(",",$values);
320                                natcasesort($return);
321
322                                $values = "<return>";
323                               
324                                foreach($return as $tmp)
325                                {
326                                        $attr = explode(";", $tmp);
327                                        $values .= "<ou attr='" . $attr[1] . "'>" . $attr[0] . "</ou>";
328                                }
329                                       
330                                $values .= "</return>";
331                               
332                                return $values;                         
333                        }
334                }
335                return false;
336        }
337       
338        public final function setAddGroupsJmessenger($pData)
339        {
340                $pData = ( $pData ) ? serialize($pData) : "";
341               
342                if( $this->db )
343                {
344                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_jmessenger_jabberit';";
345                       
346                        if( $this->db->query($query) )
347                        {
348                                while( $this->db->next_record())
349                                        $result[] = $this->db->row();                                   
350                        }
351                       
352                        if( count($result) == 0 )
353                                $query = "INSERT INTO phpgw_config( config_app, config_name, config_value ) VALUES('phpgwapi', 'groups_jmessenger_jabberit', '".$pData."');";
354                        else
355                                $query = "UPDATE phpgw_config SET config_value = '".$pData."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_jmessenger_jabberit';";
356                       
357                        if ( $this->db->query($query) )
358                                return true;
359                }
360               
361                return false;
362        }
363
364        public final function setAddGroupsSearch($pData)
365        {
366                if( $pData)
367                {
368                        if( $this->db )
369                        {
370                                $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND  config_name = 'groups_search_jabberit';";
371                               
372                                if( $this->db->query($query) )
373                                {
374                                        while( $this->db->next_record())
375                                                $result[] = $this->db->row();                           
376                                }
377                               
378                                if( count($result) == 0 )
379                                {
380                                        $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','groups_search_jabberit','".serialize($pData)."');";
381                                        $this->db->query($query);
382                                        return true;
383                                }
384                                else
385                                {
386                                        $keyLdap = array_keys($pData);
387                                        $resultQuery = unserialize($result[0]['config_value']);                                 
388                                       
389                                        if( is_array(unserialize($pData[$keyLdap[0]])) )
390                                                $resultQuery[$keyLdap[0]] = $pData[$keyLdap[0]];
391                                        else
392                                                unset($resultQuery[$keyLdap[0]]);
393
394                                        if( count($resultQuery))
395                                                $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_search_jabberit';";
396                                        else
397                                                $query = "DELETE FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_search_jabberit';";
398                                               
399                                        $this->db->query($query);
400                                        return true;
401                                }
402                        }                       
403                }
404        }
405
406        public final function setGroupsLocked($pGroups)
407        {
408                $groups = "";
409               
410                if( is_array($pGroups) )
411                {
412                        foreach($pGroups as $tmp)               
413                                if(trim($tmp) != "")
414                                        $groups .= $tmp . ";";
415               
416                        $groups = substr($groups, 0, strlen($groups) - 1 );             
417                }
418               
419                if( $this->db )
420                {
421                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";       
422                       
423                        if($this->db->query($query))
424                        {
425
426                                if ( $this->db->query($query) )
427                                {       
428                                        while($this->db->next_record())
429                                                $result[] = $this->db->row();
430                                }
431
432                                if( count($result) == 0 )
433                                {
434                                        $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','groups_locked_jabberit','".$groups."');";
435                                        $this->db->query($query);
436                                        return true;
437                                }
438                                else
439                                {
440                                        $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
441                                        $this->db->query($query);
442                                        return true;
443                                }
444                        }
445                }
446               
447                return false;
448        }
449       
450        public final function setHostJabber($pParam)
451        {
452                $confHostsJabber =  array();
453
454                foreach($pParam as $key => $itens)
455                        $confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens;
456
457                if( $this->db )
458                {
459                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';";
460                       
461                        if( $this->db->query($query) )
462                        {
463                                while($this->db->next_record())
464                                        $result[] = $this->db->row();                           
465                        }
466                       
467                        if( count($result) == 0 )
468                        {
469                                $return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>";                         
470                                $hostsJabber[0] = $confHostsJabber;
471                               
472                                $this->fileD->ldapExternal($hostsJabber);
473                                 
474                                $query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')";
475                                $this->db->query($query);                               
476                        }
477                        else
478                        {
479                                $resultQuery = unserialize($result[0]['config_value']);
480                                $foundOrg = false;
481                               
482                                foreach($resultQuery as $key => $itens)
483                                {
484                                        $foundString = array_search($confHostsJabber['org'], $itens);
485                                        if( $foundString )
486                                        {
487                                                $foundOrg = $foundString;
488                                                $ky = $key;
489                                        }
490                                }       
491
492                                if( ! $foundOrg )
493                                        $resultQuery[] = $confHostsJabber;     
494                                else
495                                        $resultQuery[$ky] = $confHostsJabber;
496
497                                $return = "<return>";
498                               
499                                foreach( $resultQuery as $itens )
500                                        $return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>";
501                               
502                                $return .= "</return>";
503                               
504                                $this->fileD->ldapExternal($resultQuery);
505                               
506                                $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';";
507                                $this->db->query($query);
508                        }
509                        return $return;
510                }       
511                return false;
512        }
513       
514        public final function setOuGroupsLocked($pGroup)
515        {
516               
517                function strallpos($haystack, $needle, $offset = 0)
518                {
519                    $result = array();
520                    for($i = $offset; $i< strlen($haystack); $i++ )
521                    {
522                        $pos = strpos($haystack,$needle,$i);
523                        if($pos !== FALSE)
524                        {
525                            $offset =  $pos;
526                            if($offset >= $i)
527                                $result[] = $i = $offset;
528                        }
529                    }
530               
531                return $result;
532                }
533
534                $group = $pGroup['group'];
535                $gidnumber = $pGroup['gidnumber'];
536                $organization = strtoupper(trim($pGroup['ou']));
537
538                $posAll = strallpos($organization, "OU=" );
539                $orgs = array();
540
541                for( $i = 0 ; $i < count($posAll); $i++ )
542                {
543                        $pos = strpos($organization, ",");
544                        $tmpString = substr($organization, $posAll[$i] + 3);
545                        $orgs[] = substr($tmpString, 0, strpos($tmpString, ","));
546                }
547
548                $organization = implode("/", array_reverse($orgs));
549
550                if( $this->db )
551                {
552                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";       
553                       
554                        if($this->db->query($query))
555                        {
556
557                                if ( $this->db->query($query) )
558                                {       
559                                        while($this->db->next_record())
560                                                $result[] = $this->db->row();
561                                }
562
563                                $groupsLocked = explode(";",$result[0]['config_value']);
564                                       
565                                foreach( $groupsLocked as $tmp )
566                                {
567                                        $aux = explode(":", $tmp);
568                                        if(($group.":".$gidnumber) == ($aux[0].":".$aux[1]))
569                                        {
570                                                if( $aux[2] )
571                                                {
572                                                        $ou_groups = explode(",",$aux[2]);
573                                                        natcasesort($ou_groups);
574                                                        $key = array_search($organization, $ou_groups);
575                                                       
576                                                        if( $key === false )
577                                                                array_push($ou_groups, $organization);
578                                                       
579                                                        $groups .= $group.":".$gidnumber.":";
580                                                       
581                                                        $return = "<return>";                                           
582                                                       
583                                                        foreach($ou_groups as $tmp)
584                                                        {
585                                                                $return .= "<ou attr='".$tmp."'>".$tmp."</ou>";
586                                                                $groups .= $tmp .",";   
587                                                        }
588                                                       
589                                                        $return .= "</return>";
590                                                       
591                                                        $groups  = substr($groups,0,strlen($groups)-1);
592                                                        $groups .= ";";
593                                                }
594                                                else
595                                                {
596                                                        $groups .= $group.":".$gidnumber.":".$organization.";";
597                                                        $return = "<return><ou attr='".$organization."'>".$organization."</ou></return>";
598                                                }
599                                        }
600                                        else
601                                                $groups .= $tmp . ";" ;
602                                }
603
604                                $groups = substr($groups,0,strlen($groups)-1);
605
606                                $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
607                                $this->db->query($query);
608                               
609                                return $return;
610                        }
611                }
612               
613                return false;
614        }
615       
616        public final function removeAttributesLdap($pOrg)
617        {
618                $organization = $pOrg['org'];
619               
620                if( $this->db )
621                {
622                        $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'";
623                               
624                        if ( $this->db->query($query) )
625                        {       
626                                while( $this->db->next_record() )
627                                        $result[] = $this->db->row();
628               
629                                if( count($result) > 0 )
630                                        $attributesOrg = $result[0]['config_value'];
631                        }
632
633                        $attributesOrg = explode(",", $attributesOrg);
634                        $newValue = "";
635                        foreach($attributesOrg as $tmp)
636                        {
637                                $attr = explode(";",$tmp);
638                                 
639                                if( strtolower(trim($attr[0])) != strtolower(trim($organization)))
640                                {
641                                        $newValue .= $attr[0] . ";" . $attr[1] . ",";
642                                }
643                        }
644                       
645                        $newValue = substr($newValue, 0,(strlen($newValue) -1 ));
646                       
647                        if( trim($newValue) != "")
648                                $query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'";
649                        else
650                                $query = "DELETE from phpgw_config where config_name = 'attributes_org_ldap_jabberit'";
651                               
652                        if( $this->db->query($query))
653                                return true;
654                        else
655                                return false;
656                }
657                return false;   
658        }
659
660        public final function removeHostsJabber($pItem)
661        {
662                $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';";
663
664                if( $this->db )
665                {
666                        if($this->db->query($query))
667                        {
668                                while($this->db->next_record())
669                                        $result[] = $this->db->row();
670                                       
671                                if( count($result) > 0 )
672                                {
673                                        $confHostsOrgs = unserialize($result[0]['config_value']);
674                                        $hosts = explode(":", $pItem['item']);
675                                        $key = "";
676
677                                        if( count($confHostsOrgs) > 0 )
678                                        {
679                                                for( $i = 0; $i < count($confHostsOrgs); $i++)
680                                                        if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1])
681                                                                $key = $i;     
682
683                                                array_splice($confHostsOrgs, $key, 1);
684                               
685                                                if(count($confHostsOrgs) > 0)
686                                                {                                       
687                                                        $this->fileD->ldapExternal($confHostsOrgs);
688                                                        $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';";
689                                                }
690                                                else
691                                                {
692                                                        $this->fileD->ldapExternal("");
693                                                        $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';";
694                                                }
695                                        }
696                                        else
697                                        {       
698                                                $this->fileD->ldapExternal("");                                         
699                                                $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';";
700                                        }
701
702                                        if( $this->db->query($query) )
703                                                return "true";
704                                }               
705                        }                       
706                }
707                return "false";
708        }
709
710        public final function removeOuGroupsLocked($pGroup)
711        {
712                $group = $pGroup['group'];
713                $gidnumber = $pGroup['gidnumber'];
714                $organization = strtoupper($pGroup['ou']);
715                $return = false;
716               
717                if( $this->db )
718                {
719                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";       
720                       
721                        if($this->db->query($query))
722                        {
723
724                                if ( $this->db->query($query) )
725                                {       
726                                        while($this->db->next_record())
727                                                $result[] = $this->db->row();
728                                }
729
730                                $groupsLocked = explode(";",$result[0]['config_value']);
731                               
732                                foreach( $groupsLocked as $tmp )
733                                {
734                                        $aux = explode(":",$tmp);
735                                       
736                                        if(($group.":".$gidnumber) == ($aux[0].":".$aux[1]))
737                                        {
738                                                $ous = explode(",", $aux[2]);
739                                                $key = array_search($organization, $ous);
740
741                                                if( $key !== false )
742                                                        unset($ous[$key]);
743
744                                                $groups .= $group.":".$gidnumber.":";
745                                               
746                                                foreach($ous as $ouTmp)
747                                                        $groups .= $ouTmp .",";
748                                               
749                                                $groups  = substr($groups,0,strlen($groups)-1);
750                                                $groups .= ";";
751                                        }
752                                        else
753                                                $groups .= $tmp . ";" ;                                                                 
754                                }
755                                       
756                                $groups  = substr($groups,0,strlen($groups)-1);
757                       
758                                $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
759
760                                if( $this->db->query($query))
761                                        $return = true;
762                        }
763                }       
764               
765                return $return;
766        }
767
768}
769?>
Note: See TracBrowser for help on using the repository browser.