Ignore:
Timestamp:
09/15/10 17:06:46 (14 years ago)
Author:
pereira.jair
Message:

Ticket #1186 - Alterado modulo administrativo do organograma p/ definir diferentes niveis de usuarios.

Location:
branches/2.2/workflow/inc
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/workflow/inc/class.WorkflowLDAP.inc.php

    r3221 r3255  
    562562                        ); 
    563563 
    564                         $result = array_merge($result, ldap_get_entries($this->dataSource, $resourceIdentifier)); 
     564                        $entries = ldap_get_entries($this->dataSource, $resourceIdentifier); 
     565                        if (is_array($entries)) { 
     566                                $result = array_merge($result, $entries); 
     567                        } 
     568                         
    565569                        unset($result['count']); 
    566570                } 
  • branches/2.2/workflow/inc/class.bo_adminaccess.inc.php

    r3167 r3255  
    8585                return $this->so->getUserNames($admins_id); 
    8686        } 
     87         
     88        /** 
     89        * Retorna o nivel administrativo do organograma do processo 
     90        * 
     91        * @param array $p processo 
     92        * @return array o nivel administrativo do monitor do processo 
     93        * @access public 
     94        */ 
     95        function get_organogram_admin_level($p) 
     96        { 
     97                return $this->so->getUserAdminLevel('ORG', $p['uid'], $p['pid']); 
     98        } 
    8799 
    88100        /** 
     
    221233                return null; 
    222234        } 
     235         
     236        /** 
     237        * Seta o nivel administrativo do organograma 
     238        * 
     239        * @param array $p processo 
     240        * @return arraym 
     241        * @access public 
     242        */ 
     243        function set_organogram_admin_level($p) 
     244        { 
     245                $np = explode('_', $p['np']); 
     246                $levels = array(); 
     247                foreach ($np as $pair) 
     248                { 
     249                        list($key, $value) = explode('=', $pair, 2); 
     250                        $levels[$key] = ($value == '1') ? true : false; 
     251                } 
     252                 
     253 
     254                $result = $this->so->setAdminLevel('ORG', $p['uid'], $p['pid'], $levels); 
     255                 
     256                if (!$result) { 
     257                        return "Não atualizou as permissões."; 
     258                } 
     259                 
     260        } 
    223261 
    224262        /** 
  • branches/2.2/workflow/inc/class.so_adminaccess.inc.php

    r3167 r3255  
    184184        function get_granted_organograms($user_id) 
    185185        { 
    186                 return $this->getUserPermissions('ORG', $user_id); 
     186                return $this->getUserPermissions('ORG', $user_id, 0); 
    187187        } 
    188188 
     
    311311        * @param string $type type of resource 
    312312        * @param integer $uid user id 
     313        * @param requiredLevel Level Required to Access. 
    313314        * @return bool 
    314315        * @access public 
    315316        */ 
    316         function getUserPermissions($type, $uid) 
     317        function getUserPermissions($type, $uid, $requiredLevel = null) 
    317318        { 
    318319                $query = " 
    319320                        SELECT 
    320                                 numvalue 
     321                                numvalue, 
     322                                nivel 
    321323                        FROM 
    322324                                egw_wf_admin_access 
     
    329331                $output = array(); 
    330332                if ($result) 
    331                         while ($row = $result->fetchRow()) 
    332                                 $output[] = $row['numvalue']; 
     333                        while ($row = $result->fetchRow()) { 
     334                                $authorized = $this->_checkLevelNumber($row['nivel'], $requiredLevel); 
     335                                if (isset($requiredLevel)) { 
     336                                        $authorized = $this->checkUserAccessToResource($type,$uid,$row['numvalue'],$requiredLevel); 
     337                                        if ($authorized) { 
     338                                                $output[] = $row['numvalue']; 
     339                                        } 
     340                                } else { 
     341                                        $output[] = $row['numvalue']; 
     342                                } 
     343                        } 
    333344 
    334345                return $output; 
     
    342353         * @return array 
    343354         */ 
    344         function getUserGroupPermissions($type, $uid) 
     355        function getUserGroupPermissions($type, $uid, $requiredLevel = null) 
    345356        { 
    346357                $groups = galaxia_retrieve_user_groups($uid); 
     
    361372                $output = array(); 
    362373                if ($result) 
    363                         while ($row = $result->fetchRow()) 
    364                                 $output[] = $row['numvalue']; 
     374                        while ($row = $result->fetchRow()) { 
     375                                if (isset($requiredLevel)) { 
     376                                        //$authorized = $this->_checkLevelNumber($row['nivel'], $requiredLevel);                 
     377                                        $authorized = $this->checkUserAccessToResource($type,$uid,$row['numvalue'],$requiredLevel); 
     378                                        if ($authorized) { 
     379                                                $output[] = $row['numvalue']; 
     380                                        } 
     381                                } else { 
     382                                        $output[] = $row['numvalue']; 
     383                                } 
     384                        } 
    365385 
    366386                return $output; 
     
    376396        function checkUserAccessToType($type, $uid) 
    377397        { 
    378                 return (count($this->getUserPermissions($type, $uid)) > 0); 
     398                return (count($this->getUserPermissions($type, $uid,0)) > 0); 
    379399        } 
    380400        /** 
     
    414434 
    415435                $result = $this->db->query($query, array($type, $uid, $numvalue)); 
     436                 
    416437                $row = $result->fetchRow(); 
    417438 
    418                 if (isset($row['nivel'])) 
    419                         return $this->_checkLevelNumber($row['nivel'], $requiredLevel); 
     439                if (isset($row['nivel'])) { 
     440                        $res = $this->_checkLevelNumber($row['nivel'], $requiredLevel);          
     441                        return $res; 
     442                } 
    420443                else 
    421444                        return false; 
     
    491514        } 
    492515        /** 
    493         * Setaa o nivel de administracao 
     516        * Seta o nivel de administracao 
    494517        * 
    495518        * @param string  $type tipo de recurso 
     
    505528                        $level = $this->_permissionListToNumber($level); 
    506529 
    507                 $query = " 
    508                         UPDATE egw_wf_admin_access 
     530                $query = "UPDATE egw_wf_admin_access 
    509531                        SET 
    510532                                nivel = ? 
     
    513535                                (tipo = ?) AND 
    514536                                (numvalue = ?)"; 
    515                 $this->db->query($query, array($level, $uid, $type, $numvalue)); 
     537                $result = $this->db->query($query, array($level, $uid, $type, $numvalue)); 
     538                 
     539                return $result; 
    516540        } 
    517541 
  • branches/2.2/workflow/inc/class.so_orgchart.inc.php

    r3225 r3255  
    145145                else 
    146146                { 
    147                         $organizations = $this->acl->getUserPermissions("ORG", $this->userID); 
     147                        $organizations = $this->acl->getUserPermissions("ORG", $this->userID, 0); 
    148148                        $organizations[] = -1; 
    149149                        $query = "SELECT organizacao_id, nome, descricao, ativa, url_imagem, sitio FROM organizacao WHERE (organizacao_id IN (" . implode(',', $organizations)  . ")) ORDER BY nome"; 
     
    11261126                $mobile         = ''; 
    11271127                $homePhone  = ''; 
    1128  
     1128                 
    11291129                /* 
    11301130                 * Check if the current user can view the mobile and homePhone of the employee 
     
    11321132                 * that's being retrieved 
    11331133                 */ 
    1134                 if (in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) { 
     1134                $authorized = $this->acl->checkUserAccessToResource('ORG', $account_id, (int) $organizationID, 1);  
     1135                if ((in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) || ($authorized)) { 
    11351136                        $mobile         = $employeeEntry['mobile']; 
    11361137                        $homePhone      = $employeeEntry['homephone']; 
  • branches/2.2/workflow/inc/class.ui_orgchart.inc.php

    r3167 r3255  
    5050 
    5151                $isAdmin = $this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 
    52                 $isOrgchartManager = $this->workflow_acl->checkUserGroupAccessToType('ORG', $GLOBALS['phpgw_info']['user']['account_id']); 
     52                $isOrgchartManager = $this->workflow_acl->checkUserGroupAccessToType('ORG', $GLOBALS['phpgw_info']['user']['account_id'],0); 
    5353 
    5454                if (!($isAdmin || $isOrgchartManager)) 
  • branches/2.2/workflow/inc/hook_sidebox_menu.inc.php

    r3167 r3255  
    3838 
    3939        /* check if the user can administrate the orgchart */ 
    40         if ($workflowACL->checkUserGroupAccessToType('ORG', $userID) || $isWorkflowAdmin) 
     40        if ($workflowACL->checkUserGroupAccessToType('ORG', $userID,0) || $isWorkflowAdmin) 
    4141                $file['Organization Chart']     = $GLOBALS['phpgw']->link('/index.php','menuaction=workflow.ui_orgchart.draw'); 
    4242 
Note: See TracChangeset for help on using the changeset viewer.