From bba3dba9ac91853372ebdfa5444a4be8f54b5eb5 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 6 Oct 2011 10:14:13 +0000 Subject: [PATCH] * EMailAdmin allow to specify smtp auth credentials for alarms/notifications only, otherwise credentials of current user are used --- emailadmin/inc/class.emailadmin_bo.inc.php | 18 +- emailadmin/inc/class.emailadmin_ui.inc.php | 32 +- emailadmin/lang/egw_de.lang | 2 + emailadmin/lang/egw_en.lang | 2 + emailadmin/setup/etemplates.inc.php | 20 +- emailadmin/templates/default/edit.xet | 458 +++++++++++++++++++++ emailadmin/templates/default/index.xet | 116 ++++++ setup/inc/hook_config.inc.php | 4 + setup/templates/default/config.tpl | 10 +- 9 files changed, 634 insertions(+), 28 deletions(-) create mode 100644 emailadmin/templates/default/edit.xet create mode 100644 emailadmin/templates/default/index.xet diff --git a/emailadmin/inc/class.emailadmin_bo.inc.php b/emailadmin/inc/class.emailadmin_bo.inc.php index b1a04674f8..9b3e423c91 100644 --- a/emailadmin/inc/class.emailadmin_bo.inc.php +++ b/emailadmin/inc/class.emailadmin_bo.inc.php @@ -308,7 +308,8 @@ class emailadmin_bo extends so_sql 'ea_default_domain' => 'mail_suffix', 'ea_smtp_server' => 'smtp_server', 'ea_smtp_port' => 'smtp_port', - )+($this->data['ea_smtp_auth']=='yes' ? array( //ToDo: if no, we may have to reset config values for that too? + )+($this->data['ea_smtp_auth']!='no' ? array( //ToDo: if no, we may have to reset config values for that too? + 'ea_smtp_auth' => 'smtpAuth', 'ea_smtp_auth_username' => 'smtp_auth_user', 'ea_smtp_auth_password' => 'smtp_auth_passwd', ) : array()) as $ea_name => $config_name) @@ -700,9 +701,9 @@ class emailadmin_bo extends so_sql $ogServer->host = $data['smtpServer']; $ogServer->port = $data['smtpPort']; $ogServer->editForwardingAddress = ($data['editforwardingaddress'] == 'yes'); - $ogServer->smtpAuth = $data['smtpAuth'] == 'yes'; + $ogServer->smtpAuth = ($data['smtpAuth'] == 'yes' || $data['smtpAuth'] == 'ann' ); if($ogServer->smtpAuth) { - if(!empty($data['ea_smtp_auth_username'])) { + if(!empty($data['ea_smtp_auth_username']) && $data['smtpAuth'] == 'yes') { $ogServer->username = $data['ea_smtp_auth_username']; } else { // if we use special logintypes for IMAP, we assume this to be used for SMTP too @@ -714,7 +715,7 @@ class emailadmin_bo extends so_sql $ogServer->username = $GLOBALS['egw_info']['user']['account_lid']; } } - if(!empty($data['ea_smtp_auth_password'])) { + if(!empty($data['ea_smtp_auth_password']) && $data['smtpAuth'] == 'yes') { $ogServer->password = $data['ea_smtp_auth_password']; } else { $ogServer->password = $GLOBALS['egw_info']['user']['passwd']; @@ -825,8 +826,8 @@ class emailadmin_bo extends so_sql { if (($profiles = $this->soemailadmin->getProfileList(0,true))) { - //error_log(__METHOD__.__LINE__.' Found profile 2 merge'); $profile = array_shift($profiles); + //error_log(__METHOD__.__LINE__.' Found profile 2 merge:'.array2string($profile)); } else { @@ -862,14 +863,16 @@ class emailadmin_bo extends so_sql 'mail_suffix' => 'defaultDomain', 'smtp_server' => 'smtpServer', 'smtp_port' => 'smtpPort', + 'smtpAuth' => 'ea_smtp_auth', 'smtp_auth_user' => 'ea_smtp_auth_username', 'smtp_auth_passwd' => 'ea_smtp_auth_password', ) as $setup_name => $ea_name_data) { + if ($setup_name == 'smtp_auth_passwd' && empty($settings[$setup_name]) && !empty($settings['smtp_auth_user']) && $settings['smtpAuth'] != 'no') continue; if (!is_array($ea_name_data)) { $profile[$ea_name_data] = $settings[$setup_name]; - if ($setup_name == 'smtp_auth_user') $profile['stmpAuth'] = !empty($settings['smtp_auth_user']); + //if ($setup_name == 'smtp_auth_user' && $profile['smtpAuth'] == 'no' && !empty($settings['smtp_auth_user'])) $profile['smtpAuth'] = 'yes'; } else { @@ -891,7 +894,8 @@ class emailadmin_bo extends so_sql } // merge the other not processed values unchanged $profile = array_merge($profile,array_diff_assoc($settings,$to_parse)); - //error_log(__METHOD__.__LINE__.' Profile to Save:'.array2string($profile).' Profile to Parse:'.array2string($to_parse)); + //error_log(__METHOD__.__LINE__.' Profile to Save:'.array2string($profile)); + //error_log(__METHOD__.__LINE__.' Profile to Parse:'.array2string($to_parse)); $this->soemailadmin->updateProfile($profile); self::$sessionData['profile'] = array(); $this->saveSessionData(); diff --git a/emailadmin/inc/class.emailadmin_ui.inc.php b/emailadmin/inc/class.emailadmin_ui.inc.php index 37a6b99d06..614717458d 100644 --- a/emailadmin/inc/class.emailadmin_ui.inc.php +++ b/emailadmin/inc/class.emailadmin_ui.inc.php @@ -14,7 +14,7 @@ * User interface */ class emailadmin_ui extends emailadmin_bo -{ +{ var $public_functions = array ( 'index' => True, @@ -24,7 +24,7 @@ class emailadmin_ui extends emailadmin_bo 'save' => True, 'listProfiles' => True, ); - + function __construct() { parent::__construct(); @@ -56,7 +56,7 @@ class emailadmin_ui extends emailadmin_bo } if ($rowsfound) { - if (($accountID || !empty($groupID)) && $rowsfound == 1) + if (($accountID || !empty($groupID)) && $rowsfound == 1) { $linkData = array ( @@ -189,7 +189,7 @@ class emailadmin_ui extends emailadmin_bo if (!empty($filter)) foreach ($filter as $fk => $fv) $content['nm']['col_filter'][$fk] = $fv; // seTting the Title of the app $GLOBALS['egw_info']['flags']['app_header'] = lang('emailadmin'); - $tpl->exec('emailadmin.emailadmin_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); + $tpl->exec('emailadmin.emailadmin_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); } /** @@ -251,6 +251,20 @@ class emailadmin_ui extends emailadmin_bo return $returnval; } + /** + * Get a list of supported SMTP Auth Config options + * + * @return array value => label pairs + */ + static public function getSMTPAuthConfig() + { + return array( + 'no' => 'No', + 'yes' => 'Yes, use credentials of current user or if given credentials below', + 'ann' => 'Yes, use credentials below only for alarms and notifications, otherwise use credentials of current user', + ); + } + function edit($content=null) { //$this->editProfile($profileid); @@ -334,7 +348,7 @@ class emailadmin_ui extends emailadmin_bo $js .= 'window.close();'; echo "\n\n\n\n\n"; $GLOBALS['egw']->common->egw_exit(); - break; + break; case 'cancel': $js .= 'window.close();'; echo "\n\n\n\n\n"; @@ -368,9 +382,9 @@ class emailadmin_ui extends emailadmin_bo } } if ($rowfound) $content = array_merge($this->data,array()); - $preserv['smtpcapabilities'] = $content['smtpcapabilities'] = + $preserv['smtpcapabilities'] = $content['smtpcapabilities'] = constant((!empty($content['ea_smtp_type'])?$content['ea_smtp_type']:'defaultsmtp').'::CAPABILITIES'); - $preserv['imapcapabilities'] = $content['imapcapabilities'] = + $preserv['imapcapabilities'] = $content['imapcapabilities'] = constant((!empty($content['ea_imap_type'])?$content['ea_imap_type']:'defaultimap').'::CAPABILITIES'); if (!empty($msg)) $content['msg'] = $msg; list($content['ea_smtp_auth_username'],$content['smtp_senders_email']) = explode(';',$content['ea_smtp_auth_username']); @@ -392,7 +406,9 @@ class emailadmin_ui extends emailadmin_bo foreach($this->tracking->field2label as $field => $label) { $sel_options['status'][$field] = lang($label); } - /* + + $sel_options['ea_smtp_auth'] = self::getSMTPAuthConfig(); + /* $content['stored_templates'] = html::checkbox_multiselect( 'ea_stationery_active_templates',$content['ea_stationery_active_templates'] ,$bostationery->get_stored_templates(),true,'',3,true,'width: 100%;'); diff --git a/emailadmin/lang/egw_de.lang b/emailadmin/lang/egw_de.lang index a91e67605e..426669fcdf 100644 --- a/emailadmin/lang/egw_de.lang +++ b/emailadmin/lang/egw_de.lang @@ -148,4 +148,6 @@ users can define their own signatures emailadmin de Anwender können ihre eigene users can utilize these stationery templates emailadmin de Benutzer können diese Briefpapiervorlagen verwenden vaction messages with start- and end-date require an admin account to be set! emailadmin de Urlaubsbenachrichtigungen mit Start- und Enddatum benötigen einen gesetzten Administrator Benutzer! virtual mail manager emailadmin de Virtual MAIL ManaGeR +yes, use credentials below only for alarms and notifications, otherwise use credentials of current user emailadmin de Ja, die Daten darunter nur für Alarme und Benachrichtigungen verwenden, ansonsten die Daten des aktiven Benutzers +yes, use credentials of current user or if given credentials below emailadmin de Ja, benutze Daten des aktuellen Benutzers oder wenn angegeben die Daten darunter you have received a new message on the emailadmin de Sie haben eine neue Nachricht erhalten diff --git a/emailadmin/lang/egw_en.lang b/emailadmin/lang/egw_en.lang index fd04617698..f628017efd 100755 --- a/emailadmin/lang/egw_en.lang +++ b/emailadmin/lang/egw_en.lang @@ -148,4 +148,6 @@ users can define their own signatures emailadmin en Users can define their own s users can utilize these stationery templates emailadmin en Users can utilize these stationery templates vaction messages with start- and end-date require an admin account to be set! emailadmin en Vacation messages with start and end date require an admin account to be set! virtual mail manager emailadmin en Virtual MAIL ManaGeR +yes, use credentials below only for alarms and notifications, otherwise use credentials of current user emailadmin en Yes, use credentials below only for alarms and notifications, otherwise use credentials of current user +yes, use credentials of current user or if given credentials below emailadmin en Yes, use credentials of current user or if given credentials below you have received a new message on the emailadmin en You have received a new message on the diff --git a/emailadmin/setup/etemplates.inc.php b/emailadmin/setup/etemplates.inc.php index cfb0c8255b..40620c6614 100644 --- a/emailadmin/setup/etemplates.inc.php +++ b/emailadmin/setup/etemplates.inc.php @@ -1,14 +1,14 @@ 'emailadmin.edit.IMAP','template' => '','lang' = $templ_data[] = array('name' => 'emailadmin.edit.signature','template' => '','lang' => '','group' => '0','version' => '1.7.004','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:37:"users can define their own signatures";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:26:"ea_user_defined_signatures";s:4:"size";s:6:"yes,no";}}i:2;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"htmlarea";s:4:"span";s:1:"2";s:4:"name";s:20:"ea_default_signature";s:4:"size";s:17:"advanced,,700,180";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1270799878',); -$templ_data[] = array('name' => 'emailadmin.edit.SMTP','template' => '','lang' => '','group' => '0','version' => '1.7.004','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:1:{s:2:"h4";s:29:",!@smtpcapabilities=/forward/";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"Select type of SMTP Server";}i:2;a:4:{s:4:"type";s:6:"select";s:4:"name";s:12:"ea_smtp_type";s:5:"align";s:5:"right";s:8:"onchange";i:1;}}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:13:"SMTP settings";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:34:"SMTP-Server hostname or IP address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:14:"ea_smtp_server";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:16:"SMTP-Server Port";}s:1:"B";a:2:{s:4:"type";s:3:"int";s:4:"name";s:12:"ea_smtp_port";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:19:"smtp authentication";i:1;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Use SMTP auth";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:12:"ea_smtp_auth";s:4:"size";s:6:"yes,no";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:29:"send using this eMail-Address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:18:"smtp_senders_email";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"username";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:21:"ea_smtp_auth_username";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"password";}s:1:"B";a:2:{s:4:"type";s:6:"passwd";s:4:"name";s:21:"ea_smtp_auth_password";}}}s:4:"rows";i:4;s:4:"cols";i:2;s:7:"options";a:0:{}}}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:12:"smtp options";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:2:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:32:"user can edit forwarding address";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:24:"ea_editforwardingaddress";s:4:"size";s:6:"yes,no";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}}}s:4:"rows";i:4;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1274772869',); +$templ_data[] = array('name' => 'emailadmin.edit.SMTP','template' => '','lang' => '','group' => '0','version' => '1.7.004','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:1:{s:2:"h4";s:29:",!@smtpcapabilities=/forward/";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"Select type of SMTP Server";}i:2;a:4:{s:4:"type";s:6:"select";s:4:"name";s:12:"ea_smtp_type";s:5:"align";s:5:"right";s:8:"onchange";i:1;}}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:13:"SMTP settings";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:34:"SMTP-Server hostname or IP address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:14:"ea_smtp_server";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:16:"SMTP-Server Port";}s:1:"B";a:2:{s:4:"type";s:3:"int";s:4:"name";s:12:"ea_smtp_port";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:19:"smtp authentication";i:1;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Use SMTP auth";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:12:"ea_smtp_auth";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:29:"send using this eMail-Address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:18:"smtp_senders_email";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"username";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:21:"ea_smtp_auth_username";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"password";}s:1:"B";a:2:{s:4:"type";s:6:"passwd";s:4:"name";s:21:"ea_smtp_auth_password";}}}s:4:"rows";i:4;s:4:"cols";i:2;s:7:"options";a:0:{}}}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:12:"smtp options";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:2:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:32:"user can edit forwarding address";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:24:"ea_editforwardingaddress";s:4:"size";s:6:"yes,no";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}}}s:4:"rows";i:4;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1274772869',); $templ_data[] = array('name' => 'emailadmin.edit.stationery','template' => '','lang' => '','group' => '0','version' => '1.7.003','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:16:"active templates";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:44:"users can utilize these stationery templates";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:4:"name";s:30:"ea_stationery_active_templates";i:1;a:3:{s:4:"type";s:3:"box";s:4:"name";s:30:"ea_stationery_active_templates";s:4:"size";s:3:",10";}s:4:"size";s:1:"5";}}i:2;a:2:{s:1:"A";a:6:{s:4:"type";s:4:"html";s:4:"span";s:1:"2";s:8:"readonly";s:1:"1";s:4:"help";s:27:"manage stationery templates";s:4:"name";s:27:"manage_stationery_templates";s:5:"align";s:5:"right";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1255600503',); diff --git a/emailadmin/templates/default/edit.xet b/emailadmin/templates/default/edit.xet new file mode 100644 index 0000000000..a38850f603 --- /dev/null +++ b/emailadmin/templates/default/edit.xet @@ -0,0 +1,458 @@ + + + + + + + + + +