Ignore:
Timestamp:
06/04/09 10:30:18 (15 years ago)
Author:
alexandrecorreia
Message:

Ticket #505 - Arquivos modificados para a administração de hosts virtuais no servidor Jabber.

Location:
trunk/jabberit_messenger/inc
Files:
1 deleted
11 edited
2 moved

Legend:

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

    r895 r946  
    2828                $this->db = new db_im(); 
    2929 
    30                 $ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 
    31                 $ou_User = substr($this->ou_User,strpos($this->ou_User, "ou=")); 
    32                 $ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc="))); 
    33  
    3430                // (OU) User 
    3531                $this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 
     
    3935                // Hosts Jabber 
    4036                $this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); 
    41                 $this->hostsJabber =  explode(";", $this->hostsJabber); 
    4237                 
    4338                // Server Name Jabber 
    4439                $this->serverJabber = $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']; 
    45         } 
    46  
    47         public final function getParticipantsExternal() 
    48         {                
    49                 $Participants = (trim($_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']) && 
    50                                                         $_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit']); 
    51  
    52                 if( !$this->groupsLocked() && $Participants )            
    53                         return "true"; 
    54                 else 
    55                         return "false";          
    5640        } 
    5741 
     
    7963        public final function list_contacts($param) 
    8064        { 
    81                 $users  = $this->users_auth_im($param['name']); 
    82                 $order  = array(); 
     65                $order          = array(); 
     66                $ou_User        = substr($this->ou_User, (strpos($this->ou_User,"=")+1)); 
     67                $return         = '<empty/>'; 
     68                $users          = $this->users_auth_im($param['name']); 
    8369                 
    8470                if (!is_array($users) && trim($users) === 'Many Results') 
    8571                        return "<error>Many Results</error>"; 
    8672 
     73                foreach($this->hostsJabber as $conf ) 
     74                        if(array_search("*", $conf)) 
     75                                $hostDefault = $conf['jabberName']; 
     76                         
    8777                if( is_array($users) ) 
    8878                {        
    89                         if( is_array($this->hostsJabber) ) 
    90                         { 
    91                                 for( $i = 0 ; $i < count($users); $i++ ) 
    92                                 { 
    93                                         foreach($this->hostsJabber as $values) 
     79                        for($i = 0; $i < count($users); $i++)                            
     80                        { 
     81                                if( is_array($this->hostsJabber) ) 
     82                                { 
     83                                        foreach($this->hostsJabber as $itens) 
    9484                                        { 
    95                                                 $itens = explode(":", $values); 
    96                                                 if( $users[$i]['dn'] == $itens[0] ) 
    97                                                         $users[$i]['jid'] = $users[$i]['jid']."@".$itens[1]; 
     85                                                if( $itens['org'] === $users[$i]['ou']  ) 
     86                                                { 
     87                                                        if( strpos($users[$i]['jid'], "@") === false ) 
     88                                                                $users[$i]['jid'] = $users[$i]['jid']."@".$itens['jabberName']; 
     89                                                } 
     90                                                else 
     91                                                { 
     92                                                        if( $users[$i]['ou'] === $ou_User ) 
     93                                                        { 
     94                                                                if( strpos($users[$i]['jid'], "@") === false ) 
     95                                                                        $users[$i]['jid'] = $users[$i]['jid']."@".$this->serverJabber; 
     96                                                        } 
     97                                                        else 
     98                                                        { 
     99                                                                if( strpos($users[$i]['jid'], "@") === false ) 
     100                                                                        $users[$i]['jid'] = $users[$i]['jid']."@".$hostDefault; 
     101                                                        } 
     102                                                } 
    98103                                        } 
    99104                                } 
    100105                        } 
    101                          
     106 
    102107                        foreach($users as $tmp) 
    103108                        { 
    104                                 if ( !array_key_exists($tmp['dn'], $order) ) 
    105                                         $order[$tmp['dn']] = array(); 
    106  
    107                                 if( (strpos($tmp['jid'], "@" )) === false ) 
     109                                if ( !array_key_exists($tmp['ou'], $order) ) 
     110                                        $order[$tmp['ou']] = array(); 
     111 
     112                                if( strpos($tmp['jid'], "@") === false) 
    108113                                        $tmp['jid'] = $tmp['jid']."@".$this->serverJabber; 
    109114 
    110                                 $_SESSION['debug'][] = $order[$tmp['dn']][] = '<data><cn>' . $tmp['cn'] . '</cn><mail>' . $tmp['mail'] .'</mail><uid>' . $tmp['uid'] . '</uid><jid>' . $tmp['jid'] . '</jid><photo>' . $tmp['photo'] . '</photo></data>'; 
     115                                $order[$tmp['ou']][] = '<data><ou>'.$tmp['ou'].'</ou><cn>'.$tmp['cn'].'</cn><mail>'.$tmp['mail'].'</mail><uid>'.$tmp['uid'].'</uid><jid>'.$tmp['jid'].'</jid><photo>'.$tmp['photo'].'</photo></data>'; 
    111116                        } 
    112117                         
     
    118123                        $return .= '</uids>'; 
    119124                } 
    120                 else 
    121                         $return = '<empty/>'; 
    122125                 
    123126                return $return; 
     
    128131        $array_uids = $this->db->get_accounts_acl(); 
    129132        $count = count($array_uids); 
    130         $uids_members = array(); 
     133        $members = array();; 
    131134        $result = array(); 
    132135         
    133         for($i = 0; $i < $count ;$i+=50) 
     136        for( $i = 0; $i < $count ; $i+=50 ) 
    134137        {    
    135138            $partial_uids = array_slice($array_uids,$i,50); 
     
    150153                    $orgs = array_unique($orgs); 
    151154 
    152                                 foreach( $orgs as $tmp ) 
    153                                         $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $tmp); 
     155                                foreach( $orgs as $orgB ) 
     156                                        $result[] = $this->ldap->getUsersLdap("cn=*".$pName."*", $filter_uid, $orgB ); 
    154157                        } 
    155158                        else 
    156                     $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid); 
     159                    $result[] = $this->ldap->getUsersLdap("cn=*".$pName."*", $filter_uid, "" ); 
    157160        } 
    158161 
    159162        if ( is_array($result) ) 
    160163        { 
    161                 for($i = 0; $i < count($result); $i++) 
    162                         if(is_array($result[$i])) 
    163                                 $uids_members = array_merge($uids_members,$result[$i]); 
     164                for( $i = 0; $i < count($result); $i++ ) 
     165                        if( is_array($result[$i]) ) 
     166                                $members = array_merge($members,$result[$i]); 
    164167        } 
    165                  
    166         if( count($uids_members) > 50 ) 
     168              
     169        if( count($members) > 150) 
    167170        { 
    168                 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);           
    169                 return 'Many Results'; 
     171                $ou = substr( $this->ou_User, strpos($this->ou_User, "=") + 1 ); 
     172                        for($i = 0 ; $i < count($members); $i++ ) 
     173                        { 
     174                                if( $ou == $members[$i]['ou'] ) 
     175                                        $uids_org[] = $members[$i]; 
     176                                else 
     177                                        if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'])) 
     178                                                unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$members[$i]['ou']]); 
     179                        } 
     180                        return $uids_org; 
    170181        }             
    171          
    172         if( count($uids_members) > 0 ) 
    173             return $uids_members; 
    174         else 
    175             return 0;   
     182                return $members;         
    176183        } 
    177184         
     
    191198            $filter_gid = "(gidnumber=". $filter_gid. ")"; 
    192199                 
    193                 $result = $this->ldap->list_groups_memberUid($filter_gid); 
     200                $result = $this->ldap->getGroupsMemberUid($filter_gid); 
    194201 
    195202                if( $result && is_array($result) ) 
     
    274281        } 
    275282} 
     283 
    276284?> 
  • trunk/jabberit_messenger/inc/class.db_im.inc.php

    r896 r946  
    1414define('PHPGW_API_INC','../phpgwapi/inc'); 
    1515require_once(PHPGW_API_INC . '/class.db.inc.php'); 
     16require_once "class.fileDefine.inc.php"; 
    1617         
    1718class db_im 
     
    2526        private $db_type; 
    2627        private $user_id; 
     28        private $fileD; 
    2729         
    2830        public final function __construct() 
    2931        { 
     32                $this->fileD = new fileDefine(); 
    3033                $this->db_name = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']; 
    3134                $this->db_host = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']; 
     
    5154        }        
    5255 
     56        public final function editHostJabber($pItem) 
     57        { 
     58                $hostsJabber = unserialize($this->getHostsJabber()); 
     59                $findHosts      = explode(":", $pItem['item']); 
     60                $return = "";    
     61                 
     62                for( $i = 0 ; $i < count($hostsJabber); $i++ ) 
     63                        if( $hostsJabber[$i]['org'] == $findHosts[0] && $hostsJabber[$i]['jabberName'] == $findHosts[1] ) 
     64                        { 
     65                                $return = "org:" . $hostsJabber[$i]['org'] . ";" . 
     66                                                  "jabberName:" . $hostsJabber[$i]['jabberName'] . ";" .                                                          
     67                                                  "serverLdap:" . $hostsJabber[$i]['serverLdap'] . ";" . 
     68                                                  "contextLdap:" . $hostsJabber[$i]['contextLdap'] . ";" . 
     69                                                  "user:" . $hostsJabber[$i]['user'] . ";" . 
     70                                                  "password:" . $hostsJabber[$i]['password'] ;                                                                                                                                                                                             
     71                        } 
     72 
     73                return trim($return); 
     74        } 
     75         
    5376        public final function getApplicationsEnabled() 
    5477        { 
     
    338361        public final function setHostJabber($pParam) 
    339362        { 
    340                 $organization   = $pParam['organization']; 
    341                 $hostJabber             = $pParam['hostJabber']; 
    342          
     363                $confHostsJabber =  array(); 
     364 
     365                foreach($pParam as $key => $itens) 
     366                        $confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens; 
     367 
    343368                if( $this->db ) 
    344369                { 
    345370                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; 
    346371                         
    347                         if($this->db->query($query)) 
    348                         { 
    349                          
    350                                 if ( $this->db->query($query) ) 
    351                                 {        
    352                                         while($this->db->next_record()) 
    353                                                 $result[] = $this->db->row(); 
    354                                 } 
    355                                  
    356                                 if( count($result) == 0 ) 
    357                                 { 
    358                                         $confHostJabber = strtoupper($organization).":".$hostJabber; 
    359                                         $return = "<return><confServer ou='".strtoupper($organization)."' serverName='".$hostJabber."'>".$confHostJabber."</confServer></return>"; 
    360                                         $query = "INSERT INTO phpgw_config(config_app,config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($confHostJabber)."')"; 
    361                                         $_SESSION['debug']['gravar'] = $confHostJabber; 
    362                                         $this->db->query($query);                                        
    363                                 } 
     372                        if( $this->db->query($query) ) 
     373                        { 
     374                                while($this->db->next_record()) 
     375                                        $result[] = $this->db->row();                            
     376                        } 
     377                         
     378                        if( count($result) == 0 ) 
     379                        { 
     380                                $return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>";                           
     381                                $hostsJabber[0] = $confHostsJabber; 
     382                                 
     383                                $this->fileD->ldapExternal($hostsJabber); 
     384                                  
     385                                $query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')"; 
     386                                $this->db->query($query);                                
     387                        } 
     388                        else 
     389                        { 
     390                                $resultQuery = unserialize($result[0]['config_value']);  
     391                                $foundOrg = false; 
     392                                 
     393                                foreach($resultQuery as $key => $itens) 
     394                                { 
     395                                        $foundString = array_search($confHostsJabber['org'], $itens); 
     396                                        if( $foundString ) 
     397                                        { 
     398                                                $foundOrg = $foundString; 
     399                                                $ky = $key; 
     400                                        } 
     401                                }        
     402 
     403                                if( ! $foundOrg ) 
     404                                        $resultQuery[] = $confHostsJabber;       
    364405                                else 
    365                                 { 
    366                                         $confHostJabber = unserialize($result[0]['config_value']); 
    367                                         $OrgHosts = explode(";", $confHostJabber); 
    368                                         $stringSearch = strtoupper($organization).":".$hostJabber; 
    369                                         $FoundString = array_search($stringSearch, $OrgHosts); 
    370  
    371                                         if( $FoundString === false) 
    372                                                 $confHostJabber .= ";" . $stringSearch; 
    373                                  
    374                                         $items = explode(";", $confHostJabber); 
    375                                         natcasesort($items); 
    376                                                                                          
    377                                         $return = "<return>"; 
    378                                         foreach($items as $tmp) 
    379                                         { 
    380                                                 $aux = explode(":",$tmp); 
    381                                                 $return .= "<confServer ou='".$aux[0]."' serverName='".$aux[1]."'>".$tmp."</confServer>"; 
    382                                         }                                        
    383                                         $return .= "</return>"; 
    384  
    385                                         $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostJabber)."' WHERE config_name = 'map_org_realm_jabberit';"; 
    386                                         $this->db->query($query); 
    387                                 } 
    388                                  
    389                                 return $return; 
    390                         } 
    391                 } 
    392  
     406                                        $resultQuery[$ky] = $confHostsJabber; 
     407 
     408                                $return = "<return>"; 
     409                                 
     410                                foreach( $resultQuery as $itens ) 
     411                                        $return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>"; 
     412                                 
     413                                $return .= "</return>"; 
     414                                 
     415                                $this->fileD->ldapExternal($resultQuery); 
     416                                 
     417                                $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';"; 
     418                                $this->db->query($query); 
     419                        } 
     420                        return $return; 
     421                }        
    393422                return false; 
    394423        } 
     
    466495        } 
    467496         
    468         public final function setUseParticipantsExternal($pFlag) 
    469         { 
    470                 $flag = $pFlag['value']; 
    471                 $return = ""; 
    472                  
    473                 if( $this->db ) 
    474                 { 
    475                         $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'use_external_participants_jabberit';"; 
    476  
    477                         if ( $this->db->query($query) ) 
    478                         {        
    479                                 while($this->db->next_record()) 
    480                                         $result[] = $this->db->row(); 
    481                         } 
    482  
    483                         if(count($result) == 0) 
    484                         { 
    485                                 $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','use_external_participants_jabberit','".$flag."')"; 
    486                                 $this->db->query($query); 
    487                                 return true; 
    488                         } 
    489                         else 
    490                         { 
    491                                 $query = "UPDATE phpgw_config SET config_value = '".$flag."' WHERE config_app = 'phpgwapi' AND config_name = 'use_external_participants_jabberit'"; 
    492                                 $this->db->query($query); 
    493                                 return true; 
    494                         } 
    495                 } 
    496                 return false; 
    497         } 
    498          
    499         public final function setOrganization($pOrganization) 
    500         { 
    501                 $organization = $pOrganization['organization']; 
    502                 $orgConfiguration = ""; 
    503                  
    504                 if( $this->db ) 
    505                 { 
    506                         $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'conf_organization_jabberit'"; 
    507  
    508                         if ( $this->db->query($query) ) 
    509                         {        
    510                                 while($this->db->next_record()) 
    511                                         $result[] = $this->db->row(); 
    512                  
    513                                 if(count($result) > 0) 
    514                                         $orgConfiguration = $result[0]['config_value']; 
    515                         } 
    516  
    517                         if( trim($orgConfiguration) == "" ) 
    518                         { 
    519                                 $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','conf_organization_jabberit','".$organization."')"; 
    520                                 $this->db->query($query); 
    521                                  
    522                                 return "<return><ou attr='".$organization."'>".$organization."</ou></return>"; 
    523                         } 
    524                         else 
    525                         { 
    526                                 $orgAux = explode(",",$orgConfiguration); 
    527                                  
    528                                 foreach( $orgAux as $tmp ) 
    529                                 { 
    530                                         if(strtolower(trim($tmp)) === strtolower(trim($organization))) 
    531                                                 return false; 
    532                                 } 
    533  
    534                                 $value = $orgConfiguration . "," . $organization; 
    535                                 $query = "UPDATE phpgw_config SET config_value = '".$value."' WHERE config_app = 'phpgwapi' AND config_name = 'conf_organization_jabberit'"; 
    536                                 $this->db->query($query); 
    537  
    538                                 $return = explode(",",$value); 
    539                                 natcasesort($return); 
    540  
    541                                 $values = "<return>"; 
    542                                  
    543                                 foreach($return as $tmp) 
    544                                         $values .= "<ou attr='" . $tmp . "'>" . $tmp . "</ou>"; 
    545                                          
    546                                 $values .= "</return>"; 
    547                                  
    548                                 return $values;                  
    549                         } 
    550                 } 
    551                 return false;  
    552         } 
    553  
    554497        public final function removeAttributesLdap($pOrg) 
    555498        { 
     
    610553                                { 
    611554                                        $confHostsOrgs = unserialize($result[0]['config_value']); 
    612                                         $confHostsOrgs = explode(";", $confHostsOrgs);                                   
    613                                         $foundValue = array_search($pItem['item'], $confHostsOrgs);                                      
    614          
    615                                         if( $foundValue !== false ) 
    616                                                 array_splice($confHostsOrgs, $foundValue, 1); 
    617                                          
    618                                         if(count($confHostsOrgs) > 0 ) 
     555                                        $hosts = explode(":", $pItem['item']); 
     556                                        $key = ""; 
     557 
     558                                        if( count($confHostsOrgs) > 0 ) 
    619559                                        { 
    620                                                 foreach( $confHostsOrgs as $values ) 
    621                                                         $stringHostsOrgs .= $values . ";"; 
    622          
    623                                                 $stringHostsOrgs = substr($stringHostsOrgs, 0, strlen($stringHostsOrgs) -1 ); 
    624                                                 $query = "UPDATE phpgw_config SET config_value = '".serialize($stringHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';"; 
     560                                                for( $i = 0; $i < count($confHostsOrgs); $i++) 
     561                                                        if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1]) 
     562                                                                $key = $i;       
     563 
     564                                                array_splice($confHostsOrgs, $key, 1); 
     565                                 
     566                                                if(count($confHostsOrgs) > 0) 
     567                                                {                                        
     568                                                        $this->fileD->ldapExternal($confHostsOrgs); 
     569                                                        $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';"; 
     570                                                } 
     571                                                else 
     572                                                { 
     573                                                        $this->fileD->ldapExternal(""); 
     574                                                        $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; 
     575                                                } 
    625576                                        } 
    626577                                        else 
     578                                        {        
     579                                                $this->fileD->ldapExternal("");                                          
    627580                                                $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; 
    628                                          
     581                                        } 
     582 
    629583                                        if( $this->db->query($query) ) 
    630584                                                return "true"; 
     
    692646                return $return; 
    693647        } 
    694          
    695         public final function removeParticipantsExternal($pOrganization) 
    696         { 
    697                  
    698                 $organization = $pOrganization['participants'];  
    699                  
    700                 if( $this->db ) 
    701                 { 
    702                         $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'conf_organization_jabberit'"; 
    703                                  
    704                         if ( $this->db->query($query) ) 
    705                         {        
    706                                 while( $this->db->next_record() ) 
    707                                         $result[] = $this->db->row(); 
    708                  
    709                                 if( count($result) > 0 ) 
    710                                         $valueDB = $result[0]['config_value']; 
    711                         } 
    712  
    713                         $OrgDB = explode(",", $valueDB); 
    714                         $newValue = "";  
    715  
    716                         foreach($OrgDB as $tmp) 
    717                         { 
    718                                 if( strtolower(trim($tmp)) != strtolower(trim($organization))) 
    719                                         $newValue .= $tmp . ","; 
    720                         } 
    721                          
    722                         $newValue = substr($newValue, 0,(strlen($newValue) -1 )); 
    723                          
    724                         if( trim($newValue) != "") 
    725                                 $query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'conf_organization_jabberit'"; 
    726                         else 
    727                                 $query = "DELETE from phpgw_config where config_name = 'conf_organization_jabberit'"; 
    728                                  
    729                         if( $this->db->query($query)) 
    730                                 return true; 
    731                         else 
    732                                 return false; 
    733                 } 
    734                 return false;    
    735         } 
     648 
    736649} 
    737650?> 
  • trunk/jabberit_messenger/inc/class.fileDefine.inc.php

    r551 r946  
    1111  \***************************************************************************/ 
    1212 
    13 class FileDefine 
     13class fileDefine 
    1414{ 
     15        public final function ldapExternal($pConfLdap) 
     16        { 
     17                $file = "confLDAPExternal.php"; 
     18                $writeFile = "<?php $"."LDAP_EXTERNAL="."\"".base64_encode(serialize($pConfLdap))."\""." ?>"; 
     19                $this->writeFile($writeFile, $file); 
     20        } 
    1521 
    16         public final function getParams($pParam) 
     22        public final function ldapInternal($pParam) 
    1723        { 
    1824                $array_values = explode("\n", $pParam['val']);   
     25                $file = "confLDAPInternal.php"; 
    1926                $infoServer = array(); 
    20  
     27                 
    2128                foreach($array_values as $tmp ) 
    2229                { 
     
    2532                        switch(trim($nvalue[0])) 
    2633                        { 
     34                                case "JETTI_NAME_JABBERIT" : 
     35                                                $infoServer['jabberName'] = $nvalue[1];                          
     36                                                break; 
     37                                                 
    2738                                case "JETTI_SERVER_LDAP_JABBERIT" : 
    28                                                         $infoServer['host'] = $nvalue[1];                                                        
    29                                                         break;                   
     39                                                $infoServer['serverLdap'] = $nvalue[1];                                                  
     40                                                break;                   
    3041                         
    3142                                case "JETTI_CONTEXT_LDAP_JABBERIT" :     
    32                                                         $infoServer['context'] = $nvalue[1]; 
    33                                                         break; 
     43                                                $infoServer['contextLdap'] = $nvalue[1]; 
     44                                                break; 
    3445                         
    3546                                case "JETTI_USER_LDAP_JABBERIT" : 
    36                                                         $infoServer['dn'] = $nvalue[1]; 
    37                                                         break; 
     47                                                $infoServer['user'] = $nvalue[1]; 
     48                                                break; 
    3849                         
    3950                                case "JETTI_PASSWORD_LDAP_JABBERIT" : 
    40                                                         $infoServer['passwd'] = $nvalue[1];                              
    41                                                         break; 
     51                                                $infoServer['password'] = $nvalue[1];                            
     52                                                break; 
    4253                        } 
    4354                } 
    4455                 
    45                 $this->writeFile($infoServer); 
     56                $writeFile = "<?php $"."LDAP_INTERNAL="."\"".base64_encode(serialize($infoServer))."\""." ?>"; 
     57                $this->writeFile( $writeFile, $file ); 
    4658        } 
    4759 
    48         private final function writeFile($pContent) 
     60        private final function writeFile($pContent, $pfile) 
    4961    { 
    50          
    51                 $filename = dirname(__FILE__).'/conf_Ldap_Photos.php'; 
    52                 $caracter = "$"; 
    53                 $content = "<?php ".$caracter."CONF_SERVER="."\"" . base64_encode(serialize($pContent)) ."\""." ?>"; 
    54  
    55                 if (!$handle = fopen($filename, 'w')) 
    56                 { 
    57                         echo "Não foi possível abrir o arquivo : \n($filename)"; 
     62                $filename = dirname(__FILE__).'/'.$pfile; 
     63                $content = $pContent; 
     64                         
     65                if ( !$handle = fopen($filename, 'w') ) 
    5866                        exit; 
    59                 } 
    6067                 
    6168                if (fwrite($handle, $content) === FALSE) 
    62                 { 
    63                         echo "Não foi possível escrever no arquivo : \n($filename)"; 
    6469                        exit; 
    65                 } 
    66                  
    67                 echo "Arquivo : \n $filename \ncriado com sucesso !!"; 
     70 
    6871                fclose($handle); 
    6972    } 
  • trunk/jabberit_messenger/inc/class.ldap_im.inc.php

    r892 r946  
    1717class ldap_im 
    1818{ 
     19        private $attr_org; 
     20        private $common; 
     21        private $hostsJabber; 
    1922        private $ldap; 
    20         private $ldap_host; 
    2123        private $ldap_context; 
    2224        private $ldap_dn; 
     25        private $ldap_host; 
    2326        private $ldap_pass; 
    24         private $common; 
    25         private $jid; 
    2627        private $max_result; 
    27         private $ou_User; 
    2828         
    2929        public final function __construct() 
     30        { 
     31                // Attributes org ldap; 
     32                $this->attr_org = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']); 
     33                 
     34                // Hosts Jabber 
     35                $this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); 
     36                 
     37                // Result Ldap 
     38                $this->max_result = 30; 
     39        } 
     40 
     41        public final function __destruct() 
     42        { 
     43                if( $this->ldap ) 
     44                        ldap_close($this->ldap); 
     45        }        
     46 
     47        private final function ldapConn() 
     48        { 
     49                $this->common = new common();            
     50                 
     51                $GLOBALS['phpgw_info']['server']['ldap_version3'] = true; 
     52 
     53                $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_dn, $this->ldap_pass, false ); 
     54        } 
     55         
     56        private final function ldapRoot() 
    3057        { 
    3158                $this->ldap_host        = (isset($_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_host']; 
     
    3360                $this->ldap_dn          = (isset($_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 
    3461                $this->ldap_pass        = (isset($_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 
    35                 $this->jid                      = $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']; 
    36                 $this->max_result       = 50; 
    37         } 
    38  
    39         public final function __destruct() 
    40         { 
    41                 if( $this->ldap ) 
    42                         ldap_close($this->ldap); 
    43         }        
    44  
    45         private final function _connect_ldap() 
    46         { 
    47                 $this->common = new common(); 
    48                  
    49                 if( !$this->ldap ) 
    50                 { 
    51                         $GLOBALS['phpgw_info']['server']['ldap_version3'] = true; 
    52                         $this->ldap = $this->common->ldapConnect( $this->ldap_host,$this->ldap_dn,$this->ldap_pass, false ); 
    53                 } 
    54         } 
    55          
    56         private final function _ldapConnect($refer = false) 
    57         { 
    58                 function ldapRebindJabberit($ldap_connection, $ldap_url) 
    59                 { 
    60                         $acc = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc']; 
    61                         $pw = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw']; 
     62 
     63                $this->ldapConn(); 
     64        } 
     65 
     66        private final function ldapCatalog() 
     67        { 
     68                $version3 = true; 
     69                $refer  = true; 
     70 
     71                if(!function_exists('ldap_connect')) 
     72                        return false; 
     73                 
     74                if(!$conn = ldap_connect($this->ldap_host)) 
     75                        return false; 
     76 
     77                if( $version3 ) 
     78                        if( !ldap_set_option($conn,LDAP_OPT_PROTOCOL_VERSION,3) ) 
     79                                $version3 = false; 
     80 
     81                ldap_set_option($conn, LDAP_OPT_REFERRALS, $refer); 
     82 
     83                // Bind as Admin 
     84                if($this->ldap_dn && $this->ldap_pass && !ldap_bind($conn, $this->ldap_dn, $this->ldap_pass)) 
     85                        return false; 
     86                 
     87                // Bind as Anonymous 
     88                if(!$this->ldap_dn && !$this->ldap_pass && !@ldap_bind($conn)) 
     89                        return false; 
    6290                         
    63                         @ldap_bind($ldap_connection, $acc,$pw); 
    64                 } 
    65  
    66                 // Using ContactCenter configuration. 
    67                 $this->ldap_host        =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['host']; 
    68                 $this->ldap_context     =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['dn']; 
    69                 $this->ldap_dn          =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc']; 
    70                 $this->ldap_pass        =       $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw']; 
    71  
    72                 $this->ldap = ldap_connect($this->ldap_host); 
    73                 ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, 3); 
    74                 ldap_set_option($this->ldap, LDAP_OPT_REFERRALS, $refer); 
    75                  
    76                 if ($refer) 
    77                 { 
    78                         ldap_set_rebind_proc($this->ldap, ldapRebindJabberit); 
    79                 } 
    80                  
    81                 @ldap_bind($this->ldap,$this->ldap_dn,$this->ldap_pass); 
    82         } 
    83  
    84         public final function list_groups_memberUid($pGroup) 
    85         { 
    86                 $this->_ldapConnect(); 
     91                return $conn; 
     92        } 
     93 
     94        public final function getGroupsLdap($pOrg) 
     95        { 
     96                $this->ldapRoot(); 
     97 
     98                if( $this->ldap )        
     99                { 
     100                        $organization = 'ou=' . $pOrg['ou'] .",". $this->ldap_context; 
     101                        $filter = "(&(phpgwAccountType=g)(objectClass=posixGroup))"; 
     102                        $justthese = array("cn","gidNumber"); 
     103                        $search = ldap_list($this->ldap, $organization, $filter, $justthese); 
     104                        $entry = ldap_get_entries( $this->ldap, $search ); 
     105 
     106                        if( $entry ) 
     107                        {                                        
     108                                $result_groups = "<ldap>"; 
     109                                foreach($entry as $tmp) 
     110                                        if( $tmp['gidnumber'][0] != "" ) 
     111                                                $result_groups .= "<org><cn>".$tmp['cn'][0]."</cn><gid>".$tmp['gidnumber'][0]."</gid></org>"; 
     112                                 
     113                                $result_groups .= "</ldap>";                                             
     114                        } 
     115                } 
     116 
     117                return $result_groups; 
     118        } 
     119 
     120        public final function getGroupsMemberUid($pGroup) 
     121        { 
     122                $this->ldapRoot(); 
    87123                 
    88124                if( $this->ldap ) 
     
    100136        } 
    101137 
    102         public final function list_participants_externals($pSearch) 
    103         { 
    104                 $this->_ldapConnect(true); 
    105                  
    106                 $mail = $pSearch['mail']; 
    107                  
    108                 if( $this->ldap ) 
    109                 { 
    110                         $filter = "(&(phpgwaccounttype=u)(mail=".$mail."))"; 
    111                         $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto"); 
    112                         $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1); 
    113                         $entry1 = ldap_get_entries($this->ldap,$search); 
    114                         $entry = ldap_first_entry( $this->ldap, $search ); 
    115                 }                        
    116                  
    117                 if( $entry1['count'] > 0 ) 
    118                 { 
    119                         $i = 0; 
    120                         $result_user = array(); 
    121                         $result = array(); 
    122  
    123                         while($entry) 
    124                         { 
    125                          
    126                                 if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' ) 
    127                                 { 
    128                                         $result['uidnumber'] = @ldap_get_values($this->ldap, $entry, 'uidnumber');                       
    129                                         $result['mail'] = @ldap_get_values($this->ldap, $entry, 'mail'); 
    130                                         $result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid'); 
    131                                         $result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn'); 
    132  
    133                                         foreach ( $result as $key => $value ) 
    134                                                 $result_user[$i][$key] = $value[0]; 
    135  
    136                                         $ou = explode('dc=', $entry1[$i]['dn']); 
    137                                         $ou = explode("ou=",$ou[0]); 
    138                                         $ou = array_pop($ou); 
    139                                         $result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1)); 
    140  
    141                                         $result_user[$i]['photo'] = 0; 
    142  
    143                                         $photo = @ldap_get_values_len($this->ldap, $entry, 'jpegphoto'); 
    144  
    145                                         if ( $photo ) 
    146                                         { 
    147                                                 $result_user[$i]['photo'] = 1; 
    148                                                 $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0]; 
    149                                         } 
    150  
    151                                         $i++; 
    152                                 }                                
    153                                 $entry = ldap_next_entry($this->ldap,$entry);    
    154                         } 
    155                          
    156                         $return  = "<uids>"; 
    157                         $return .= "<".$result_user[0]['dn']."><data>"; 
    158                         $return .= "<cn>".$result_user[0]['cn']."</cn>"; 
    159                         $return .= "<mail>".$result_user[0]['mail']."</mail>"; 
    160                         $return .= "<uid>".$result_user[0]['uid']."</uid>"; 
    161                         $return .= "<photo>".$result_user[0]['photo']."</photo>";                                                                        
    162                         $return .= "</data></".$result_user[0]['dn'].">";                        
    163                         $return .= "</uids>"; 
    164  
    165                         return $return;          
    166                 } 
    167                  
    168                 return '<empty/>'; 
    169         } 
    170  
    171         public final function list_users_ldap( $search, $uidnumber, $ous = false ) 
    172         { 
    173                 $this->_connect_ldap(); 
    174          
    175                 if( $this->ldap ) 
    176                 { 
    177                         $filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))"; 
    178                         $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto"); 
    179                         // SERPRO 
    180                         //$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto"); 
    181          
    182                         if( $ous != false ) 
    183                                 $search = ldap_search($this->ldap,$ous.",".$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1); 
    184                         else 
    185                                 $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1); 
    186  
    187                         $entry1 = ldap_get_entries($this->ldap,$search); 
    188                         $entry  = ldap_first_entry($this->ldap,$search); 
    189                 } 
    190  
    191                 if( $entry1['count'] > 0 ) 
    192                 { 
    193                         if( count($entry1) < $this->max_result ) 
    194                         { 
    195                                 $i = 0; 
    196                                 $result_user = array(); 
    197                                 $result = array(); 
    198  
    199                                 while($entry) 
    200                                 { 
    201                                  
    202                                         if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' ) 
    203                                         { 
    204                                                 $result['uidnumber'] = @ldap_get_values($this->ldap, $entry, 'uidnumber');                       
    205                                                 $result['mail'] = @ldap_get_values($this->ldap, $entry, 'mail'); 
    206                                                 $result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid'); 
    207                                                 $result['jid'] = @ldap_get_values($this->ldap, $entry, 'uid'); 
    208                                                 $result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn'); 
    209                                                 // SERPRO 
    210                                                 //$result['description'] = @ldap_get_values($this->ldap, $entry, 'description'); 
    211  
    212                                                 foreach ( $result as $key => $value ) 
    213                                                         $result_user[$i][$key] = $value[0]; 
    214  
    215                                                 $ou = explode('dc=', $entry1[$i]['dn']); 
    216                                                 $ou = explode("ou=",$ou[0]); 
    217                                                 $ou = array_pop($ou); 
    218                                                 $result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1)); 
    219  
    220                                                 $result_user[$i]['photo'] = 0; 
    221                                                 $photo = @ldap_get_values_len($this->ldap, $entry, 'jpegphoto'); 
    222                                                 if ( $photo ) 
    223                                                 { 
    224                                                         $result_user[$i]['photo'] = 1; 
    225                                                         $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0]; 
    226                                                 } 
    227                                                  
    228                                                 $organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']); 
    229  
    230                                                 if(is_array($organization)) 
    231                                                 { 
    232                                                         foreach($organization as $attr) 
    233                                                         { 
    234                                                                 $tmp = explode(";",$attr); 
    235                                                                 if( strtolower(trim($tmp[0])) == strtolower(trim($result_user[$i]['dn'])) ) 
    236                                                                 { 
    237                                                                         switch(strtolower(trim($tmp[1]))) 
    238                                                                         { 
    239                                                                                 case "mail" : 
    240                                                                                                 $uid = $result_user[$i]['mail']; 
    241                                                                                                 $uid = substr($uid,0,strpos($uid,"@"));  
    242                                                                                                 $result_user[$i]['uid'] = $uid; 
    243                                                                                                 break; 
    244          
    245                                                                                 case "description" : 
    246                                                                                                 // SERPRO 
    247                                                                                                 // parte antes do arroba;  
    248                                                                                                 $result_user[$i]['uid'] = $result_user[$i]['description'];                                                                               
    249                                                                                                 break; 
    250                                                                         } 
    251                                                                 } 
    252                                                         } 
    253                                                 } 
    254                                                  
    255                                                 $i++; 
    256                                         }                                
    257                                         $entry = ldap_next_entry($this->ldap,$entry);    
    258                                 } 
    259                                  
    260                                 return $result_user; 
    261                         } 
    262                         else 
    263                         { 
    264                                 return "Many Results"; 
    265                         } 
    266                 } 
    267                 return 0; 
    268         } 
    269          
    270         public final function listOrganizationsLdap() 
    271         { 
    272  
    273                 $this->_connect_ldap(); 
     138        public final function getOrganizationsLdap() 
     139        { 
     140                $this->ldapRoot(); 
    274141         
    275142                if( $this->ldap ) 
     
    287154                return $result_org; 
    288155        } 
    289          
    290         public final function getGroupsLdap($pOrg) 
    291         { 
    292                 $this->_ldapConnect(true); 
    293                 $organization = 'ou=' . $pOrg['ou'] .",". $this->ldap_context; 
    294                  
    295                 if( $this->ldap )        
    296                 { 
    297                         $filter = "(&(phpgwAccountType=g)(objectClass=posixGroup))"; 
    298                         $justthese = array("cn","gidNumber"); 
    299                         $search = ldap_list($this->ldap, $organization, $filter, $justthese); 
     156 
     157        public final function getUsersLdap( $search, $uidnumber, $ous = false) 
     158        { 
     159                // Ldap Principal 
     160                $ldapRoot = $this->getUsersLdapRoot($search, $uidnumber, $ous); 
     161                 
     162                if( !$ous ) 
     163                { 
     164                        // Ldap Outros 
     165                        $ldapCatalog = $this->getUsersLdapCatalog( $search ); 
     166                        $ldapRoot = array_merge( $ldapRoot, $ldapCatalog );              
     167                } 
     168                 
     169                return $ldapRoot; 
     170        } 
     171 
     172        private final function getUsersLdapCatalog( $search ) 
     173        { 
     174                $confHosts      = $this->hostsJabber; 
     175                $result = array(); 
     176                $return = array(); 
     177                $conn   = "";            
     178 
     179                for($i = 0; $i < count($confHosts); $i++ ) 
     180                { 
     181                        $this->ldap_host        = $confHosts[$i]['serverLdap']; 
     182                        $this->ldap_context = $confHosts[$i]['contextLdap']; 
     183                        $this->ldap_dn          = $confHosts[$i]['user']; 
     184                        $this->ldap_pass        = $confHosts[$i]['password']; 
     185 
     186                        $conn = $this->ldapCatalog(); 
     187 
     188                        if( $conn ) 
     189                        { 
     190                                $filter = "(&(phpgwaccounttype=u)(".$search ."))"; 
     191                                $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                                
     192                                $search1 = @ldap_search($conn, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); 
     193                                $entry1 = @ldap_get_entries( $conn, $search1 ); 
     194 
     195                                $result = $this->resultArray($entry1, $conn ); 
     196 
     197                                if( count($return) > 0 ) 
     198                                $return = array_merge($return, $result); 
     199                                else 
     200                                        $return = $result;                               
     201 
     202                        unset($result);  
     203 
     204                        ldap_close($conn); 
     205                        } 
     206                } 
     207                 
     208                return $return; 
     209        } 
     210 
     211        private final function getUsersLdapRoot( $search, $uidnumber, $ous = false ) 
     212        { 
     213                $this->ldapRoot(); 
     214                $result = array(); 
     215 
     216                if( $this->ldap ) 
     217                { 
     218                        $searchRoot = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ; 
     219                        $filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))"; 
     220                        $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                                
     221                        $search = ldap_search($this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1); 
    300222                        $entry = ldap_get_entries( $this->ldap, $search ); 
    301223 
    302                         if( $entry ) 
    303                         {                                        
    304                                 $result_groups = "<ldap>"; 
    305                                 foreach($entry as $tmp) 
    306                                         if( $tmp['gidnumber'][0] != "" ) 
    307                                                 $result_groups .= "<org><cn>".$tmp['cn'][0]."</cn><gid>".$tmp['gidnumber'][0]."</gid></org>"; 
    308                                  
    309                                 $result_groups .= "</ldap>";                                             
    310                         } 
    311                 } 
    312  
    313                 return $result_groups; 
     224                        $result = $this->resultArray($entry, $this->ldap ); 
     225                }                
     226 
     227                return $result; 
     228        } 
     229         
     230        private final function resultArray($pArray, $pConn) 
     231        { 
     232                $entry = $pArray; 
     233                $result = array(); 
     234 
     235                $j = 0; 
     236                for($i = 0 ; $i < $entry['count']; $i++) 
     237                { 
     238                        if ( $entry[$i]['phpgwaccountvisible'][0] != '-1' ) 
     239                        { 
     240                                $result[$j]['uidnumber'] = $entry[$i]['uidnumber'][0];                   
     241                                $result[$j]['mail']     =  $entry[$i]['mail'][0]; 
     242                                $result[$j]['uid']      =  $entry[$i]['uid'][0]; 
     243                                $result[$j]['jid']      = $entry[$i]['uid'][0]; 
     244                                $ou = explode("dc=", $entry[$i]['dn']); 
     245                                $ou = explode("ou=",$ou[0]); 
     246                                $ou = array_pop($ou); 
     247                                $result[$j]['ou']       = strtoupper(substr($ou,0,strlen($ou)-1));                                       
     248                                if( $entry[$i]['jpegphoto'][0] ) 
     249                                { 
     250                                        $result[$j]['photo'] = "1"; 
     251                                        $filterPhoto = "(objectclass=*)"; 
     252                                        $photoLdap = ldap_read($pConn, $entry[$i]['dn'], $filterPhoto, array("jpegPhoto")); 
     253                                        $firstEntry = ldap_first_entry($pConn, $photoLdap); 
     254                                        $photo = ldap_get_values_len($pConn, $firstEntry, "jpegPhoto"); 
     255                                        $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['uid'])] = $photo[0]; 
     256                                } 
     257                                else 
     258                                        $result[$j]['photo'] = "0"; 
     259 
     260                                $result[$j++]['cn']     = $entry[$i]['cn'][0]; 
     261                        } 
     262                 
     263                        $organization = $this->attr_org; 
     264         
     265                        if(is_array($organization)) 
     266                        { 
     267                                foreach($organization as $attr) 
     268                                { 
     269                                        $tmp = explode(";",$attr); 
     270                                        if( strtolower(trim($tmp[0])) == strtolower(trim($result[$i]['dn'])) ) 
     271                                        { 
     272                                                switch(strtolower(trim($tmp[1]))) 
     273                                                { 
     274                                                        case "mail" : 
     275                                                                        $uid = $result[$i]['mail']; 
     276                                                                        $uid = substr($uid,0,strpos($uid,"@"));  
     277                                                                        $result[$i]['uid'] = $uid; 
     278                                                                        break; 
     279         
     280                                                        case "description" : 
     281                                                                        // SERPRO 
     282                                                                        // parte antes do arroba;  
     283                                                                        $result[$i]['uid'] = $result[$i]['description'];                                                                                 
     284                                                                        break; 
     285                                                } 
     286                                        } 
     287                                } 
     288                        } 
     289                } 
     290                return $result; 
    314291        } 
    315292} 
  • trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php

    r697 r946  
    2727        } 
    2828         
    29         public final function backPage() 
    30         { 
    31                 echo "<pre>"; 
    32                 print_r($_POST); 
    33                 echo "</pre>"; 
    34         }        
    35  
    3629        public final function editGroups() 
    3730        { 
     
    6356                         
    6457                        $ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";      
    65                         if( ($LdapOus = $ldap->listOrganizationsLdap()) ) 
     58                        if( ($LdapOus = $ldap->getOrganizationsLdap()) ) 
    6659                        { 
    6760                                foreach($LdapOus as $tmp ) 
  • trunk/jabberit_messenger/inc/class.uigroupslocked.inc.php

    r570 r946  
    7070                 
    7171                $ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";      
    72                 if( ($LdapOus = $ldap->listOrganizationsLdap()) ) 
     72                if( ($LdapOus = $ldap->getOrganizationsLdap()) ) 
    7373                { 
    7474                        foreach($LdapOus as $tmp ) 
  • trunk/jabberit_messenger/inc/class.uihostsjabber.inc.php

    r915 r946  
    5353                require_once "load_lang.php"; 
    5454 
    55  
    56                 // Load Ldap; 
    57                 require_once "class.ldap_im.inc.php"; 
    58                  
    59                 $ldap = new ldap_im(); 
    60                  
    61                 $ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";      
    62                 if( ($LdapOus = $ldap->listOrganizationsLdap()) ) 
    63                 { 
    64                         foreach($LdapOus as $tmp ) 
    65                                 $ous .= "<option value='".$tmp."'>".$tmp."</option>"; 
    66                 } 
    67                  
    6855                $ConfHosts = $this->bo->getHostsJabber(); 
    6956                 
     
    7158                { 
    7259                        $ConfHosts = unserialize($this->bo->getHostsJabber()); 
    73                         $ConfHosts = explode(";", $ConfHosts); 
    74                         natcasesort($ConfHosts); 
    7560                } 
    7661                 
    7762                $value_Organizations_Servers = ""; 
    7863                 
    79                 if(is_array($ConfHosts))         
     64                if( is_array($ConfHosts) )       
    8065                { 
    81                         foreach($ConfHosts as $values) 
     66                        foreach($ConfHosts as $itens) 
    8267                        { 
    83                                 $itens = explode(":", $values); 
    84                          
    85                                 $value_Organizations_Servers .= "<tr id='".$values."' style='width:40%' class='row_off'>"; 
    86                                 $value_Organizations_Servers .= "<td>".$itens[0]."</td>"; 
    87                                 $value_Organizations_Servers .= "<td>".$itens[1]."</td>"; 
    88                                 $value_Organizations_Servers .= "<td><a href='javascript:constructScript.removeHostsJ(\"".$values."\");'>".lang('Delete')."</a></td>"; 
     68                                $value_Organizations_Servers .= "<tr id='".$itens['org'].":".$itens['jabberName']."' style='width:40%' class='row_off'>"; 
     69                                $value_Organizations_Servers .= "<td>".$itens['org']."</td>"; 
     70                                $value_Organizations_Servers .= "<td>".$itens['jabberName']."</td>"; 
     71                                $value_Organizations_Servers .= "<td><a href='javascript:constructScript.editHostsJ(\"".$itens['org'].":".$itens['jabberName']."\");'>".lang('Edit')."</a></td>"; 
     72                                $value_Organizations_Servers .= "<td><a href='javascript:constructScript.removeHostsJ(\"".$itens['org'].":".$itens['jabberName']."\");'>".lang('Delete')."</a></td>";                            
    8973                                $value_Organizations_Servers .= "</tr>"; 
    9074                        } 
     
    9882                                                                                                        'lang_Back' => lang('Back'), 
    9983                                                                                                    'lang_Delete' => lang('Delete'), 
     84                                                                                                    'lang_Edit' => lang('Edit'), 
    10085                                                                                                    'lang_Example' => lang('Example'), 
     86                                                                                                    'lang_new' => lang('New'), 
    10187                                                                                                    'lang_Organization' => lang('Organization'), 
    10288                                                                                                        'lang_save' => lang('Save'), 
    10389                                                                                                    'lang_ServerJabber' => lang('Servers Jabber'), 
    10490                                                                                                        'lang_Registration_Organizations_and_Server_Jabber' => lang("Registration of Organizations and Servers Jabber"),                                                                                                         
    105                                                                                                         'options_ous_ldap' => $ous, 
    10691                                                                                                        'value_Organizations_Servers' => $value_Organizations_Servers, 
    10792                                                                                )); 
  • trunk/jabberit_messenger/inc/controller.xml

    r899 r946  
    3434                        <item ref="contacts_im" alias="list_contacts" class="contacts_im" method="list_contacts" prefix="class." suffix=".inc.php"/> 
    3535                        <item ref="contacts_im" alias="verifyAddNewContact" class="contacts_im" method="verifyAddNewContact" prefix="class." suffix=".inc.php"/> 
     36                        <item ref="db_im" alias="editHostJabber" class="db_im" method="editHostJabber" prefix="class." suffix=".inc.php"/> 
    3637                        <item ref="db_im" alias="getPreferences" class="db_im" method="getPreferences" prefix="class." suffix=".inc.php"/> 
    3738                        <item ref="db_im" alias="setAttributesLdap" class="db_im" method="setAttributesLdap" prefix="class." suffix=".inc.php"/> 
    3839                        <item ref="db_im" alias="setHostJabber" class="db_im" method="setHostJabber" prefix="class." suffix=".inc.php"/> 
     40                        <item ref="db_im" alias="setPreferences" class="db_im" method="setPreferences" prefix="class." suffix=".inc.php"/> 
    3941                        <item ref="db_im" alias="setOuGroupsLocked" class="db_im" method="setOuGroupsLocked" prefix="class." suffix=".inc.php"/> 
    4042                        <item ref="db_im" alias="setOrganization" class="db_im" method="setOrganization" prefix="class." suffix=".inc.php"/> 
    41                         <item ref="db_im" alias="setPreferences" class="db_im" method="setPreferences" prefix="class." suffix=".inc.php"/> 
    4243                        <item ref="db_im" alias="setUseParticipantsExternal" class="db_im" method="setUseParticipantsExternal" prefix="class." suffix=".inc.php"/> 
    4344                        <item ref="db_im" alias="removeAttributesLdap" class="db_im" method="removeAttributesLdap" prefix="class." suffix=".inc.php"/> 
     
    4546                        <item ref="db_im" alias="removeOuGroupsLocked" class="db_im" method="removeOuGroupsLocked" prefix="class." suffix=".inc.php"/> 
    4647                        <item ref="db_im" alias="removeParticipantsExternal" class="db_im" method="removeParticipantsExternal" prefix="class." suffix=".inc.php"/> 
    47                         <item ref="ldap_im" alias="list_organizations_ldap" class="ldap_im" method="list_organizations_ldap" prefix="class." suffix=".inc.php"/> 
    48                         <item ref="ldap_im" alias="list_participants_externals" class="ldap_im" method="list_participants_externals" prefix="class." suffix=".inc.php"/> 
     48                        <item ref="fileDefine" alias="ldapExternal" class="fileDefine" method="ldapExternal" prefix="class." suffix=".inc.php"/> 
     49                        <item ref="fileDefine" alias="ldapInternal" class="fileDefine" method="ldapInternal" prefix="class." suffix=".inc.php"/>                         
    4950                        <item ref="ldap_im" alias="getGroupsLdap" class="ldap_im" method="getGroupsLdap" prefix="class." suffix=".inc.php"/> 
    50                         <item ref="ldap_im" alias="photo_ldap" class="ldap_im" method="photo_ldap" prefix="class." suffix=".inc.php"/> 
    51                         <item ref="ujabber" alias="AddNewContact" class="ujabber" method="AddNewContact" prefix="class." suffix=".inc.php"/> 
    52                         <item ref="ujabber" alias="getGroupsJabber" class="ujabber" method="getGroupsJabber" prefix="class." suffix=".inc.php"/>                         
    53                         <item ref="FileDefine" alias="getParams" class="FileDefine" method="getParams" prefix="class." suffix=".inc.php"/>                       
    5451                </php> 
    5552                <xml></xml> 
  • trunk/jabberit_messenger/inc/hook_admin.inc.php

    r942 r946  
    1717                'Enable the Expresso Messenger inside of the modules' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uimodule.edit_conf'), 
    1818                'Configuration of authentication attribute by Organization (OU)' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiconforganization.edit_conf'), 
    19                 'External Participants' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiexternals.editParticipantsExternals'), 
    2019                'Restrict group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uigroupslocked.editGroups'), 
    2120                'Free organization for group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uienabledgroups.getGroups'), 
    22                 //'Map organization for realm jabber' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uihostsjabber.edit_conf'), 
     21                'Map organization for realm jabber' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uihostsjabber.edit_conf'), 
    2322        ); 
    2423 
  • trunk/jabberit_messenger/inc/jabberit_acl.inc.php

    r864 r946  
    4646                $_SESSION['phpgw_info']['jabberit_messenger']['webserver_url'] = $webserver_url; 
    4747                 
    48                 $ExternalParticipants = "";  
    49                 if(trim($_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit'])) 
    50                 {                        
    51                         $ExternalParticipants = explode(",",$_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']); 
    52                          
    53                         if(is_array($ExternalParticipants))      
    54                         { 
    55                                 natcasesort($ExternalParticipants); 
    56                                 $ExternalParticipants = implode(",", $ExternalParticipants); 
    57                         } 
    58                 } 
    59                  
    6048                require_once dirname(__FILE__) . '/load_lang.php'; 
    6149                 
    6250                $var_js  = "var path_jabberit='".$webserver_url."';"; 
    63                 $var_js .= "var externalParticipantsJabberit='".$ExternalParticipants."';"; 
    6451 
    6552                echo "<script type=\"text/javascript\">".$var_js."</script>"; 
  • trunk/jabberit_messenger/inc/jabberit_sessions.inc.php

    r894 r946  
    5555                $_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit'] = $GLOBALS['phpgw_info']['server']['use_attribute_jabberit']; 
    5656                $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']           = $GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit']; 
    57                 $_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit'] = $GLOBALS['phpgw_info']['server']['use_external_participants_jabberit']; 
    58                 $_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']                     = $GLOBALS['phpgw_info']['server']['conf_organization_jabberit'];                
    5957                $_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']                         = $GLOBALS['phpgw_info']['server']['map_org_realm_jabberit']; 
    6058 
  • trunk/jabberit_messenger/inc/login.php

    r893 r946  
    8282                // Enable Plugins Java; 
    8383                $pluginsJava[] = $path . "applet.jar?" . filemtime("applet.jar"); 
    84                 $pluginsJava[] = $path . "plugins/filetransfer.jar?" . filemtime("plugins/filetransfer.jar"); 
    8584                $pluginsJava[] = $path . "plugins/xhtml.jar?" . filemtime("plugins/xhtml.jar"); 
     85                $pluginsJava[] = $path . "plugins/filetransfer.jar?" . filemtime("plugins/filetransfer.jar");            
    8686                 
    8787                for($i = 0; $i < count($pluginsJava); $i++) 
  • trunk/jabberit_messenger/inc/webservice.php

    r697 r946  
    1111  \***************************************************************************/ 
    1212 
    13 function 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 } 
    18  
    19 class ldapPhoto 
    20 { 
    21         private $host; 
    22         private $dn; 
     13class webService 
     14{ 
     15        private $conn; 
     16        private $contextLdap; 
     17        private $userDn;         
     18        private $jabberName; 
    2319        private $passwd; 
     20        private $photo_user = array(); 
    2421        private $refer; 
    25         private $user_referral; 
    26         private $password_referral; 
    27         private $conn; 
    28         private $context; 
    29         private $photo_user = array(); 
    30         private $handle; 
    31  
    32  
     22        private $serverLdap; 
     23         
    3324        function __construct() 
    3425        { 
    35                 require_once('conf_Ldap_Photos.php'); 
    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']; 
     26                require_once('confLDAPInternal.php'); 
     27                $handle   = unserialize(base64_decode($LDAP_INTERNAL)); 
     28 
     29                $this->jabberName       = $handle['jabberName']; 
     30                $this->serverLdap       = $handle['serverLdap']; 
     31                $this->contextLdap      = $handle['contextLdap']; 
     32                $this->userDn           = $handle['user']; 
     33                $this->passwd           = $handle['password']; 
    4234                 
    4335                $this->refer    = true; 
    4436                $this->version3 = true; 
    4537        } 
    46  
    47  
     38         
    4839        private final function ldapConnect() 
    4940        { 
    5041                if(!function_exists('ldap_connect')) 
    51                 { 
    52                         printf("<b>Erro : Ldap Não suportado %s</b><br>" , $this->host); 
    53                         return False; 
    54                 } 
    55                  
    56                 if(!$this->conn = ldap_connect($this->host)) 
    57                 { 
    58                         printf("<b>Erro: não pode conectar no servidor ldap %s!</b><br>", $this->host); 
    59                         return False; 
    60                 } 
     42                        return False; 
     43                 
     44                if(!$this->conn = ldap_connect($this->serverLdap)) 
     45                        return False; 
    6146 
    6247                if( $this->version3 ) 
    63                 { 
    6448                        if( !ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3) ) 
    6549                                $this->version = false; 
    66                 } 
     50 
    6751                ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer); 
    6852 
    69                 // verifica refer 
    70                 if( $this->refer ) 
    71                 { 
    72                         @ldap_set_rebind_proc($this->conn, ldap_rebind); 
    73                 } 
    74                  
    75                 // bind as admin 
    76                 if($this->dn && $this->passwd && !ldap_bind($this->conn, $this->dn, $this->passwd)){ 
    77                         echo "<center><b>ExpressoLivre indisponível no momento</b></center>"; 
    78                         return False; 
    79                 } 
    80  
    81                 // bind as anonymous 
    82                 if(!$this->dn && !$this->passwd && !@ldap_bind($this->conn)) 
    83                 { 
    84                         echo "<center><b>ExpressoLivre indisponível no momento</b></center>"; 
    85                         return False; 
    86                 }                                                
    87         } 
    88          
    89         public final function getNameOrganization($pUid, $pCharset) 
    90         { 
     53                // Bind as Admin 
     54                if($this->userDn && $this->passwd && !ldap_bind($this->conn, $this->userDn, $this->passwd)) 
     55                        return False; 
     56                 
     57                // Bind as Anonymous 
     58                if(!$this->userDn && !$this->passwd && !@ldap_bind($this->conn)) 
     59                        return False; 
     60        } 
     61 
     62        private final function ldapConnectExternal($pHostJabber) 
     63        { 
     64                require_once('confLDAPExternal.php'); 
     65                $handle   = unserialize(base64_decode($LDAP_EXTERNAL)); 
     66 
     67                foreach($handle as $itens) 
     68                        if(trim($pHostJabber) == $itens['jabberName']) 
     69                        { 
     70                                $this->jabberName       = $itens['jabberName']; 
     71                                $this->serverLdap       = $itens['serverLdap']; 
     72                                $this->contextLdap      = $itens['contextLdap']; 
     73                                $this->userDn           = $itens['user']; 
     74                                $this->passwd           = $itens['password']; 
     75                        }                
     76 
     77                $this->refer    = true; 
     78                $this->version3 = true; 
     79                 
    9180                $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          
    121         public final function getPhotoLdap($uid) 
    122         { 
    123                 $this->ldapConnect(); 
    124                 if( $this->conn ) 
    125                 { 
    126                         $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    127                         $justthese = array("uid","jpegPhoto"); 
    128                         $search = ldap_search($this->conn,$this->context,$filter,$justthese); 
    129                         $entry1 = ldap_get_entries($this->conn,$search); 
    130                         $entry = ldap_first_entry( $this->conn, $search ); 
    131                         if( $entry1['count'] > 0 ) 
    132                         { 
    133                                 $i = 0; 
    134                                 $photo = ""; 
    135                                 $return_photo = ""; 
    136                                 $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); 
    137                                 if ($photo) 
    138                                         $return_photo = $photo[0];                                                               
    139                                 return $return_photo; 
    140                         } 
    141                 } 
     81        } 
     82         
     83        public final function getNameOrganization($pJid, $pCharset) 
     84        { 
     85                $uid = substr($pJid, 0, strpos($pJid,"@")); 
     86                 
     87                if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 ))) 
     88                { 
     89                        $this->ldapConnect(); 
     90                         
     91                        if( $this->conn ) 
     92                        { 
     93                                $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     94                                $justthese = array("uid","cn","dn"); 
     95                                $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     96                                $entry = ldap_get_entries($this->conn,$search); 
     97                                $cn = $entry[0]['cn'][0]; 
     98                                $ou = explode("dc=", $entry[0]['dn']); 
     99                                $ou = explode("ou=",$ou[0]); 
     100                                $ou = array_pop($ou); 
     101                                $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
     102         
     103                                $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     104                        } 
     105                } 
     106                else 
     107                { 
     108                        $this->ldapConnectExternal(substr($pJid, strpos($pJid, "@") + 1 )); 
     109 
     110                        if( $this->conn ) 
     111                        { 
     112                                $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     113                                $justthese = array("uid","cn","dn"); 
     114                                $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     115                                $entry = ldap_get_entries($this->conn,$search); 
     116                                $cn = $entry[0]['cn'][0]; 
     117                                $ou = explode("dc=", $entry[0]['dn']); 
     118                                $ou = explode("ou=",$ou[0]); 
     119                                $ou = array_pop($ou); 
     120                                $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
     121         
     122                                $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     123                        } 
     124                } 
     125 
     126                if( $pCharset === "1" ) 
     127                        return $return; 
     128                else 
     129                        return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); 
     130 
     131                $return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado");                        
     132 
     133                if( $pCharset === 1 ) 
     134                        return $return; 
     135                else 
     136                        return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); 
     137 
     138        } 
     139         
     140        public final function getPhotoLdap($pJid) 
     141        { 
     142                $uid = substr($pJid, 0, strpos($pJid,"@")); 
     143         
     144                if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 ))) 
     145                { 
     146                        $this->ldapConnect(); 
     147                         
     148                        if( $this->conn ) 
     149                        { 
     150                                $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     151                                $justthese = array("uid","jpegPhoto"); 
     152                                $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     153                                $entry1 = ldap_get_entries($this->conn,$search); 
     154                                $entry = ldap_first_entry( $this->conn, $search ); 
     155                                if( $entry1['count'] > 0 ) 
     156                                { 
     157                                        $i = 0; 
     158                                        $photo = ""; 
     159                                        $return_photo = ""; 
     160                                        $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); 
     161 
     162                                        if ($photo) 
     163                                                $return_photo = $photo[0];                                                               
     164                                        return $return_photo; 
     165                                } 
     166                        } 
     167                } 
     168                else 
     169                { 
     170                        $jabberName = substr($pJid, strpos($pJid, "@") + 1 ); 
     171                         
     172                        if( strpos($jabberName, "/") ) 
     173                                $jabberName = substr($jabberName, 0, strpos($jabberName, "/")); 
     174                         
     175                        $this->ldapConnectExternal($jabberName); 
     176 
     177                        if( $this->conn ) 
     178                        { 
     179                                $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     180                                $justthese = array("uid","jpegPhoto"); 
     181                                $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     182                                $entry1 = ldap_get_entries($this->conn,$search); 
     183                                $entry = ldap_first_entry( $this->conn, $search ); 
     184                                if( $entry1['count'] > 0 ) 
     185                                { 
     186                                        $i = 0; 
     187                                        $photo = ""; 
     188                                        $return_photo = ""; 
     189                                        $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); 
     190                                        if ($photo) 
     191                                                $return_photo = $photo[0];                                                               
     192                                        return $return_photo; 
     193                                } 
     194                        } 
     195                } 
     196                                         
    142197                return false; 
    143198        } 
    144199         
    145         public final function getPhotoSession($pUid) 
    146         { 
    147                 if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid])) 
    148                 { 
    149                         $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]); 
    150                          
     200        public final function getPhotoSession($pUid, $pOu) 
     201        { 
     202                $uid = $pUid; 
     203                if( strpos($pUid, "@") ) 
     204                        $uid = substr($pUid, 0, strpos($pUid, "@")); 
     205                 
     206                if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) ) 
     207                { 
     208                        $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); 
     209 
    151210                        header("Content-Type: image/jpeg"); 
    152211                        $width = imagesx($photo); 
     
    157216                        imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); 
    158217                        imagejpeg($small_photo,'',100); 
    159                          
    160                         unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]);    
     218 
     219                        unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); 
     220 
    161221                        return;  
    162222                } 
     
    164224} 
    165225 
    166 if(trim($_REQUEST['uid']) != "") 
    167 { 
    168         $uid = trim($_REQUEST['uid']); 
    169         $a = new ldapPhoto(); 
    170          
    171         if( strpos($uid,"@")) 
    172         { 
    173                 $uid = substr($uid, 0, strpos($uid,"@"));        
    174                 $photo = $a->getPhotoLdap($uid); 
    175                 $photoWidth = 70; 
    176                 $photoHeight = 90; 
    177                 $newImage = imagecreatetruecolor($photoWidth,$photoHeight);              
    178  
    179                 if($photo) 
    180                 { 
    181                         $photo = imagecreatefromstring($photo); 
    182                         imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); 
    183                 } 
    184                 else 
    185                 { 
    186                         $photo = @imagecreatefrompng("../templates/default/images/photo.png"); 
    187                         imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); 
    188                 } 
    189  
    190                 ob_start(); 
    191                 imagepng($newImage); 
    192                 $imagePhoto = ob_get_contents(); 
    193                 imagedestroy($newImage); 
    194                 ob_end_clean(); 
    195                 printf("%s",base64_encode($imagePhoto)); 
     226if(trim($_REQUEST['javaPhoto']) != "" ) 
     227{ 
     228        $obj = new webService(); 
     229        $jid = $_REQUEST['javaPhoto']; 
     230         
     231        $photo = $obj->getPhotoLdap($jid); 
     232        $photoWidth = 70; 
     233        $photoHeight = 90; 
     234        $newImage = imagecreatetruecolor($photoWidth,$photoHeight);              
     235 
     236        if( $photo ) 
     237        { 
     238                $photo = imagecreatefromstring($photo); 
     239                imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); 
    196240        } 
    197241        else 
    198242        { 
    199                 $a->getPhotoSession($uid); 
    200         } 
     243                $photo = @imagecreatefrompng("../templates/default/images/photo.png"); 
     244                imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); 
     245        } 
     246         
     247        ob_start(); 
     248        imagepng($newImage); 
     249        $imagePhoto = ob_get_contents(); 
     250        imagedestroy($newImage); 
     251        ob_end_clean(); 
     252        printf("%s",base64_encode($imagePhoto)); 
     253         
    201254} 
    202255 
     
    204257{ 
    205258        $jid = trim($_POST['jid']); 
    206         if( strpos($jid,"@")) 
    207                 $jid = substr($jid, 0, strpos($jid,"@")); 
    208259        $charset = trim($_POST['charset']); 
    209         $a = new ldapPhoto(); 
    210          
    211         printf("%s",$a->getNameOrganization($jid, $charset)); 
    212 } 
     260        $obj = new webService(); 
     261         
     262        printf("%s",$obj->getNameOrganization($jid, $charset)); 
     263} 
     264 
     265if(trim($_REQUEST['phpPhoto']) != "") 
     266{ 
     267        $obj = new webservice(); 
     268        $ou = $_REQUEST['phpOu']; 
     269        $jid = $_REQUEST['phpPhoto']; 
     270         
     271        $obj->getPhotoSession($jid, $ou); 
     272} 
     273 
    213274?> 
Note: See TracChangeset for help on using the changeset viewer.