'purge_spam_keep'));
}
+$prefGroups['accounts'] = array(
+ 'column' => _("General Options"),
+ 'label' => _("Additional Accounts"),
+ 'desc' => _("Configure additional mail accounts to display."),
+ 'members' => array('accountsmanagement')
+);
+
$prefGroups['compose'] = array(
'column' => _("Message Options"),
'label' => _("Message Composition"),
// End Login Tasks preferences
+// Accounts preferences
+
+// UI for flag management.
+$_prefs['accountsmanagement'] = array(
+ 'type' => 'special'
+);
+
+$_prefs['accounts'] = array(
+ 'value' => json_encode(array()),
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'implicit');
+
+// End Accounts preferences
+
+
// Message Composition preferences
// Link to the stationery preferences.
--- /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));
+});
--- /dev/null
+<?php
+/**
+ * The IMP_Accounts class provides an interface to deal with storing
+ * connection details of additional accounts to access within IMP.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Accounts
+{
+ /**
+ * Singleton instance.
+ *
+ * @var IMP_Accounts
+ */
+ static protected $_instance;
+
+ /**
+ * The cached list of accounts.
+ *
+ * @var array
+ */
+ protected $_accounts = null;
+
+ /**
+ * Attempts to return a reference to a concrete object instance.
+ * It will only create a new instance if no instance currently exists.
+ *
+ * @return IMP_Accounts The created concrete instance.
+ */
+ static public function singleton()
+ {
+ if (!isset(self::$_instance)) {
+ self::$_instance = new IMP_Accounts();
+ }
+
+ return self::$_instance;
+ }
+
+ /**
+ * Save the accounts list to the prefs backend.
+ */
+ protected function _save()
+ {
+ $GLOBALS['prefs']->setValue('accounts', json_encode($this->_accounts));
+ }
+
+ /**
+ * Return the raw list of servers.
+ *
+ * @return array An array of server information.
+ */
+ public function getList()
+ {
+ $this->_loadList();
+ return $this->_accounts;
+ }
+
+ /**
+ * Loads the flag list from the preferences into the local cache.
+ */
+ protected function _loadList()
+ {
+ if (is_null($this->_accounts)) {
+ $this->_accounts = json_decode($GLOBALS['prefs']->getValue('accounts'), true);
+ }
+ }
+
+ /**
+ * Retrieve information on a single account.
+ *
+ * @param integer $label The label ID.
+ *
+ * @return array The configuration array, or false if label not found.
+ */
+ public function getAccount($label)
+ {
+ $this->_loadList();
+
+ return isset($this->_accounts[$label])
+ ? $this->_accounts[$label]
+ : false;
+ }
+
+ /**
+ * Add an account.
+ *
+ * @param array $config The necessary config:
+ * <pre>
+ * 'port' - (integer) The remote port.
+ * 'secure' -(string) Either 'auto', 'no', or 'yes'.
+ * 'server' - (string) The server hostspec.
+ * 'type' - (string) Either 'imap' or 'pop3'.
+ * 'username' - (string) The username to use.
+ * </pre>
+ *
+ * @return integer The label ID.
+ */
+ public function addAccount($config)
+ {
+ $this->_loadList();
+
+ $this->_accounts[] = $config;
+ $this->_save();
+
+ end($this->_accounts);
+ return key($this->_accounts);
+ }
+
+ /**
+ * Delete an account from the list.
+ *
+ * @param integer $label The label ID.
+ *
+ * @return boolean True on success.
+ */
+ public function deleteAccount($label)
+ {
+ if ($this->getAccount($label)) {
+ unset($this->_accounts[$label]);
+ $this->_save();
+ return true;
+ }
+
+ return false;
+ }
+
+}
--- /dev/null
+<input type="hidden" name="accounts_action" id="accounts_action" />
+<input type="hidden" name="accounts_data" id="accounts_data" />
+
+<?php if (Horde_Util::getFormData('accounts_action') == 'new'): ?>
+<table class="accountsmanagement">
+ <tr>
+ <td class="item"><?php echo _("Type") ?>:</td>
+ <td class="item">
+ <select name="accounts_type">
+ <option value="imap" selected="selected"><?php echo _("IMAP") ?></option>
+ <option value="pop3"><?php echo _("POP3") ?></option>
+ </select>
+ </td>
+ <td class="required">*</td>
+ </tr>
+ <tr>
+ <td class="item"><?php echo _("Server") ?>:</td>
+ <td class="item"><input name="accounts_server" size="30"/></td>
+ <td class="required">*</td>
+ </tr>
+ <tr>
+ <td class="item"><?php echo _("Username") ?>:</td>
+ <td class="item"><input name="accounts_username" size="30"/></td>
+ <td class="required">*</td>
+ </tr>
+ <tr>
+ <td class="item"><?php echo _("Port") ?>:</td>
+ <td class="item"><input name="accounts_port" size="10"/></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td class="item"><?php echo _("Use secure connection?") ?></td>
+ <td class="item">
+ <select name="accounts_secure">
+ <option value="yes" selected="selected"><?php echo _("Required") ?></option>
+ <option value="auto" selected="selected"><?php echo _("Use if available") ?></option>
+ <option value="no" selected="selected"><?php echo _("Never") ?></option>
+ </select>
+ </td>
+ <td></td>
+ </tr>
+</table>
+
+<input id="add_button" type="button" class="button" value="<?php echo _("Save") ?>" />
+<input id="cancel_button" type="button" class="button" value="<?php echo _("Cancel") ?>" />
+<?php else: ?>
+<?php
+$imp_accounts = IMP_Accounts::singleton();
+$accounts_list = $imp_accounts->getList();
+$delete_img = Horde::img('delete.png');
+?>
+
+<table class="accountsmanagement">
+ <thead>
+ <tr>
+ <td>Server</td>
+ <td>Type</td>
+ <td></td>
+ </tr>
+ </thead>
+ <tbody>
+<?php if (empty($accounts_list)): ?>
+ <tr>
+ <td class="noneconfigured" colspan="3"><?php echo _("No accounts configured") ?></td>
+ </tr>
+<?php else: ?>
+<?php foreach ($accounts_list as $key => $val): ?>
+ <tr id="accountsid_<?php echo $key ?>">
+ <td><?php echo htmlspecialchars($val['server']) ?></td>
+ <td><?php echo htmlspecialchars($val['type']) ?></td>
+ <td><a class="accountsdelete" href="#"><?php echo $delete_img ?></a></td>
+ </tr>
+<?php endforeach; ?>
+<?php endif; ?>
+ </tbody>
+</table>
+
+<input id="new_button" type="submit" class="button" value="<?php echo _("Add Account") ?>" />
+<?php endif; ?>
background-image: url("graphics/mail_forwarded.png");
}
-/* Flag management (prefs) styles. */
-table.flagmanagement {
+/* Accounts/flag management (prefs) styles. */
+table.accountsmanagement, table.flagmanagement {
padding-bottom: 10px;
}
-table.flagmanagement td {
+table.accountsmanagement td, table.flagmanagement td {
padding-right: 12px;
}
-table.flagmanagement thead td {
+table.accountsmanagement thead td, table.flagmanagement thead td {
font-weight: bold;
text-decoration: underline;
}
+table.accountsmanagement td.required {
+ color: red;
+}
table.flagmanagement tbody td.flagicon {
text-align: center;
}
+table.accountsmanagement td.noneconfigured {
+ font-style: italic;
+}
.folderunsub {
background: #bbb;