[2] | 1 | <?php |
---|
| 2 | /***********************************************************************************\ |
---|
| 3 | * Expresso Administração * |
---|
| 4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
| 5 | * ---------------------------------------------------------------------------------* |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \***********************************************************************************/ |
---|
| 11 | |
---|
| 12 | class uicomputers |
---|
| 13 | { |
---|
| 14 | var $public_functions = array |
---|
| 15 | ( |
---|
| 16 | 'list_computers' => True, |
---|
| 17 | 'add_computer' => True, |
---|
| 18 | 'validade_computers_data_add' => True, |
---|
| 19 | 'edit_computer' => True, |
---|
| 20 | 'validade_computers_data_edit' => True, |
---|
| 21 | 'delete_computer' => True, |
---|
| 22 | 'css' => True |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | var $bo; |
---|
| 26 | var $nextmatchs; |
---|
| 27 | var $functions; |
---|
[27] | 28 | var $current_config; |
---|
| 29 | var $db_functions; |
---|
[2] | 30 | |
---|
| 31 | function uicomputers() |
---|
| 32 | { |
---|
| 33 | $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 34 | $this->bo = CreateObject('expressoAdmin1_2.bocomputers'); |
---|
| 35 | $this->so = $this->bo->so; |
---|
| 36 | $this->functions = $this->bo->functions; |
---|
[64] | 37 | $this->db_functions = $this->bo->db_functions; |
---|
[27] | 38 | |
---|
| 39 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
| 40 | $c->read_repository(); |
---|
| 41 | $this->current_config = $c->config_data; |
---|
[2] | 42 | } |
---|
| 43 | |
---|
| 44 | function list_computers() |
---|
| 45 | { |
---|
[64] | 46 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 47 | $manager_acl = $this->functions->read_acl($manager_lid); |
---|
| 48 | $manager_contexts = $manager_acl['contexts']; |
---|
| 49 | foreach ($manager_acl['contexts_display'] as $index=>$tmp_context) |
---|
| 50 | { |
---|
| 51 | $context_display .= '<br>'.$tmp_context; |
---|
| 52 | } |
---|
[2] | 53 | |
---|
| 54 | // Verifica se tem acesso a este modulo |
---|
[64] | 55 | if (!$this->functions->check_acl($manager_lid,'list_computers')) |
---|
[2] | 56 | { |
---|
| 57 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | if(isset($_POST['query'])) |
---|
| 61 | { |
---|
| 62 | // limit query to limit characters |
---|
| 63 | if(eregi('^[a-z_0-9_-].+$',$_POST['query'])) |
---|
| 64 | { |
---|
| 65 | $GLOBALS['query'] = $_POST['query']; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 70 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 71 | |
---|
| 72 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Computers'); |
---|
| 73 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 74 | |
---|
| 75 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 76 | $p->set_file(array('computers' => 'computers.tpl')); |
---|
| 77 | $p->set_block('computers','body','body'); |
---|
| 78 | $p->set_block('computers','row','row'); |
---|
| 79 | $p->set_block('computers','row_empty','row_empty'); |
---|
| 80 | |
---|
| 81 | // Seta as variaveis padroes. |
---|
| 82 | $var = Array( |
---|
| 83 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 84 | 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.add_computer'), |
---|
[64] | 85 | 'add_computers_disabled' => $this->functions->check_acl($manager_lid,'create_computers') ? '' : 'display:none', |
---|
[2] | 86 | 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), |
---|
| 87 | 'lang_back' => lang('Back'), |
---|
| 88 | 'context_display' => $context_display, |
---|
| 89 | 'lang_computers_uid' => lang('Computer UID'), |
---|
| 90 | 'lang_add_computers' => lang('Create Computers'), |
---|
| 91 | 'lang_description' => lang('Description'), |
---|
| 92 | 'lang_edit' => lang('Edit'), |
---|
| 93 | 'lang_delete' => lang('Delete'), |
---|
| 94 | 'lang_context' => lang('context'), |
---|
| 95 | 'lang_search' => lang('search') |
---|
| 96 | ); |
---|
| 97 | $p->set_var($var); |
---|
| 98 | |
---|
| 99 | // Save query |
---|
| 100 | $p->set_var('query', $GLOBALS['query']); |
---|
| 101 | |
---|
| 102 | //Admin make a search |
---|
| 103 | if ($GLOBALS['query'] != '') |
---|
| 104 | { |
---|
[64] | 105 | $computers_info = $this->functions->get_list('computers', $GLOBALS['query'], $manager_contexts); |
---|
[2] | 106 | } |
---|
| 107 | |
---|
| 108 | if (!count($computers_info) && $GLOBALS['query'] != '') |
---|
| 109 | { |
---|
| 110 | $p->set_var('message',lang('No matches found')); |
---|
| 111 | $p->parse('rows','row_empty',True); |
---|
| 112 | } |
---|
| 113 | else if (count($computers_info)) |
---|
| 114 | { |
---|
[64] | 115 | if ($this->functions->check_acl($manager_lid,'edit_computers')) |
---|
[2] | 116 | { |
---|
| 117 | $can_edit = True; |
---|
| 118 | } |
---|
[64] | 119 | if ($this->functions->check_acl($manager_lid,'delete_computers')) |
---|
[2] | 120 | { |
---|
| 121 | $can_delete = True; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | foreach($computers_info as $computer) |
---|
| 125 | { |
---|
| 126 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color); |
---|
| 127 | $var = array( |
---|
| 128 | 'tr_color' => $tr_color, |
---|
| 129 | 'row_cn' => $computer['cn'], |
---|
| 130 | 'row_description' => $computer['description'] |
---|
| 131 | ); |
---|
| 132 | $p->set_var($var); |
---|
| 133 | |
---|
| 134 | if ($can_edit) |
---|
| 135 | { |
---|
| 136 | $p->set_var('edit_link',$this->row_action('edit','computer',$computer['uidNumber'])); |
---|
| 137 | } |
---|
| 138 | else |
---|
| 139 | { |
---|
| 140 | $p->set_var('edit_link',' '); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | if ($can_delete) |
---|
| 144 | { |
---|
| 145 | $p->set_var('delete_link',$this->row_action('delete','computer',$computer['uidNumber'])); |
---|
| 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | $p->set_var('delete_link',' '); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | $p->fp('rows','row',True); |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | $p->set_var($var); |
---|
| 156 | $p->pfp('out','body'); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | function add_computer() |
---|
| 160 | { |
---|
[64] | 161 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 162 | $manager_acl = $this->functions->read_acl($manager_lid); |
---|
| 163 | $manager_contexts = $manager_acl['contexts']; |
---|
[2] | 164 | |
---|
| 165 | // Verifica se tem acesso a este modulo |
---|
[64] | 166 | if (!$this->functions->check_acl($manager_lid,'create_computers')) |
---|
[2] | 167 | { |
---|
| 168 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 172 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 173 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Computers'); |
---|
| 174 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 175 | |
---|
| 176 | // Set o template |
---|
| 177 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 178 | $p->set_file(Array('create_email_list' => 'computers_form.tpl')); |
---|
| 179 | |
---|
| 180 | // Inclue na combo, os usuarios previamente selecionados no caso de um erro na validacao dos dados. |
---|
| 181 | $users_in_list = ''; |
---|
| 182 | if (count($_POST['email_list_users']) != 0) |
---|
| 183 | { |
---|
| 184 | foreach ($_POST['email_list_users'] as $user_data) |
---|
| 185 | { |
---|
| 186 | $tmp = explode("|", $user_data); |
---|
| 187 | $user_cn = $tmp[0]; |
---|
| 188 | $user_email = $tmp[1]; |
---|
| 189 | $users_in_list .= '<option value="'.$user_data.'">'.$user_cn. ' (' . $user_email . ')' . '</option>'; |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
[64] | 193 | foreach ($manager_contexts as $index=>$context) |
---|
| 194 | $sectors .= $this->functions->get_organizations($context); |
---|
[2] | 195 | |
---|
[27] | 196 | // Cria combo de dominio samba |
---|
| 197 | if ($this->current_config['expressoAdmin_samba_support'] == 'true') |
---|
| 198 | { |
---|
| 199 | $a_sambadomains = $this->db_functions->get_sambadomains_list(); |
---|
| 200 | $sambadomainname_options = ''; |
---|
| 201 | if (count($a_sambadomains)) |
---|
| 202 | { |
---|
| 203 | foreach ($a_sambadomains as $a_sambadomain) |
---|
| 204 | { |
---|
| 205 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | |
---|
[2] | 210 | // Seta variaveis utilizadas pelo tpl. |
---|
| 211 | $var = Array( |
---|
| 212 | // LINKS |
---|
| 213 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.list_computers'), |
---|
| 214 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.validade_computers_data_add'), |
---|
| 215 | |
---|
| 216 | 'combo_sectors' => $sectors, |
---|
| 217 | 'row_on' => "#DDDDDD", |
---|
| 218 | 'row_off' => "#EEEEEE", |
---|
| 219 | 'color_bg1' => "#E8F0F0", |
---|
| 220 | 'lang_back' => lang('Back'), |
---|
| 221 | 'lang_save' => lang('save'), |
---|
| 222 | 'lang_sectors' => lang('Sectors'), |
---|
[27] | 223 | 'lang_sambadomain' => lang('Domain'), |
---|
| 224 | |
---|
[2] | 225 | 'lang_computer_cn' => lang('Computer UID'), |
---|
| 226 | 'lang_computer_description' => lang('Description'), |
---|
| 227 | 'lang_computer_type' => lang('Computer Type'), |
---|
| 228 | |
---|
| 229 | 'lang_active_workstation' => lang('WorkStation Active'), |
---|
| 230 | 'lang_desactive_workstation' => lang('WorkStation Desactive'), |
---|
| 231 | 'lang_trust_account' => lang('Trust Account'), |
---|
| 232 | 'lang_server' => lang('Server'), |
---|
| 233 | 'lang_computer_password' => lang('Computer password'), |
---|
| 234 | |
---|
| 235 | 'display_tr_computer_password' => $_POST['sambaAcctFlags'] == '[I ]' ? '' : 'display:none', |
---|
| 236 | |
---|
[27] | 237 | 'sambadomainname_options' => $sambadomainname_options, |
---|
| 238 | |
---|
[2] | 239 | // Retorna os valores, quando da um erro na validação. |
---|
| 240 | 'computer_cn' => $_POST['computer_cn'], |
---|
| 241 | 'computer_description' => $_POST['computer_description'], |
---|
| 242 | |
---|
| 243 | // Quando for edit, passa o id do grupo, quando for para criar um grupo novo, passa vazio. |
---|
| 244 | 'hidden_vars' => '<input type="hidden" name="uidnumber" value="">', |
---|
| 245 | 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>" |
---|
| 246 | ); |
---|
| 247 | $p->set_var($var); |
---|
| 248 | |
---|
| 249 | if ($_POST['sambaAcctFlags'] != '') |
---|
| 250 | { |
---|
| 251 | switch($_POST['sambaAcctFlags']) |
---|
| 252 | { |
---|
| 253 | case '[W ]': |
---|
| 254 | $p->set_var('active_workstation_selected', 'selected'); |
---|
| 255 | break; |
---|
| 256 | case '[DW ]': |
---|
| 257 | $p->set_var('desactive_workstation_selected', 'selected'); |
---|
| 258 | break; |
---|
| 259 | case '[I ]': |
---|
| 260 | $p->set_var('trust_account_selected', 'selected'); |
---|
| 261 | break; |
---|
| 262 | case '[S ]': |
---|
| 263 | $p->set_var('server_selected', 'selected'); |
---|
| 264 | break; |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | $p->pfp('out','create_email_list'); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | function validade_computers_data_add() |
---|
| 272 | { |
---|
| 273 | if (($_POST['sambaAcctFlags'] == '[I ]') && ($_POST['computer_password'] == '')) |
---|
| 274 | { |
---|
| 275 | $_POST['error_messages'] = lang('Computer password is empty.'); |
---|
| 276 | ExecMethod('expressoAdmin1_2.uicomputers.add_computer'); |
---|
| 277 | return; |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | $computer_cn = $_POST['computer_cn']; |
---|
| 281 | |
---|
| 282 | // Verifica se o uid do computador nao esta vazio. |
---|
| 283 | if ($computer_cn == '') |
---|
| 284 | { |
---|
| 285 | $_POST['error_messages'] = lang('Computer UID is empty.'); |
---|
| 286 | ExecMethod('expressoAdmin1_2.uicomputers.add_computer'); |
---|
| 287 | return; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | // Verifica se o nome do computaor existe no contexto atual. |
---|
| 291 | if ($this->so->exist_computer_uid($computer_cn)) |
---|
| 292 | { |
---|
| 293 | $_POST['error_messages'] = lang('Computer UID already exist.'); |
---|
| 294 | ExecMethod('expressoAdmin1_2.uicomputers.add_computer'); |
---|
| 295 | return; |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | ExecMethod('expressoAdmin1_2.bocomputers.create_computer'); |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | function edit_computer() |
---|
| 303 | { |
---|
[64] | 304 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 305 | $manager_acl = $this->functions->read_acl($manager_lid); |
---|
| 306 | $manager_contexts = $manager_acl['contexts']; |
---|
[2] | 307 | |
---|
| 308 | // Verifica se tem acesso a este modulo |
---|
[64] | 309 | if (!$this->functions->check_acl($manager_lid,'edit_computers')) |
---|
[2] | 310 | { |
---|
| 311 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 312 | } |
---|
| 313 | |
---|
[64] | 314 | // Set o header |
---|
[2] | 315 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 316 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 317 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Computer'); |
---|
| 318 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 319 | |
---|
| 320 | // Set o template |
---|
| 321 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 322 | $p->set_file(Array('edit_computers' => 'computers_form.tpl')); |
---|
| 323 | |
---|
| 324 | //O POST esta vazio, oq indica que precisamos recuperar os dados do computador no ldap. |
---|
| 325 | if ($_POST['try_saved'] != 'true') |
---|
[27] | 326 | { |
---|
[2] | 327 | $uidnumber = $_GET['uidnumber']; |
---|
[64] | 328 | $computer_data = $this->so->get_computer_data($uidnumber); |
---|
[2] | 329 | |
---|
[64] | 330 | // Gera combo sectors |
---|
| 331 | foreach ($manager_contexts as $index=>$context) |
---|
| 332 | $sectors .= $this->functions->get_organizations($context, trim(strtolower($computer_data['context']))); |
---|
[2] | 333 | |
---|
[27] | 334 | // Cria combo de dominios do samba |
---|
| 335 | if ($this->current_config['expressoAdmin_samba_support'] == 'true') |
---|
| 336 | { |
---|
| 337 | $a_sambadomains = $this->db_functions->get_sambadomains_list(); |
---|
| 338 | $sambadomainname_options = ''; |
---|
| 339 | if (count($a_sambadomains)) |
---|
| 340 | { |
---|
| 341 | foreach ($a_sambadomains as $a_sambadomain) |
---|
| 342 | { |
---|
| 343 | if ($a_sambadomain['samba_domain_sid'] == $computer_data['sambasid']) |
---|
| 344 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
| 345 | else |
---|
| 346 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | |
---|
[2] | 351 | // Salva valores antigos |
---|
| 352 | $var = Array( |
---|
| 353 | 'uidnumber' => $uidnumber, |
---|
| 354 | 'old_computer_cn' => $computer_data['computer_cn'], |
---|
| 355 | 'old_computer_dn' => $computer_data['dn'], |
---|
| 356 | 'old_computer_sambaAcctFlags' => $computer_data['sambaAcctFlags'], |
---|
| 357 | 'old_computer_description' => $computer_data['computer_description'], |
---|
| 358 | 'old_computer_context' => $computer_data['context'], |
---|
[27] | 359 | 'old_sambasid' => $computer_data['sambasid'], |
---|
[2] | 360 | |
---|
| 361 | 'row_on' => "#DDDDDD", |
---|
| 362 | 'row_off' => "#EEEEEE", |
---|
| 363 | 'color_bg1' => "#E8F0F0", |
---|
| 364 | 'lang_back' => lang('Back'), |
---|
| 365 | 'lang_save' => lang('save'), |
---|
| 366 | 'lang_sectors' => lang('Sectors'), |
---|
[27] | 367 | 'lang_sambadomain' => lang('Domain'), |
---|
[2] | 368 | 'lang_computer_cn' => lang('Computer UID'), |
---|
| 369 | 'lang_computer_description' => lang('Description'), |
---|
| 370 | 'lang_computer_type' => lang('Computer Type'), |
---|
| 371 | 'lang_active_workstation' => lang('WorkStation Active'), |
---|
| 372 | 'lang_desactive_workstation' => lang('WorkStation Desactive'), |
---|
| 373 | 'lang_trust_account' => lang('Trust Account'), |
---|
| 374 | 'lang_server' => lang('Server'), |
---|
| 375 | 'lang_computer_password' => lang('Computer password'), |
---|
| 376 | |
---|
| 377 | 'display_tr_computer_password' => $computer_data['sambaAcctFlags'] == '[I ]' ? '' : 'display:none', |
---|
| 378 | |
---|
| 379 | 'computer_cn' => $computer_data['computer_cn'], |
---|
| 380 | 'computer_dn' => $computer_data['dn'], |
---|
| 381 | 'computer_description' => $computer_data['computer_description'], |
---|
| 382 | 'combo_sectors' => $sectors, |
---|
[27] | 383 | 'sambadomainname_options' => $sambadomainname_options, |
---|
[2] | 384 | |
---|
| 385 | // LINKS |
---|
| 386 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.list_computers'), |
---|
| 387 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.validade_computers_data_edit') |
---|
| 388 | ); |
---|
| 389 | $p->set_var($var); |
---|
| 390 | |
---|
| 391 | if ($computer_data['sambaAcctFlags'] != '') |
---|
| 392 | { |
---|
| 393 | switch($computer_data['sambaAcctFlags']) |
---|
| 394 | { |
---|
| 395 | case '[W ]': |
---|
| 396 | $p->set_var('active_workstation_selected', 'selected'); |
---|
| 397 | break; |
---|
| 398 | case '[DW ]': |
---|
| 399 | $p->set_var('desactive_workstation_selected', 'selected'); |
---|
| 400 | break; |
---|
| 401 | case '[I ]': |
---|
| 402 | $p->set_var('trust_account_selected', 'selected'); |
---|
| 403 | break; |
---|
| 404 | case '[S ]': |
---|
| 405 | $p->set_var('server_selected', 'selected'); |
---|
| 406 | break; |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | } |
---|
| 410 | else // DEMAIS VEZES |
---|
| 411 | { |
---|
| 412 | // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados. |
---|
[64] | 413 | foreach ($manager_contexts as $index=>$context) |
---|
| 414 | $sectors .= $this->functions->get_organizations($context, trim(strtolower($_POST['sector_context']))); |
---|
| 415 | //$sectors = $this->functions->get_organizations($manager_contexts); |
---|
[2] | 416 | |
---|
[27] | 417 | // Cria combo de dominios do samba |
---|
| 418 | if ($this->current_config['expressoAdmin_samba_support'] == 'true') |
---|
| 419 | { |
---|
| 420 | $a_sambadomains = $this->db_functions->get_sambadomains_list(); |
---|
| 421 | $sambadomainname_options = ''; |
---|
| 422 | if (count($a_sambadomains)) |
---|
| 423 | { |
---|
| 424 | foreach ($a_sambadomains as $a_sambadomain) |
---|
| 425 | { |
---|
| 426 | if ($a_sambadomain['samba_domain_sid'] == $_POST['sambasid']) |
---|
| 427 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
| 428 | else |
---|
| 429 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
| 430 | } |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | |
---|
[2] | 434 | $var = Array( |
---|
| 435 | // LINKS |
---|
| 436 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.list_computers'), |
---|
| 437 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.validade_computers_data_edit'), |
---|
| 438 | |
---|
| 439 | 'row_on' => "#DDDDDD", |
---|
| 440 | 'row_off' => "#EEEEEE", |
---|
| 441 | 'color_bg1' => "#E8F0F0", |
---|
| 442 | 'lang_back' => lang('Back'), |
---|
| 443 | 'lang_save' => lang('save'), |
---|
| 444 | 'lang_sectors' => lang('Sectors'), |
---|
[27] | 445 | 'lang_sambadomain' => lang('Domain'), |
---|
[2] | 446 | 'lang_computer_cn' => lang('Computer UID'), |
---|
| 447 | 'lang_computer_description' => lang('Description'), |
---|
| 448 | 'lang_computer_type' => lang('Computer Type'), |
---|
| 449 | 'lang_active_workstation' => lang('WorkStation Active'), |
---|
| 450 | 'lang_desactive_workstation' => lang('WorkStation Desactive'), |
---|
| 451 | 'lang_trust_account' => lang('Trust Account'), |
---|
| 452 | 'lang_server' => lang('Server'), |
---|
| 453 | 'lang_computer_password' => lang('Computer password'), |
---|
| 454 | |
---|
| 455 | // Retorna os valores, quando da um erro na validação. |
---|
| 456 | 'uidnumber' => $_POST['uidnumber'], |
---|
| 457 | 'error_messages' => $_POST['error_messages'] == '' ? '' : "<script type='text/javascript'>alert('".$_POST['error_messages']."')</script>", |
---|
| 458 | |
---|
| 459 | 'display_tr_computer_password' => $_POST['sambaAcctFlags'] == '[I ]' ? '' : 'display:none', |
---|
| 460 | |
---|
| 461 | // Retorna os valores, quando da um erro na validação. |
---|
| 462 | 'computer_cn' => $_POST['computer_cn'], |
---|
| 463 | 'computer_description' => $_POST['computer_description'], |
---|
| 464 | 'combo_sectors' => $sectors, |
---|
[27] | 465 | 'sambadomainname_options' => $sambadomainname_options, |
---|
[2] | 466 | |
---|
| 467 | // Valores que devem ser mantidos, aqui sao referenciados como old. |
---|
| 468 | 'old_computer_cn' => $_POST['old_computer_cn'], |
---|
| 469 | 'old_computer_dn' => $_POST['old_computer_dn'], |
---|
| 470 | 'old_computer_sambaAcctFlags' => $_POST['old_computer_sambaAcctFlags'], |
---|
| 471 | 'old_computer_description' => $_POST['old_computer_description'], |
---|
| 472 | 'old_computer_context' => $_POST['old_computer_context'], |
---|
[27] | 473 | 'old_sambasid' => $_POST['sambasid'] |
---|
[2] | 474 | ); |
---|
| 475 | $p->set_var($var); |
---|
| 476 | |
---|
| 477 | if ($_POST['sambaAcctFlags'] != '') |
---|
| 478 | { |
---|
| 479 | switch($_POST['sambaAcctFlags']) |
---|
| 480 | { |
---|
| 481 | case '[W ]': |
---|
| 482 | $p->set_var('active_workstation_selected', 'selected'); |
---|
| 483 | break; |
---|
| 484 | case '[DW ]': |
---|
| 485 | $p->set_var('desactive_workstation_selected', 'selected'); |
---|
| 486 | break; |
---|
| 487 | case '[I ]': |
---|
| 488 | $p->set_var('trust_account_selected', 'selected'); |
---|
| 489 | break; |
---|
| 490 | case '[S ]': |
---|
| 491 | $p->set_var('server_selected', 'selected'); |
---|
| 492 | break; |
---|
| 493 | } |
---|
| 494 | } |
---|
| 495 | } |
---|
| 496 | $p->pfp('out','edit_computers'); |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | function validade_computers_data_edit() |
---|
| 500 | { |
---|
| 501 | // Verifica se o uid do computador nao esta vazio. |
---|
| 502 | if ($_POST['computer_cn'] == '') |
---|
| 503 | { |
---|
| 504 | $_POST['error_messages'] = lang('Computer UID is empty.'); |
---|
| 505 | ExecMethod('expressoAdmin1_2.uicomputers.edit_computer'); |
---|
| 506 | return; |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | ExecMethod('expressoAdmin1_2.bocomputers.save_computer'); |
---|
| 510 | } |
---|
| 511 | |
---|
| 512 | function delete_computer() |
---|
| 513 | { |
---|
| 514 | //_debug_array($_GET); |
---|
| 515 | |
---|
| 516 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 517 | $acl = $this->functions->read_acl($account_lid); |
---|
| 518 | $manager_context = $acl[0]['context']; |
---|
| 519 | |
---|
| 520 | // Verifica se tem acesso a este modulo |
---|
| 521 | if (!$this->functions->check_acl($account_lid,'delete_computers')) |
---|
| 522 | { |
---|
| 523 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 527 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 528 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Delete Computer'); |
---|
| 529 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 530 | |
---|
| 531 | // Set o template |
---|
| 532 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 533 | $p->set_file(Array('delete_computer' => 'computers_delete.tpl')); |
---|
| 534 | |
---|
| 535 | // Get group data |
---|
| 536 | $uidnumber = $_GET['uidnumber']; |
---|
| 537 | $computer_data = $this->so->get_computer_data($uidnumber, $manager_context); |
---|
| 538 | |
---|
| 539 | // Seta variaveis utilizadas pelo tpl. |
---|
| 540 | $var = Array( |
---|
| 541 | 'color_bg1' => "#E8F0F0", |
---|
| 542 | 'lang_back' => lang('Back'), |
---|
| 543 | 'lang_delete' => lang('Delete'), |
---|
| 544 | 'lang_delete_computer' => lang('Do you realy want delete this Computer?'), |
---|
| 545 | 'dn' => $email_list_data['dn'], |
---|
| 546 | 'computer_cn' => $computer_data['computer_cn'], |
---|
| 547 | 'computer_dn' => $computer_data['dn'], |
---|
| 548 | 'computer_description' => $computer_data['computer_description'], |
---|
| 549 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.list_computers'), |
---|
| 550 | 'delete_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.bocomputers.delete_computer'), |
---|
| 551 | ); |
---|
| 552 | $p->set_var($var); |
---|
| 553 | $p->pfp('out','delete_computer'); |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | function row_action($action,$type,$uidNumber) |
---|
| 557 | { |
---|
| 558 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
| 559 | 'menuaction' => 'expressoAdmin1_2.uicomputers.'.$action.'_'.$type, |
---|
| 560 | 'uidnumber' => $uidNumber |
---|
| 561 | )).'"> '.lang($action).' </a>'; |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | function css() |
---|
| 565 | { |
---|
| 566 | $appCSS = ''; |
---|
| 567 | return $appCSS; |
---|
| 568 | } |
---|
| 569 | } |
---|
| 570 | ?> |
---|