thomascube
2006-01-25 5e35126796f14e0910a007972779d96fd49e1789
Added folder purge function and some checks


10 files modified
86 ■■■■ changed files
index.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_imap.inc 14 ●●●● patch | view | raw | blame | history
program/js/app.js 44 ●●●● patch | view | raw | blame | history
program/js/common.js 6 ●●●● patch | view | raw | blame | history
program/lib/MDB2/Driver/Manager/fbsql.php 1 ●●●● patch | view | raw | blame | history
program/steps/addressbook/func.inc 3 ●●●●● patch | view | raw | blame | history
program/steps/mail/check_recent.inc 4 ●●●● patch | view | raw | blame | history
program/steps/mail/folders.inc 8 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 3 ●●●●● patch | view | raw | blame | history
skins/default/templates/mail.html 1 ●●●● patch | view | raw | blame | history
index.php
@@ -244,7 +244,7 @@
  if ($_action=='addcontact')
    include('program/steps/mail/addcontact.inc');
  if ($_action=='expunge')
  if ($_action=='expunge' || $_action=='purge')
    include('program/steps/mail/folders.inc');
  if ($_action=='check-recent')
program/include/rcube_imap.inc
@@ -986,8 +986,18 @@
    
    if ($msg_count>0)
      {
      $this->clear_message_cache($mailbox.'.msg');
      return iil_C_ClearFolder($this->conn, $mailbox);
      $cleared = iil_C_ClearFolder($this->conn, $mailbox);
      // make sure the message count cache is cleared as well
      if ($cleared)
        {
        $this->clear_message_cache($mailbox.'.msg');
        $a_mailbox_cache = $this->get_cache('messagecount');
        unset($a_mailbox_cache[$mailbox]);
        $this->update_cache('messagecount', $a_mailbox_cache);
        }
      return $cleared;
      }
    else
      return 0;
program/js/app.js
@@ -145,6 +145,9 @@
        if (this.env.messagecount)
          this.enable_command('select-all', 'select-none', 'sort', 'expunge', true);
        if (this.env.messagecount && this.env.mailbox==this.env.trash_mailbox)
          this.enable_command('purge', true);
        this.set_page_buttons();
        // focus this window
@@ -622,9 +625,10 @@
          this.expunge_mailbox(this.env.mailbox);
        break;
      case 'clear-mailbox':
        //if (this.env.messagecount)
          //this.clear_mailbox(this.env.mailbox);
      case 'purge':
      case 'empty-mailbox':
        if (this.env.messagecount)
          this.purge_mailbox(this.env.mailbox);
        break;
