Revert "Allow sysadmins to define static responses which are immutable for the user"
This reverts commit 84ffd59c0c3ff78bca5fbcd2c8893b741f36c9ba.
| | |
| | | // Note: useful when SMTP server stores sent mail in user mailbox |
| | | $rcmail_config['no_save_sent_messages'] = false; |
| | | |
| | | // A static list of canned responses which are immutable for the user |
| | | $rcmail_config['compose_responses_static'] = array( |
| | | // array('name' => 'Canned Response 1', 'text' => 'Static Response One'), |
| | | // array('name' => 'Canned Response 2', 'text' => 'Static Response Two'), |
| | | ); |
| | | |
| | | // ---------------------------------- |
| | | // PLUGINS |
| | | // ---------------------------------- |
| | |
| | | * These are stored in local config and user preferences. |
| | | * |
| | | * @param boolean True to sort the list alphabetically |
| | | * @param boolean True if only this user's responses shall be listed |
| | | * @return array List of the current user's stored responses |
| | | */ |
| | | public function get_compose_responses($sorted = false, $user_only = false) |
| | | public function get_compose_responses($sorted = false) |
| | | { |
| | | $responses = array(); |
| | | |
| | | if (!$user_only) { |
| | | foreach ($this->config->get('compose_responses_static', array()) as $response) { |
| | | if (empty($response['key'])) |
| | | $response['key'] = substr(md5($response['name']), 0, 16); |
| | | $response['static'] = true; |
| | | $response['class'] = 'readonly'; |
| | | $k = $sorted ? '0000-' . strtolower($response['name']) : $response['key']; |
| | | $responses[$k] = $response; |
| | | } |
| | | } |
| | | |
| | | foreach ($this->config->get('compose_responses', array()) as $response) { |
| | | if (empty($response['key'])) |
| | | $response['key'] = substr(md5($response['name']), 0, 16); |
| | |
| | | this.responses_list = new rcube_list_widget(this.gui_objects.responseslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | this.responses_list.addEventListener('select', function(list){ |
| | | var win, id = list.get_single_selection(); |
| | | p.enable_command('delete', !!id && $.inArray(id, p.env.readonly_responses) < 0); |
| | | p.enable_command('delete', !!id); |
| | | if (id && (win = p.get_frame_window(p.env.contentframe))) { |
| | | p.set_busy(true); |
| | | p.location_href({ _action:'edit-response', _key:id, _framed:1 }, win); |
| | |
| | | // edit-response |
| | | if (($key = get_input_value('_key', RCUBE_INPUT_GPC))) { |
| | | foreach ($responses as $i => $response) { |
| | | if (empty($response['key'])) |
| | | $response['key'] = substr(md5($response['name']), 0, 16); |
| | | if ($response['key'] == $key) { |
| | | $RESPONSE_RECORD = $response; |
| | | $RESPONSE_RECORD['index'] = $i; |
| | |
| | | } |
| | | |
| | | // save response |
| | | if ($RCMAIL->action == 'save-response' && isset($_POST['_name']) && !$RESPONSE_RECORD['static']) { |
| | | if ($RCMAIL->action == 'save-response' && isset($_POST['_name'])) { |
| | | $name = trim(get_input_value('_name', RCUBE_INPUT_POST)); |
| | | $text = trim(get_input_value('_text', RCUBE_INPUT_POST)); |
| | | |
| | | if (!empty($_REQUEST['_framed'])) |
| | | $RCMAIL->output->framed = 1; |
| | | |
| | | if (!empty($name) && !empty($text)) { |
| | | $dupes = 0; |
| | |
| | | $responses[] = $response; |
| | | } |
| | | |
| | | $responses = array_filter($responses, function($item){ return empty($item['static']); }); |
| | | if ($RCMAIL->user->save_prefs(array('compose_responses' => array_values($responses)))) { |
| | | if ($RCMAIL->user->save_prefs(array('compose_responses' => $responses))) { |
| | | $RCMAIL->output->show_message('successfullysaved', 'confirmation'); |
| | | $RCMAIL->output->command('parent.update_response_row', $response, $key); |
| | | $RCMAIL->overwrite_action('edit-response'); |
| | | $RCMAIL->output->command('update_response_row', $response, $key); |
| | | $RESPONSE_RECORD = $response; |
| | | } |
| | | } |
| | |
| | | global $RCMAIL, $OUTPUT, $RESPONSE_RECORD; |
| | | |
| | | // Set form tags and hidden fields |
| | | $disabled = !empty($RESPONSE_RECORD['static']); |
| | | $key = $RESPONSE_RECORD['key']; |
| | | list($form_start, $form_end) = get_form_tags($attrib, 'save-response', $key, array('name' => '_key', 'value' => $key)); |
| | | unset($attrib['form'], $attrib['id']); |
| | |
| | | $label = rcube_label('responsename'); |
| | | |
| | | $table->add('title', html::label('ffname', Q(rcube_label('responsename')))); |
| | | $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], array('id' => 'ffname', 'size' => $attrib['size'], 'disabled' => $disabled), 'text')); |
| | | $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], array('id' => 'ffname', 'size' => $attrib['size']), 'text')); |
| | | |
| | | $table->add('title', html::label('fftext', Q(rcube_label('responsetext')))); |
| | | $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows'], 'disabled' => $disabled), 'textarea')); |
| | | $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows']), 'textarea')); |
| | | |
| | | $out .= $table->show($attrib); |
| | | $out .= $form_end; |
| | |
| | | return $out; |
| | | } |
| | | |
| | | $OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static'])); |
| | | $OUTPUT->add_handler('responseform', 'rcube_response_form'); |
| | | $OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-response' ? 'savenewresponse' : 'editresponse'))); |
| | | |
| | |
| | | |
| | | if (!empty($name) && !empty($text)) { |
| | | $dupes = 0; |
| | | $responses = $RCMAIL->get_compose_responses(false, true); |
| | | $responses = $RCMAIL->get_compose_responses(); |
| | | foreach ($responses as $resp) { |
| | | if (strcasecmp($name, preg_replace('/\s\(\d+\)$/', '', $resp['name'])) == 0) |
| | | $dupes++; |
| | |
| | | |
| | | if ($RCMAIL->action == 'delete-response') { |
| | | if ($key = get_input_value('_key', RCUBE_INPUT_GPC)) { |
| | | $responses = $RCMAIL->get_compose_responses(false, true); |
| | | $responses = $RCMAIL->get_compose_responses(); |
| | | foreach ($responses as $i => $response) { |
| | | if (empty($response['key'])) |
| | | $response['key'] = substr(md5($response['name']), 0, 16); |
| | |
| | | } |
| | | |
| | | if ($deleted) { |
| | | $RCMAIL->output->command('display_message', rcube_label('deletedsuccessfully'), 'confirmation'); |
| | | $RCMAIL->output->command('display_message', rcube_label('successfullydeleted'), 'confirmation'); |
| | | $RCMAIL->output->command('remove_response', $key); |
| | | } |
| | | |
| | |
| | | |
| | | // set client env |
| | | $OUTPUT->add_gui_object('responseslist', $attrib['id']); |
| | | $OUTPUT->set_env('readonly_responses', array_values(array_map(function($rec){ return $rec['key']; }, |
| | | array_filter($plugin['list'], function($item){ return !empty($item['static']); })))); |
| | | |
| | | return $out; |
| | | } |
| | |
| | | height: 18px; |
| | | } |
| | | |
| | | #identities-table tbody tr.readonly td |
| | | { |
| | | font-style: italic; |
| | | } |
| | | |
| | | #subscription-table tr.virtual td |
| | | { |
| | | color: #666; |
| | |
| | | |
| | | <div id="formfooter"> |
| | | <div class="footerindent"> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" condition="!env:readonly" /> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | #identities-table tbody tr.readonly td { |
| | | font-style: italic; |
| | | } |
| | | |
| | | #folder-details, |
| | | #identity-details { |
| | | position: absolute; |
| | |
| | | </div> |
| | | |
| | | <div class="footerleft formbuttons"> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" condition="!env:readonly" /> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" /> |
| | | </div> |
| | | |
| | | <roundcube:include file="/includes/footer.html" /> |