Changeset 3225


Ignore:
Timestamp:
09/09/10 15:56:47 (14 years ago)
Author:
viani
Message:

Ticket #1186 - Correção no array de atributos Ldap retornados pela pesquisa de employee

Location:
branches/2.2/workflow
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/workflow/doc/change_log.txt

    r3221 r3225  
    2222[2.2.000] 
    2323 
     24        #1186 - Exibição dos atributos mobile e homePhone, do Ldap, no cartão de visita do organograma (pereira.jair) 
     25        #1177 - Correção da máscara de ano no componete wf_calendar (adeildosantos) 
    2426        #1176 - Otimização da query de busca ldap na classe WorkflowLDAP, e prevenção contra loop infinito (fabianok) 
    2527        #1172 - Ajustar a preparação do ambiente do Workflow para chamadas de webservices (asaikawa) 
  • branches/2.2/workflow/inc/class.CachedLDAP.inc.php

    r3212 r3225  
    7272        */ 
    7373        private $entryAttributes = array('uid', 'cn', 'givenname', 'mail', 'sn', 'accountstatus', 'uidnumber', 'dn', 'employeenumber', 'cpf', 'telephonenumber'); 
    74          
    75         /** 
    76          * @var array $entryAttributesLDAP Os atributos que serão buscados somente no LDAP.  
    77          * (Alguns campos não são armazenados no banco, e o campo mobile pode ser mais do que um por funcionário) 
     74 
     75        /** 
     76         * @var array $entryAttributesLDAP Attributes thats only exists in LDAP. 
     77         * The attributes mobile and homePhone are not present in databaseCache, because they may have more 
     78         * This is not the very best approach because the best solution should be store all attributes 
     79         * from Ldap into databaseCache 
     80         * than one value 
    7881         * @access private 
    7982         * */ 
     
    135138                /* load the information and establish the connection */ 
    136139                $this->loadLDAP(); 
    137                  
     140 
    138141                $ldapfields = array(); 
    139          
     142 
     143                // Merge the arrays os attributes from databaseCache and Ldap 
    140144                $ldapfields = array_merge($this->entryAttributes,$this->entryAttributesLDAP); 
    141                  
     145 
    142146                /* perform the search */ 
    143147                $resourceIdentifier = ldap_search($this->dataSource, $this->userContext, $ldapQuery, $ldapfields); 
     
    147151                if ($entries['count'] != 1) 
    148152                        return false; 
    149                          
    150             //print_r($entries); 
    151153 
    152154                /* format the output */ 
    153155                $output = array(); 
    154156                foreach ($ldapfields as $attribute) 
    155                         if ($attribute == 'dn') 
     157                        if ($attribute == 'dn' or $attribute == 'mobile' or $attribute == 'homePhone') 
     158                                // Retrieve all occurrencies of mobile and homePhone 
    156159                                $output[$attribute] = $entries[0][$attribute]; 
    157160                        else 
    158                                 $output[$attribute] = $entries[0][$attribute]; 
    159                                  
     161                                // Retrieve first occurrence of other attributes 
     162                                $output[$attribute] = $entries[0][$attribute][0]; 
    160163 
    161164                /* insert the timestamp of the last update */ 
  • branches/2.2/workflow/inc/class.so_orgchart.inc.php

    r3212 r3225  
    11041104                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
    11051105 
    1106                  
    11071106                /* here we need fresh information. Let's access ldap first */ 
    11081107                $employeeEntry = $cachedLDAP->getEntryByID($employeeID); 
    1109                  
     1108 
    11101109                if ($entry === false) 
    11111110                        return array('error' => 'Funcionário não encontrado.'); 
    1112                  
    1113                 $employeeInfo                           = $orgchart->getEmployee($employeeID); 
    1114                 $employeeStatusInfo             = $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']); 
    1115                 $account_id                             = $_SESSION['phpgw_info']['workflow']['account_id']; 
    1116                 $organization_supervisors       = $orgchart->getOrganizationSupervisors($employeeInfo['organizacao_id']); 
    1117                  
    1118                 /*  
    1119                  * Verify the supervisor of the organization 
    1120                  * if the logged user is the supervisor of the selected user 
    1121                  * then will show the mobile and homePhone number. 
    1122                  */  
     1111 
     1112                $employeeInfo                           = $orgchart->getEmployee($employeeID); 
     1113                $employeeStatusInfo                     = $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']); 
     1114                $account_id                                     = $_SESSION['phpgw_info']['workflow']['account_id']; 
     1115                $organization_supervisors       = $orgchart->getOrganizationSupervisors($employeeInfo['organizacao_id']); 
     1116 
     1117                // Make an array with all supervisors and their substitures 
    11231118                $arr_supervisores = array(); 
    11241119                foreach ($organization_supervisors as $supervisor) { 
     
    11281123                        } 
    11291124                } 
    1130                  
     1125 
    11311126                $mobile         = ''; 
    11321127                $homePhone  = ''; 
    1133                  
     1128 
     1129                /* 
     1130                 * Check if the current user can view the mobile and homePhone of the employee 
     1131                 * This condition is true if the current user is a supervisor or is the same user 
     1132                 * that's being retrieved 
     1133                 */ 
    11341134                if (in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) { 
    11351135                        $mobile         = $employeeEntry['mobile']; 
    11361136                        $homePhone      = $employeeEntry['homephone']; 
    1137                 }  
    1138                  
     1137                } 
     1138 
    11391139                $outputInfo[] = array( 
    11401140                        'name' => 'Mobile', 
    11411141                        'value' => ( ! empty( $mobile ) ? $mobile : '' ) ); 
    1142                          
     1142 
    11431143                $outputInfo[] = array( 
    11441144                        'name' => 'homePhone', 
     
    11641164                        'name' => 'UIDNumber', 
    11651165                        'value' => $employeeID); 
    1166  
    1167                  
    11681166 
    11691167                $outputInfo[] = array( 
     
    14301428                * I'm not supose to be here.. (date validations speaking) 
    14311429                * move me to some validation class! 
    1432                 */  
     1430                */ 
    14331431 
    14341432                /* validating dates */ 
     
    15051503                $result = $this -> db -> query( $query, array( $areaID, $substituteID, $date_start, $date_end ) ); 
    15061504                $this->_checkError( $result ); 
    1507                  
     1505 
    15081506                return ( ( $result === false ) ? false : true ); 
    15091507        } 
     
    15331531                $result = $this -> db -> query( $query, array( $substituteID, $date_start, $date_end, $substitutionID ) ); 
    15341532                $this->_checkError( $result ); 
    1535                  
     1533 
    15361534                return ( ( $result === false ) ? false : true ); 
    15371535        } 
     
    15751573         * @param int $organizationID Organization's ID 
    15761574         * @param int $telephoneID Substitution's ID 
    1577          * @return bool  
     1575         * @return bool 
    15781576         * @access public 
    15791577         */ 
  • branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php

    r3212 r3225  
    157157                return $output; 
    158158        } 
    159          
     159 
    160160        /** 
    161161         * Searches for all the supervisors of an organization. 
    162162         * 
    163          * This method will search in table areas for all the supervisors and replacement in the organization., todas as áreas que pertencem à organização solicitada. 
     163         * This method will search in table areas for all the supervisors and replacement in the organization. 
    164164         * @param int $organizationID the ID of the Organization. 
    165165         * @return array Uma array seqüencial contendo as áreas de uma organização e seus titulares e substitutos. Cada linha do array conterá: 
     
    170170         */ 
    171171        function getOrganizationSupervisors($organizationID) { 
    172                 $query = "  SELECT  
    173                                                 a.titular_funcionario_id,  
    174                                                 s.funcionario_id as substituto_funcionario_id,  
     172                $query = "  SELECT 
     173                                                a.titular_funcionario_id, 
     174                                                s.funcionario_id as substituto_funcionario_id, 
    175175                                                a.area_id 
    176                                         FROM  
    177                                                 area a  
    178                                                 LEFT OUTER JOIN substituicao s  
     176                                        FROM 
     177                                                area a 
     178                                                LEFT OUTER JOIN substituicao s 
    179179                                                ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) 
    180                                         WHERE  
    181                                                 a.titular_funcionario_id is not null  
    182                                                 and a.ativa = 'S'  
    183                                                 AND organizacao_id = ? 
    184                                         GROUP BY  
     180                                        WHERE 
     181                                                a.titular_funcionario_id is not null 
     182                                                and a.ativa = 'S' 
     183                                                AND a.organizacao_id = ? 
     184                                        GROUP BY 
    185185                                                a.titular_funcionario_id, 
    186                                                 s.funcionario_id,  
     186                                                s.funcionario_id, 
    187187                                                a.area_id"; 
    188188                $result = $this->db->query($query, array($organizationID)); 
     
    518518                return $output; 
    519519        } 
    520          
     520 
    521521        /** 
    522522         * Return all areas that the employee is a supervisor. 
    523          *  
     523         * 
    524524         * Search in the organization for all areas that the employee is a supervisor. 
    525525         * @param int $employeeID The ID of employee 
     
    533533                } 
    534534 
    535                 $query = "SELECT  
     535                $query = "SELECT 
    536536                                                a.area_id 
    537                                         FROM  
    538                                                 area a  
    539                                                 LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id)  
    540                                                 AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim))  
    541                                         WHERE  
    542                                                 a.titular_funcionario_id = ? OR  
     537                                        FROM 
     538                                                area a 
     539                                                LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id) 
     540                                                AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) 
     541                                        WHERE 
     542                                                a.titular_funcionario_id = ? OR 
    543543                                                s.funcionario_id = ? 
    544544                                        GROUP BY 
    545545                                                a.area_id"; 
    546                  
     546 
    547547                $result = $this->db->query($query, array($employeeID,$employeeID)); 
    548548                if (!$result) 
    549549                        return false; 
    550                  
     550 
    551551                $output = $result->GetArray(-1); 
    552552                return $output; 
Note: See TracChangeset for help on using the changeset viewer.