Changeset 4457 for sandbox


Ignore:
Timestamp:
05/19/11 13:38:13 (13 years ago)
Author:
airton
Message:

Ticket #1991 - Parametrizacao das buscas LDAP no ExpressoMail?

Location:
sandbox/2.2.0.2/expressoMail1_2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/expressoMail1_2/inc/class.exporteml.inc.php

    r4416 r4457  
    200200                        if (count($array_ids)==1)  
    201201                        {  
    202                                 $sEMLData=$imapf->treat_base64_from_post($array_mesgs[$i]);  
    203                                 $fileName=$this->CreateFileEml($sEMLData, $tempDir,'',$array_subjects[$i],$i);  
     202                                $sEMLData=$imapf->treat_base64_from_post($array_mesgs[0]);  
     203                                $fileName=$this->CreateFileEml($sEMLData, $tempDir,'',$array_subjects[0],"offline");  
    204204                                return $tempDir.'/'.$fileName;  
    205205                        } 
     
    304304                $body           = $this-> getBody($id_number); 
    305305                 
    306                 $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]."_".time().".php"; //source_[sessao]_[timestamp].php 
     306                $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".php"; 
    307307                $f = fopen($tempDir.'/'.$file,"w"); 
    308308                fputs($f,$header ."\r\n\r\n". $body); 
     
    338338                $name = md5($_SESSION[ 'phpgw_session' ][ 'session_id' ].microtime()); 
    339339                 
    340                 $file = $_SESSION[ 'phpgw_session' ][ 'session_id' ].$name; 
    341                 $f = fopen($tempDir . '/'.$file,"w"); 
     340                //$file = $_SESSION[ 'phpgw_session' ][ 'session_id' ].$name; 
     341                $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]."_".time().".php"; //source_[sessao]_[timestamp].php  
     342                $f = fopen($tempDir . '/'.$file,"w"); 
    342343                fputs($f,utf8_encode($header) ."\r\n\r\n". utf8_encode($body)); 
    343344                fclose($f);  
  • sandbox/2.2.0.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r4436 r4457  
    14251425                $regs_found = array();  
    14261426                $tags_found = @mb_eregi("<style\b[^>]*>(.*?)</style>", $body, $regs_found); 
    1427                 $wrapper_class = 'ExpressoCssWrapper'.time(); 
    14281427                 
    14291428                foreach ($regs_found as $block_found) {  
     
    14391438                        $prefix = ".$wrapper_class ";  
    14401439                        foreach ($css->css[41] as $key => $value) { 
    1441                         //explode multiple selectors per block 
    1442                          $selectors = explode(',', $key); 
    1443                         foreach ($selectors as $selector) { 
    1444                                 if (ereg('\*', $key)) { 
    1445                                         //skip selecto '*' 
    1446                                         continue; 
    1447                                 } 
    1448  
    1449                                 $selector = eregi_replace('[^#\.]*body.*', '', $selector); 
    1450                                 $css->css[41][$prefix.trim($selector)] = $value; 
    1451                         } 
     1440                                                //explode multiple selectors per block  
     1441                                                $selectors = explode(',', $key);  
     1442                                                          
     1443                                    foreach ($selectors as $selector) {  
     1444                                        if (ereg('\*', $key)) {  
     1445                                                                //skip selecto '*'  
     1446                                            continue;  
     1447                                        }  
     1448                                                                  
     1449                                                        $selector = eregi_replace('[^#\.]*body.*', '', $selector);  
     1450                                                        $css->css[41][$prefix.trim($selector)] = $value;  
     1451                                    }  
    14521452                        unset($css->css[41][$key]); 
    14531453                        } 
     
    29252925                        $imagesParts[$value[6]] = $value[3];     
    29262926 
    2927                 //Build Forwarding Attachments!!!        
    2928                 foreach($forwarding_attachments as $forwarding_attachment) 
     2927                //Build Forwarding Attachments!!!                     
     2928                foreach($forwarding_attachments as $forwarding_attachment)  
    29292929                { 
    29302930                        $file_description = unserialize(rawurldecode($forwarding_attachment)); 
    2931                          
    2932                         $file_description = array_values($file_description); 
    2933                         foreach($file_description as $i => $descriptor){                                 
    2934                                 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 
    2935                         } 
    2936                         $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 
    2937                         $fileName = $file_description[2]; 
    2938                          
    2939                         $file_description[5] = strlen($fileContent); //Size of file 
    2940                         $return_forward[] = $file_description; 
    2941                  
    2942                         $mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2])); 
     2931                        $file_description = array_values($file_description);  
     2932                                         
     2933                                foreach($file_description as $i => $descriptor){                                  
     2934                                                        $file_description[$i] = eregi_replace('\'*\'','',$descriptor);  
     2935                                                }  
     2936                                                $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]);  
     2937                                                $fileName = $file_description[2];  
     2938                                                  
     2939                                                $file_description[5] = strlen($fileContent); //Size of file  
     2940                                                $return_forward[] = $file_description;  
     2941                                          
     2942                                                $mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2]));  
    29432943                } 
    29442944                 
     
    30353035                                if (array_key_exists("name", $_attachment)) 
    30363036                                { 
    3037                                         //unset($return_files[$index]); 
     3037                                        unset($return_files[$index]); 
    30383038                                        $return_files[$index] = $_attachment['name']."_SIZE_".$return_files[$index][1] = $_attachment['size']; 
    30393039                                } 
    30403040                                else 
    30413041                                { 
    3042                                         //unset($return_files[$index]); 
     3042                                        unset($return_files[$index]); 
    30433043                                        $return_files[$index] = $_attachment[2]."_SIZE_". $return_files[$index][1] = $_attachment[5]; 
    30443044                                } 
     
    41034103        if($timestamp){ 
    41044104                        $pdate = date_parse(date('r')); // pega a data atual do servidor (TODO: pegar a data da mensagem local)  
    4105                 $file = $tempDir."imap_".$_SESSION[ 'phpgw_session' ][ 'session_id' ];           
    41064105                        $timestamp += $pdate['zone']*(60); //converte a data da mensagem para o fuso horário GMT 0. Isto é feito devido ao Expresso Mail armazenar a data no fuso horário GMT 0 e para exibi-la converte ela para o fuso horário local.  
    4107                                  
    4108                 /* TODO: o diretorio /tmp deve ser substituido pelo diretorio temporario configurado no setup */  
    4109                 $file = "/tmp/sess_".$_SESSION[ 'phpgw_session' ][ 'session_id' ];  
     4106                        /* TODO: o diretorio /tmp deve ser substituido pelo diretorio temporario configurado no setup */  
     4107                        $file = "/tmp/sess_".$_SESSION[ 'phpgw_session' ][ 'session_id' ];  
     4108                 
    41104109                $f = fopen($file,"w"); 
    41114110                fputs($f,base64_encode($source)); 
    4112             fclose($f); 
    4113             $command = "python ".$_SESSION['rootPatch']."/expressoMail1_2/imap.py ".escapeshellarg($imap_server)." ".escapeshellarg($imap_port)." ".escapeshellarg($username)." ".escapeshellarg($password)." ".escapeshellarg($timestamp)." ".escapeshellarg($folder)." ".escapeshellarg($file); 
     4111            fclose($f);            
     4112                   $command = "python ".$_SESSION['rootPatch']."/expressoMail1_2/imap.py ".escapeshellarg($imap_server)." ".escapeshellarg($imap_port)." ".escapeshellarg($username)." ".escapeshellarg($password)." ".escapeshellarg($timestamp)." ".escapeshellarg($folder)." ".escapeshellarg($file); 
    41144113            $return['command']=exec(escapeshellcmd($command)); 
    41154114        }else{ 
  • sandbox/2.2.0.2/expressoMail1_2/inc/class.ldap_functions.inc.php

    r3909 r4457  
    11<?php 
     2require_once($_SESSION['rootPath'].'/API/class.servicelocator.php'); 
    23include_once("class.imap_functions.inc.php"); 
    34include_once("class.functions.inc.php"); 
     
    1718        var $max_result; 
    1819        var $functions; 
     20        var $ldapService; 
     21         
    1922        function ldap_functions(){ 
    2023        // todo: Page Configuration for External Catalogs. 
    2124                @include("../contactcenter/setup/external_catalogs.inc.php"); 
    22                 $this->external_srcs= ( isset( $external_srcs ) ) ? $external_srcs : NULL; 
    23                 $this->max_result       = 200; 
     25                $this->ldapService = ServiceLocator::getService('ldap'); 
     26                $this->external_srcs = $external_srcs; 
     27                $this->max_result = $this->ldapService->limit; 
    2428                $this->functions = new functions(); 
    2529        } 
     
    8387                include_once("class.functions.inc.php"); 
    8488                $functions = new functions; 
    85  
    86                 $search_for     = utf8_encode($params['search_for']); 
     89                 
    8790                $field          = $params['field']; 
    8891                $ID                     = $params['ID']; 
    89                  
    90                 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) 
    91                     $extendedinfo=true; 
    92                 else 
    93                     $extendedinfo=false; 
    94  
    95                 $search_for     = explode(" ",$search_for); 
    96                 $aux=""; 
    97                 foreach ($search_for as $search) 
    98                 { 
    99                         if(!$aux) 
    100                         { 
    101                                 $aux=$search; 
    102                         } 
    103                         else 
    104                         { 
    105                                 if (strlen($search) > 2) 
    106                                 { 
    107                                         $aux=$aux."*".$search; 
    108                                 } 
    109                                 else 
    110                                 { 
    111                                         $aux=$aux." ".$search; 
    112                                 } 
    113                         } 
    114                 } 
    115                 $search_for=$aux; 
    116                  
     92 
     93                $ldapService = ServiceLocator::getService('ldap'); 
     94                $filter =  $ldapService->getSearchFilter($params['search_for']); 
     95         
    11796                $contacts_result = array(); 
    11897                $contacts_result['field'] = $field; 
    11998                $contacts_result['ID'] = $ID; 
     99                $search_for = utf8_encode($params['search_for']); 
     100 
    120101                // follow the referral 
    121102                $this->ldapConnect(true); 
    122  
     103                 
    123104                if ($this->ds) 
    124                 { 
    125                         if (($field != 'null') && ($ID != 'null')) 
    126                         { 
    127                                 $filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )"; 
    128                                 if($extendedinfo) 
    129                                 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); 
    130                                 else 
    131                                     $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid"); 
    132                         } 
    133                         else 
    134                         { 
    135                                 $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; 
    136                                 if($extendedinfo) 
    137                                 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou"); 
    138                                 else 
    139                                     $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid"); 
    140                         } 
    141                         $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); 
    142                         if(!$sr) 
    143                                 return null; 
    144                         $count_entries = ldap_count_entries($this->ds,$sr); 
    145  
    146                         // Get user org dn. 
    147                         $user_dn = $_SESSION['phpgw_info']['expressomail']['user']['account_dn']; 
    148                         $user_sector_dn = ldap_explode_dn ( $user_dn, false ); 
    149                         array_shift($user_sector_dn); 
    150                         array_shift($user_sector_dn); 
    151                         $user_sector_dn = implode(",", $user_sector_dn); 
    152  
    153                         // New search only on user sector 
    154                         if ($count_entries > $this->max_result) 
    155                         { 
    156                                 // Close old ldap conection 
    157                                 ldap_close($this->ds); 
    158  
    159                                 // Reopen a local ldap connection, following referral 
    160                                 $this->ldapRootConnect(true); 
    161  
    162                                 $sr= ldap_search($this->ds, $user_sector_dn, $filter, $justthese); 
     105        { 
     106                $ldapService->connection = $this->ds; 
     107 
     108                $justthese = array("cn", "mail", "telephonenumber", "mobile", "phpgwaccountvisible", "uid", "employeenumber", "ou"); 
     109                $types = false; 
     110 
     111                if( $field == 'null' || $ID == 'null' ) 
     112                { 
     113                    $justthese[] = "jpegphoto"; 
     114                    $types = 'u'; 
     115                } 
     116 
     117                $filter = $ldapService->getSearchFilter( $params['search_for'], $types ); 
     118 
     119                $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result); 
     120                         
     121                if(!$sr) 
     122                    return null; 
     123 
     124                $count_entries = ldap_count_entries($this->ds,$sr); 
     125 
     126                $info = ldap_get_entries($this->ds, $sr); 
     127 
     128            // New search only on user sector 
     129            if ($count_entries == $this->max_result) 
     130            { 
     131                $overload = $count_entries; 
     132            } 
     133            else 
     134            { 
     135                $catalogsNum=count($this->external_srcs); 
     136                for ($i=0; $i<=$catalogsNum; $i++)      { 
     137                        if ($this->external_srcs[$i]["quicksearch"]) { 
     138                                $this->ldapConnect(true,$i); 
     139                                $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; 
     140                                $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); 
     141                                $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); 
    163142                                if(!$sr) 
    164143                                        return null; 
    165144                                $count_entries = ldap_count_entries($this->ds,$sr); 
    166  
    167                                 if ($count_entries > $this->max_result){ 
    168                                         $return = array(); 
    169                                         $return['status'] = false; 
    170                                         $return['error'] = "many results"; 
    171                                         return $return; 
     145                                $search = ldap_get_entries($this->ds, $sr); 
     146                                for ($j=0; $j<$search["count"]; $j++) { 
     147                                        $info[] = $search[$j]; 
    172148                                } 
    173                                 else 
    174                                 { 
    175                                         $quickSearch_only_in_userSector = true; 
    176                                 } 
    177                         } 
    178  
    179                         $info = ldap_get_entries($this->ds, $sr); 
    180  
    181                         $tmp = array(); 
    182                         $tmp_users_from_user_org = array(); 
    183  
    184                         if (!$quickSearch_only_in_userSector) { 
    185                                 $catalogsNum=count($this->external_srcs); 
    186                                 for ($i=0; $i<=count($this->external_srcs); $i++)       { 
    187                                         if ($this->external_srcs[$i]["quicksearch"]) { 
    188                                                 $this->ldapConnect(true,$i); 
    189                                                 $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; 
    190                                                 if($extendedinfo) 
    191                                                 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); 
    192                                                 else 
    193                                                     $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid"); 
    194                                                 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); 
    195                                                 if(!$sr) 
    196                                                         return null; 
    197                                                 $count_entries = ldap_count_entries($this->ds,$sr); 
    198                                                 $search = ldap_get_entries($this->ds, $sr); 
    199                                                 for ($j=0; $j<$search["count"]; $j++) { 
    200                                                         $info[] = $search[$j]; 
    201                                                 } 
    202                                                 $info["count"] = count($info)-1; 
    203                                         } 
    204                                 } 
    205                         } 
    206  
    207                         for ($i=0; $i<$info["count"]; $i++) 
    208                         { 
    209                                 if ($quickSearch_only_in_userSector) 
    210                                 { 
    211                                         $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 
    212                                 } 
    213                                 else 
    214                                 { 
    215                                         if (preg_match("/$user_sector_dn/i", $info[$i]['dn'])) 
    216                                         { 
    217                                                 $tmp_users_from_user_org[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 
    218                                         } 
    219                                         else 
    220                                         { 
    221                                                 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 
    222                                         } 
    223                                 } 
    224                         } 
    225                         natcasesort($tmp_users_from_user_org); 
    226                         natcasesort($tmp); 
    227  
    228                         if (($field != 'null') && ($ID != 'null')) 
    229                         { 
    230                                 $i = 0; 
    231  
    232                                 $tmp = array_merge($tmp, $tmp_users_from_user_org); 
    233                                 natcasesort($tmp); 
    234  
    235                                 foreach ($tmp as $info => $cn) 
    236                                 { 
    237                                         $contacts_result[$i] = array(); 
    238                                         $contacts_result[$i]["cn"] = $cn; 
    239                                         list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info); 
    240                                         $i++; 
    241                                 } 
    242                                 $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; 
    243                         } 
    244                         else 
    245                         { 
    246                                 $options_users_from_user_org = ''; 
    247                                 $options = ''; 
    248  
    249                                 /* List of users from user org */ 
    250                                 $i = 0; 
    251                                 foreach ($tmp_users_from_user_org as $info => $cn) 
    252                                 { 
    253                                         $contacts_result[$i] = array(); 
    254                                         $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); 
    255                                         $i++; 
    256                                 } 
    257  
    258                                 /* List of users from others org */ 
    259                                 foreach ($tmp as $info => $cn) 
    260                                 { 
    261                                         $contacts_result[$i] = array(); 
    262                                         $options .= $this->make_quicksearch_card($info, $cn); 
    263                                         $i++; 
    264                                 } 
    265  
    266                                 if ($quickSearch_only_in_userSector) 
    267                                 { 
    268                                         if ($options != '') 
    269                                         { 
    270                                                 $head_option = 
    271                                                         '<tr class="quicksearchcontacts_unselected">' . 
    272                                                                 '<td colspan="2" width="100%" align="center">' . 
    273                                                                         str_replace("%1", $this->max_result,$this->functions->getLang('More than %1 results were found')) . '.<br>' . 
    274                                                                         $this->functions->getLang('Showing only the results found in your organization') . '.'; 
    275                                                                 '</td>' . 
    276                                                         '</tr>'; 
    277                                                 $contacts_result = $head_option . $options_users_from_user_org . $options; 
    278                                         } 
    279                                         else 
    280                                         { 
    281                                                 $return = array(); 
    282                                                 $return['status'] = false; 
    283                                                 $return['error'] = "many results"; 
    284                                                 return $return; 
    285                                         } 
    286                                 } 
    287                                 else 
    288                                 { 
    289                                         if (($options_users_from_user_org != '') && ($options != '')) 
    290                                         { 
    291                                                 $head_option0 = 
    292                                                         '<tr class="quicksearchcontacts_unselected">' . 
    293                                                                 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 
    294                                                                         $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; 
    295                                                                 '</td>' . 
    296                                                         '</tr>'; 
    297  
    298                                                 $head_option1 = 
    299                                                         '<tr class="quicksearchcontacts_unselected">' . 
    300                                                                 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 
    301                                                                         $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; 
    302                                                                 '</td>' . 
    303                                                         '</tr>'; 
    304                                         } 
    305                                         $contacts_result = $head_option0 . $options_users_from_user_org . $head_option1 . $options; 
    306                                 } 
    307                         } 
    308                 } 
    309                 ldap_close($this->ds); 
    310                 return $contacts_result; 
     149                                $info["count"] = count($info)-1; 
     150                        } 
     151                } 
     152            } 
     153 
     154            $tmp = array(); 
     155            $tmp_users_from_user_org = array(); 
     156 
     157            for ($i=0; $i<$info["count"]; $i++) 
     158            { 
     159                $key = $info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' .                       $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' .      $info[$i]["ou"][0]; 
     160 
     161                if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn'])) 
     162                { 
     163                        $tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]); 
     164                        continue; 
     165                } 
     166 
     167                $tmp[$key] = utf8_decode($info[$i]["cn"][0]); 
     168            } 
     169 
     170            natcasesort($tmp_users_from_user_org); 
     171            natcasesort($tmp); 
     172 
     173            if (($field != 'null') && ($ID != 'null')) 
     174            { 
     175                    $i = 0; 
     176 
     177                    $tmp = array_merge($tmp, $tmp_users_from_user_org); 
     178                    natcasesort($tmp); 
     179 
     180                    foreach ($tmp as $info => $cn) 
     181                    { 
     182                            $contacts_result[$i] = array(); 
     183                            $contacts_result[$i]["cn"] = $cn; 
     184                            list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info); 
     185                            $i++; 
     186                    } 
     187                    $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; 
     188                    $contacts_result['maxResult'] = $ldapService->limit; 
     189            } 
     190            else 
     191            { 
     192                    $options_users_from_user_org = ''; 
     193                    $options = ''; 
     194 
     195             
     196                    $i = 0; 
     197                    foreach ($tmp_users_from_user_org as $info => $cn) 
     198                    { 
     199                            $contacts_result[$i] = array(); 
     200                            $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); 
     201                            $i++; 
     202                    } 
     203 
     204             
     205                    foreach ($tmp as $info => $cn) 
     206                    { 
     207                            $contacts_result[$i] = array(); 
     208                            $options .= $this->make_quicksearch_card($info, $cn); 
     209                            $i++; 
     210                    } 
     211 
     212 
     213                    if (($options_users_from_user_org != '') && ($options != '')) 
     214                    {                                    
     215                            $head_option0 = 
     216                                    '<tr class="quicksearchcontacts_unselected">' . 
     217                                            '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 
     218                                                    $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; 
     219                                            '</td>' . 
     220                                    '</tr>'; 
     221 
     222                            $head_option1 = 
     223                                    '<tr class="quicksearchcontacts_unselected">' . 
     224                                            '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 
     225                                                    $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; 
     226                                            '</td>' . 
     227                                    '</tr>'; 
     228                    } 
     229                     
     230                    $head_option = ''; 
     231 
     232                    if( $overload ) 
     233                    $head_option = '<tr class="quicksearchcontacts_unselected">' . 
     234                                    '<td colspan="2" width="100%" align="center" style="background:#EEEEEE; color: red;"><B>' .str_replace('%1', $this->max_result, $this->functions->getLang('More than %1 results. Please, try to refine your search.')) . '</B> '. 
     235                                    '</td>' . 
     236                                    '</tr>'; 
     237 
     238                    $contacts_result = $head_option.$head_option0 . $options_users_from_user_org . $head_option1. $options; 
     239 
     240                } 
     241            } 
     242 
     243            ldap_close($this->ds); 
     244 
     245            return $contacts_result; 
    311246        } 
    312247 
     
    450385        //Busca usuarios de um contexto e ja retorna as options do select - usado por template serpro; 
    451386        function search_users($params) 
    452         { 
    453                 $this->ldapConnect(false,0); 
    454                 //Monta lista de Grupos e Usuarios 
    455                 $users = Array(); 
    456                 $groups = Array(); 
    457                 $user_context= $this->ldap_context; 
    458                 $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; 
    459                 $filtro =utf8_encode($params['filter']); 
    460                 $context =utf8_encode($params['context']);//adicionado 
    461  
    462                 if ($this->ds) 
     387    { 
     388                $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; 
     389                        $ldapService = ServiceLocator::getService('ldap'); 
     390                        $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], 
     391                        $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], 
     392                        $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); 
     393                         
     394                        $groups = $ldapService->accountSearch($params['filter'], array("gidNumber","cn"), $params['context'] , 'g', 'cn');  
     395                        $users = $ldapService->accountSearch($params['filter'], array("uidNumber","cn"), $params['context'] , 'u', 'cn'); 
     396                        $group_options = array(); 
     397                        $user_options  = array(); 
     398                        foreach($groups as $group) 
     399                        { 
     400                                $group_options[] = '"'.$group['gidNumber'].'U'.'":"'.$group['cn'].'"'; 
     401                } 
     402                         
     403                foreach($users as $user)  
    463404                { 
    464                     $justthese = array("gidNumber","cn"); 
    465                     if ($params['type'] == 'search') 
    466                         $sr=ldap_search($this->ds, $context, ("(&(phpgwaccounttype=g)(!(phpgwaccountvisible=-1))(cn=*$filtro*))"),$justthese); 
    467                     else 
    468                         $sr=ldap_list($this->ds,  $context ? $context : $user_context, ("(&(phpgwaccounttype=g)(!(phpgwaccountvisible=-1))(cn=*".$filtro."*))"),$justthese); 
    469                     $info = ldap_get_entries($this->ds, $sr); 
    470                     for ($i=0; $i<$info["count"]; $i++) 
    471                         $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name'    =>    $uids=$info[$i]["cn"][0], 'type'    =>    g); 
    472                     $justthese = array("phpgwaccountvisible","uidNumber","cn"); 
    473                     if ($params['type'] == 'search') 
    474                        // $sr=ldap_search($this->ds, $user_context, ("(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1))(phpgwaccountstatus=A)(|(cn=*$filtro*)(mail=$filtro*)))"),$justthese); 
    475                        $sr=ldap_search($this->ds, $context, ("(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1))(phpgwaccountstatus=A)(|(cn=*$filtro*)(mail=$filtro*)))"),$justthese); 
    476                     else 
    477                         $sr=ldap_list($this->ds, $context ? $context : $user_context, ("(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1))(phpgwaccountstatus=A)(|(cn=*$filtro*)(mail=$filtro*)))"),$justthese); 
    478  
    479                     $info = ldap_get_entries($this->ds, $sr); 
    480                     for ($i=0; $i<$info["count"]; $i++) 
    481                     { 
    482                         if ($info[$i]["phpgwaccountvisible"][0] == '-1') 
    483                       continue; 
    484                         $users[$uids=$info[$i]["uidnumber"][0]] = Array('name'    =>    $uids=$info[$i]["cn"][0], 'type'    =>    u); 
    485                     } 
    486                 } 
    487                 ldap_close($this->ds); 
    488          
    489                 @asort($users); 
    490                 @reset($users); 
    491                 @asort($groups); 
    492                 @reset($groups); 
    493                 $user_options =''; 
    494                 $group_options =''; 
    495  
    496                 foreach($groups as $id => $user_array) { 
    497                         $newId = $id.'U'; 
    498                         $group_options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 
    499                 } 
    500                 foreach($users as $id => $user_array) { 
    501                     if($owner != $id){ 
    502                         $newId = $id.'U'; 
    503                         $user_options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 
    504                     } 
    505                 } 
     405                                if($owner != $user['uidNumber']) 
     406                                        $user_options[] = '"'.$user['uidNumber'].'U'.'":"'.$user['cn'].'"'; 
     407                        } 
     408                         
     409                        $user_options = '{'.implode( ',', $user_options ).'}'; 
     410                        $group_options = '{'.implode( ',', $group_options ).'}'; 
     411                 
    506412                return array("users" => $user_options, "groups" => $group_options); 
    507         } 
     413    } 
    508414 
    509415        function catalogsearch($params) 
    510416        { 
    511                 $cn     = $params['search_for'] ? "*".utf8_encode($params['search_for'])."*" : "*"; 
    512                 $max_result       = $params['max_result'] ? $params['max_result'] : $this->max_result; 
     417                $ldapService = ServiceLocator::getService('ldap'); 
     418                $filter =  $ldapService->getSearchFilter($params['search_for'],array('u','l','s'));  
     419                 
    513420                $catalog = $params['catalog']; 
    514421                $error = False; 
    515                 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) 
    516                     $extendedinfo=true; 
    517                 else 
    518                     $extendedinfo=false; 
     422                 
     423                //if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) 
     424                    //$extendedinfo=true; 
     425                //else 
     426                    //$extendedinfo=false; 
    519427 
    520428 
     
    524432 
    525433                if ($this->ds) { 
    526                         if ($catalog == 0){ 
    527                                 //os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca; 
    528                                 if($extendedinfo) 
    529                                 $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou"); 
    530                                 else 
    531                                     $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible"); 
    532  
    533                                 $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(cn=".$cn."))"; 
    534                                 //$user_context = "ou=".$params['organization'].",".$this->ldap_context; 
    535                         }else { 
    536                                 //os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca; 
    537                                 if($extendedinfo) 
    538                                 $justthese = array("cn", "mail", "employeeNumber", "ou"); 
    539                                 else 
    540                                     $justthese = array("cn", "mail"); 
    541                                 $filter="(&(objectClass=".$this->object_class.")(cn=".$cn."))"; 
    542                                 //$user_context = $this->branch."=".$params['organization'].",".$external_srcs[$catalog]['dn']; 
    543                         } 
    544  
    545                         $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $max_result+1); 
     434                        $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou"); 
     435                        $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $ldapService->limit+1); 
     436                         
    546437                        if(!$sr) 
    547438                                return null; 
    548439                        $count_entries = ldap_count_entries($this->ds,$sr); 
    549                         if ($count_entries > $max_result){ 
     440                        if ($count_entries > $ldapService->limit){  
    550441                                $info = null; 
    551442                                $error = True; 
     
    591482                        unset($g_tmp); 
    592483 
    593                         return  array('users' => $users, 'groups' => $groups, 'error' => $error); 
     484                        return  array('users' => $users, 'groups' => $groups, 'error' => $error,'maxResult' => $ldapService->limit); 
    594485                }else 
    595486                return null; 
     
    676567        function get_available_users2($params) 
    677568        { 
    678                 $this->ldapRootConnect(); 
    679  
    680                 $context= $params['context']; 
    681                 $justthese = array("cn", "uid", "cn"); 
    682                 $filter = "(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"; 
    683  
    684             if ($this->ds) 
    685             { 
    686                         $sr=ldap_search($this->ds, $context, $filter, $justthese); 
    687                         $entries = ldap_get_entries($this->ds, $sr); 
    688  
    689                         for ($i=0; $i<$entries["count"]; $i++){ 
    690                                 if($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] != $entries[$i]["uid"][0]){ 
    691                                         $u_tmp[$entries[$i]["uid"][0]] = $entries[$i]["cn"][0]; 
    692                                 } 
    693                         } 
    694  
    695                         natcasesort($u_tmp); 
    696  
    697                         $i = 0; 
    698                         $users = array(); 
    699  
    700                         if (count($u_tmp)) 
    701                         { 
    702                                 foreach ($u_tmp as $uidnumber => $cn) 
    703                                 { 
    704                                         $options .= "<option value=$uidnumber>$cn</option>"; 
    705                                 } 
    706                                 unset($u_tmp); 
    707                         } 
    708  
    709                         ldap_close($this->ds); 
    710                 return $options; 
    711                 } 
     569                $ldapService = ServiceLocator::getService('ldap');  
     570                $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], 
     571                $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], 
     572                $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); 
     573                 
     574                $entries = $ldapService->accountSearch($params['sentence'], array('cn', 'uid'), $params['context'], 'u', 'cn'); 
     575                 
     576                $options = array(); 
     577                 
     578                foreach ($entries as $value)  
     579                        $options[] = '"'.$value['uid'].'"'.':'.'"'.$value['cn'].'"'; 
     580                 
     581                return "{".implode(',',$options)."}";            
    712582        } 
    713583 
  • sandbox/2.2.0.2/expressoMail1_2/js/QuickCatalogSearch.js

    r4037 r4457  
    510510                var search               = itemSearch ? Element('search_for').value : ''; 
    511511                var catalog              = Element('select_catalog').value; 
    512                 var max_result  = 400; 
    513512 
    514513                var handler_searchResults = function(data){ 
    515514                        Element('msg_search').style.visibility = 'hidden'; 
    516515                        if(data.error){ 
    517                                 alert(get_lang('More than %1 results. Please, try to refine your search.',max_result)); 
     516                                alert(get_lang('More than %1 results. Please, try to refine your search.',data.maxResult)); 
    518517                                return false; 
    519518                        }else if(data.users.length == 0 && data.groups.length == 0){ 
     
    537536                        } 
    538537 
    539                         var arr         = new Array(max_result); 
     538                        var arr         = new Array(data.maxResult); 
    540539 
    541540                        for(i = 0; data.groups && i < data.groups.length; i++) { 
     
    551550                                group.innerHTML = '<select multiple style="display:none;width:580px" size="14" id="list_values">'+ arr.join() +'</select>'; 
    552551 
    553                         arr = new Array(max_result); 
     552                        arr = new Array(data.maxResult); 
    554553                         
    555554                        for(i = 0; data.users && i < data.users.length; i++) { 
     
    582581 
    583582                Element('msg_search').style.visibility = 'visible'; 
    584                 cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults); 
     583                cExecute ("$this.ldap_functions.catalogsearch&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults); 
    585584        } 
    586585 
  • sandbox/2.2.0.2/expressoMail1_2/js/common_functions.js

    r4416 r4457  
    342342                var countDivFiles = 1; 
    343343 
    344         divFile = document.createElement('div');  
    345  
    346         var inputFile = document.createElement("input");  
     344        divFile = document.createElement('div'); 
     345        var inputFile = document.createElement("input"); 
    347346        inputFile.id        = "inputFile_"+id_border+"_"+countDivFiles;  
     347         
    348348        inputFile.name      = "file_"+countDivFiles;  
    349349        inputFile.type      = "file";  
    350         inputFile.size      = 50;  
    351         inputFile.maxlength = 255;  
    352         inputFile.onchange  = function () {  
    353                 validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));  
    354                 openTab.autosave_timer[id_border] = setTimeout("save_msg("+id_border+")", autosave_time);  
     350        inputFile.size      = 50; 
     351        inputFile.maxlength = 255; 
     352         
     353        inputFile.onchange  = function () { 
     354                validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border')); 
     355                 
     356                openTab.autosave_timer[id_border] = setTimeout("save_msg("+id_border+")", autosave_time); 
    355357        };  
    356          
    357         inputFile.onfocus = function () {        
    358                 if (openTab.autosave_timer[id_border])  
    359                         clearTimeout(openTab.autosave_timer[id_border]);  
    360         };  
    361          
    362         divFile.appendChild(inputFile);  
    363  
    364         var linkFile = document.createElement("a");  
    365         linkFile.id        = "linkFile_"+id_border+"_"+countDivFiles;  
    366         linkFile.href      = 'javascript:void(0)';  
    367         linkFile.onclick   = function () {removeFile("divFile_"+id_border+"_"+countDivFiles); return false;};  
    368         linkFile.innerHTML = get_lang("Remove"); 
    369          
     358                 
     359                 
     360        inputFile.onfocus = function () {        
     361                if (openTab.autosave_timer[id_border]) 
     362                        clearTimeout(openTab.autosave_timer[id_border]); 
     363        };       
     364                 
     365        divFile.appendChild(inputFile);          
     366        var linkFile = document.createElement("a");      
     367        linkFile.id        = "linkFile_"+id_border+"_"+countDivFiles; 
     368        linkFile.href      = 'javascript:void(0)'; 
     369        linkFile.onclick   = function () { 
     370                removeFile("divFile_"+id_border+"_"+countDivFiles); return false; 
     371        }; 
     372                 
     373        linkFile.innerHTML = get_lang("Remove");         
     374                 
    370375        divFile.appendChild(linkFile); 
    371376        divFile.id = "divFile_"+id_border+"_"+countDivFiles; 
     
    376381//      Remove Input File Dynamically. 
    377382function removeFile(id){ 
    378         var border_id = id.substr(8,1); 
    379383        var el = Element(id); 
    380384        el.parentNode.removeChild(el); 
     
    565569 
    566570                if ((!data.status) && (data.error == "many results")){ 
    567                         alert(get_lang('More than %1 results. Please, try to refine your search.',200)); 
     571                        alert(get_lang('More than %1 results. Please, try to refine your search.',data.maxResult)); 
    568572                        return false; 
    569573                } 
  • sandbox/2.2.0.2/expressoMail1_2/js/draw_api.js

    r4413 r4457  
    196196                                temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); 
    197197                                if (temp) { 
    198                                        if(is_win && is_gecko && preferences.gears_firefox_windows != "") 
    199                                             location.href = preferences.gears_firefox_windows; 
    200                                        else if(!is_win && is_gecko && preferences.gears_firefox_linux != "") 
    201                                            location.href = preferences.gears_firefox_linux; 
    202                                        else if(is_ie && preferences.gears_ie != "") 
    203                                            location.href = preferences.gears_ie; 
    204                                        else 
    205                                             location.href = "http://gears.google.com/?action=install&message="+get_lang("To use local messages, install Google Gears")+"&return="+document.location.href; 
     198                                       //if(is_win && is_gecko && preferences.gears_firefox_windows != "") 
     199                                        //    location.href = preferences.gears_firefox_windows; 
     200                                       //else if(!is_win && is_gecko && preferences.gears_firefox_linux != "") 
     201                                         //  location.href = preferences.gears_firefox_linux; 
     202                                       //else if(is_ie && preferences.gears_ie != "") 
     203                                           //location.href = preferences.gears_ie; 
     204                                       //else 
     205                                                        expresso_local_messages.installGears(); 
    206206                                } 
    207207                                else { 
     
    250250                tree_folders.draw(Element('content_folders')); 
    251251                if (!expresso_offline) { 
    252                         n_root.changeState(); 
    253                         tree_folders.getNodeById('INBOX')._select(); 
     252                        //n_root.changeState(); 
     253                        //tree_folders.getNodeById('INBOX')._select(); 
    254254                } 
    255255                else { 
     
    31893189        } 
    31903190 
    3191         /**  
    3192         * event to enable autosave_draft on file attachment  
    3193         */  
    3194         function save_onchange_attachment_handler () { 
    3195                 away = false;  
    3196                 var save_link = Element("save_message_options_"+border_id);  
    3197                 save_link.onclick = function onclick(event) {  
    3198                 openTab.toPreserve[border_id] = true;   
    3199                         save_msg(border_id);  
    3200                 };  
    3201                 save_link.className = 'message_options';  
    3202         };  
    32033191         
    32043192        var add_files = document.createElement("A"); 
    32053193        add_files.setAttribute("href", "javascript:void(0)"); 
    3206         add_files.onclick = function () { 
    3207                 var obj = addFile(ID);  
    3208                 if (preferences.auto_save_draft == 1 && obj) { 
    3209                         if ( obj.addEventListener )  
    3210                         obj.addEventListener('click', save_onchange_attachment_handler, false);  
    3211                 }  
    3212                 return false;  
    3213         };  
     3194         
     3195        add_files.onclick = function () {  
     3196                                        var obj = addFile(ID);  
     3197                                        if (preferences.auto_save_draft == 1 && obj) {  
     3198                                                if ( obj.addEventListener )  
     3199                                                        obj.addEventListener('click', save_onchange_attachment_handler, false);  
     3200                                        }  
     3201                                        return false;  
     3202                                };  
     3203         
    32143204        add_files.innerHTML =  get_lang("Attachments: add+"); 
    32153205        add_files.setAttribute("tabIndex","-1"); 
  • sandbox/2.2.0.2/expressoMail1_2/js/main.js

    r4413 r4457  
    18411841                //Replace all files to new files 
    18421842                var divFiles = Element("divFiles_"+border_id); 
     1843                 
    18431844                divFiles.innerHTML = ''; 
    18441845                 
  • sandbox/2.2.0.2/expressoMail1_2/js/sharemailbox.js

    r4108 r4457  
    295295         
    296296        var finderTimeout = ''; 
    297         cShareMailbox.prototype.optionFinderTimeout = function(obj) 
    298         { 
    299                 clearTimeout(finderTimeout);     
    300                 var oWait = document.getElementById("em_span_searching"); 
    301                 oWait.innerHTML = get_lang('Searching')+"..."; 
    302                 var finderTimeout = setTimeout("sharemailbox.optionFinder('"+obj.id+"')",500); 
     297        cShareMailbox.prototype.optionFinderTimeout = function(obj, event) 
     298        { 
     299                if( event.keyCode === 13 ) 
     300                {        
     301                        limit = 0; 
     302                        sharemailbox.optionFinder(obj.id); 
     303                }        
     304                return; 
    303305        } 
    304306         
Note: See TracChangeset for help on using the changeset viewer.