alecpl
2009-06-05 0b2ce91f25aed4c174c437e679155d30bd0387bf
- Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI


7 files modified
163 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/rcmail.php 4 ●●●● patch | view | raw | blame | history
program/include/rcube_imap.php 10 ●●●●● patch | view | raw | blame | history
program/js/app.js 61 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 7 ●●●●● patch | view | raw | blame | history
program/steps/mail/mark.inc 77 ●●●● patch | view | raw | blame | history
program/steps/mail/move_del.inc 3 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI
- Fix displaying of big maximum upload filesize (#1485889)
- Added possibility to invert messages selection
- After move/delete from 'show' action display next message instead of messages list (#1485887)
program/include/rcmail.php
@@ -301,10 +301,6 @@
    if (!($this->output instanceof rcube_template))
      $this->output = new rcube_template($this->task, $framed);
    foreach (array('flag_for_deletion','read_when_deleted') as $js_config_var) {
      $this->output->set_env($js_config_var, $this->config->get($js_config_var));
    }
    // set keep-alive/check-recent interval
    if ($keep_alive = $this->config->get('keep_alive')) {
      // be sure that it's less than session lifetime
program/include/rcube_imap.php
@@ -1627,13 +1627,9 @@
    // send expunge command in order to have the moved message
    // really deleted from the source mailbox
    if ($moved) {
      // but only when flag_for_deletion is set to false
      if (!rcmail::get_instance()->config->get('flag_for_deletion', false))
        {
        $this->_expunge($from_mbox, FALSE, $a_uids);
        $this->_clear_messagecount($from_mbox);
        $this->_clear_messagecount($to_mbox);
        }
      $this->_expunge($from_mbox, FALSE, $a_uids);
      $this->_clear_messagecount($from_mbox);
      $this->_clear_messagecount($to_mbox);
    }
    // moving failed
    else if (rcmail::get_instance()->config->get('delete_always', false)) {
program/js/app.js
@@ -1797,13 +1797,13 @@
      lock = true;
      this.set_busy(true, 'movingmessage');
      }
    else if (!this.env.flag_for_deletion)
    else
      this.show_contentframe(false);
    // Hide message command buttons until a message is selected
    this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'viewsource', 'download', false);
    this._with_selected_messages('moveto', lock, add_url, (this.env.flag_for_deletion ? false : true));
    this._with_selected_messages('moveto', lock, add_url);
    };
  // delete selected messages from the current mailbox
@@ -1815,9 +1815,14 @@
    if (!this.env.uid && !selection.length)
      return;
    // if there is a trash mailbox defined and we're not currently in it:
    if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() != String(this.env.trash_mailbox).toLowerCase())
      {
    // if config is set to flag for deletion
    if (this.env.flag_for_deletion)
      this.mark_message('delete');
    // if there isn't a defined trash mailbox or we are in it
    else if (!this.env.trash_mailbox || String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
      this.permanently_remove_messages();
    // if there is a trash mailbox defined and we're not currently in it
    else {
      // if shift was pressed delete it immediately
      if (this.message_list && this.message_list.shiftkey)
        {
@@ -1827,21 +1832,6 @@
      else
        this.move_messages(this.env.trash_mailbox);
      }
    // if there is a trash mailbox defined but we *are* in it:
    else if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
      this.permanently_remove_messages();
    // if there isn't a defined trash mailbox and the config is set to flag for deletion
    else if (!this.env.trash_mailbox && this.env.flag_for_deletion)
      {
      this.mark_message('delete');
      if (this.env.action == 'show')
        this.command('nextmessage', '', this);
      else if (selection.length == 1)
        this.message_list.select_next();
      }
    // if there isn't a defined trash mailbox and the config is set NOT to flag for deletion
    else if (!this.env.trash_mailbox)
      this.permanently_remove_messages();
  };
  // delete the selected messages permanently
@@ -1852,7 +1842,7 @@
      return;
      
    this.show_contentframe(false);
    this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''), true);
    this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''));
    };
  // Send a specifc request with UIDs of all selected messages
@@ -1872,16 +1862,7 @@
        {
        id = selection[n];
        a_uids[a_uids.length] = id;
        if (remove)
          this.message_list.remove_row(id, (n == selection.length-1));
        else
        {
          this.set_message_status(id, 'deleted', true);
          if (this.env.read_when_deleted)
            this.set_message_status(id, 'unread', false);
          this.set_message(id);
        }
        this.message_list.remove_row(id, (n == selection.length-1));
      }
    }