@@ -1435,6 +1439,28 @@
    };
  this.purge_mailbox = function(mbox)
    {
    var lock = false;
    var add_url = '';
    if (!confirm(this.get_label('purgefolderconfirm')))
      return false;
    // lock interface if it's the active mailbox
    if (mbox == this.env.mailbox)
       {
       lock = true;
       this.set_busy(true, 'loading');
       add_url = '&_reload=1';
       }
    // send request to server
    var url = '_mbox='+escape(mbox);
    this.http_request('purge', url+add_url, lock);
    };
  // move selected messages to the specified mailbox
  this.move_messages = function(mbox)
    {
@@ -2068,6 +2094,7 @@
      return false;
      
    //if (this.env.framed && add_url=='')
    //  add_url = '&_framed=1';
    
    if (action && (cid || action=='add'))
@@ -2081,9 +2108,9 @@
  this.delete_contacts = function()
    {
    // exit if no mailbox specified or if selection is empty
    if (!(this.selection.length || this.env.cid))
    if (!(this.selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm')))
      return;
    var a_cids = new Array();
    if (this.env.cid)
@@ -2821,7 +2848,7 @@
    if (request_obj.__lock)
      this.set_busy(false);
  console(request_obj.responseText);
  console(request_obj.get_text());
    // if we get javascript code from server -> execute it
    if (request_obj.get_text() && (ctype=='text/javascript' || ctype=='application/x-javascript'))
@@ -2837,9 +2864,12 @@
        break;
      case 'list':
        if (this.env.messagecount)
          this.enable_command('purge', (this.env.mailbox==this.env.trash_mailbox));
      case 'expunge':
        this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false);
        break;
        break;
      }
    request_obj.reset();
program/js/common.js
@@ -6,11 +6,11 @@
 | Copyright (C) 2005, RoundCube Dev, - Switzerland                      |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | Modified:2005/11/06 (roundcube)                                       |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 +-----------------------------------------------------------------------+
 $Id$
*/
@@ -271,7 +271,7 @@
    {
    var reg_str = '([a-z0-9][-a-z0-9\.\+_]*)\@(([-a-z0-9][\.]?)*[a-z0-9]\.[a-z]{2,9})';
    var reg1 = inline ? new RegExp(reg_str, 'i') : new RegExp('^'+reg_str+'$', 'i');
    var reg2 = /[\._\-\@]{2}/;
    var reg2 = /[\._\-]{2}/;
    return reg1.test(input) && !reg2.test(input) ? true : false;
    }
  return false;
program/lib/MDB2/Driver/Manager/fbsql.php
@@ -478,7 +478,6 @@
     * @return mixed data array on success, a MDB2 error on failure
     * @access public
     */
     */
    function listTableIndexes($table)
    {
        $db =& $this->getDBInstance();
program/steps/addressbook/func.inc
@@ -91,6 +91,9 @@
  
  $OUTPUT->add_script($javascript);  
  // add some labels to client
  rcube_add_label('deletecontactconfirm');
  return $out;
  }
program/steps/mail/check_recent.inc
@@ -22,10 +22,10 @@
$REMOTE_REQUEST = TRUE;
$mbox = $IMAP->get_mailbox_name();
if ($recent_count = $IMAP->messagecount(NULL, 'RECENT'))
if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
  {
  $count = $IMAP->messagecount();
  $unread_count = $IMAP->messagecount(NULL, 'UNSEEN');
  $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
    
  $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox), $unread_count);
  $commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
program/steps/mail/folders.inc
@@ -16,7 +16,6 @@
 +-----------------------------------------------------------------------+
 $Id$
*/
$REMOTE_REQUEST = TRUE;
@@ -26,7 +25,7 @@
// send EXPUNGE command
if ($_action=='expunge')
  {
  $success = $IMAP->expunge();
  $success = $IMAP->expunge($_GET['_mbox']);
  // reload message list if current mailbox  
  if ($success && $_GET['_reload'])
@@ -42,11 +41,12 @@
// clear mailbox
else if ($_action=='purge')
  {
  $success = $IMAP->clear_mailbox();
  $success = $IMAP->clear_mailbox($_GET['_mbox']);
  
  if ($success && $_GET['_reload'])
    {
    $commands = "this.set_env('messagecount', 0);\n";
    $commands = "this.clear_message_list();\n";
    $commands .= "this.set_env('messagecount', 0);\n";
    $commands .= "this.set_env('pagecount', 0);\n";
    $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
    $commands .= sprintf("this.set_unread_count('%s', 0);\n", addslashes($mbox));
program/steps/mail/func.inc
@@ -66,6 +66,9 @@
  global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH;
  static $s_added_script = FALSE;
  static $a_mailboxes;
  // add some labels to client
  rcube_add_label('purgefolderconfirm');
  
// $mboxlist_start = rcube_timer();
  
skins/default/templates/mail.html
@@ -31,6 +31,7 @@
<div id="mailboxcontrols">
<roundcube:label name="folder" />:&nbsp;
<roundcube:button command="expunge" label="compact" classAct="active" />&nbsp;
<roundcube:button command="purge" label="empty" classAct="active" />&nbsp;
</div>