Make result of rcmail::get_compose_responses() always an (indexed) array; add plugin hook for updating user prefs: 'preferences_update'
| | |
| | | */ |
| | | public function get_compose_responses($sorted = false) |
| | | { |
| | | $responses = array(); |
| | | foreach ($this->config->get('compose_responses', array()) as $response) { |
| | | if (empty($response['key'])) |
| | | $response['key'] = substr(md5($response['name']), 0, 16); |
| | |
| | | $responses[$k] = $response; |
| | | } |
| | | |
| | | // sort list by name |
| | | if ($sorted) { |
| | | // sort list by name |
| | | ksort($responses, SORT_LOCALE_STRING); |
| | | return array_values($responses); |
| | | } |
| | | |
| | | return $responses; |
| | | return array_values($responses); |
| | | } |
| | | |
| | | |
| | |
| | | if (!$this->ID) |
| | | return false; |
| | | |
| | | $config = $this->rc->config; |
| | | $old_prefs = (array)$this->get_prefs(); |
| | | $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; |
| | | |
| | | // merge (partial) prefs array with existing settings |
| | | $save_prefs = $a_user_prefs + $old_prefs; |