@@ -2029,15 +2010,29 @@
      uid = a_uids[i];
      if (rows[uid])
        {
    this.set_message(uid, 'deleted', true);
        if (rows[uid].unread)
          r_uids[r_uids.length] = uid;
    if (this.env.skip_deleted)
          this.message_list.remove_row(uid, (i == this.message_list.selection.length-1));
    else
      this.set_message(uid, 'deleted', true);
        }
      }
    add_url = '&_from='+(this.env.action ? this.env.action : '');
    if (r_uids.length)
      add_url = '&_ruid='+r_uids.join(',');
      add_url += '&_ruid='+r_uids.join(',');
    if (this.env.skip_deleted) {
      // also send search request to get the right messages
      if (this.env.search_request)
        add_url += '&_search='+this.env.search_request;
      if (this.env.next_uid)
        add_url += '&_next_uid='+this.env.next_uid;
    }
    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url);
    return true;  
  };
program/steps/mail/func.inc
@@ -89,6 +89,13 @@
  $OUTPUT->set_env('quota', $IMAP->get_capability('quota'));
  $OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter());
  if ($CONFIG['flag_for_deletion'])
    $OUTPUT->set_env('flag_for_deletion', true);
  if ($CONFIG['read_when_deleted'])
    $OUTPUT->set_env('read_when_deleted', true);
  if ($CONFIG['skip_deleted'])
    $OUTPUT->set_env('skip_deleted', true);
  if ($CONFIG['trash_mbox'])
    $OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);
  if ($CONFIG['drafts_mbox'])
program/steps/mail/mark.inc
@@ -30,24 +30,85 @@
{
  $flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
  $marked = $IMAP->set_flag($uids, $flag);
  if ($marked == -1) {
    // send error message
    if ($_POST['_from'] != 'show')
      $OUTPUT->command('list_mailbox');
    $OUTPUT->show_message('errormarking', 'error');
    $OUTPUT->send();
    exit;
  }
  if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid']))
    {
  if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
    $uids = get_input_value('_ruid', RCUBE_INPUT_POST);
    $read = $IMAP->set_flag($uids, 'SEEN');
    
    if ($read != -1)
    if ($read != -1 && !$CONFIG['skip_deleted'])
      $OUTPUT->command('flag_deleted_as_read', $uids);
    }
  if ($marked != -1 && ($flag == 'SEEN' || $flag == 'UNSEEN'))
  {
  }
  if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
    $mbox_name = $IMAP->get_mailbox_name();
    $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX'));
  }
  else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
    if ($_POST['_from'] == 'show') {
      if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
    $OUTPUT->command('show_message', $next);
      else
    $OUTPUT->command('command', 'list');
    } else {
      // count messages before changing anything
      $old_count = $IMAP->messagecount();
      $old_pages = ceil($old_count / $IMAP->page_size);
      // refresh saved search set after moving some messages
      if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
        $_SESSION['search'][$search_request] = $IMAP->refresh_search();
      }
      $msg_count      = $IMAP->messagecount();
      $pages          = ceil($msg_count / $IMAP->page_size);
      $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
      $remaining      = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
      // jump back one page (user removed the whole last page)
      if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) {
    $IMAP->set_page($IMAP->list_page-1);
    $_SESSION['page'] = $IMAP->list_page;
    $jump_back = true;
      }
      // update message count display
      $OUTPUT->set_env('messagecount', $msg_count);
      $OUTPUT->set_env('current_page', $IMAP->list_page);
      $OUTPUT->set_env('pagecount', $pages);
      // update mailboxlist
      $mbox = $IMAP->get_mailbox_name();
      $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX'));
//      $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
      $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
      // add new rows from next page (if any)
      if (($jump_back || $nextpage_count > 0)) {
    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
    if (!$jump_back) {
          $a_headers = array_slice($a_headers, -$count, $count);
        }
      rcmail_js_message_list($a_headers, false, false);
      }
    }
  }
  $OUTPUT->send();
}
  
exit;
?>
?>
program/steps/mail/move_del.inc
@@ -44,8 +44,7 @@
        exit;
    }
    if (!$CONFIG['flag_for_deletion'])
        $addrows = true;
    $addrows = true;
}
// delete messages 
else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {