Make result of rcmail::get_compose_responses() always an (indexed) array; add plugin hook for updating user prefs: 'preferences_update'

pull/134/head
Thomas Bruederli 11 years ago
parent 460a3eaaac
commit 4f432f880a

@ -355,6 +355,7 @@ class rcmail extends rcube
*/ */
public function get_compose_responses($sorted = false) public function get_compose_responses($sorted = false)
{ {
$responses = array();
foreach ($this->config->get('compose_responses', array()) as $response) { foreach ($this->config->get('compose_responses', array()) as $response) {
if (empty($response['key'])) if (empty($response['key']))
$response['key'] = substr(md5($response['name']), 0, 16); $response['key'] = substr(md5($response['name']), 0, 16);
@ -362,13 +363,12 @@ class rcmail extends rcube
$responses[$k] = $response; $responses[$k] = $response;
} }
if ($sorted) {
// sort list by name // sort list by name
if ($sorted) {
ksort($responses, SORT_LOCALE_STRING); ksort($responses, SORT_LOCALE_STRING);
return array_values($responses);
} }
return $responses; return array_values($responses);
} }

@ -163,8 +163,16 @@ class rcube_user
if (!$this->ID) if (!$this->ID)
return false; return false;
$plugin = $this->rc->plugins->exec_hook('preferences_update', array(
'userid' => $this->ID, 'prefs' => $a_user_prefs, 'old' => (array)$this->get_prefs()));
if (!empty($plugin['abort'])) {
return;
}
$a_user_prefs = $plugin['prefs'];
$old_prefs = $plugin['old'];
$config = $this->rc->config; $config = $this->rc->config;
$old_prefs = (array)$this->get_prefs();
// merge (partial) prefs array with existing settings // merge (partial) prefs array with existing settings
$save_prefs = $a_user_prefs + $old_prefs; $save_prefs = $a_user_prefs + $old_prefs;

Loading…
Cancel
Save