#1326320 - PATCH for R424

Ryan Rittenhouse ryanmr at goshen.edu
Fri Dec 22 15:03:36 CET 2006


I've put this on a fresh SVN and haven't been able to login. It give me the login screen 
ok but when I try to logon it give me a blank screen. Anyone else having this problem?

-Ryan

Network Administrator
Goshen College
(574) 535-7004

Black.myst wrote:
> Hello
> 
> I installed Pierre's diff on the last SVN.  I join the updated diff.
> 
> I applied the original patch to R400, added the new files, update to 
> R424 and fix some conflicts.
> 
> I have NOT include SQL to diff, the table structure to handle mailrule is:
> CREATE TABLE `mailrules` (
>   `mailrule_id` int(11) NOT NULL auto_increment,
>   `from` varchar(128) default NULL,
>   `to` varchar(128) default NULL,
>   `subject` varchar(128) default NULL,
>   `user_id` int(10) unsigned NOT NULL default '0',
>   `del` tinyint(1) NOT NULL default '0',
>   `location` varchar(128) default NULL,
>   PRIMARY KEY  (`mailrule_id`)
> ) TYPE=MyISAM;
> 
> 
> Note : The SQL script is NOT compatible with SQLite :-(
> 
> Black Myst
> 
> 
> Thomas Bruederli a écrit :
>> Hi Pierre
>>
>> Please update your local copy to the latest revision (svn update) and
>> then create the diff again. The current one removes newly added 
>> features :-(
>>
>> ~Thomas
>>
>>
>> Pierre Lena wrote:
>>> Here is the diff file.
>>>
>>> Regards.
>>>
> 
> ------------------------------------------------------------------------
> 
> Index: program/include/main.inc
> ===================================================================
> --- program/include/main.inc	(revision 424)
> +++ program/include/main.inc	(working copy)
> @@ -1341,6 +1341,12 @@
>          'itentitieslist' => 'rcmail_identities_list',
>          'identityframe' => 'rcmail_identity_frame',
>          'identityform' => 'rcube_identity_form',
> +		
> +		// ADDED TO HANDLE MAILRULES
> +		'mailruleslist' => 'rcmail_mailrule_list',
> +		'mailrulesframe' => 'rcmail_mailrule_frame',
> +		'mailrulesform' => 'rcube_mailrule_form',
> +		//
>          'foldersubscription' => 'rcube_subscription_form',
>          'createfolder' => 'rcube_create_folder_form',
>          'renamefolder' => 'rcube_rename_folder_form',
> Index: program/localization/fr/labels.inc
> ===================================================================
> --- program/localization/fr/labels.inc	(revision 424)
> +++ program/localization/fr/labels.inc	(working copy)
> @@ -146,10 +146,11 @@
>  $labels['ldappublicsearchfield'] = 'Recherche sur';
>  $labels['ldappublicsearchform'] = 'Chercher un contact';
>  $labels['ldappublicsearch'] = 'Recherche';
> -$labels['settingsfor'] = 'Paramètres pour';
> -$labels['preferences'] = 'Préférences';
>  $labels['userpreferences'] = 'Préférences utilisateur';
>  $labels['editpreferences'] = 'Editer les préférences utilisateur';
> +$labels['mailrules'] = 'Règles';
> +$labels['managemailrules'] = 'Gérer les règles de messagerie';
> +$labels['newmailrule'] = 'Nouvelle règle';
>  $labels['identities'] = 'Identités';
>  $labels['manageidentities'] = 'Gérer les identités pour ce compte';
>  $labels['newidentity'] = 'Nouvelle identité';
> @@ -180,4 +181,6 @@
>  $labels['sortby'] = 'Trier par';
>  $labels['sortasc'] = 'Tri ascendant';
>  $labels['sortdesc'] = 'Tri descendant';
> +$labels['location'] = 'Destination';
> +
>  ?>
> Index: program/js/app.js
> ===================================================================
> --- program/js/app.js	(revision 424)
> +++ program/js/app.js	(working copy)
> @@ -247,9 +247,15 @@
>  
>  
>        case 'settings':
> -        this.enable_command('preferences', 'identities', 'save', 'folders', true);
> +        this.enable_command('preferences', 'identities', 'save', 'folders', 'mailrules', true);
>          
> -        if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity')
> +		if(this.env.action=='mailrules' || this.env.action=='edit-mailrule' || this.env.action=='add-mailrule')
> +		 this.enable_command('edit', 'add', 'delete', true);
> +		 
> +		if (this.env.action=='edit-mailrule' || this.env.action=='add-mailrule')
> +          this.enable_command('save', true);
> +		
> +        if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='')
>            this.enable_command('edit', 'add', 'delete', true);
>  
>          if (this.env.action=='edit-identity' || this.env.action=='add-identity')
> @@ -269,6 +275,18 @@
>              this.identity_list.highlight_row(this.env.iid);
>            }
>  
> +		  //ADDED TO HANDLE MAILRULES
> +		  if (this.gui_objects.mailruleslist)
> +          {
> +          this.mailrule_list = new rcube_list_widget(this.gui_objects.mailruleslist, {multiselect:false, draggable:false, keyboard:false});
> +          this.mailrule_list.addEventListener('select', function(o){ pmailrule_select(o); });
> +          this.mailrule_list.init();
> +          this.mailrule_list.focus();
> +
> +          if (this.env.iid)
> +            this.mailrule_list.highlight_row(this.env.iid);
> +          }
> +		  //
>          break;
>  
>        case 'login':
> @@ -556,22 +574,18 @@
>        case 'add':
>          if (this.task=='addressbook')
>            this.load_contact(0, 'add');
> -
> -        /* LDAP stuff, has to be re-written with new address book
> -          if (!window.frames[this.env.contentframe].rcmail)
> -            this.load_contact(0, 'add');
> -          else
> -            {
> -            if (window.frames[this.env.contentframe].rcmail.selection.length)
> -              this.add_ldap_contacts();
> -            else
> -              this.load_contact(0, 'add');
> -            }
> -        */
>          else if (this.task=='settings')
>            {
> -          this.identity_list.clear_selection();
> -          this.load_identity(0, 'add-identity');
> +	        if(this.env.action=='mailrules')
> +			{
> +				this.mailrule_list.clear_selection();
> +				this.load_mailrule(0, 'add-mailrule');		  
> +			}
> +			else
> +			{
> +				this.identity_list.clear_selection();
> +				this.load_identity(0, 'add-identity');
> +			}
>            }
>          break;
>  
> @@ -628,7 +642,12 @@
>            this.delete_contacts();
>          // user settings task
>          else if (this.task=='settings')
> -          this.delete_identity();
> +		{
> +		  if(this.env.action=='edit-mailrule')
> +		    this.delete_mailrule();
> +		  else
> +			this.delete_identity();
> +		}
>          break;
>  
>  
> @@ -903,12 +922,19 @@
>          this.goto_url('');
>          break;
>  
> +	  case 'mailrules':
> +	    this.goto_url('mailrules');
> +        break;
> +	  
>        case 'identities':
>          this.goto_url('identities');
>          break;
>            
>        case 'delete-identity':
>          this.delete_identity();
> +	 
> +	  case 'delete-mailrule':
> +        this.delete_mailrule();
>          
>        case 'folders':
>          this.goto_url('folders');
> @@ -2368,6 +2394,13 @@
>        this.load_identity(id, 'edit-identity');
>      };
>  
> +  this.mailrule_select = function(list)
> +  {
> +   var id;
> +    if (id = list.get_single_selection())
> +      this.load_mailrule(id, 'edit-mailrule');
> +  }
> +  
>    // load contact record
>    this.load_identity = function(id, action)
>      {
> @@ -2388,10 +2421,32 @@
>        this.set_busy(true);
>        target.location.href = this.env.comm_path+'&_action='+action+'&_iid='+id+add_url;
>        }
> +	  
>      return true;
>      };
>  
> +   // load rule record
> +    this.load_mailrule = function(id, action)
> +    {
> +    if (action=='edit-mailrule' && (!id || id==this.env.iid))
> +      return false;
> +	  
> +    var add_url = '';
> +    var target = window;
> +    if (this.env.contentframe && window.frames && window.frames[this.envcontentframe])
> +      {
> +      add_url = '&_framed=1';
> +      target = window.frames[this.env.contentframe];
> +      document.getElementById(this.env.contentframe).style.visibility = 'inherit';
> +      }
>  
> +    if (action && (id || action=='add-mailrule'))
> +      {
> +      this.set_busy(true);
> +      target.location.href = this.env.comm_path+'&_action='+action+'&_iid='+id+add_url;
> +      }
> +    return true;
> +    };
>  
>    this.delete_identity = function(id)
>      {
> @@ -2403,21 +2458,26 @@
>      if (!id)
>        id = this.env.iid ? this.env.iid : selection[0];
>  
> -/*
> -    // 'remove' row from list (just hide it)
> -    if (this.identity_rows && this.identity_rows[id].obj)
> -      {
> -      this.clear_selection();
> -      this.identity_rows[id].obj.style.display = 'none';
> -      }
> -*/
> -
>      // if (this.env.framed && id)
>      this.goto_url('delete-identity', '_iid='+id, true);
>      return true;
>      };
>  
> +  this.delete_mailrule = function(id)
> +    {
> +    // exit if no mailbox specified or if selection is empty
> +    var selection = this.mailrule_list.get_selection();
> +    if (!(selection.length || this.env.iid))
> +      return;
> +    
> +    if (!id)
> +      id = this.env.iid ? this.env.iid : selection[0];
>  
> +    // if (this.env.framed && id)
> +    this.goto_url('delete-mailrule', '_iid='+id, true);
> +    return true;
> +    };
> +
>    // tell server to create and subscribe a new mailbox
>    this.create_folder = function(name)
>      {
> Index: program/steps/settings/save_identity.inc
> ===================================================================
> --- program/steps/settings/save_identity.inc	(revision 424)
> +++ program/steps/settings/save_identity.inc	(working copy)
> @@ -145,6 +145,6 @@
>  
>  
>  // go to next step
> -rcmail_overwrite_action($_POST['_framed'] ? 'edit-identitiy' : 'identities');
> +rcmail_overwrite_action($_POST['_framed'] ? 'edit-identity' : 'identities');
>  
>  ?>
> \ No newline at end of file
> Index: program/steps/settings/save_mailrule.inc
> ===================================================================
> --- program/steps/settings/save_mailrule.inc	(revision 0)
> +++ program/steps/settings/save_mailrule.inc	(revision 0)
> @@ -0,0 +1,139 @@
> +<?php
> +
> +/*
> + +-----------------------------------------------------------------------+
> + | program/steps/settings/save_mailrule.inc                              |
> + |                                                                       |
> + | This file is part of the RoundCube Webmail client                     |
> + | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
> + | Licensed under the GNU GPL                                            |
> + |                                                                       |
> + | PURPOSE:                                                              |
> + |   Save an identity record or to add a new one                         |
> + |                                                                       |
> + +-----------------------------------------------------------------------+
> + | Author: Thomas Bruederli <roundcube at gmail.com>                        |
> + +-----------------------------------------------------------------------+
> +
> + $Id: save_identity.inc 344 2006-09-14 03:49:28Z estadtherr $
> +
> +*/
> +
> +$a_save_cols = array('from', 'to', 'subject', 'location');
> +
> +
> +// check input
> +if (empty($_POST['_from']) && empty($_POST['_to']) && empty($_POST['_subject']) && empty($_POST['_location']) )
> +  {
> +  show_message('formincomplete', 'warning');
> +  rcmail_overwrite_action('edit-mailrule');
> +  return;
> +  }
> +
> +
> +// update an existing contact
> +if ($_POST['_iid'])
> +  {
> +  $a_write_sql = array();
> +
> +  foreach ($a_save_cols as $col)
> +    {
> +    $fname = '_'.$col;
> +    if (!isset($_POST[$fname]))
> +      continue;
> +
> +    $a_write_sql[] = sprintf("%s=%s",
> +                             $DB->quoteIdentifier($col),
> +                             $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols))));
> +    }
> +
> +
> +  if (sizeof($a_write_sql))
> +    {
> +    $DB->query("UPDATE ".get_table_name('mailrules')."
> +                SET ".join(', ', $a_write_sql)."
> +                WHERE  mailrule_id=?
> +                AND    user_id=?
> +                AND    del<>1",
> +                get_input_value('_iid', RCUBE_INPUT_POST),
> +                $_SESSION['user_id']);
> +                       
> +    $updated = $DB->affected_rows();
> +    }
> +       
> +  if ($updated)
> +    {
> +		show_message('successfullysaved', 'confirmation');
> +
> +    // mark all other identities as 'not-default'
> +    if (!empty($_POST['_standard']))
> +      $DB->query("UPDATE ".get_table_name('mailrule')."
> +                  SET ".$DB->quoteIdentifier('standard')."='0'
> +                  WHERE  user_id=?
> +                  AND    mailrule_id<>?
> +                  AND    del<>1",
> +                  $_SESSION['user_id'],
> +                  get_input_value('_iid', RCUBE_INPUT_POST));
> +    
> +    if ($_POST['_framed'])
> +      {
> +      // update the changed col in list
> +      // ...      
> +      }
> +    }
> +  else if ($DB->is_error())
> +    {
> +    // show error message
> +    show_message('errorsaving', 'error');
> +    rcmail_overwrite_action('edit-mailrule');
> +    }
> +  }
> +
> +// insert a new contact
> +else
> +  {
> +  $a_insert_cols = $a_insert_values = array();
> +
> +  foreach ($a_save_cols as $col)
> +    {
> +    $fname = '_'.$col;
> +    if (!isset($_POST[$fname]))
> +      continue;
> +    
> +    $a_insert_cols[] = $DB->quoteIdentifier($col);
> +    $a_insert_values[] = $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols)));
> +    }
> +    
> +  if (sizeof($a_insert_cols))
> +    {
> +    $DB->query("INSERT INTO ".get_table_name('mailrules')."
> +                (user_id, ".join(', ', $a_insert_cols).")
> +                VALUES (?, ".join(', ', $a_insert_values).")",
> +                $_SESSION['user_id']);
> +
> +    $insert_id = $DB->insert_id(get_sequence_name('mailrules'));
> +    }
> +    
> +  if ($insert_id)
> +    {
> +    $_GET['_iid'] = $insert_id;
> +
> +    if ($_POST['_framed'])
> +      {
> +      // add contact row or jump to the page where it should appear
> +      // ....
> +      }
> +    }
> +  else
> +    {
> +    // show error message
> +    show_message('errorsaving', 'error');
> +    rcmail_overwrite_action('edit-mailrule');
> +    }
> +  }
> +
> +
> +// go to next step
> +rcmail_overwrite_action($_POST['_framed'] ? 'edit-mailrule' : 'mailrules');
> +
> +?>
> \ No newline at end of file
> Index: program/steps/settings/func.inc
> ===================================================================
> --- program/steps/settings/func.inc	(revision 424)
> +++ program/steps/settings/func.inc	(working copy)
> @@ -230,8 +230,36 @@
>    return $out;
>    }
>  
> +function rcmail_mailrule_list($attrib)
> +{
> + global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
>  
>  
> +  // get contacts from DB
> +  $sql_result = $DB->query("SELECT * FROM ".get_table_name('mailrules')."
> +                            WHERE  del<>1
> +                            AND    user_id=?",
> +                            $_SESSION['user_id']);
> +
> +
> +  // add id to message list table if not specified
> +  if (!strlen($attrib['id']))
> +    $attrib['id'] = 'mailruleslist';
> +
> +  // define list of cols to be displayed
> +  $a_show_cols = array('from', 'to', 'subject','location');
> +
> +  // create XHTML table  
> +  $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'mailrule_id');
> +  
> +  // set client env
> +  $javascript = sprintf("%s.gui_object('mailruleslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
> +  $OUTPUT->add_script($javascript);    
> +
> +  return $out;
> +  }
> +
> +
>  // similar function as in /steps/addressbook/edit.inc
>  function get_form_tags($attrib, $action, $add_hidden=array())
>    {
> Index: program/steps/settings/delete_mailrule.inc
> ===================================================================
> --- program/steps/settings/delete_mailrule.inc	(revision 0)
> +++ program/steps/settings/delete_mailrule.inc	(revision 0)
> @@ -0,0 +1,53 @@
> +<?php
> +
> +/*
> + +-----------------------------------------------------------------------+
> + | program/steps/settings/delete_mailrule.inc                            |
> + |                                                                       |
> + | This file is part of the RoundCube Webmail client                     |
> + | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
> + | Licensed under the GNU GPL                                            |
> + |                                                                       |
> + | PURPOSE:                                                              |
> + |   Delete the submitted mailrules (IIDs) from the database             |
> + |                                                                       |
> + +-----------------------------------------------------------------------+
> + | Author: Thomas Bruederli <roundcube at gmail.com>                        |
> + +-----------------------------------------------------------------------+
> +
> + $Id: delete_mailrule.inc
> +
> +*/
> +
> +$REMOTE_REQUEST = $_GET['_remote'] ? TRUE : FALSE;
> +
> +if ($_GET['_iid'])
> +  {
> +  $DB->query("UPDATE ".get_table_name('mailrules')."
> +              SET    del=1
> +              WHERE  user_id=?
> +              AND    mailrule_id IN (".$_GET['_iid'].")",
> +              $_SESSION['user_id']);
> +
> +  $count = $DB->affected_rows();
> +  if ($count)
> +    {
> +    $commands = show_message('deletedsuccessfully', 'confirmation');
> +    }
> +
> +  // send response
> +  if ($REMOTE_REQUEST)
> +    rcube_remote_response($commands);
> +  }
> +
> +
> +if ($REMOTE_REQUEST)
> +  exit;
> +
> +
> +// go to mailrules page
> +$_action = 'mailrules';
> +
> +// overwrite action variable  
> +$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
> +?>
> \ No newline at end of file
> Index: program/steps/settings/mailrules.inc
> ===================================================================
> --- program/steps/settings/mailrules.inc	(revision 0)
> +++ program/steps/settings/mailrules.inc	(revision 0)
> @@ -0,0 +1,46 @@
> +<?php
> +
> +/*
> + +-----------------------------------------------------------------------+
> + | program/steps/settings/manage_mailrules.inc                           |
> + |                                                                       |
> + | This file is part of the RoundCube Webmail client                     |
> + | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
> + | Licensed under the GNU GPL                                            |
> + |                                                                       |
> + | PURPOSE:                                                              |
> + |    Provide functionality to create/delete/rename mail rules           |
> + |                                                                       |
> + +-----------------------------------------------------------------------+
> + | Author: Thomas Bruederli <roundcube at gmail.com>                        |
> + +-----------------------------------------------------------------------+
> +
> + $Id: manage_mailrules.inc N/A 2006-12-11 mangoose $
> +
> +*/
> +
> +if ($USER_DATA = $DB->fetch_assoc($sql_result))
> +  $PAGE_TITLE = sprintf('%s (%s@%s)', rcube_label('mailrules'), $USER_DATA['username'], $USER_DATA['mail_host']);
> +
> +$OUTPUT->include_script('list.js');
> +
> +function rcmail_mailrule_frame($attrib)
> +  {
> +  global $OUTPUT, $JS_OBJECT_NAME;
> +
> +  if (!$attrib['id'])
> +    $attrib['id'] = 'rcmMailRuleFrame';
> +
> +  $attrib['name'] = $attrib['id'];
> +
> +  $OUTPUT->add_script(sprintf("%s.set_env('contentframe', '%s');", $JS_OBJECT_NAME, $attrib['name']));
> +
> +  $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
> +  $out = '<iframe'. $attrib_str . '></iframe>';
> +
> +  return $out;
> +  }
> +
> +
> +parse_template('mailrules');
> +?>
> \ No newline at end of file
> Index: program/steps/settings/edit_mailrule.inc
> ===================================================================
> --- program/steps/settings/edit_mailrule.inc	(revision 0)
> +++ program/steps/settings/edit_mailrule.inc	(revision 0)
> @@ -0,0 +1,128 @@
> +<?php
> +
> +/*
> + +-----------------------------------------------------------------------+
> + | program/steps/settings/edit_identity.inc                              |
> + |                                                                       |
> + | This file is part of the RoundCube Webmail client                     |
> + | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
> + | Licensed under the GNU GPL                                            |
> + |                                                                       |
> + | PURPOSE:                                                              |
> + |   Show edit form for a identity record or to add a new one            |
> + |                                                                       |
> + +-----------------------------------------------------------------------+
> + | Author: Thomas Bruederli <roundcube at gmail.com>                        |
> + +-----------------------------------------------------------------------+
> +
> + $Id: edit_mailrule.inc 392 2006-12-03 22:32:16Z mangoose $
> +
> +*/
> +
> +if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-mailrule')
> +  {
> +  $DB->query("SELECT * FROM ".get_table_name('mailrules')."
> +              WHERE  mailrule_id=?
> +              AND    user_id=?
> +              AND    del<>1",
> +              get_input_value('_iid', RCUBE_INPUT_GPC),
> +              $_SESSION['user_id']);
> +  
> +  $MAILRULE_RECORD = $DB->fetch_assoc();
> +  
> +  if (is_array($MAILRULE_RECORD))
> +    $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $MAILRULE_RECORD['mailrule_id']));
> +    
> +  $PAGE_TITLE = rcube_label('edititem');
> +  }
> +else
> +  $PAGE_TITLE = rcube_label('newitem');
> +
> +
> +$OUTPUT->include_script('list.js');
> +
> +
> +function rcube_mailrule_form($attrib)
> +  {
> +  global $MAILRULE_RECORD, $JS_OBJECT_NAME, $OUTPUT;
> +
> +  $OUTPUT->include_script('tiny_mce/tiny_mce_src.js');
> +  $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," .
> +                                    "apply_source_formatting : true," .
> +                                    "content_css : '\$__skin_path' + '/editor_content.css'," .
> +                                    "popups_css : '\$__skin_path' + '/editor_popups.css'," .
> +                                    "editor_css : '\$__skin_path' + '/editor_ui.css'," .
> +                                    "theme : 'advanced'," .
> +                                    "theme_advanced_toolbar_location : 'top'," .
> +                                    "theme_advanced_toolbar_align : 'left'," .
> +                                    "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," .
> +                                    "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," .
> +                                    "theme_advanced_buttons3 : '' });");
> +
> +  if (!$MAILRULE_RECORD && $GLOBALS['_action']!='add-mailrule')
> +    return rcube_label('notfound');
> +
> +  // add some labels to client
> +  rcube_add_label('noemailwarning');
> +  rcube_add_label('nonamewarning');
> +
> +
> +  list($form_start, $form_end) = get_form_tags($attrib, 'save-mailrule', array('name' => '_iid', 'value' => $MAILRULE_RECORD['mailrule_id']));
> +  unset($attrib['form']);
> +
> +
> +  // list of available cols
> +  $a_show_cols = array('from'        => array('type' => 'text'),
> +                       'to'          => array('type' => 'text'),
> +                       'subject' 	 => array('type' => 'text'),
> +					   'location'	 => array('type' => 'text'));
> +
> +
> +  // a specific part is requested
> +  if ($attrib['part'])
> +    {
> +		$colprop = $a_show_cols[$attrib['part']];
> +		if (is_array($colprop))
> +		{
> +		 $out = $form_start;
> +		 $out .= rcmail_get_edit_field($attrib['part'], $MAILRULE_RECORD[$attrib['part']], $attrib, $colprop['type']); 
> +		 return $out;
> +		}
> +    else
> +		return '';
> +    }
> +
> +
> +  // return the complete edit form as table
> +  $out = "$form_start<table>\n\n";
> +
> +  foreach ($a_show_cols as $col => $colprop)
> +    {
> +    $attrib['id'] = 'rcmfd_'.$col;
> +
> +    if (strlen($colprop['onclick']))
> +      $attrib['onclick'] = $colprop['onclick'];
> +    else
> +      unset($attrib['onclick']);
> +
> +    $label = strlen($colprop['label']) ? $colprop['label'] : $col;
> +    $value = rcmail_get_edit_field($col, $MAILRULE_RECORD[$col], $attrib, $colprop['type']);
> +
> +    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
> +                    $attrib['id'],
> +                    rep_specialchars_output(rcube_label($label)),
> +                    $value);
> +    }
> +
> +  $out .= "\n</table>$form_end";
> +
> +  return $out;  
> +  }
> +
> +
> +
> +if ($_action=='add-mailrule' && template_exists('addmailrule'))
> +  parse_template('addmailrule');
> +
> +parse_template('editmailrule');
> +?>
> Index: program/steps/mail/check_recent.inc
> ===================================================================
> --- program/steps/mail/check_recent.inc	(revision 424)
> +++ program/steps/mail/check_recent.inc	(working copy)
> @@ -25,36 +25,37 @@
>  
>  foreach ($a_mailboxes as $mbox_name)
>    {
> -  if ($mbox_name == $IMAP->get_mailbox_name())
> -    {
> -    if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
> -      {
> -      $count = $IMAP->messagecount();
> -      $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
> +	if ($mbox_name == $IMAP->get_mailbox_name())
> +	{
> +		if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
> +		{
> +		$count = $IMAP->messagecount();
> +		$unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
>  
> -      $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unread_count);
> -      $commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
> -      $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
> -      $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());
> +		// add new message headers to list
> +		$a_headers = array();
> +		for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
> +			{
> +				$header = $IMAP->get_headers($id, NULL, FALSE);
> +				if ($header->recent)
> +				{
> +					$a_headers[] = $header;
> +				}	
> +			}
>  
> -      // add new message headers to list
> -      $a_headers = array();
> -      for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
> -        {
> -        $header = $IMAP->get_headers($id, NULL, FALSE);
> -        if ($header->recent)
> -          $a_headers[] = $header;
> -        }
> -
> -      $commands .= rcmail_js_message_list($a_headers, TRUE);
> -      }
> +		$commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unread_count);
> +		$commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
> +		$commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
> +		$commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());
> +		
> +		$commands .= rcmail_js_message_list($a_headers, TRUE);
> +		}
>      }
>    else
>      {
> -    if ($IMAP->messagecount($mbox_name, 'RECENT'))
> -      $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $IMAP->messagecount($mbox_name, 'UNSEEN'));
> -    }
> +		if ($IMAP->messagecount($mbox_name, 'RECENT'))
> +			$commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $IMAP->messagecount($mbox_name, 'UNSEEN'));
> +	}
>    }
> -
>  rcube_remote_response($commands);
>  ?>
> Index: program/steps/mail/func.inc
> ===================================================================
> --- program/steps/mail/func.inc	(revision 424)
> +++ program/steps/mail/func.inc	(working copy)
> @@ -23,6 +23,8 @@
>  require_once('lib/enriched.inc');
>  
>  
> +
> +
>  $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';
>  
>  if (empty($_SESSION['mbox'])){
> @@ -293,7 +295,7 @@
>  // return the message list as HTML table
>  function rcmail_message_list($attrib)
>    {
> -  global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT, $JS_OBJECT_NAME;
> +  global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT, $JS_OBJECT_NAME,$DB;
>  
>    $skin_path = $CONFIG['skin_path'];
>    $image_tag = '<img src="%s%s" alt="%s" border="0" />';
> @@ -406,9 +408,60 @@
>  
>    $a_js_message_arr = array();
>  
> +  //ADDED TO HANDLE MAILRULE
> +	$SQL_RESULT = $DB->query("SELECT * FROM ".get_table_name('mailrules')"
> +                            WHERE  del<>1
> +                            AND    user_id=?",
> +                            $_SESSION['user_id']);
> +	while ($sql_arr = $DB->fetch_assoc($SQL_RESULT))
> +		{
> +			$SQL_ARRA[] = $sql_arr;
> +		}
> +  //
>    // create row for each message
> -  foreach ($a_headers as $i => $header)  //while (list($i, $header) = each($a_headers))
> +  foreach ($a_headers as $i => $header)
>      {
> +	//ADDED TO HANDLE MAILRULE
> +
> +	$from_parts = $IMAP->decode_address_list($header->from);
> +	$to_parts = $IMAP->decode_address_list($header->to);
> +	$moved_message = 0;
> +
> +	foreach($SQL_ARRA as $sql_arr)
> +	{
> +	   $need_to_be_moved = 0;
> +	foreach($from_parts as $from_part)
> +	 {
> +		if(empty($sql_arr['from']) || stristr($from_part['name'],$sql_arr['from']) || stristr($from_part['address'],$sql_arr['from']))
> +		{
> +			$need_to_be_moved++;
> +		}
> +	}
> +	
> +	foreach($to_parts as $to_part)
> +	{
> +		if(empty($sql_arr['to']) || stristr($to_part['name'],$sql_arr['to']) || stristr($to_part['address'],$sql_arr['to']))
> +		{
> +			$need_to_be_moved++;
> +		}
> +	}
> +	   
> +	if(empty($sql_arr['subject']) || stristr(rep_specialchars_output($IMAP->decode_header($header->subject), 'html', 'all'),$sql_arr['subject']))
> +		{
> +			$need_to_be_moved++;
> +		}
> +	   
> +	  if($need_to_be_moved == 3)
> +	  {
> +	    $IMAP->move_message($header->uid,$sql_arr['location'],$_SESSION['mbox']);
> +	    $moved_message = 1;
> +	    break;
> +        }
> +	}
> +	if($moved_message == 0)
> +	   {
> +	//
> +		
>      $message_icon = $attach_icon = '';
>      $js_row_arr = array();
>      $zebra_class = $i%2 ? 'even' : 'odd';
> @@ -468,12 +521,17 @@
>      
>      if (sizeof($js_row_arr))
>        $a_js_message_arr[$header->uid] = $js_row_arr;
> +
> +    //ADDED TO HANDLE MAILRULE
>      }
> -  
> +    //
> +    }
> +     
>    // complete message table
>    $out .= "</tbody></table>\n";
>    
>    
> +  
>    $message_count = $IMAP->messagecount();
>    
>    // set client env
> Index: skins/default/settings.css
> ===================================================================
> --- skins/default/settings.css	(revision 424)
> +++ skins/default/settings.css	(working copy)
> @@ -59,6 +59,7 @@
>    padding-right: 10px;
>  }
>  
> +#mailrules-list,
>  #identities-list,
>  #folder-manager
>  {
> @@ -76,6 +77,7 @@
>    height: expression((parseInt(document.documentElement.clientHeight)-215)+'px');
>  }
>  
> +#mailrules-table,
>  #identities-table
>  {
>    width: 600px;
> @@ -83,11 +85,13 @@
>    background-color: #F9F9F9;
>  }
>  
> +#mailrules-table tbody td,
>  #identities-table tbody td
>  {
>    cursor: pointer;
>  }
>  
> +#mailrule-frame,
>  #identity-frame
>  {
>    position: relative;
> @@ -95,6 +99,7 @@
>    border: 1px solid #999999;
>  }
>  
> +#mailrule-details,
>  #identity-details
>  {
>    margin-top: 30px;
> @@ -102,6 +107,7 @@
>    border: 1px solid #999999;
>  }
>  
> +#mailrule-details table td.title,
>  #identity-details table td.title
>  {
>    color: #666666;
> @@ -121,6 +127,7 @@
>  
>  #userprefs-title,
>  #identity-title,
> +#mailrule-title,
>  div.boxtitle,
>  #subscription-table thead td
>  {
> Index: skins/default/templates/editmailrule.html
> ===================================================================
> --- skins/default/templates/editmailrule.html	(revision 0)
> +++ skins/default/templates/editmailrule.html	(revision 0)
> @@ -0,0 +1,37 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +<html xmlns="http://www.w3.org/1999/xhtml">
> +<head>
> +<title><roundcube:object name="pagetitle" /></title>
> +<roundcube:include file="/includes/links.html" />
> +<link rel="stylesheet" type="text/css" href="/settings.css" />
> +</head>
> +<body>
> +
> +<roundcube:include file="/includes/taskbar.html" />
> +<roundcube:include file="/includes/header.html" />
> +<roundcube:include file="/includes/settingstabs.html" />
> +
> +
> +<div id="mailrules-list">
> +<roundcube:object name="mailruleslist" id="mailrules-table" class="records-table" cellspacing="0" summary="MailRules list" editIcon="" />
> +
> +<p><roundcube:button command="add" type="input" label="newmailrule" class="button" /></p>
> +
> +<div id="mailrule-details">
> +<div id="mailrule-title"><roundcube:label name="edititem" /></div>
> +
> +<div style="padding:15px;">
> +<roundcube:object name="mailrulesform" size="40" />
> +
> +<p><br />
> +<roundcube:button command="delete" type="input" class="button" label="delete" /> 
> +<roundcube:button command="save" type="input" class="button" label="save" />
> +</p>
> +</div>
> +</div>
> +</div>
> +
> +<roundcube:include file="/includes/settingscripts.html" />
> +
> +</body>
> +</html>
> Index: skins/default/templates/mail.html
> ===================================================================
> --- skins/default/templates/mail.html	(revision 424)
> +++ skins/default/templates/mail.html	(working copy)
> @@ -26,11 +26,9 @@
>  </div>
>  
>  <div id="messagecountbar">
> -<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
>  <roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
>   <roundcube:object name="messageCountDisplay" /> 
>  <roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
> -<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
>  </div>
>  
>  <div id="mailboxlist-header"><roundcube:label name="mailboxlist" /></div>
> @@ -77,7 +75,7 @@
>  <roundcube:button command="select-all" label="all" classAct="active" /> 
>  <roundcube:button command="select-all" prop="unread" label="unread" classAct="active" /> 
>  <roundcube:button command="select-none" label="none" classAct="active" />    
> -<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="image" width="120" id="quotadisplay" />
> +<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" />
>  </div>
>  
>  </body>
> Index: skins/default/templates/addmailrule.html
> ===================================================================
> --- skins/default/templates/addmailrule.html	(revision 0)
> +++ skins/default/templates/addmailrule.html	(revision 0)
> @@ -0,0 +1,36 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +<html xmlns="http://www.w3.org/1999/xhtml">
> +<head>
> +<title><roundcube:object name="pagetitle" /></title>
> +<roundcube:include file="/includes/links.html" />
> +<link rel="stylesheet" type="text/css" href="/settings.css" />
> +</head>
> +<body>
> +
> +<roundcube:include file="/includes/taskbar.html" />
> +<roundcube:include file="/includes/header.html" />
> +<roundcube:include file="/includes/settingstabs.html" />
> +
> +
> +<div id="mailrules-list">
> +<roundcube:object name="mailruleslist" id="mailrules-table" class="records-table" cellspacing="0" summary="MailRules list" editIcon="" />
> +
> +<p><roundcube:button command="add" type="input" label="newmailrule" class="button" /></p>
> +
> +<div id="mailrule-details">
> +<div id="mailrule-title"><roundcube:label name="edititem" /></div>
> +
> +<div style="padding:15px;">
> +<roundcube:object name="mailrulesform" size="40" />
> +
> +<p><br />
> +<roundcube:button command="save" type="input" class="button" label="save" />
> +</p>
> +</div>
> +</div>
> +</div>
> +
> +<roundcube:include file="/includes/settingscripts.html" />
> +
> +</body>
> +</html>
> \ No newline at end of file
> Index: skins/default/templates/message.html
> ===================================================================
> --- skins/default/templates/message.html	(revision 424)
> +++ skins/default/templates/message.html	(working copy)
> @@ -11,11 +11,9 @@
>  <roundcube:include file="/includes/header.html" />
>  
>  <div id="messagecountbar">
> -<roundcube:button command="firstmessage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessage" />
> -<roundcube:button command="previousmessage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessage" />
> +<roundcube:button command="previousmessage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
>   <roundcube:object name="messageCountDisplay" /> 
> -<roundcube:button command="nextmessage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessage" />
> -<roundcube:button command="lastmessage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessage" />
> +<roundcube:button command="nextmessage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
>  </div>
>  
>  <div id="messagetoolbar">
> Index: skins/default/templates/mailrules.html
> ===================================================================
> --- skins/default/templates/mailrules.html	(revision 0)
> +++ skins/default/templates/mailrules.html	(revision 0)
> @@ -0,0 +1,23 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +<html xmlns="http://www.w3.org/1999/xhtml">
> +<head>
> +<title><roundcube:object name="pagetitle" /></title>
> +<roundcube:include file="/includes/links.html" />
> +<link rel="stylesheet" type="text/css" href="/settings.css" />
> +</head>
> +<body>
> +
> +<roundcube:include file="/includes/taskbar.html" />
> +<roundcube:include file="/includes/header.html" />
> +<roundcube:include file="/includes/settingstabs.html" />
> +
> +<div id="mailrules-list">
> +<roundcube:object name="mailruleslist" id="mailrules-table" class="records-table" cellspacing="0" summary="MailRules list" editIcon="" />
> +
> +<p><roundcube:button command="add" type="input" label="newmailrule" class="button" /></p>
> +</div>
> +
> +<roundcube:include file="/includes/settingscripts.html" />
> +
> +</body>
> +</html>
> Index: skins/default/templates/addressbook.html
> ===================================================================
> --- skins/default/templates/addressbook.html	(revision 424)
> +++ skins/default/templates/addressbook.html	(working copy)
> @@ -21,11 +21,9 @@
>  </div>
>  
>  <div id="abookcountbar">
> -<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstpage" />
>  <roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previouspage" />
>   <roundcube:object name="recordsCountDisplay" /> 
>  <roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextpage" />
> -<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastpage" />
>  </div>
>  
>  <div id="addresslist">
> Index: skins/default/templates/compose.html
> ===================================================================
> --- skins/default/templates/compose.html	(revision 424)
> +++ skins/default/templates/compose.html	(working copy)
> @@ -106,9 +106,7 @@
>  <td align="right">
>  <roundcube:label name="charset" />: <roundcube:object name="charsetSelector" tabindex="8" />
>  </td>
> -<td align="right">
> - <roundcube:label name="editortype" />: </td>
> -<roundcube:object name="editorSelector" tabindex="9" />
> +
>  </tr></tbody></table>
>  
>  </td>
> Index: skins/default/templates/ldappublicsearch.html
> ===================================================================
> --- skins/default/templates/ldappublicsearch.html	(revision 424)
> +++ skins/default/templates/ldappublicsearch.html	(working copy)
> @@ -22,7 +22,7 @@
>  <roundcube:object name="ldappublicaddresslist"
>    id="ldappublicaddresslist"
>    cellspacing="0"
> -  summary="LDAP email address list" />
> +  summary="Ldap email address list" />
>  </div>
>  
>  <roundcube:include file="/includes/ldapscripts.html" />
> Index: skins/default/templates/login.html
> ===================================================================
> --- skins/default/templates/login.html	(revision 424)
> +++ skins/default/templates/login.html	(working copy)
> @@ -24,7 +24,7 @@
>  <form name="form" action="./" method="post">
>  <roundcube:object name="loginform" form="form" />
>  
> -<p style="text-align: center;"><input type="submit" class="button" value="<roundcube:label name="login" />" /></p>
> +<p style="text-align: center;"><input type="submit" class="button" value="<roundcube:label name="login" />" />
>  
>  </form>
>  </div>
> Index: skins/default/includes/settingstabs.html
> ===================================================================
> --- skins/default/includes/settingstabs.html	(revision 424)
> +++ skins/default/includes/settingstabs.html	(working copy)
> @@ -1,3 +1,6 @@
>  <div id="tabsbar">
> -<span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span><span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span><span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
> +<span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
> +<span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span>
> +<span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
> +<span id="settingstabmailrules" class="tablink"><roundcube:button command="mailrules" type="link" label="mailrules" title="managemailrules" class="tablink" /></span>
>  </div>
> Index: index.php
> ===================================================================
> --- index.php	(revision 424)
> +++ index.php	(working copy)
> @@ -358,7 +358,7 @@
>  
>    if ($_action=='add-identity' || $_action=='edit-identity')
>      include('program/steps/settings/edit_identity.inc');
> -
> +	
>    if ($_action=='delete-identity')
>      include('program/steps/settings/delete_identity.inc');
>    
> @@ -372,6 +372,20 @@
>        $_action=='create-folder' || $_action=='rename-folder' || $_action=='delete-folder')
>      include('program/steps/settings/manage_folders.inc');
>  
> +	
> +// ADDED TO HANDLE MAILRULE
> +  if ($_action=='mailrules')
> +    include('program/steps/settings/mailrules.inc');
> +
> +  if ($_action=='save-mailrule')
> +    include('program/steps/settings/save_mailrule.inc');
> +	
> +  if ($_action=='edit-mailrule' || $_action=='add-mailrule')
> +    include('program/steps/settings/edit_mailrule.inc');
> +	
> +  if ($_action=='delete-mailrule')
> +    include('program/steps/settings/delete_mailrule.inc');
> +//
>    }
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 




More information about the Dev mailing list