[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: email/inc class.bofilters.inc.php,1.2,1.3 class.
From: |
Angelo Tony Puglisi <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: email/inc class.bofilters.inc.php,1.2,1.3 class.bopreferences.inc.php,1.16,1.17 class.mail_msg_display.inc.php,1.33,1.34 class.uifilters.inc.php,1.2,1.3 |
Date: |
Tue, 22 Jan 2002 08:16:37 -0500 |
Update of /cvsroot/phpgroupware//email/inc
In directory subversions:/tmp/cvs-serv3909/email/inc
Modified Files:
class.bofilters.inc.php class.bopreferences.inc.php
class.mail_msg_display.inc.php class.uifilters.inc.php
Log Message:
implement saving and reading user submitted filter data from prefs, and
preselecting saved values on the edit page
Index: class.bofilters.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.bofilters.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.bofilters.inc.php 20 Jan 2002 23:58:47 -0000 1.2
--- class.bofilters.inc.php 22 Jan 2002 13:16:34 -0000 1.3
***************
*** 16,30 ****
{
var $public_functions = array(
! 'get_langed_labels' => True,
! 'folder' => True,
! 'folder_action' => True,
! 'folder_data' => True
);
! var $filters = Array();
var $template = '';
var $finished_mlist = '';
var $submit_mlist_to_class_form = '';
! var $debug = 3;
var $sieve_to_imap_fields=array();
var $result_set = Array();
--- 16,30 ----
{
var $public_functions = array(
! 'process_submitted_data' => True
);
! var $all_filters = Array();
! var $filter_num = 0;
! //var $this_filter = Array();
var $template = '';
var $finished_mlist = '';
var $submit_mlist_to_class_form = '';
! var $debug = 0;
! var $debug_set_prefs = 0;
var $sieve_to_imap_fields=array();
var $result_set = Array();
***************
*** 53,57 ****
if ($this->debug > 1) { echo 'email.bofilters
*constructor*: msg object NOT yet initialized<br>'; }
$args_array = Array();
! // should we log in or not
$args_array['do_login'] = False;
//$args_array['do_login'] = True;
--- 53,58 ----
if ($this->debug > 1) { echo 'email.bofilters
*constructor*: msg object NOT yet initialized<br>'; }
$args_array = Array();
! // should we log in or not, no, we only need prefs
initialized
! // if any data is needed mail_msg will open stream for
us
$args_array['do_login'] = False;
//$args_array['do_login'] = True;
***************
*** 60,64 ****
$already_initialized = True;
if ($this->debug > 0) { echo 'email.bofilters.
*constructor*: LEAVING<br>'; }
!
$this->sieve_to_imap_fields = Array(
'from' => 'FROM',
--- 61,65 ----
$already_initialized = True;
if ($this->debug > 0) { echo 'email.bofilters.
*constructor*: LEAVING<br>'; }
!
$this->sieve_to_imap_fields = Array(
'from' => 'FROM',
***************
*** 77,191 ****
}
! function process_submitted_data()
{
! if ($this->debug > 0) { echo
'bofilters.process_submitted_data: ENTERING<br>'."\r\n"; }
! if ($this->debug > 1) { echo
'bofilters.process_submitted_data: caling
$this->distill_filter_args<br>'."\r\n"; }
! $this->distill_filter_args();
!
! if ($this->debug > 2) { echo
'bofilters.process_submitted_data: post distill_filter_args; this->filters[]
dump <strong><pre>'; print_r($this->filters); echo "</pre></strong>\r\n"; }
! if ($this->debug > 0) { echo 'bofilters:
process_submitted_data: LEAVING<br>'."\r\n"; }
}
! function distill_filter_args()
{
! if ($this->debug > 2) { echo 'bofilters:
$GLOBALS[HTTP_POST_VARS] count=['.count($GLOBALS['HTTP_POST_VARS']).'] ; dump
<strong><pre>'; print_r($GLOBALS['HTTP_POST_VARS']); echo
"</pre></strong>\r\n"; }
! // do we have data
// we must have data because the form action made this
code run
@reset($GLOBALS['HTTP_POST_VARS']);
! // look for top level "filter_X" array
while(list($key,$value) =
each($GLOBALS['HTTP_POST_VARS']))
{
! if ($this->debug > 1) { echo 'bofilters:
$GLOBALS[HTTP_POST_VARS] key,value walk thru: $key: ['.$key.'] ; $value
DUMP:<pre>'; print_r($value); echo "</pre>\r\n"; }
! if ((strstr($key, 'filter_'))
! && (strstr($key, 'filter_0_source_accounts') ==
False))
! {
! // put the raw data dor this particular
filter into a local var
! $filter_X =
$GLOBALS['HTTP_POST_VARS'][$key];
! if ($this->debug > 0) { echo
'bofilters: distill_filter_args: filter_X dump <strong><pre>';
print_r($filter_X); echo "</pre></strong>\r\n"; }
!
! // prepare to fill your structured array
! $this_idx = count($this->filters);
!
! // grab the "filter name" associated
with this data
! $this->filters[$this_idx]['filtername']
= $filter_X['filtername'];
! // init sub arrays
! $this->filters[$this_idx]['matches'] =
Array();
! $this->filters[$this_idx]['actions'] =
Array();
!
! // extract match and action data from
this filter_X data array
!
while(list($filter_X_key,$filter_X_value) = each($filter_X))
{
! /*
! @capability: extract
multidimentional filter data embedded in this 1 dimentional array
! @discussion: php3 limits POST
arrays to one level of array key/value pairs
! thus complex filtering
instructions are containded in special strings submitted as controls names
! matching instructions willlook
something like this:
! $filter_X
['match_0_comparator'] => 'contains'
! the "key" string
"match_0_comparator" needs to be "decompressed" into an associative array
! the string means this:
! a: we are dealing with "match"
data
! b: when this data is
"decompressed" this would be match[0] data
! c: that this should be match[0]
["comparator"] where "comparator" is the key, and
! d: that value of this
match[0]["comparator"] = "contains"
! thus, we are looking at a match
to see if something "contains" a string that will be described in the next
key/value iteration
! such string may look like this
in its raw form:
! [match_0_matchthis] =>
"@spammer.com"
! translates to this:
! match[0]["matchthis"] =
"@spammer.com"
! @author Angles
! */
! if (strstr($filter_X_key,
'match_'))
! {
! // now we grab the
index value from the key string
! $match_this_idx =
(int)$filter_X_key[6];
! if ($this->debug > 1) {
echo 'bofilters: distill_filter_args: match_this_idx grabbed value:
['.$match_this_idx.']<br>'; }
! // grab "key" that
comes after that match_this_idx we just got
! // remember "substr"
uses 1 as the first letter in a string, not 0, AND starts returning the letter
AFTER the specified location
! $match_grabbed_key =
substr($filter_X_key, 8);
! if ($this->debug > 1) {
echo 'bofilters: distill_filter_args: match_grabbed_key value:
['.$match_grabbed_key.']<br>'; }
!
$this->filters[$this_idx]['matches'][$match_this_idx][$match_grabbed_key] =
$filter_X[$filter_X_key];
!
! }
! /*
! @capability: extract
multidimentional filter data embedded in this 1 dimentional array
! @discussion: php3 limits POST
arrays to one level of array key/value pairs
! thus complex filtering
instructions are containded in special strings submitted as controls names
! action instructions willlook
something like this:
! $filter_X
['action_1_judgement'] => 'fileinto'
! the "key" string
"action_1_judgement" needs to be "decompressed" into an associative array
! the string means this:
! a: we are dealing with "action"
instructions
! b: when this data is
"decompressed" this would be action[1] data
! c: that this should be
action[1] ["judgement"] where "judgement" is the key, and
! d: that value of this action[1]
["judgement"] = "fileinto"
! @author Angles
! */
! elseif (strstr($filter_X_key,
'action_'))
! {
! // now we grab the
index value from the key string
! $action_this_idx =
(int)$filter_X_key[7];
! if ($this->debug > 1) {
echo 'bofilters: distill_filter_args: action_this_idx grabbed value:
['.$action_this_idx.']<br>'; }
! // grab "key" that
comes after that match_this_idx we just got
! // remember "substr"
uses 1 as the first letter in a string, not 0, AND starts returning the letter
AFTER the specified location
! $action_grabbed_key =
substr($filter_X_key, 9);
! if ($this->debug > 1) {
echo 'bofilters: distill_filter_args: action_grabbed_key value:
['.$action_grabbed_key.']<br>'; }
!
$this->filters[$this_idx]['actions'][$action_this_idx][$action_grabbed_key] =
$filter_X[$filter_X_key];
! }
}
}
! if
((isset($GLOBALS['HTTP_POST_VARS']['filter_'.$this_idx.'_source_accounts']))
! &&
(!isset($this->filters[$this_idx]['source_accounts'])))
{
! // what account(s) do we examine
! // because this comes from a
multiselect list box, it's not in the same "array" format as the others
! // lest it become a 2 level deep array
which php3 could not handle
! $source_accounts = array();
! $source_accounts =
$GLOBALS['HTTP_POST_VARS']['filter_0_source_accounts'];
!
$this->filters[$this_idx]['source_accounts'] = $source_accounts;
! }
}
! if ($this->debug > 0) { echo 'bofilters:
distill_filter_args: this->filters[] dump <strong><pre>';
print_r($this->filters); echo "</pre></strong>\r\n"; }
! }
function sieve_to_imap_string()
{
--- 78,369 ----
}
! function obtain_filer_num()
{
! if ((isset($GLOBALS['HTTP_POST_VARS']['filter_num']))
! && ((string)$GLOBALS['HTTP_POST_VARS']['filter_num'] !=
''))
! {
! $filter_num =
(int)$GLOBALS['HTTP_POST_VARS']['filter_num'];
! }
! elseif ((isset($GLOBALS['HTTP_GET_VARS']['filter_num']))
! && ((string)$GLOBALS['HTTP_GET_VARS']['filter_num'] !=
''))
! {
! $filter_num =
(int)$GLOBALS['HTTP_GET_VARS']['filter_num'];
! }
! else
! {
! $filter_num = $this->get_next_avail_num();
! }
! return $filter_num;
}
! function get_next_avail_num()
{
! // NOT coded yet
! return 0;
! }
!
! function process_submitted_data()
! {
! if ($this->debug_set_prefs > 0) { echo
'bofilters.process_submitted_data: ENTERING<br>'."\r\n"; }
! if ($this->debug_set_prefs > 2) { echo
'bofilters.process_submitted_data: HTTP_POST_VARS dump:<pre>';
print_r($GLOBALS['HTTP_POST_VARS']); echo '</pre>'."\r\n"; }
! //if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: caling
$this->distill_filter_args<br>'."\r\n"; }
! //$this->distill_filter_args();
// we must have data because the form action made this
code run
+ $this_filter = array();
+
+ // --- get submitted data that is not in the form of an
array ----
+
+ // FILTER NUMBER
+ if ((isset($GLOBALS['HTTP_POST_VARS']['filter_num']))
+ && ((string)$GLOBALS['HTTP_POST_VARS']['filter_num'] !=
''))
+ {
+ $this_filter['filter_num'] =
(int)$GLOBALS['HTTP_POST_VARS']['filter_num'];
+ }
+ else
+ {
+ echo 'bofilters.process_submitted_data: LEAVING
with ERROR, unable to obtain POST filter_num';
+ return;
+ }
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: $this_filter[filter_num]:
['.$this_filter['filter_num'].']<br>'; }
+
+ // FILTER NAME
+ if ((isset($GLOBALS['HTTP_POST_VARS']['filtername']))
+ && ((string)$GLOBALS['HTTP_POST_VARS']['filtername'] !=
''))
+ {
+ $this_filter['filtername'] =
$GLOBALS['HTTP_POST_VARS']['filtername'];
+ }
+ else
+ {
+ $this_filter['filtername'] = 'Filter
'.$this_filter['filter_num'];
+ }
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: $this_filter[filtername]:
['.$this_filter['filtername'].']<br>'; }
+
+ // ---- The Rest of the data is submitted in Array
Form ----
+
+ // SOURCE ACCOUNTS
+ if
((isset($GLOBALS['HTTP_POST_VARS']['source_accounts']))
+ &&
((string)$GLOBALS['HTTP_POST_VARS']['source_accounts'] != ''))
+ {
+ // extract the "fake uri" data with parse_str
+ // and fill our filter struct
+ for ($i=0; $i <
count($GLOBALS['HTTP_POST_VARS']['source_accounts']); $i++)
+ {
+
parse_str($GLOBALS['HTTP_POST_VARS']['source_accounts'][$i],
$this_filter['source_accounts'][$i]);
+ // re-urlencode the foldername, because
we generally keep the fldball urlencoded
+
$this_filter['source_accounts'][$i]['folder'] =
urlencode($this_filter['source_accounts'][$i]['folder']);
+ // make sure acctnum is an int
+
$this_filter['source_accounts'][$i]['acctnum'] =
(int)$this_filter['source_accounts'][$i]['acctnum'];
+ }
+
+ }
+ else
+ {
+
$this_filter['source_accounts'][0]['folder'] = 'INBOX';
+
$this_filter['source_accounts'][0]['acctnum'] = 0;
+ }
+ if ($this->debug_set_prefs > 2) { echo
'.process_submitted_data: $this_filter[source_accounts] dump:<pre>';
print_r($this_filter['source_accounts']); echo '</pre>'."\r\n"; }
+
+ // --- "deep" array form data ---
@reset($GLOBALS['HTTP_POST_VARS']);
! // init sub arrays
! $this_filter['matches'] = Array();
! $this_filter['actions'] = Array();
! // look for top level "match_X[]" and "action_X[]" items
while(list($key,$value) =
each($GLOBALS['HTTP_POST_VARS']))
{
! // do not walk thru data we already obtained
! if (($key == 'filter_num')
! || ($key == 'filtername')
! || ($key == 'source_accounts'))
! {
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: $GLOBALS[HTTP_POST_VARS] key,value walk
thru: $key: ['.$key.'] is data we already processed, skip to next loop<br>'; }
! continue;
! }
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: $GLOBALS[HTTP_POST_VARS] key,value walk
thru: $key: ['.$key.'] ; $value DUMP:<pre>'; print_r($value); echo
"</pre>\r\n"; }
! // extract match and action data from this
filter_X data array
! if (strstr($key, 'match_'))
! {
! // now we grab the index value from the
key string
! $match_this_idx = (int)$key[6];
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: match_this_idx grabbed value:
['.$match_this_idx.']<br>'; }
! $match_data =
$GLOBALS['HTTP_POST_VARS'][$key];
! // is this row even being used?
! if ((isset($match_data['andor']))
! && ($match_data['andor'] ==
'ignore_me'))
! {
! if ($this->debug_set_prefs > 1)
{ echo 'bofilters.process_submitted_data: SKIP this row, $match_data[andor]:
['.$match_data['andor'].']<br>'; }
! }
! else
{
!
$this_filter['matches'][$match_this_idx] = $match_data;
! if ($this->debug_set_prefs > 1)
{ echo 'bofilters.process_submitted_data:
$this_filter[matches]['.$match_this_idx.'] =
['.serialize($this_filter['matches'][$match_this_idx]).']<br>'; }
}
}
! elseif (strstr($key, 'action_'))
{
! // now we grab the index value from the
key string
! $action_this_idx = (int)$key[7];
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: action_this_idx grabbed value:
['.$action_this_idx.']<br>'; }
! $action_data =
$GLOBALS['HTTP_POST_VARS'][$key];
! if ((isset($action_data['judgement']))
! && ($action_data['judgement'] ==
'ignore_me'))
! {
! if ($this->debug_set_prefs > 1)
{ echo 'bofilters.process_submitted_data: SKIP this row,
$action_data[judgement]: ['.$match_data['andor'].']<br>'; }
! }
! else
! {
!
$this_filter['actions'][$action_this_idx] = $action_data;
! if ($this->debug_set_prefs > 1)
{ echo 'bofilters.process_submitted_data:
$this_filter[actions][$action_this_idx]:
['.serialize($this_filter['actions'][$action_this_idx]).']<br>'; }
! }
! }
}
! if ($this->debug_set_prefs > 2) { echo
'bofilters.process_submitted_data: $this_filter[] dump <strong><pre>';
print_r($this_filter); echo "</pre></strong>\r\n"; }
!
! // SAVE TO PREFS DATABASE
! // we called begin_request in the constructor, so we
know the prefs object exists
! // filters are based at [filters][X] where X is the
filter_num, based on the [email] top level array tree
! // first we delete any existing data at the desired
prefs location
! $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']';
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->delete_struct("email",
$pref_struct_str) which will eval $pref_struct_str='.$pref_struct_str.'<br>'; }
!
$GLOBALS['phpgw']->preferences->delete_struct('email',$pref_struct_str);
! // now add this filter piece by piece
! // we can only set a non-array value, but we can use
array string for the base
! // but we can grab structures
!
! // $this_filter['filter_num'] integer use this as the
array key based on [filters]
! // $this_filter['filtername'] string (will require
htmlslecialchars_encode and decode
! $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["filtername"]';
! if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['filtername'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
! $GLOBALS['phpgw']->preferences->add_struct('email',
$pref_struct_str, $this_filter['filtername']);
+ // $this_filter['source_accounts'] array
+ // $this_filter['source_accounts'][X] array
+ // $this_filter['source_accounts'][X]['folder'] string
+ // $this_filter['source_accounts'][X]['acctnum']
integer
+ for ($i=0; $i < count($this_filter['source_accounts']);
$i++)
+ {
+ // folder
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["source_accounts"]['.$i.']["folder"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['source_accounts'][$i]['folder'].') which will
eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['source_accounts'][$i]['folder']);
+ // acctnum
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["source_accounts"]['.$i.']["acctnum"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['source_accounts'][$i]['acctnum'].') which
will eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['source_accounts'][$i]['acctnum']);
+ }
+
+ // $this_filter['matches'] Array
+ // $this_filter['matches'][X] Array
+ // $this_filter['matches'][X]['andor'] UNSET for
$this_filter['matches'][0], SET for all the rest
+ // $this_filter['matches'][X]['examine']
known_string
+ // $this_filter['matches'][X]['comparator']
known_string
+ // $this_filter['matches'][X]['matchthis']
user_string
+ for ($i=0; $i < count($this_filter['matches']); $i++)
+ {
+ // andor
+ if (isset($this_filter['matches'][$i]['andor']))
+ {
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["matches"]['.$i.']["andor"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['matches'][$i]['andor'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['matches'][$i]['andor']);
+ }
+ // examine
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["matches"]['.$i.']["examine"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['matches'][$i]['examine'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['matches'][$i]['examine']);
+ // comparator
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["matches"]['.$i.']["comparator"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['matches'][$i]['comparator'].') which will
eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['matches'][$i]['comparator']);
+ // matchthis
+ // user_string, may need
htmlslecialchars_encode decode and/or the user may forget to tnter data here
+ if
((!isset($this_filter['matches'][$i]['matchthis']))
+ ||
(trim($this_filter['matches'][$i]['matchthis']) == ''))
+ {
+
$this_filter['matches'][$i]['matchthis'] = 'user_string_not_filled_by_user';
+ }
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["matches"]['.$i.']["matchthis"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['matches'][$i]['matchthis'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['matches'][$i]['matchthis']);
+ }
+
+ // $this_filter['actions'] Array
+ // $this_filter['actions'][X] Array
+ // $this_filter['actions'][X]['judgement']
known_string
+ // $this_filter['actions'][X]['folder'] string
contains URI style data ex. "&folder=INBOX.Trash&acctnum=0"
+ // $this_filter['actions'][X]['actiontext']
user_string
+ // $this_filter['actions'][X]['stop_filtering'] UNSET |
SET string "True"
+ for ($i=0; $i < count($this_filter['actions']); $i++)
+ {
+ // judgement
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["actions"]['.$i.']["judgement"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['actions'][$i]['judgement'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['actions'][$i]['judgement']);
+ // folder
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["actions"]['.$i.']["folder"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['actions'][$i]['folder'].') which will eval
$pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['actions'][$i]['folder']);
+ // actiontext
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["actions"]['.$i.']["actiontext"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['actions'][$i]['actiontext'].') which will
eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['actions'][$i]['actiontext']);
+ // stop_filtering
+ if
(isset($this_filter['actions'][$i]['stop_filtering']))
+ {
+ $pref_struct_str =
'["filters"]['.$this_filter['filter_num'].']["actions"]['.$i.']["stop_filtering"]';
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: using preferences->add_struct("email",
$pref_struct_str, '.$this_filter['actions'][$i]['stop_filtering'].') which will
eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str,
$this_filter['actions'][$i]['stop_filtering']);
+ }
+ }
+ // SORT THAT ARRAY by key, so the integer array heys go
from lowest to hightest
+
ksort($GLOBALS['phpgw']->preferences->data['email']['filters']);
+ if ($this->debug_set_prefs > 2) { echo
'bofilters.process_submitted_data: direct pre-save
$GLOBALS[phpgw]->preferences->data[email][filters] DUMP:<pre>';
print_r($GLOBALS['phpgw']->preferences->data['email']['filters']); echo
'</pre>'; }
+
+ // DONE processing prefs, SAVE to the Repository
+ if ($this->debug_set_prefs > 1)
+ {
+ echo 'bofilters.process_submitted_data: *debug*
at ['.$this->debug_set_prefs.'] so skipping save_repository<br>';
+ }
+ else
+ {
+ if ($this->debug_set_prefs > 1) { echo
'bofilters.process_submitted_data: SAVING REPOSITORY<br>'; }
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+ // end the email session
+ $GLOBALS['phpgw']->msg->end_request();
+
+ // redirect user back to filters list page
+ $take_me_to_url = $GLOBALS['phpgw']->link(
+
'/index.php',
+
'menuaction=email.uifilters.filters_list');
+
+ if ($this->debug_set_prefs > 0) { echo
'bofilters.process_submitted_data: almost LEAVING, about to issue a redirect
to:<br>'.$take_me_to_url.'<br>'; }
+ if ($this->debug_set_prefs > 1)
+ {
+ echo 'bofilters.process_submitted_data:
LEAVING, *debug* at ['.$this->debug_set_prefs.'] so skipping Header redirection
to: ['.$take_me_to_url.']<br>';
+ }
+ else
+ {
+ if ($this->debug_set_prefs > 0) { echo
'bofilters.process_submitted_data: LEAVING with redirect to:
<br>'.$take_me_to_url.'<br>'; }
+ Header('Location: ' . $take_me_to_url);
+ }
+ }
+
+
+ function read_filter_data_from_prefs()
+ {
+ $this->all_filters = array();
+ // read sublevel data from prefs
+ // since we know the constructor called begin_request,
we know we can get that data here:
+ if
((isset($GLOBALS['phpgw']->msg->unprocessed_prefs['email']['filters']))
+ &&
(is_array($GLOBALS['phpgw']->msg->unprocessed_prefs['email']['filters']))
+ &&
(count($GLOBALS['phpgw']->msg->unprocessed_prefs['email']['filters']) > 0)
+ &&
(isset($GLOBALS['phpgw']->msg->unprocessed_prefs['email']['filters'][0]['source_accounts'])))
+ {
+ $this->all_filters =
$GLOBALS['phpgw']->msg->unprocessed_prefs['email']['filters'];
+ }
+ return $this->all_filters;
+ }
+
function sieve_to_imap_string()
{
Index: class.bopreferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.bopreferences.inc.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** class.bopreferences.inc.php 22 Jan 2002 07:33:17 -0000 1.16
--- class.bopreferences.inc.php 22 Jan 2002 13:16:34 -0000 1.17
***************
*** 820,833 ****
// redirect user back to main preferences page
- //if ($this->debug_set_prefs > 1)
- //{
- // echo
'email.bopreferences.preferences(): *debug* skipping Header redirection<br>';
- //}
- //else
- //{
- // Header('Location: ' .
$GLOBALS['phpgw']->link('/preferences/index.php'));
- //}
-
- // redirect user back to main preferences page
$take_me_to_url = $GLOBALS['phpgw']->link(
'/preferences/index.php');
--- 820,823 ----
Index: class.mail_msg_display.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.mail_msg_display.inc.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** class.mail_msg_display.inc.php 20 Jan 2002 23:58:47 -0000 1.33
--- class.mail_msg_display.inc.php 22 Jan 2002 13:16:34 -0000 1.34
***************
*** 581,585 ****
'is_multiple' => False,
'multiple_rows' => '4',
! 'show_status_is' => 'enabled,disabled'
);
// loop thru $local_args[], replacing defaults with any args
specified in $feed_args[]
--- 581,586 ----
'is_multiple' => False,
'multiple_rows' => '4',
! 'show_status_is' => 'enabled,disabled',
! 'pre_select_multi' => (string)$acctnum
);
// loop thru $local_args[], replacing defaults with any args
specified in $feed_args[]
***************
*** 637,641 ****
{
// this logic determines if the combobox should
be initialized with certain account already selected
! if ((string)$local_args['pre_select_acctnum']
== (string)$this_acctnum)
{
$sel = ' selected';
--- 638,648 ----
{
// this logic determines if the combobox should
be initialized with certain account already selected
! if ((!$local_args['is_multiple'])
! && ((string)$local_args['pre_select_acctnum']
== (string)$this_acctnum))
! {
! $sel = ' selected';
! }
! elseif (($local_args['is_multiple'])
! && (strstr($local_args['pre_select_multi'],
(string)$this_acctnum)))
{
$sel = ' selected';
Index: class.uifilters.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.uifilters.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.uifilters.inc.php 20 Jan 2002 23:58:47 -0000 1.2
--- class.uifilters.inc.php 22 Jan 2002 13:16:34 -0000 1.3
***************
*** 20,24 ****
);
var $bo;
! var $debug = 3;
function uifilters()
--- 20,24 ----
);
var $bo;
! var $debug = 0;
function uifilters()
***************
*** 88,91 ****
--- 88,92 ----
$GLOBALS['phpgw']->template->set_var('lang_redirect',lang('Redirect'));
$GLOBALS['phpgw']->template->set_var('lang_fileinto',lang('File into'));
+
$GLOBALS['phpgw']->template->set_var('lang_flag',lang('Flag as important'));
$GLOBALS['phpgw']->template->set_var('lang_ignore_me1',lang('not used'));
$GLOBALS['phpgw']->template->set_var('lang_and',lang('And'));
***************
*** 96,113 ****
- // DEBUGGING
- if ($this->debug > 2) { echo 'uifilters.filters:
HTTP_POST_VARS dump:<b>'."\r\n"; var_dump($GLOBALS['HTTP_POST_VARS']); echo
'<br><br>'."\r\n"; }
-
-
- // THIS WILL BE MOVED
- // make the filters object
- $this->bo = CreateObject("email.bofilters");
- $this->bo->distill_filter_args();
-
-
// setup some form vars
$form_edit_filter_action = $GLOBALS['phpgw']->link(
'/index.php',
!
'menuaction=email.uifilters.filters_edit');
$form_cancel_action = $GLOBALS['phpgw']->link(
--- 97,107 ----
// setup some form vars
+ //$form_edit_filter_action = $GLOBALS['phpgw']->link(
+ // '/index.php',
+ //
'menuaction=email.uifilters.filters_edit');
$form_edit_filter_action = $GLOBALS['phpgw']->link(
'/index.php',
!
'menuaction=email.bofilters.process_submitted_data');
$form_cancel_action = $GLOBALS['phpgw']->link(
***************
*** 115,130 ****
'menuaction=email.uifilters.filters_list');
// ---- Filter Number ----
! // for now we have only one filter
! $filternum = 0;
!
$GLOBALS['phpgw']->template->set_var('filternum',$filternum);
// ---- Filter Name ----
! $filter_name_box_name =
'filter_'.$filternum.'[filtername]';
! $filter_name_box_value = '';
$GLOBALS['phpgw']->template->set_var('filter_name_box_name',$filter_name_box_name);
$GLOBALS['phpgw']->template->set_var('filter_name_box_value',$filter_name_box_value);
// --- many email apps offer 2 matches options rows
---
// --- others offer 1 match options row with the
option of more ---
--- 109,173 ----
'menuaction=email.uifilters.filters_list');
+ // make the filters object
+ $this->bo = CreateObject("email.bofilters");
+ // get all filters
+ $this->bo->read_filter_data_from_prefs();
+
// ---- Filter Number ----
! // what filter are we supposed to edit
! $filter_num = $this->bo->obtain_filer_num();
!
$GLOBALS['phpgw']->template->set_var('filter_num',$filter_num);
!
! if ($this->debug > 2) { echo 'uifilters.filters:
$this->bo->obtain_filer_num(): ['.$this->bo->obtain_filer_num().'] ;
$this->bo->all_filters DUMP<pre>'; print_r($this->bo->all_filters); echo
'</pre>'."\r\n"; }
!
! // does the data exist or is this a new filter
! if ((isset($this->bo->all_filters[$filter_num]))
! &&
(isset($this->bo->all_filters[$filter_num]['source_accounts'])))
! {
! $filter_exists = True;
! }
! else
! {
! $filter_exists = False;
! }
// ---- Filter Name ----
! $filter_name_box_name = 'filtername';
! if ($filter_exists)
! {
! $filter_name_box_value =
$this->bo->all_filters[$filter_num]['filtername'];
! }
! else
! {
! $filter_name_box_value = 'Filter '.$filter_num;
! }
$GLOBALS['phpgw']->template->set_var('filter_name_box_name',$filter_name_box_name);
$GLOBALS['phpgw']->template->set_var('filter_name_box_value',$filter_name_box_value);
+ // ---- source_account_listbox_name Selected logic ----
+ if ($filter_exists)
+ {
+ $pre_select_multi = '';
+ for ($i=0; $i <
count($this->bo->all_filters[$filter_num]['source_accounts']); $i++)
+ {
+ $this_acct =
$this->bo->all_filters[$filter_num]['source_accounts'][$i]['acctnum'];
+ // make a comma sep string of all
source accounts, so we can make them selected
+ if ($pre_select_multi == '')
+ {
+ $pre_select_multi .=
(string)$this_acct;
+ }
+ else
+ {
+ $pre_select_multi .= ',
'.(string)$this_acct;
+ }
+ }
+ }
+ else
+ {
+ // preselect the default account
+ $pre_select_multi = '0';
+ }
+
// --- many email apps offer 2 matches options rows
---
// --- others offer 1 match options row with the
option of more ---
***************
*** 136,146 ****
{
// 1st row has an account combobox
! //$source_account_listbox_name =
'filter_'.$filternum.'[source_account]'
// now that we use a multi select box,
and php3 can only handle one sub element on POST
// we have to put this outside the
array that holds the other data
// should we use checkboxes instead?
! $source_account_listbox_name =
'filter_'.$filternum.'_source_accounts[]';
$feed_args = Array(
! 'pre_select_acctnum' => 0,
'widget_name'
=> $source_account_listbox_name,
'folder_key_name'
=> 'folder',
--- 179,189 ----
{
// 1st row has an account combobox
! //$source_account_listbox_name =
'filter_'.$filter_num.'[source_account]'
// now that we use a multi select box,
and php3 can only handle one sub element on POST
// we have to put this outside the
array that holds the other data
// should we use checkboxes instead?
! $source_account_listbox_name =
'source_accounts[]';
$feed_args = Array(
! 'pre_select_acctnum' => '',
'widget_name'
=> $source_account_listbox_name,
'folder_key_name'
=> 'folder',
***************
*** 150,154 ****
'multiple_rows'
=> '4',
//'show_status_is'
=> 'enabled,disabled'
! 'show_status_is'
=> 'enabled'
);
// get you custom built HTML combobox
(a.k.a. selectbox) widget
--- 193,198 ----
'multiple_rows'
=> '4',
//'show_status_is'
=> 'enabled,disabled'
! 'show_status_is'
=> 'enabled',
! 'pre_select_multi'
=> $pre_select_multi
);
// get you custom built HTML combobox
(a.k.a. selectbox) widget
***************
*** 160,175 ****
{
// 2nd row has an and/or combo box with
"not enabled" option for when you do not need the 2nd line
! $andor_select_name =
'filter_'.$filternum.'[match_'.(string)$i.'_andor]';
$GLOBALS['phpgw']->template->set_var('andor_select_name',$andor_select_name);
$V_match_left_td =
$GLOBALS['phpgw']->template->parse('V_match_and_or_ignore','B_match_and_or_ignore');
}
// things both rows have
! $examine_selectbox_name =
'filter_'.$filternum.'[match_'.(string)$i.'_examine]';
! $comparator_selectbox_name =
'filter_'.$filternum.'[match_'.(string)$i.'_comparator]';
! $matchthis_textbox_name =
'filter_'.$filternum.'[match_'.(string)$i.'_matchthis]';
! $match_textbox_txt = '';
!
$GLOBALS['phpgw']->template->set_var('examine_selectbox_name',$examine_selectbox_name);
$GLOBALS['phpgw']->template->set_var('comparator_selectbox_name',$comparator_selectbox_name);
$GLOBALS['phpgw']->template->set_var('matchthis_textbox_name',$matchthis_textbox_name);
$GLOBALS['phpgw']->template->set_var('match_textbox_txt',$match_textbox_txt);
--- 204,296 ----
{
// 2nd row has an and/or combo box with
"not enabled" option for when you do not need the 2nd line
! $andor_select_name =
'match_'.(string)$i.'[andor]';
! // what to preselect
! $ignore_me_selected = '';
! $or_selected = '';
! $and_selected = '';
! // as our numbers of rows go beyond
what the user previously set, there will bo no andor data
! if
(!isset($this->bo->all_filters[$filter_num]['matches'][$i]['andor']))
! {
! $ignore_me_selected = '
selected';
! }
! elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['andor'] == 'or')
! {
! $or_selected = ' selected';
! }
! elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['andor'] == 'and')
! {
! $and_selected = ' selected';
! }
! else
! {
! $ignore_me_selected = '
selected';
! }
$GLOBALS['phpgw']->template->set_var('andor_select_name',$andor_select_name);
+
$GLOBALS['phpgw']->template->set_var('or_selected',$or_selected);
+
$GLOBALS['phpgw']->template->set_var('and_selected',$and_selected);
+
$GLOBALS['phpgw']->template->set_var('ignore_me_selected',$ignore_me_selected);
$V_match_left_td =
$GLOBALS['phpgw']->template->parse('V_match_and_or_ignore','B_match_and_or_ignore');
}
// things both rows have
! $examine_selectbox_name =
'match_'.(string)$i.'[examine]';
! // what to preselect for "examine"
! $from_selected = '';
! $to_selected = '';
! $cc_selected = '';
! $subject_selected = '';
! // as our numbers of rows go beyond what the
user previously set, there will bo no data
! if
((!isset($this->bo->all_filters[$filter_num]['matches'][$i]['examine']))
! ||
($this->bo->all_filters[$filter_num]['matches'][$i]['examine'] == 'from'))
! {
! $from_selected = ' selected';
! }
! elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['examine'] == 'to')
! {
! $to_selected = ' selected';
! }
! elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['examine'] == 'cc')
! {
! $cc_selected = ' selected';
! }
! elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['examine'] == 'subject')
! {
! $subject_selected = ' selected';
! }
! else
! {
! $from_selected = ' selected';
! }
$GLOBALS['phpgw']->template->set_var('examine_selectbox_name',$examine_selectbox_name);
+
$GLOBALS['phpgw']->template->set_var('from_selected',$from_selected);
+
$GLOBALS['phpgw']->template->set_var('to_selected',$to_selected);
+
$GLOBALS['phpgw']->template->set_var('cc_selected',$cc_selected);
+
$GLOBALS['phpgw']->template->set_var('subject_selected',$subject_selected);
+ // COMPARATOR
+ $comparator_selectbox_name =
'match_'.(string)$i.'[comparator]';
+ $contains_selected = '';
+ $notcontains_selected = '';
+ if
((!isset($this->bo->all_filters[$filter_num]['matches'][$i]['comparator']))
+ ||
($this->bo->all_filters[$filter_num]['matches'][$i]['comparator'] ==
'contains'))
+ {
+ $contains_selected = ' selected';
+ }
+ elseif
($this->bo->all_filters[$filter_num]['matches'][$i]['comparator'] ==
'notcontains')
+ {
+ $notcontains_selected = ' selected';
+ }
+ else
+ {
+ $contains_selected = ' selected';
+ }
$GLOBALS['phpgw']->template->set_var('comparator_selectbox_name',$comparator_selectbox_name);
+
$GLOBALS['phpgw']->template->set_var('contains_selected',$contains_selected);
+
$GLOBALS['phpgw']->template->set_var('notcontains_selected',$notcontains_selected);
+ // MATCHTHIS
+ $matchthis_textbox_name =
'match_'.(string)$i.'[matchthis]';
+ $match_textbox_txt = '';
+ if
(isset($this->bo->all_filters[$filter_num]['matches'][$i]['matchthis']))
+ {
+ $match_textbox_txt =
$this->bo->all_filters[$filter_num]['matches'][$i]['matchthis'];
+ }
$GLOBALS['phpgw']->template->set_var('matchthis_textbox_name',$matchthis_textbox_name);
$GLOBALS['phpgw']->template->set_var('match_textbox_txt',$match_textbox_txt);
***************
*** 183,192 ****
// for ex. if you "fileinto" a folder, what would the
second action be? Delete it? doesn't make sense
// with evolution, the second action could be
"scoring", but we don't have scoring
! // so for now, offer ONE action row
$num_actionrows = 1;
for ($i=0; $i < $num_actionrows; $i++)
{
$action_rownum = (string)$i;
! $actionbox_judgement_name =
'filter_'.$filternum.'[action_'.$action_rownum.'_judgement]';
$GLOBALS['phpgw']->template->set_var('actionbox_judgement_name',$actionbox_judgement_name);
// 1st row does NOT have the IGNORE_ME option
in the actionbox
--- 304,314 ----
// for ex. if you "fileinto" a folder, what would the
second action be? Delete it? doesn't make sense
// with evolution, the second action could be
"scoring", but we don't have scoring
! // UPDATE: offer "flag as important" option, this could
be a 2nd action
! // but that's not coded yet, so for NOW offer 1 row, in
the FUTURE offer 2 rows
$num_actionrows = 1;
for ($i=0; $i < $num_actionrows; $i++)
{
$action_rownum = (string)$i;
! $actionbox_judgement_name =
'action_'.$action_rownum.'[judgement]';
$GLOBALS['phpgw']->template->set_var('actionbox_judgement_name',$actionbox_judgement_name);
// 1st row does NOT have the IGNORE_ME option
in the actionbox
***************
*** 201,211 ****
// --- Folders Listbox ---
! $folder_listbox_name =
'filter_'.$filternum.'[action_'.$action_rownum.'_folder]';
$listbox_show_unseen = False;
! // for existing data, we must specify which
folder was selected in the script
! $listbox_pre_select = '';
$feed_args = Array(
'mailsvr_stream' => '',
! 'pre_select_folder' =>
$listbox_pre_select,
'skip_folder' => '',
'show_num_new' =>
$listbox_show_unseen,
--- 323,347 ----
// --- Folders Listbox ---
! $folder_listbox_name =
'action_'.$action_rownum.'[folder]';
$listbox_show_unseen = False;
! // for existing data, we must specify which
folder was selected in the stored filter
! if
((!isset($this->bo->all_filters[$filter_num]['actions'][$i]['folder']))
! ||
($this->bo->all_filters[$filter_num]['actions'][$i]['folder'] == ''))
! {
! $pre_select_folder = '';
! $pre_select_folder_acctnum = '';
! }
! else
! {
!
parse_str($this->bo->all_filters[$filter_num]['actions'][$i]['folder'],
$parsed_folder);
! // note also that parse_str will
urldecode the uri folder data
! $pre_select_folder =
$parsed_folder['folder'];
! $pre_select_folder_acctnum =
$parsed_folder['acctnum'];
! //echo '$pre_select_folder:
['.$pre_select_folder.'] ; pre_select_folder_acctnum
['.$pre_select_folder_acctnum.']';
! }
$feed_args = Array(
'mailsvr_stream' => '',
! 'pre_select_folder' =>
$pre_select_folder,
! 'pre_select_folder_acctnum' =>
$pre_select_folder_acctnum,
'skip_folder' => '',
'show_num_new' =>
$listbox_show_unseen,
***************
*** 217,226 ****
);
$folder_listbox =
$GLOBALS['phpgw']->msg->folders_mega_listbox($feed_args);
!
! $action_textbox_name =
'filter_'.$filternum.'[action_'.$action_rownum.'_actiontext]';
! $action_textbox_txt = '';
!
! $stop_filtering_checkbox_name =
'filter_'.$filternum.'[action_'.$action_rownum.'_stop_filtering]';
! $stop_filtering_checkbox_checked = '';
$GLOBALS['phpgw']->template->set_var('V_action_widget',$V_action_widget);
--- 353,378 ----
);
$folder_listbox =
$GLOBALS['phpgw']->msg->folders_mega_listbox($feed_args);
! // ACTIONTEXT
! $action_textbox_name =
'action_'.$action_rownum.'[actiontext]';
! if
((!isset($this->bo->all_filters[$filter_num]['actions'][$i]['actiontext']))
! ||
($this->bo->all_filters[$filter_num]['actions'][$i]['actiontext'] == ''))
! {
! $action_textbox_txt = '';
! }
! else
! {
! $action_textbox_txt =
$this->bo->all_filters[$filter_num]['actions'][$i]['actiontext'];
! }
! // STOP_FILTERING
! $stop_filtering_checkbox_name =
'action_'.$action_rownum.'[stop_filtering]';
! if
((!isset($this->bo->all_filters[$filter_num]['actions'][$i]['stop_filtering']))
! ||
($this->bo->all_filters[$filter_num]['actions'][$i]['stop_filtering'] == ''))
! {
! $stop_filtering_checkbox_checked = '';
! }
! else
! {
! $stop_filtering_checkbox_checked =
'checked';
! }
$GLOBALS['phpgw']->template->set_var('V_action_widget',$V_action_widget);
***************
*** 240,243 ****
--- 392,397 ----
$GLOBALS['phpgw']->template->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
$GLOBALS['phpgw']->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
+
+
// debugging result list
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: email/inc class.bofilters.inc.php,1.2,1.3 class.bopreferences.inc.php,1.16,1.17 class.mail_msg_display.inc.php,1.33,1.34 class.uifilters.inc.php,1.2,1.3,
Angelo Tony Puglisi <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: email/templates/default filters.tpl,1.4,1.5 filters_blocks.tpl,1.2,1.3
- Next by Date:
[Phpgroupware-cvs] CVS: stocks/setup tables_baseline.inc.php,1.2,1.3
- Previous by thread:
[Phpgroupware-cvs] CVS: email/templates/default filters.tpl,1.4,1.5 filters_blocks.tpl,1.2,1.3
- Next by thread:
[Phpgroupware-cvs] CVS: stocks/setup tables_baseline.inc.php,1.2,1.3
- Index(es):