Ignore:
Timestamp:
11/12/08 10:59:07 (15 years ago)
Author:
niltonneto
Message:

resolve #358, #363, #365, #366

Location:
trunk/jabberit_messenger/inc
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/jabberit_messenger/inc/class.FileDefine.inc.php

    r439 r551  
    1414{ 
    1515 
    16         final function getParams($pParam) 
     16        public final function getParams($pParam) 
    1717        { 
    1818                $array_values = explode("\n", $pParam['val']);   
     
    6868                fclose($handle); 
    6969    } 
    70  
    7170} 
    7271?> 
  • trunk/jabberit_messenger/inc/class.contacts_im.inc.php

    r417 r551  
    2626        } 
    2727 
    28         private final function users_auth_im($pName) 
    29         {    
    30         $array_uids = $this->db->get_accounts_acl(); 
    31         $count = count($array_uids); 
    32         $uids_members = array(); 
    33          
    34         for($i = 0; $i < $count ;$i+=50) 
    35         {    
    36             $partial_uids = array_slice($array_uids,$i,50); 
    37             $filter_uid = implode(")(uidnumber=",$partial_uids); 
    38             $filter_uid = "(uidnumber=". $filter_uid. ")"; 
    39             $result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid); 
    40             if ( is_array($result) ) 
    41                 $uids_members = array_merge($uids_members,$result);                          
    42                  
    43                 if(count($uids_members) > 50){ 
    44                         unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);           
    45                         return 'Many Results'; 
    46                 }             
    47         } 
    48         if(count($uids_members) > 0) 
    49             return $uids_members; 
    50         else 
    51             return 0;    
     28        public final function getParticipantsExternal() 
     29        { 
     30                return $_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit'];              
    5231        } 
    53                  
     32 
    5433        public final function list_contacts($param) 
    5534        { 
     
    8261                return $return; 
    8362        } 
     63         
     64        private final function users_auth_im($pName) 
     65        {    
     66        $array_uids = $this->db->get_accounts_acl(); 
     67        $count = count($array_uids); 
     68        $uids_members = array(); 
     69         
     70        for($i = 0; $i < $count ;$i+=50) 
     71        {    
     72            $partial_uids = array_slice($array_uids,$i,50); 
     73            $filter_uid = implode(")(uidnumber=",$partial_uids); 
     74            $filter_uid = "(uidnumber=". $filter_uid. ")"; 
     75            $result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid); 
     76            if ( is_array($result) ) 
     77                $uids_members = array_merge($uids_members,$result);                          
     78                 
     79                if(count($uids_members) > 50){ 
     80                        unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);           
     81                        return 'Many Results'; 
     82                }             
     83        } 
     84        if(count($uids_members) > 0) 
     85            return $uids_members; 
     86        else 
     87            return 0;    
     88        } 
     89         
     90         
    8491} 
    8592?> 
  • trunk/jabberit_messenger/inc/class.ldap_im.inc.php

    r526 r551  
    5353        } 
    5454         
     55        private final function _ldapConnect($refer = false) 
     56        { 
     57                function ldapRebindJabberit($ldap_connection, $ldap_url) 
     58                { 
     59                        $acc = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc']; 
     60                        $pw = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw']; 
     61                         
     62                        @ldap_bind($ldap_connection, $acc,$pw); 
     63                } 
     64 
     65                // Using ContactCenter configuration. 
     66                $this->ldap_host        =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['host']; 
     67                $this->ldap_context     =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['dn']; 
     68                $this->ldap_dn          =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc']; 
     69                $this->ldap_pass        =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw']; 
     70 
     71                $this->ldap = ldap_connect($this->ldap_host); 
     72                ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, 3); 
     73                ldap_set_option($this->ldap, LDAP_OPT_REFERRALS, $refer); 
     74                 
     75                if ($refer) 
     76                { 
     77                        ldap_set_rebind_proc($this->ldap, ldapRebindJabberit); 
     78                } 
     79                 
     80                @ldap_bind($this->ldap,$this->ldap_dn,$this->ldap_pass); 
     81        } 
     82 
     83        public final function list_participants_externals($pSearch) 
     84        { 
     85                $this->_ldapConnect(true); 
     86                 
     87                $mail = $pSearch['mail']; 
     88                 
     89                if( $this->ldap ) 
     90                { 
     91                        $filter = "(&(phpgwaccounttype=u)(mail=".$mail."))"; 
     92                        $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto"); 
     93                        $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1); 
     94                        $entry1 = ldap_get_entries($this->ldap,$search); 
     95                        $entry = ldap_first_entry( $this->ldap, $search ); 
     96                }                        
     97                 
     98                if( $entry1['count'] > 0 ) 
     99                { 
     100                        $i = 0; 
     101                        $result_user = array(); 
     102                        $result = array(); 
     103 
     104                        while($entry) 
     105                        { 
     106                         
     107                                if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' ) 
     108                                { 
     109                                        $result['uidnumber'] = @ldap_get_values($this->ldap, $entry, 'uidnumber');                       
     110                                        $result['mail'] = @ldap_get_values($this->ldap, $entry, 'mail'); 
     111                                        $result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid'); 
     112                                        $result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn'); 
     113 
     114                                        foreach ( $result as $key => $value ) 
     115                                                $result_user[$i][$key] = $value[0]; 
     116 
     117                                        $ou = explode('dc=', $entry1[$i]['dn']); 
     118                                        $ou = explode("ou=",$ou[0]); 
     119                                        $ou = array_pop($ou); 
     120                                        $result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1)); 
     121 
     122                                        $result_user[$i]['photo'] = 0; 
     123 
     124                                        $photo = @ldap_get_values_len($this->ldap, $entry, 'jpegphoto'); 
     125 
     126                                        if ( $photo ) 
     127                                        { 
     128                                                $result_user[$i]['photo'] = 1; 
     129                                                $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0]; 
     130                                        } 
     131 
     132                                        $i++; 
     133                                }                                
     134                                $entry = ldap_next_entry($this->ldap,$entry);    
     135                        } 
     136                         
     137                        $return  = "<uids>"; 
     138                        $return .= "<".$result_user[0]['dn']."><data>"; 
     139                        $return .= "<cn>".$result_user[0]['cn']."</cn>"; 
     140                        $return .= "<mail>".$result_user[0]['mail']."</mail>"; 
     141                        $return .= "<uid>".$result_user[0]['uid']."</uid>"; 
     142                        $return .= "<photo>".$result_user[0]['photo']."</photo>";                                                                        
     143                        $return .= "</data></".$result_user[0]['dn'].">";                        
     144                        $return .= "</uids>"; 
     145 
     146                        return $return;          
     147                } 
     148                 
     149                return '<empty/>'; 
     150        } 
     151 
    55152        public final function list_users_ldap($search, $uidnumber) 
    56153        { 
  • trunk/jabberit_messenger/inc/controller.xml

    r519 r551  
    3030                </js> 
    3131                <php path="/var/www/expresso/jabberit_messenger/inc" suffix=".class.php"> 
     32                        <item ref="contacts_im" alias="getParticipantsExternal" class="contacts_im" method="getParticipantsExternal" prefix="class." suffix=".inc.php"/> 
    3233                        <item ref="contacts_im" alias="list_contacts" class="contacts_im" method="list_contacts" prefix="class." suffix=".inc.php"/> 
    3334                        <item ref="db_im" alias="getPreferences" class="db_im" method="getPreferences" prefix="class." suffix=".inc.php"/> 
     
    3637                        <item ref="db_im" alias="removeAttributesLdap" class="db_im" method="removeAttributesLdap" prefix="class." suffix=".inc.php"/>                   
    3738                        <item ref="ldap_im" alias="list_organizations_ldap" class="ldap_im" method="list_organizations_ldap" prefix="class." suffix=".inc.php"/> 
     39                        <item ref="ldap_im" alias="list_participants_externals" class="ldap_im" method="list_participants_externals" prefix="class." suffix=".inc.php"/> 
    3840                        <item ref="ldap_im" alias="photo_ldap" class="ldap_im" method="photo_ldap" prefix="class." suffix=".inc.php"/> 
    3941                        <item ref="ujabber" alias="AddNewContact" class="ujabber" method="AddNewContact" prefix="class." suffix=".inc.php"/> 
  • trunk/jabberit_messenger/inc/getphoto.php

    r494 r551  
    1010  *  option) any later version.                                               * 
    1111  \***************************************************************************/ 
     12 
     13function ldap_rebind($ldap_connection, $ldap_url){ 
     14        include('conf_Ldap_Photos.php'); 
     15        $handle   = unserialize(base64_decode($CONF_SERVER)); 
     16        @ldap_bind($ldap_connection, $handle['dn'],$handle['passwd']); 
     17} 
    1218 
    1319class ldapPhoto 
     
    2834        { 
    2935                require_once('conf_Ldap_Photos.php'); 
    30                 $this->handle   = unserialize(base64_decode($CONF_SERVER)); 
    31                  
    32                 $this->host             = $this->handle['host']; 
    33                 $this->context  = $this->handle['context']; 
    34                 $this->dn               = $this->handle['dn']; 
    35                 $this->passwd   = $this->handle['passwd']; 
    36                  
    37                 $this->refer    = false; 
     36                $handle   = unserialize(base64_decode($CONF_SERVER)); 
     37 
     38                $this->host             = $handle['host']; 
     39                $this->context  = $handle['context']; 
     40                $this->dn               = $handle['dn']; 
     41                $this->passwd   = $handle['passwd']; 
     42                 
     43                $this->refer    = true; 
    3844                $this->version3 = true; 
    3945        } 
    4046 
    41         private final function ldap_rebind($ldap_connection, $ldap_url) 
    42         { 
    43                 @ldap_bind($ldap_connection, $this->user_referral, $this->password_referral); 
    44         } 
    4547 
    4648        private final function ldapConnect() 
     
    5759                        return False; 
    5860                } 
     61 
    5962                if( $this->version3 ) 
    6063                { 
     
    6366                } 
    6467                ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer); 
     68 
    6569                // verifica refer 
    6670                if( $this->refer ) 
    6771                { 
    68                         $this->user_referral = $this->dn; 
    69                         $this->password_referral = $this->passwd; 
    70                         @ldap_set_rebind_proc($this->conn, $this->ldap_rebind); 
     72                        @ldap_set_rebind_proc($this->conn, ldap_rebind); 
    7173                } 
    7274                 
     
    7678                        return False; 
    7779                } 
     80 
    7881                // bind as anonymous 
    7982                if(!$this->dn && !$this->passwd && !@ldap_bind($this->conn)) 
     
    8487        } 
    8588         
     89        public final function getNameOrganization($pUid, $pCharset) 
     90        { 
     91                $this->ldapConnect(); 
     92                 
     93                if( $this->conn ) 
     94                { 
     95                        $filter = "(&(phpgwaccounttype=u)(uid=".$pUid.")(!(phpgwaccountvisible=-1)))"; 
     96                        $justthese = array("uid","cn","dn"); 
     97                        $search = ldap_search($this->conn,$this->context,$filter,$justthese); 
     98                        $entry = ldap_get_entries($this->conn,$search); 
     99                        $cn = $entry[0]['cn'][0]; 
     100                        $ou = explode("dc=", $entry[0]['dn']); 
     101                        $ou = explode("ou=",$ou[0]); 
     102                        $ou = array_pop($ou); 
     103                        $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
     104 
     105                        $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     106 
     107                        if( $pCharset === "1" ) 
     108                                return $return; 
     109                        else 
     110                                return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); 
     111 
     112                        $return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado");                        
     113 
     114                        if( $pCharset === 1 ) 
     115                                return $return; 
     116                        else 
     117                                return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); 
     118                } 
     119        } 
     120         
    86121        public final function getPhotoLdap($uid) 
    87122        { 
     
    89124                if( $this->conn ) 
    90125                { 
    91                         $filter = "(&(phpgwaccounttype=u)(uid=".$uid."))"; 
    92                         $justthese = array("uid","phpgwAccountVisible","jpegPhoto"); 
     126                        $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     127                        $justthese = array("uid","jpegPhoto"); 
    93128                        $search = ldap_search($this->conn,$this->context,$filter,$justthese); 
    94129                        $entry1 = ldap_get_entries($this->conn,$search); 
    95130                        $entry = ldap_first_entry( $this->conn, $search ); 
    96  
    97131                        if( $entry1['count'] > 0 ) 
    98132                        { 
     
    100134                                $photo = ""; 
    101135                                $return_photo = ""; 
    102          
    103                                  
    104                                 if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' ) 
    105                                 { 
    106                                         $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); 
    107          
    108                                         if ( $photo ) 
    109                                                 $return_photo = $photo[0]; 
    110                                 }                                
     136                                $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); 
     137                                if ($photo) 
     138                                        $return_photo = $photo[0];                                                               
    111139                                return $return_photo; 
    112140                        } 
     
    172200} 
    173201 
     202if(trim($_POST['jid']) != "") 
     203{ 
     204        $jid = trim($_POST['jid']); 
     205        if( strpos($jid,"@")) 
     206                $jid = substr($jid, 0, strpos($jid,"@")); 
     207        $charset = trim($_POST['charset']); 
     208        $a = new ldapPhoto(); 
     209         
     210        printf("%s",$a->getNameOrganization($jid, $charset)); 
     211} 
    174212?> 
  • trunk/jabberit_messenger/inc/jabberit_acl.inc.php

    r494 r551  
    3131        { 
    3232 
     33                $ldapManager = CreateObject('contactcenter.bo_ldap_manager'); 
     34                $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager'] = $ldapManager->srcs[1]; 
     35                 
    3336                $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 
    3437                $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 
  • trunk/jabberit_messenger/inc/jabberit_sessions.inc.php

    r526 r551  
    1616        $_SESSION['phpgw_info']['jabberit_messenger']['passwd']         = $GLOBALS['phpgw_info']['user']['passwd']; 
    1717                $_SESSION['phpgw_info']['jabberit_messenger']['mail']           = $GLOBALS['phpgw_info']['user']['email']; 
     18                $_SESSION['phpgw_info']['jabberit_messenger']['fullname']       = $GLOBALS['phpgw_info']['user']['fullname']; 
     19 
     20                //Server http or https  
     21                $_SESSION['phpgw_info']['jabberit_messenger']['use_https']      = $GLOBALS['phpgw_info']['server']['use_https']; 
    1822 
    1923                //Organization Ldap 
    2024                $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']     = $GLOBALS['phpgw_info']['user']['account_dn']; 
    21  
    2225 
    2326                //Ldap 
     
    4548                $_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit'] = $GLOBALS['phpgw_info']['server']['use_attribute_jabberit']; 
    4649                $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit'] = $GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit']; 
    47  
     50                $_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit'] = $GLOBALS['phpgw_info']['server']['use_external_participants_jabberit']; 
     51                 
    4852?> 
  • trunk/jabberit_messenger/inc/login.php

    r526 r551  
    1616        if(isset($_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'])) 
    1717    { 
     18                // Path Server 
    1819                $path = $_SESSION['phpgw_info']['jabberit_messenger']['webserver_url']; 
    1920                $SERVER_EXPRESSO = $_SERVER['HTTP_HOST'] . $path; 
     21         
     22                // Type Protocol http / https 
     23                $protocol = trim("http"); 
     24                if( $_SESSION['phpgw_info']['jabberit_messenger']['use_https'] === 2 ) 
     25                        $protocol = trim("https"); 
    2026                 
     27                // Uid user 
    2128                $uid = $_SESSION['phpgw_info']['jabberit_messenger']['user']; 
    2229                 
     
    2633                $organization_user = substr($organization_user, strpos($organization_user,"ou=") + 3 , strlen($organization_user)); 
    2734                $organization_user = substr($organization_user, 0, strpos($organization_user, ",")); 
     35                 
     36                // FirstName 
     37                $CnName = explode(" ",$_SESSION['phpgw_info']['jabberit_messenger']['fullname']); 
    2838                 
    2939                if(is_array($organization)) 
     
    6878                $template->set_var("value_userproxy",$_SESSION['phpgw_info']['jabberit_messenger']['use_proxy_java']); 
    6979                $template->set_var("value_expresso",$SERVER_EXPRESSO); 
     80                $template->set_var("value_use_https", $protocol); 
    7081                $template->set_var("value_company", $_SESSION['phpgw_info']['jabberit_messenger']['name_company']); 
     82                $template->set_var("value_cnname",$CnName[0]); 
    7183                $template->set_file(Array('jabberit_messenger' => 'jabberIM.tpl')); 
    7284                $template->set_block('jabberit_messenger','index'); 
Note: See TracChangeset for help on using the changeset viewer.