From: Michael M Slusarz Date: Mon, 17 Aug 2009 21:22:09 +0000 (-0600) Subject: Re-add some accounts management code that went missing on merge. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b09d56b740ab779862340a568a56944726e04856;p=horde.git Re-add some accounts management code that went missing on merge. Also, provide some more information on the accounts pref page. --- diff --git a/imp/js/accountsmanagement.js b/imp/js/accountsmanagement.js new file mode 100644 index 000000000..84c77f745 --- /dev/null +++ b/imp/js/accountsmanagement.js @@ -0,0 +1,58 @@ +/** + * Provides the javascript for managing accounts. + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + */ + +var ImpAccountsmanagement = { + // Variables set by other code: confirm_delete + + _sendData: function(a, d) + { + $('accounts_action').setValue(a) + $('accounts_data').setValue(d); + $('prefs').submit(); + }, + + clickHandler: function(e) + { + if (e.isRightClick()) { + return; + } + + var elt = e.element(); + + while (Object.isElement(elt)) { + if (elt.hasClassName('accountsdelete')) { + if (window.confirm(this.confirm_delete)) { + this._sendData('delete', elt.up('TR').readAttribute('id').substring(11)); + } + e.stop(); + return; + } + + switch (elt.readAttribute('id')) { + case 'add_button': + this._sendData('add', ''); + break; + + case 'cancel_button': + this._sendData('', ''); + break; + + case 'new_button': + this._sendData('new', ''); + break; + } + + elt = elt.up(); + } + } + +}; + +document.observe('dom:loaded', function() { + var am = ImpAccountsmanagement; + document.observe('click', am.clickHandler.bindAsEventListener(am)); +}); diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 1cc52bb8c..ca69960db 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -406,6 +406,14 @@ class IMP_Application extends Horde_Registry_Application /* Add necessary javascript files here (so they are added to the * document HEAD). */ switch ($group) { + case 'accounts': + Horde::addScriptFile('accountsmanagement.js', 'imp', true); + + Horde::addInlineScript(array( + 'ImpAccountsmanagement.confirm_delete = ' . Horde_Serialize::serialize(_("Are you sure you want to delete this account?"), Horde_Serialize::JSON, Horde_Nls::getCharset()) + )); + break; + case 'flags': Horde::addScriptFile('colorpicker.js', 'horde', true); Horde::addScriptFile('flagmanagement.js', 'imp', true); @@ -462,6 +470,10 @@ class IMP_Application extends Horde_Registry_Application case 'flagmanagement': $this->_prefsFlagManagement(); return false; + + case 'accountsmanagement': + $this->_prefsAccountsManagement(); + return false; } } @@ -726,6 +738,47 @@ class IMP_Application extends Horde_Registry_Application } } + /** + * TODO + */ + protected function _prefsAccountsManagement() + { + $vars = Horde_Variables::getDefaultVariables(); + + switch ($vars->accounts_action) { + case 'add': + if (!$vars->accounts_server || + !$vars->accounts_username) { + $GLOBALS['notification']->push(_("Missing required values."), 'horde.error'); + } else { + /* Port is not required. */ + $port = $vars->accounts_port; + if (!$port) { + $port = ($vars->accounts_type == 'imap') ? 143 : 110; + } + + $imp_accounts = IMP_Accounts::singleton(); + $imp_accounts->addAccount(array( + 'port' => $port, + 'secure' => $vars->accounts_secure, + 'server' => $vars->accounts_server, + 'type' => $vars->accounts_type, + 'username' => $vars->accounts_username + )); + $GLOBALS['notification']->push(sprintf(_("Account \"%s\" added."), $vars->accounts_server), 'horde.success'); + } + break; + + case 'delete': + $imp_accounts = IMP_Accounts::singleton(); + $tmp = $imp_accounts->getAccount($vars->accounts_data); + if ($imp_accounts->deleteAccount($vars->accounts_data)) { + $GLOBALS['notification']->push(sprintf(_("Account \"%s\" deleted."), $tmp['server']), 'horde.success'); + } + break; + } + } + /* horde/services/cache.php methods. */ /** diff --git a/imp/templates/prefs/accountsmanagement.inc b/imp/templates/prefs/accountsmanagement.inc index dd6cba01f..89b55b0f4 100644 --- a/imp/templates/prefs/accountsmanagement.inc +++ b/imp/templates/prefs/accountsmanagement.inc @@ -53,8 +53,10 @@ $delete_img = Horde::img('delete.png'); - - + + + + @@ -68,6 +70,14 @@ $delete_img = Horde::img('delete.png'); + + + + + + + + diff --git a/imp/themes/screen.css b/imp/themes/screen.css index fe84d4771..074447470 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -330,9 +330,12 @@ table.accountsmanagement thead td, table.flagmanagement thead td { font-weight: bold; text-decoration: underline; } -table.accountsmanagement td.required { +table.accountsmanagement td.required, .accountsNotSecure { color: red; } +.accountsSecure { + color: green; +} table.flagmanagement tbody td.flagicon { text-align: center; }
ServerType?