Also, provide some more information on the accounts pref page.
--- /dev/null
+/**
+ * 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));
+});
/* 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);
case 'flagmanagement':
$this->_prefsFlagManagement();
return false;
+
+ case 'accountsmanagement':
+ $this->_prefsAccountsManagement();
+ return false;
}
}
}
}
+ /**
+ * 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. */
/**
<table class="accountsmanagement">
<thead>
<tr>
- <td>Server</td>
- <td>Type</td>
+ <td><?php echo _("Server") ?></td>
+ <td><?php echo _("Type") ?></td>
+ <td><?php echo _("Port") ?></td>
+ <td><?php echo _("Secure") ?>?</td>
<td></td>
</tr>
</thead>
<tr id="accountsid_<?php echo $key ?>">
<td><?php echo htmlspecialchars($val['server']) ?></td>
<td><?php echo htmlspecialchars($val['type']) ?></td>
+ <td><?php echo htmlspecialchars($val['port']) ?></td>
+<?php if ($val['secure'] == 'auto'): ?>
+ <td><?php echo _("Auto") ?></td>
+<?php elseif ($val['secure'] == 'yes'): ?>
+ <td class="accountsSecure"><?php echo _("Yes") ?></td>
+<?php else: ?>
+ <td class="accountsNotSecure"><?php echo _("No") ?></td>
+<?php endif; ?>
<td><a class="accountsdelete" href="#"><?php echo $delete_img ?></a></td>
</tr>
<?php endforeach; ?>
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;
}