Changeset 1516 for trunk/expressoAdmin1_2
- Timestamp:
- 10/20/09 10:46:34 (15 years ago)
- Location:
- trunk/expressoAdmin1_2
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.bosectors.inc.php
r1391 r1516 48 48 $sector_info['objectClass'][1] = 'organizationalUnit'; 49 49 50 /*Insere as informações sobre quota total por usuários e por gigabytes de espaço em disco 51 Se não vierem os dados, ele coloca 0 (Caso não exista controle de cota). 52 */ 53 $sector_info['diskQuota'] = isset($_POST['disk_quota']) ? $_POST['disk_quota'] : "0"; 54 $sector_info['usersQuota'] = isset($_POST['users_quota']) ? $_POST['users_quota'] : "0"; 55 56 50 57 $systemName = $GLOBALS['phpgw_info']['server']['system_name']; 51 58 if ($systemName != '') … … 96 103 $this->so->add_attribute($sector_info[0]['dn'], $ldap_mod_add); 97 104 } 98 else 105 elseif($sector_info['phpgwaccountvisible'] == '-1') 99 106 { 100 107 $ldap_mod_del['objectClass'] = 'phpgwAccount'; 101 108 $ldap_mod_del['phpgwaccountvisible'] = array(); 102 109 $this->so->remove_attribute($sector_info[0]['dn'], $ldap_mod_del); 110 } 111 112 //Modifica o conteúdo das cotas. 113 if( (isset($_POST['disk_quota']) ) && (isset($_POST['users_quota']) ) ) { //se for passado alguma coisa, lógico 114 $ldap_mod_replace = array(); 115 $ldap_mod_replace['diskQuota'] = $_POST['disk_quota']; 116 $ldap_mod_replace['usersQuota'] = $_POST['users_quota']; 117 $this->so->replace_attribute($sector_info[0]['dn'], $ldap_mod_replace); 103 118 } 104 119 -
trunk/expressoAdmin1_2/inc/class.db_functions.inc.php
r597 r1516 39 39 return $result; 40 40 } 41 42 //returns true if cotas control property is set. 43 function use_cota_control() { 44 $query = "select * from phpgw_config where config_name='expressoAdmin_cotasOu' and config_value='true'"; 45 $this->db->query($query); 46 if($this->db->next_record()) 47 return true; 48 return false; 49 } 50 41 51 /* 42 52 * Reativa os usuários desabilitados por tempo inativo modificando o seu ultimo acesso para o dia atual. -
trunk/expressoAdmin1_2/inc/class.functions.inc.php
r597 r1516 522 522 $sectors_info = $s->get_organizations($context, $selected, $referral, $show_invisible_ou, $master); 523 523 return $sectors_info; 524 } 525 524 } 525 526 /* 527 Funciona de maneira similar ao get_sectors_list, porém retorna a propria OU do contexto 528 e monta o array de retorno de forma diferente, necessário para algumas mudanças implementadas 529 no método admin.uisectors.list_sectors. 530 */ 531 function get_organizations2($contexts, $selected='', $referral=false, $show_invisible_ou=true) { 532 533 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 534 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 535 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 536 537 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 538 539 if ($referral) 540 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 541 else 542 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 543 544 ldap_bind($ldap_conn,$dn,$passwd); 545 546 $justthese = array("dn","diskQuota","usersQuota","actualDiskQuota"); 547 $filter = "(ou=*)"; 548 foreach ($contexts as $context) { 549 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 550 551 ldap_sort($ldap_conn, $search, "ou"); 552 $info = ldap_get_entries($ldap_conn, $search); 553 ldap_close($ldap_conn); 554 555 // Retiro o count do array info e inverto o array para ordenaçãoo. 556 for ($i=0; $i<$info["count"]; $i++) 557 { 558 $dn = $info[$i]["dn"]; 559 560 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 561 //if (strtolower($dn) == $context) 562 //continue; 563 564 $array_dn = ldap_explode_dn ( $dn, 1 ); 565 566 $array_dn_reverse = array_reverse ( $array_dn, true ); 567 568 // Retirar o indice count do array. 569 array_pop ( $array_dn_reverse ); 570 571 $inverted_dn[implode ( "#", $array_dn_reverse )] = $info[$i]; 572 } 573 } 574 // Ordenação por chave 575 ksort($inverted_dn); 576 577 // Construção do select 578 $level = 0; 579 $options = array(); 580 foreach ($inverted_dn as $dn=>$info_ou) 581 { 582 $display = ''; 583 $info_retorno = array(); 584 $array_dn_reverse = explode ( "#", $dn ); 585 $array_dn = array_reverse ( $array_dn_reverse, true ); 586 587 $level = count( $array_dn ) - (int)(count(explode(",", $GLOBALS['phpgw_info']['server']['ldap_context'])) + 1); 588 589 if ($level == 0) 590 $display .= '+'; 591 else 592 { 593 for ($i=0; $i<$level; $i++) 594 $display .= '---'; 595 } 596 597 reset ( $array_dn ); 598 $display .= ' ' . (current ( $array_dn ) ); 599 600 $info_retorno['display'] = $display; 601 $info_retorno['dn'] = $info_ou['dn']; 602 $info_retorno['diskquota'] = $info_ou['diskquota'][0]; 603 $info_retorno['usersquota'] = $info_ou['usersquota'][0]; 604 // $info_retorno['actualdiskquota'] = round($this->get_actual_disk_usage($info_ou['dn']),2);//$info_ou['actualdiskquota'][0]; 605 // $info_retorno['actualnumusers'] = $this->get_num_users($info_ou['dn']); 606 607 array_push($options,$info_retorno); 608 609 } 610 return $options; 611 } 612 613 function get_info($context, $referral = false) { 614 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 615 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 616 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 617 618 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 619 620 if ($referral) 621 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 622 else 623 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 624 625 ldap_bind($ldap_conn,$dn,$passwd); 626 627 $filter="(objectClass=organizationalUnit)"; 628 $search=ldap_search($ldap_conn, $context, $filter); 629 $result = ldap_get_entries($ldap_conn, $search); 630 return $result; 631 632 } 633 634 function get_num_users($context,$selected='', $referral=false, $show_invisible_ou=true) { 635 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 636 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 637 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 638 639 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 640 641 if ($referral) 642 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 643 else 644 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 645 646 ldap_bind($ldap_conn,$dn,$passwd); 647 648 $justthese = array("dn"); 649 $filter = "(objectClass=inetOrgPerson)"; 650 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 651 652 $retorno = ldap_count_entries($ldap_conn, $search); 653 ldap_close($ldap_conn); 654 655 return $retorno; 656 } 657 658 //Checa se existe quota para mais um usuï¿œrio no setor... se existir retorna true, senï¿œo false. 659 function existe_quota_usuario($setor) { 660 $num_users = $this->get_num_users($setor['dn']); 661 //return $num_users . " --- " . $setor['usersquota'][0] 662 if(($num_users>=$setor['usersquota'][0]) && ($setor['usersquota'][0]!=-1)) { 663 return false; 664 } 665 return true; 666 } 667 668 //Checa se existe quota em disco para mais um usuï¿œrio no setor... se existir retorna true, senï¿œo false. 669 function existe_quota_disco($setor,$quota_novo_usuario) { 670 settype($quota_novo_usuario,"float"); 671 $quota_novo_usuario /= 1024; //A quota vï¿œm da interface em megabytes, deve se tornar gigabyte. 672 673 $nova_quota = $this->get_actual_disk_usage($setor['dn']) + $quota_novo_usuario; 674 if(( $nova_quota >= $setor['diskquota'][0] ) && ($setor['diskquota'][0] != -1)) { 675 return false; 676 } 677 return true; 678 } 679 680 // Soma as quotas de todos os usuï¿œrios daquele contexto. 681 function get_actual_disk_usage($context) { 682 $quota_usada=0; 683 $contexts = array($context); 684 $usuarios = $this->get_list('accounts', '', $contexts); 685 686 $imap_functions = new imap_functions(); 687 foreach($usuarios as $usuario) { 688 $temp = $imap_functions->get_user_info($usuario['account_lid']); 689 if($temp['mailquota'] != -1) //Usuï¿œrio sem cota nï¿œo conta... 690 $quota_usada += ($temp['mailquota'] / 1024); 691 } 692 return $quota_usada; 693 } 694 526 695 function get_sectors($selected='', $referral=false, $show_invisible_ou=true) 527 696 { -
trunk/expressoAdmin1_2/inc/class.sosectors.inc.php
r1394 r1516 130 130 } 131 131 } 132 133 function replace_attribute($dn, $info) 134 { 135 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 136 137 if (ldap_mod_replace($connection, $dn, $info)) 138 { 139 ldap_close($connection); 140 return true; 141 } 142 else 143 { 144 echo 'Erro na escrita no LDAP, funcao replace_attribute: ' . ldap_error($connection); 145 ldap_close($connection); 146 return false; 147 } 148 } 132 149 133 150 function remove_attribute($dn, $info) -
trunk/expressoAdmin1_2/inc/class.uisectors.inc.php
r1394 r1516 20 20 'validate_data_sectors_edit' => True, 21 21 'delete_sector' => True, 22 'css' => True 22 'css' => True, 23 'view_cota' => True 23 24 ); 24 25 … … 63 64 $p->set_block('sectors','row_empty','row_empty'); 64 65 65 $sectors_info = $this->functions->get_sectors_list($contexts); 66 //$sectors_info = $this->functions->get_sectors_list($contexts); 67 $sectors_info = $this->functions->get_organizations2($contexts); 66 68 67 69 $var = Array( … … 69 71 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 70 72 'context_display' => $context_display, 71 'lang_inactives' => lang('list inactives') 73 'lang_inactives' => lang('list inactives'), 74 'lang_ver_cota' => lang('view cota') 72 75 ); 73 76 $p->set_var($var); … … 97 100 $var = Array( 98 101 'tr_color' => $tr_color, 99 'sector_name' => $sector, 100 'add_link' => $this->row_action('add','sector',$context) 102 'sector_name' => $sector['display'], 103 'cota_link' => $this->row_action('view','cota',$sector['dn']), 104 'add_link' => $this->row_action('add','sector',$sector['dn']) 101 105 ); 102 106 if(isset($GLOBALS['phpgw_info']['server']['time_to_account_expires'])) 103 $var['inactives_link'] = $this->row_action('list_inactive','users',$ context,'uiaccounts');107 $var['inactives_link'] = $this->row_action('list_inactive','users',$sector['dn'],'uiaccounts'); 104 108 else 105 109 $var['inactives_link'] = lang('disabled'); … … 109 113 if ($can_edit) 110 114 { 111 $p->set_var('edit_link',$this->row_action('edit','sector',$ context));115 $p->set_var('edit_link',$this->row_action('edit','sector',$sector['dn'])); 112 116 } 113 117 else … … 118 122 if ($can_delete) 119 123 { 120 $p->set_var('delete_link',$this->row_action('delete','sector',$ context));124 $p->set_var('delete_link',$this->row_action('delete','sector',$sector['dn'])); 121 125 } 122 126 else … … 185 189 'context' => $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context, 186 190 'sector' => $_POST['sector'], 191 'disk_quota' => $_POST['disk_quota'], 192 'users_quota' => $_POST['users_quota'], 187 193 'manager_org' => $combo_manager_org, 188 194 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', 189 195 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 190 196 ); 197 198 if($this->functions->db_functions->use_cota_control()) { 199 $var["open_comment_cotas"] = ""; 200 $var["close_comment_cotas"] =""; 201 } 202 else { 203 $var["open_comment_cotas"] = "<!--"; 204 $var["close_comment_cotas"] ="-->"; 205 } 206 191 207 $p->set_var($var); 192 208 $p->set_var($this->functions->make_dinamic_lang($p, 'list')); … … 228 244 { 229 245 $sector_info = $this->so->get_info($context); 246 $sector_disk_quota = $sector_info[0]['diskquota'][0]; 247 $sector_users_quota = $sector_info[0]['usersquota'][0]; 230 248 $_POST['sector_visible'] = $sector_info[0]['phpgwaccountvisible'][0]; 231 249 } … … 240 258 'manager_org' => $combo_manager_org, 241 259 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', 260 'disk_quota' => $_POST['disk_quota'] == '' ? $sector_disk_quota : $_POST['disk_quota'], 261 'users_quota' => $_POST['users_quota'] == '' ? $sector_users_quota : $_POST['users_quota'], 242 262 243 263 'lang_add' => lang('Add'), 244 264 'disable' => 'disabled', 245 265 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 246 ); 266 'lang_disk_quota' => lang('disk quota'), 267 'lang_users_quota' => lang('users quota') 268 ); 269 if($this->functions->db_functions->use_cota_control()) { 270 $var["open_comment_cotas"] = ""; 271 $var["close_comment_cotas"] =""; 272 } 273 else { 274 $var["open_comment_cotas"] = "<!--"; 275 $var["close_comment_cotas"] ="-->"; 276 } 247 277 $p->set_var($var); 248 278 $p->set_var($this->functions->make_dinamic_lang($p, 'list')); … … 250 280 $p->pfp('out','edit_sector'); 251 281 } 282 283 function view_cota() 284 { 285 $context = $_GET['context']; 286 $a_tmp = explode(",", ldap_dn2ufn($context)); 287 288 $sector_name = $a_tmp[0]; 289 if($this->functions->db_functions->use_cota_control()) { 290 $sector_info = $this->so->get_info($context); 291 $sector_disk_cota = $sector_info[0]['diskquota'][0]; 292 $sector_users_cota = $sector_info[0]['usersquota'][0]; 293 } 294 else { 295 $sector_disk_cota = lang('cotas control disabled'); 296 $sector_users_cota = lang('cotas control disabled'); 297 } 298 299 300 unset($GLOBALS['phpgw_info']['flags']['noheader']); 301 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 302 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sector'); 303 $GLOBALS['phpgw']->common->phpgw_header(); 304 305 // Set o template 306 $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 307 $p->set_file(Array('ver_cota' => 'sectors_cota.tpl')); 308 309 310 // Seta variaveis utilizadas pelo tpl. 311 $var = Array( 312 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), 313 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 314 'context' => $context, 315 'sector' => $sector_name, 316 'disk_cota' => $sector_disk_cota, 317 'users_cota' => $sector_users_cota, 318 'actual_users' => $this->functions->get_num_users($context), 319 'actual_disk' => round($this->functions->get_actual_disk_usage($context),2), 320 321 'lang_back' => lang('Back'), 322 'lang_context' => lang('Context'), 323 'lang_sector_name' => lang('Sector name'), 324 'lang_disk_cota' => lang('disk usage cota'), 325 'lang_users_cota' => lang('user number cota'), 326 'lang_user_number' => lang('user number'), 327 'lang_disk_used' => lang('disk usage'), 328 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", 329 ); 330 $p->set_var($var); 331 332 $p->pfp('out','ver_cota'); 333 } 252 334 253 335 function validate_data_sectors_add() -
trunk/expressoAdmin1_2/inc/class.user.inc.php
r621 r1516 36 36 $return['status'] = true; 37 37 38 if($this->db_functions->use_cota_control()) { 39 //Verifica quota de usuários e disco 40 $setor = $this->functions->get_info($params['context']); 41 if (!$this->functions->existe_quota_usuario($setor[0])) { 42 $return['status'] = false; 43 $return['msg'] = $this->functions->lang("user cota exceeded");//TODO colocar valor de acordo com tabela de traduções. 44 return $return; 45 } 46 if (!$this->functions->existe_quota_disco($setor[0],$params['mailquota'])) { 47 $return['status'] = false; 48 $return['msg'] = $this->functions->lang("disk cota exceeded");//TODO colocar valor de acordo com tabela de traduções. 49 return $return; 50 } 51 } 52 38 53 // Verifica o acesso do gerente 39 54 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'add_users')) … … 303 318 */ 304 319 320 //Verifica quota de disco, como estou alterando, não preciso checar quota de usuários. 321 if($this->db_functions->use_cota_control()) { 322 $setor = $this->functions->get_info($new_values['context']); 323 if (!$this->functions->existe_quota_disco($setor[0],$new_values['mailquota'])) { 324 $return['status'] = false; 325 $return['msg'] = "Quota em disco excedida...";//TODO colocar valor de acordo com tabela de traduções. 326 return $return; 327 } 328 } 329 305 330 $manager_account_lid = $_SESSION['phpgw_session']['session_lid']; 306 331 if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && -
trunk/expressoAdmin1_2/templates/default/config.tpl
r594 r1516 162 162 <td><span>{lang_Result}: </span><span id="nextid_db_result"></span></td> 163 163 </tr> 164 <tr class="row_off"> 165 <td>{lang_use_quotas_control_for_ou}</td> 166 <td> 167 <select name="newsettings[expressoAdmin_cotasOu]"> 168 <option value="">{lang_No}</option> 169 <option value="true"{selected_expressoAdmin_cotasOu_true}>{lang_Yes}</option> 170 </select> 171 </td> 172 </tr> 164 173 <tr class="row_on"> 165 174 <td>{lang_use_login_generator}</td> -
trunk/expressoAdmin1_2/templates/default/sectors.tpl
r597 r1516 17 17 </table> 18 18 19 <table border="0" width=" 65%" align="center">19 <table border="0" width="70%" align="center"> 20 20 <tr bgcolor="{th_bg}"> 21 21 <td>{lang_name}</td> 22 22 <td>{lang_inactives}</td> 23 <td>{lang_ver_cota}</td> 23 24 <td>{lang_add_sub_sectors}</td> 24 25 <td>{lang_edit}</td> … … 32 33 <tr bgcolor="{tr_color}"> 33 34 <td>{sector_name}</td> 34 <td width="13%">{inactives_link}</td> 35 <td width="25%">{add_link}</td> 35 <td width="13%">{inactives_link}</td> 36 <td width="13%">{cota_link}</td> 37 <td width="12%">{add_link}</td> 36 38 <td width="5%">{edit_link}</td> 37 39 <td width="5%">{delete_link}</td> -
trunk/expressoAdmin1_2/templates/default/sectors_form.tpl
r1145 r1516 23 23 </td> 24 24 </tr> 25 {open_comment_cotas} 26 <tr> 27 <td> 28 {lang_users_quota}: 29 </td> 30 <td> 31 <input type="text" autocomplete="off" name="users_quota" value={users_quota}> 32 </td> 33 </tr> 34 35 <tr> 36 <td> 37 {lang_disk_quota}: 38 </td> 39 <td> 40 <input type="text" autocomplete="off" name="disk_quota" value={disk_quota}> 41 </td> 42 </tr> 43 {close_comment_cotas} 25 44 <tr> 26 45 <td>
Note: See TracChangeset
for help on using the changeset viewer.