source: trunk/expressoMail1_2/inc/class.db_functions.inc.php @ 5514

Revision 5514, 22.9 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2434 - Implementacao anexos, acls e delegacao de participantes

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2                /***************************************************************************
3                * Expresso Livre                                                           *
4                * http://www.expressolivre.org                                             *
5                * --------------------------------------------                             *
6                *  This program is free software; you can redistribute it and/or modify it *
7                *  under the terms of the GNU General Public License as published by the   *
8                *  Free Software Foundation; either version 2 of the License, or (at your  *
9                *  option) any later version.                                              *
10                \**************************************************************************/
11               
12if(!isset($_SESSION['phpgw_info']['expressomail']['server']['db_name'])) {
13        include_once('../header.inc.php');
14        $_SESSION['phpgw_info']['expressomail']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; 
15        $_SESSION['phpgw_info']['expressomail']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
16        $_SESSION['phpgw_info']['expressomail']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
17        $_SESSION['phpgw_info']['expressomail']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
18        $_SESSION['phpgw_info']['expressomail']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
19        $_SESSION['phpgw_info']['expressomail']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
20}
21else{
22        define('PHPGW_INCLUDE_ROOT','../');     
23        define('PHPGW_API_INC','../phpgwapi/inc');       
24        include_once(PHPGW_API_INC.'/class.db.inc.php');
25}
26include_once('class.dynamic_contacts.inc.php');
27       
28class db_functions
29{       
30       
31        var $db;
32        var $user_id;
33        var $related_ids;
34       
35        function db_functions(){
36                $this->db = new db();           
37                $this->db->Halt_On_Error = 'no';
38                $this->db->connect(
39                                $_SESSION['phpgw_info']['expressomail']['server']['db_name'],
40                                $_SESSION['phpgw_info']['expressomail']['server']['db_host'],
41                                $_SESSION['phpgw_info']['expressomail']['server']['db_port'],
42                                $_SESSION['phpgw_info']['expressomail']['server']['db_user'],
43                                $_SESSION['phpgw_info']['expressomail']['server']['db_pass'],
44                                $_SESSION['phpgw_info']['expressomail']['server']['db_type']
45                );             
46                $this -> user_id = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];       
47        }
48
49        // BEGIN of functions.
50        function get_cc_contacts()
51        {                               
52                $result = array();
53                $stringDropDownContacts = '';           
54               
55                $query_related = $this->get_query_related('A.id_owner'); // field name for owner
56                       
57                // Traz os contatos pessoais e compartilhados
58                $query = 'select A.names_ordered, C.connection_value from phpgw_cc_contact A, '.
59                        'phpgw_cc_contact_conns B, phpgw_cc_connections C where '.
60                        'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
61                        'and B.id_typeof_contact_connection = 1 and ('.$query_related.') group by '.
62                        'A.names_ordered,C.connection_value     order by lower(A.names_ordered)';
63               
64        if (!$this->db->query($query))
65                return null;
66                while($this->db->next_record())
67                        $result[] = $this->db->row();
68
69                if (count($result) != 0)
70                {
71                        // Monta string                         
72                        foreach($result as $contact)
73                                $stringDropDownContacts = $stringDropDownContacts . urldecode(urldecode($contact['names_ordered'])). ';' . $contact['connection_value'] . ',';
74                        //Retira ultima virgula.
75                        $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1));
76                }
77                else
78                        return null;
79
80                return $stringDropDownContacts;
81        }
82        // Get Related Ids for sharing contacts or groups.
83        function get_query_related($field_name){               
84                $query_related = $field_name .'='.$this -> user_id;
85                // Only at first time, it gets all related ids...
86                if(!$this->related_ids) {
87                        $query = 'select id_related from phpgw_cc_contact_rels where id_contact='.$this -> user_id.' and id_typeof_contact_relation=1';         
88                        if (!$this->db->query($query)){
89                return $query_related;
90                        }
91                       
92                        $result = array( );
93                        while($this->db->next_record()){
94                                $row = $this->db->row();
95                                $result[] = $row['id_related'];
96                        }
97                        if($result)
98                                $this->related_ids = implode(",",$result);
99                }
100                if($this->related_ids)
101                        $query_related .= ' or '.$field_name.' in ('.$this->related_ids.')';
102               
103                return $query_related;
104        }
105        function get_cc_groups()
106        {
107                // Pesquisa no CC os Grupos Pessoais.
108                $stringDropDownContacts = '';                   
109                $result = array();
110                $query_related = $this->get_query_related('owner'); // field name for 'owner'           
111                $query = 'select title, short_name, owner from phpgw_cc_groups where '.$query_related.' order by lower(title)';
112
113                // Executa a query
114                if (!$this->db->query($query))
115                return null;
116                // Retorna cada resultado               
117                while($this->db->next_record())
118                        $result[] = $this->db->row();
119
120                // Se houver grupos ....                               
121                if (count($result) != 0)
122                {
123                        // Create Ldap Object, if exists related Ids for sharing groups.
124                        if($this->related_ids){
125                                $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids']= array();
126                                include_once("class.ldap_functions.inc.php");
127                                $ldap = new ldap_functions();
128                        }
129                        $owneruid = '';
130                        foreach($result as $group){
131                                // Searching uid (LDAP), if exists related Ids for sharing groups.
132                                // Save into user session. It will used before send mail (verify permission).
133                                if(!isset($_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']]) && isset($ldap)){                                 
134                                        $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']] = $ldap -> uidnumber2uid($group['owner']);
135                                }
136                                if($this->user_id != $group['owner'])
137                                        $owneruid = "::".$_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']];
138                                else
139                                        $owneruid = '';
140
141                                $stringDropDownContacts .=  $group['title']. ';' . ($group['short_name'].$owneruid) . ',';
142                        }
143                        //Retira ultima virgula.
144                        $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1));
145                }
146                else
147                        return null;           
148                return $stringDropDownContacts;
149        }
150       
151        function getContactsByGroupAlias($alias)
152        {
153                list($alias,$uid) = explode("::",$alias);               
154                $cc_related_ids = $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'];           
155                // Explode personal group, If exists related ids (the user has permission to send email).
156                if(is_array($cc_related_ids) && $uid){
157                        $owner =  array_search($uid,$cc_related_ids);                   
158                }
159               
160                $query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ".
161                "phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D,phpgw_cc_groups E where ".
162                "A.id_contact = B.id_contact and B.id_connection = C.id_connection ".
163                "and B.id_typeof_contact_connection = 1 and ".
164                "A.id_owner =".($owner ? $owner : $this->user_id)." and ".                     
165                "D.id_group = E.id_group and ".
166                "D.id_connection = C.id_connection and E.short_name = '".$alias."'";
167
168                if (!$this->db->query($query))
169                {
170                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
171                }
172
173                $return = false;
174
175                while($this->db->next_record())
176                {
177                        $return[] = $this->db->row();
178                }
179
180                return $return;
181        }
182
183        function getAddrs($array_addrs) {
184                $array_addrs_final = array();                           
185
186                for($i = 0; $i < count($array_addrs); $i++){
187                        $j = count($array_addrs_final);
188
189                        if(preg_replace('/\s+/', '', $array_addrs[$i]) != ""){
190                                if(strchr($array_addrs[$i],'@') == "") {               
191                                        if(strpos($array_addrs[$i],'<') && strpos($array_addrs[$i],'>')){
192                                                $alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>'));
193                                                $alias = str_replace('<','', str_replace('>','',$alias));
194                                        }
195                                        else{
196                                                $alias = $array_addrs[$i];                     
197                                                $alias = preg_replace('/\s/', '', $alias);
198                                        }       
199                                        $arrayContacts = $this -> getContactsByGroupAlias($alias);
200
201                                        if($arrayContacts) {
202                                                foreach($arrayContacts as $index => $contact){
203                                                        if($contact['names_ordered']) {
204                                                                $array_addrs_final[$j] = '"'.$contact['names_ordered'].'" <'.$contact['connection_value'].'>';
205                                                        }
206                                                        else
207                                                                $array_addrs_final[$j] = $contact['connection_value'];
208
209                                                        $j++;
210                                                }
211                                        }else{
212                                                return array("False" => "$alias");
213                                        }
214                                }
215                                else{
216                                        $array_addrs_final[$j] = $array_addrs[$i];
217                                }
218                        }else{
219                                $array_addrs_final[$j] = $array_addrs[$i];
220                        }
221                }
222                return $array_addrs_final;
223        }
224
225        //Gera lista de contatos para ser gravado e acessado pelo expresso offline.
226        function get_dropdown_contacts_to_cache() {
227                return $this->get_dropdown_contacts();
228        }
229       
230        function get_dropdown_contacts(){
231                $contacts = $this->get_cc_contacts();
232                $groups = $this->get_cc_groups();
233               
234                if(($contacts) && ($groups))
235                        $stringDropDownContacts = $contacts . ',' . $groups;
236                elseif ((!$contacts) && (!$groups))
237                        $stringDropDownContacts = '';
238                elseif (($contacts) && (!$groups))
239                        $stringDropDownContacts = $contacts;
240                elseif ((!$contacts) && ($groups))
241                        $stringDropDownContacts = $groups;
242                                       
243                if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) {
244                        // Free others requests
245                        session_write_close();
246                        $dynamic_contact = new dynamic_contacts();
247                        $dynamic = $dynamic_contact->dynamic_contact_toString();
248                        if ($dynamic)
249                                $stringDropDownContacts .= ($stringDropDownContacts ? ',' : '') . $dynamic;
250                }
251                return $stringDropDownContacts;
252        }
253        function getUserByEmail($params){       
254                // Follow the referral
255                $email = $params['email'];
256                $query = 'select A.names_ordered, C.connection_name, C.connection_value, A.photo'.
257                                ' from phpgw_cc_contact A, phpgw_cc_contact_conns B, '.
258                                'phpgw_cc_connections C where A.id_contact = B.id_contact'.
259                                ' and B.id_connection = C.id_connection and A.id_contact ='.
260                                '(select A.id_contact from phpgw_cc_contact A, phpgw_cc_contact_conns B,'.
261                                'phpgw_cc_connections C where A.id_contact = B.id_contact'.
262                                ' and B.id_connection = C.id_connection and A.id_owner = '.$this -> user_id.
263                                ' and C.connection_value = \''.$email.'\') and '.
264                                'C.connection_is_default = true and B.id_typeof_contact_connection = 2';
265
266        if (!$this->db->query($query))
267                return null;
268
269
270                if($this->db->next_record()) {
271                        $result = $this->db->row();
272
273                        $obj =  array("cn" => $result['names_ordered'],
274                                          "email" => $email,
275                                          "type" => "personal",
276                                          "telefone" =>  $result['connection_value']);
277
278                        if($result['photo'])
279                                $_SESSION['phpgw_info']['expressomail']['contact_photo'] =  array($result['photo']);                           
280
281                        return $obj;
282                }
283                return $result;
284        }
285       
286        function get_dynamic_contacts()
287        {                               
288                // Pesquisa os emails e ultima inserção nos contatos dinamicos.
289                if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__))
290                {
291                return $this->db->Error;
292}
293                while($this->db->next_record())
294                {
295                        $result[] = $this->db->row();
296                }
297                if($result) foreach($result as $item)
298                {
299                        $contacts = unserialize($item['data']);
300                }
301                if (count($contacts) == 0)
302                {                       
303                        return null;
304                }       
305                //Sort by email
306                function cmp($a, $b) { return strcmp($a["email"], $b["email"]);}
307                usort($contacts,"cmp");
308                return $contacts;
309        }
310        function update_contacts($contacts=array())
311        {                       
312               
313       
314                if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__))
315        {
316            $result['dberr1'] = $this->db->Error;
317        }
318                $regs = array();
319                while($this->db->next_record())
320        {
321            $regs[] = $this->db->row();
322        }
323                $old_contatacts = array();
324                foreach($regs as $old){
325                        $old_contatacts = unserialize($old['data']);
326                }
327                 
328                foreach($old_contatacts as $i => $v)
329                        foreach($contacts as $ii => $vv)
330                                if(trim($v['email']) == trim($vv['email']))
331                                        unset($old_contatacts[$i]);
332               
333                 
334                 $old_contatacts = array_merge( $old_contatacts , $contacts);           
335                // Atualiza um email nos contatos dinamicos.
336                if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($old_contatacts).'\'','id_owner ='.$this->user_id,__LINE__,__FILE__))
337                {
338                        return $this->db->Error;
339                }
340                return $contacts;
341        }       
342        function update_preferences($params){
343                $string_serial = urldecode($params['prefe_string']);                           
344                $string_serial = get_magic_quotes_gpc() ? $string_serial : addslashes($string_serial);
345                $query = "update phpgw_preferences set preference_value = '".$string_serial."' where preference_app = 'expressoMail'".
346                        " and preference_owner = '".$this->user_id."'";
347
348                if (!$this->db->query($query))
349                        return $this->db->error;
350                else
351                        return array("success" => true);
352        }
353       
354        function insert_contact($contact)       
355        {
356                $contacts[] = array( 'timestamp'        => time(),
357                                                                'email'         => $contact );
358
359                // Insere um email nos contatos dinamicos.     
360                $query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner)  ' .
361                                        'values ( \''.serialize($contacts).'\', '.$this->user_id.')';
362               
363                if(!$this->db->query($query,__LINE__,__FILE__))
364                return $this->db->Error;
365        return $contacts;
366        }
367       
368        function remove_dynamic_contact($user_id,$line,$file)
369        {
370                $where = $user_id.' = id_owner';
371                $this->db->delete('phpgw_expressomail_contacts',$where,$line,$file);   
372        }
373       
374        function import_vcard($params){
375            include_once('class.imap_functions.inc.php');
376            $objImap = new imap_functions();
377            $msg_number = $params['msg_number'];
378            $idx_file = $params['idx_file'];
379            $msg_part = $params['msg_part'];
380            $msg_folder = $params['msg_folder'];
381            $from_ajax = $params['from_ajax'];
382            $encoding = strtolower($params['encoding']);
383            $fileContent = "";
384            $cirus_delimiter = $params['cirus_delimiter'];
385            $expFolder = explode($cirus_delimiter, $msg_folder);
386
387            if($msg_number != null && $msg_part != null && $msg_folder != null && (intval($idx_file == '0' ? '1' : $idx_file)))
388            {
389                require_once PHPGW_INCLUDE_ROOT.'/expressoMail1_2/inc/class.attachment.inc.php';
390                $attachmentObj = new attachment();
391                $attachmentObj->setStructureFromMail($msg_folder,$msg_number);
392                $fileContent = $attachmentObj->getAttachment($msg_part);
393                $info = $attachmentObj->getAttachmentInfo($msg_part);
394                $filename = $info['name'];
395            }
396            else
397                    $filename = $idx_file;
398                   
399            // It's necessary to access calendar method.
400            $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
401            $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
402            $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar';
403            include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php');
404            $uiicalendar = CreateObject("calendar.uiicalendar");
405                        if($params['selected'] || $params['readable']){
406                                $user = $params['id_user'];
407                               
408                                $_REQUEST['data'] = $fileContent;
409                                $_REQUEST['type'] = 'iCal';
410                                $_REQUEST['params']['calendar'] = $params['selected'];
411                                $_REQUEST['readable'] = $params['readable'] ? true : false;
412                $_REQUEST['analize'] = isset($params['analize']) ? true : false;
413                                $_REQUEST['params']['status'] = $params['status'];
414                                $_REQUEST['params']['owner'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];
415                                if(isset($params['acceptedSuggestion'])){
416                                        $_REQUEST['params']['acceptedSuggestion'] = $params['acceptedSuggestion'];
417                                        $_REQUEST['params']['from'] = $params['from'];
418                                }
419                               
420                                ob_start();
421                                include_once(PHPGW_INCLUDE_ROOT.'/prototype/converter.php');
422                                $output = ob_get_clean();                       
423                                $valid = json_decode($output, true);
424                                if($_REQUEST['readable']){     
425                                        if(!is_array($valid))
426                                        {
427                                                $output = unserialize($output);
428                                                foreach($output as $key => $value)
429                                                    return $value;
430                                        }
431                                        return false;
432                                }
433
434                                if(empty($valid))
435                                        return "error";
436                                return "ok";
437                        }
438            if(strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) // IF se a conta o ical estiver em uma conta compartilhada
439            {
440                include_once('class.ldap_functions.inc.php');
441                $ldap = new ldap_functions();
442                $account['uid'] = $expFolder[1];
443                $account['uidnumber']  = $ldap->uid2uidnumber($expFolder[1]);
444                $account['mail']  = $ldap->getMailByUid($expFolder[1]);
445
446                return $uiicalendar->import_from_mail($fileContent, $from_ajax,$account);
447            }
448            else
449                return $uiicalendar->import_from_mail($fileContent, $from_ajax);
450
451        }
452
453    function insert_certificate($email,$certificate,$serialnumber,$authoritykeyidentifier=null)
454        {
455                if(!$email || !$certificate || !$serialnumber || !$authoritykeyidentifier)
456                        return false;
457                // Insere uma chave publica na tabela phpgw_certificados.
458                $data = array   ('email' => $email,
459                                                 'chave_publica' => $certificate,
460                                                 'serialnumber' => $serialnumber,
461                                                 'authoritykeyidentifier' => $authoritykeyidentifier);
462
463                if(!$this->db->insert('phpgw_certificados',$data,array(),__LINE__,__FILE__)){
464                return $this->db->Error;
465        }
466        return true;
467        }
468
469        function get_certificate($email=null)
470        {
471                if(!$email) return false;
472                $result = array();
473
474                $where = array ('email' => $email,
475                                                'revogado' => 0,
476                                                'expirado' => 0);
477
478                if(!$this->db->select('phpgw_certificados','chave_publica', $where, __LINE__,__FILE__))
479        {
480            $result['dberr1'] = $this->db->Error;
481            return $result;
482        }
483                $regs = array();
484                while($this->db->next_record())
485        {
486            $regs[] = $this->db->row();
487        }
488                if (count($regs) == 0)
489        {
490            $result['dberr2'] = ' Certificado nao localizado.';
491            return $result;
492        }
493                $result['certs'] = $regs;
494                return $result;
495        }
496
497        function update_certificate($serialnumber=null,$email=null,$authoritykeyidentifier,$expirado,$revogado)
498        {
499                if(!$email || !$serialnumber) return false;
500                if(!$expirado)
501                        $expirado = 0;
502                if(!$revogado)
503                        $revogado = 0;
504
505                $data = array   ('expirado' => $expirado,
506                                                 'revogado' => $revogado);
507
508                $where = array  ('email' => $email,
509                                                 'serialnumber' => $serialnumber,
510                                                 'authoritykeyidentifier' => $authoritykeyidentifier);
511
512                if(!$this->db->update('phpgw_certificados',$data,$where,__LINE__,__FILE__))
513                {
514                        return $this->db->Error;
515                }
516                return true;
517        }
518
519       
520        /**
521     * @abstract Recupera o valor da regra padrão.
522     * @return retorna o valor da regra padrão.
523     */
524        function get_default_max_size_rule()
525        {
526                $query = "SELECT config_value FROM phpgw_config WHERE config_name = 'expressoAdmin_default_max_size'";
527                if(!$this->db->query($query))
528            return false;
529
530        $return = array();
531                       
532                while($this->db->next_record())
533            array_push($return, $this->db->row());
534                       
535                return $return;
536        }
537       
538        /**
539     * @abstract Recupera a regra de um usuário.
540     * @return retorna a regra que o usuário pertence. Caso o usuário não participe de nenhuma regra, retorna false.
541     */
542        function get_rule_by_user($id_user)
543        {
544                $return = array();     
545                $query = "SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user='$id_user' AND configuration_type='MessageMaxSize'";
546               
547                if(!$this->db->query($query))
548            return false;
549               
550                while($this->db->next_record())
551            array_push($return, $this->db->row());
552                       
553                return $return;
554        }
555       
556       
557        function get_rule_by_user_in_groups($id_group)
558        {
559                $return = array();
560                $query = "SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE configuration_type='MessageMaxSize' AND email_user_type='G' AND email_user='".$id_group."'";
561
562                if(!$this->db->query($query))   
563                        return false;   
564                       
565                while($this->db->next_record())
566                        array_push($return, $this->db->row());
567
568                return $return;
569        }
570        function getMaximumRecipientsUser($pUserUID)
571        {
572
573           $query = 'SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$pUserUID.'\' AND configuration_type = \'LimitRecipient\' AND email_user_type = \'U\' ';
574           $this->db->query($query);
575
576           $return = array();
577
578            while($this->db->next_record())
579              $return =  $this->db->row();
580
581            return $return['email_max_recipient'];
582        }
583
584        function getMaximumRecipientsGroup($pGroupsGuidnumbers)
585        {
586           $groupsGuidNumbers = '';
587
588           foreach ($pGroupsGuidnumbers as $guidNumber => $cn)
589             $groupsGuidNumbers .= $guidNumber.', ';
590
591           $groupsGuidNumbers = substr($groupsGuidNumbers,0,-2);
592
593           $query = 'SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user IN ('.$groupsGuidNumbers.') AND configuration_type = \'LimitRecipient\' AND email_user_type = \'G\' ';
594           $this->db->query($query);
595
596           $return = array();
597
598            while($this->db->next_record())
599              $return[] =  $this->db->row();
600
601            $maxSenderReturn = 0;
602
603            foreach ($return as $maxSender)
604            {
605                if($maxSender['email_max_recipient'] > $maxSenderReturn)
606                    $maxSenderReturn = $maxSender['email_max_recipient'];
607            }
608
609            return $maxSenderReturn;
610        }
611
612        function validadeSharedAccounts($user,$grups,$accountsMails)
613        {
614
615             $arrayMailsBlocked = array();
616
617             $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$user.'\' AND email_recipient = \'*\'  AND configuration_type = \'InstitutionalAccountException\' AND email_user_type = \'U\' ';
618             $this->db->query($query);
619             $this->db->next_record();
620                 if($this->db->row())
621                   return $arrayMailsBlocked;
622
623            foreach ($grups as $guidNumber => $cn)
624            {
625                 $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$guidNumber.'\' AND email_recipient = \'*\'  AND configuration_type = \'InstitutionalAccountException\' AND email_user_type = \'G\' ';
626                 $this->db->query($query);
627                 $this->db->next_record();
628                 if($this->db->row())
629                     return $arrayMailsBlocked;
630
631            }
632
633            foreach ($accountsMails as $mail)
634            {
635               
636               $blocked = true;
637
638               $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_recipient = \''.$mail.'\' AND configuration_type = \'InstitutionalAccountException\' ';
639               $this->db->query($query);
640           
641                while($this->db->next_record())
642                {
643                    $row =  $this->db->row();
644                   
645                    if(($row['email_user'] == '*' ||  $row['email_user'] == $user) && ($row['email_user_type'] == 'T' || $row['email_user_type'] == 'U'))
646                        $blocked = false;
647                    else if(array_key_exists($row['email_user'], $grups) && $row['email_user_type'] == 'G')
648                         $blocked = false;
649
650                }
651
652                if($blocked == true)
653                    array_push ($arrayMailsBlocked, $mail);
654            }
655
656            return $arrayMailsBlocked;
657        }
658
659}
660?>
Note: See TracBrowser for help on using the repository browser.