source: trunk/jabberit_messenger/inc/class.db_im.inc.php @ 7673

Revision 7673, 20.2 KB checked in by douglasz, 11 years ago (diff)

Ticket #3236 - Correcoes para Performance: Function Within Loop Declaration.

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