[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /***************************************************************************\ 3 * EGroupWare - EMailAdmin * 4 * http://www.egroupware.org * 5 * Written by : Lars Kneschke [lkneschke@egroupware.org] * 6 * ------------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \***************************************************************************/ 12 /* $Id: class.ui.inc.php 20261 2006-01-22 17:59:06Z lkneschke $ */ 13 14 class ui 15 { 16 17 var $public_functions = array 18 ( 19 'addProfile' => True, 20 'css' => True, 21 'deleteProfile' => True, 22 'editProfile' => True, 23 'listProfiles' => True, 24 'saveProfile' => True 25 ); 26 27 var $cats; 28 var $nextmatchs; 29 var $t; 30 var $boqmailldap; 31 32 function ui() 33 { 34 $this->nextmatchs =& CreateObject('phpgwapi.nextmatchs'); 35 $this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL); 36 $this->boemailadmin =& CreateObject('emailadmin.bo'); 37 } 38 39 function addProfile() 40 { 41 $allGroups = $GLOBALS['egw']->accounts->get_list('groups'); 42 foreach($allGroups as $groupInfo) 43 { 44 $groups[$groupInfo['account_id']] = $groupInfo['account_lid']; 45 } 46 asort($groups); 47 48 $allGroups = array('' => lang('any group')); 49 foreach($groups as $groupID => $groupName) 50 { 51 $allGroups[$groupID] = $groupName; 52 } 53 54 $applications = array( 55 'calendar' => $GLOBALS['egw_info']['apps']['calendar']['title'], 56 'felamimail' => $GLOBALS['egw_info']['apps']['felamimail']['title'], 57 ); 58 asort($applications); 59 $applications = array_merge(array('' => lang('any application')),$applications); 60 61 $this->display_app_header(); 62 63 $this->t->set_file(array("body" => "editprofile.tpl")); 64 $this->t->set_block('body','main'); 65 66 $this->translate(); 67 68 #$this->t->set_var('profile_name',$profileList[0]['description']); 69 $this->t->set_var('smtpActiveTab','1'); 70 $this->t->set_var('imapActiveTab','1'); 71 $this->t->set_var('application_select_box', $GLOBALS['egw']->html->select('globalsettings[ea_appname]','',$applications, true, "style='width: 250px;'")); 72 $this->t->set_var('group_select_box', $GLOBALS['egw']->html->select('globalsettings[ea_group]','',$allGroups, true, "style='width: 250px;'")); 73 74 $linkData = array 75 ( 76 'menuaction' => 'emailadmin.ui.saveProfile' 77 ); 78 $this->t->set_var('action_url',$GLOBALS['egw']->link('/index.php',$linkData)); 79 80 $linkData = array 81 ( 82 'menuaction' => 'emailadmin.ui.listProfiles' 83 ); 84 $this->t->set_var('back_url',$GLOBALS['egw']->link('/index.php',$linkData)); 85 86 foreach($this->boemailadmin->getSMTPServerTypes() as $key => $value) 87 { 88 $this->t->set_var("lang_smtp_option_$key",$value); 89 }; 90 91 foreach($this->boemailadmin->getIMAPServerTypes() as $key => $value) 92 { 93 $this->t->set_var("lang_imap_option_$key",$value['description']); 94 }; 95 96 $this->t->parse("out","main"); 97 print $this->t->get('out','main'); 98 } 99 100 function css() 101 { 102 $appCSS = 103 'th.activetab 104 { 105 color:#000000; 106 background-color:#D3DCE3; 107 border-top-width : 1px; 108 border-top-style : solid; 109 border-top-color : Black; 110 border-left-width : 1px; 111 border-left-style : solid; 112 border-left-color : Black; 113 border-right-width : 1px; 114 border-right-style : solid; 115 border-right-color : Black; 116 } 117 118 th.inactivetab 119 { 120 color:#000000; 121 background-color:#E8F0F0; 122 border-bottom-width : 1px; 123 border-bottom-style : solid; 124 border-bottom-color : Black; 125 } 126 127 .td_left { border-left : 1px solid Gray; border-top : 1px solid Gray; } 128 .td_right { border-right : 1px solid Gray; border-top : 1px solid Gray; } 129 130 div.activetab{ display:inline; } 131 div.inactivetab{ display:none; }'; 132 133 return $appCSS; 134 } 135 136 function deleteProfile() 137 { 138 $this->boemailadmin->deleteProfile($_GET['profileid']); 139 $this->listProfiles(); 140 } 141 142 function display_app_header() 143 { 144 if(!@is_object($GLOBALS['egw']->js)) 145 { 146 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 147 } 148 $GLOBALS['egw']->js->validate_file('tabs','tabs'); 149 $GLOBALS['egw_info']['flags']['include_xajax'] = True; 150 151 switch($_GET['menuaction']) 152 { 153 case 'emailadmin.ui.addProfile': 154 case 'emailadmin.ui.editProfile': 155 $GLOBALS['egw_info']['nofooter'] = true; 156 $GLOBALS['egw']->js->validate_file('jscode','editProfile','emailadmin'); 157 $GLOBALS['egw']->js->set_onload('javascript:initAll();'); 158 #$GLOBALS['egw']->js->set_onload('smtp.init();'); 159 160 break; 161 162 case 'emailadmin.ui.listProfiles': 163 $GLOBALS['egw']->js->validate_file('jscode','listProfile','emailadmin'); 164 165 break; 166 } 167 $GLOBALS['egw']->common->egw_header(); 168 169 if($_GET['menuaction'] == 'emailadmin.ui.listProfiles' || $_GET['menuaction'] == 'emailadmin.ui.deleteProfile') 170 echo parse_navbar(); 171 } 172 173 function editProfile($_profileID='') 174 { 175 $allGroups = $GLOBALS['egw']->accounts->get_list('groups'); 176 foreach($allGroups as $groupInfo) 177 { 178 $groups[$groupInfo['account_id']] = $groupInfo['account_lid']; 179 } 180 asort($groups); 181 182 $allGroups = array('' => lang('any group')); 183 foreach($groups as $groupID => $groupName) 184 { 185 $allGroups[$groupID] = $groupName; 186 } 187 188 $applications = array( 189 'calendar' => $GLOBALS['egw_info']['apps']['calendar']['title'], 190 'felamimail' => $GLOBALS['egw_info']['apps']['felamimail']['title'], 191 ); 192 asort($applications); 193 $applications = array_merge(array('' => lang('any application')),$applications); 194 195 if($_profileID != '') 196 { 197 $profileID = $_profileID; 198 } 199 elseif(is_int(intval($_GET['profileid'])) && !empty($_GET['profileid'])) 200 { 201 $profileID = intval($_GET['profileid']); 202 } 203 else 204 { 205 return false; 206 } 207 208 $profileList = $this->boemailadmin->getProfileList($profileID); 209 $profileData = $this->boemailadmin->getProfile($profileID); 210 $this->display_app_header(); 211 212 $this->t->set_file(array("body" => "editprofile.tpl")); 213 $this->t->set_block('body','main'); 214 215 $this->translate(); 216 217 foreach((array)$profileData as $key => $value) 218 { 219 //print "$key $value<br>"; 220 switch($key) 221 { 222 case 'imapEnableCyrusAdmin': 223 case 'imapEnableSieve': 224 case 'imapTLSAuthentication': 225 case 'imapTLSEncryption': 226 case 'smtpAuth': 227 case 'smtpLDAPUseDefault': 228 case 'userDefinedAccounts': 229 case 'imapoldcclient': 230 case 'editforwardingaddress': 231 if($value == 'yes') 232 $this->t->set_var('selected_'.$key,'checked="1"'); 233 break; 234 case 'imapType': 235 case 'smtpType': 236 case 'imapLoginType': 237 $this->t->set_var('selected_'.$key.'_'.$value,'selected="1"'); 238 break; 239 case 'ea_appname': 240 $this->t->set_var('application_select_box', $GLOBALS['egw']->html->select('globalsettings[ea_appname]',$value,$applications, true, "style='width: 250px;'")); 241 break; 242 case 'ea_group': 243 $this->t->set_var('group_select_box', $GLOBALS['egw']->html->select('globalsettings[ea_group]',$value,$allGroups, true, "style='width: 250px;'")); 244 break; 245 default: 246 $this->t->set_var('value_'.$key,$value); 247 break; 248 } 249 } 250 251 $linkData = array 252 ( 253 'menuaction' => 'emailadmin.ui.saveProfile', 254 'profileID' => $profileID 255 ); 256 $this->t->set_var('action_url',$GLOBALS['egw']->link('/index.php',$linkData)); 257 258 $linkData = array 259 ( 260 'menuaction' => 'emailadmin.ui.listProfiles' 261 ); 262 $this->t->set_var('back_url',$GLOBALS['egw']->link('/index.php',$linkData)); 263 264 foreach($this->boemailadmin->getSMTPServerTypes() as $key => $value) 265 { 266 $this->t->set_var("lang_smtp_option_$key",$value); 267 }; 268 269 foreach($this->boemailadmin->getIMAPServerTypes() as $key => $value) 270 { 271 $this->t->set_var("lang_imap_option_$key",$value['description']); 272 }; 273 274 $this->t->parse("out","main"); 275 print $this->t->get('out','main'); 276 } 277 278 function listProfiles() 279 { 280 $this->display_app_header(); 281 282 $this->t->set_file(array("body" => "listprofiles.tpl")); 283 $this->t->set_block('body','main'); 284 285 $this->translate(); 286 287 $profileList = $this->boemailadmin->getProfileList(); 288 289 // create the data array 290 if ($profileList) 291 { 292 for ($i=0; $i < count($profileList); $i++) 293 { 294 $linkData = array 295 ( 296 'menuaction' => 'emailadmin.ui.editProfile', 297 'nocache' => '1', 298 'tabpage' => '3', 299 'profileid' => $profileList[$i]['profileID'] 300 ); 301 $imapServerLink = '<a href="#" onclick="egw_openWindowCentered2(\''.$GLOBALS['egw']->link('/index.php',$linkData).'\',\'ea_editProfile\',700,600); return false;">'.$profileList[$i]['imapServer'].'</a>'; 302 303 $linkData = array 304 ( 305 'menuaction' => 'emailadmin.ui.editProfile', 306 'nocache' => '1', 307 'tabpage' => '1', 308 'profileid' => $profileList[$i]['profileID'] 309 ); 310 $descriptionLink = '<a href="#" onclick="egw_openWindowCentered2(\''.$GLOBALS['egw']->link('/index.php',$linkData).'\',\'ea_editProfile\',700,600); return false;">'.$profileList[$i]['description'].'</a>'; 311 312 $linkData = array 313 ( 314 'menuaction' => 'emailadmin.ui.editProfile', 315 'nocache' => '1', 316 'tabpage' => '2', 317 'profileid' => $profileList[$i]['profileID'] 318 ); 319 $smtpServerLink = '<a href="#" onclick="egw_openWindowCentered2(\''.$GLOBALS['egw']->link('/index.php',$linkData).'\',\'ea_editProfile\',700,600); return false;">'.$profileList[$i]['smtpServer'].'</a>'; 320 321 $linkData = array 322 ( 323 'menuaction' => 'emailadmin.ui.deleteProfile', 324 'profileid' => $profileList[$i]['profileID'] 325 ); 326 $deleteLink = '<a href="'.$GLOBALS['egw']->link('/index.php',$linkData). 327 '" onClick="return confirm(\''.lang('Do you really want to delete this Profile').'?\')">'. 328 lang('delete').'</a>'; 329 330 $application = (empty($profileList[$i]['ea_appname']) ? lang('any application') : $GLOBALS['egw_info']['apps'][$profileList[$i]['ea_appname']]['title']); 331 $linkData = array 332 ( 333 'menuaction' => 'emailadmin.ui.editProfile', 334 'nocache' => '1', 335 'tabpage' => '1', 336 'profileid' => $profileList[$i]['profileID'] 337 ); 338 $applicationLink = '<a href="#" onclick="egw_openWindowCentered2(\''.$GLOBALS['egw']->link('/index.php',$linkData).'\',\'ea_editProfile\',700,600); return false;">'.$application.'</a>'; 339 340 $group = (empty($profileList[$i]['ea_group']) ? lang('any group') : $GLOBALS['egw']->accounts->id2name($profileList[$i]['ea_group'])); 341 $linkData = array 342 ( 343 'menuaction' => 'emailadmin.ui.editProfile', 344 'nocache' => '1', 345 'tabpage' => '1', 346 'profileid' => $profileList[$i]['profileID'] 347 ); 348 $groupLink = '<a href="#" onclick="egw_openWindowCentered2(\''.$GLOBALS['egw']->link('/index.php',$linkData).'\',\'ea_editProfile\',700,600); return false;">'.$group.'</a>'; 349 350 $moveButtons = '<img src="'. $GLOBALS['egw']->common->image('phpgwapi', 'up') .'" onclick="moveUp(this)"> '. 351 '<img src="'. $GLOBALS['egw']->common->image('phpgwapi', 'down') .'" onclick="moveDown(this)">'; 352 353 $data['profile_'.$profileList[$i]['profileID']] = array( 354 $descriptionLink, 355 $smtpServerLink, 356 $imapServerLink, 357 $applicationLink, 358 $groupLink, 359 $deleteLink, 360 $moveButtons, 361 362 ); 363 } 364 } 365 366 // create the array containing the table header 367 $rows = array( 368 lang('description'), 369 lang('smtp server name'), 370 lang('imap/pop3 server name'), 371 lang('application'), 372 lang('group'), 373 lang('delete'), 374 lang('order'), 375 ); 376 377 // create the table html code 378 $this->t->set_var('server_next_match',$this->nextMatchTable( 379 $rows, 380 $data, 381 lang('profile list'), 382 $_start, 383 $_total, 384 $_menuAction) 385 ); 386 387 $linkData = array 388 ( 389 'menuaction' => 'emailadmin.ui.addProfile' 390 ); 391 $this->t->set_var('add_link',$GLOBALS['egw']->link('/index.php',$linkData)); 392 393 $this->t->parse("out","main"); 394 395 print $this->t->get('out','main'); 396 397 } 398 399 function nextMatchTable($_rows, $_data, $_description, $_start, $_total, $_menuAction) 400 { 401 $template =& CreateObject('phpgwapi.Template',EGW_APP_TPL); 402 $template->set_file(array("body" => "nextMatch.tpl")); 403 $template->set_block('body','row_list','rowList'); 404 $template->set_block('body','header_row','headerRow'); 405 406 $var = Array( 407 'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'], 408 'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=emailadmin.ui.listServers'), 409 'right_next_matchs' => $this->nextmatchs->right('/admin/groups.php',$start,$total,'menuaction=emailadmin.ui.listServers'), 410 'lang_groups' => lang('user groups'), 411 'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=emailadmin.ui.listServers'), 412 'description' => $_description, 413 'header_edit' => lang('Edit'), 414 'header_delete' => lang('Delete') 415 ); 416 $template->set_var($var); 417 418 $data = ''; 419 if(is_array($_rows)) 420 { 421 foreach($_rows as $value) 422 { 423 $data .= "<td align='center'><b>$value</b></td>"; 424 } 425 $template->set_var('header_row_data', $data); 426 $template->fp('headerRow','header_row',True); 427 #$template->fp('header_row','header_row',True); 428 } 429 430 if(is_array($_data)) 431 { 432 foreach($_data as $rowID => $value) 433 { 434 $data = ''; 435 foreach($value as $rowData) 436 { 437 $data .= "<td align='center'>$rowData</td>"; 438 } 439 $template->set_var('row_data', $data); 440 $template->set_var('row_id', $rowID); 441 $template->fp('rowList','row_list',True); 442 } 443 } 444 445 return $template->fp('out','body'); 446 447 } 448 449 function saveProfile() 450 { 451 $globalSettings = array(); 452 $smtpSettings = array(); 453 $imapSettings = array(); 454 455 // try to get the profileID 456 if(is_int(intval($_GET['profileID'])) && !empty($_GET['profileID'])) 457 { 458 $globalSettings['profileID'] = intval($_GET['profileID']); 459 } 460 $globalSettings['description'] = $_POST['globalsettings']['description']; 461 $globalSettings['defaultDomain'] = $_POST['globalsettings']['defaultDomain']; 462 $globalSettings['organisationName'] = $_POST['globalsettings']['organisationName']; 463 $globalSettings['userDefinedAccounts'] = $_POST['globalsettings']['userDefinedAccounts']; 464 $globalSettings['ea_appname'] = ($_POST['globalsettings']['ea_appname'] == 'any' ? '' : $_POST['globalsettings']['ea_appname']); 465 $globalSettings['ea_group'] = ($_POST['globalsettings']['ea_group'] == 'any' ? '' : (int)$_POST['globalsettings']['ea_group']); 466 467 468 // get the settings for the smtp server 469 $smtpType = $_POST['smtpsettings']['smtpType']; 470 foreach($this->boemailadmin->getFieldNames($smtpType,'smtp') as $key) 471 { 472 $smtpSettings[$key] = $_POST['smtpsettings'][$smtpType][$key]; 473 } 474 $smtpSettings['smtpType'] = $smtpType; 475 476 #_debug_array($smtpSettings); 477 478 // get the settings for the imap/pop3 server 479 $imapType = $_POST['imapsettings']['imapType']; 480 foreach($this->boemailadmin->getFieldNames($imapType,'imap') as $key) 481 { 482 $imapSettings[$key] = $_POST['imapsettings'][$imapType][$key]; 483 } 484 $imapSettings['imapType'] = $imapType; 485 486 #_debug_array($imapSettings); 487 488 $this->boemailadmin->saveProfile($globalSettings, $smtpSettings, $imapSettings); 489 #if ($_POST['bo_action'] == 'save_ldap' || $_GET['bo_action'] == 'save_ldap') 490 #{ 491 # $this->listProfiles(); 492 #} 493 #else 494 #{ 495 # $this->editServer($_GET["serverid"],$_GET["pagenumber"]); 496 #} 497 print "<script type=\"text/javascript\">opener.location.reload(); window.close();</script>"; 498 $GLOBALS['egw']->common->egw_exit(); 499 exit; 500 } 501 502 function translate() 503 { 504 # skeleton 505 # $this->t->set_var('',lang('')); 506 507 $this->t->set_var('lang_server_name',lang('server name')); 508 $this->t->set_var('lang_server_description',lang('description')); 509 $this->t->set_var('lang_edit',lang('edit')); 510 $this->t->set_var('lang_save',lang('save')); 511 $this->t->set_var('lang_delete',lang('delete')); 512 $this->t->set_var('lang_back',lang('back')); 513 $this->t->set_var('lang_remove',lang('remove')); 514 $this->t->set_var('lang_ldap_server',lang('LDAP server')); 515 $this->t->set_var('lang_ldap_basedn',lang('LDAP basedn')); 516 $this->t->set_var('lang_ldap_server_admin',lang('admin dn')); 517 $this->t->set_var('lang_ldap_server_password',lang('admin password')); 518 $this->t->set_var('lang_add_profile',lang('add profile')); 519 $this->t->set_var('lang_domain_name',lang('domainname')); 520 $this->t->set_var('lang_SMTP_server_hostname_or_IP_address',lang('SMTP-Server hostname or IP address')); 521 $this->t->set_var('lang_SMTP_server_port',lang('SMTP-Server port')); 522 $this->t->set_var('lang_Use_SMTP_auth',lang('Use SMTP auth')); 523 $this->t->set_var('lang_Select_type_of_SMTP_Server',lang('Select type of SMTP Server')); 524 $this->t->set_var('lang_profile_name',lang('Profile Name')); 525 $this->t->set_var('lang_default_domain',lang('enter your default mail domain (from: user@domain)')); 526 $this->t->set_var('lang_organisation_name',lang('name of organisation')); 527 $this->t->set_var('lang_user_defined_accounts',lang('users can define their own emailaccounts')); 528 $this->t->set_var('lang_LDAP_server_hostname_or_IP_address',lang('LDAP server hostname or ip address')); 529 $this->t->set_var('lang_LDAP_server_admin_dn',lang('LDAP server admin DN')); 530 $this->t->set_var('lang_LDAP_server_admin_pw',lang('LDAP server admin password')); 531 $this->t->set_var('lang_LDAP_server_base_dn',lang('LDAP server accounts DN')); 532 $this->t->set_var('lang_use_LDAP_defaults',lang('use LDAP defaults')); 533 $this->t->set_var('lang_LDAP_settings',lang('LDAP settings')); 534 $this->t->set_var('lang_select_type_of_imap/pop3_server',lang('select type of IMAP/POP3 server')); 535 $this->t->set_var('lang_pop3_server_hostname_or_IP_address',lang('POP3 server hostname or ip address')); 536 $this->t->set_var('lang_pop3_server_port',lang('POP3 server port')); 537 $this->t->set_var('lang_imap_server_hostname_or_IP_address',lang('IMAP server hostname or ip address')); 538 $this->t->set_var('lang_imap_server_port',lang('IMAP server port')); 539 $this->t->set_var('lang_use_tls_encryption',lang('use tls encryption')); 540 $this->t->set_var('lang_use_tls_authentication',lang('use tls authentication')); 541 $this->t->set_var('lang_sieve_settings',lang('Sieve settings')); 542 $this->t->set_var('lang_enable_sieve',lang('enable Sieve')); 543 $this->t->set_var('lang_sieve_server_hostname_or_ip_address',lang('Sieve server hostname or ip address')); 544 $this->t->set_var('lang_sieve_server_port',lang('Sieve server port')); 545 $this->t->set_var('lang_enable_cyrus_imap_administration',lang('enable Cyrus IMAP server administration')); 546 $this->t->set_var('lang_cyrus_imap_administration',lang('Cyrus IMAP server administration')); 547 $this->t->set_var('lang_admin_username',lang('admin username')); 548 $this->t->set_var('lang_admin_password',lang('admin passwort')); 549 $this->t->set_var('lang_imap_server_logintyp',lang('imap server logintyp')); 550 $this->t->set_var('lang_standard',lang('username (standard)')); 551 $this->t->set_var('lang_vmailmgr',lang('username@domainname (Virtual MAIL ManaGeR)')); 552 $this->t->set_var('lang_pre_2001_c_client',lang('IMAP C-Client Version < 2001')); 553 $this->t->set_var('lang_user_can_edit_forwarding_address',lang('user can edit forwarding address')); 554 $this->t->set_var('lang_can_be_used_by_application',lang('can be used by application')); 555 $this->t->set_var('lang_can_be_used_by_group',lang('can be used by group')); 556 $this->t->set_var('lang_smtp_auth',lang('smtp authentication')); 557 $this->t->set_var('lang_username',lang('username')); 558 $this->t->set_var('lang_password',lang('password')); 559 $this->t->set_var('lang_smtp_settings',lang('smtp settings')); 560 $this->t->set_var('lang_smtp_options',lang('smtp options')); 561 $this->t->set_var('lang_profile_access_rights',lang('profile access rights')); 562 $this->t->set_var('lang_global_settings',lang('')); 563 $this->t->set_var('lang_organisation',lang('organisation')); 564 $this->t->set_var('lang_global_options',lang('global options')); 565 $this->t->set_var('lang_server_settings',lang('server settings')); 566 $this->t->set_var('lang_encryption_settings',lang('encryption settings')); 567 $this->t->set_var('',lang('')); 568 $this->t->set_var('',lang('')); 569 $this->t->set_var('',lang('')); 570 $this->t->set_var('',lang('')); 571 # $this->t->set_var('',lang('')); 572 573 } 574 } 575 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |