From d79ba42e852c85dd27f2f8bdb161636ca369072b Mon Sep 17 00:00:00 2001 From: jerome Date: Wed, 23 Apr 2014 16:09:45 +0200 Subject: [PATCH] Issue #75 --- src/includes/functions.inc.php | 41 +++++++++++ src/lang/bg_BG.lang.php | 10 +++ src/lang/de_DE.lang.php | 10 +++ src/lang/en_US.lang.php | 10 +++ src/lang/es_ES.lang.php | 10 +++ src/lang/fr_FR.lang.php | 10 +++ src/lang/it_IT.lang.php | 10 +++ src/lang/ko_KR.lang.php | 10 +++ src/lang/nl_NL.lang.php | 10 +++ src/lang/pt_BR.lang.php | 10 +++ src/lang/zh_CN.lang.php | 10 +++ .../Controller/ConfigController.class.php | 70 ++++++++++++++++++- src/psm/Util/Module/Modal.class.php | 59 +++------------- src/psm/Util/Updater/StatusNotifier.class.php | 33 ++------- src/templates/config/config.tpl.html | 38 ++++++---- src/templates/main_modal.tpl.html | 6 +- static/js/scripts.js | 16 ++++- 17 files changed, 264 insertions(+), 99 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 4b8260ed..e6034083 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -412,6 +412,47 @@ function psm_build_mail($from_name = null, $from_email = null) { return $phpmailer; } +/** + * Prepare a new SMS util. + * + * @return \psm\Txtmsg\TxtmsgInterface + */ +function psm_build_sms() { + $sms = null; + + // open the right class + // not making this any more dynamic, because perhaps some gateways need custom settings (like Mollie) + switch(strtolower(psm_get_conf('sms_gateway'))) { + case 'mosms': + $sms = new \psm\Txtmsg\Mosms(); + break; + case 'inetworx': + $sms = new \psm\Txtmsg\Inetworx(); + break; + case 'mollie': + $sms = new \psm\Txtmsg\Mollie(); + $sms->setGateway(1); + break; + case 'spryng': + $sms = new \psm\Txtmsg\Spryng(); + break; + case 'clickatell': + $sms = new \psm\Txtmsg\Clickatell(); + break; + case 'textmarketer': + $sms = new \psm\Txtmsg\Textmarketer(); + break; + } + + // copy login information from the config file + if($sms) { + $sms->setLogin(psm_get_conf('sms_gateway_username'), psm_get_conf('sms_gateway_password')); + $sms->setOriginator(psm_get_conf('sms_from')); + } + + return $sms; +} + /** * Generate a new link to the current monitor * @param array $params key value pairs diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index 2fa6a2cc..992b680a 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'log_email' => 'Да се пази ли лог на изпратените имейли от системата', 'log_sms' => 'Да се пази ли лог на изпратените SMS съобщения от системата', 'updated' => 'Настройките са обновени успешно.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Имейл', 'tab_sms' => 'SMS', 'tab_log' => 'Логове', @@ -208,6 +209,15 @@ $sm_lang = array( 'Времето е в секунди, ако е 0 страницата няма да се обновява.'. '', 'seconds' => 'секунди', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // За нов ред в имейл съобщението, моля използвайте тага
'notifications' => array( diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index c06646ef..e6d62d64 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -193,6 +193,7 @@ $sm_lang = array( 'log_email' => 'Email Log per Script senden?', 'log_sms' => 'SMS Log per Script senden?', 'updated' => 'Die Einstellungen wurden gespeichert.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -207,6 +208,15 @@ $sm_lang = array( 'Time in seconds, if 0 the page won\'t refresh.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 6f6c825b..8eed1d3b 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -193,6 +193,7 @@ $sm_lang = array( 'log_email' => 'Log emails sent by the script', 'log_sms' => 'Log text messages sent by the script', 'updated' => 'The configuration has been updated.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -207,6 +208,15 @@ $sm_lang = array( 'Time in seconds, if 0 the page won\'t refresh.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index 4af5f488..d5dba720 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -191,6 +191,7 @@ $sm_lang = array( 'log_email' => 'Enviar Log via email?', 'log_sms' => 'Enviar Log via SMS ?', 'updated' => 'Configuración guardada.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -205,6 +206,15 @@ $sm_lang = array( 'Tiempo en segundos, indicar "0" para no actualizar.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index 8cf9a243..dd625673 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -192,6 +192,7 @@ $sm_lang = array( 'log_email' => 'Enregistrer tout les emails envoyés', 'log_sms' => 'Enregistrer tout les SMS envoyés', 'updated' => 'La configuration a été mise à jour.', + 'nochanges' => 'La configuration n\'a pas été modifiée.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Événements', @@ -206,6 +207,15 @@ $sm_lang = array( 'Temps en secondes. Si 0, la page n\'est pas rafraîchie.'. '', 'seconds' => 'secondes', + 'test' => 'Tester', + 'test_email' => 'Un email va vous être envoyé à l\'adresse définie dans votre profil utilisateur.', + 'test_sms' => 'Un SMS va vous être envoyé au numéro défini dans votre profil utilisateur.', + 'send' => 'Envoyer', + 'test_message' => 'Message de test', + 'email_sent' => 'Email envoyé', + 'email_error' => 'Erreur lors de l\'envoie de l\'email', + 'sms_sent' => 'Sms envoyé', + 'sms_error' => 'Erreur lors de l\'envoie du sms', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index a7f475eb..930fd304 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -191,6 +191,7 @@ $sm_lang = array( 'log_email' => 'Registra email inviate dallo script.', 'log_sms' => 'Registra SMS inviati dallo script.', 'updated' => 'La configurazione è stato aggiornata.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -205,6 +206,15 @@ $sm_lang = array( 'Tempo in secondi, se impostato a 0 la pagina non si aggiornerà.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index 9f1b8647..84c0a62f 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -191,6 +191,7 @@ $sm_lang = array( 'log_email' => '이메일로 로그를 전송하시겠습니까?', 'log_sms' => 'SMS로 로그를 전송하시겠습니까?', 'updated' => '설정이 수정되었습니다.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => '로그', @@ -205,6 +206,15 @@ $sm_lang = array( '시간은 초(sec)로 설정을 하고, 0은 새로고침을 하지 않습니다.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index 7d8893f1..c7548a30 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -192,6 +192,7 @@ $sm_lang = array( 'log_email' => 'Log emails verstuurd bij het script?', 'log_sms' => 'Log sms berichten verstuurd bij het script?', 'updated' => 'De configuratie is gewijzigd.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -206,6 +207,15 @@ $sm_lang = array( 'Tijd in seconden, als de tijd 0 is wordt de pagina niet ververst.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 2f30da20..3fd236c1 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -193,6 +193,7 @@ $sm_lang = array( 'log_email' => 'Registrar no Log os envios de email feitos pelo script?', 'log_sms' => 'Registrar no Log os envios de mensagens de texto feitos pelo script?', 'updated' => 'A configuração foi atualizada.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => 'Email', 'tab_sms' => 'Texto', 'tab_log' => 'Logs', @@ -207,6 +208,15 @@ $sm_lang = array( 'Tempo em segundos, Se 0 a página não será atualizada.'. '', 'seconds' => 'segundos', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 92d4a8a9..e97e1145 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -192,6 +192,7 @@ $sm_lang = array( 'log_email' => '记录脚本所发邮件?', 'log_sms' => '记录脚本所发短信SMS?', 'updated' => '设置已更新.', + 'nochanges' => 'The configuration didn\'t change.', 'tab_email' => '邮件发送设置', 'tab_sms' => '短信发送设置', 'tab_log' => '日志设置', @@ -206,6 +207,15 @@ $sm_lang = array( '单位为秒, 设置为0则不自动刷新.'. '', 'seconds' => 'seconds', + 'test' => 'Test', + 'test_email' => 'An email will be sent to the address specified in your user profile.', + 'test_sms' => 'A SMS will be sent to the phone number specified in your user profile.', + 'send' => 'Send', + 'test_message' => 'Test message', + 'email_sent' => 'Email sent', + 'email_error' => 'Error in email sending', + 'sms_sent' => 'Sms sent', + 'sms_error' => 'Error in sms sending', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php index 34544cc2..45ed4733 100644 --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -61,6 +61,8 @@ class ConfigController extends AbstractController { 'sms_gateway_password', 'sms_from', ); + + private $default_tab = 'general'; function __construct(Database $db, Template $tpl) { parent::__construct($db, $tpl); @@ -117,6 +119,20 @@ class ConfigController extends AbstractController { $tpl_data[$input_key] = (isset($config[$input_key])) ? $config[$input_key] : ''; } + $tpl_data[$this->default_tab . '_active'] = 'active'; + + $modal = new \psm\Util\Module\Modal($this->tpl, 'testEmail', \psm\Util\Module\Modal::MODAL_TYPE_OKCANCEL); + $this->addModal($modal); + $modal->setTitle(psm_get_lang('servers', 'send_email')); + $modal->setMessage(psm_get_lang('config', 'test_email')); + $modal->setOKButtonLabel(psm_get_lang('config', 'send')); + + $modal = new \psm\Util\Module\Modal($this->tpl, 'testSMS', \psm\Util\Module\Modal::MODAL_TYPE_OKCANCEL); + $this->addModal($modal); + $modal->setTitle(psm_get_lang('servers', 'send_sms')); + $modal->setMessage(psm_get_lang('config', 'test_sms')); + $modal->setOKButtonLabel(psm_get_lang('config', 'send')); + $this->tpl->addTemplateData($this->getTemplateId(), $tpl_data); } @@ -143,9 +159,11 @@ class ConfigController extends AbstractController { } // save all values to the database + $changed = false; foreach($clean as $key => $value) { // check if key already exists, otherwise add it - if(psm_get_conf($key) === null) { + $old_value = psm_get_conf($key); + if($old_value === null) { // not yet set, add it $this->db->save( PSM_DB_PREFIX . 'config', @@ -154,22 +172,67 @@ class ConfigController extends AbstractController { 'value' => $value, ) ); - } else { + $changed = true; + } else if($value != $old_value) { // update $this->db->save( PSM_DB_PREFIX . 'config', array('value' => $value), array('key' => $key) ); + $changed = true; } } - $this->addMessage(psm_get_lang('config', 'updated'), 'success'); + if($changed) { + $this->addMessage(psm_get_lang('config', 'updated'), 'success'); + } + + if(!empty($_POST['test_email'])) { + // build mail object + $mail = psm_build_mail(); + $message = psm_get_lang('config', 'test_message'); + $mail->Subject = $message; + $mail->Priority = 1; + $mail->Body = $message; + $mail->AltBody = str_replace('
', "\n", $message); + $user = $this->user->getUser(); + $mail->AddAddress($user->email, $user->name); + if($mail->Send()) { + $this->addMessage(psm_get_lang('config', 'email_sent'), 'success'); + } else { + $this->addMessage(psm_get_lang('config', 'email_error') . ': ' . $mail->ErrorInfo, 'error'); + } + } elseif(!empty($_POST['test_sms'])) { + // build sms object + $sms = psm_build_sms(); + if($sms) { + $user = $this->user->getUser(); + $sms->addRecipients($user->mobile); + if($sms->sendSMS(psm_get_lang('config', 'test_message'))) { + $this->addMessage(psm_get_lang('config', 'sms_sent'), 'success'); + } else { + $this->addMessage(psm_get_lang('config', 'sms_error'), 'error'); + } + } + } elseif(!$changed) { + $this->addMessage(psm_get_lang('config', 'nochanges')); + } if($clean['language'] != psm_get_conf('language')) { header('Location: ' . $_SERVER['REQUEST_URI']); die(); } + + if(isset($_POST['general_submit'])) { + $this->default_tab = 'general'; + } elseif(isset($_POST['email_submit']) || !empty($_POST['test_email'])) { + $this->default_tab = 'email'; + } elseif(isset($_POST['sms_submit']) || !empty($_POST['test_sms'])) { + $this->default_tab = 'sms'; + } elseif(isset($_POST['logging_submit'])) { + $this->default_tab = 'logging'; + } } $this->initializeAction('index'); } @@ -223,6 +286,7 @@ class ConfigController extends AbstractController { 'label_auto_refresh_servers' => psm_get_lang('config', 'auto_refresh_servers'), 'label_seconds' => psm_get_lang('config', 'seconds'), 'label_save' => psm_get_lang('system', 'save'), + 'label_test' => psm_get_lang('config', 'test'), ) ); diff --git a/src/psm/Util/Module/Modal.class.php b/src/psm/Util/Module/Modal.class.php index c5b70d27..18b911be 100644 --- a/src/psm/Util/Module/Modal.class.php +++ b/src/psm/Util/Module/Modal.class.php @@ -125,52 +125,9 @@ class Modal implements ModalInterface { $tpl_id = 'main_modal_container'; $this->tpl->newTemplate($tpl_id, 'main_modal.tpl.html'); - $buttons = array(); - switch($this->type) - { - case self::MODAL_TYPE_OK: - $buttons[] = array( - 'modal_button_class' => 'modalOKButton', - 'modal_button_type' => 'primary', - 'modal_button_dismiss' => '', - 'modal_button_label' => empty($this->ok_label) ? psm_get_lang('system', 'ok') : $this->ok_label, - ); - break; - - case self::MODAL_TYPE_OKCANCEL: - $buttons[] = array( - 'modal_button_class' => 'modalCancelButton', - 'modal_button_type' => 'default', - 'modal_button_attr' => 'data-dismiss="modal"', - 'modal_button_label' => psm_get_lang('system', 'cancel'), - ); - $buttons[] = array( - 'modal_button_class' => 'modalOKButton', - 'modal_button_type' => 'primary', - 'modal_button_attr' => '', - 'modal_button_label' => empty($this->ok_label) ? psm_get_lang('system', 'ok') : $this->ok_label, - ); - break; - - case self::MODAL_TYPE_DANGER: - $buttons[] = array( - 'modal_button_class' => 'modalCancelButton', - 'modal_button_type' => 'default', - 'modal_button_attr' => 'data-dismiss="modal"', - 'modal_button_label' => psm_get_lang('system', 'cancel'), - ); - $buttons[] = array( - 'modal_button_class' => 'modalOKButton', - 'modal_button_type' => 'danger', - 'modal_button_attr' => '', - 'modal_button_label' => empty($this->ok_label) ? psm_get_lang('system', 'ok') : $this->ok_label, - ); - break; - } - - if(sizeof($buttons)) { - $this->tpl->addTemplateDataRepeat($tpl_id, 'buttons', $buttons); - } + $has_cancel = ($this->type == self::MODAL_TYPE_OK) ? false : true; + $button_type = ($this->type == self::MODAL_TYPE_DANGER) ? 'danger' : 'primary'; + $button_label = empty($this->ok_label) ? psm_get_lang('system', 'ok') : $this->ok_label; $message = !empty($this->message) ? $this->message : ''; $matches = array(); @@ -181,9 +138,13 @@ class Modal implements ModalInterface { } $this->tpl->addTemplateData($tpl_id, array( - 'modal_id' => $this->modal_id, - 'modal_title' => !empty($this->title) ? $this->title : psm_get_lang('system', 'title'), - 'modal_body' => $message, + 'modal_id' => $this->modal_id, + 'modal_title' => !empty($this->title) ? $this->title : psm_get_lang('system', 'title'), + 'modal_body' => $message, + '?has_cancel' => $has_cancel, + 'label_cancel' => psm_get_lang('system', 'cancel'), + 'modal_button_type' => $button_type, + 'modal_button_label'=> $button_label, )); diff --git a/src/psm/Util/Updater/StatusNotifier.class.php b/src/psm/Util/Updater/StatusNotifier.class.php index 0d07ad43..045a662c 100644 --- a/src/psm/Util/Updater/StatusNotifier.class.php +++ b/src/psm/Util/Updater/StatusNotifier.class.php @@ -223,37 +223,14 @@ class StatusNotifier { return false; } + $sms = psm_build_sms(); + if(!$sms) { + return false; + } + // we have to build an userlist for the log table.. $userlist = array(); - // open the right class - // not making this any more dynamic, because perhaps some gateways need custom settings (like Mollie) - switch(strtolower(psm_get_conf('sms_gateway'))) { - case 'mosms': - $sms = new \psm\Txtmsg\Mosms(); - break; - case 'inetworx': - $sms = new \psm\Txtmsg\Inetworx(); - break; - case 'mollie': - $sms = new \psm\Txtmsg\Mollie(); - $sms->setGateway(1); - break; - case 'spryng': - $sms = new \psm\Txtmsg\Spryng(); - break; - case 'clickatell': - $sms = new \psm\Txtmsg\Clickatell(); - break; - case 'textmarketer': - $sms = new \psm\Txtmsg\Textmarketer(); - break; - } - - // copy login information from the config file - $sms->setLogin(psm_get_conf('sms_gateway_username'), psm_get_conf('sms_gateway_password')); - $sms->setOriginator(psm_get_conf('sms_from')); - // add all users to the recipients list foreach ($users as $user) { $userlist[] = $user['user_id']; diff --git a/src/templates/config/config.tpl.html b/src/templates/config/config.tpl.html index ff9fcf96..c99a27f1 100755 --- a/src/templates/config/config.tpl.html +++ b/src/templates/config/config.tpl.html @@ -1,13 +1,13 @@ -
+
-
+
{label_general}
@@ -46,11 +46,11 @@
- +
-
+
{label_settings_email}
@@ -94,12 +94,18 @@
+
+
+ + +
+
- +
-
+
{label_settings_sms}
@@ -138,12 +144,18 @@
+
+
+ + +
+
- +
-
+
{label_settings_log}
@@ -157,7 +169,7 @@
- +
diff --git a/src/templates/main_modal.tpl.html b/src/templates/main_modal.tpl.html index de480fd2..09251429 100644 --- a/src/templates/main_modal.tpl.html +++ b/src/templates/main_modal.tpl.html @@ -7,10 +7,8 @@

{modal_body}

diff --git a/static/js/scripts.js b/static/js/scripts.js index e3676c24..77a8b6f9 100755 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -6,9 +6,8 @@ $().ready(function() { } var $modal_id = $this.attr('data-modal-id') || 'main'; var $modal = $('#' + $modal_id + 'Modal'); - var href = $this.attr('href'); if($modal.length) { - $modal.find('.modalOKButton').attr('href', href); + $modal.find('.modalOKButton').data('modal-origin', $this); var param = $this.attr('data-modal-param'); if(param) { @@ -18,6 +17,7 @@ $().ready(function() { $($modal).find('span.modalP' + (index+1)).text(value); } } + scroll(0, 0); $modal.modal('show'); } else { // Just in case we forgot the dialog box @@ -28,6 +28,18 @@ $().ready(function() { } return false; }); + + $('.modalOKButton').click(function(e) { + var $this = $(this); + var $origin = $this.data('modal-origin'); + if ($origin.is('a')) { + window.location = $origin.attr('href'); + } else { + $origin.next('input[type=hidden]').attr('value', 1); + $origin.closest('form').submit(); + } + return false; + }); psm_flash_message(); psm_tooltips();