Changeset 548


Ignore:
Timestamp:
11/06/08 17:27:54 (15 years ago)
Author:
eduardoalex
Message:

Desenvolvimento da tarefa #371

Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/templates/celepar/config.tpl

    r547 r548  
    77<!-- END header --> 
    88<!-- BEGIN body --> 
     9        <tr class="row_on"> 
     10    <td>{lang_Time_for_expire_inatives_accounts(0 for never expires)}:</td> 
     11    <td><input size="8" name="newsettings[time_to_account_expires]" value="{value_time_to_account_expires}"></td> 
     12   </tr> 
    913   <tr class="row_off"> 
    1014    <td>{lang_Timeout_for_sessions_in_seconds_(default_14400_=_4_hours)}:</td> 
  • trunk/expressoAdmin1_2/inc/class.db_functions.inc.php

    r507 r548  
    3737                        $result[] = $this->db->row(); 
    3838                return $result; 
     39        } 
     40/* 
     41        *       Reativa os usuários desabilitados por tempo inativo modificando o seu ultimo acesso para o dia atual. 
     42        */ 
     43        function reativar_usuario_inativo($uidNumber) { 
     44                 
     45        /*      $sql = "insert into phpgw_access_log (sessionid,loginid,ip,li,lo,account_id) values ('expirescontrol','teste','10.10.10.10','0','0','1') "; 
     46                        $this->db->query($sql);*/ 
     47                 
     48                $sql = "select * from phpgw_access_log where account_id=$uidNumber order by li desc limit 1"; 
     49         
     50                $this->db->query($sql); 
     51                $this->db->next_record(); 
     52                $linha = $this->db->row(); 
     53 
     54                 
     55                if(count($linha)>0) { 
     56                        $sql = "insert into phpgw_access_log (sessionid,loginid,ip,li,lo,account_id) values ('expirescontrol','".$linha["loginid"]."','0.0.0.0','".time()."','0','".$linha["account_id"]."')"; 
     57                         
     58                        $this->db->query($sql); 
     59                } 
     60        } 
     61 
     62         
     63        function inserir_usuario_log_controle_inativo($uid,$uidNumber) { 
     64                        $sql = "insert into phpgw_access_log (sessionid,loginid,ip,li,lo,account_id) values ('expirescontrol','".$uid."','0.0.0.0','".time()."','0','".$uidNumber."')"; 
     65                         
     66                        $this->db->query($sql); 
    3967        } 
    4068 
  • trunk/expressoAdmin1_2/inc/class.functions.inc.php

    r414 r548  
    351351                        return $array_acl; 
    352352                } 
     353                 
     354                function get_inative_users($contexts) { 
     355                        $retorno = array(); 
     356                        $tempUsers = array(); 
     357                        //Pego no LDAP todos os usuários dos contextos em questão. 
     358                        $usuariosLdap = $this->get_list('accounts','',$contexts); 
     359                        foreach($usuariosLdap as $usuarioLdap) { 
     360                                $tempUsers[$usuarioLdap["account_id"]] = $usuarioLdap["account_lid"]; 
     361                        } 
     362                        $ids = implode(",",array_keys($tempUsers)); //Consigo a lista de uids daquele contexto para mandar na query para o banco. 
     363                         
     364                        //Pego nas configurações do expresso o número de dias necessários para inatividade. 
     365                        $timeToExpire = $GLOBALS['phpgw_info']['server']['time_to_account_expires']; 
     366                         
     367                         
     368                        $ultimoTsValido = time() - ($timeToExpire * 86400); //O último timestamp válido é dado pelo de agora menos o número de dias para expirar vezes a quantidade de segundos existente em 1 dia. 
     369                        $query = "select account_id,max(li) as last_login from phpgw_access_log where account_id in (".$ids.") group by account_id having max(li) < ".$ultimoTsValido." order by max(li)"; 
     370 
     371                        $GLOBALS['phpgw']->db->query($query); 
     372                        while($GLOBALS['phpgw']->db->next_record()) 
     373                        { 
     374                                $result = $GLOBALS['phpgw']->db->row(); 
     375                                array_push($retorno,array("uidNumber"=>$result["account_id"],"login"=> $tempUsers[$result["account_id"]],"li"=>$result["last_login"])); 
     376                        } 
     377                         
     378                        return $retorno; 
     379                } 
    353380 
    354381                function safeBitCheck($number,$comparison) 
  • trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php

    r540 r548  
    2020                        'show_photo'                            => True, 
    2121                        'show_access_log'                       => True, 
    22                         'css'                                           => True 
     22                        'css'                                           => True, 
     23                        'list_inative_users' => True 
    2324                ); 
    2425 
     
    5051                        $GLOBALS['phpgw']->js->validate_file('jscode','tabs','expressoAdmin1_2'); 
    5152                        $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2'); 
     53                } 
     54 
     55                function list_inative_users() { 
     56 
     57                        $context = $_GET["context"]; 
     58 
     59                        unset($GLOBALS['phpgw_info']['flags']['noheader']); 
     60                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
     61                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '. lang('list inatives'); 
     62                        $GLOBALS['phpgw']->common->phpgw_header(); 
     63 
     64                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
     65                        $p->set_file(array('inative_users' => 'list_inativos.tpl')); 
     66                        $p->set_block('inative_users','list','list'); 
     67                        $p->set_block('inative_users','row','row'); 
     68                        $p->set_block('inative_users','row_empty','row_empty'); 
     69                        $contexts = array(); 
     70                        array_push($contexts,$context); 
     71                                                 
     72                        $usuarios = $this->functions->get_inative_users($contexts); 
     73 
     74         
     75                         
     76                        $var = Array( 
     77                                'th_bg'                                 => $GLOBALS['phpgw_info']['theme']['th_bg'], 
     78                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php?menuaction=expressoAdmin1_2.uisectors.list_sectors'), 
     79                                'context_display'               => $context_display, 
     80                                'lang_idusuario'                        => lang('uidNumber'), 
     81                                'lang_login'                    => lang('user login'), 
     82                                'lang_ultimo_login'     => lang('last login'), 
     83                                'lang_back'                     => lang('back') 
     84                        ); 
     85                        $p->set_var($var); 
     86 
     87                        if (!count($usuarios)) 
     88                        { 
     89                                $p->set_var('message',lang('No matches found')); 
     90                        } 
     91                        else 
     92                        { 
     93                                foreach($usuarios as $usuario) 
     94                                { 
     95                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color); 
     96                                         
     97                                        $var = Array( 
     98                                                'tr_color'    => $tr_color, 
     99                                                'id'  => $usuario["uidNumber"], 
     100                                                'login' => $usuario["login"], 
     101                                                'data_ultimo_login' => date("d/m/Y",$usuario["li"]) 
     102                                        ); 
     103                                        $p->set_var($var); 
     104 
     105                                        $p->fp('rows','row',True); 
     106                                } 
     107                        }                
     108                        $p->parse('rows','row_empty',True); 
     109                        $p->pfp('out','list'); 
     110 
     111                         
    52112                } 
    53113 
     
    551611                        } 
    552612 
     613                        $start_coment = "<!--"; 
     614                        $end_coment = "-->";             
     615                        $time_to_expire = $GLOBALS['phpgw_info']['server']['time_to_account_expires']; 
     616                        if(isset($time_to_expire)) { 
     617                                if ($GLOBALS['phpgw']->session->get_last_access_on_history($user_info["uidnumber"])+($time_to_expire*86400) < time()) 
     618                                { 
     619                                        $start_coment = ""; 
     620                                        $end_coment = ""; 
     621                                } 
     622                        } 
     623 
    553624                        if ($alert_warning != '') 
    554625                                $alert_warning = "alert('". $alert_warning ."')"; 
     
    572643                                'disable_phonenumber'           => $disabled_phonenumber, 
    573644                                'disable_group'                         => $disabled_group, 
     645                                'lang_account_expired'  => lang('lang_account_expired'), 
     646                                'lang_yes'                                              => lang('yes'), 
     647                                'lang_no'                                               => lang('no'), 
     648                                'start_coment_expired'                                          => $start_coment, 
     649                                'end_coment_expired'                                            => $end_coment,  
    574650                                 
    575651                                // Display ABAS 
  • trunk/expressoAdmin1_2/inc/class.uisectors.inc.php

    r414 r548  
    6868                                'th_bg'                                 => $GLOBALS['phpgw_info']['theme']['th_bg'], 
    6969                                'back_url'                              => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 
    70                                 'context_display'               => $context_display 
     70                                'context_display'               => $context_display, 
     71                                'lang_inatives'                 => lang('list inatives') 
    7172                        ); 
    7273                        $p->set_var($var); 
     
    99100                                                'add_link' => $this->row_action('add','sector',$context) 
    100101                                        ); 
     102                                         
     103                                        if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires'])) 
     104                                                $var['inatives_link'] = $this->row_action('list_inative','users',$context,'uiaccounts'); 
     105                                        else 
     106                                                $var['inatives_link'] = lang('disabled'); 
     107 
    101108                                        $p->set_var($var); 
    102109 
     
    321328                } 
    322329                 
    323                 function row_action($action,$type,$context) 
     330                function row_action($action,$type,$context,$class='uisectors') 
    324331                { 
    325332                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( 
    326                                 'menuaction'            => 'expressoAdmin1_2.uisectors.'.$action.'_'.$type, 
     333                                'menuaction'            => 'expressoAdmin1_2.'.$class.'.'.$action.'_'.$type, 
    327334                                'context'               => $context 
    328335                        )).'"> '.lang($action).' </a>'; 
  • trunk/expressoAdmin1_2/inc/class.user.inc.php

    r528 r548  
    580580                                        $this->db_functions->write_log("turn off user account",$dn); 
    581581                                } 
     582 
     583                                if ($new_values['phpgwaccountexpired'] == '1') ///////////////////////// 
     584                                { 
     585                                        $this->db_functions->write_log("Reativado usuário bloqueado por inatividade",'',$dn,'',''); 
     586                                        $this->db_functions->reativar_usuario_inativo($old_values['uidnumber']); 
     587                                } 
     588 
     589 
    582590                                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    583591                                // ACCOUNT VISIBLE 
  • trunk/expressoAdmin1_2/templates/default/accounts_form.tpl

    r540 r548  
    114114                        <td><input type="checkbox" {phpgwaccountvisible_checked} {disabled} name="phpgwaccountvisible" id="phpgwaccountvisible" value="1"</td> 
    115115                </tr>            
    116  
     116                {start_coment_expired} 
     117                <tr bgcolor={row_on}> 
     118                                        <td colspan="2">{lang_account_expired}:</td> 
     119                                        <td><input type="radio" {disabled} name="phpgwaccountexpired" id="phpgwaccountexpired" value="1" />{lang_yes} 
     120                                        <input type="radio" checked="checked" {disabled} name="phpgwaccountexpired" id="phpgwaccountexpired" value="2" />{lang_no}</td> 
     121                                </tr>           {end_coment_expired} 
    117122                <tr bgcolor={row_on} style="display:{display_access_log_button}"> 
    118123                        <td><input type='button' {disabled} {disabled_access_button} value='{lang_show_access_logs}' onclick="document.location.href='./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_access_log&account_id={uidnumber}';"></td> 
  • trunk/expressoAdmin1_2/templates/default/sectors.tpl

    r414 r548  
    1717 </table> 
    1818  
    19  <table border="0" width="55%" align="center"> 
     19 <table border="0" width="65%" align="center"> 
    2020  <tr bgcolor="{th_bg}"> 
    2121   <td>{lang_name}</td> 
     22   <td>{lang_inatives}</td> 
    2223   <td>{lang_add_sub_sectors}</td> 
    2324   <td>{lang_edit}</td> 
     
    3132 <tr bgcolor="{tr_color}"> 
    3233  <td>{sector_name}</td> 
     34  <td width="13%">{inatives_link}</td>   
    3335  <td width="25%">{add_link}</td> 
    3436  <td width="5%">{edit_link}</td> 
  • trunk/phpgwapi/inc/class.sessions.inc.php

    r370 r548  
    520520                        } 
    521521 
     522                        if($this->account_id!=null) { 
     523                                $last_access = $this->get_last_access_on_history($this->account_id); 
     524                                //echo $last_access+($current_config["time_to_account_expires"]*86400); 
     525                                //exit(0); 
     526                                 
     527                                $this->read_repositories(False); 
     528                                if((isset($GLOBALS['phpgw_info']['server']['time_to_account_expires'])) && ($last_access) && ($this->account_lid!="expresso-admin")) { 
     529                                        if ($last_access+($GLOBALS['phpgw_info']['server']['time_to_account_expires']*86400) < time()) 
     530                                        { 
     531                                                if(is_object($GLOBALS['phpgw']->log)) 
     532                                                { 
     533                                                        $GLOBALS['phpgw']->log->message(array( 
     534                                                                'text' => 'W-LoginFailure, account loginid %1 is expired for innativity', 
     535                                                                'p1'   => $this->account_lid, 
     536                                                                'line' => __LINE__, 
     537                                                                'file' => __FILE__ 
     538                                                        )); 
     539                                                        $GLOBALS['phpgw']->log->commit(); 
     540                                                } 
     541                                                $this->reason = 'account is expired'; 
     542                                                $this->cd_reason = 98; 
     543                 
     544                                                return False; 
     545                                        } 
     546                                } 
     547                        } 
     548 
    522549                        /* jakjr: Expresso does not use auto-create account. 
    523550                        if (!$this->account_id && $GLOBALS['phpgw_info']['server']['auto_create_acct'] == True) 
     
    597624 
    598625                        return $this->sessionid; 
     626                } 
     627 
     628                /** 
     629                  * Retorna o UNIX DATE do ultimo acesso dessa conta, baseado na tabela de histórico. 
     630                  */ 
     631                function get_last_access_on_history($account_id) { 
     632                        $GLOBALS['phpgw']->db->query("select li from phpgw_access_log where account_id='$account_id' order by li desc limit 1",__LINE__,__FILE__); 
     633                        if(!$GLOBALS['phpgw']->db->next_record()) 
     634                                return false; 
     635                        return $GLOBALS['phpgw']->db->f('li'); 
    599636                } 
    600637 
Note: See TracChangeset for help on using the changeset viewer.