phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] email/inc class.mail_filters.inc.php, 1.8 class.mail_


From: skwashd
Subject: [Phpgroupware-cvs] email/inc class.mail_filters.inc.php, 1.8 class.mail_msg.inc.php, 1.5 class.mail_msg_base.inc.php, 1.80 class.mail_dcom_pop3.inc.php, 1.12 class.mail_dcom_nntp.inc.php, 1.5 class.mail_dcom_base_sock.inc.php, 1.25 class.mail_dcom_imap.inc.php, 1.22 class.mail_dcom_imap_sock.inc.php, 1.16 class.mail_msg_display.inc.php, 1.42 class.mail_msg_wrappers.inc.php, 1.39 class.spell_struct.inc.php, 1.3 class.spell_svc_none.inc.php, 1.3 class.spell_svc_php.inc.php, 1.3 class.spell.inc.php, 1.3 class.so_mail_msg.inc.php, 1.2 class.mail_send.inc.php, 1.12 class.msg_bootstrap.inc.php, 1.3 class.mail_dcom_base.inc.php, 1.10 class.mail_dcom.inc.php, 1.11 class.boaction.inc.php, 1.18 class.boattach_file.inc.php, 1.5 class.bocompose.inc.php, 1.9 class.bofilters.inc.php, 1.15 class.bosend.inc.php, 1.12 class.html_widgets.inc.php, 1.4 class.bopreferences.inc.php, 1.24 class.bomessage.inc.php, 1.15 class.bofolder.inc.php, 1.9 class.boindex.inc.php, 1.31 class.svc_debug.inc.php, 1.2 hook_settings.inc.php, 1.4 class.svc_ nextmatches.inc.php, 1.3 hook_preferences.inc.php, 1.15 class.uiindex.inc.php, 1.23 class.uijsaddressbook.inc.php, 1.4 class.uimessage.inc.php, 1.12 class.uifolder.inc.php, 1.6 class.uifilters.inc.php, 1.15 class.ui_mail_debug.inc.php, 1.3 hook_notifywindow_simple.inc.php, 1.10 class.uicompose.inc.php, 1.6 class.uipreferences.inc.php, 1.18 class.uiattach_file.inc.php, 1.3 hook_manual.inc.php, 1.9 hook_home.inc.php, 1.57 hook_admin.inc.php, 1.8 hook_notifywindow.inc.php, 1.12 functions.inc.php, 1.118 class.email_service.inc.php, 1.2 hook_login.inc.php, 1.2 class.uisearch.inc.php, 1.2
Date: Thu, 24 Feb 2005 12:50:30 -0000

Update of email/inc

Modified Files:
     Branch: MAIN
            class.mail_filters.inc.php lines: +1 -1
            class.mail_msg.inc.php lines: +1 -1
            class.mail_msg_base.inc.php lines: +823 -338
            class.mail_dcom_pop3.inc.php lines: +1 -1
            class.mail_dcom_nntp.inc.php lines: +1 -1
            class.mail_dcom_base_sock.inc.php lines: +25 -0
            class.mail_dcom_imap.inc.php lines: +4 -4
            class.mail_dcom_imap_sock.inc.php lines: +31 -1
            class.mail_msg_display.inc.php lines: +652 -314
            class.mail_msg_wrappers.inc.php lines: +640 -86
            class.spell_struct.inc.php lines: +1 -1
            class.spell_svc_none.inc.php lines: +1 -1
            class.spell_svc_php.inc.php lines: +1 -1
            class.spell.inc.php lines: +20 -12
            class.so_mail_msg.inc.php lines: +693 -50
            class.mail_send.inc.php lines: +37 -7
            class.msg_bootstrap.inc.php lines: +36 -17
            class.mail_dcom_base.inc.php lines: +43 -3
            class.mail_dcom.inc.php lines: +4 -0
            class.boaction.inc.php lines: +206 -132
            class.boattach_file.inc.php lines: +6 -6
            class.bocompose.inc.php lines: +113 -14
            class.bofilters.inc.php lines: +50 -38
            class.bosend.inc.php lines: +123 -3
            class.html_widgets.inc.php lines: +1773 -1609
            class.bopreferences.inc.php lines: +162 -325
            class.bomessage.inc.php lines: +250 -52
            class.bofolder.inc.php lines: +78 -13
            class.boindex.inc.php lines: +49 -18
            class.svc_debug.inc.php lines: +232 -9
            hook_settings.inc.php lines: +1 -1
            class.svc_nextmatches.inc.php lines: +3 -3
            hook_preferences.inc.php lines: +23 -1
            class.uiindex.inc.php lines: +72 -71
            class.uijsaddressbook.inc.php lines: +1 -1
            class.uimessage.inc.php lines: +193 -78
            class.uifolder.inc.php lines: +27 -31
            class.uifilters.inc.php lines: +159 -139
            class.ui_mail_debug.inc.php lines: +307 -189
            hook_notifywindow_simple.inc.php lines: +1 -1
            class.uicompose.inc.php lines: +29 -32
            class.uipreferences.inc.php lines: +96 -114
            class.uiattach_file.inc.php lines: +1 -1
            hook_manual.inc.php lines: +1 -1
            hook_home.inc.php lines: +249 -153
            hook_admin.inc.php lines: +19 -17
            hook_notifywindow.inc.php lines: +1 -1
            functions.inc.php lines: +2 -1
Added Files:
     Branch: MAIN
            class.email_service.inc.php lines: +259 -0
            hook_login.inc.php lines: +5 -0
            class.uisearch.inc.php lines: +457 -0

Log Message:
merge from 16

====================================================

====================================================

====================================================
Index: email/inc/class.mail_msg_base.inc.php
diff -u email/inc/class.mail_msg_base.inc.php:1.79 
email/inc/class.mail_msg_base.inc.php:1.80
--- email/inc/class.mail_msg_base.inc.php:1.79  Sat Mar 29 23:19:49 2003
+++ email/inc/class.mail_msg_base.inc.php       Thu Dec 30 23:13:50 2004
@@ -234,6 +234,9 @@
                var $a = array();
                var $acctnum = 0;
                var $fallback_default_acctnum = 0;
+
+               // this object is 3 files, each an object "extending" the 
other, this prevents 3 constructor calls
+               var $been_constructed = False;
                // data storage for caching functions moved to SO object
                var $so = '##NOTHING##';

@@ -264,8 +267,8 @@
                var $browser = 0;
                // use message UIDs instead of "message sequence numbers" in 
requests to the mail server
                var $force_msg_uids = True;
-               // phpgw 0.9.14 was last for old template system, after that is 
xslt, make note of version below
-               var $phpgw_0914_orless = '-1';
+               // phpgw 0.9.16 was last for old template system, after that is 
xslt, make note of version below
+               var $phpgw_before_xslt = '-1';
                // raw prefs, before we process them to extract extra acct 
and/or filters data, not of much use
                var $unprocessed_prefs=array();
                // raw filters array for use by the filters class, we just put 
the data here, that is all, while collecting other prefs
@@ -277,9 +280,17 @@
                // delete URI data is buffered to here, then executed at one 
time (FUTURE)
                var $buffered_delete_commmands = array();
                // I think crypto var this is no longer used, uses global 
crypto now I think (which does little anyway, w/o mcrypt)
-               var $crypto;
+               //var $crypto;
+
+               // reply messages get this "quoting" prefix to each line, see 
bocompose and bosend
+               //var $reply_prefix = '>';
+               var $reply_prefix = '> ';
+               //var $reply_prefix = '| ';

                // ---- Data Caching  ----
+               var $use_cached_prefs = True;
+               //var $use_cached_prefs = False;
+
                // (A) session data caching in appsession, for data that is 
temporary in nature
                // right now this means msgball_list in appsession, and a bunch 
of stuff we generate (mailsvr_str) stored in L1 cache
                // also tries to appsession cache the "processed prefs" during 
begin_request (NOTE: expire this on pref subit so new prefs actually take 
effect)
@@ -310,9 +321,9 @@
                // EXTRA ACCOUNTS
                // used for looping thru extra account data during begin request
                var $ex_accounts_count = 0;
-               // extra_acounts[X][acctnum] = integer
-               // extra_acounts[X][status] = empty | enabled | disabled
-               var $extra_acounts = array();
+               // extra_accounts[X][acctnum] = integer
+               // extra_accounts[X][status] = empty | enabled | disabled
+               var $extra_accounts = array();
                // same as above but includes the default account, makes 
checking streams easier
                var $extra_and_default_acounts = array();

@@ -336,6 +347,8 @@
                var $debug_args_oop_access = 0;
                var $debug_args_special_handlers = 0;
                var $debug_index_page_display = 0;
+               // this is just being implemented
+               var $debug_message_display = 0;
                // dormant code, "longterm_caching" currently OBSOLETE
                var $debug_longterm_caching = 0;
                //var $skip_args_special_handlers = 'get_mailsvr_callstr, 
get_mailsvr_namespace, get_mailsvr_delimiter, get_folder_list';
@@ -343,22 +356,47 @@
                var $skip_args_special_handlers = '';

                /*!
-               @function mail_msg
-               @abstract CONSTRUCTOR
+               @function mail_msg_base
+               @abstract CONSTRUCTOR place holder, does nothing
                */
-               function mail_msg()
+               function mail_msg_base()
                {
+                       if (($this->debug_logins > 0) && 
(is_object($this->dbug->out))) { $this->dbug->out('mail_msg('.__LINE__.'): 
*constructor*: $GLOBALS[PHP_SELF] = ['.$GLOBALS['PHP_SELF'].'] $this->acctnum = 
['.$this->acctnum.']  get_class($this) : "'.get_class($this).'" ; 
get_parent_class($this) : "'.get_parent_class($this).'"<br>'); }
+                       if ($this->debug_logins > 0) { echo 
'mail_msg('.__LINE__.'): *constructor*: $GLOBALS[PHP_SELF] = 
['.$GLOBALS['PHP_SELF'].'] $this->acctnum = ['.$this->acctnum.']  
get_class($this) : "'.get_class($this).'" ; get_parent_class($this) : 
"'.get_parent_class($this).'"<br>'; }
+                       return;
+               }
+
+               /*!
+               @function initialize_mail_msg
+               @abstract the real CONSTRUCTOR needs to be called by name.
+               @discussion This used to be called in the final extends file to 
this aggregrate class.
+               NEW now called only from bootstrap class, because the 
preferences API class keeps constructing
+               this object for every account it makes preferences for, I would 
change that but changing the API
+               is like moving a mountain, so I remove all auto constructor 
functions and make this have to
+               be called explicitly to stop useless runthroughs caused by 
preferences API.
+               */
+               function initialize_mail_msg()
+               {
+                       if ($this->been_constructed == True)
+                       {
+                               // do not run thru this again, probably one of 
the "extends" objects call this
+                               return;
+                       }
+                       // Set this so we do not run thru this again
+                       $this->been_constructed = True;
+
+                       // ... OK ... now we actually do the CONSTRUCTOR
                        // svc_debug object goes here
                        if ($this->dbug == '##NOTHING##')
                        {
                                $this->dbug = CreateObject('email.svc_debug');
                        }

-                       //if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: *constructor*: $GLOBALS[PHP_SELF] = 
['.$GLOBALS['PHP_SELF'].'] $this->acctnum = ['.$this->acctnum.']  
get_class($this) : "'.get_class($this).'" ; get_parent_class($this) : 
"'.get_parent_class($this).'"<br>'); }
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: *constructor*: $this->acctnum = 
['.$this->acctnum.'] ; $this->a  DUMP:', $this->a); }
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: *constructor*: extra data $p1 (if provided): 
'.serialize($p1).'<br>'); }
+                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): ENTERING manual 
*constructor*: $GLOBALS[PHP_SELF] = ['.$GLOBALS['PHP_SELF'].'] $this->acctnum = 
['.$this->acctnum.']  get_class($this) : "'.get_class($this).'" ; 
get_parent_class($this) : "'.get_parent_class($this).'"<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: $this->acctnum = ['.$this->acctnum.'] ; $this->a  DUMP:', 
$this->a); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: extra data $p1 (if provided): '.serialize($p1).'<br>'); }

-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: *constructor*: checking and or setting GET and POST 
reference based on PHP version<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: checking and or setting GET and POST reference based on PHP 
version<br>'); }
                        // make GPC reference for php versions < 4.1 and > 4.2
                        // since this constructor is apparently called many 
times
                        // during the script run (not sure why) we check if 
we've already done it first
@@ -399,10 +437,11 @@
                                        $this->ref_SESSION = 
&$GLOBALS['HTTP_SESSION_VARS'];
                                }
                        }
-
+
                        // SO object has data storage functions
                        if ($this->so == '##NOTHING##')
                        {
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: creating sub SO object "so_mail_msg"<br>'); }
                                $this->so = CreateObject('email.so_mail_msg');
                        }

@@ -410,23 +449,64 @@
                        // TEMPORARY ONLY DURING MIGRATION AND TABLE DEVELOPMENT
                        if ($this->use_private_table)
                        {
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: checking if "so_am_table_exists"<br>'); }
                                if ($this->so->so_am_table_exists() == False)
                                {
                                        $this->use_private_table = False;
                                }
                        }

+                       // UNDER DEVELOPMENT when to use cached preferences
+                       if ($this->use_cached_prefs == True)
+                       {
+                               // any preferences page menuaction is a NO NO 
to cached prefs
+                               if (stristr($this->ref_GET['menuaction'], 
'preferences.'))
+                               {
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: string "preferences." is in menuaction so NO CACHED PREFS, 
setting $this->use_cached_prefs to False<br>'); }
+                                       $this->use_cached_prefs = False;
+                               }
+                       }
+
+                       // UNDER DEVELOPMENT bulk data query from AngleMail DB
+                       // only necessary to grab huge bulk data for INDEX page
+                       // and some other menuactions too, but we will add more 
later
+                       if ((stristr($this->ref_GET['menuaction'], 
'email.uiindex'))
+                       || (stristr($this->ref_GET['menuaction'], 
'email.uimessage.message')))
+                       {
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: calling $this->so->so_prop_use_group_data(True)<br>'); }
+                               //$this->so->use_group_data = True;
+                               $this->so->so_prop_use_group_data(True);
+                       }
+                       else
+                       {
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: calling $this->so->so_prop_use_group_data(False)<br>'); }
+                               //$this->so->use_group_data = False;
+                               $this->so->so_prop_use_group_data(False);
+                       }
+
                        // trying this new thing for template porting issues
-                       if ($this->phpgw_0914_orless == '-1')
+                       // relfbecker recommends NOT using a version test for 
xslt check
+                       if ($this->phpgw_before_xslt == '-1')
                        {
-                               $this->phpgw_0914_orless = 
!isset($GLOBALS['phpgw']->xslttpl);
+                               if (is_object($GLOBALS['phpgw']->xslttpl))
+                               {
+                                       $this->phpgw_before_xslt = False;
+                               }
+                               else
+                               {
+                                       $this->phpgw_before_xslt = True;
+                               }
+                       }
                        /*
+                       // relfbecker recommends NOT using a version test for 
xslt check
+                       if ($this->phpgw_before_xslt == '-1')
+                       {
                                $this_ver = 
$GLOBALS['phpgw_info']['server']['versions']['phpgwapi'];
                                $pre_xslt_ver = '0.9.14.0.1.1';
                                if (!$this_ver)
                                {
                                        // damn stupid fallback if the api 
moves the version to another place
-                                       $this->phpgw_0914_orless = True;
+                                       $this->phpgw_before_xslt = True;
                                }
                                // this is a function in phpgwapi 
"common_functions" file for phpgw 0.9.15+
                                elseif (function_exists(amorethanb))
@@ -434,12 +514,12 @@
                                        if (amorethanb($this_ver, 
$pre_xslt_ver))
                                        {
                                                // this phpgw version is after 
the switch to xslt templates
-                                               $this->phpgw_0914_orless = 
False;
+                                               $this->phpgw_before_xslt = 
False;
                                        }
                                        else
                                        {
                                                // this phpgw version is NOT in 
the xslt era
-                                               $this->phpgw_0914_orless = True;
+                                               $this->phpgw_before_xslt = True;
                                        }
                                }
                                else
@@ -447,15 +527,16 @@
                                        if 
($GLOBALS['phpgw']->common->cmp_version_long($this_ver, $pre_xslt_ver))
                                        {
                                                // this phpgw version is after 
the switch to xslt templates
-                                               $this->phpgw_0914_orless = 
False;
+                                               $this->phpgw_before_xslt = 
False;
                                        }
                                        else
                                        {
                                                // this phpgw version is NOT in 
the xslt era
-                                               $this->phpgw_0914_orless = True;
+                                               $this->phpgw_before_xslt = True;
                                        }
-                               }*/
+                               }
                        }
+                       */

                        $this->known_external_args = array(
                                // === NEW GPC "OBJECTS" or Associative Arrays 
===
@@ -548,6 +629,16 @@
                                // (c) send_message.php: when set to "forward" 
and used with "fwd_proc" instructs on how to construct
                                //      the SMTP mail
                                'action',
+                               // ----  orig_action: string  ----
+                               // USAGE:
+                               // preserves the original "action" of the 
compose page because new and forward body lines
+                               // need to be shorter then reply to we need to 
remember the desired "action" and store it here
+                               // also used to preserve this thru the spell 
check process too
+                               // initially we only put this only in the GET 
part of GPC
+                               // why is this different, "orig_action" can 
have the value "new" meaning new mail
+                               // whereas plain old "action" can not tell us 
of a new mail situation, not right now anyway,
+                               // so the "new" value can be preserved to the 
send code and also thru the spell page and back too
+                               'orig_action',

                                // === MESSAGE NUMBER AND MIME PART REFERENCES 
===
                                // *update* now in msgball
@@ -723,7 +814,8 @@
                                // experimental: Set Flag indicative we've run 
thru this function
                                'already_grab_class_args_gpc'
                        );
-                       //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: constructor: $this->known_args[] dump<pre>'; 
print_r($this->known_args); echo '</pre>'); }
+                       //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
constructor: $this->known_args[] DUMP:', $this->known_args); }
+                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.initialize_mail_msg('.__LINE__.'): manual 
*constructor*: LEAVING<br>'); }
                }

                /*!
@@ -736,8 +828,8 @@
                // ----  BEGIN request from Mailserver / Initialize This Mail 
Session  -----
                function begin_request($args_array)
                {
-                       if ($this->debug_logins > 0) { 
$this->dbug->out('<br>mail_msg: begin_request: ENTERING'.'<br>'); }
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: feed var args_array[] DUMP:', 
$args_array); }
+                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): ENTERING'.'<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): feed var args_array[] 
DUMP:', $args_array); }

                        // Grab GPC vars, after we get an acctnum, we'll put 
them in the appropriate account's "args" data
                        // issue?: which acctnum arg array would this be 
talking to when we inquire about "already_grab_class_args_gpc"?
@@ -745,35 +837,35 @@
                        && 
((string)$this->get_arg_value('already_grab_class_args_gpc') != '') )
                        {
                                // somewhere, there's already been a call to 
grab_class_args_gpc(), do NOT re-run
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: "already_grab_class_args_gpc" is 
set, do not re-grab<br>'); }
-                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: "already_grab_class_args_gpc" 
pre-existing $this->get_all_args() DUMP:', $this->get_all_args()); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
"already_grab_class_args_gpc" is set, do not re-grab<br>'); }
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
"already_grab_class_args_gpc" pre-existing $this->get_all_args() DUMP:', 
$this->get_all_args()); }
                                $got_args=array();
                        }
                        else
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: "already_grab_class_args_gpc" is NOT 
set, call grab_class_args_gpc() now<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
"already_grab_class_args_gpc" is NOT set, call grab_class_args_gpc() now<br>'); 
}
                                $got_args=array();
                                $got_args = $this->grab_class_args_gpc();
                        }

                        // FIND THE "BEST ACCTNUM" and set it
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call:  
get_best_acctnum($args_array, $got_args) <br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call:  
get_best_acctnum($args_array, $got_args) <br>'); }
                        $acctnum = $this->get_best_acctnum($args_array, 
$got_args);
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: "get_best_acctnum" returns $acctnum 
['.$acctnum.']<br>'); }
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: * * * *SETTING CLASS ACCTNUM* * * * 
by calling $this->set_acctnum('.serialize($acctnum).')<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): "get_best_acctnum" 
returns $acctnum ['.$acctnum.']<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): * * * *SETTING CLASS 
ACCTNUM* * * * by calling $this->set_acctnum('.serialize($acctnum).')<br>'); }
                        $this->set_acctnum($acctnum);

                        // SET GOT_ARGS TO THAT ACCTNUM
                        // use that acctnum to set "got_args" to the appropiate 
acctnum
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call: 
$this->set_arg_array($got_args); <br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call: 
$this->set_arg_array($got_args); <br>'); }
                        $this->set_arg_array($got_args, $acctnum);
-                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: post set_arg_array 
$this->get_all_args() DUMP:', $this->get_all_args()); }
+                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): post set_arg_array 
$this->get_all_args() DUMP:', $this->get_all_args()); }

                        // Initialize Internal Args
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call: 
"init_internal_args_and_set_them('.$acctnum.')"<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call: 
"init_internal_args_and_set_them('.$acctnum.')"<br>'); }
                        $this->init_internal_args_and_set_them($acctnum);

-                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: POST "grab_class_args_gpc", 
"get_best_acctnum", and "init_internal_args_and_set_them" : 
this->get_all_args() DUMP:', $this->get_all_args()); }
+                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): POST 
"grab_class_args_gpc", "get_best_acctnum", and 
"init_internal_args_and_set_them" : this->get_all_args() DUMP:', 
$this->get_all_args()); }

                        // (chopped out the re-use existing object code - never 
worked right, maybe later...)

@@ -784,247 +876,428 @@
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] 
== 'db')
                        || ($this->use_private_table == True))
                        {
+                               /*
+                               if (! is_object($this->so))
+                               {
+                                       $this->initialize_mail_msg();
+                               }
+                               */
+
                                // REF_SESSION should not really be in 
$_SESSION namespace so RE-CREATE all this outside of php4 sessions
                                
$this->so->prep_db_session_compat('begin_request LINE '.__LINE__);
                        }


-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to create_email_preferences 
and setup extra accounts<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to handle email 
preferences and setup extra accounts<br>'); }
                        // ----  Obtain Preferences Data  ----

                        /*
                        // UNDER DEVELOPMEMT: caching the prefs data
-                       // see if our "processed prefs" (what we make below) 
were appsession cached by us already
-                       // FORGET IT THIS IS AS COMPLICATED AS DOING IT FOR REAL
-                       $appsession_cached_prefs = 
$this->read_session_cache_item('cached_prefs', $acctnum);
-                       if (($this->session_cache_enabled == True)
-                       && ($appsession_cached_prefs))
+                       // data we need to DB save to cache final processed 
prefs
+                       $this->unprocessed_prefs
+                       $this->raw_filters
+                       $this->ex_accounts_count
+                       $this->extra_accounts
+                       $this->extra_and_default_acounts
+                       $this->a[X]->prefs
+                       // where X is the account number, we can use 
"set_pref_array(array_data, acctnum) for each account
+
+                       // ok lets make an array to hold this data in the DB
+                       $cached_prefs = array();
+                       $cached_prefs['unprocessed_prefs'] = array();
+                       $cached_prefs['raw_filters'] = array();
+                       $cached_prefs['ex_accounts_count'] = '0';
+                       $cached_prefs['extra_accounts'] = array();
+                       $cached_prefs['extra_and_default_acounts'] = array();
+                       $cached_prefs['a'] = array();
+                       */
+                       // ---- GET FROM CACHE THE COMPLETED PREF DATA
+                       //$this->use_cached_prefs = True;
+                       //$this->use_cached_prefs = False;
+                       if ($this->use_cached_prefs == False)
                        {
-                               $appsession_cached_prefs = 
unserialize($appsession_cached_prefs);
-                               //['cached_prefs'] has several sub elements 
that fill out the prefs we need
-                               // (a) unprocessed_prefs that we keep around, 
disabled account name access this because disabled accounts do not get 
processed prefs
-                               $this->unprocessed_prefs = array();
-                               $this->unprocessed_prefs['email'] = array();
-                               $this->unprocessed_prefs['email'] = 
$appsession_cached_prefs['cached_prefs']['unprocessed_prefs'];
-                               // (b) filter data we got from prefs and cached
-                               $this->raw_filters = array();
-                               if 
((isset($appsession_cached_prefs['cached_prefs']['raw_filters']))
-                               && 
(is_array($appsession_cached_prefs['cached_prefs']['raw_filters'])))
+                               $cached_prefs = $this->nothing;
+                       }
+                       else
+                       {
+                               /*
+                               // data we need to DB save to cache final 
processed prefs
+                               $this->unprocessed_prefs
+                               $this->raw_filters
+                               $this->ex_accounts_count
+                               $this->extra_accounts
+                               $this->extra_and_default_acounts
+                               $this->a[X]->['prefs']
+                               // where X is the account number, we can use 
"set_pref_array(array_data, acctnum) for each account
+
+                               // ok this is what we should get from the DB 
storage (we use appsession for now)
+                               $cached_prefs = array();
+                               $cached_prefs['unprocessed_prefs'] = array();
+                               $cached_prefs['raw_filters'] = array();
+                               $cached_prefs['ex_accounts_count'] = '0';
+                               $cached_prefs['extra_accounts'] = array();
+                               $cached_prefs['extra_and_default_acounts'] = 
array();
+                               $cached_prefs['a'] = array();
+                               */
+                               // get the data from appsession, we use 
compression to avoid problems unserializing
+                               $my_location = '0;cached_prefs';
+                               $cached_prefs = 
$this->so->so_appsession_passthru($my_location);
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): raw $cached_prefs as 
returned from cache DUMP:', $cached_prefs); }
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): raw serialized 
$cached_prefs is '.htmlspecialchars(serialize($cached_prefs)).'<br>'); }
+                       }
+
+                       // ok if we actually got cached_prefs then maybe we can 
use them
+                       if (($this->use_cached_prefs == True)
+                       && ((string)$cached_prefs != $this->nothing)
+                       && (is_array($cached_prefs))
+                       && (isset($cached_prefs['extra_and_default_acounts'])))
+                       {
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): raw $cached_prefs 
deemed to actually have usable data, so process it<br>'); }
+                               // UN-defang the filters
+                               // NO remember that filters are left in defang 
(htmlquotes encoded) form
+                               // UNTIL they are going to be used, then 
bofilters defangs them
+                               //for ($x=0; $x < 
count($cached_prefs['raw_filters']); $x++)
+                               //{
+                               //      
$cached_prefs['raw_filters'][$x]['filtername'] = 
$this->db_defang_decode($cached_prefs['raw_filters'][$x]['filtername']);
+                               //      
$cached_prefs['raw_filters'][$x]['source_accounts']['folder'] = 
$this->db_defang_decode($cached_prefs['raw_filters'][$x]['source_accounts']['folder']);
+                               //      for ($y=0; $y < 
count($cached_prefs['raw_filters']['matches']); $y++)
+                               //      {
+                               //              
$cached_prefs['raw_filters'][$x]['matches'][$y]['matchthis']
+                               //                      = 
$this->db_defang_decode($cached_prefs['raw_filters'][$x]['matches'][$y]['matchthis']);
+                               //      }
+                               //      for ($y=0; $y < 
count($cached_prefs['raw_filters']['actions']); $y++)
+                               //      {
+                               //              
$cached_prefs['raw_filters'][$x]['actions'][$y]['folder']
+                               //                      = 
$this->db_defang_decode($cached_prefs['raw_filters'][$x]['actions'][$y]['folder']);
+                               //      }
+                               //}
+                               // UN-defang the rest of the prefs that may 
need it
+                               $defang_these = array();
+                               $defang_these[0] = 'passwd';
+                               $defang_these[1] = 'email_sig';
+                               $defang_these[2] = 'trash_folder_name';
+                               $defang_these[3] = 'sent_folder_name';
+                               $defang_these[4] = 'userid';
+                               $defang_these[5] = 'address';
+                               $defang_these[6] = 'mail_folder';
+                               $defang_these[7] = 'fullname';
+                               $defang_these[8] = 'account_name';
+                               $loops = 
count($cached_prefs['extra_and_default_acounts']);
+                               for ($i=0; $i < $loops; $i++)
                                {
-                                       $this->raw_filters = 
$appsession_cached_prefs['cached_prefs']['raw_filters'];
+                                       for ($x=0; $x < count($defang_these); 
$x++)
+                                       {
+                                               $defang_word = 
$defang_these[$x];
+                                               if 
(isset($cached_prefs['a'][$i]['prefs'][$defang_word]))
+                                               {
+                                                       
$cached_prefs['a'][$i]['prefs'][$defang_word]
+                                                               = 
$this->db_defang_decode($cached_prefs['a'][$i]['prefs'][$defang_word]);
+                                               }
+                                       }
                                }
-                               // (c) prefs for default account 0, ALSO are 
the "backwards compatibility prefs data
-                               
$this->set_pref_array($appsession_cached_prefs['cached_prefs']['acct_0'], 0);
-                               if 
(is_array($GLOBALS['phpgw_info']['user']['preferences']['email']) == False)
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): retrieved $cached_prefs 
AFTER UN-defang DUMP:', $cached_prefs); }
+                               // lets fill the data
+                               $this->unprocessed_prefs = 
$cached_prefs['unprocessed_prefs'];
+                               $this->raw_filters = 
$cached_prefs['raw_filters'];
+                               $this->ex_accounts_count = 
$cached_prefs['ex_accounts_count'];
+                               $this->extra_accounts = 
$cached_prefs['extra_accounts'];
+                               $this->extra_and_default_acounts = 
$cached_prefs['extra_and_default_acounts'];
+                               $loops = 
count($this->extra_and_default_acounts);
+                               for ($i=0; $i < $loops; $i++)
                                {
-                                       
$GLOBALS['phpgw_info']['user']['preferences']['email'] = array();
-                                       
$GLOBALS['phpgw_info']['user']['preferences']['email'] = 
$appsession_cached_prefs['cached_prefs']['acct_0'];
+                                       
$this->set_pref_array($cached_prefs['a'][$i]['prefs'], $i);
                                }
-                               // (d) the rest of the accounts, what are their 
account numbers?
-                               // since some accts could be disabled, they 
need not be contiguously numbered, disabled accts do not get processed prefs
-                               $ex_acct_nums = array();
-                               if 
(isset($appsession_cached_prefs['cached_prefs']['ex_accounts_nums']))
-                               {
-                                       $ex_acct_nums = 
explode(',',$appsession_cached_prefs['cached_prefs']['ex_accounts_nums']);
-                               }
-                               //(e)  fill in this array containing some info 
about these accounts status, acct 0 is always done because we know acct 0 
always exists
-                               $this->extra_and_default_acounts = array();
-                               $this->extra_and_default_acounts[0]['acctnum'] 
= 0;
-                               $this->extra_and_default_acounts[0]['status'] = 
'enabled';
-                               // (f) fill in this item with data about the 
number of accounts
-                               $this->ex_accounts_count = count($ex_acct_nums);
-                               // (g) fill the prefs for extra accounts if 
necessary
-                               
$this->extra_and_default_acounts[$i+1]['acctnum'] = 
$this->extra_accounts[$i]['acctnum'];
-                               
$this->extra_and_default_acounts[$i+1]['status'] = 
$this->extra_accounts[$i]['status'];
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): successfully retrieved 
and applied $cached_prefs<br>'); }
                        }
-                       */
-
-                       // obtain the preferences from the database, put them 
in $this->unprocessed_prefs, note THIS GETS ALL PREFS for some reason, not just 
email prefs?
-                       //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: BEFORE "create_email_preferences" 
GLOBALS[phpgw_info][user][preferences] DUMP<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']); echo '</pre>'); }
-                       //$this->unprocessed_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences();
-                       $tmp_email_only_prefs = array();
-                       $tmp_email_only_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences();
-                       // clean "unprocessed_prefs" so all prefs oher than 
email are NOT included
-                       $this->unprocessed_prefs = array();
-                       $this->unprocessed_prefs['email'] = array();
-                       $this->unprocessed_prefs['email'] = 
$tmp_email_only_prefs['email'];
-                       $tmp_email_only_prefs = array();
-                       unset($tmp_email_only_prefs);
-                       //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: AFTER "create_email_preferences" 
GLOBALS[phpgw_info][user][preferences] DUMP<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']); echo '</pre>'); }
-
-                       // BACKWARDS COMPAT for apps that have no clue what 
multiple accounts are about
-                       // fill email's 
$GLOBALS['phpgw_info']['user']['preferences'] with the data for backwards 
compatibility (we don't use that)
-                       // damn, where did email's prefs get filled already? 
Where are they getting filled, anyway do not re-fill if not needed
-                       // NO - IT IS POSSIBLE THIS MAY NOT CATCH ALL PREF 
CHANGES IN CORNER CASES
-                       //if 
(is_array($GLOBALS['phpgw_info']['user']['preferences']['email']) == False)
+                       //$allow_prefs_shortcut = True;
+                       //$allow_prefs_shortcut = False;
+                       //if 
((is_array($GLOBALS['phpgw_info']['user']['preferences']['email']) == True)
+                       //&& ($allow_prefs_shortcut == True))
                        //{
-                               //$GLOBALS['phpgw_info']['user']['preferences'] 
= $this->unprocessed_prefs;
-                               
$GLOBALS['phpgw_info']['user']['preferences']['email'] = array();
-                               
$GLOBALS['phpgw_info']['user']['preferences']['email'] = 
$this->unprocessed_prefs['email'];
+                       //      if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): prefs array already 
created by the API, NOT calling "create_email_preferences"<br>'); }
+                       //      $this->unprocessed_prefs = array();
+                       //      $this->unprocessed_prefs['email'] = array();
+                       //      $this->unprocessed_prefs['email'] = 
$GLOBALS['phpgw_info']['user']['preferences']['email'];
+                       //      if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): did NOT call 
create_email_preferences, prefs were already available in 
$GLOBALS["phpgw_info"]["user"]["preferences"]["email"] <br>'); }
                        //}
-                       //echo 'dump3 <pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']); echo '</pre>';
-                       // BUT DO NOT put unneeded stuff in there, 
[ex_accounts] and [filters] multilevel arrays
-                       // are not needed for mackward compat, we need them 
internally but external apps do not use this raw data
-                       if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts']))
-                       {
-                               
$GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts'] = array();
-                               
unset($GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts']);
-                       }
-                       if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['email']['filters']))
-                       {
-                               
$GLOBALS['phpgw_info']['user']['preferences']['email']['filters'] = array();
-                               
unset($GLOBALS['phpgw_info']['user']['preferences']['email']['filters']);
-                       }
-                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: AFTER backwards_compat and cleaning 
GLOBALS[phpgw_info][user][preferences] DUMP:', 
$GLOBALS['phpgw_info']['user']['preferences']); }
-
-                       // first, put the filter data from prefs in a holding 
var for use by the filters class if needed
-                       // raw filters array for use by the filters class, we 
just put the data here, that is all, while collecting other prefs
-                       $this->raw_filters = array();
-                       if 
((isset($this->unprocessed_prefs['email']['filters']))
-                       && 
(is_array($this->unprocessed_prefs['email']['filters'])))
-                       {
-                               $this->raw_filters = 
$this->unprocessed_prefs['email']['filters'];
-                               // not get that out of "unprocessed_prefs" 
because it is not needed there any more
-                               $this->unprocessed_prefs['email']['filters'] = 
array();
-                               
unset($this->unprocessed_prefs['email']['filters']);
-                       }
-                       //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: put filter data in 
$this->raw_filters DUMP<pre>'; print_r($this->raw_filters); echo '</pre>'); }
-
-                       // second, set the prefs for the default, base acct 0, 
BUT do not give it data it does not need
-                       // we already got "filters" out of "unprocessed_prefs", 
so when setting acct0 prefs, do not give it the "ex_accounts" array
-                       $acct0_prefs_cleaned = array();
-                       $acct0_prefs_cleaned = $this->unprocessed_prefs;
-                       if 
((isset($acct0_prefs_cleaned['email']['ex_accounts']))
-                       && 
(is_array($acct0_prefs_cleaned['email']['ex_accounts'])))
-                       {
-                               $acct0_prefs_cleaned['email']['ex_accounts'] = 
array();
-                               
unset($acct0_prefs_cleaned['email']['ex_accounts']);
-                       }
-                       // now we can use that to set the prefs for the base 
account
-
-                       // ---  process pres for in multi account enviornment 
---
-                       // for our use, put prefs in a class var to be accessed 
thru OOP-style access calls in mail_msg_wrapper
-                       // since we know these prefs to be the  top level 
prefs, for the default email account, force them into acctnum 0
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: putting top level, default account, 
pref data in acct 0 with $this->set_pref_array($acct0_prefs_cleaned[email], 0); 
<br>'); }
-                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request:  $acct0_prefs_cleaned[email] DUMP:', 
$acct0_prefs_cleaned['email']); }
-                       
//$this->set_pref_array($this->unprocessed_prefs['email'], 0);
-                       $this->set_pref_array($acct0_prefs_cleaned['email'], 0);
-                       $acct0_prefs_cleaned = array();
-                       unset($acct0_prefs_cleaned);
-
-
-                       // ===  EXTRA ACCOUNTS  ===
-                       // they are located in an array based at 
$this->unprocessed_prefs['email']['ex_accounts'][]
-                       // determine what extra accounts have been defined
-                       // note: php3 DOES have is_array(), ok to use it here
-                       if 
((isset($this->unprocessed_prefs['email']['ex_accounts']))
-                       && 
(is_array($this->unprocessed_prefs['email']['ex_accounts'])))
+                       else
                        {
-                               $this->ex_accounts_count = 
count($this->unprocessed_prefs['email']['ex_accounts']);
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: 
$this->unprocessed_prefs[email][ex_accounts] is set and is_array, its count: 
$this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
-                               if ($this->debug_logins > 2) { 
$this->dbug->out('$this->unprocessed_prefs[email][ex_accounts] DUMP:', 
$this->unprocessed_prefs['email']['ex_accounts']); }
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to process extra account data 
; $this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
-                               // note: extra accounts lowest possible value = 
1, NOT 0
-                               // also, $key, although numbered integers, may 
not be conticuous lowest to highest (may be empty or missing elements inbetween)
-
-                               // ---- what accounts have some data defined
-                               // array_extra_accounts[X]['acctnum'] : integer
-                               // array_extra_accounts[X]['status'] string = 
"enabled" | "disabled" | "empty"
-                               //while(list($key,$value) = 
each($this->unprocessed_prefs['email']['ex_accounts']))
-                               while(list($key,$value) = 
each($this->unprocessed_prefs['email']['ex_accounts']))
-                               {
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: inside loop: for each 
$this->unprocessed_prefs[email][ex_accounts] ; $key: ['.serialize($key).'] 
$value DUMP:', $value); }
-                                       // if we are here at all then this 
array item must have some data defined
-                                       $next_pos = 
count($this->extra_accounts);
-                                       $this->extra_accounts[$next_pos] = 
array();
-                                       
$this->extra_accounts[$next_pos]['acctnum'] = (int)$key;
-                                       // ----  is this account "enabled", 
"disabled" or is this array item "empty"
-                                       // first, see if it has essential data, 
if not, it's an empty array item
-                                       if ( 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['fullname']))
-                                       || 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['email_sig']))
-                                       || 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['layout'])) )
-                                       {
-                                               // this account lacks essential 
data needed to describe an account, it must be an "empty" element
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: inside loop: account ['.$key.'] is 
*empty*: $this->unprocessed_prefs[email][ex_accounts]['.$key.']: 
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]).']<br>'); }
-                                               
$this->extra_accounts[$next_pos]['status'] = 'empty';
-                                       }
-                                       // ... so the account is not empty ...
-                                       elseif ( 
(isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']))
-                                       && 
((string)$this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']
 != ''))
-                                       {
-                                               // this account is defined AND 
enabled,
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: inside loop: account ['.$key.'] is 
*enabled*: 
$this->unprocessed_prefs[email][ex_accounts]['.$key.'][ex_account_enabled]:  
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']).']<br>');
 }
-                                               
$this->extra_accounts[$next_pos]['status'] = 'enabled';
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $cached_prefs either 
disabled or no data was cached<br>'); }
+                               // make this empty without question, since 
cached prefs were not recovered
+                               $cached_prefs = array();
+                               // IT SEEMS PREFS FOR ACCT 0 NEED TO RUN THRU 
THIS TO FILL "Account Name" thingy
+                               // obtain the preferences from the database, 
put them in $this->unprocessed_prefs, note THIS GETS ALL PREFS for some reason, 
not just email prefs?
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): BEFORE processing email 
prefs, GLOBALS[phpgw_info][user][preferences][email] DUMP:', 
$GLOBALS['phpgw_info']['user']['preferences']['email']); }
+
+                               //$this->unprocessed_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences();
+                               $tmp_email_only_prefs = array();
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): calling 
create_email_preferences, may be time consuming<br>'); }
+                               $tmp_email_only_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences();
+                               // clean "unprocessed_prefs" so all prefs oher 
than email are NOT included
+                               $this->unprocessed_prefs = array();
+                               $this->unprocessed_prefs['email'] = array();
+                               $this->unprocessed_prefs['email'] = 
$tmp_email_only_prefs['email'];
+                               $tmp_email_only_prefs = array();
+                               unset($tmp_email_only_prefs);
+                               //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): AFTER 
"create_email_preferences" GLOBALS[phpgw_info][user][preferences] DUMP<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']); echo '</pre>'); }
+
+                               // BACKWARDS COMPAT for apps that have no clue 
what multiple accounts are about
+                               // fill email's 
$GLOBALS['phpgw_info']['user']['preferences'] with the data for backwards 
compatibility (we don't use that)
+                               // damn, where did email's prefs get filled 
already? Where are they getting filled, anyway do not re-fill if not needed
+                               // NO - IT IS POSSIBLE THIS MAY NOT CATCH ALL 
PREF CHANGES IN CORNER CASES
+                               if 
(is_array($GLOBALS['phpgw_info']['user']['preferences']['email']) == False)
+                               {
+                                       
//$GLOBALS['phpgw_info']['user']['preferences'] = $this->unprocessed_prefs;
+                                       
$GLOBALS['phpgw_info']['user']['preferences']['email'] = array();
+                                       
$GLOBALS['phpgw_info']['user']['preferences']['email'] = 
$this->unprocessed_prefs['email'];
+                               }
+                               //echo 'dump3 <pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']); echo '</pre>';
+                               // BUT DO NOT put unneeded stuff in there, 
[ex_accounts] and [filters] multilevel arrays
+                               // are not needed for mackward compat, we need 
them internally but external apps do not use this raw data
+                               //if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts']))
+                               //{
+                               //      
$GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts'] = array();
+                               //      
unset($GLOBALS['phpgw_info']['user']['preferences']['email']['ex_accounts']);
+                               //}
+                               //if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['email']['filters']))
+                               //{
+                               //      
$GLOBALS['phpgw_info']['user']['preferences']['email']['filters'] = array();
+                               //      
unset($GLOBALS['phpgw_info']['user']['preferences']['email']['filters']);
+                               //}
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): AFTER backwards_compat 
and cleaning GLOBALS[phpgw_info][user][preferences] DUMP:', 
$GLOBALS['phpgw_info']['user']['preferences']); }
+
+
+                               // first, put the filter data from prefs in a 
holding var for use by the filters class if needed
+                               // raw filters array for use by the filters 
class, we just put the data here, that is all, while collecting other prefs
+                               $this->raw_filters = array();
+                               if 
((isset($this->unprocessed_prefs['email']['filters']))
+                               && 
(is_array($this->unprocessed_prefs['email']['filters'])))
+                               {
+                                       $this->raw_filters = 
$this->unprocessed_prefs['email']['filters'];
+                                       // not get that out of 
"unprocessed_prefs" because it is not needed there any more
+                                       
$this->unprocessed_prefs['email']['filters'] = array();
+                                       
unset($this->unprocessed_prefs['email']['filters']);
+                               }
+                               //if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): put filter data in 
$this->raw_filters DUMP<pre>'; print_r($this->raw_filters); echo '</pre>'); }
+
+                               // second, set the prefs for the default, base 
acct 0, BUT do not give it data it does not need
+                               // we already got "filters" out of 
"unprocessed_prefs", so when setting acct0 prefs, do not give it the 
"ex_accounts" array
+                               $acct0_prefs_cleaned = array();
+                               $acct0_prefs_cleaned = $this->unprocessed_prefs;
+                               if 
((isset($acct0_prefs_cleaned['email']['ex_accounts']))
+                               && 
(is_array($acct0_prefs_cleaned['email']['ex_accounts'])))
+                               {
+                                       
$acct0_prefs_cleaned['email']['ex_accounts'] = array();
+                                       
unset($acct0_prefs_cleaned['email']['ex_accounts']);
+                               }
+                               // now we can use that to set the prefs for the 
base account
+
+                               // ---  process pres for in multi account 
enviornment ---
+                               // for our use, put prefs in a class var to be 
accessed thru OOP-style access calls in mail_msg_wrapper
+                               // since we know these prefs to be the  top 
level prefs, for the default email account, force them into acctnum 0
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): putting top level, 
default account, pref data in acct 0 with 
$this->set_pref_array($acct0_prefs_cleaned[email], 0); <br>'); }
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
$acct0_prefs_cleaned[email] DUMP:', $acct0_prefs_cleaned['email']); }
+                               
//$this->set_pref_array($this->unprocessed_prefs['email'], 0);
+                               
$this->set_pref_array($acct0_prefs_cleaned['email'], 0);
+                               $acct0_prefs_cleaned = array();
+                               unset($acct0_prefs_cleaned);
+
+
+                               // ===  EXTRA ACCOUNTS  ===
+                               // they are located in an array based at 
$this->unprocessed_prefs['email']['ex_accounts'][]
+                               // determine what extra accounts have been 
defined
+                               // note: php3 DOES have is_array(), ok to use 
it here
+                               if 
((isset($this->unprocessed_prefs['email']['ex_accounts']))
+                               && 
(is_array($this->unprocessed_prefs['email']['ex_accounts'])))
+                               {
+                                       $this->ex_accounts_count = 
count($this->unprocessed_prefs['email']['ex_accounts']);
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
$this->unprocessed_prefs[email][ex_accounts] is set and is_array, its count: 
$this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
+                                       if ($this->debug_logins > 2) { 
$this->dbug->out('$this->unprocessed_prefs[email][ex_accounts] DUMP:', 
$this->unprocessed_prefs['email']['ex_accounts']); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to process extra 
account data ; $this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
+                                       // note: extra accounts lowest possible 
value = 1, NOT 0
+                                       // also, $key, although numbered 
integers, may not be conticuous lowest to highest (may be empty or missing 
elements inbetween)
+
+                                       // ---- what accounts have some data 
defined
+                                       // array_extra_accounts[X]['acctnum'] : 
integer
+                                       // array_extra_accounts[X]['status'] 
string = "enabled" | "disabled" | "empty"
+                                       //while(list($key,$value) = 
each($this->unprocessed_prefs['email']['ex_accounts']))
+                                       while(list($key,$value) = 
each($this->unprocessed_prefs['email']['ex_accounts']))
+                                       {
+                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): inside loop: for each 
$this->unprocessed_prefs[email][ex_accounts] ; $key: ['.serialize($key).'] 
$value DUMP:', $value); }
+                                               // if we are here at all then 
this array item must have some data defined
+                                               $next_pos = 
count($this->extra_accounts);
+                                               
$this->extra_accounts[$next_pos] = array();
+                                               
$this->extra_accounts[$next_pos]['acctnum'] = (int)$key;
+                                               // ----  is this account 
"enabled", "disabled" or is this array item "empty"
+                                               // first, see if it has 
essential data, if not, it's an empty array item
+                                               if ( 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['fullname']))
+                                               || 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['email_sig']))
+                                               || 
(!isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['layout'])) )
+                                               {
+                                                       // this account lacks 
essential data needed to describe an account, it must be an "empty" element
+                                                       if ($this->debug_logins 
> 1) { $this->dbug->out('mail_msg.begin_request('.__LINE__.'): inside loop: 
account ['.$key.'] is *empty*: 
$this->unprocessed_prefs[email][ex_accounts]['.$key.']: 
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]).']<br>'); }
+                                                       
$this->extra_accounts[$next_pos]['status'] = 'empty';
+                                               }
+                                               // ... so the account is not 
empty ...
+                                               elseif ( 
(isset($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']))
+                                               && 
((string)$this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']
 != ''))
+                                               {
+                                                       // this account is 
defined AND enabled,
+                                                       if ($this->debug_logins 
> 1) { $this->dbug->out('mail_msg.begin_request('.__LINE__.'): inside loop: 
account ['.$key.'] is *enabled*: 
$this->unprocessed_prefs[email][ex_accounts]['.$key.'][ex_account_enabled]:  
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']).']<br>');
 }
+                                                       
$this->extra_accounts[$next_pos]['status'] = 'enabled';
+                                               }
+                                               else
+                                               {
+                                                       // this account is 
defined BUT not enabled
+                                                       if ($this->debug_logins 
> 1) { $this->dbug->out('mail_msg.begin_request('.__LINE__.'): inside loop: 
account ['.$key.'] is *disabled*: 
$this->unprocessed_prefs[email][ex_accounts]['.$key.'][ex_account_enabled]:  
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']).']<br>');
 }
+                                                       
$this->extra_accounts[$next_pos]['status'] = 'disabled';
+                                               }
+
+                                               // IF ENABLED, then
+                                               if 
($this->extra_accounts[$next_pos]['status'] == 'enabled')
+                                               {
+                                                       // PROCESS EXTRA 
ACCOUNT PREFS
+                                                       // run thru the create 
prefs function requesting this particular acctnum
+                                                       // fills in certain 
missing data, and does some sanity checks, and any data processing that may be 
necessary
+                                                       $sub_tmp_prefs = 
array();
+                                                       // we "fool" 
create_email_preferences into processing extra account info as if it were top 
level data
+                                                       // by specifing the 
secong function arg as the integer of this particular enabled account
+                                                       $this_ex_acctnum = 
$this->extra_accounts[$next_pos]['acctnum'];
+                                                       if ($this->debug_logins 
> 1) { $this->dbug->out('mail_msg.begin_request('.__LINE__.'): CALLING 
create_email_preferences("", $this_ex_acctnum) for specific account, where 
$this_ex_acctnum: ['.serialize($this_ex_acctnum).'] <br>'); }
+                                                       $sub_tmp_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences('', $this_ex_acctnum);
+                                                       // now put these 
processed prefs in the correct location  in our prefs array
+                                                       
$this->set_pref_array($sub_tmp_prefs['email'], $this_ex_acctnum);
+                                               }
                                        }
-                                       else
+                                       // extra_and_default_acounts is the 
same as above but has default account inserted at position zero
+                                       $this->extra_and_default_acounts = 
array();
+                                       // first put in the default account
+                                       
$this->extra_and_default_acounts[0]['acctnum'] = 0;
+                                       
$this->extra_and_default_acounts[0]['status'] = 'enabled';
+                                       // now add whetever extra accounts we 
processed above
+                                       $loops = count($this->extra_accounts);
+                                       for ($i=0; $i < $loops; $i++)
                                        {
-                                               // this account is defined BUT 
not enabled
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: inside loop: account ['.$key.'] is 
*disabled*: 
$this->unprocessed_prefs[email][ex_accounts]['.$key.'][ex_account_enabled]:  
['.serialize($this->unprocessed_prefs['email']['ex_accounts'][$key]['ex_account_enabled']).']<br>');
 }
-                                               
$this->extra_accounts[$next_pos]['status'] = 'disabled';
+                                               
$this->extra_and_default_acounts[$i+1]['acctnum'] = 
$this->extra_accounts[$i]['acctnum'];
+                                               
$this->extra_and_default_acounts[$i+1]['status'] = 
$this->extra_accounts[$i]['status'];
                                        }
-
-                                       // IF ENABLED, then
-                                       if 
($this->extra_accounts[$next_pos]['status'] == 'enabled')
-                                       {
-                                               // PROCESS EXTRA ACCOUNT PREFS
-                                               // run thru the create prefs 
function requesting this particular acctnum
-                                               // fills in certain missing 
data, and does some sanity checks, and any data processing that may be necessary
-                                               $sub_tmp_prefs = array();
-                                               // we "fool" 
create_email_preferences into processing extra account info as if it were top 
level data
-                                               // by specifing the secong 
function arg as the integer of this particular enabled account
-                                               $this_ex_acctnum = 
$this->extra_accounts[$next_pos]['acctnum'];
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call 
create_email_preferences("", $this_ex_acctnum) where $this_ex_acctnum: 
['.serialize($this_ex_acctnum).'] <br>'); }
-                                               $sub_tmp_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences('', $this_ex_acctnum);
-                                               // now put these processed 
prefs in the correct location  in our prefs array
-                                               
$this->set_pref_array($sub_tmp_prefs['email'], $this_ex_acctnum);
-                                       }
-                               }
-                               // extra_and_default_acounts is the same as 
above but has default account inserted at position zero
-                               $this->extra_and_default_acounts = array();
-                               // first put in the default account
-                               $this->extra_and_default_acounts[0]['acctnum'] 
= 0;
-                               $this->extra_and_default_acounts[0]['status'] = 
'enabled';
-                               // now add whetever extra accounts we processed 
above
-                               $loops = 
count($GLOBALS['phpgw']->msg->extra_accounts);
-                               for ($i=0; $i < $loops; $i++)
+                                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $this->extra_accounts 
DUMP:', $this->extra_accounts); }
+                                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
$this->extra_and_default_acounts DUMP:', $this->extra_and_default_acounts); }
+                               }
+                               else
                                {
-                                       
$this->extra_and_default_acounts[$i+1]['acctnum'] = 
$this->extra_accounts[$i]['acctnum'];
-                                       
$this->extra_and_default_acounts[$i+1]['status'] = 
$this->extra_accounts[$i]['status'];
+                                       $this->ex_accounts_count = 0;
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
$this->unprocessed_prefs[email][ex_accounts] NOT set or NOT is_array, 
$this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
                                }
-                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: $this->extra_accounts DUMP:', 
$this->extra_accounts); }
-                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: $this->extra_and_default_acounts 
DUMP:', $this->extra_and_default_acounts); }
-                       }
-                       else
+                               // if NO extra accounts axist, we STILL need to 
put the default account inextra_and_default_acounts
+                               // extra_and_default_acounts will not have been 
handled whatsoever if no extra accounts exist
+                               // so make sure the default account is there
+                               if (count($this->extra_and_default_acounts) == 
0)
+                               {
+                                       $this->extra_and_default_acounts = 
array();
+                                       // first put in the default account
+                                       
$this->extra_and_default_acounts[0]['acctnum'] = 0;
+                                       
$this->extra_and_default_acounts[0]['status'] = 'enabled';
+                               }
+                               // -end- extra account init handling
+                       }
+
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'): POST create_email_preferences 
GLOBALS[phpgw_info][user][preferences][email] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']['email']) ; echo 
'</pre>';}
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'): POST create_email_preferences 
$this->get_all_prefs() dump:<pre>'; print_r($this->get_all_prefs()) ; echo 
'</pre>';}
+                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): POST 
create_email_preferences direct access dump of $this->a DUMP:', $this->a); }
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'):  preferences->create_email_preferences 
called, GLOBALS[phpgw_info][user][preferences] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']) ; echo '</pre>';}
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'):  preferences->create_email_preferences 
called, GLOBALS[phpgw_info][user] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']['user']) ; echo '</pre>';}
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'): preferences->create_email_preferences 
called, GLOBALS[phpgw_info] dump:<pre>'; print_r($GLOBALS['phpgw_info']) ; echo 
'</pre>';}
+                       //if ($this->debug_logins > 2) { echo 
'mail_msg.begin_request('.__LINE__.'): preferences->create_email_preferences 
called, GLOBALS[phpgw] dump:<pre>'; print_r($GLOBALS['phpgw']) ; echo '</pre>';}
+
+                       // ---- CACHE THE COMPLETED PREF DATA
+                       if (($this->use_cached_prefs == True)
+                       && (!$cached_prefs))
                        {
-                               $this->ex_accounts_count = 0;
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: 
$this->unprocessed_prefs[email][ex_accounts] NOT set or NOT is_array, 
$this->ex_accounts_count: ['.$this->ex_accounts_count.']<br>'); }
-                       }
-                       // if NO extra accounts axist, we STILL need to put the 
default account inextra_and_default_acounts
-                       // extra_and_default_acounts will not have been handled 
whatsoever if no extra accounts exist
-                       // so make sure the default account is there
-                       if (count($this->extra_and_default_acounts) == 0)
-                       {
-                               $this->extra_and_default_acounts = array();
-                               // first put in the default account
-                               $this->extra_and_default_acounts[0]['acctnum'] 
= 0;
-                               $this->extra_and_default_acounts[0]['status'] = 
'enabled';
+                               // for whever reason we did not get any data 
from the stored prefs
+                               /*
+                               // data we need to DB save to cache final 
processed prefs
+                               $this->unprocessed_prefs
+                               $this->raw_filters
+                               $this->ex_accounts_count
+                               $this->extra_accounts
+                               $this->extra_and_default_acounts
+                               $this->a[X]->['prefs']
+                               // where X is the account number, we can use 
"set_pref_array(array_data, acctnum) for each account
+                               */
+                               // ok lets make an array to hold this data in 
the DB
+                               $cached_prefs = array();
+                               $cached_prefs['unprocessed_prefs'] = array();
+                               $cached_prefs['raw_filters'] = array();
+                               $cached_prefs['ex_accounts_count'] = '0';
+                               $cached_prefs['extra_accounts'] = array();
+                               $cached_prefs['extra_and_default_acounts'] = 
array();
+                               $cached_prefs['a'] = array();
+                               // lets fill the data
+                               $cached_prefs['unprocessed_prefs'] = 
$this->unprocessed_prefs;
+                               $cached_prefs['raw_filters'] = 
$this->raw_filters;
+                               // defang the filters
+                               // NO remember bofilters defangs, htmlquotes 
encodes, the filters FOR US
+                               // they are stored in the preferences DB 
already in defanged state
+                               // we never need to degang or UN-defang filters
+                               // because bofilters handles ALL that for us
+                               //for ($x=0; $x < 
count($cached_prefs['raw_filters']); $x++)
+                               //{
+                               //      
$cached_prefs['raw_filters'][$x]['filtername'] = 
$this->db_defang_encode($cached_prefs['raw_filters'][$x]['filtername']);
+                               //      
$cached_prefs['raw_filters'][$x]['source_accounts']['folder'] = 
$this->db_defang_encode($cached_prefs['raw_filters'][$x]['source_accounts']['folder']);
+                               //      for ($y=0; $y < 
count($cached_prefs['raw_filters']['matches']); $y++)
+                               //      {
+                               //              
$cached_prefs['raw_filters'][$x]['matches'][$y]['matchthis']
+                               //                      = 
$this->db_defang_encode($cached_prefs['raw_filters'][$x]['matches'][$y]['matchthis']);
+                               //      }
+                               //      for ($y=0; $y < 
count($cached_prefs['raw_filters']['actions']); $y++)
+                               //      {
+                               //              
$cached_prefs['raw_filters'][$x]['actions'][$y]['folder']
+                               //                      = 
$this->db_defang_encode($cached_prefs['raw_filters'][$x]['actions'][$y]['folder']);
+                               //      }
+                               //}
+                               $cached_prefs['ex_accounts_count'] = 
$this->ex_accounts_count;
+                               $cached_prefs['extra_accounts'] = 
$this->extra_accounts;
+                               $cached_prefs['extra_and_default_acounts'] = 
$this->extra_and_default_acounts;
+                               $cached_prefs['a'] = array();
+                               $defang_these = array();
+                               $defang_these[0] = 'passwd';
+                               $defang_these[1] = 'email_sig';
+                               $defang_these[2] = 'trash_folder_name';
+                               $defang_these[3] = 'sent_folder_name';
+                               $defang_these[4] = 'userid';
+                               $defang_these[5] = 'address';
+                               $defang_these[6] = 'mail_folder';
+                               $defang_these[7] = 'fullname';
+                               $defang_these[8] = 'account_name';
+                               $loops = 
count($this->extra_and_default_acounts);
+                               for ($i=0; $i < $loops; $i++)
+                               {
+                                       $cached_prefs['a'][$i] = array();
+                                       $cached_prefs['a'][$i]['prefs'] = 
array();
+                                       $cached_prefs['a'][$i]['prefs'] = 
$this->a[$i]['prefs'];
+                                       // defang
+                                       for ($x=0; $x < count($defang_these); 
$x++)
+                                       {
+                                       $defang_word = $defang_these[$x];
+                                               if 
(isset($cached_prefs['a'][$i]['prefs'][$defang_word]))
+                                               {
+                                                       
$cached_prefs['a'][$i]['prefs'][$defang_word]  = 
$this->db_defang_encode($cached_prefs['a'][$i]['prefs'][$defang_word]);
+                                               }
+                                       }
+                               }
+                               // just use account 0 for this eventhough the 
prefs are for every account
+                               $my_location = '0;cached_prefs';
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): POST 
create_email_preferences we made the $cached_prefs for storage DUMP:', 
$cached_prefs); }
+                               $this->so->so_appsession_passthru($my_location, 
$cached_prefs);
                        }
-                       // -end- extra account init handling
-
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: POST create_email_preferences 
GLOBALS[phpgw_info][user][preferences][email] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']['email']) ; echo 
'</pre>';}
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: POST create_email_preferences $this->get_all_prefs() 
dump:<pre>'; print_r($this->get_all_prefs()) ; echo '</pre>';}
-                       if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: POST create_email_preferences direct 
access dump of $this->a DUMP:', $this->a); }
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: preferences->create_email_preferences called, 
GLOBALS[phpgw_info][user][preferences] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']['user']['preferences']) ; echo '</pre>';}
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: preferences->create_email_preferences called, 
GLOBALS[phpgw_info][user] dump:<pre>'; print_r($GLOBALS['phpgw_info']['user']) 
; echo '</pre>';}
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: preferences->create_email_preferences called, 
GLOBALS[phpgw_info] dump:<pre>'; print_r($GLOBALS['phpgw_info']) ; echo 
'</pre>';}
-                       //if ($this->debug_logins > 2) { echo 'mail_msg: 
begin_request: preferences->create_email_preferences called, GLOBALS[phpgw] 
dump:<pre>'; print_r($GLOBALS['phpgw']) ; echo '</pre>';}

                        // ---- SET important class vars  ----
                        $this->att_files_dir = 
$GLOBALS['phpgw_info']['server']['temp_dir'].SEP.$GLOBALS['phpgw_info']['user']['sessionid'];

                        // and.or get some vars we will use later in this 
function
                        $mailsvr_callstr = 
$this->get_arg_value('mailsvr_callstr');
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $mailsvr_callstr 
'.$mailsvr_callstr.'<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $mailsvr_callstr 
'.$mailsvr_callstr.'<br>'); }

                        // set class var "$this->cache_mailsvr_data" based on 
prefs info
                        // FIXME: why have this in 2 places, just keep it in 
prefs (todo)
@@ -1032,32 +1305,32 @@
                        if ((isset($this->cache_mailsvr_data_disabled))
                        && ($this->cache_mailsvr_data_disabled == True))
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: OLD DEFUNCT OPTION folder cache 
DISABLED, $this->cache_mailsvr_data_disabled = 
'.serialize($this->cache_mailsvr_data_disabled).'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): OLD DEFUNCT OPTION 
folder cache DISABLED, $this->cache_mailsvr_data_disabled = 
'.serialize($this->cache_mailsvr_data_disabled).'<br>'); }
                                $this->cache_mailsvr_data = False;
                        }
                        elseif (($this->get_isset_pref('cache_data'))
                        && ($this->get_pref_value('cache_data') != ''))
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: OLD DEFUNCT OPTION folder cache is 
enabled in user prefs'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): OLD DEFUNCT OPTION 
folder cache is enabled in user prefs'.'<br>'); }
                                $this->cache_mailsvr_data = True;
                        }
                        else
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: OLD DEFUNCT OPTION folder cache is 
NOT enabled in user prefs'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): OLD DEFUNCT OPTION 
folder cache is NOT enabled in user prefs'.'<br>'); }
                                $this->cache_mailsvr_data = False;
                        }

                        // ----  Should We Login  -----
                        if (!isset($args_array['do_login']))
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $args_array[do_login] was NOT set, 
so we set it to default value "FALSE"'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $args_array[do_login] 
was NOT set, so we set it to default value "FALSE"'.'<br>'); }
                                $args_array['do_login'] = False;
                        }
                        // ---- newer 3 way do_login_ex value from the 
bootstrap class
                        if ( (!defined(BS_LOGIN_NOT_SPECIFIED))
                        || (!isset($args_array['do_login_ex'])) )
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $args_array[do_login_ex] not set, 
getting default from a temp local bootstrap object'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
$args_array[do_login_ex] not set, getting default from a temp local bootstrap 
object'.'<br>'); }
                                // that means somewhere the bootstrap class has 
been run
                                $local_bootstrap = 
CreateObject('email.msg_bootstrap');
                                
$local_bootstrap->set_do_login($args_array['do_login'], 'begin_request');
@@ -1065,7 +1338,7 @@
                                $local_bootstrap = '';
                                unset($local_bootstrap);
                        }
-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $args_array[] DUMP 
['.serialize($args_array).']'.'<br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $args_array[] DUMP 
['.serialize($args_array).']'.'<br>'); }

                        /*
                        // ----  Are We In Newsmode Or Not  -----
@@ -1120,30 +1393,52 @@
                        {
                                // IF we already have a cached_folder_list, we 
DO NOT NEED to immediately log in
                                // if and when a login is required, calls to 
"ensure_stream_and_folder" will take care of that login
-                               $appsession_cached_folder_list = 
$this->read_session_cache_item('folder_list', $acctnum);
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('begin_request: LINE '.__LINE__.' check for 
$appsession_cached_folder_list DUMP:', $appsession_cached_folder_list); }
-                               if ($appsession_cached_folder_list)
+                               // actually, we could even test the L1 class 
cashed folder_list first, that is a sure sign we have the data
+                               // note _direct_access_arg_value returns NULL 
(nothing) if that arg is not set
+                               $L1_cached_folder_list = 
$this->_direct_access_arg_value('folder_list', $acctnum);
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('begin_request: LINE '.__LINE__.' check for 
$L1_cached_folder_list DUMP:', $L1_cached_folder_list); }
+                               if ((isset($L1_cached_folder_list) == False)
+                               || (!$L1_cached_folder_list))
+                               {
+                                       $appsession_cached_folder_list = 
$this->read_session_cache_item('folder_list', $acctnum);
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('begin_request: LINE '.__LINE__.' check for 
$appsession_cached_folder_list DUMP:', $appsession_cached_folder_list); }
+                                       // while we are here, if we got a 
folder list now put it in L1 cache so no more aueries to the DB
+                                       // but only if it a new style, full 
folder_list including the folder_short elements
+                                       if 
(isset($appsession_cached_folder_list[0]['folder_short']))
+                                       {
+                                               // cache the result in "Level 1 
cache" class object var
+                                               if (($this->debug_logins > 1) 
|| ($this->debug_args_special_handlers > 1)) { $this->dbug->out('begin_request: 
LINE '.__LINE__.' while we are here, put folder_list into Level 1 class var 
"cache" so no more queries to DB for this<br>'); }
+                                               
$this->set_arg_value('folder_list', $appsession_cached_folder_list, $acctnum);
+                                       }
+                               }
+                               else
+                               {
+                                       // we have L1 data, no need to query 
the database
+                                       $appsession_cached_folder_list = 
$L1_cached_folder_list;
+                               }
+                               if (($L1_cached_folder_list)
+                               || ($appsession_cached_folder_list))
                                {
                                        // in this case, extreme caching is in 
use, AND we already have cached data, so NO NEED TO LOGIN
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: session extreme caching IS in use, 
AND we have a cached "folder_list", which means should also have all necessary 
cached data, so NO LOGIN NEEDED<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): session extreme caching 
IS in use, AND we have a cached "folder_list", which means should also have all 
necessary cached data, so NO LOGIN NEEDED<br>'); }
                                        $decision_to_login = False;

                                        // get a few more things that we would 
otherwise get during the login code (which we'll be skiping)
                                        $processed_folder_arg = 
$this->get_best_folder_arg($args_array, $got_args, $acctnum);
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: session extreme caching IS in use, 
Login may NOT occur, so about to issue: $this->set_arg_value("folder", 
'.$processed_folder_arg.', '.serialize($acctnum).')<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): session extreme caching 
IS in use, Login may NOT occur, so about to issue: 
$this->set_arg_value("folder", '.$processed_folder_arg.', 
'.serialize($acctnum).')<br>'); }
                                        $this->set_arg_value('folder', 
$processed_folder_arg, $acctnum);
                                        if ( $this->get_isset_pref('userid')
                                        && ($this->get_pref_value('userid') != 
''))
                                        {
                                                $user = 
$this->get_pref_value('userid');
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: session extreme caching IS in use, 
Login may NOT occur, so about to issue: 
$this->set_arg_value("mailsvr_account_username", '.$user.', 
'.serialize($acctnum).')<br>'); }
+                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): session extreme caching 
IS in use, Login may NOT occur, so about to issue: 
$this->set_arg_value("mailsvr_account_username", '.$user.', 
'.serialize($acctnum).')<br>'); }
                                                
$this->set_arg_value('mailsvr_account_username', $user, $acctnum);
                                        }
                                }
                                else
                                {
                                        // in this case, extreme caching is in 
use, HOWEVER we do not have necessary cached data, so WE NEED A LOGIN
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: session extreme caching IS in use, 
but we do NOT have a cached "folder_list", meaning we probably do NOT have any 
cached data, so we NEED A LOGIN, allow it if requested<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): session extreme caching 
IS in use, but we do NOT have a cached "folder_list", meaning we probably do 
NOT have any cached data, so we NEED A LOGIN, allow it if requested<br>'); }
                                        $decision_to_login = True;
                                }
                        }
@@ -1154,13 +1449,13 @@

                                // get a few more things that we would 
otherwise get during the login code (which we'll be skiping)
                                $processed_folder_arg = 
$this->get_best_folder_arg($args_array, $got_args, $acctnum);
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request ('.__LINE__.'): we are NOT allowed to 
log in (see code this line) but we still need to get this info, so about to 
issue: $this->set_arg_value("folder", '.$processed_folder_arg.', 
'.serialize($acctnum).')<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): we are NOT allowed to 
log in (see code this line) but we still need to get this info, so about to 
issue: $this->set_arg_value("folder", '.$processed_folder_arg.', 
'.serialize($acctnum).')<br>'); }
                                $this->set_arg_value('folder', 
$processed_folder_arg, $acctnum);
                                if ( $this->get_isset_pref('userid')
                                && ($this->get_pref_value('userid') != ''))
                                {
                                        $user = $this->get_pref_value('userid');
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request ('.__LINE__.'): we are NOT allowed to 
log in (see code this line) but we still need to get this info, so about to 
issue: $this->set_arg_value("mailsvr_account_username", '.$user.', 
'.serialize($acctnum).')<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): we are NOT allowed to 
log in (see code this line) but we still need to get this info, so about to 
issue: $this->set_arg_value("mailsvr_account_username", '.$user.', 
'.serialize($acctnum).')<br>'); }
                                        
$this->set_arg_value('mailsvr_account_username', $user, $acctnum);
                                }
                        }
@@ -1192,40 +1487,40 @@
                        {
                                // extreme caching and logins handled above in 
the first if .. then
                                // if we are here, generally we are allowed to 
login
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: session extreme caching is NOT in 
use, any begin_request logins ARE allowed <br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): session extreme caching 
is NOT in use, any begin_request logins ARE allowed <br>'); }
                                $decision_to_login = True;
                        }

-                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: <u>maybe about to enter login 
sequence</u>, $args_array[]: ['.serialize($args_array).'] ; $decision_to_login 
['.serialize($decision_to_login).'] <br>'); }
+                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): <u>maybe about to enter 
login sequence</u>, $args_array[]: ['.serialize($args_array).'] ; 
$decision_to_login ['.serialize($decision_to_login).'] <br>'); }

                        // now actually use that test result
                        if ($decision_to_login == True)
                        {
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: entered and starting login sequence 
<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): entered and starting 
login sequence <br>'); }

                                //  ----  Get Email Password
                                if ($this->get_isset_pref('passwd') == False)
                                {
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: 
this->a[$this->acctnum][prefs][passwd] NOT set, fallback to 
$GLOBALS[phpgw_info][user][passwd]'.'<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): 
this->a[$this->acctnum][prefs][passwd] NOT set, fallback to 
$GLOBALS[phpgw_info][user][passwd]'.'<br>'); }
                                        // DO NOT alter the password and put 
that altered password BACK into the preferences array
                                        // why not? used to have a reason, but 
that was obviated, no reason at the moment
                                        
//$this->set_pref_value('passwd',$GLOBALS['phpgw_info']['user']['passwd']);
                                        
//$this->a[$this->acctnum]['prefs']['passwd'] = 
$GLOBALS['phpgw_info']['user']['passwd'];
                                        $pass = 
$GLOBALS['phpgw_info']['user']['passwd'];
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: pass grabbed from 
GLOBALS[phpgw_info][user][passwd] = 
'.htmlspecialchars(serialize($pass)).'<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): pass grabbed from 
GLOBALS[phpgw_info][user][passwd] = 
'.htmlspecialchars(serialize($pass)).'<br>'); }
                                }
                                else
                                {
                                        // DO NOT alter the password and do NOT 
put that altered password BACK into the preferences array
                                        // keep the one in GLOBALS in encrypted 
form if possible ????
                                        $pass = $this->get_pref_value('passwd');
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: pass from prefs: already defanged 
for us, but still encrypted <pre>'.$pass.'</pre><br>'."\r\n"); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): pass from prefs: 
already defanged for us, but still encrypted <pre>'.$pass.'</pre><br>'."\r\n"); 
}
                                        // IMPORTANT: (this note on "defanging" 
still valid as of Jan 24, 2002
                                        // the last thing you do before saving 
to the DB is "de-fang"
                                        // so the FIRST thing class prefs does 
when reading from the db MUST be to "UN-defang", and that IS what happens there
                                        // so by now phpgwapi/class.preferences 
has ALREADY done the "de-fanging"
                                        $pass = 
$this->decrypt_email_passwd($pass);
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: pass from prefs: decrypted: 
<pre>'.$pass.'</pre><br>'."\r\n"); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): pass from prefs: 
decrypted: <pre>'.$pass.'</pre><br>'."\r\n"); }
                                }
                                // ----  ISSET CHECK for userid and passwd to 
avoid garbage logins  ----
                                if ( $this->get_isset_pref('userid')
@@ -1240,13 +1535,13 @@
                                        // FIXME make this use an official 
error function
                                        // problem - invalid or nonexistant 
info for userid and/or passwd
                                        //if ($this->debug_logins > 0) {
-                                               echo 'mail_msg: begin_request: 
ERROR: userid or passwd empty'."<br>\r\n"
+                                               echo 
'mail_msg.begin_request('.__LINE__.'): ERROR: userid or passwd empty'."<br>\r\n"
                                                        .' * * 
$this->get_pref_value(userid) = '
                                                                
.$this->get_pref_value('userid')."<br>\r\n"
                                                        .' * * if the userid is 
filled, then it must be the password that is missing'."<br>\r\n"
                                                        .' * * tell your admin 
if a) you have a custom email password or not when reporting this 
error'."<br>\r\n";
                                        //}
-                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: begin_request: LEAVING with ERROR: userid or passwd 
empty<br>'); }
+                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): LEAVING with ERROR: 
userid or passwd empty<br>'); }
                                        return False;
                                }

@@ -1264,7 +1559,7 @@
                                $this_server_type = 
$this->get_pref_value('mail_server_type');
                                // ok, now put that object into the array
                                //$this_acctnum = $this->get_acctnum();
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: creating new dcom_holder at 
$GLOBALS[phpgw_dcom_'.$acctnum.'] = new mail_dcom_holder'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): creating new 
dcom_holder at $GLOBALS[phpgw_dcom_'.$acctnum.'] = new 
mail_dcom_holder'.'<br>'); }
                                $GLOBALS['phpgw_dcom_'.$acctnum] = new 
mail_dcom_holder;
                                $GLOBALS['phpgw_dcom_'.$acctnum]->dcom = 
CreateObject("email.mail_dcom", $this_server_type);
                                // initialize the dcom class variables
@@ -1286,12 +1581,13 @@
                                //@set_time_limit(60);
                                // login to INBOX because we know that 
always(?) should exist on an imap server and pop server
                                // after we are logged in we can get additional 
info that will lead us to the desired folder (if not INBOX)
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call dcom->open: 
$GLOBALS["phpgw_dcom_".$acctnum('.$acctnum.')]->dcom->open('.$mailsvr_callstr."INBOX".',
 '.$user.', '.$pass.', )'.'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call 
dcom->open: 
$GLOBALS["phpgw_dcom_".$acctnum('.$acctnum.')]->dcom->open('.$mailsvr_callstr."INBOX".',
 '.$user.', '.$pass.', )'.'<br>'); }
+                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): <font color="red">MAIL 
SERVER COMMAND</font>'.'<br>'); }
                                $mailsvr_stream = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->open($mailsvr_callstr."INBOX", $user, 
$pass, '');
                                $pass = '';
                                //@set_time_limit(0);

-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: open returns $mailsvr_stream = 
['.serialize($mailsvr_stream).']<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): open returns 
$mailsvr_stream = ['.serialize($mailsvr_stream).']<br>'); }

                                // Logged In Success or Faliure check
                                if ( (!isset($mailsvr_stream))
@@ -1299,7 +1595,7 @@
                                {
                                        // set the "mailsvr_stream" to blank so 
all will know the login failed
                                        $this->set_arg_value('mailsvr_stream', 
'');
-                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: begin_request: LEAVING with ERROR: failed to open 
mailsvr_stream : '.$mailsvr_stream.'<br>'); }
+                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): LEAVING with ERROR: 
failed to open mailsvr_stream : '.$mailsvr_stream.'<br>'); }
                                        // we return false, but SHOULD WE ERROR 
EXIT HERE?
                                        return False;
                                }
@@ -1312,47 +1608,48 @@
                                // ----  Get additional Data now that we are 
logged in to the mail server  ----
                                // namespace is often obtained by directly 
querying the mailsvr
                                $mailsvr_namespace = 
$this->get_arg_value('mailsvr_namespace');
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $mailsvr_namespace: 
'.serialize($mailsvr_namespace).'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $mailsvr_namespace: 
'.serialize($mailsvr_namespace).'<br>'); }
                                $mailsvr_delimiter = 
$this->get_arg_value('mailsvr_delimiter');
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: $mailsvr_delimiter: 
'.serialize($mailsvr_delimiter).'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): $mailsvr_delimiter: 
'.serialize($mailsvr_delimiter).'<br>'); }


                                // FIND FOLDER VALUE
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: <b> *** FIND FOLDER VALUE *** 
</b><br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): <b> *** FIND FOLDER 
VALUE *** </b><br>'); }
                                // get best available, most legit, folder value 
that we can find, and prep it in
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call: 
"get_best_folder_arg($args_array, $got_args, $acctnum(='.$acctnum.'))"<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call: 
"get_best_folder_arg($args_array, $got_args, $acctnum(='.$acctnum.'))"<br>'); }
                                $processed_folder_arg = 
$this->get_best_folder_arg($args_array, $got_args, $acctnum);
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: "get_best_folder_arg" returns 
$processed_folder_arg 
['.htmlspecialchars(serialize($processed_folder_arg)).']<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): "get_best_folder_arg" 
returns $processed_folder_arg 
['.htmlspecialchars(serialize($processed_folder_arg)).']<br>'); }

                                // ---- Switch To Desired Folder If Necessary  
----
                                if ($processed_folder_arg == 'INBOX')
                                {
                                        // NO need to switch to another folder
                                        // put this $processed_folder_arg in 
arg "folder", replacing any unprocessed value that may have been there
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: NO need to switch folders, about to 
issue: $this->set_arg_value("folder", '.$processed_folder_arg.', 
'.serialize($acctnum).')<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): NO need to switch 
folders, about to issue: $this->set_arg_value("folder", 
'.$processed_folder_arg.', '.serialize($acctnum).')<br>'); }
                                        $this->set_arg_value('folder', 
$processed_folder_arg, $acctnum);
                                }
                                else
                                {
                                        // switch to the desired folder now 
that we are sure we have it's official name
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: need to switch folders (reopen) from 
INBOX to $processed_folder_arg: '.$processed_folder_arg.'<br>'); }
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to issue: 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->reopen('.$mailsvr_stream.', 
'.$mailsvr_callstr.$processed_folder_arg,', )'.'<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): need to switch folders 
(reopen) from INBOX to $processed_folder_arg: '.$processed_folder_arg.'<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to issue: 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->reopen('.$mailsvr_stream.', 
'.$mailsvr_callstr.$processed_folder_arg,', )'.'<br>'); }
                                        //$did_reopen = 
$tmp_a['dcom']->reopen($mailsvr_stream, $mailsvr_callstr.$processed_folder_arg, 
'');
+                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: begin_request('.__LINE__.'): <font color="red">MAIL 
SERVER COMMAND</font>'.'<br>'); }
                                        $did_reopen = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->reopen($mailsvr_stream, 
$mailsvr_callstr.$processed_folder_arg, '');
-                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: reopen returns: 
'.serialize($did_reopen).'<br>'); }
+                                       if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): reopen returns: 
'.serialize($did_reopen).'<br>'); }
                                        // error check
                                        if ($did_reopen == False)
                                        {
-                                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: begin_request: LEAVING with re-open ERROR, closing 
stream, FAILED to reopen (change folders) $mailsvr_stream ['.$mailsvr_stream.'] 
INBOX to ['.$mailsvr_callstr.$processed_folder_arg.'<br>'); }
+                                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): LEAVING with re-open 
ERROR, closing stream, FAILED to reopen (change folders) $mailsvr_stream 
['.$mailsvr_stream.'] INBOX to 
['.$mailsvr_callstr.$processed_folder_arg.'<br>'); }
                                                // log out since we could not 
reopen, something must have gone wrong
                                                $this->end_request();
                                                return False;
                                        }
                                        else
                                        {
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: Successful switch folders (reopen) 
from (default initial folder) INBOX to ['.$processed_folder_arg.']<br>'); }
+                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): Successful switch 
folders (reopen) from (default initial folder) INBOX to 
['.$processed_folder_arg.']<br>'); }
                                                // put this 
$processed_folder_arg in arg "folder", since we were able to successfully 
switch folders
-                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: switched folders (via reopen), about 
to issue: $this->set_arg_value("folder", '.$processed_folder_arg.', 
$acctnum(='.$acctnum.'))<br>'); }
+                                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): switched folders (via 
reopen), about to issue: $this->set_arg_value("folder", 
'.$processed_folder_arg.', $acctnum(='.$acctnum.'))<br>'); }
                                                $this->set_arg_value('folder', 
$processed_folder_arg, $acctnum);
                                        }
                                }
@@ -1365,11 +1662,11 @@
                                        
.'&fldball[acctnum]='.$this->get_acctnum()
                                        .'&sort='.$this->get_arg_value('sort')
                                        
.'&order='.$this->get_arg_value('order');
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call 
$this->set_arg_value(index_refresh_uri, $this_index_refresh_uri, 
$acctnum(='.$acctnum.')); ; where $this_index_refresh_uri: 
'.htmlspecialchars($this_index_refresh_uri).'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call 
$this->set_arg_value(index_refresh_uri, $this_index_refresh_uri, 
$acctnum(='.$acctnum.')); ; where $this_index_refresh_uri: 
'.htmlspecialchars($this_index_refresh_uri).'<br>'); }
                                $this->set_arg_value('index_refresh_uri', 
$this_index_refresh_uri, $acctnum);

-                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg: begin_request: about to leave, direct access dump 
of $this->a  DUMP:', $this->a); }
-                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: begin_request: LEAVING, success'.'<br>'); }
+                               if ($this->debug_logins > 2) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to leave, direct 
access dump of $this->a  DUMP:', $this->a); }
+                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): LEAVING, 
success'.'<br>'); }
                                // returning this is vestigal, not really 
necessary, but do it anyway
                                // it's importance is that it returns something 
other then "False" on success
                                return $this->get_arg_value('mailsvr_stream', 
$acctnum);
@@ -1385,7 +1682,7 @@
                                        
.'&fldball[acctnum]='.$this->get_acctnum()
                                        .'&sort='.$this->get_arg_value('sort')
                                        
.'&order='.$this->get_arg_value('order');
-                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request: about to call 
$this->set_arg_value(index_refresh_uri, $this_index_refresh_uri, 
$acctnum(='.$acctnum.')); ; where $this_index_refresh_uri: 
'.htmlspecialchars($this_index_refresh_uri).'<br>'); }
+                               if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg.begin_request('.__LINE__.'): about to call 
$this->set_arg_value(index_refresh_uri, $this_index_refresh_uri, 
$acctnum(='.$acctnum.')); ; where $this_index_refresh_uri: 
'.htmlspecialchars($this_index_refresh_uri).'<br>'); }
                                $this->set_arg_value('index_refresh_uri', 
$this_index_refresh_uri, $acctnum);

                                //if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: begin_request ('.__LINE__.'): LEAVING, we were NOT 
allowed to, $args_array[do_login]: ['.serialize($args_array['do_login']).'] if 
TRUE, then we must return *something* so calling function does NOT think error, 
so return $args_array[do_login] <br>'); }
@@ -1460,7 +1757,8 @@
                                        $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $this_acctnum);
                                        if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: end_request: stream exists, for $this_acctnum 
['.$this_acctnum.'] , $mailsvr_stream : ['.$mailsvr_stream.'] ; logging 
out'.'<br>'); }
                                        // SLEEP seems to give the server time 
to send its OK response, used tcpdump to confirm this
-                                       sleep(1);
+                                       //sleep(1);
+                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: end_request('.__LINE__.'): <font color="red">MAIL 
SERVER COMMAND</font>'.'<br>'); }
                                        
$GLOBALS['phpgw_dcom_'.$this_acctnum]->dcom->close($mailsvr_stream);
                                        // sleep here does not have any effect
                                        //sleep(1);
@@ -1605,6 +1903,7 @@
                                // log in to INBOX because we know INBOX should 
exist on every mail server, "reopen" to desired folder (if different) later
                                //@set_time_limit(60);
                                if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder: about to call dcom->open: 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->open('.$mailsvr_callstr."INBOX".', 
'.$user.', '.$pass.', )'.'<br>'); }
+                               if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder('.__LINE__.'): <font 
color="red">MAIL SERVER COMMAND</font>'.'<br>'); }
                                $mailsvr_stream = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->open($mailsvr_callstr."INBOX", $user, 
$pass, '');
                                $pass = '';
                                //@set_time_limit(0);
@@ -1752,6 +2051,7 @@
                                {
                                        if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder('.__LINE__.'): need to 
switch folders (reopen) from $preped_current_folder_arg 
['.$preped_current_folder_arg.'] to $preped_folder: '.$preped_folder.'<br>'); }
                                        if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder('.__LINE__.'): about to 
issue: $GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->reopen('.$mailsvr_stream.', 
'.$mailsvr_callstr.$preped_folder,', )'.'<br>'); }
+                                       if ($this->debug_logins > 0) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder('.__LINE__.'): <font 
color="red">MAIL SERVER COMMAND</font>'.'<br>'); }
                                        $did_reopen = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->reopen($mailsvr_stream, 
$mailsvr_callstr.$preped_folder, '');
                                        if ($this->debug_logins > 1) { 
$this->dbug->out('mail_msg: ensure_stream_and_folder('.__LINE__.'): reopen 
returns: '.serialize($did_reopen).'<br>'); }
                                        if ($did_reopen == False)
@@ -2161,7 +2461,8 @@
                                $feed_folder = $this->get_arg_value('folder');
                        }
                        //echo 'prep_folder_out: param $feed_folder 
['.$feed_folder.'], :: ';
-                       $preped_folder = 
$GLOBALS['phpgw']->msg->ensure_one_urlencoding($feed_folder);
+                       $preped_folder = 
$this->ensure_one_urlencoding($feed_folder);
+                       $preped_folder = str_replace('&', '%26', 
$preped_folder);
                        //echo ' $preped_folder ['.$preped_folder.']<br>';
                        return $preped_folder;
                }
@@ -2785,9 +3086,38 @@
                }

                /*!
+               @function folder_list_change_callback
+               @abstract dcom class callback to alert when dcom class has made 
a change to the folder list
+               @param $acctnum  OPTIONAL
+               discussion CACHE NOTE: this item is saved in the appsession 
cache, the folder_list, so altering
+               that list requires wiping that saved info because it has become 
stale.
+               @author Angles
+               */
+               function folder_list_change_callback($acctnum='')
+               {
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg: folder_list_change_callback('.__LINE__.'): 
ENTERING, param $acctnum ['.$acctnum.']<br>'); }
+                       // what acctnum is operative here, we can only get a 
folder list for one account at a time (obviously)
+                       if ((!isset($acctnum))
+                       || ((string)$acctnum == ''))
+                       {
+                               $acctnum = $this->get_acctnum();
+                       }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg: folder_list_change_callback('.__LINE__.'): willo 
use $acctnum ['.$acctnum.']<br>'); }
+                       // class dcom recorded a change in the folder list
+                       // supposed to happen when create or delete or rename 
mailbox is called
+                       // dcom class will callback to this function to handle 
cleanup of stale folder_list data
+                       // expire cached data
+                       if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: folder_list_change_callback('.__LINE__.'): calling 
$this->expire_session_cache_item(folder_list, '.$acctnum.') <br>'); }
+                       $sucess = 
$this->expire_session_cache_item('folder_list', $acctnum);
+
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg: folder_list_change_callback('.__LINE__.'): LEAVING, 
returning $sucess ['.$sucess.']<br>'); }
+                       return $sucess;
+               }
+
+               /*!
                @function get_folder_list
                @abstract  list of folders in a numbered array, each element 
has 2 properties, "folder_long" and "folder_short"
-               @param $mailsvr_stream   DEPRECIATED - do not use
+               @param $acctnum (int) OPTIONAL
                @param $force_refresh   boolean, will cause any cached folder 
data to expire, and "fresh" data is retrieved from the mailserver
                @return   array   numbered, with each numbered element having 
array keys  "folder_long" and "folder_short"
                @discussion  returns a numbered array, each element has 2 
properties, "folder_long" and "folder_short"
@@ -2804,13 +3134,13 @@
                */
                function get_folder_list($acctnum='', $force_refresh=False)
                {
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg: get_folder_list: ENTERING<br>'); }
                        // what acctnum is operative here, we can only get a 
folder list for one account at a time (obviously)
                        if ((!isset($acctnum))
                        || ((string)$acctnum == ''))
                        {
                                $acctnum = $this->get_acctnum();
                        }
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg: get_folder_list: ENTERING<br>'); }
                        if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: for the rest of this function we 
will use $acctnum: ['.$acctnum.'] <br>'); }
                        // hardcore debug
                        if (stristr($this->skip_args_special_handlers, 
'get_folder_list'))
@@ -2828,6 +3158,7 @@

                        // check if class dcom reports that the folder list has 
changed
                        // is this accounts dcom object has not been created 
yet, then obviously we did not just change its folder list
+                       // NOTE THIS IS OBSOLETED - THE DCOM CLASS NOW USES 
CALLBACK FUNCTION "folder_list_change_callback"
                        if ((is_object($GLOBALS['phpgw_dcom_'.$acctnum]->dcom))
                        && 
($GLOBALS['phpgw_dcom_'.$acctnum]->dcom->folder_list_changed == True))
                        {
@@ -2896,21 +3227,31 @@
                                {
                                        //if 
($this->debug_args_special_handlers > 1) { echo 'mail_msg: get_folder_list: 
using *Prefs DB* cached folder list data<br>';}
                                        if ($this->debug_args_special_handlers 
> 1) { $this->dbug->out('mail_msg: get_folder_list: using appsession cached 
folder list data<br>'); }
-                                       // cached folder list does NOT contain 
"folder_short" data
-                                       // that cuts cached data in 1/2, no 
need to cache something this easy to deduce
-                                       // therefor... add FOLDER SHORT element 
to cached_data array structure
-                                       if ($this->debug_args_special_handlers 
> 1) { $this->dbug->out('mail_msg: get_folder_list: (L1) adding [folder_short] 
element to $cached_data array<br>'); }
-                                       for ($i=0; $i<count($cached_data);$i++)
-                                       {
-                                               $my_folder_long = 
$cached_data[$i]['folder_long'];
-                                               $my_folder_acctnum = 
$cached_data[$i]['acctnum'];
-                                               $my_folder_short = 
$this->get_folder_short($my_folder_long, $my_folder_acctnum);
-                                               if 
($this->debug_args_special_handlers > 1) { $this->dbug->out('* * mail_msg: 
get_folder_list: add folder_short loop (L1) ['.$i.']: $my_folder_long 
['.$my_folder_long.'] ; $my_folder_acctnum ['.$my_folder_acctnum.'] ; 
$my_folder_short ['.$my_folder_short.']<br>'); }
-                                               
$cached_data[$i]['folder_short'] = $my_folder_short;
-                                               
//$cached_data[$i]['folder_short'] = 
$this->get_folder_short($cached_data[$i]['folder_long']);
-                                               if 
($this->debug_args_special_handlers > 2) { $this->dbug->out(' * * 
$cached_data['.$i.'][folder_long]='.htmlspecialchars($cached_data[$i]['folder_long']).'
 ; 
$cached_data['.$i.'][folder_short]='.htmlspecialchars($cached_data[$i]['folder_short']).'<br>');
 }
+                                       if 
(!isset($cached_data[0]['folder_short']))
+                                       {
+                                               // OLD cached folder list does 
NOT contain "folder_short" data
+                                               // that cuts cached data in 
1/2, no need to cache something this easy to deduce
+                                               // therefor... add FOLDER SHORT 
element to cached_data array structure
+                                               if 
($this->debug_args_special_handlers > 1) { $this->dbug->out('mail_msg: 
get_folder_list: (L1) adding [folder_short] element to $cached_data 
array<br>'); }
+                                               for ($i=0; 
$i<count($cached_data);$i++)
+                                               {
+                                                       $my_folder_long = 
$cached_data[$i]['folder_long'];
+                                                       $my_folder_acctnum = 
$cached_data[$i]['acctnum'];
+                                                       $my_folder_short = 
$this->get_folder_short($my_folder_long, $my_folder_acctnum);
+                                                       if 
($this->debug_args_special_handlers > 1) { $this->dbug->out('* * mail_msg: 
get_folder_list: add folder_short loop (L1) ['.$i.']: $my_folder_long 
['.$my_folder_long.'] ; $my_folder_acctnum ['.$my_folder_acctnum.'] ; 
$my_folder_short ['.$my_folder_short.']<br>'); }
+                                                       
$cached_data[$i]['folder_short'] = $my_folder_short;
+                                                       
//$cached_data[$i]['folder_short'] = 
$this->get_folder_short($cached_data[$i]['folder_long']);
+                                                       if 
($this->debug_args_special_handlers > 2) { $this->dbug->out(' * * 
$cached_data['.$i.'][folder_long]='.htmlspecialchars($cached_data[$i]['folder_long']).'
 ; 
$cached_data['.$i.'][folder_short]='.htmlspecialchars($cached_data[$i]['folder_short']).'<br>');
 }
+                                               }
+                                               if 
($this->debug_args_special_handlers > 2) { $this->dbug->out('mail_msg: 
get_folder_list: $cached_data *after* adding "folder_short" data DUMP:', 
$cached_data); }
+                                               // -----------
+                                               // SAVE DATA TO APPSESSION DB 
CACHE (WITH the [folder_short] data)
+                                               // -----------
+                                               // save "folder_list" (WITH 
ADDED  folder short data) to appsession data store
+                                               // new style folder_list is 
stored FULL, has all elements
+                                               if 
($this->debug_args_special_handlers > 1) { $this->dbug->out('mail_msg: 
get_folder_list: added folder short, now resave in DB as new style, complete 
folder list, set appsession cache $this->save_session_cache_item(folder_list, 
$cached_data, '.$acctnum.']) <br>'); }
+                                               
$this->save_session_cache_item('folder_list', $cached_data, $acctnum);
                                        }
-                                       if ($this->debug_args_special_handlers 
> 2) { $this->dbug->out('mail_msg: get_folder_list: $cached_data *after* adding 
"folder_short" data DUMP:', $cached_data); }
                                        // cache the result in "Level 1 cache" 
class object var
                                        if ($this->debug_args_special_handlers 
> 1) { $this->dbug->out('mail_msg: get_folder_list: put folder_list into Level 
1 class var "cache" $this->set_arg_value(folder_list, $cached_data, 
'.$acctnum.');<br>'); }
                                        $this->set_arg_value('folder_list', 
$cached_data, $acctnum);
@@ -3074,15 +3415,17 @@
                                }
                        }
                        if ($this->debug_args_special_handlers > 2) { 
$this->dbug->out('mail_msg: get_folder_list: my_folder_list with only 
"folder_long" DUMP:', $my_folder_list); }
-                       // -----------
-                       // SAVE DATA TO APPSESSION DB CACHE (without the 
[folder_short] data)
-                       // -----------
-                       // save "folder_list" (without folder short data) to 
appsession data store
-                       if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: set appsession cache 
$this->save_session_cache_item(folder_list, $my_folder_list, '.$acctnum.']) 
<br>'); }
-                       $this->save_session_cache_item('folder_list', 
$my_folder_list, $acctnum);
+                       // NEW just save the complete list, leaving out the 
folder short does not reduce size my a material amount
+                       //// -----------
+                       //// SAVE DATA TO APPSESSION DB CACHE (without the 
[folder_short] data)
+                       //// -----------
+                       //// save "folder_list" (without folder short data) to 
appsession data store
+                       //if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: set appsession cache 
$this->save_session_cache_item(folder_list, $my_folder_list, '.$acctnum.']) 
<br>'); }
+                       //$this->save_session_cache_item('folder_list', 
$my_folder_list, $acctnum);

                        // add FOLDER SHORT element to folder_list array 
structure
                        // that cuts cached data in 1/2, no need to cache 
something this easy to deduce
+                       // NEW: forget about it, just add folder short THEN 
SAVE it, additional data is not that much more
                        for ($i=0; $i<count($my_folder_list);$i++)
                        {
                                $my_folder_long = 
$my_folder_list[$i]['folder_long'];
@@ -3091,6 +3434,15 @@
                                if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: add folder_short loop['.$i.']: 
$my_folder_long ['.$my_folder_long.'] ; $my_folder_acctnum 
['.$my_folder_acctnum.'] ; $my_folder_short ['.$my_folder_short.']<br>'); }
                                $my_folder_list[$i]['folder_short'] = 
$my_folder_short;
                        }
+
+                       // -----------
+                       // SAVE DATA TO APPSESSION DB CACHE (WITH the 
[folder_short] data)
+                       // -----------
+                       // save "folder_list" (WITH ADDED  folder short data) 
to appsession data store
+                       // new style folder_list is stored FULL, has all 
elements
+                       if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: set appsession cache 
$this->save_session_cache_item(folder_list, $my_folder_list, '.$acctnum.']) 
<br>'); }
+                       $this->save_session_cache_item('folder_list', 
$my_folder_list, $acctnum);
+
                        // cache the result to "level 1 cache" class arg holder 
var
                        if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg: get_folder_list: set Level 1 class var "cache" 
$this->set_arg_value(folder_list, $my_folder_list, '.$acctnum.') <br>'); }
                        $this->set_arg_value('folder_list', $my_folder_list, 
$acctnum);
@@ -3256,7 +3608,7 @@
                        }

                        // DECISION: no more than 4 DIRECTORIES DEEP of 
recursion
-                       $num_slashes = 
$GLOBALS['phpgw']->msg->substr_count_ex($folder_long, "/");
+                       $num_slashes = $this->substr_count_ex($folder_long, 
"/");
                        if (($home_type_namespace)
                        && ($num_slashes >= 4))
                        {
@@ -4606,9 +4958,24 @@
                        }
                }

-               // my implementation of a PHP4 only function
                /*!
                @function body_hard_wrap
+               @abstract Wrap test calls either the php4 wordwrap OR 
optionally sucky native code
+               @author Angles
+               @discussion when php3 compat was necessary I made a sucky hand 
made body wrap,
+               but now php4 is expected so this function should call the php4 
function wordwrap instead.
+               */
+               function body_hard_wrap($in='', $size=78)
+               {
+                       // use sucky hand made function
+                       //return $this->body_hard_wrap_ex($in, $size);
+                       // use the php4 builting function
+                       return wordwrap($in, $size, "\r\n");
+
+               }
+               // my implementation of a PHP4 only function
+               /*!
+               @function body_hard_wrap_ex
                @abstract my implementation of a PHP4 only function which keeps 
lines of text under a certain length.
                @author Angles
                @discussion Keeps lines of text under a certain length, adding 
linebreaks to break up lines if
@@ -4622,7 +4989,7 @@
                php4 function which does the same, but at the time of this 
functions origination it
                was necessary to implement all non php3 functions with a 
compatibility function.
                */
-               function body_hard_wrap($in, $size=80)
+               function body_hard_wrap_ex($in, $size=80)
                {
                        // this function formats lines according to the defined
                        // linesize. Linebrakes (\n\n) are added when 
neccessary,
@@ -4674,6 +5041,56 @@
                        return $out;
                }

+               /*!
+               @function recall_desired_action
+               @abstract used to preserve if this originated as a reply, 
replyall, forward, or new mail
+               @author Angles
+               @discussion Used in both bocompose and bosend so we put it here 
for general access.
+               Line lengths will differ for new mail and forwarded orig body, 
vs. reply mail that has longer
+               lines. So this preserves this info for later use. Particularly 
we like to preserve this thru the spelling pass also.
+               We look for GPC args "action" or "orig_action", as keys, and 
their
+               values are limited to "reply", "replyall", "forward", and 
"new", with "new" being deduced on the
+               initial compose page call and put into "orig_action" for later 
use, while the others possible "action"
+               values simply get stored in "orig_action" no deduction is 
required, it is specified.
+               If new future actions are added, adjust this function 
accordingly.
+               @access public
+               */
+               function recall_desired_action()
+               {
+                       // what action are we dealing with here, reply(all), 
forward, or newmail
+                       // we care because new and forward get different line 
length then reply mail that has ">"
+                       $orig_action = 'unknown';
+                       if (($this->get_isset_arg('action'))
+                       && (
+                               ($this->get_arg_value('action') == 'forward')
+                               || ($this->get_arg_value('action') == 'reply')
+                               || ($this->get_arg_value('action') == 
'replyall')
+                               )
+                       )
+                       {
+                               $orig_action = $this->get_arg_value('action');
+                       }
+                       elseif (($this->get_isset_arg('orig_action'))
+                       && (
+                               ($this->get_arg_value('orig_action') == 
'forward')
+                               || ($this->get_arg_value('orig_action') == 
'reply')
+                               || ($this->get_arg_value('orig_action') == 
'replyall')
+                               || ($this->get_arg_value('orig_action') == 
'new')
+                               )
+                       )
+                       {
+                               $orig_action = 
$this->get_arg_value('orig_action');
+                       }
+                       else
+                       {
+                               // if not reply, replyall, nor forward 
"action", then we have NEW message
+                               // if this is set now then the above 
"orig_action" should preserve it
+                               $orig_action = 'new';
+                       }
+                       return $orig_action;
+               }
+
+
                
/**************************************************************************\
                *
                * Functions PHP Should Have OR Functions From PHP4+ Backported 
to PHP3 *
@@ -4808,7 +5225,37 @@
                                return True;
                        }
                }
-
+
+               /*!
+               @function is_serialized_smarter
+               @abstract find out if a string is already serialized, BUT NOT 
FOOLED BY SLASH problems on unserizalize.
+               @param $string_data SHOULD be a string
+               */
+               function is_serialized_smarter($string_data)
+               {
+                       if ((is_string($string_data))
+                       && (unserialize($string_data) == False))
+                       {
+                               // when you unserialize a normal 
(not-serialized) string, you get False
+                               // HOWEVER slashes may b0rk unserialize, do not 
be fooled, it is still serialized
+                               // so use a second test here, piss poor test, 
but it helps
+                               if (stristr($string_data, ':"stdClass":'))
+                               {
+                                       // unserialize failed but the source 
str appears to look like a serialized thing
+                                       return True;
+                               }
+                               else
+                               {
+                                       // second test still says this is not  
serialized str
+                                       return False;
+                               }
+                       }
+                       else
+                       {
+                               return True;
+                       }
+               }
+
                // PHP3 SAFE Version of "substr_count"
                /*!
                @function substr_count_ex
@@ -5047,6 +5494,9 @@
                Does a loop thru existing accounts. NOTE THIS REALLY WIPES DATA 
completely, it is not
                very smart, it wipes cached data that may still be useful, so 
this really does clear the cache.
                UNDER DEVELOPMEMT
+               UPDATE we use folder as a key in msgball_list but batch expire 
still works because
+               it wipes data based on a key prior to folder name, same as with 
other data that has a
+               folder name in its data key.
                */
                function batch_expire_cached_items($called_by='not_specified', 
$only_msgball_list=False)
                {
@@ -5123,7 +5573,7 @@
                                // we only care about doing this is caching is 
enabled
                                // this should already be cached, if not, it 
will be after this call
                                // this works OK for both php4 sessions AND 
sessions_db
-                               $msg_headers = 
$GLOBALS['phpgw']->msg->phpgw_header($msgball);
+                               $msg_headers = $this->phpgw_header($msgball);
                                if ($this->debug_events > 2) { 
$this->dbug->out('email_msg_base: event_msg_seen('.__LINE__.'): SEEN-UNSEEN 
"phpgw_header" examination for $msg_headers DUMP:', $msg_headers); }
                                //if ($this->debug_events > 2) { 
$this->dbug->out('email_msg_base: event_msg_seen('.__LINE__.'): (extreme mode) 
SEEN-UNSEEN "phpgw_header" examination for $msg_headers <br> * 
'.serialize($msg_headers).'<br>'); }
                                $did_alter = False;
@@ -5286,8 +5736,10 @@
                        // so we have data in the cache?
                        $data_name = 'msgball_list';
                        // currently we DO NOT use the $extra_keys param for 
msgball_list data
+                       // UPDATE YES NOW WE USE FOLDER NAME IN THE DATA KEYS 
FOR MSGBALL_LIST
+                       $ex_folder = $urlencoded_folder;
                        // get session data
-                       if (($this->debug_events > 1) || 
($this->debug_session_caching > 1)) { echo 'mail_msg: 
event_msg_move_or_delete('.__LINE__.'): DIRECT CALL to get appsession data for 
$location ['.$location.'], $app ['.$app.']<br>'; }
+                       //if (($this->debug_events > 1) || 
($this->debug_session_caching > 1)) { echo 'mail_msg: 
event_msg_move_or_delete('.__LINE__.'): DIRECT CALL to get appsession data for 
$location ['.$location.'], $app ['.$app.']<br>'; }

                        //$cached_msgball_data = 
$GLOBALS['phpgw']->session->appsession($location,$app);
                        //$cached_msgball_data = 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name];
@@ -5306,28 +5758,34 @@
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] 
== 'db')
                        || ($this->use_private_table == True))
                        {
-                               if 
((isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'])
 == False)
-                               || 
(!$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']))
+                               if 
((isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder])
 == False)
+                               || 
(!$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder]))
                                {
-                                       $my_location = 
(string)$acctnum.';msgball_list';
-                                       if ($this->debug_events > 1) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) sessions_type is 
['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this 
additional step to read data from phpgw_app_sessions table, $my_location 
['.$my_location.']<br>'); }
+                                       //$my_location = 
(string)$acctnum.';msgball_list';
+                                       // NOW WE USE FOLDER TOO as a data key 
for msgball_list
+                                       $my_location = 
(string)$acctnum.';msgball_list;'.$ex_folder;
+                                       if (($this->debug_events > 1) || 
($this->debug_session_caching > 1)) { echo 'mail_msg: 
event_msg_move_or_delete('.__LINE__.'): DIRECT CALL to get appsession data for 
$location ['.$location.'], $app ['.$app.']<br>'; }
+                                       if ($this->debug_events > 1) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) sessions_type is 
['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this 
additional step to read data from a database table, $my_location 
['.$my_location.']<br>'); }
                                        if ($this->use_private_table == True)
                                        {
-                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']
-                                                       = 
$this->so->so_get_data($my_location);
+                                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder]
+                                               //      = 
$this->so->so_get_data($my_location);
+                                               // TRY USING COMPRESSION for 
msgball_list
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder]
+                                                       = 
$this->so->so_get_data($my_location, True);
                                        }
                                        else
                                        {
-                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder]
                                                        = 
$GLOBALS['phpgw']->session->appsession($my_location, 'email');
                                        }
-                                       //if ($this->debug_events > 2) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) [email][dat]['.$acctnum.'][msgball_list] DUMP:<pre>'; 
print_r($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']);
 echo '</pre>'); }
+                                       //if ($this->debug_events > 2) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) [email][dat]['.$acctnum.'][msgball_list] DUMP:<pre>'; 
print_r($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][ex_folder]);
 echo '</pre>'); }
                                }
                        }

-                       $cached_msgball_data =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'];
+                       $cached_msgball_data =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder];

-                       if (($this->debug_events > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
event_msg_move_or_delete('.__LINE__.'): restored $cached_msgball_data DUMP:', 
$cached_msgball_data); }
+                       if (($this->debug_events > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
event_msg_move_or_delete('.__LINE__.'): for $my_location ['.$my_location.'], 
restored $cached_msgball_data DUMP:', $cached_msgball_data); }

                        if ((!$cached_msgball_data)
                        && ($this->session_cache_extreme == False))
@@ -5350,7 +5808,7 @@
                                // expire entire msgball_list and the 
folder_status_info
                                if ($this->debug_events > 1) { 
$this->dbug->out('mail_msg: event_msg_move_or_delete: ('.__LINE__.') 
(non-extreme mode) calling $this->expire_session_cache_item("msgball_list", 
'.$msgball['acctnum'].')<br>'); }
                                // FUTURE: if each account ever saves 
msgball_list for individual folders instead of just one folder per account, 
then add extra_keys to this command
-                               
$this->expire_session_cache_item('msgball_list', $msgball['acctnum']);
+                               
$this->expire_session_cache_item('msgball_list', $msgball['acctnum'], 
$ex_folder);

                                // ANYTIME a message is moved out of a folder, 
we need to remove any cached "msg_structure" and "phpgw_header" data
                                // damn why are we doing this in non-extreme 
mode?
@@ -5437,8 +5895,8 @@
                                        if (($this->debug_events > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
event_msg_move_or_delete('.__LINE__.'): (extreme mode) (step 1) array_splice of 
$cached_msgball_data[msgball_list] results in this $cached_msgball_data DUMP:', 
$cached_msgball_data); }

                                        // save altered data back into the cache
-                                       // NOT needed if using a REFERENCE
-                                       if (($this->debug_session_caching > 1) 
|| ($this->debug_events > 1)) { $this->dbug->out('mail_msg: 
event_msg_move_or_delete: ('.__LINE__.') saving altered msgball_list directly 
to appsession, location: ['.$location.'] $app ['.$app.']<br>'); }
+                                       // NOT needed if using a REFERENCE and 
only using regular appsession (i.e. NOT the anglemail table)
+                                       //if (($this->debug_session_caching > 
1) || ($this->debug_events > 1)) { $this->dbug->out('mail_msg: 
event_msg_move_or_delete: ('.__LINE__.') saving altered msgball_list directly 
to appsession, location: ['.$location.'] $app ['.$app.']<br>'); }
                                        // COMMENT IF USING REF, UNCOMMENT IF 
NOT USING REFERENCES
                                        
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']
 = $cached_msgball_data;

@@ -5446,15 +5904,23 @@
                                        if 
(($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                                        || ($this->use_private_table == True))
                                        {
-                                               $my_location = 
(string)$acctnum.';msgball_list';
-                                               if ($this->debug_events > 1) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) sessions_type is 
['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this 
additional step to save data to phpgw_app_sessions table, $my_location 
['.$my_location.']<br>'); }
+                                               //$my_location = 
(string)$acctnum.';msgball_list';
+                                               // NOW WE USE FOLDER TOO as a 
data key for msgball_list
+                                               $my_location = 
(string)$acctnum.';msgball_list;'.$ex_folder;
+                                               if ($this->debug_events > 1) { 
$this->dbug->out('email_msg_base: event_msg_move_or_delete('.__LINE__.'): 
(extreme mode) sessions_type is 
['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this 
additional step to save data to a database table, $my_location 
['.$my_location.'], if using anglemail table this step is always 
necessary<br>'); }
                                                if ($this->use_private_table == 
True)
                                                {
-                                                       
$this->so->so_set_data($my_location, 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']);
+                                                       
//$this->so->so_set_data($my_location, 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']);
+                                                       // TRY USING 
COMPRESSION for msgball_list (only available for anglemail table)
+                                                       $this->so->so_set_data(
+                                                               $my_location,
+                                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder],
+                                                               True
+                                                       );
                                                }
                                                else
                                                {
-                                                       
$GLOBALS['phpgw']->session->appsession($my_location, 'email', 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list']);
+                                                       
$GLOBALS['phpgw']->session->appsession($my_location, 'email', 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum]['msgball_list'][$ex_folder]);
                                                }
                                        }
                                        $did_alter = True;
@@ -5672,6 +6138,23 @@
                }

                /*!
+               @function href_maketag_class
+               @abstract will generate a typical A HREF html item with 
optional CLASS value for css specs
+               */
+               function href_maketag_class($href_link='',$href_text='default 
text', $css_class_name='')
+               {
+                       if ($css_class_name != '')
+                       {
+                               $class_prop=' class="'.$css_class_name.'" ';
+                       }
+                       else
+                       {
+                               $class_prop='';
+                       }
+                       return '<a '.$class_prop.' href="' .$href_link .'">' 
.$href_text .'</a>' ."\n";
+               }
+
+               /*!
                @function img_maketag
                @abstract will generate a typical IMG html item
                */
@@ -5686,10 +6169,12 @@
                        if ($alt != '')
                        {
                                $alt_tag = ' alt="['.$alt.']"';
+                               $title_tag = ' title="'.$alt.'"';
                        }
                        else
                        {
                                $alt_tag = ' alt="['.$alt_default_txt.']"';
+                               $title_tag = '';
                        }
                        if ($height != '')
                        {
@@ -5715,7 +6200,7 @@
                        {
                                $border_tag = '';
                        }
-                       $image_html = '<img src="'.$location.'"' .$height_tag 
.$width_tag .$border_tag .$alt_tag .'>';
+                       $image_html = '<img src="'.$location.'"' .$height_tag 
.$width_tag .$border_tag .$title_tag .$alt_tag .'>';
                        return $image_html;
                }


====================================================

====================================================

====================================================
Index: email/inc/class.mail_dcom_base_sock.inc.php
diff -u email/inc/class.mail_dcom_base_sock.inc.php:1.24 
email/inc/class.mail_dcom_base_sock.inc.php:1.25
--- email/inc/class.mail_dcom_base_sock.inc.php:1.24    Fri Mar 14 04:00:48 2003
+++ email/inc/class.mail_dcom_base_sock.inc.php Thu Dec 30 23:13:50 2004
@@ -318,6 +318,8 @@
        */
        class mail_dcom_base extends network
        {
+               // OBSOLETED "folder_list_changed" by the newer function 
"folder_list_did_change"
+               var $folder_list_changed=False;
                // Cached Data
                // raw message data from the server, some raw data, some 
exploded into a string list
                var $header_glob = '';
@@ -598,6 +600,29 @@
                }

                /*!
+               @function folder_list_did_change
+               @abstract if folder is created, deleted, or renamed this this 
function handles cleanup of stale data in main msg object.
+               @discussion THIS IS A COPY OF THE FUNCTION IN THE NON-SOCK 
CLASS, THEY SHOULD BE THE SAME
+               @author Angles
+               */
+               function folder_list_did_change()
+               {
+                       // NOTE THIS FLAG "folder_list_changed" IS NOW 
OBSOLETED SINCE THIS
+                       // CALLBACK FUNCTION IS PROVEN TO WORK
+                       $this->folder_list_changed = True;
+                       if (is_object($GLOBALS['phpgw']->msg))
+                       {
+                               // call that classes "callback" function 
designed to handle cleaning stale folder_list there
+                               $sucess = 
$GLOBALS['phpgw']->msg->folder_list_change_callback();
+                               // if it was handled correctly, then reset the 
"folder_list_changed" because we did our job
+                               if ($sucess)
+                               {
+                                       $this->folder_list_changed = False;
+                               }
+                       }
+               }
+
+               /*!
                @function create_header
                @abstract ?
                @author unknown, maybe Skeeter ? Rehberg ? Engo ?

====================================================
Index: email/inc/class.mail_dcom_imap.inc.php
diff -u email/inc/class.mail_dcom_imap.inc.php:1.21 
email/inc/class.mail_dcom_imap.inc.php:1.22
--- email/inc/class.mail_dcom_imap.inc.php:1.21 Fri Mar 14 04:00:51 2003
+++ email/inc/class.mail_dcom_imap.inc.php      Thu Dec 30 23:13:50 2004
@@ -44,20 +44,20 @@
                function createmailbox($stream,$mailbox)
                {
                        $mailbox = $this->utf7_encode($mailbox);
-                       $this->folder_list_changed = True;
+                       $this->folder_list_did_change();
                        return imap_createmailbox($stream,$mailbox);
                }

                function deletemailbox($stream,$mailbox)
                {
-                       $this->folder_list_changed = True;
+                       $this->folder_list_did_change();
                        $mailbox = $this->utf7_encode($mailbox);
                        return imap_deletemailbox($stream,$mailbox);
                }

                function renamemailbox($stream,$mailbox_old,$mailbox_new)
                {
-                       $this->folder_list_changed = True;
+                       $this->folder_list_did_change();
                        $mailbox_old = $this->utf7_encode($mailbox_old);
                        $mailbox_new = $this->utf7_encode($mailbox_new);
                        return 
imap_renamemailbox($stream,$mailbox_old,$mailbox_new);

====================================================
Index: email/inc/class.mail_dcom_imap_sock.inc.php
diff -u email/inc/class.mail_dcom_imap_sock.inc.php:1.15 
email/inc/class.mail_dcom_imap_sock.inc.php:1.16
--- email/inc/class.mail_dcom_imap_sock.inc.php:1.15    Fri Mar 14 04:00:52 2003
+++ email/inc/class.mail_dcom_imap_sock.inc.php Thu Dec 30 23:13:50 2004
@@ -36,7 +36,20 @@
        may be just one line, skeeter is listed as an author for that function.
        */
        class mail_dcom extends mail_dcom_base
-       {
+       {
+
+               /**
+               * This stops users from using email if they do not have 
php-imap enabled
+               *
+               address@hidden skwashd
+               */
+               function mail_dcom()
+               {
+                       echo "<br>\n" . lang('php-imap support not installed - 
exiting') . "<br>\n";
+                       echo lang('contact your system administrator');
+                       exit;
+               }
+
                
/**************************************************************************\
                *       data analysis specific to IMAP data communications
                
\**************************************************************************/
@@ -274,6 +287,8 @@
                {
                        // not yet implemented
                        if ($this->debug_dcom >= 1) { echo 'imap: call to 
unimplemented socket function: createmailbox<br>'; }
+                       // eventually this will use this function to call for 
expiration of stale cached data, if any
+                       //$this->folder_list_did_change();
                        return true;
                }
                /*!
@@ -284,8 +299,23 @@
                {
                        // not yet implemented
                        if ($this->debug_dcom >= 1) { echo 'imap: call to 
unimplemented socket function: deletemailbox<br>'; }
+                       // eventually this will use this function to call for 
expiration of stale cached data, if any
+                       //$this->folder_list_did_change();
+                       return true;
+               }
+               /*!
+               @function renamemailbox
+               @abstract not yet implemented in IMAP sockets module
+               */
+               function renamemailbox($stream,$mailbox_old,$mailbox_new)
+               {
+                       // not yet implemented
+                       if ($this->debug_dcom >= 1) { echo 'imap: call to 
unimplemented socket function: renamemailbox<br>'; }
+                       // eventually this will use this function to call for 
expiration of stale cached data, if any
+                       //$this->folder_list_did_change();
                        return true;
                }
+
                /*!
                @function expunge
                @abstract not yet implemented in IMAP sockets module

====================================================
Index: email/inc/class.mail_msg_display.inc.php
diff -u email/inc/class.mail_msg_display.inc.php:1.41 
email/inc/class.mail_msg_display.inc.php:1.42
--- email/inc/class.mail_msg_display.inc.php:1.41       Sun May 25 21:38:27 2003
+++ email/inc/class.mail_msg_display.inc.php    Thu Dec 30 23:13:50 2004
@@ -24,7 +24,7 @@
        
\**************************************************************************/

        /* $Id$ */
-
+
        // include this last, it extends mail_msg_wrappers which extends 
mail_msg_base
        // so (1) include mail_msg_base, (2) incluse mail_msg_wrappers 
extending mail_msg_base
        // then (3) include mail_msg which extends mail_msg_wrappers and, by 
inheritance, mail_msg_base
@@ -32,21 +32,36 @@
 {

        /*!
+       @function mail_msg
+       @abstract Constructor
+       @discussion normally this would call $this->initialize_mail_msg which 
is a function in the base class,
+       HOWEVER I had to stop the auto constructor runthrough because 
preferences class API keeps making
+       copies of this object thus calling the constructor unnecessarily for 
what the pref API needs, which is
+       only a few functions in this object, SO NOW this class has NO real auto 
called constructor,
+       instead the initialization function needs to be explicitly called, 
which it is in the bootstrap class.
+       */
+       function mail_msg()
+       {
+               //$this->initialize_mail_msg();
+               return;
+       }
+
+       /*!
        @function get_common_langs
-       @abstract Certain strings commonly used with folder names have langs 
available here. Example lang for INBOX.
-       @param (string) OPTIONAL if no param is given, an array of available 
langs is returned,
-       or pass a param like "lang_inbox" and if we have the lang, we return 
the langed string, if your param is
-       not in the langs handled here, an error string is returned.
-       @result (string or array) no param returns an associative array in key, 
value style, a param returns a string
-       of the lang you requested or an error string if we have no lang for the 
param.
-       @discussion Certain strings are used so often in an email app that we 
should put them here
-       to make translations easier by centralizing some common lang calls. 
This function concentrates
-       on langs associated with folder names, such as the lang for "INBOX", or 
for "Sent", or for "Folder".
-       On first call this finction fills an $this->common_langs array, and 
only filles it with a small
-       group of the selected langs handled in this function. If no param 
provided this returns the whole array of
-       langs handled here. Or pass a string param and this return its lang if 
it is handled here, otherwise
-       an error string is returned. Most langes are not needed in the core 
object, so they are not provided in this function.
-       Check this function to see what langs are contained here.
+       @abstract Certain strings commonly used with folder names have langs 
available here. Example lang for INBOX.
+       @param (string) OPTIONAL if no param is given, an array of available 
langs is returned,
+       or pass a param like "lang_inbox" and if we have the lang, we return 
the langed string, if your param is
+       not in the langs handled here, an error string is returned.
+       @result (string or array) no param returns an associative array in key, 
value style, a param returns a string
+       of the lang you requested or an error string if we have no lang for the 
param.
+       @discussion Certain strings are used so often in an email app that we 
should put them here
+       to make translations easier by centralizing some common lang calls. 
This function concentrates
+       on langs associated with folder names, such as the lang for "INBOX", or 
for "Sent", or for "Folder".
+       On first call this finction fills an $this->common_langs array, and 
only filles it with a small
+       group of the selected langs handled in this function. If no param 
provided this returns the whole array of
+       langs handled here. Or pass a string param and this return its lang if 
it is handled here, otherwise
+       an error string is returned. Most langes are not needed in the core 
object, so they are not provided in this function.
+       Check this function to see what langs are contained here.
        @author Angles
        */
        function get_common_langs($this_word='##NOTHING##')
@@ -89,28 +104,28 @@

        /*!
        @function common_folder_is
-       @abstract Quick, limited match for folder name matching certain common 
IMAP folders, such as Sent, INBOX, or Trash.
-       @param $query_fldball (array of type fldball) A fldball with the name 
of folder you are wondering about.
-       @param $match_fld_name (known string) can be INBOX, Sent, or Trash.
-       @result Boolean True if param $query_fld_name is a match to 
$match_fld_name, False otherwise.
-       @discussion Certain folder may exist on any IMAP server, such as Sent, 
INBOX, and Trash.
-       This function is limited to these common folder names only, it is not a 
generic lookup function.
-       This is a quick way to check if the given folder is in fact one of 
these common IMAP folders,
-       because these folders often require different handling for their 
message list display. For example the
-       Sent folder displays who a message is TO, not who the message is FROM, 
as with all other folders.
-       Also, names such as Sent and Trash depend on user preference values 
that are not required to be in
-       known "folder long" form, so the string to match to also requires 
special handling to eventually
-       compare correctly. This function processes each param for accurate 
matching.
+       @abstract Quick, limited match for folder name matching certain common 
IMAP folders, such as Sent, INBOX, or Trash.
+       @param $query_fldball (array of type fldball) A fldball with the name 
of folder you are wondering about.
+       @param $match_fld_name (known string) can be INBOX, Sent, or Trash.
+       @result Boolean True if param $query_fld_name is a match to 
$match_fld_name, False otherwise.
+       @discussion Certain folder may exist on any IMAP server, such as Sent, 
INBOX, and Trash.
+       This function is limited to these common folder names only, it is not a 
generic lookup function.
+       This is a quick way to check if the given folder is in fact one of 
these common IMAP folders,
+       because these folders often require different handling for their 
message list display. For example the
+       Sent folder displays who a message is TO, not who the message is FROM, 
as with all other folders.
+       Also, names such as Sent and Trash depend on user preference values 
that are not required to be in
+       known "folder long" form, so the string to match to also requires 
special handling to eventually
+       compare correctly. This function processes each param for accurate 
matching.
        @author Angles
        */
        function common_folder_is($query_fldball='##NOTHING##', 
$match_fld_name='##NOTHING##')
        {
-               if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: ENTERING 
<br>'); }
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: param 
$query_fldball ['.htmlspecialchars(serialize($query_fldball)).'] param 
$match_fld_name ['.htmlspecialchars($match_fld_name).']<br>'); }
-
+               if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: ENTERING 
<br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: param 
$query_fldball ['.htmlspecialchars(serialize($query_fldball)).'] param 
$match_fld_name ['.htmlspecialchars($match_fld_name).']<br>'); }
+
                //return 'FIX ME: stub function not completed. 
mail_msg_display.common_folder_is LINE '.__LINE__;
                $acctnum = $query_fldball['acctnum'];
-
+
                /*
                if (    $this->get_folder_short($this->get_arg_value('folder'))
                 != 
$this->get_folder_short($this->get_pref_value('sent_folder_name')))
@@ -118,40 +133,46 @@
                        // blaaaa
                }
                */
-               if (($query_fldball == $this->nothing)
-               || ($match_fld_name == $this->nothing))
+               if (((string)$query_fldball == $this->nothing)
+               || ((string)$match_fld_name == $this->nothing))
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, not enough param data supplied, so returning False<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, not enough param data supplied, so returning False<br>'); }
                        return False;
                }
                elseif (($match_fld_name != 'INBOX')
                && (strtolower($match_fld_name) != 'trash')
                && (strtolower($match_fld_name) != 'sent'))
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, param $match_fld_name ['.htmlspecialchars($match_fld_name).'] is 
not INBOX nor Trash, nor Sent, this function can not test for anything else, so 
returning False<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, param $match_fld_name ['.htmlspecialchars($match_fld_name).'] is 
not INBOX nor Trash, nor Sent, this function can not test for anything else, so 
returning False<br>'); }
                        return False;
                }
                elseif ($this->is_ball_data($query_fldball, 'any') == False)
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, input data fails 
$this->is_ball_data('.htmlspecialchars(serialize($query_fldball)).', "any"), so 
returning False<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING 
with Error, input data fails 
$this->is_ball_data('.htmlspecialchars(serialize($query_fldball)).', "any"), so 
returning False<br>'); }
                        return False;
                }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: 
$query_fldball DUMP:', $query_fldball); }
+
                // First, handle the easiest test - INBOX
                if (($match_fld_name == 'INBOX')
                && ($query_fldball['folder'] == 'INBOX'))
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING, 
returning True, tested for and found INBOX<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING, 
returning True, tested for and found INBOX<br>'); }
                        return True;
                }
+               else
+               {
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: 
match_fld_name and $query_fldball["folder"], either one nor both were INBOX, so 
did not match the test, so continue with more checks...<br>'); }
+               }
                // continue ...
                // does the mailserver have folders, if not then there is NO 
trash folder no matter what
                if ($this->get_mailsvr_supports_folders($acctnum) == False)
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING, 
mailserver does NOT support folders, and not testing for INBOX, so returning 
False<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: LEAVING, 
mailserver does NOT support folders, and not testing for INBOX, so returning 
False<br>'); }
                        return False;
                }
                // continue ...
-
+
                // handle looking for Trash match
                if (strtolower($match_fld_name) == 'trash')
                {
@@ -163,23 +184,23 @@
                }
                else
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
with ERROR, we should not ever get here because param sanity test is above, 
param $match_fld_name ['.htmlspecialchars($match_fld_name).'] needs to be 
either "Trash" or "Sent" at this point in the code, but it is not<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
with ERROR, we should not ever get here because param sanity test is above, 
param $match_fld_name ['.htmlspecialchars($match_fld_name).'] needs to be 
either "Trash" or "Sent" at this point in the code, but it is not<br>'); }
                        return False;
                }
                // use that $needle to use the same code to handle both Trash 
and Sent matchings
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: now 
testing if input data is "'.$needle.'" folder ...<br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: now 
testing if input data is "'.$needle.'" folder ...<br>'); }
                // are we even supposed to use a trash or sent folder
                if ( (!$this->get_isset_pref('use_'.$needle.'_folder', 
$acctnum))
                || (!$this->get_pref_value('use_'.$needle.'_folder', $acctnum)) 
)
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] LEAVING, returning False, testing for '.$needle.' folder but user 
preferences do NOT even want a '.$needle.' folder<br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] LEAVING, returning False, testing for '.$needle.' folder but user 
preferences do NOT even want a '.$needle.' folder<br>'); }
                        return False;
                }
-
+
                // does the trash folder actually exist ?
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] humm... does the "'.$needle.'" folder actually exist :: 
this->get_pref_value("'.$needle.'_folder_name", '.$acctnum.') = 
['.htmlspecialchars($this->get_pref_value($needle.'_folder_name', 
$acctnum)).']<br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] humm... does the "'.$needle.'" folder actually exist :: 
this->get_pref_value("'.$needle.'_folder_name", '.$acctnum.') = 
['.htmlspecialchars($this->get_pref_value($needle.'_folder_name', 
$acctnum)).']<br>'); }
                $found_needle_folder_long = $this->folder_lookup('', 
$this->get_pref_value($needle.'_folder_name', $acctnum));
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] did lookup on pref value for "'.$needle.'" folder, got 
$found_needle_folder_long 
['.htmlspecialchars($found_needle_folder_long).']<br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] did lookup on pref value for "'.$needle.'" folder, got 
$found_needle_folder_long 
['.htmlspecialchars($found_needle_folder_long).']<br>'); }
                if ((isset($found_needle_folder_long))
                && ($found_needle_folder_long != ''))
                {
@@ -192,30 +213,30 @@
                // do we even need to continue
                if ($havefolder == False)
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] LEAVING, returning False, testing for '.$needle.' folder, user 
preferences DO want a '.$needle.' folder, but that folder does NOT exist, so 
param certainly can not be a real '.$needle.' folder. <br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_display)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] LEAVING, returning False, testing for '.$needle.' folder, user 
preferences DO want a '.$needle.' folder, but that folder does NOT exist, so 
param certainly can not be a real '.$needle.' folder. <br>'); }
                        return False;
                }
                // so the trash folder exists, does it match the param to test 
against
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] "'.$needle.'" folder exist, does it match a prepped param fldball, 
get prepped fldball folder string top use for the comparing<br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] "'.$needle.'" folder exist, does it match a prepped param fldball, 
get prepped fldball folder string top use for the comparing<br>'); }
                $query_folder_long = 
$this->prep_folder_in($query_fldball['folder'], $acctnum);
-               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] now we have folder long names to compare, does $query_folder_long 
['.htmlspecialchars($query_folder_long).'] equal $found_needle_folder_long 
['.htmlspecialchars($found_needle_folder_long).'] <br>'); }
+               if ($this->debug_args_special_handlers > 1) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: [test: 
'.$needle.'] now we have folder long names to compare, does $query_folder_long 
['.htmlspecialchars($query_folder_long).'] equal $found_needle_folder_long 
['.htmlspecialchars($found_needle_folder_long).'] <br>'); }
                if ($query_folder_long == $found_needle_folder_long)
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
return True, match '.$needle.', and found '.$needle.' folder exists and matched 
the input ball data <br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
return True, match '.$needle.', and found '.$needle.' folder exists and matched 
the input ball data <br>'); }
                        return True;
                }
                else
                {
-                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
return False, match '.$needle.', and found '.$needle.' folder exists BUT input 
ball data does not match it. <br>'); }
+                       if ($this->debug_args_special_handlers > 0) { 
$this->dbug->out('mail_msg(_wrappers)('.__LINE__.'): common_folder_is: LEAVING, 
return False, match '.$needle.', and found '.$needle.' folder exists BUT input 
ball data does not match it. <br>'); }
                        return False;
                }
        }
-
+
        /*!
        @function all_folders_listbox
-       @abstract gets a list of all folders available to the user, and makes 
an HTML listbox widget with that data.
-       BEING PHASED OUT, REPLACED BY HTML WIDGET CLASS, soon to be DEPRECIATED.
-       @param $feed_args[] array or args that you will "feed" into the 
function, contains the following members
+       @abstract gets a list of all folders available to the user, and makes 
an HTML listbox widget with that data.
+       BEING PHASED OUT, REPLACED BY HTML WIDGET CLASS, soon to be DEPRECIATED.
+       @param $feed_args[] array or args that you will "feed" into the 
function, contains the following members
                ['mailsvr_stream'] : integer : the stream where the data 
communications with the mailserver takes place
                ['pre_select_folder'] : string : if you want a particular 
folder already selected in the listbox, put that foldername
                        here. Note you must know the name of the folder as it 
will aooear in the kistbox for this to work.
@@ -226,15 +247,15 @@
                ['widget_name'] : string : name of the select widget : 
important for form post usage. Default "folder"
                ['embeded_extra_data'] : string : OPTIONAL, if this is 
specified, the value='' becomes "fake_uri_data"
                        in order to contain the extra data. Mostly used to 
include the acctnum for the folder.
-                       In this case, the "widget_name" is appended with 
"_fake_uri" which tells the script to
+                       In this case, the "widget_name" is appended with 
"_fake_uri" which tells the script to
                        use "explode_fake_uri()" to get the data, which it then 
inserts back into the HTTP_POST_VARS
                        as if the data had never been embeeded. NOTE: such data 
should be urlencode'd just as if this
                        were a URI, however "prep_folder_out" takes care of 
this for the folder name automatically.
                ['on_change'] : string : the HTML select widget's "onChange" 
value. Default: "document.switchbox.submit()'"
                '[first_line_txt'] : string : the text that initially is 
displayed in the select widget, used for information only,
                        like a descriptive label, it does not have any 
important data usage. Default: "lang('switch current folder to')"
-       @result string representing an HTML listbox widget
-       @discussion BEING PHASED OUT, REPLACED BY HTML WIDGET CLASS, altough 
this function *may*
+       @result string representing an HTML listbox widget
+       @discussion BEING PHASED OUT, REPLACED BY HTML WIDGET CLASS, altough 
this function *may*
        be retaied just to generate the raw data, but not the actual html.
        @access   private
        */
@@ -246,7 +267,7 @@
                }
                //$debug_widget = True;
                $debug_widget = False;
-
+
                $acctnum = $this->get_acctnum();
                // establish fallback default args
                $local_args = Array(
@@ -379,7 +400,7 @@
                                        } else {
                                        $item_tags = $item_tags .'<option 
value="'.$option_value.'"'.$sel.'>' .$folder_short;
                                        }
-
+

                                        // "show_num_new" is currently BROKEN
                                        // do we show the number of new 
(unseen) messages for this folder
@@ -442,7 +463,7 @@
                {
                        $feed_args=array();
                }
-
+
                $acctnum = $this->get_acctnum();
                // establish fallback default args
                $local_args = Array(
@@ -457,7 +478,7 @@
                        'acctnum_key_name'      => 'acctnum',
                        'on_change'             => 
'document.switchbox.submit()',
                        'first_line_txt'        => lang('switch current folder 
to')
-               );
+               );
                // loop thru $local_args[], replacing defaults with any args 
specified in $feed_args[]
                if ($debug_mega_listbox > 1) { 
$this->dbug->out('folders_mega_listbox('.__LINE__.'): $feed_args data DUMP:', 
$feed_args); }
                if (count($feed_args) == 0)
@@ -496,9 +517,9 @@
                }
                // at this point, local_args[] has anything that was passed in 
the feed_args[]
                if ($debug_mega_listbox > 1) { 
$this->dbug->out('folders_mega_listbox('.__LINE__.'):FINAL Listbox Local 
Args:<br>'.serialize($local_args).'<br>'); }
-
+
                $item_tags = '';
-
+
                // we need the loop to include the default account AS WELL AS 
the extra accounts
                for ($x=0; $x < count($this->extra_and_default_acounts); $x++)
                {
@@ -531,7 +552,7 @@
                                        break;
                                }
                                // ... back to working code
-
+
                                // iterate thru the folder list, building the 
HTML tags using that data
                                for ($i=0; $i<count($folder_list);$i++)
                                {
@@ -553,22 +574,22 @@
                                        // this logic determines we should not 
include a certain folder in the combobox list
                                        if ($folder_short != 
$this->get_folder_short($local_args['skip_folder']))
                                        {
-                                               // we need to make value="X" 
imitate URI type data, so we can embed the acctnum data
-                                               // for the folder in there with 
folder name, whereas normally option value="X" can only
-                                               // hold no nore than one data 
item as limited by BOTH html and php 's treatment of a combobox
-
+                                               // we need to make value="X" 
imitate URI type data, so we can embed the acctnum data
+                                               // for the folder in there with 
folder name, whereas normally option value="X" can only
+                                               // hold no nore than one data 
item as limited by BOTH html and php 's treatment of a combobox
+
                                                $option_value =  
'&'.$local_args['folder_key_name'].'='.$this->prep_folder_out($folder_long)
                                                                
.'&'.$local_args['acctnum_key_name'].'='.$folder_acctnum;
-
+
                                                $text_blurb = 
'['.$folder_acctnum.'] '.$folder_short;
-
+
                                                $item_tags .= '<option 
value="'.$option_value.'"'.$sel.'>'.$text_blurb.'</option>'."\r\n";
                                        }
                                }
                        }
                }
                // now $item_tags contains the internal (i.e. "option" items) 
folder list for this "select" combobox widget
-
+
                // ----  add the HTML tags that surround this internal list 
data  ----
                if ((isset($local_args['on_change']))
                && ($local_args['on_change'] != ''))
@@ -579,7 +600,7 @@
                {
                        $on_change_tag = '';
                }
-
+
                // the widget_name with "_fake_uri" tells the script what to do 
with this data
                $listbox_widget =
                         '<select name="'.$local_args['widget_name'].'" 
'.$on_change_tag.'>'
@@ -590,28 +611,28 @@
                if ($debug_mega_listbox > 0) { 
$this->dbug->out('folders_mega_listbox('.__LINE__.'): LEAVING<br>'); }
                return $listbox_widget;
        }
-
-
+
+
        // ---- Messages Sort Order Start and Msgnum  -----
        /*!
        @function fill_sort_order_start_msgnum
        @abstract alias to "fill_sort_order_start" because msgnum is NO LONGER 
handled here, function was renamed.
        @author Angles
-       @discussion alias function for backward compatibility only, useful only 
until the rest of the code calls the
+       @discussion alias function for backward compatibility only, useful only 
until the rest of the code calls the
        real function "fill_sort_order_start"
        */
        function fill_sort_order_start_msgnum()
        {
                $this->fill_sort_order_start();
        }
-
+
        /*!
        @function fill_sort_order_start
        @abstract handles determining what values sort, order, and start should 
have.
        @author Angles
-       @discussion if sort, order, and start are available in the GPC vars and 
are valid (values work, not out of range) then
-       those GPC vars are used as source data. If not, then data is generated 
accourding to the users prefs for sort and order,
-       abd start is assumed 0 if not otherwise provided in the GPC vars. NOTE: 
MSGNUM IS NO LONGER HANDLED
+       @discussion if sort, order, and start are available in the GPC vars and 
are valid (values work, not out of range) then
+       those GPC vars are used as source data. If not, then data is generated 
accourding to the users prefs for sort and order,
+       abd start is assumed 0 if not otherwise provided in the GPC vars. NOTE: 
MSGNUM IS NO LONGER HANDLED
        IN THIS FUNCTION so it was renamed from "fill_sort_order_start_msgnum" 
to "fill_sort_order_start".
        @syntax These are the PHP Sorting definitions and what they do and what 
their int value is.
        SORTDATE:  0    //This is the Date that the senders email client stanp 
the message with
@@ -719,32 +740,45 @@
        /*!
        @function prev_next_navigation
        @abstract ?
+       @discussion Adding ex_acctnum and ex_folder params AS AN EXPERIMENT.
        @author Angles
        */
-       function prev_next_navigation($old_method_totalmessages=0)
+       function prev_next_navigation($old_method_totalmessages=0, 
$ex_acctnum='', $ex_folder='')
        {
                //$debug_nav = True;
                //$debug_nav = False;
                $debug_nav = $this->debug_index_page_display;
                if ($debug_nav > 0) { $this->dbug->out('mail_msg_display: 
prev_next_navigation('.__LINE__.'): ENTERING, (try debug_index_page_display = 3 
to see data dumps)<br>'); }

-               // this gets a verified non stale msgball_list and puts it in 
cache, or uses the one in cache if it passes verified and not stale test
-               $this->get_msgball_list();
                // but we do not want a COPY of this data it can be thousands 
of items, so we try to get a reference
                $nav_data = array();
                $nav_data['msgball_list'] = array();
-               $ex_acctnum = $this->get_acctnum();
+               // TESTING THIS AS AN OPTIONAL PARAM HERE
+               // we used to obtain it here no matter what, now it may be 
passed as a param
+               if ((!isset($ex_acctnum))
+               || ((string)$ex_acctnum == ''))
+               {
+                       $ex_acctnum = $this->get_acctnum();
+               }
+               // TESTING THIS AS AN OPTIONAL PARAM HERE
+               if ((!isset($ex_folder))
+               || ((string)$ex_folder == ''))
+               {
+                       $ex_folder = 
$this->prep_folder_out($this->get_arg_value('folder', $acctnum));
+               }
+               // TESTING this gets a verified non stale msgball_list and puts 
it in cache, or uses the one in cache if it passes verified and not stale test
+               //$this->get_msgball_list($ex_acctnum, $ex_folder);
+               // remember the actual msgball_list is a sub element of an 
array that includes validity info
                if (($this->session_cache_enabled == True)
-               && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'])))
-               //&& 
(isset($GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'])))
+               && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list'][$ex_folder]['msgball_list'])))
+               //&& 
(isset($GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'][$ex_folder])))
                {
-                       $nav_data['msgball_list'] =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'];
-                       //$nav_data['msgball_list'] =& 
$GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'];
+                       $nav_data['msgball_list'] =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list'][$ex_folder]['msgball_list'];
                }
                else
                {
                        // ok we could not obtain a reference for some reason, 
get a COPY then
-                       $nav_data['msgball_list'] = $this->get_msgball_list();
+                       $nav_data['msgball_list'] = 
$this->get_msgball_list($ex_acctnum, $ex_folder);
                }
                //$nav_data['msgnum_idx'] = 
$this->array_search_ex($this->get_arg_value('["msgball"]["msgnum"]'), 
$nav_data['msgball_list']);

@@ -807,9 +841,9 @@
                        $nav_data['prev_msg'] = $nav_data['active_msgnum_idx'] 
- 1;
                        $nav_data['method'] = 'old_broken';
                }
-
+
                if ($debug_nav > 2) { $this->dbug->out('mail_msg_display: 
prev_next_navigation('.__LINE__.'): step1 $nav_data[] DUMP:', $nav_data); }
-
+
                // if it's not possible to have a prev message, then make 
"prev_msg" False
                if ($nav_data['active_msgnum_idx'] <= $nav_data['lowest_left'])
                {
@@ -826,20 +860,20 @@
                if ($debug_nav > 0) { $this->dbug->out('mail_msg_display: 
prev_next_navigation('.__LINE__.'): LEAVING<br>'); }
                return $nav_data;
        }
-
+
        /*!
-       @function all_ex_accounts_listbox
+       @function all_ex_accounts_listbox DEPRECIATED
        @abstract Creates a listbox with all email accounts.
-       @discussion  Used in the switch account combobox, and the filers page 
too, I think. The listbox
-       is sort of an HTML widget. For the raw data, see the function, it is 
easy to get the data without the
-       HTML if you want that.
+       @discussion  Used in the switch account combobox, and the filers page 
too, I think. The listbox
+       is sort of an HTML widget. For the raw data, see the function, it is 
easy to get the data without the
+       HTML if you want that. DEPRECIATED now should use function in widgets 
class.
        @author Angles
        */
        function all_ex_accounts_listbox($feed_args)
        {
                // $this->ex_accounts_count
                // $this->extra_accounts
-
+
                if(!$feed_args)
                {
                        $feed_args=array();
@@ -1041,7 +1075,7 @@
        // ----  High-Level Function To Get The "so-and-so" wrote String   -----
        /*!
        @function get_who_wrote
-       @abstract
+       @abstract PROBABLY NO LONGER USED
        @author Angles and code from previous maintainer
        */
        function get_who_wrote($msg)
@@ -1070,7 +1104,9 @@
                        $personal = trim($from->personal);
                        // non-us-ascii chars in headers MUST be specially 
encoded, so decode them (if any) now
                        $personal = $this->decode_header_string($personal);
-                       //$personal = $this->qprint_rfc_header($personal);
+                       ////$personal = $this->qprint_rfc_header($personal);
+                       // escape certain undesirable chars before HTML display
+                       $personal =  $this->htmlspecialchars_encode($personal);
                        $personal = $personal .' 
('.$from->mailbox.'@'.$from->host.')';
                }
                return $personal;
@@ -1124,19 +1160,53 @@

        /* * * * * * * * * * *
          *
-         *   = = = = = = MIME ANALYSIS = = = = =
+         *   = = = = = = MIME ANALYSIS = = = = =
          *
          * * * * * * *  * * * */
        // ---- Message Structure Analysis   -----
        /*!
        @function get_flat_pgw_struct
-       @abstract Message Structure Analysis, make multilevel php message 
struct into a flat array
-       @param $struct (php structure from ?)
-       @discussion This is the meat of the home grown MIME analysis this app 
uses.
+       @abstract Message Structure Analysis, make multilevel php message 
struct into a flat array aka "part_nice"
+       @param $struct (php structure from ?)
+       @discussion This is the meat of the home grown MIME analysis this app 
uses.
        @author Angles
        */
        function get_flat_pgw_struct($struct)
        {
+               if ($this->debug_message_display > 0) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct:  ENTERING <br>'); }
+               //if ($this->debug_message_display > 1) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct:  param $msgball 
['.serialize($msgball).']<br>'); }
+               if ($this->debug_message_display > 2) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct:  param $struct DUMP:', 
$struct); }
+
+               /*
+               // NO NEED TO CACHE THIS DATA, NO CONTACT WITH MAILSERVER IS 
NEEDED FOR THIS DATA
+               // try to get it from cache, this function handles checking for 
session_cache_extreme True or False
+               if ($this->session_cache_extreme == True)
+               {
+                       if ((isset($msgball['folder']))
+                       && (trim($msgball['folder']) != '')
+                       && (isset($msgball['acctnum']))
+                       && ((string)($msgball['acctnum']) != ''))
+                       {
+                               $ex_folder = $msgball['folder'];
+                               $ex_msgnum = $msgball['msgnum'];
+                       }
+                       else
+                       {
+                               $ex_folder = $this->prep_folder_out();
+                               $ex_msgnum = $this->get_acctnum();
+                       }
+                       // the cached data is returned as a ready to use array 
if it exists, or False if not existing
+                       $cache_flat_pgw_struct = 
$this->read_session_cache_item('flat_pgw_struct', $acctnum, $ex_folder, 
$ex_msgnum);
+                       //echo '** flat_pgw_struct: $specific_key 
['.$specific_key.'] :: $cache_flat_pgw_struct DUMP<pre>'; 
print_r($cache_phpgw_header); echo '</pre>';
+                       if ($cache_flat_pgw_struct)
+                       {
+                               if ($this->debug_message_display > 0) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct:  LEAVING returning 
cached data<br>'); }
+                               return $cache_flat_pgw_struct;
+                       }
+               }
+               if ($this->debug_message_display > 1) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct: beginning ... no 
cached data available or caching is not enabled<br>'); }
+               */
+
                if (isset($this->not_set))
                {
                        $not_set = $this->not_set;
@@ -1145,7 +1215,7 @@
                {
                        $not_set = '-1';
                }
-
+
                // get INITIAL part structure / array from the fetchstructure  
variable
                if ((!isset($struct->parts[0]) || (!$struct->parts[0])))
                {
@@ -1155,13 +1225,13 @@
                {
                        $part = $struct->parts;
                }
-
+
                //$part = Array();
                //$part[0] = $struct;

-               //echo '<br>INITIAL var part serialized:<br>' .serialize($part) 
.'<br><br>';
+               //echo '<br>INITIAL var part serialized:<br>' .serialize($part) 
.'<br><br>';

-               $d1_num_parts = count($part);
+               $d1_num_parts = count($part);
                $part_nice = Array();

                // get PRIMARY level part information
@@ -1174,7 +1244,7 @@
                        $d1_mime_num = (string)($d1+1);
                        $part_nice[$array_position] = 
$this->pgw_msg_struct($part[$d1], $not_set, $d1_mime_num, ($d1+1), 
$d1_num_parts, 1);
                        if ($deepest_level < 1) { $deepest_level=1; }
-
+
                        // get SECONDARY/EMBEDDED level part information
                        $d1_array_pos = $array_position;
                        if ($part_nice[$d1_array_pos]['ex_num_subparts'] != 
$not_set)
@@ -1187,7 +1257,7 @@
                                        $array_position++;
                                        $part_nice[$array_position] = 
$this->pgw_msg_struct($d2_part, $d1_array_pos, $d2_mime_num, ($d2+1), 
$d2_num_parts, 2);
                                        if ($deepest_level < 2) { 
$deepest_level=2; }
-
+
                                        // get THIRD/EMBEDDED level part 
information
                                        $d2_array_pos = $array_position;
                                        if ($d2_part['ex_num_subparts'] != 
$not_set)
@@ -1200,7 +1270,7 @@
                                                        $array_position++;
                                                        
$part_nice[$array_position] = $this->pgw_msg_struct($d3_part, $d2_array_pos, 
$d3_mime_num, ($d3+1), $d3_num_parts, 3);
                                                        if ($deepest_level < 3) 
{ $deepest_level=3; }
-
+
                                                        // get FOURTH/EMBEDDED 
level part information
                                                        $d3_array_pos = 
$array_position;
                                                        if 
($d3_part['ex_num_subparts'] != $not_set)
@@ -1213,7 +1283,7 @@
                                                                        
$array_position++;
                                                                        
$part_nice[$array_position] = $this->pgw_msg_struct($d4_part, $d3_array_pos, 
$d4_mime_num, ($d4+1), $d4_num_parts, 4);
                                                                        if 
($deepest_level < 4) { $deepest_level=4; }
-
+
                                                                        // get 
FIFTH LEVEL EMBEDDED level part information
                                                                        
$d4_array_pos = $array_position;
                                                                        if 
($d4_part['ex_num_subparts'] != $not_set)
@@ -1226,7 +1296,7 @@
                                                                                
        $array_position++;
                                                                                
        $part_nice[$array_position] = $this->pgw_msg_struct($d5_part, 
$d4_array_pos, $d5_mime_num, ($d5+1), $d5_num_parts, 5);
                                                                                
        if ($deepest_level < 5) { $deepest_level=5; }
-
+
                                                                                
        // get SIXTH LEVEL EMBEDDED level part information
                                                                                
        $d5_array_pos = $array_position;
                                                                                
        if ($d5_part['ex_num_subparts'] != $not_set)
@@ -1239,7 +1309,7 @@
                                                                                
                        $array_position++;
                                                                                
                        $part_nice[$array_position] = 
$this->pgw_msg_struct($d6_part, $d5_array_pos, $d6_mime_num, ($d6+1), 
$d6_num_parts, 6);
                                                                                
                        if ($deepest_level < 6) { $deepest_level=6; }
-
+
                                                                                
                        // get SEVENTH LEVEL EMBEDDED level part information
                                                                                
                        $d6_array_pos = $array_position;
                                                                                
                        if ($d6_part['ex_num_subparts'] != $not_set)
@@ -1252,7 +1322,7 @@
                                                                                
                                        $array_position++;
                                                                                
                                        $part_nice[$array_position] = 
$this->pgw_msg_struct($d7_part, $d6_array_pos, $d7_mime_num, ($d7+1), 
$d7_num_parts, 7);
                                                                                
                                        if ($deepest_level < 7) { 
$deepest_level=7; }
-
+
                                                                                
                                        // get EIGTH LEVEL EMBEDDED level part 
information
                                                                                
                                        $d7_array_pos = $array_position;
                                                                                
                                        if ($d7_part['ex_num_subparts'] != 
$not_set)
@@ -1265,7 +1335,7 @@
                                                                                
                                                        $array_position++;
                                                                                
                                                        
$part_nice[$array_position] = $this->pgw_msg_struct($d8_part, $d7_array_pos, 
$d8_mime_num, ($d8+1), $d8_num_parts, 8);
                                                                                
                                                        if ($deepest_level < 8) 
{ $deepest_level=8; }
-
+
                                                                                
                                                        // get NINTH LEVEL 
EMBEDDED level part information
                                                                                
                                                        $d8_array_pos = 
$array_position;
                                                                                
                                                        if 
($d8_part['ex_num_subparts'] != $not_set)
@@ -1278,7 +1348,7 @@
                                                                                
                                                                        
$array_position++;
                                                                                
                                                                        
$part_nice[$array_position] = $this->pgw_msg_struct($d9_part, $d8_array_pos, 
$d9_mime_num, ($d9+1), $d9_num_parts, 9);
                                                                                
                                                                        if 
($deepest_level < 9) { $deepest_level=9; }
-
+
                                                                                
                                                                        // get 
10th LEVEL EMBEDDED level part information
                                                                                
                                                                        
$d9_array_pos = $array_position;
                                                                                
                                                                        if 
($d9_part['ex_num_subparts'] != $not_set)
@@ -1291,7 +1361,7 @@
                                                                                
                                                                                
        $array_position++;
                                                                                
                                                                                
        $part_nice[$array_position] = $this->pgw_msg_struct($d10_part, 
$d9_array_pos, $d10_mime_num, ($d10+1), $d10_num_parts, 10);
                                                                                
                                                                                
        if ($deepest_level < 10) { $deepest_level=10; }
-
+
                                                                                
                                                                                
        // get 11th LEVEL EMBEDDED level part information
                                                                                
                                                                                
        $d10_array_pos = $array_position;
                                                                                
                                                                                
        if ($d10_part['ex_num_subparts'] != $not_set)
@@ -1343,7 +1413,7 @@

                // CONTINUE WITH THE ANALYSIS

-               // ---- Mime Characteristics Analysis  and more Attachments 
Detection  -----
+               // ---- Mime Characteristics Analysis  and more Attachments 
Detection  -----
                // ANALYSIS LOOP Part 1
                for ($i = 0; $i < count($part_nice); $i++)
                {
@@ -1376,11 +1446,11 @@
                        {
                                for ($p = 0; $p < 
$part_nice[$i]['ex_num_param_pairs']; $p++)
                                {
-                                       if
+                                       if
                                        (
-                                               
(($part_nice[$i]['params'][$p]['attribute'] == 'name')
+                                               
(($part_nice[$i]['params'][$p]['attribute'] == 'name')
                                                || 
($part_nice[$i]['params'][$p]['attribute'] == 'filename'))
-
+
                                                && 
($part_nice[$i]['params'][$p]['value'] != $not_set)
                                        )
                                        {
@@ -1397,11 +1467,11 @@
                        {
                                for ($p = 0; $p < 
$part_nice[$i]['ex_num_dparam_pairs']; $p++)
                                {
-                                       if
+                                       if
                                        (
-                                               
(($part_nice[$i]['dparams'][$p]['attribute'] == 'name')
+                                               
(($part_nice[$i]['dparams'][$p]['attribute'] == 'name')
                                                || 
($part_nice[$i]['dparams'][$p]['attribute'] == 'filename'))
-
+
                                                && 
($part_nice[$i]['dparams'][$p]['value'] != $not_set)
                                        )
                                        {
@@ -1411,7 +1481,7 @@
                                        }
                                }
                        }
-
+
                        // Attachment Detection PART2 = if a part has 
encoding=base64 , then treat as an attachment
                        //      eventhough the above code did not find a name 
for the part
                        if (($part_nice[$i]['encoding'] == 'base64')
@@ -1444,7 +1514,7 @@
                                {
                                        // NOTE: if a part has a name in the 
params, the it would have been handled
                                        // before this if..then block. Thus, to 
get to this point in the code means
-                                       // we MUST have a base64 part with NO 
NAME -
+                                       // we MUST have a base64 part with NO 
NAME -
                                        // NOR does it have an OBVIOUS 
type/subtype (text/plain)
                                        // we have NO CHOICE but to treat it as 
an attachment
                                        $part_nice[$i]['ex_attachment'] = True;
@@ -1472,21 +1542,22 @@
                                // sometimes the name's extention is the only 
info we have, i.e. ".doc" implies a WORD file
                                //$part_nice['ex_part_name'] = 'no_name.att';
                        }
-
-
+
+
                        /*!
                        @concept MIME PART CATAGORIZATION in get_flat_pgw_struct
-                       @abstract Anglemail uses an custom flat mime analysis 
which gives human understandable names to MIME parts.
-                       @example POSSIBLE VALUES FOR [ " m_description " ] ARE
+                       @abstract Anglemail uses an custom flat mime analysis 
which gives human understandable names to MIME parts.
+                       @example POSSIBLE VALUES FOR [ " m_description " ] ARE
                        container
                        packagelist
                        presentable/image
                        attachment
                        presentable
-                       @syntax RULES for determining m_description are
+                       @syntax RULES for determining m_description are
                        a) if no subpart(s) then we have either "presentable" 
or "attachment"
                        b) if subpart(s) and a boundary param, then we have a 
"packagelist" (HeadersOnly)
-                       c) else we have a container
+                       c) else we have a container.
+                       Presentable can be qualified with "image".
                        */
                        if ((int)$part_nice[$i]['ex_num_subparts'] < 1)
                        {
@@ -1512,6 +1583,7 @@
                                else
                                {
                                        // not an attachment, nor an attachment 
that's an image for inline display
+                                       // so it is presentable
                                        $part_nice[$i]['m_description'] = 
'presentable';
                                }
                        }
@@ -1525,14 +1597,16 @@
                                // c) else we have a container
                                $part_nice[$i]['m_description'] = 'container';
                        }
-
+
                        // ------  KEYWORD LIST  -------
-
+
                        // probably will be depreciated
                        // at least for now, keywords "plain" and "html" are 
needed below
                        $part_nice[$i]['m_keywords'] = '';
                        if ((stristr($part_nice[$i]['subtype'], 'plain'))
-                       || (stristr($part_nice[$i]['subtype'], 'html')))
+                       || (stristr($part_nice[$i]['subtype'], 'html'))
+                       // enriched = part of APPLE MAIL multipart / 
alternative subpart where the html part usually is
+                       || (stristr($part_nice[$i]['subtype'], 'enriched')))
                        {
                                $part_nice[$i]['m_keywords'] .= 
$part_nice[$i]['subtype'] .' ';
                        }
@@ -1541,22 +1615,173 @@
                        {
                                $part_nice[$i]['m_keywords'] .= 
$part_nice[$i]['encoding'] .' ';
                        }
-
-
+
+                       // keyword "alt_hide"
+                       // Also a keywords we use can be "alt_hide" which means 
that the
+                       // part is part of an alternative pair of parts and 
this one can be hidden because
+                       // it is the simpler text part, while we desire to show 
the html part as the better-to-show
+                       // part, and showing 2 of the same, i.e. both of the 
alternatives, is undesirable.
+                       // so is a presentable part of an alternative pair of 
parts
+                       if ($part_nice[$i]['m_description'] == 'presentable')
+                       {
+                               // TEST THIS:
+                               // (a) is the part text/plain
+                               // (b) if so, is that parent marked as 
multipart/related
+                               //// (c) is the very next part HTML, because 
apple uses "enhanced" which looks b0rked,
+                               //// so that case needs the simpler part to 
also be shown.
+                               ////UPDATE this (c) thing will fail if the html 
is in a related nest, so skip this check
+                               // and CHECK 2 TIMES: note that we test 2 times
+                               // (1) the first is where the mail has only 2 
parts
+                               // and AngleMail flatening code has left the 
top level headers out of the
+                               // flat array, as it does sometimes.
+                               // (2) the first is where the mail has a 
RELATED subgroup that is at the 1st level debth
+                               // i.e. the first thing below the top level 
headers themselves, thus
+                               // and AngleMail flatening code has left the 
top level headers out of the
+                               // flat array, as it does sometimes, so we need 
to look back 2 steps to those top level headers
+                               // that are only available thru the 
$struct->type thing because our flattening code
+                               // has left the top level headers out of the 
flat array, as it does sometimes
+                               // (3) The second is for anything deep enough 
so that the parent part IS in the
+                               // flat array, which is more typical.
+                               $presentable_parent_idx = 
$part_nice[$i]['ex_parent_flat_idx'];
+                               if (
+                                  ($part_nice[$i]['type'] == 'text')
+                               && ($part_nice[$i]['subtype'] == 'plain')
+                               && ($part_nice[$i]['ex_parent_flat_idx'] == 
$not_set)
+                               //&& (stristr($struct->type, 'multipart'))
+                               && ((string)$struct->type == '1')  // "1" = 
"multipart"
+                               && (stristr($struct->subtype, 'alternative'))
+                               )
+                               {
+                                       // SET THIS FLAG: then, in presentation 
loop, we can decide not to show it
+                                       $part_nice[$i]['m_keywords'] .= 
'alt_hide' .' ';
+                               }
+                               // scanario (2) as outlined above
+                               elseif (
+                                  ($part_nice[$i]['type'] == 'text')
+                               && ($part_nice[$i]['subtype'] == 'plain')
+                               && 
($part_nice[$presentable_parent_idx]['ex_parent_flat_idx'] == $not_set)
+                               && (stristr($struct->type, 'multipart'))
+                               // SHOULD BE THIS   && ((string)$struct->type 
== '1')  // "1" = "multipart"
+                               && (stristr($struct->subtype, 'alternative'))
+                               //&& ($part_nice[$i+1]['type'] == 'text')
+                               //&& ($part_nice[$i+1]['subtype'] == 'html')
+                               )
+                               {
+                                       // SET THIS FLAG: then, in presentation 
loop, we can decide not to show it
+                                       $part_nice[$i]['m_keywords'] .= 
'alt_hide' .' ';
+                               }
+                               // scenario (3) as outlined above
+                               // same as (1) above but we do not need to look 
all the way back to the top level headers
+                               // i.e. because the parent part is included in 
the flat parts array
+                               elseif (
+                                  ($part_nice[$i]['ex_level_debth'] > 1)
+                               && ($part_nice[$i]['type'] == 'text')
+                               && ($part_nice[$i]['subtype'] == 'plain')
+                               && ($part_nice[$presentable_parent_idx]['type'] 
== 'multipart')
+                               && 
($part_nice[$presentable_parent_idx]['subtype'] == 'alternative')
+                               //&& ($part_nice[$i+1]['type'] == 'text')
+                               //&& ($part_nice[$i+1]['subtype'] == 'html')
+                               )
+                               {
+                                       // SET THIS FLAG: then, in presentation 
loop, we can decide not to show it
+                                       $part_nice[$i]['m_keywords'] .= 
'alt_hide' .' ';
+                               }
+                       }
+                       // more keyword "alt_hide"
+                       // ALSO use this same kind of test to hide images that 
get swapped into the main related part,
+                       // so we do  not show these images on their own
+                       if ($part_nice[$i]['m_description'] == 
'presentable/image')
+                       {
+                               //echo '('.__LINE__.') presentable/image , 
$struct->type ['.$struct->type.'] , $struct->subtype 
['.$struct->subtype.']<br>';
+                               // TEST THIS:
+                               // * IS the parent marked as multipart/related
+                               // and CHECK 2 TIMES: note that we test 2 times
+                               // (1) the first is where the mail has only 2 
parts
+                               // and AngleMail flatening code has left the 
top level headers out of the
+                               // flat array, as it does sometimes.
+                               // (2) The second is for anything deep enough 
so that the parent part IS in the
+                               // flat array, which is more typical.
+                               $presentable_parent_idx = 
$part_nice[$i]['ex_parent_flat_idx'];
+                               if (
+                                  //ok I am an image, is my parent the top 
level headers
+                                  ($part_nice[$i]['ex_parent_flat_idx'] == 
$not_set)
+                               && ((string)$struct->type == '1')  // "1" = 
"multipart"
+                               && (stristr($struct->subtype, 'related'))
+                               )
+                               {
+                                       //echo '('.__LINE__.') 
presentable/image , alt_hide related to top level<br>';
+                                       // SET THIS FLAG: then, in presentation 
loop, we can decide not to show it
+                                       $part_nice[$i]['m_keywords'] .= 
'alt_hide' .' ';
+                               }
+                               // same as above but we do not need to look all 
the way back to the top level headers
+                               // ie because the parent part is included in 
the flat parts array
+                               elseif (
+                                  ($part_nice[$i]['ex_level_debth'] > 1)
+                               && ($part_nice[$presentable_parent_idx]['type'] 
== 'multipart')
+                               && 
($part_nice[$presentable_parent_idx]['subtype'] == 'related')
+                               )
+                               {
+                                       // SET THIS FLAG: then, in presentation 
loop, we can decide not to show it
+                                       $part_nice[$i]['m_keywords'] .= 
'alt_hide' .' ';
+                               }
+                       }
+
                        // ------  EXCEPTIONS TO THE RULES  -------
-
+
                        // = = = = =  Exceptions for Less-Standard Subtypes = = 
= = =
                        //"m_description" set above will work *most all* the 
time. However newer standards
-                       // are encouraged to make use of the "subtype" param, 
not create new "type"s
+                       // are encouraged to make use of the "subtype" param, 
not create new "type"s
                        // the following "multipart/SUBTYPES" should be treated 
as
                        // "container" instead of "packagelist"
-
-                       // (1) Exception: multipart/RELATED: for ex. Outl00k 
Stationary handling
+
+                       // (1a) Exception: multipart/RELATED: for ex. Outl00k 
Stationary handling
                        // where an HTML part has references to other parts 
(images) in it
-                       // treat it's *child* multipart/alternative as 
"container", not as "packagelist"
+                       // the first 2 tests simple set a "m_html_related_kids" 
flag
+                       // the 3rd test is another form of exception concerning 
related parts
+                       // which requires a change to "container" instead of 
"packagelist"
                        $part_nice[$i]['m_html_related_kids'] = False;
                        $parent_idx = $part_nice[$i]['ex_parent_flat_idx'];
-                       if (($part_nice[$i]['ex_level_debth'] > 1)  // does not 
apply to level1, b/c level1 has no parent
+                       // level 1 has no parent in part_nice because we skip 
to presentable stuff
+                       // so in that case we need to check top level headers
+                       if (
+                          ($part_nice[$i]['type'] == 'text')
+                       && ($part_nice[$i]['subtype'] == 'html')
+                       && ($part_nice[$parent_idx]['type'] == 'multipart')
+                       && ($part_nice[$parent_idx]['subtype'] == 'alternative')
+                       && ($part_nice[$parent_idx]['ex_parent_flat_idx'] == 
$not_set)
+                       && (stristr($struct->subtype, 'RELATED'))
+                       )
+                       {
+                               // SET THIS FLAG: then, in presentation loop, 
see if a HTML part
+                               // has a parent with this flag - if so, replace 
"id" reference(s) with
+                               // http... mime reference(s). Example: MS 
Stationary mail's image background
+                               $part_nice[$parent_idx]['m_html_related_kids'] 
= True;
+                               //$part_nice[$i]['m_keywords'] .= 'id_swap' .' 
';
+                               $part_nice[$i]['m_keywords'] .= 'related' .' ';
+                       }
+                       // same as above but we do not need to look all the way 
back to the top level headers
+                       // ie an html part with a parent that is explicitly set 
as RELATED
+                       elseif (
+                          ($part_nice[$i]['ex_level_debth'] > 1)
+                       && ($part_nice[$i]['type'] == 'text')
+                       && ($part_nice[$i]['subtype'] == 'html')
+                       && ($part_nice[$parent_idx]['type'] == 'multipart')
+                       && ($part_nice[$parent_idx]['subtype'] == 'related')
+                       )
+                       {
+                               // SET THIS FLAG: then, in presentation loop, 
see if a HTML part
+                               // has a parent with this flag - if so, replace 
"id" reference(s) with
+                               // http... mime reference(s). Example: MS 
Stationary mail's image background
+                               $part_nice[$parent_idx]['m_html_related_kids'] 
= True;
+                               //$part_nice[$i]['m_keywords'] .= 'id_swap' .' 
';
+                               $part_nice[$i]['m_keywords'] .= 'related' .' ';
+                       }
+                       // (1b) Exception: multipart/RELATED: for ex. Outl00k 
Stationary handling
+                       // where an HTML part has references to other parts 
(images) in it
+                       // treat it's *child* multipart/alternative as 
"container", not as "packagelist"
+                       // similar to above but more serious, MANIPULATE 
"container" vs. "packagelist"
+                       // while also determining is it has related html style 
child parts
+                       elseif (($part_nice[$i]['ex_level_debth'] > 1)  // does 
not apply to level1, b/c level1 has no parent
                        && ($part_nice[$i]['type'] == 'multipart')
                        && ($part_nice[$i]['subtype'] == 'alternative')
                        && ($part_nice[$parent_idx]['type'] == 'multipart')
@@ -1565,13 +1790,40 @@
                                // NOTE: treat it's *child* 
multipart/alternative as "container", not as "packagelist"
                                $part_nice[$i]['m_description'] = 'container';
                                $part_nice[$i]['m_keywords'] .= 'Force 
Container, id_swap' .' ';
-                               // SET THIS FLAG: then, in presentation loop, 
see if a HTML part
-                               // has a parent with this flag - if so, replace 
"id" reference(s) with
+                               // SET THIS FLAG: then, in presentation loop, 
see if a HTML part
+                               // has a parent with this flag - if so, replace 
"id" reference(s) with
                                // http... mime reference(s). Example: MS 
Stationary mail's image background
                                $part_nice[$i]['m_html_related_kids'] = True;
                                $part_nice[$i]['m_keywords'] .= 'id_swap' .' ';
                        }
-
+                       // (1c) Exception: multipart/RELATED: for ex.  
"courier-users digest, Vol 1 #2565 - 6 msgs" segment 3.1
+                       // DAMN this is similar to exception 1b, I wonder if I 
screwed 1b up and 1c is the real thing?
+                       // where an HTML part has references to other parts 
(images) in it
+                       // treat it's *child* multipart/alternative as 
"container", not as "packagelist"
+                       // similar to above but more serious, MANIPULATE 
"container" vs. "packagelist"
+                       // while also determining is it has related html style 
child parts
+                       //this is tricky because it is part of a segment 
alternative, and this is the htm part encased in a related subsegment
+                       // - 3.1.0 segment header (multipart / alternative)
+                       // -- 3.1.1 plain part  (text / plain)
+                       // --- 3.1.2 related subpart (subsegment) in entirety, 
both html part and image part (multipart / related) *** NEEDS TO BE A CONTAINER 
***
+                       // ---- 3.1.2.1 html part of the related segment (text 
/ html)
+                       // ---- 3.1.2.2 image part of the related subsegment  
(image / gif)
+                       elseif (($part_nice[$i]['ex_level_debth'] > 1)  // does 
not apply to level1, b/c level1 has no parent
+                       && ($part_nice[$i]['type'] == 'multipart')
+                       && ($part_nice[$i]['subtype'] == 'related')
+                       && ($part_nice[$parent_idx]['type'] == 'multipart')
+                       && ($part_nice[$parent_idx]['subtype'] == 
'alternative'))
+                       {
+                               // NOTE: treat it's *child* 
multipart/alternative as "container", not as "packagelist"
+                               $part_nice[$i]['m_description'] = 'container';
+                               $part_nice[$i]['m_keywords'] .= 'Force 
Container, id_swap' .' ';
+                               // SET THIS FLAG: then, in presentation loop, 
see if a HTML part
+                               // has a parent with this flag - if so, replace 
"id" reference(s) with
+                               // http... mime reference(s). Example: MS 
Stationary mail's image background
+                               $part_nice[$i]['m_html_related_kids'] = True;
+                               $part_nice[$i]['m_keywords'] .= 'id_swap' .' ';
+                       }
+
                        // (2) Exception: multipart/APPLEDOUBLE  (ex. mac thru 
X.400 gateway)
                        // treat as "container", not as "packagelist"
                        if (($part_nice[$i]['type'] == 'multipart')
@@ -1580,18 +1832,18 @@
                                $part_nice[$i]['m_description'] = 'container';
                                $part_nice[$i]['m_keywords'] .= 'Force 
Container' .' ';
                        }
-
+
                        // ------  MAKE "SMART" MIME PART NUMBER  -------
-
+
                        // ---Use Mime Number Dumb To Make ex_mime_number_smart
                        $new_mime_dumb = $part_nice[$i]['ex_mime_number_dumb'];
                        $part_nice[$i]['ex_mime_number_smart'] = 
$this->mime_number_smart($part_nice, $i, $new_mime_dumb);
-
+
                        // -----   Make Smart Mime Number THE PRIMARY MIME 
NUMBER we will use
                        //$part_nice[$i]['m_part_num_mime'] = 
$part_nice[$i]['ex_mime_number_smart'];

                        // TEMPORARY HACK FOR SOCKET POP3 CLASS - feed it DUMB 
mime part numbers
-
+
                        if 
((isset($GLOBALS['phpgw_dcom_'.$this->acctnum]->dcom->imap_builtin))
                        && 
($GLOBALS['phpgw_dcom_'.$this->acctnum]->dcom->imap_builtin == False)
                        && (stristr($this->get_pref_value('mail_server_type'), 
'pop3')))
@@ -1604,32 +1856,34 @@
                                // Make Smart Mime Number THE PRIMARY MIME 
NUMBER we will use
                                $part_nice[$i]['m_part_num_mime'] = 
$part_nice[$i]['ex_mime_number_smart'];
                        }
-
+
                        // ------  MAKE CLICKABLE HREF TO THIS PART  -------
-
+
                        // make an URL and a Clickable Link to directly acces 
this part
                        //$click_info = 
$this->make_part_clickable($part_nice[$i], $this->get_arg_value('folder'), 
$this->get_arg_value('["msgball"]["msgnum"]'));
                        $click_info = 
$this->make_part_clickable($part_nice[$i], $this->get_arg_value('msgball'));
                        $part_nice[$i]['ex_part_href'] = 
$click_info['part_href'];
                        $part_nice[$i]['ex_part_clickable'] = 
$click_info['part_clickable'];
-               }
-
+               }
+
                // finally, return the customized flat phpgw msg structure array
+               if ($this->debug_message_display > 2) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct: returning $part_nice 
DUMP:', $part_nice); }
+               if ($this->debug_message_display > 0) { 
$this->dbug->out('mail_msg(display).get_flat_pgw_struct: LEAVING we made a 
$part_nice, returning it<br>'); }
                return $part_nice;
        }

        /*!
        @function pgw_msg_struct
-       @abstract Mime analysis, make multilevel php message structure into a 
flat array with human understandable information.
-       @param $part
-       @param $parent_flat_idx
-       @param $feed_dumb_mime
-       @param $feed_i
-       @param $feed_loops
-       @param $feed_debth
-       @discussion Part of the home grown MIME analysis in this app. This 
function is used by the
-       big loop stuff in function "get_flat_pgw_struct", I can not remember 
what all these params do
-       at this moment.
+       @abstract Mime analysis, make multilevel php message structure into a 
flat array with human understandable information.
+       @param $part
+       @param $parent_flat_idx
+       @param $feed_dumb_mime
+       @param $feed_i
+       @param $feed_loops
+       @param $feed_debth
+       @discussion Part of the home grown MIME analysis in this app. This 
function is used by the
+       big loop stuff in function "get_flat_pgw_struct", I can not remember 
what all these params do
+       at this moment.
        @author Angles
        */
        function pgw_msg_struct($part, $parent_flat_idx, $feed_dumb_mime, 
$feed_i, $feed_loops, $feed_debth)
@@ -1642,19 +1896,21 @@
                {
                        $not_set = '-1';
                }
-
+
                //echo 'BEGIN pgw_msg_struct<br>';
                //echo var_dump($part);
                //echo '<br>';
-
+
                // TRANSLATE PART STRUCTURE CONSTANTS INTO STRINGS OR TRUE/FALSE
                // see php manual page function.imap-fetchstructure.php
-
+
                // 1: TYPE
                $part_nice['type'] = $not_set; // Default value if not filled
-               if (isset($part->type) && $part->type)
+               // note that 0 (the number ZERO) IS A VALID possible value 
here, so 0 != not filled !
+               if ((isset($part->type))
+               && (trim((string)$part->type) != ''))
                {
-                       switch ($part->type)
+                       switch ((int)$part->type)
                        {
                                case TYPETEXT           : $part_type = 'text'; 
break;
                                case TYPEMULTIPART      : $part_type = 
'multipart'; break;
@@ -1676,12 +1932,14 @@
                {
                        $part_nice['type'] = 'text';
                }
-
+
                // 2: ENCODING
                $part_nice['encoding'] = $not_set; // Default value if not 
filled
-               if (isset($part->encoding) && $part->encoding)
+               // note that 0 (the number ZERO) IS A VALID possible value 
here, so 0 != not filled !
+               if ((isset($part->encoding))
+               && (trim((string)$part->encoding) != ''))
                {
-                       switch ($part->encoding)
+                       switch ((int)$part->encoding)
                        {
                                case ENC7BIT            : $part_encoding = 
'7bit'; break;
                                case ENC8BIT            : $part_encoding = 
'8bit'; break;
@@ -1816,7 +2074,7 @@
                        }
                }
                // ADDITIONAL INFORMATION (often uses array key "ex_" )
-
+
                // "dumb" mime part number based only on array position, will 
be made "smart" later
                $part_nice['ex_mime_number_dumb'] = $feed_dumb_mime;
                $part_nice['ex_parent_flat_idx'] = $parent_flat_idx;
@@ -1824,45 +2082,45 @@
                $part_nice['ex_level_iteration'] = $feed_i;
                $part_nice['ex_level_max_loops'] = $feed_loops;
                $part_nice['ex_level_debth'] = $feed_debth;
-
+
                //echo 'BEGIN DUMP<br>';
                //echo var_dump($part_nice);
                //echo '<br>END DUMP<br>';
-
+
                return $part_nice;
        }


        /*!
        @function mime_number_smart
-       @abstract Make a "dumb" mime part number (based only on array position) 
into a "Smart" mime
-       number that a server understands as per the RFC for IMAP.
-       @param $part_nice
-       @param $flat_idx
-       @param $new_mime_dumb
-       @discussion Part of the home grown MIME analysis in this app. So called 
"dumb" mime number is
-       based only on the zero based array location of the part. The array is 
like a tree, the numbers like
-       branches, all in numerical sequence. However, to get a MIME part from a 
server the "dumb" number
-       must be changed into the kind of part numbering as per the RFC for 
IMAP. As an aside, note that in
-       certain places where I know I am using the sockets class, not the PHP 
imap extension, I take a shortcut
-       and pass the "dumb" number to the sockets dcom class because it is 
easier to do straing array number location.
-       However, for any situation interacting with a real IMAP server requires 
the "smart" conversion done
-       in this function.
+       @abstract Make a "dumb" mime part number (based only on array position) 
into a "Smart" mime
+       number that a server understands as per the RFC for IMAP.
+       @param $part_nice
+       @param $flat_idx
+       @param $new_mime_dumb
+       @discussion Part of the home grown MIME analysis in this app. So called 
"dumb" mime number is
+       based only on the zero based array location of the part. The array is 
like a tree, the numbers like
+       branches, all in numerical sequence. However, to get a MIME part from a 
server the "dumb" number
+       must be changed into the kind of part numbering as per the RFC for 
IMAP. As an aside, note that in
+       certain places where I know I am using the sockets class, not the PHP 
imap extension, I take a shortcut
+       and pass the "dumb" number to the sockets dcom class because it is 
easier to do straing array number location.
+       However, for any situation interacting with a real IMAP server requires 
the "smart" conversion done
+       in this function.
        @author Angles
        */
        function mime_number_smart($part_nice, $flat_idx, $new_mime_dumb)
        {
                $not_set = $this->not_set;
-
+
                // ---- Construct a "Smart" mime number
-
+
                //$debug = True;
                $debug = False;
                //if (($flat_idx >= 25) && ($flat_idx <= 100))
                //{
                //      $debug = True;
                //}
-
+
                if ($debug) { $this->dbug->out('ENTER mime_number_smart<br>'); }
                if ($debug) { $this->dbug->out('fed var flat_idx: '. 
$flat_idx.'<br>'); }
                if ($debug) { $this->dbug->out('fed var new_mime_dumb: '. 
$new_mime_dumb.'<br>'); }
@@ -1872,7 +2130,7 @@
                        $smart_mime_number = 'error 1 in mime_number_smart';
                        break;
                }
-
+
                // explode new_mime_dumb into an array
                $exploded_mime_dumb = Array();
                if (strlen($new_mime_dumb) == 1)
@@ -1885,14 +2143,14 @@
                        if ($debug) { $this->dbug->out('strlen(new_mime_dumb) = 
1 :: FALSE<br>'); }
                        $exploded_mime_dumb = explode('.', $new_mime_dumb);
                }
-
+
                // cast all values in exploded_mime_dumb as integers
                for ($i = 0; $i < count($exploded_mime_dumb); $i++)
                {
                        $exploded_mime_dumb[$i] = (int)$exploded_mime_dumb[$i];
                }
                if ($debug) { $this->dbug->out('exploded_mime_dumb 
'.serialize($exploded_mime_dumb).'<br>'); }
-
+
                // make an array of all parts of this family tree,  from the 
current part (the outermost) to innermost (closest to debth level 1)
                $dumbs_part_nice = Array();
                //loop BACKWARDS
@@ -1915,11 +2173,11 @@
                }
                //if ($debug) { $this->dbug->out('dumbs_part_nice serialized: 
'.serialize($dumbs_part_nice) .'<br>'); }
                //if ($debug) { $this->dbug->out('serialize exploded_mime_dumb: 
'.serialize($exploded_mime_dumb).'<br>'); }
-
+
                // NOTE:  Packagelist -> Container EXCEPTION Conversions
                // a.k.a "Exceptions for Less-Standart Subtypes"
                // are located in the analysis loop done that BEFORE you enter 
this function
-
+
                // Reconstruct the Dumb Mime Number string into a "SMART" Mime 
Number string
                // RULE:  Dumb Mime parts that have "m_description" = 
"packagelist" (i.e. it's a header part)
                //      should be ommitted when constructing the Smart Mime 
Number
@@ -1927,7 +2185,7 @@
                //      (a) debth 1 parts that are "packagelist" *never* get 
altered in any way
                //      (b) outermost debth parts that are "packagelist" get a 
value of "0", not ommitted
                //      (c) for 2 "packagelist"s in sucession, the first one 
gets a "1", not ommitted
-
+
                // apply the rules
                $smart_mime_number_array = Array();
                for ($i = 0; $i < count($dumbs_part_nice); $i++)
@@ -1968,7 +2226,7 @@
                                }
                        }
                }
-
+
                // for 2 "packagelist"s in sucession, the first one gets a "1", 
not ommitted
                for ($i = 0; $i < count($dumbs_part_nice); $i++)
                {
@@ -1979,7 +2237,7 @@
                                $smart_mime_number_array[$i-1] = 1;
                        }
                }
-
+
                // make the "smart mime number" based on the info gathered and 
the above rules
                // as applied to the smart_mime_number_array
                $smart_mime_number = '';
@@ -2001,20 +2259,20 @@

        /*!
        @function make_part_clickable
-       @abstract message text which could be an href or mail to can be made 
clickable.
-       @param $part_nice
-       @param $msgball
+       @abstract message text which could be an href or mail to can be made 
clickable.
+       @param $part_nice
+       @param $msgball
        @author Inherited from previous maintainer, Angles refined only
        */
        function make_part_clickable($part_nice, $msgball)
        {
                $not_set = $this->not_set;
-
+
                // Part Number used to request parts from the server
                $m_part_num_mime = $part_nice['m_part_num_mime'];
-
+
                $part_name = $part_nice['ex_part_name'];
-
+
                // make a URL to directly access this part
                if ($part_nice['type'] != $not_set)
                {
@@ -2050,9 +2308,11 @@
                        .'&type=' .$url_part_type
                        .'&subtype=' .$url_part_subtype
                        .'&name=' .$url_part_name
-                       .'&encoding=' .$url_part_encoding);
+                       .'&encoding=' .$url_part_encoding);
                // Make CLICKABLE link directly to this attachment or part
                $href_part_name = $this->decode_header_string($part_name);
+               // escape certain undesirable chars before HTML display
+               $href_part_name = 
$this->htmlspecialchars_encode($href_part_name);
                // ex_part_clickable
                $ex_part_clickable = '<a 
href="'.$ex_part_href.'">'.$href_part_name.'</a>';
                // put these two vars in an array, and pass it back to the 
calling process
@@ -2066,10 +2326,10 @@
        @function make_clickable
        @abstract message text which could be an href or mail to can be made 
clickable.
        @author See Discussion
-       @discussion This code inherited from previous maintainer, who said this 
-
+       @discussion This code inherited from previous maintainer, who said this 
-
        function make_clickable taken from text_to_links() in the SourceForge 
Snipplet Library
        http://sourceforge.net/snippet/detail.php?type=snippet&id=100004
-       modified to make mailto: addresses compose in phpGW (not by Angles)
+       modified to make mailto: addresses compose in phpGW (not by Angles)
        */
        function make_clickable($data, $folder)
        {
@@ -2087,6 +2347,7 @@
                        $line = eregi_replace("(http://[^ )\r\n]+)","<A 
href=\"\\1\" target=\"_new\">\\1</A>",$line);
                        $line = eregi_replace("(https://[^ )\r\n]+)","<A 
href=\"\\1\" target=\"_new\">\\1</A>",$line);
                        $line = eregi_replace("(ftp://[^ )\r\n]+)","<A 
href=\"\\1\" target=\"_new\">\\1</A>",$line);
+                       $line = eregi_replace("(irc://[^ )\r\n]+)","<A 
href=\"\\1\">\\1</A>",$line);//added by skwashd for chatzilla :)
                        $line = 
eregi_replace("([-a-z0-9_]+(\.[_a-z0-9-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)+))",
                                "<a 
href=\"".$GLOBALS['phpgw']->link("/".$GLOBALS['phpgw_info']['flags']['currentapp']."/compose.php","folder=".$this->prep_folder_out($folder))
                                ."&to=\\1\">\\1</a>", $line);
@@ -2100,7 +2361,7 @@
        @function has_this_param
        @abstract does a MIME param array contain a certain attribute.
        @param $param_array
-       @param $needle
+       @param $needle
        @author Angles
        @discussion can take as input either a php structure or an anglemail 
flat part array.
        For example, an attribute could be "filename" and its value could be 
"image.png", this
@@ -2148,7 +2409,7 @@
        /*!
        @function array_keys_str
        @abstract debug function, report all "keys" in an associative array of 
"key - value"
-       @param $my_array
+       @param $my_array
        @author Angles
        */
        function array_keys_str($my_array)
@@ -2164,8 +2425,8 @@
        @param none, it uses the class args described below in "discussion"
        @result string which has either (a) a langed report to show the user 
about the move or delete that just occured
        or (b) an empty string indicating no move or delete actions were taken, 
so none need to report anything
-       @discussion See the example for the discussion.
-       @example This is really the discussion. This function uses the 
following class args
+       @discussion See the example for the discussion.
+       @example This is really the discussion. This function uses the 
following class args
          ['args']['td']        "td" means "Total Deleted", if it's filled it 
contains the number of messages that were deleted
          ['args']['tm']        "tm" means "Total Moved", if it's filled it 
contains the number of messages that were moved
          ['args']['tf']        "tf" means "To Folder", if it's filled it 
contains the name of the folder that messages were moved to
@@ -2206,25 +2467,28 @@
                        && ($this->get_arg_value('tf') != ''))
                        {
                                $_tf = 
$this->prep_folder_in($this->get_arg_value('tf'));
+                               // NOTE if the folder name has html unfriendly 
chars, like " or <, we need to do this just in case
+                               //echo '$this->htmlspecialchars_encode($_tf) 
['.$this->htmlspecialchars_encode($_tf).'] <br>';
+                               $_tf = $this->htmlspecialchars_encode($_tf);
                        }
                        else
                        {
                                $_tf = 'empty';
                        }
                        // with the name of the "To Folder" we can build our 
report string
-                       if ($this->get_arg_value('tm') == 0)
+                       if ($this->get_arg_value('tm') == 0)
                        {
                                // these args are filled, indicating a MOVE was 
attempted
                                // but since 0 messages were in fact moved, 
there must have been an error
-                               $report_this = lang("Error moving messages 
to").' '.$_tf;
+                               $report_this = lang('Error moving messages 
to').' '.$_tf;
                        }
                        elseif ($this->get_arg_value('tm') == 1)
                        {
-                               $report_this = lang("1 message has been moved 
to").' '.$_tf;
+                               $report_this = lang('1 message has been moved 
to').' '.$_tf;
                        }
                        else
                        {
-                               $report_this = $this->get_arg_value('tm').' 
'.lang("messages have been moved to").' '.$_tf;
+                               $report_this = $this->get_arg_value('tm').' 
'.lang('messages have been moved to').' '.$_tf;
                        }
                }
                else
@@ -2257,24 +2521,24 @@

        /*!
        @function report_total_foldersize_conditional
-       @abstract MAYBE get the total of all messges sizes in a folder added up 
to "folder size" ONLY IF SPECIFIED.
-       @param $force_showsize (boolean) OPTIONAL, if not provided the arg 
value "force_showsize" is used, if available,
-       which is usually submitted via GPC by the user. However, if this param 
IS provided, it is used instead
-       of the arg value (overriding the arg value). In which case, if True, 
then we really so get the size, if False this function
-       does NOT get the size. If neither the arg value not this param are 
specified, the default is False, do not
-       get size data.
+       @abstract MAYBE get the total of all messges sizes in a folder added up 
to "folder size" ONLY IF SPECIFIED.
+       @param $force_showsize (boolean) OPTIONAL, if not provided the arg 
value "force_showsize" is used, if available,
+       which is usually submitted via GPC by the user. However, if this param 
IS provided, it is used instead
+       of the arg value (overriding the arg value). In which case, if True, 
then we really so get the size, if False this function
+       does NOT get the size. If neither the arg value not this param are 
specified, the default is False, do not
+       get size data.
        @result string, either (a) folder size nicely formatted for human 
readability, or (b) an empty string
        if it was not OK to obtain the data according to the speed skip test
-       @discussion  total size of all emails in this folder added up, if its 
OK to get that data.
-       Getting folder size *can* take long time if alot of mail is in the 
folder, which put unneeded load on the IMAP server,
+       @discussion  total size of all emails in this folder added up, if its 
OK to get that data.
+       Getting folder size *can* take long time if alot of mail is in the 
folder, which put unneeded load on the IMAP server,
        Additionally, there are 2 ways to get folder stats about a folder, one 
way ALWAYS requests the size from
-       the mailserver, the other way does NOT request the size from the 
mailserver. For speed reasons,
-       we only use the way that does NOT ask for the size, and additionally we 
may cache that data too.
-       However, if the user specifically requests the folder size, only then 
do we actually use the IMAP function
-       that will return the size. If various logic determines we are 
specifically to get the size data, then we
-       get the data and return it in human formatted format. Otherwise we do 
NOT get the size, and return
-       an empty string.
-       @author Angles
+       the mailserver, the other way does NOT request the size from the 
mailserver. For speed reasons,
+       we only use the way that does NOT ask for the size, and additionally we 
may cache that data too.
+       However, if the user specifically requests the folder size, only then 
do we actually use the IMAP function
+       that will return the size. If various logic determines we are 
specifically to get the size data, then we
+       get the data and return it in human formatted format. Otherwise we do 
NOT get the size, and return
+       an empty string.
+       @author Angles
        */
        function 
report_total_foldersize_conditional($force_showsize='##NOTHING##')
        {
@@ -2297,11 +2561,16 @@
                        // in this case, user has requested override of this 
speed skip option
                        $do_show_size = True;
                }
+               elseif ($this->get_isset_pref('show_foldersize'))
+               {
+                       // user has set the pref to always show the size of the 
folder
+                       $do_show_size = True;
+               }
                // if we get to here and $do_show_size  has not specifically 
been set to True, then False is the fallback default
-
+
                // if it's ok to obtain size, and size IS obtained, this 
$return_folder_size will be filled
                $return_folder_size = '';
-
+
                // ----  Get The Folder Size if it's OK  ----
                if ($do_show_size)
                {
@@ -2311,35 +2580,35 @@
                }
                return $return_folder_size;
        }
-
+
        /*!
        @function get_msg_list_display
        @abstract make an array containing all necessary data to display an 
"index.php" type list of mesasages
-       @param $folder_info (array) OPTIONAL. Array elements as defined in 
return from
-       function "get_folder_status_info". This is primarily a time saver, if 
you already have the data,
-       then pass it, else this function will obtain the data for itself.
-       @param $folder_info (array of integers) OPTIONAL. integers representing 
a list of message numbers we
-       should display, pass this data if you have search results to show, for 
example. If this is not present,
-       then this function get a numbered array list of all message numbers in 
that folder, sorted and ordered
-       according to preferences and/or user submitted page view args.
-       @result array See Example for an explanation of what is in the returned 
array.
-       @discussion Kind of a "black box" function to generate all data needed 
to make a message
-       list page. This function returns an associative array of data only, no 
markup (I think).
-       See the Example for more information.
-       @example This is the structure of the associative array returned by 
this function.
+       @param $folder_info (array) OPTIONAL. Array elements as defined in 
return from
+       function "get_folder_status_info". This is primarily a time saver, if 
you already have the data,
+       then pass it, else this function will obtain the data for itself.
+       @param $folder_info (array of integers) OPTIONAL. integers representing 
a list of message numbers we
+       should display, pass this data if you have search results to show, for 
example. If this is not present,
+       then this function get a numbered array list of all message numbers in 
that folder, sorted and ordered
+       according to preferences and/or user submitted page view args.
+       @result array See Example for an explanation of what is in the returned 
array.
+       @discussion Kind of a "black box" function to generate all data needed 
to make a message
+       list page. This function returns an associative array of data only, no 
markup (I think).
+       See the Example for more information.
+       @example This is the structure of the associative array returned by 
this function.
        "first_item" boolean, flag indicating this is the first item in the 
array, the first message
                to display, states the obvious, but the index tpl uses it to 
show a form tag only once
        "back_color" used in html UI's to alternate the color or each row of 
data
        "has_attachment" attachment dection code has determined that this 
message has attachment(s)
                which tells the UI to show the user something, like a paperclip 
image.
-       "msgnum" the number the mail server has assigned this message, used for 
fetching.
-       "subject" message subject text suitable for display, text only.
+       "msgnum" the number the mail server has assigned this message, used for 
fetching.
+       "subject" message subject text suitable for display, text only.
        "subject_link" URL that will request this message from the server, use 
with "subject" to make an HREF
        "size" message size suitable for display
-       "is_unseen" this message has NOT yet been viewed by the client.
-       "from_name" Part 1 of 2 of the From String to show the user. This part 
1 is the "personal"
-               data of the From person if it's available, if not we have no 
choice but to show
-               the plain address of the from person.
+       "is_unseen" this message has NOT yet been viewed by the client.
+       "from_name" Part 1 of 2 of the From String to show the user. This part 
1 is the "personal"
+               data of the From person if it's available, if not we have no 
choice but to show
+               the plain address of the from person.
        "display_address_from" Part 2 of 2 of the From String to show the user. 
This part 2 contains
                any additional info the user prefers to see in the From String, 
which can be either
                (a) the plain address of the From person, or
@@ -2373,7 +2642,7 @@
                //$debug_msg_list_display = 3;
                $debug_msg_list_display = $this->debug_index_page_display;
                if ($debug_msg_list_display > 0) { 
$this->dbug->out('mail_msg_display: get_msg_list_display('.__LINE__.'): 
ENTERING<br>'); }
-
+
                if(!$folder_info)
                {
                        $folder_info=array();
@@ -2391,21 +2660,21 @@
                        $folder_info = array();
                        $folder_info = $this->get_folder_status_info();
                        /*!
-                       @capability get_folder_status_info info used in the 
get_msg_list_display function.
-                       @discussion Duhhh, why is this document info here, it 
belongs with the
-                       "get_folder_status_info" itself. Anyway, here goes.
-                       Recall that the "get_folder_status_info" function 
returns this array.
-                       UPDATE ME this has changed some.
-                       @example UPDATE ME this should be moved to the 
"get_folder_status_info" doc string itself.
+                       @capability get_folder_status_info info used in the 
get_msg_list_display function.
+                       @discussion Duhhh, why is this document info here, it 
belongs with the
+                       "get_folder_status_info" itself. Anyway, here goes.
+                       Recall that the "get_folder_status_info" function 
returns this array.
+                       UPDATE ME this has changed some.
+                       @example UPDATE ME this should be moved to the 
"get_folder_status_info" doc string itself.
                        folder_info["is_imap"] boolean - pop3 server do not 
know what is "new" or not, IMAP servers do
                        folder_info["folder_checked"] string - the folder 
checked, as processed by the msg class, which may have done a lookup on the 
folder name
                        folder_info["alert_string"] string - langd string to 
show the user about status of new messages in this folder
                        folder_info["number_new"] integer - for IMAP the number 
"recent" and/or "unseen"messages, for POP3 the total number of messages
                        folder_info["number_all"] integer - for IMAP and POP3 
the total number messages in the folder
-                       and some validity data used for caching.
+                       and some validity data used for caching.
                        */
                }
-
+
                // initialize return structure
                $msg_list_display = Array();
                // if no message are available to show, return an empty aray
@@ -2413,29 +2682,37 @@
                {
                        return $msg_list_display;
                }
-
+
                // we have messages to list, continue...
                // if we were passed an array of message numbers to show, use 
that, if not then
                // get a numbered array list of all message numbers in that 
folder, sorted and ordered
                if (!$msgball_list)
                {
+                       // NOW WE USE FOLDER NAME ALSO IN THE DATA KEY FOR 
MSGBALL_LIST
+                       $ex_folder = $folder_info['fldball']['folder'];
+
                        // msgball_list may be thousands of items, try to fill 
the cache and get a reference
                        //GLOBALS[phpgw_session][phpgw_app_sessions][email]
-                       $this->get_msgball_list();
-                       $ex_acctnum = $this->get_acctnum();
+                       // fill the cache ? - NO this is folly
+                       //$this->get_msgball_list();
+                       //$ex_acctnum = $this->get_acctnum();
+                       // TESTING get the acctnum from the folder info
+                       $ex_acctnum = $folder_info['fldball']['acctnum'];
                        if (($this->session_cache_enabled == True)
-                       && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'])))
+                       && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list'][$ex_folder]['msgball_list'])))
                        //&& 
(isset($GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'])))
                        {
-                               $msgball_list =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'];
+                               $msgball_list =& 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list'][$ex_folder]['msgball_list'];
                                //$msgball_list =& 
$GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'];
-                               //{ echo 'mail_msg_display: 
get_msg_list_display('.__LINE__.'): $msgball_list *REFERENCE* DUMP:<pre>'; 
print_r($msgball_list); echo '</pre>'; }
+                               //{ echo 'mail_msg_display: 
get_msg_list_display('.__LINE__.'): $msgball_list *REFERENCE* DUMP:<pre>'; 
print_r($msgball_list); echo '</pre>'; }
                                //$msgball_list = 
$GLOBALS['phpgw_session']['phpgw_app_sessions']['email']['dat'][$ex_acctnum]['msgball_list']['msgball_list'];
                        }
                        else
                        {
                                // ok we could not obtain a reference for some 
reason, get a COPY then
-                               $msgball_list = $this->get_msgball_list();
+                               //$msgball_list = $this->get_msgball_list();
+                               // EXPERIMENT with passing arge to this
+                               $msgball_list = 
$this->get_msgball_list($ex_acctnum, $ex_folder);
                        }
                }

@@ -2451,7 +2728,7 @@
                {
                        $totaltodisplay = $folder_info['number_all'];
                }
-
+
                if ($this->get_isset_arg('start'))
                {
                        $start = $this->get_arg_value('start');
@@ -2465,7 +2742,7 @@
                for ($i=$start; $i < $totaltodisplay; $i++)
                {
                        $this_loop_msgball = 
$this->ball_data_parse_str($msgball_list[$i]);
-                       if ($debug_msg_list_display > 2) { 
$this->dbug->out('mail_msg_display: get_msg_list_display: $msgball_list['.$i.'] 
['.$msgball_list[$i].'] $this_loop_msgball data DUMP:', $this_loop_msgball); }
+                       if ($debug_msg_list_display > 2) { 
$this->dbug->out('mail_msg_display: get_msg_list_display: $msgball_list['.$i.'] 
['.$msgball_list[$i].'] $this_loop_msgball data DUMP:', $this_loop_msgball); }
                        // we use $x to sequentially fill the $msg_list_display 
array
                        //$x++;
                        $x = $x + 1;
@@ -2488,18 +2765,18 @@
                        ////$msg_list_display[$x]['back_color'] = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($msg_list_display[$x-1]['back_color']);

                        /*!
-                       @capability Inside "get_msg_list_display", SHOW 
ATTACHMENT CLIP issue.
+                       @capability Inside "get_msg_list_display", SHOW 
ATTACHMENT CLIP issue.
                        @discussion SKIP this for POP3 - fetchstructure for 
POP3 requires download the WHOLE msg
-                       so PHP can build the fetchstructure data (IMAP server 
does this internally). This
-                       applies to builtin IMAP extension and the sockets POP3 
class.
+                       so PHP can build the fetchstructure data (IMAP server 
does this internally). This
+                       applies to builtin IMAP extension and the sockets POP3 
class.
                        */
-
+
                        //      THIS skips attachmant check only for POP3 
socket (not build in) situations
                        //if 
((isset($GLOBALS['phpgw_dcom_'.$this->acctnum]->dcom->imap_builtin))
                        //&& 
($GLOBALS['phpgw_dcom_'.$this->acctnum]->dcom->imap_builtin == False)
                        //&& 
(stristr($this->get_pref_value('mail_server_type'), 'pop3')))
                        // ... but ...
-                       //      THIS skips attachment check for ALL POP3 
situations
+                       //      THIS skips attachment check for ALL POP3 
situations
                        //      it is WAY SLOW to check for attachments like 
this with POP3
                        if (stristr($this->get_pref_value('mail_server_type'), 
'pop3'))
                        {
@@ -2513,16 +2790,64 @@
                                // now examine that msg_struct for signs of an 
attachment
                                $msg_list_display[$x]['has_attachment'] = 
$this->has_real_attachment($msg_structure);
                        }
-
+
                        // Message Information: THE MESSAGE'S HEADERS ENVELOPE 
DATA
                        $hdr_envelope = $this->phpgw_header($this_loop_msgball);
-
+
+                       /*
+                       // begin GMT handling by "acros"
+                       // pongo bien la hora de los correos (GMT)
+#                      echo"hora inicial $hdr_envelope->date<br>";
+#                                              echo"hora inicial 
$hdr_envelope->udate<br>";
+///modificacion
+$msg_date2=$hdr_envelope->date;
+$comma = strpos($msg_date2,',');
+                       if($comma)
+                       {
+                               $msg_date2 = substr($msg_date2,$comma + 2);
+                       }
+                       //echo 'Msg Date : '.$msg_date."<br>\n";
+                       $dta = array();
+                       $ta = array();
+
+                       $dta = explode(' ',$msg_date2);
+                       $ta = explode(':',$dta[3]);
+                       if(substr($dta[4],0,3) <> 'GMT')
+                       {
+                               $tzoffset = substr($dta[4],0,1);
+                               (int)$tzhours = substr($dta[4],1,2);
+                               (int)$tzmins = substr($dta[4],3,2);
+#echo"$ta[0] y $tzoffset";
+                               switch ($tzoffset)
+                               {
+                                       case '+':
+                                               (int)$ta[0] -= (int)$tzhours;
+                                               (int)$ta[1] -= (int)$tzmins;
+#echo"$ta[0]";
+                                               break;
+                                       case '-':
+                                               (int)$ta[0] += (int)$tzhours;
+                                               (int)$ta[1] += (int)$tzmins;
+                                               break;
+                               }
+                       }
+
+                       $new_time = 
mktime($ta[0],$ta[1],$ta[2],$GLOBALS['month_array'][strtolower($dta[1])],$dta[0],$dta[2])
 - ((60 * 60) * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tzoffset']));
+$new_time2=gmdate("D, d M Y H:m:s",$new_time)." GMT";
+$hdr_envelope->date = $new_time2;
+$hdr_envelope->udate = $new_time;
+#echo"hora final $hdr_envelope->udate<br>";
+#echo"hora final $hdr_envelope->date<br>";
+                       #$message_date = 
$GLOBALS['phpgw']->common->show_date($msg_headers->udate);
+//fin modificacion
+// end GMT handling by "acros"
+                       */
                        // MESSAGE REFERENCE (a) NUMBER (b) FOLDER (c) ACCTNUM 
and (d) FAKE_URL EMBEDDED MULTI DATA
                        $msg_list_display[$x]['msgnum'] = 
$this_loop_msgball['msgnum'];
                        $msg_list_display[$x]['folder'] = 
$this_loop_msgball['folder'];
                        $msg_list_display[$x]['acctnum'] = 
$this_loop_msgball['acctnum'];
                        $msg_list_display[$x]['uri'] = 
$this_loop_msgball['uri'];
-
+
                        // SUBJECT
                        // NOTE: the acctnum MUST be matched to this individual 
message and folder
                        $msg_list_display[$x]['subject'] = 
$this->get_subject($hdr_envelope,'');
@@ -2533,7 +2858,7 @@
                                                        
.'&sort='.$this->get_arg_value('sort')
                                                        
.'&order='.$this->get_arg_value('order')
                                                        
.'&start='.$this->get_arg_value('start'));
-
+
                        // SIZE
                        if ($this->newsmode)
                        {
@@ -2545,7 +2870,7 @@
                        {
                                $msg_list_display[$x]['size'] = 
$this->format_byte_size($hdr_envelope->Size);
                        }
-
+
                        // FLAG HANDLING - initialize some vars
                        $msg_list_display[$x]['is_unseen'] = False;
                        $msg_list_display[$x]['is_answered'] = False;
@@ -2559,26 +2884,26 @@
                        if (stristr($msg_list_display[$x]['flags'], 'Seen') == 
False)
                        {
                                $msg_list_display[$x]['is_unseen'] = True;
-                       }
+                       }
                        if (stristr($msg_list_display[$x]['flags'], 'Answered'))
                        {
                                $msg_list_display[$x]['is_answered'] = True;
-                       }
+                       }
                        if (stristr($msg_list_display[$x]['flags'], 'Flagged'))
                        {
                                $msg_list_display[$x]['is_flagged'] = True;
-                       }
+                       }
                        if (stristr($msg_list_display[$x]['flags'], 'Deleted'))
                        {
                                $msg_list_display[$x]['is_deleted'] = True;
-                       }
+                       }
                        if (stristr($msg_list_display[$x]['flags'], 'Draft'))
                        {
                                $msg_list_display[$x]['is_draft'] = True;
-                       }
+                       }

                        // FROM and REPLY TO  HANDLING
-
+
                        // ---- What to use as From Person's target email 
address  ----
                        // $reply is used to construct the "from link" below, 
it determines the target address
                        // to send mail to when the user clicks on a clickable 
"from string" that is an HREF
@@ -2599,14 +2924,14 @@
                        }
                        //$replyto = $this->make_rfc2822_address($reply);
                        $replyto = $reply->mailbox.'@'.$reply->host;
-
+
                        /*!
                        @capability FROM DISPLAYABLE String
                        @abstract  display the "from" data according to user 
preferences
-                       @result   string which is actually part 2 of 2 of the 
From String,
+                       @result   string which is actually part 2 of 2 of the 
From String,
                        with "from_name" being part 1 of 2.
-                       @discussion See the Example for some background on the 
terms used here.
-                       @example First some background on the terms used here
+                       @discussion See the Example for some background on the 
terms used here.
+                       @example First some background on the terms used here
                        * "plain address" means the "address@hidden" part
                        * "personal" means the name string that may be 
associated with that address
                                in the headers that would look like this if 
present: "Joe Dough" &lt;address@hidden&gt;
@@ -2617,7 +2942,7 @@
                        of course, if the personal data is not available, then 
we show the plain anyway
                        ISSUE 3: and if that plain address should be the "from" 
or "reply to (if any)" as the plain address part
                        of the display string. There IS actually an option to 
display the plain address of the specified
-                       "ReplyTo" header in the From String the user wants to 
see.
+                       "ReplyTo" header in the From String the user wants to 
see.
                        */
                        $from = $hdr_envelope->from[0];
                        if (!$from->personal)
@@ -2633,7 +2958,9 @@
                        {
                                $personal = $replyto;
                        }
-
+                       // escape certain undesirable chars before HTML display
+                       $personal = $this->htmlspecialchars_encode($personal);
+
                        if (($this->get_pref_value('show_addresses') == 'from')
                        && ($personal != $from->mailbox.'@'.$from->host))
                        {
@@ -2654,7 +2981,7 @@
                                @capabability From String includes ReplyTo 
plain address
                                @discussion  according to preferences, for the 
displayed "From" string the user wants to
                                see the "personal" data AND the plain address 
of the "ReplyTo" header, if available.
-                               To visually indicate this is reply to address, 
we surround in in < >
+                               To visually indicate this is reply to address, 
we surround in in < >
                                instead of ( ) which we use to surround the 
"from" plain address, as used above.
                                Note: even though we use the "personal" name 
from the From header, we show
                                with it the plain address from the ReplyTo 
header. This is how this preference works :)
@@ -2667,7 +2994,7 @@
                        {
                                /*!
                                @capabability user sees ONLY the "plain 
address" of the From person
-                               @discussion  The displayed "From String" the 
user will see is
+                               @discussion  The displayed "From String" the 
user will see is
                                the "plain address" of the From person ONLY, no 
"personal" data is ahown.
                                This happens as a fallback option when the 
user's assumed desire to see the
                                "personal" data is unable to be fulfilled 
because that "personal" data for the
@@ -2676,11 +3003,12 @@
                                $msg_list_display[$x]['display_address_from'] = 
'';
                                $msg_list_display[$x]['who_to'] = 
$from->mailbox.'@'.$from->host;
                        }
-
+
                        // ----  From Name ----
                        // Part 1 of 2 of the From string (see above)
                        // NOTE: wasn't this decode_header_string proc already 
done above?
-                       $msg_list_display[$x]['from_name'] = 
$this->decode_header_string($personal);
+                       //$msg_list_display[$x]['from_name'] = 
$this->decode_header_string($personal);
+                       $msg_list_display[$x]['from_name'] = $personal;

                        // ----  From Link  ----
                        // this is a URL that can be used to turn the "From 
String" into a clickable link
@@ -2700,7 +3028,7 @@
                        {
                                $msg_list_display[$x]['from_link'] = 
$msg_list_display[$x]['from_link'] .'&personal='.urlencode($personal);
                        }
-
+
                        // if it's a long plain address with no spaces, then 
add a space to the TD can wrap the text
                        if ((!strstr($msg_list_display[$x]['from_name'], " "))
                        && (strlen($msg_list_display[$x]['from_name']) > 15)
@@ -2712,6 +3040,7 @@
                        // DATE
                        // date_time has both date and time, which probably is 
long enough to make a TD cell wrap text to 2 lines
                        $msg_date_time = 
$GLOBALS['phpgw']->common->show_date($hdr_envelope->udate);
+//echo"$msg_date_time";
                        
if($GLOBALS['phpgw']->common->show_date($hdr_envelope->udate,'Ymd') != 
date('Ymd'))
                        {
                                // this strips the time part, leaving only the 
date, better for single line TD cells
@@ -2725,17 +3054,24 @@
                        // *raw* date for utility purposes, such as appending 
and specifying a date
                        // php built in append does not let you specify the 
data during an append
                        //$msg_list_display[$x]['msg_date_raw'] = 
$hdr_envelope->udate;
-
+
                        // TO info for the "Sent" folder
                        // ----  To:  Message Data  -----
                        $to_data_array = array();
                        if (!$hdr_envelope->to)
                        {
-                               $to_data_final = lang('undisclosed_recipients');
+                               $to_data_final = lang('undisclosed recipients');
                        }
                        else
                        {
-                               for ($z = 0; $z < count($hdr_envelope->to); 
$z++)
+                               $to_loops = count($hdr_envelope->to);
+                               // begin test of Maz Num of To loop limitation
+                               $max_to_loops = 25;
+                               if ($to_loops > $max_to_loops)
+                               {
+                                       $to_loops = $max_to_loops;
+                               }
+                               for ($z = 0; $z < $to_loops; $z++)
                                {
                                        $topeople = $hdr_envelope->to[$z];
                                        $to_plain = 
$topeople->mailbox.'@'.$topeople->host;
@@ -2745,39 +3081,41 @@
                                        }
                                        else
                                        {
-                                               $to_person = 
$GLOBALS['phpgw']->msg->decode_header_string($topeople->personal);
+                                               $to_person = 
$this->decode_header_string($topeople->personal);
                                        }
+                                       // escape certain undesirable chars 
before HTML display
+                                       $to_person = 
$this->htmlspecialchars_encode($to_person);
                                        $to_data_array[$z] = $to_person;
                                }
                                // throw a spacer comma in between addresses, 
if more than one
                                $to_data_final = implode(', ',$to_data_array);
                        }
                        $msg_list_display[$x]['to_data_final'] = $to_data_final;
-
+
                }
                if ($debug_msg_list_display > 2) { 
$this->dbug->out('mail_msg_display: get_msg_list_display: exiting 
$msg_list_display[] DUMP', $msg_list_display); }
                if ($debug_msg_list_display > 0) { 
$this->dbug->out('mail_msg_display: get_msg_list_display('.__LINE__.'): 
LEAVING<br>'); }
                return $msg_list_display;
        }
-
+
        /*!
        @function _image_on
        @abstract temp replacement for phpgwapi  image_on until it supports 
images in different dirs.
-       @discussion Email themes have a group of similar looking images grouped 
into a directory with
-       somewhat standard names that AngleMail understands as a themed image 
set. phpgwapi does not
-       currently support subdirectories under the template images directory. 
Params are only to match the
-       phpgw api function, we do not really use them. As of this writting, Feb 
2003, images used for all themes,
-       i.e. are not in a theme subdir but are used, are check and attach on 
the index page, they are not even
-       sized, and, these are sized but not themed, on the message view page, 
are view_nofmt, view_formatted,
-       view_headers, view_raw, and view_printable. Remember if these are 
themed they must be moved
-       into the subdirs, all of them, even if they are copies, and removed 
from the main images dir, so it is
-       obvious if they are group themed or not.
+       @discussion Email themes have a group of similar looking images grouped 
into a directory with
+       somewhat standard names that AngleMail understands as a themed image 
set. phpgwapi does not
+       currently support subdirectories under the template images directory. 
Params are only to match the
+       phpgw api function, we do not really use them. As of this writting, Feb 
2003, images used for all themes,
+       i.e. are not in a theme subdir but are used, are check and attach on 
the index page, they are not even
+       sized, and, these are sized but not themed, on the message view page, 
are view_nofmt, view_formatted,
+       view_headers, view_raw, and view_printable. Remember if these are 
themed they must be moved
+       into the subdirs, all of them, even if they are copies, and removed 
from the main images dir, so it is
+       obvious if they are group themed or not.
        @author Angles
        */
        function _image_on($appname,$image,$extension='_on',$navbar=False)
        {
-               //$prefer_ext = '.gif';
-               $prefer_ext = '.png';
+               $prefer_ext = '.gif';
+               //$prefer_ext = '.png';
                return 
$GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/templates/default/images'.'/'.$image.$prefer_ext;
        }


====================================================
Index: email/inc/class.mail_msg_wrappers.inc.php
diff -u email/inc/class.mail_msg_wrappers.inc.php:1.38 
email/inc/class.mail_msg_wrappers.inc.php:1.39
--- email/inc/class.mail_msg_wrappers.inc.php:1.38      Sun May 25 21:38:27 2003
+++ email/inc/class.mail_msg_wrappers.inc.php   Thu Dec 30 23:13:50 2004
@@ -42,6 +42,15 @@
        class mail_msg_wrappers extends mail_msg_base
        {

+               /*!
+               @function mail_msg_wrappers
+               @abstract CONSTRUCTOR place holder, does nothing
+               */
+               function mail_msg_wrappers()
+               {
+                       return;
+               }
+
                // ====  Functions For Getting Information About A Message  ====

                /*!
@@ -152,7 +161,7 @@

                /*!
                @function phpgw_header
-               @abstract wrapper for IMAP_HEADER, phpgw supplies the nedessary 
stream arg and mail_dcom reference
+               @abstract wrapper for IMAP_HEADER, phpgw supplies the necessary 
stream arg and mail_dcom reference
                @param $msgball (typed array)
                @result returns the php IMAP_HEADER data
                @discussion Wrapper supplies the needed mailsvr_stream arg to 
IMAP_HEADER.
@@ -247,6 +256,10 @@
                                $this->ensure_stream_and_folder($msgball, 
'phpgw_header'.' LINE '.__LINE__);
                                $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $acctnum);
                                $data = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->header($mailsvr_stream, 
$msgball['msgnum']);
+
+                                        // fix escape problem FORGET THIS FOR 
NOW
+                                       
//$this->cache_clean_phpgw_header($data);
+
                                // PUT THIS IN CACHE
                                //  if "session_cache_extreme" is True
                                if (($data)
@@ -262,6 +275,10 @@
                                                //$msgball['folder'] = 
$this->get_arg_value('folder');
                                                $msgball['folder'] = 
$this->prep_folder_out($this->get_arg_value('folder'));
                                        }
+
+                                        // fix escape problem
+                                       
//$this->cache_clean_phpgw_header($data);
+
                                        // this is the way we pass phpgw_header 
data to the caching function
                                        $meta_data = array();
                                        $meta_data['msgball'] = array();
@@ -285,6 +302,107 @@
                }

                /*!
+               @function cache_clean_phpgw_header
+               @abstract ?
+               @param $msg_headers (php struct from header)  btw it is a 
refrence OOP directly on param
+               @author Angles
+               @discussion ?
+
+               function cache_clean_phpgw_header(&$msg_headers)
+               {
+                       //$debug = 0;
+                       $debug = 3;
+
+                       if (
+                         (!isset($msg_headers))
+                       || (!$msg_headers )
+                       //|| ($this->session_cache_extreme == False)
+                       )
+                       {
+                               return '';
+                       }
+                       // toaddress
+                       // to[]
+                       // fromaddress
+                       // from[]
+                       // reply_toaddress
+                       // reply_to[]
+                       // senderaddress
+                       // sender[]
+                       // cc[]
+
+                       if ($debug > 2) { 
$this->dbug->out('wrappers.cache_clean_phpgw_header('.__LINE__.'): BEFORE 
$msg_headers DUMP:', $msg_headers);  }
+                       // toaddress
+                       if ($msg_headers->toaddress)
+                       {
+                               $msg_headers->toaddress = 
addslashes($msg_headers->toaddress);
+                       }
+
+                       // to[]
+                       if ($msg_headers->to)
+                       {
+                               $loops = count($msg_headers->to);
+                               for($i=0;$i<$loops;$i++)
+                               {
+                                       $thingy =& $msg_headers->to[$i];
+                                       $thingy->personal = 
addslashes($thingy->personal);
+                               }
+                       }
+                       // fromaddress
+                       if ($msg_headers->fromaddress)
+                       {
+                               $msg_headers->fromaddress = 
addslashes($msg_headers->fromaddress);
+                       }
+                       // from[]
+                       if ($msg_headers->from)
+                       {
+                               $loops = count($msg_headers->from);
+                               for($i=0;$i<$loops;$i++)
+                               {
+                                       $thingy =& $msg_headers->from[$i];
+                                       $thingy->personal = 
addslashes($thingy->personal);
+                               }
+                       }
+
+                       // reply_toaddress
+                       if ($msg_headers->reply_toaddress)
+                       {
+                               $msg_headers->reply_toaddress = 
addslashes($msg_headers->reply_toaddress);
+                       }
+                       // reply_to[]
+                       if ($msg_headers->reply_to)
+                       {
+                               $loops = count($msg_headers->reply_to);
+                               for($i=0;$i<$loops;$i++)
+                               {
+                                       $thingy =& $msg_headers->reply_to[$i];
+                                       $thingy->personal = 
addslashes($thingy->personal);
+                               }
+                       }
+
+                       // senderaddress
+                       if ($msg_headers->senderaddress)
+                       {
+                               $msg_headers->senderaddress = 
addslashes($msg_headers->senderaddress);
+                       }
+                       // sender[]
+                       if ($msg_headers->sender)
+                       {
+                               $loops = count($msg_headers->sender);
+                               for($i=0;$i<$loops;$i++)
+                               {
+                                       $thingy =& $msg_headers->sender[$i];
+                                       $thingy->personal = 
addslashes($thingy->personal);
+                               }
+                       }
+
+                       // cc[]
+
+                       if ($debug > 2) { 
$this->dbug->out('wrappers.cache_clean_phpgw_header('.__LINE__.'): AFTER 
$msg_headers DUMP:', $msg_headers);  }
+               }
+               */
+
+               /*!
                @function phpgw_fetchheader
                @abstract returns the message RAW headers as a blob, or long 
string.
                @param $msgball (typed array)
@@ -409,6 +527,60 @@
                                $msgball = $this->get_arg_value('msgball');
                        }
                        $acctnum = $msgball['acctnum'];
+                       // why is this next check needed?
+                       if ((!isset($acctnum))
+                       || ((string)$acctnum == ''))
+                       {
+                               $acctnum = $this->get_acctnum();
+                       }
+
+                       // TRY CACHED DATA
+                       $cached_phpgw_fetchbody = 
$this->read_session_cache_item('phpgw_fetchbody', $msgball['acctnum'], 
$msgball['folder'], $msgball['msgnum'], $msgball['part_no']);
+                       if ($cached_phpgw_fetchbody)
+                       {
+                               // notice of event
+                               $this->event_msg_seen($msgball, 
'phpgw_fetchbody');
+                               return $cached_phpgw_fetchbody;
+                       }
+                       // if we get here we need to contact mailserver
+                       $this->ensure_stream_and_folder($msgball, 
'phpgw_fetchbody'.' LINE '.__LINE__);
+                       $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $acctnum);
+                       $msgnum = $msgball['msgnum'];
+                       $part_no = $msgball['part_no'];
+                       //echo 'mail_msg(_wrappers): phpgw_fetchbody: 
processed: $acctnum: '.$acctnum.'; $mailsvr_stream: 
'.serialize($mailsvr_stream).'; $msgnum: '.$msgnum.'; $part_no: 
'.$part_no.'<br> * $msgball dump<pre>'; print_r($msgball); echo '</pre>';
+
+                       $data = '';
+                       $data = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->fetchbody($mailsvr_stream, $msgnum, 
$part_no, $flags);
+
+                       if ($data)
+                       {
+                               // notice of event
+                               $this->event_msg_seen($msgball, 
'phpgw_fetchbody');
+                               // SET_CACHE_ITEM
+                               $meta_data = array();
+                               $meta_data['msgball'] = $msgball;
+                               $meta_data['phpgw_fetchbody'] = $data;
+                               
$this->save_session_cache_item('phpgw_fetchbody', $meta_data, $acctnum);
+                               $meta_data = array();
+                               return $data;
+                       }
+                       else
+                       {
+                               return False;
+                       }
+               }
+
+               /*
+               // OLD FUNCTION
+               function phpgw_fetchbody($msgball='', $flags='')
+               {
+                       //echo 'mail_msg(_wrappers): phpgw_fetchbody: ENTERING, 
$msgball dump<pre>'; print_r($msgball); echo '</pre>';
+                       if ( (!isset($msgball))
+                       || ($msgball == '') )
+                       {
+                               $msgball = $this->get_arg_value('msgball');
+                       }
+                       $acctnum = $msgball['acctnum'];
                        if ((!isset($acctnum))
                        || ((string)$acctnum == ''))
                        {
@@ -425,7 +597,7 @@

                        return 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->fetchbody($mailsvr_stream, $msgnum, 
$part_no, $flags);
                }
-
+               */

        // =====  Functions For Getting Information About A Folder  =====
                // returns an array of integers which are refer to all the 
messages in a folder ("INBOX") sorted and ordered
@@ -467,10 +639,16 @@
                                // DO NOT SPECIFY FOLDER unless you *really* 
know what you are doing
                                // typically "best" folder and acctnum are 
obtained during begin request
                                // right now only specialized filter searching 
requires tp specify a folder
+
+                               // UPDATE WE NOW USE A FOLDER ARG IN THE DATA 
KEY
+                               // not sure how that changes any of this, if at 
all
+                               // in this case, not even an acctnum was 
passed, so obviously a folder is out of the question here
+
                                $fake_fldball = array();
                                $fake_fldball['acctnum'] = $acctnum;
                                $fake_fldball['folder'] = $folder;
-                               $this->ensure_stream_and_folder($fake_fldball, 
'get_msgball_list'.' LINE '.__LINE__);
+                               // WHY DO THIS HERE?
+                               
//$this->ensure_stream_and_folder($fake_fldball, 'get_msgball_list'.' LINE 
'.__LINE__);
                                // ok, so now we KNOW the stream exists and 
folder value is what we need for this desired account
                        }
                        elseif ((!isset($acctnum))
@@ -485,7 +663,14 @@
                        //      $cached_msgball_data[msgball_list]
                        //      $cached_msgball_data[validity]
                        // BUT IT RETURNS TO US THE ACTUAL "msgball_list" part, 
*NOT* WITH THE OTHER STUFF TOO
-                       $cached_msgball_list = 
$this->read_session_cache_item('msgball_list', $acctnum);
+                       //$cached_msgball_list = 
$this->read_session_cache_item('msgball_list', $acctnum);
+                       // NOW WE USE FOLDER NAME AS A DATA KEY TOO
+                       if ((!isset($folder))
+                       || ((string)$folder == ''))
+                       {
+                               $folder = 
$this->prep_folder_out($this->get_arg_value('folder', $acctnum));
+                       }
+                       $cached_msgball_list = 
$this->read_session_cache_item('msgball_list', $acctnum, $folder);
                        if ($cached_msgball_list)
                        {
                                if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(wrappers).get_msgball_list: ('.__LINE__.') LEAVING, 
returning appsession cached "msgball_list"<br>'); }
@@ -495,6 +680,7 @@
                        }
                        else
                        {
+                               if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(wrappers).get_msgball_list: ('.__LINE__.') <font 
color="brown">cached had NO DATA for "msgball_list"</font><br>'); }
                                // right now only specialized filter searching 
requires tp specify a folder
                                $fake_fldball = array();
                                $fake_fldball['acctnum'] = $acctnum;
@@ -508,7 +694,7 @@
                                //{
                                //      $server_msgnum_list = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->sort($this->get_arg_value('mailsvr_stream',
 $acctnum), $this->get_arg_value('sort', $acctnum), 
$this->get_arg_value('order', $acctnum));
                                //}
-                               if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(_wrappers): get_msgball_list: ('.__LINE__.') calling 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->sort('.$this->get_arg_value('mailsvr_stream',
 $acctnum).', '.$this->get_arg_value('sort', $acctnum).', 
'.$this->get_arg_value('order', $acctnum).')<br>'); }
+                               if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(_wrappers): get_msgball_list: ('.__LINE__.') <font 
color="red">MAILSERVER CALL</font> calling 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->sort('.$this->get_arg_value('mailsvr_stream',
 $acctnum).', '.$this->get_arg_value('sort', $acctnum).', 
'.$this->get_arg_value('order', $acctnum).')<br>'); }
                                $server_msgnum_list = 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->sort($this->get_arg_value('mailsvr_stream',
 $acctnum), $this->get_arg_value('sort', $acctnum), 
$this->get_arg_value('order', $acctnum));

                                // put more information about these particular 
messages into the msgball_list[] structure
@@ -566,8 +752,12 @@
                                $meta_data['msgball_list'] = $msgball_list;
                                $meta_data['validity'] = array();
                                $meta_data['validity']['fldball'] = 
$fake_fldball;
-                               $this->save_session_cache_item('msgball_list', 
$meta_data, $acctnum);
-                               if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(_wrappers): get_msgball_list: ('.__LINE__.') 
LEAVING, had to get data from server<br>'); }
+                               
//$this->save_session_cache_item('msgball_list', $meta_data, $acctnum);
+                               // NOW WE USE FOLDER NAME ALSO IN THE DATA KEY
+                               // use the folder name that was fed as a param, 
since this most likely represents a good key to use
+                               // just in case the msgball_list, in the 
future, is a virtual one composed of msg from many folders
+                               $this->save_session_cache_item('msgball_list', 
$meta_data, $acctnum, $folder);
+                               if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('mail_msg(_wrappers): get_msgball_list: ('.__LINE__.') 
LEAVING, <font color="red">had to get data from server</font><br>'); }
                                return $msgball_list;
                        }
                }
@@ -1097,12 +1287,13 @@
                @discussion This function handles the traditional fldball 
better, a fldball["folder"] is NOT ever supposed to have
                a mailsvr_callstr, and IS ALWAYS urlencoded until just before 
we call the dcom class, when we urldecode it only
                at that point. This function assumes this behavior, so the 
typical fldball is supported by this function.
-               This will be the future version of this function, code is 
migratibg to this version.
+               This will be the future version of this function, code is 
migrating to this version.
                @author Angles
                @access public
                */
                function phpgw_createmailbox_ex($target_fldball)
                {
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_createmailbox_ex('.__LINE__.'): ENTERING: raw 
$target_fldball arg ['.htmlspecialchars($target_fldball).']<br>'); }
                        if ((isset($target_fldball['acctnum']))
                        && ((string)$target_fldball['acctnum'] != ''))
                        {
@@ -1127,7 +1318,7 @@
                        // multiple accounts means one stream may be open but 
another may not
                        // "ensure_stream_and_folder" will verify for us,
                        // tell "ensure_stream_and_folder" that its NOT 
NECESSARY to switch TO this folder
-                       $fake_fldball['no_switch_away'] = True;
+                       $target_fldball['no_switch_away'] = True;
                        $this->ensure_stream_and_folder($target_fldball, 
'phpgw_createmailbox_ex LINE ('.__LINE__.')');
                        // if $folder dies not have the {SERVERNAME}  then add 
it
                        //$target_folder_clean = 
$this->prep_folder_in($target_fldball['folder']);
@@ -1138,7 +1329,7 @@
                                $target_folder_clean = 
$mailsvr_callstr.$target_folder_clean;
                        }
                        $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $acctnum);
-                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_createmailbox_ex('.__LINE__.'): calling 
createmailbox('.$mailsvr_stream.', 
'.htmlspecialchars($target_folder_clean).'<br>'); }
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_createmailbox_ex('.__LINE__.'): calling 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->createmailbox('.serialize($mailsvr_stream).',
 '.htmlspecialchars($target_folder_clean).'<br>'); }
                        return 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->createmailbox($mailsvr_stream, 
$target_folder_clean);
                }

@@ -1158,6 +1349,59 @@
                }

                /*!
+               @function phpgw_deletemailbox_ex
+               @abstract ?
+               @param $target_fldball (array or type "fldball") NOTE: folder 
element DOES NOT NEED THE SERVER CALLSTR.
+               @discussion This function handles the traditional fldball 
better, a fldball["folder"] is NOT ever supposed to have
+               a mailsvr_callstr, and IS ALWAYS urlencoded until just before 
we call the dcom class, when we urldecode it only
+               at that point. This function assumes this behavior, so the 
typical fldball is supported by this function.
+               This will be the future version of this function, code is 
migrating to this version.
+               @author Angles
+               @access public
+               */
+               function phpgw_deletemailbox_ex($target_fldball)
+               {
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_deletemailbox_ex('.__LINE__.'): ENTERING: raw 
$target_fldball arg ['.htmlspecialchars($target_fldball).']<br>'); }
+                       if ((isset($target_fldball['acctnum']))
+                       && ((string)$target_fldball['acctnum'] != ''))
+                       {
+                               $target_fldball['acctnum'] = 
(int)$target_fldball['acctnum'];
+                       }
+                       else
+                       {
+                               $target_fldball['acctnum'] = 
$this->get_acctnum();
+                       }
+                       $acctnum = $target_fldball['acctnum'];
+                       // if folder is blank, we *should* assume INBOX because 
BUT mailsvr will give an error INBOX already exists
+                       if ((isset($target_fldball['folder']))
+                       || ((string)$target_fldball['folder'] != ''))
+                       {
+                               // good folder name, no change needed
+                       }
+                       else
+                       {
+                               $target_fldball['folder'] = 'INBOX';
+                       }
+                       // Make Sure Stream Exists
+                       // multiple accounts means one stream may be open but 
another may not
+                       // "ensure_stream_and_folder" will verify for us,
+                       // tell "ensure_stream_and_folder" that its NOT 
NECESSARY to switch TO this folder
+                       $target_fldball['no_switch_away'] = True;
+                       $this->ensure_stream_and_folder($target_fldball, 
'phpgw_deletemailbox_ex LINE ('.__LINE__.')');
+                       // if $folder dies not have the {SERVERNAME}  then add 
it
+                       //$target_folder_clean = 
$this->prep_folder_in($target_fldball['folder']);
+                       $target_folder_clean = 
urldecode($target_fldball['folder']);
+                       if (!strstr($target_folder_clean, '}'))
+                       {
+                               $mailsvr_callstr = 
$this->get_arg_value('mailsvr_callstr', $acctnum);
+                               $target_folder_clean = 
$mailsvr_callstr.$target_folder_clean;
+                       }
+                       $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $acctnum);
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_deletemailbox_ex('.__LINE__.'): calling 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->deletemailbox('.serialize($mailsvr_stream).',
 '.htmlspecialchars($target_folder_clean).'<br>'); }
+                       return 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->deletemailbox($mailsvr_stream, 
$target_folder_clean);
+               }
+
+               /*!
                @function phpgw_renamemailbox
                @abstract ?
                @author Angles
@@ -1174,6 +1418,83 @@
                }

                /*!
+               @function phpgw_renamemailbox_ex
+               @abstract ?
+               @param $target_fldball (array or type "fldball") NOTE: folder 
element DOES NOT NEED THE SERVER CALLSTR.
+               @discussion This function handles the traditional fldball 
better, a fldball["folder"] is NOT ever supposed to have
+               a mailsvr_callstr, and IS ALWAYS urlencoded until just before 
we call the dcom class, when we urldecode it only
+               at that point. This function assumes this behavior, so the 
typical fldball is supported by this function.
+               This will be the future version of this function, code is 
migrating to this version.
+               @author Angles
+               @access public
+               */
+               function phpgw_renamemailbox_ex($source_fldball,$target_fldball)
+               {
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_renamemailbox_ex('.__LINE__.'): ENTERING<br>'); }
+                       if ($this->debug_wrapper_dcom_calls > 1) { 
$this->dbug->out('phpgw_renamemailbox_ex('.__LINE__.'): raw $source_fldball arg 
['.htmlspecialchars($source_fldball).']; raw $target_fldball arg 
['.htmlspecialchars($target_fldball).']<br>'); }
+                       if ((isset($target_fldball['acctnum']))
+                       && ((string)$target_fldball['acctnum'] != ''))
+                       {
+                               $target_fldball['acctnum'] = 
(int)$target_fldball['acctnum'];
+                       }
+                       else
+                       {
+                               $target_fldball['acctnum'] = 
$this->get_acctnum();
+                       }
+                       $acctnum = $target_fldball['acctnum'];
+                       // if folder is blank, we *should* assume INBOX because 
BUT mailsvr will give an error INBOX already exists
+                       if ((isset($target_fldball['folder']))
+                       || ((string)$target_fldball['folder'] != ''))
+                       {
+                               // good folder name, no change needed
+                       }
+                       else
+                       {
+                               $target_fldball['folder'] = 'INBOX';
+                       }
+                       // Make Sure Stream Exists
+                       // multiple accounts means one stream may be open but 
another may not
+                       // "ensure_stream_and_folder" will verify for us,
+                       // tell "ensure_stream_and_folder" that its NOT 
NECESSARY to switch TO this folder
+                       $target_fldball['no_switch_away'] = True;
+                       $this->ensure_stream_and_folder($target_fldball, 
'phpgw_renamemailbox_ex LINE ('.__LINE__.')');
+                       // if $folder dies not have the {SERVERNAME}  then add 
it
+                       //$target_folder_clean = 
$this->prep_folder_in($target_fldball['folder']);
+                       $target_folder_clean = 
urldecode($target_fldball['folder']);
+                       if (!strstr($target_folder_clean, '}'))
+                       {
+                               $mailsvr_callstr = 
$this->get_arg_value('mailsvr_callstr', $acctnum);
+                               $target_folder_clean = 
$mailsvr_callstr.$target_folder_clean;
+                       }
+
+                       // SOURCE FOLDER NAME
+                       //the folder we are renaming MUST BE from the same 
account
+                       // so we only need to clean up its name
+                       if ((isset($source_fldball['folder']))
+                       || ((string)$source_fldball['folder'] != ''))
+                       {
+                               // good folder name, no change needed
+                       }
+                       else
+                       {
+                               $source_fldball['folder'] = 'INBOX';
+                       }
+                       $source_folder_clean = 
urldecode($source_fldball['folder']);
+                       // if $folder dies not have the {SERVERNAME}  then add 
it
+                       if (!strstr($source_folder_clean, '}'))
+                       {
+                               $mailsvr_callstr = 
$this->get_arg_value('mailsvr_callstr', $acctnum);
+                               $source_folder_clean = 
$mailsvr_callstr.$source_folder_clean;
+                       }
+
+                       // OK WE are ready to do it!
+                       $mailsvr_stream = 
$this->get_arg_value('mailsvr_stream', $acctnum);
+                       if ($this->debug_wrapper_dcom_calls > 0) { 
$this->dbug->out('phpgw_renamemailbox_ex('.__LINE__.'): calling 
$GLOBALS[phpgw_dcom_'.$acctnum.']->dcom->renamemailbox('.serialize($mailsvr_stream).',
 '.htmlspecialchars($source_folder_clean).', 
'.htmlspecialchars($target_folder_clean).'<br>'); }
+                       //return 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->createmailbox($mailsvr_stream, 
$target_folder_clean);
+                       return 
$GLOBALS['phpgw_dcom_'.$acctnum]->dcom->renamemailbox($mailsvr_stream, 
$source_folder_clean, $target_folder_clean);
+               }
+
+               /*!
                @function phpgw_listmailbox
                @abstract ?
                @author Angles
@@ -2542,7 +2863,7 @@
                function is_ball_data($maybe_ball='##NOTHING##', 
$expect_ball_type='any', $is_uri_type_string='')
                {
                        if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: is_ball_data('.__LINE__.'): ENTERING<br>'); }
-                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: is_ball_data('.__LINE__.'): param $maybe_fldball 
['.htmlspecialchars(serialize($maybe_fldball)).'], param $expect_ball_type 
['.$expect_ball_type.'], param $is_uri_type_string 
['.htmlspecialchars(serialize($is_uri_type_string)).']  <br>'); }
+                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: is_ball_data('.__LINE__.'): param $maybe_ball 
['.htmlspecialchars(serialize($maybe_ball)).'], param $expect_ball_type 
['.$expect_ball_type.'], param $is_uri_type_string 
['.htmlspecialchars(serialize($is_uri_type_string)).']  <br>'); }
                        // sanity check on input data
                        if ((!isset($maybe_ball))
                        || ($maybe_ball == $this->nothing)
@@ -2668,7 +2989,7 @@
                        // add to this data a "uri" element that is the 
$uri_ball_data
                        //if (isset($return_struct['uri']) == False)
                        //{
-                               $return_struct['uri'] = $uri_ball_data;
+                               //$return_struct['uri'] = $uri_ball_data;
                        //}
                        if ($do_stripslashes == True)
                        {
@@ -2680,6 +3001,8 @@
                        }
                        // we always keep folder data in urlencoded form until 
the last second
                        $return_struct['folder'] = 
$this->prep_folder_out($return_struct['folder']);
+                       //rebuild the uri string
+                       $return_struct['uri'] = 
'msgball[msgnum]='.$return_struct['msgnum'].'&msgball[folder]='.$return_struct['folder'].'&msgball[acctnum]='.$return_struct['acctnum'];
                        if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: ball_data_parse_str('.__LINE__.'): final 
$return_struct DUMP:', $return_struct); }
                        if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: ball_data_parse_str('.__LINE__.'): LEAVING<br>'); }
                        return $return_struct;
@@ -2729,13 +3052,13 @@
                        */

                        $embeded_data = array();
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: decode_fake_uri: ENTERED $uri_type_string 
['.$uri_type_string.'] <br>'); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): ENTERED 
$uri_type_string ['.$uri_type_string.'] <br>'); }
                        parse_str($uri_type_string, $embeded_data);
-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri: parse_str('.$uri_type_string.', 
into $embeded_data DUMP:', $embeded_data); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): 
parse_str('.$uri_type_string.', into $embeded_data DUMP:', $embeded_data); }

                        // NOTE PARSE_STR ***WILL ADD SLASHES*** TO ESCAPE 
QUOTES
                        // NO MATTER WHAT YOUR MAGIC SLASHES SETTING IS
-                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri ('.__LINE__.'): NOTE PARSE_STR 
***WILL ADD SLASHES*** TO ESCAPE QUOTES NO MATTER WHAT YOUR MAGIC SLASHES 
SETTING IS **stripping slashes NOW***'); }
+                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): NOTE PARSE_STR 
***WILL ADD SLASHES*** TO ESCAPE QUOTES NO MATTER WHAT YOUR MAGIC SLASHES 
SETTING IS **stripping slashes NOW***'); }
                        if (isset($embeded_data['folder']))
                        {
                                $embeded_data['folder'] = 
stripslashes($embeded_data['folder']);
@@ -2745,12 +3068,12 @@
                                $embeded_data['msgball']['folder'] = 
stripslashes($embeded_data['msgball']['folder']);
                        }

-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri: post "stripslashes" 
parse_str('.$uri_type_string.', into $embeded_data DUMP:', $embeded_data); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): post "stripslashes" 
parse_str('.$uri_type_string.', into $embeded_data DUMP:', $embeded_data); }

                        // some embeded uri-faked data needs to be raised up 
one level from sub-elements to top level
                        if ($raise_up)
                        {
-                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri: attempt to raise up data one level 
in the array <br>'); }
+                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): attempt to raise up 
data one level in the array <br>'); }
                                $count_embeded = count($embeded_data);
                                if ($count_embeded == 1)
                                {
@@ -2790,11 +3113,11 @@
                                        */
                                        // replace result with $new_top_level
                                        $embeded_data = $new_top_level;
-                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri: raise embeded up to $new_top_level 
DUMP:', $new_top_level); }
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): raise embeded up to 
$new_top_level DUMP:', $new_top_level); }
                                }
                                else
                                {
-                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri: original result had more than one 
element, can not raise <br>'); }
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): original result had 
more than one element, can not raise <br>'); }
                                }
                        }
                        // parse_str will "urldecode" the folder string, we 
need to re-urlencode it,
@@ -2804,21 +3127,22 @@
                                if ((strstr($key, 'folder'))
                                && ((string)$embeded_data[$key] != ''))
                                {
-                                       $re_urlencoded_folder = 
urlencode($embeded_data[$key]);
-                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri: re-urlencode (hopefully) folder 
element $embeded_data['.$key.'] from ['.$embeded_data[$key].'] into 
['.$re_urlencoded_folder.'] <br>'); }
+                                       //$re_urlencoded_folder = 
urlencode($embeded_data[$key]);
+                                       $re_urlencoded_folder = 
$this->prep_folder_out($embeded_data[$key]);
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): re-urlencode 
(hopefully) folder element $embeded_data['.$key.'] from 
['.$embeded_data[$key].'] into ['.$re_urlencoded_folder.'] <br>'); }
                                        $embeded_data[$key] = 
$re_urlencoded_folder;
                                }
                                elseif ((strstr($key, 'acctnum'))
                                && ((string)$embeded_data[$key] != ''))
                                {
                                        $make_int_acctnum = 
(int)$embeded_data[$key];
-                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri: $make_int_acctnum (hopefully) 
acctnum element $embeded_data['.$key.'] from 
['.serialize($embeded_data[$key]).'] into ['.serialize($make_int_acctnum).'] 
<br>'); }
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): $make_int_acctnum 
(hopefully) acctnum element $embeded_data['.$key.'] from 
['.serialize($embeded_data[$key]).'] into ['.serialize($make_int_acctnum).'] 
<br>'); }
                                        $embeded_data[$key] = $make_int_acctnum;
                                }
                        }

-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri: final $embeded_data (sub parts 
made into an associative array) DUMP:', $embeded_data); }
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: decode_fake_uri: LEAVING <br>'); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): final $embeded_data 
(sub parts made into an associative array) DUMP:', $embeded_data); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: decode_fake_uri('.__LINE__.'): LEAVING <br>'); }
                        return $embeded_data;
                }

@@ -2854,9 +3178,9 @@
                */
                function grab_class_args_gpc()
                {
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: ENTERING<br>'); }
-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: $this->ref_POST DUMP:', 
$this->ref_POST); }
-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: $this->ref_GET DUMP:', 
$this->ref_GET); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): ENTERING<br>'); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): $this->ref_POST 
DUMP:', $this->ref_POST); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): $this->ref_GET 
DUMP:', $this->ref_GET); }

                        // ----  extract any "fake_uri" embedded data from 
HTTP_POST_VARS  ----
                        // note: this happens automatically for HTTP_GET_VARS
@@ -2865,10 +3189,10 @@
                        {
                                while(list($key,$value) = each($this->ref_POST))
                                {
-                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: looking for "_fake_uri" token 
in HTTP_POST_VARS ['.$key.'] = '.$this->ref_POST[$key].'<br>'); }
+                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): looking for 
"_fake_uri" token in HTTP_POST_VARS ['.$key.'] = 
'.$this->ref_POST[$key].'<br>'); }
                                        if ($key == 'delmov_list')
                                        {
-                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: FOUND "delmov_list_fake_uri" needs decoding 
HTTP_POST_VARS['.$key.'] = ['.$this->ref_POST[$key].'] <br>'); }
+                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): FOUND "delmov_list_fake_uri" needs decoding 
HTTP_POST_VARS['.$key.'] = ['.$this->ref_POST[$key].'] <br>'); }
                                                // apache2 on test RH8.0 box 
submits "delmov_list" array with duplicate items in it, track this
                                                $seen_delmov_list_items=array();
                                                $sub_loops = 
count($this->ref_POST[$key]);
@@ -2884,7 +3208,7 @@
                                                        // bug1: apache2: do 
duplicate test on the "delmov_list" array items
                                                        if 
(in_array($this->ref_POST[$key][$i], $seen_delmov_list_items) == True)
                                                        {
-                                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: <u>unsetting</u> and *skipping* duplicate (buggy apache2) 
"delmov_list" array item ['.$this->ref_POST[$key][$i].'] <br>'); }
+                                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): <u>unsetting</u> and *skipping* duplicate 
(buggy apache2) "delmov_list" array item ['.$this->ref_POST[$key][$i].'] 
<br>'); }
                                                                
$this->ref_POST[$key][$i] = '';
                                                                // can I UNSET 
this and have the next $i index item actually be the next one
                                                                // YES, a) 
array count calculated before loop, and b) does not squash array to unset an 
item
@@ -2897,7 +3221,7 @@
                                                        else
                                                        {
                                                                // track seen 
items for duplicate test
-                                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: good (not duplicate, not buggy apache2) "delmov_list" 
array item ['.$this->ref_POST[$key][$i].'] <br>'); }
+                                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): good (not duplicate, not buggy apache2) 
"delmov_list" array item ['.$this->ref_POST[$key][$i].'] <br>'); }
                                                                $tmp_next_idx = 
count($seen_delmov_list_items);
                                                                
$seen_delmov_list_items[$tmp_next_idx] = $this->ref_POST[$key][$i];
                                                        }
@@ -2908,19 +3232,19 @@
                                                        
$this->ref_POST[$key][$i] = $sub_embedded_data;
                                                }
                                                // increment our shadow 
iteation count
-                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: decoded ARRAY "_fake_uri" data: HTTP_POST_VARS['.$key.'] 
data DUMP:', $this->ref_POST[$key]); }
+                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): decoded ARRAY "_fake_uri" data: 
HTTP_POST_VARS['.$key.'] data DUMP:', $this->ref_POST[$key]); }
                                        }
                                        elseif (strstr($key, '_fake_uri'))
                                        {
-                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: FOUND "_fake_uri" token in HTTP_POST_VARS['.$key.'] = 
['.$this->ref_POST[$key].'] <br>'); }
+                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): FOUND "_fake_uri" token in 
HTTP_POST_VARS['.$key.'] = ['.$this->ref_POST[$key].'] <br>'); }
                                                $embedded_data = array();
                                                $embedded_data = 
$this->decode_fake_uri($this->ref_POST[$key]);
                                                // Strip "_fake_uri" from $key 
and insert the associative array into HTTP_POST_VARS
                                                $new_key = 
str_replace('_fake_uri', '', $key);
-                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: embedded "_fake_uri" data will be inserted into POST VARS 
with key name: ['.$new_key.'] = ['.$this->ref_POST[$key].'] <br>'); }
+                                               if 
($this->debug_args_input_flow > 1) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): embedded "_fake_uri" data will be inserted 
into POST VARS with key name: ['.$new_key.'] = ['.$this->ref_POST[$key].'] 
<br>'); }
                                                $this->ref_POST[$new_key] = 
array();
                                                $this->ref_POST[$new_key] = 
$embedded_data;
-                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out('mail_msg: 
grab_class_args_gpc: decoded "_fake_uri" data: HTTP_POST_VARS['.$new_key.'] 
data DUMP:', $this->ref_POST[$new_key]); }
+                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out('mail_msg: 
grab_class_args_gpc('.__LINE__.'): decoded "_fake_uri" data: 
HTTP_POST_VARS['.$new_key.'] data DUMP:', $this->ref_POST[$new_key]); }
                                        }
                                        /*
                                        elseif ($key == 'delmov_list')
@@ -2941,7 +3265,7 @@

                        $got_args = array();
                        // insert *known* external args we find into 
$got_args[], then return that data
-                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: about to loop thru 
$this->known_external_args<br>'); }
+                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): about to loop 
thru $this->known_external_args<br>'); }
                        $loops = count($this->known_external_args);
                        for($i=0;$i<$loops;$i++)
                        {
@@ -2949,39 +3273,55 @@
                                //if ($this->debug_args_input_flow > 2) { 
$this->dbug->out(' * * (grab pref - external) $this_arg_name: 
['.$this_arg_name.']<br>'); }
                                if (isset($this->ref_POST[$this_arg_name]))
                                {
-                                       if ($this->debug_args_input_flow> 2) { 
$this->dbug->out(' * * (grab pref - external) 
$this->ref_POST['.$this_arg_name.'] IS set to 
['.$this->ref_POST[$this_arg_name].']<br>'); }
+                                       if ($this->debug_args_input_flow> 2) { 
$this->dbug->out(' * * (grab pref - external)('.__LINE__.') 
$this->ref_POST['.$this_arg_name.'] IS set to 
['.$this->ref_POST[$this_arg_name].']<br>'); }
                                        $got_args[$this_arg_name] = 
$this->ref_POST[$this_arg_name];
                                }
                                elseif (isset($this->ref_GET[$this_arg_name]))
                                {
-                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out(' * * (grab pref - external) 
$this->ref_GET['.$this_arg_name.'] IS set to 
['.$this->ref_GET[$this_arg_name].']<br>'); }
+                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out(' * * (grab pref - external)('.__LINE__.') 
$this->ref_GET['.$this_arg_name.'] IS set to 
['.serialize($this->ref_GET[$this_arg_name]).']<br>'); }
                                        $got_args[$this_arg_name] = 
$this->ref_GET[$this_arg_name];

+                                       // STRIPSLASHES IF NEEDED
+                                       if (($this_arg_name == 'msgball')
+                                       || ($this_arg_name == 'fldball'))
+                                       {
+                                               // php will automayically 
urldecode the folder, we don't like this
+                                               // AND PHP MIGHT ADD GPC 
SLASHES WE DO NOT WANT!!!!! depending on your ini settings
+                                               // use custom 
"stripslashes_gpc" function here because the slashes at this point would have 
been added ONLY by php itself
+                                               // i.e. we have not yet used 
"parse_str" yet, that always addes slashes, but not using it yet means any 
slashes are GPC slashes
+                                               
$not_urlencoded_but_stripslashed_folder = 
$this->stripslashes_gpc($got_args[$this_arg_name]['folder']);
+                                               // now we have no unwanted 
slashes, so put this back in the input args
+                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out(' * * (grab pref - 
external)('.__LINE__.'): msgball[folder] STRIPSLASH watch: 
$got_args[$this_arg_name]["folder"]: 
['.htmlspecialchars($got_args[$this_arg_name]['folder']).']; 
$not_urlencoded_but_stripslashed_folder: 
['.htmlspecialchars($not_urlencoded_but_stripslashed_folder).']<br>'); }
+                                               
$got_args[$this_arg_name]['folder'] = $not_urlencoded_but_stripslashed_folder;
+                                               
$not_urlencoded_but_stripslashed_folder = '';
+                                               
unset($not_urlencoded_but_stripslashed_folder);
+                                       }
                                        // ADD "uri" element to incoming 
"msgball" arg
                                        // so forms may pass this "msgball" on 
to the next page view
                                        if ($this_arg_name == 'msgball')
                                        {
                                                // php will automayically 
urldecode the folder, we don't like this
+                                               // we want the folder value to 
be URLENCODED, so we need to re-urlencode it
                                                $re_urlencoded_folder = 
$this->prep_folder_out($got_args[$this_arg_name]['folder']);
                                                
$got_args[$this_arg_name]['folder'] = $re_urlencoded_folder;
                                                
$got_args[$this_arg_name]['uri'] =
                                                        
'msgball[msgnum]='.$got_args[$this_arg_name]['msgnum']
                                                        
.'&msgball[folder]='.$got_args[$this_arg_name]['folder']
                                                        
.'&msgball[acctnum]='.$got_args[$this_arg_name]['acctnum'];
-                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out(' * * (grab pref - 
external) made msgball URI, added it to msgball[]: DUMP:', 
$got_args[$this_arg_name]); }
+                                               if 
($this->debug_args_input_flow > 2) { $this->dbug->out(' * * (grab pref - 
external)('.__LINE__.') made msgball URI, added it to msgball[]: DUMP:', 
$got_args[$this_arg_name]); }
                                        }
                                }
                                else
                                {
-                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out(' * (grab pref - external) neither POST nor GET vars have this 
item set ['.$this_arg_name.'] <br>'); }
+                                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out(' * (grab pref - external)('.__LINE__.') neither POST nor GET 
vars have this item set ['.$this_arg_name.'] <br>'); }
                                }
                        }
-                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: post-loop (external args) 
$got_args[] DUMP:', $got_args); }
+                       if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): post-loop 
(external args) $got_args[] DUMP:', $got_args); }

                        // in order to know wgat account's arg array to insert 
$got_args[] into, we need to determine what account
                        // we are dealing with before we can call 
$this->set_arg_array or "->get_isset_arg" or "->get_arg_value", etc...
                        // so whoever called this function should obtain that 
before calling $this->set_arg_array() with the data we return here
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: grab_class_args_gpc: LEAVING, returning 
$got_args<br>'); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: grab_class_args_gpc('.__LINE__.'): LEAVING, 
returning $got_args<br>'); }
                        return $got_args;
                }

@@ -3043,7 +3383,7 @@
                */
                function get_best_acctnum($args_array='', $got_args='', 
$force_feed_acctnum='')
                {
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: get_best_acctnum('.__LINE__.'): ENTERING, param 
$force_feed_acctnum ['.$force_feed_acctnum.']'); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: get_best_acctnum('.__LINE__.'): ENTERING, param 
$force_feed_acctnum ['.$force_feed_acctnum.']<br>'); }
                        if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: get_best_acctnum('.__LINE__.'): parm $args_array[] 
DUMP:', $args_array); }
                        if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: get_best_acctnum('.__LINE__.'): parm $got_args[] 
DUMP:', $got_args); }

@@ -3350,6 +3690,8 @@
                        if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: get_best_folder_arg: ENTERING <br>'); }
                        if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: get_best_folder_arg: param $acctnum ['.$acctnum.'] 
; parm $args_array[] DUMP:', $args_array); }
                        if ($this->debug_args_input_flow > 2) { 
$this->dbug->out('mail_msg: get_best_folder_arg: param $acctnum ['.$acctnum.'] 
; parm $got_args[] DUMP:', $got_args); }
+                       // initialize
+                       $processed_folder_arg = '';
                        // we SHOULD have already obtained a valid acctnum 
before calling this function
                        if (!(isset($acctnum))
                        || ((string)$acctnum == ''))
@@ -3359,8 +3701,6 @@
                        //  ----  Get Folder Value  ----
                        // ORDER OF PREFERENCE for pre-processed "folder" input 
arg
                        // (1) $args_array, IF FILLED, overrides any previous 
data or any other data source, look for these:
-                       //      $args_array['msgball']['folder']
-                       //      $args_array['fldball']['folder']
                        //      $args_array['folder']
                        // (2) GPC ['msgball']['folder']
                        // (3) GPC ['fldball']['folder']
@@ -3379,11 +3719,37 @@
                        {
                                $input_folder_arg = 
$this->get_arg_value('["msgball"]["folder"]');
                                if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: $input_folder_arg chooses 
$this->get_arg_value(["msgball"]["folder"]): ['.$input_folder_arg.']<br>'); }
+                               //VERIFY
+                               $processed_folder_arg = 
$this->prep_folder_in($input_folder_arg, 
$this->get_arg_value('["msgball"]["acctnum"]'));
+                               // when putting back into the ball data we need 
to urlencode it because folder element in ball data stays urlencoded until the 
last monent
+                               $processed_folder_arg = 
urlencode($processed_folder_arg);
+                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg('.__LINE__.'): after 
"prep_folder_in", $processed_folder_arg : ['.$processed_folder_arg.']<br>'); }
+                               // both these should be urlencoded so this is 
apples to apples comparison
+                               if ($processed_folder_arg != $input_folder_arg)
+                               {
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg('.__LINE__.'): 
$processed_folder_arg != $input_folder_arg so about to call 
$this->set_arg_value(["msgball"]["folder"], $processed_folder_arg) <br>'); }
+                                       
$this->set_arg_value('["msgball"]["folder"]', $processed_folder_arg);
+                               }
+                               // now that is done, urldecode because a legacy 
quirk requires a urldecded return from this function
+                               $processed_folder_arg = 
urldecode($processed_folder_arg);
                        }
                        elseif ($this->get_isset_arg('["fldball"]["folder"]'))
                        {
                                $input_folder_arg = 
$this->get_arg_value('["fldball"]["folder"]');
                                if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: $input_folder_arg chooses 
$this->get_arg_value(["fldball"]["folder"]): ['.$input_folder_arg.']<br>'); }
+                               //VERIFY
+                               $processed_folder_arg = 
$this->prep_folder_in($input_folder_arg, 
$this->get_arg_value('["fldball"]["acctnum"]'));
+                               // when putting back into the ball data we need 
to urlencode it because folder element in ball data stays urlencoded until the 
last monent
+                               $processed_folder_arg = 
urlencode($processed_folder_arg);
+                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg('.__LINE__.'): after 
"prep_folder_in", $processed_folder_arg : ['.$processed_folder_arg.']<br>'); }
+                               // both these should be urlencoded so this is 
apples to apples comparison
+                               if ($processed_folder_arg != $input_folder_arg)
+                               {
+                                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg('.__LINE__.'): 
$processed_folder_arg != $input_folder_arg so about to call 
$this->set_arg_value(["fldball"]["folder"], $processed_folder_arg) <br>'); }
+                                       
$this->set_arg_value('["fldball"]["folder"]', $processed_folder_arg);
+                               }
+                               // now that is done, urldecode because a legacy 
quirk requires a urldecded return from this function
+                               $processed_folder_arg = 
urldecode($processed_folder_arg);
                        }
                        elseif ($this->get_isset_arg('delmov_list'))
                        {
@@ -3416,9 +3782,17 @@
                        }
                        // ---- Prep the Folder Name (remove encodings, verify 
it's long name (with namespace)
                        // folder prepping does a lookup which requires a 
folder list which *usually* (unless caching) requires a login
-                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: about to issue 
$processed_folder_arg = $this->prep_folder_in('.$input_folder_arg.')<br>'); }
-                       $processed_folder_arg = 
$this->prep_folder_in($input_folder_arg);
-                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: get_best_folder_arg: LEAVING, returning 
$processed_folder_arg value: ['.$processed_folder_arg.']<br>'); }
+                       if ($processed_folder_arg != '')
+                       {
+                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: we already obtained above a 
$processed_folder_arg ['.$processed_folder_arg.']<br>'); }
+                       }
+                       else
+                       {
+                               if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: about to issue 
$processed_folder_arg = $this->prep_folder_in('.$input_folder_arg.')<br>'); }
+                               $processed_folder_arg = 
$this->prep_folder_in($input_folder_arg);
+                       }
+                       if ($this->debug_args_input_flow > 1) { 
$this->dbug->out('mail_msg: get_best_folder_arg: remember legacy quirk says 
return value from here should be urdecoded, eventhough msgball and fldball keep 
folder element urlencoded usually<br>'); }
+                       if ($this->debug_args_input_flow > 0) { 
$this->dbug->out('mail_msg: get_best_folder_arg: LEAVING, returning 
$processed_folder_arg value: ['.$processed_folder_arg.'] remember legacy quirk 
says return value from here should be urdecoded, eventhough msgball and fldball 
keep folder element urlencoded usually<br>'); }
                        return $processed_folder_arg;
                }

@@ -3540,6 +3914,10 @@
                                //      data['validity']['folder_status_info']
                                // then you have provided EVERYTHING we need

+                               // NOTE 5: NOW we also use folder as a data 
key, so each folder has its own msgball_list
+                               // so later we will use this folder data for 
what is called $extra_keys, but it is just the folder name here
+                               // update to make it easier to understand I 
call this $folder_name now
+
                                // easy way is "note 1", at this point 
providing the other stuff is not needed for normal operation
                                // perhaps if you already have the other stuff 
and you know it has not changed ("folder_status_info" still good)
                                // then *maybe* it might save some time passing 
"folder_status_info" you already have
@@ -3642,29 +4020,38 @@
                                // RECAST DATA ready for saving in appsession
                                //$data = serialize($data);

-                               if (($this->debug_session_caching > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
save_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.'] DUMP:', $data); }
+                               // NOW WE USE FOLDER INFO TOO SO EVERY FOLDER 
GETS ITS OWN MSGBALL_LIST
+                               $folder_name = 
$data['validity']['fldball']['folder'];
+                               if (($this->debug_session_caching > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
save_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.']['.$folder_name.'] DUMP:', $data); }
                                // SET DATA
-                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
 = $data;
+                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
 = $data;
+                               // SET DATA USING FOLDER ALSO
+                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$folder_name]
 = $data;

                                // for DB sessions_db ONLY
                                if 
(($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                                || ($this->use_private_table == True))
                                {
-                                       $my_location = 
(string)$acctnum.';'.$data_name;
-                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): 
sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we 
have this additional step to put data into phpgw_app_sessions table, 
$my_location ['.$my_location.']<br>'); }
+                                       //$my_location = 
(string)$acctnum.';'.$data_name;
+                                       // SET DATA USING FOLDER ALSO
+                                       $my_location = 
(string)$acctnum.';'.$data_name.';'.$folder_name;
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): 
sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we 
have this additional step to put data into database anglemail table, 
$my_location ['.$my_location.']<br>'); }
                                        if ($this->use_private_table == True)
                                        {
-                                               
$this->so->so_set_data($my_location, $data);
+                                               
//$this->so->so_set_data($my_location, $data);
+                                               // TRY USING COMPRESSION
+                                               
$this->so->so_set_data($my_location, $data, True);
                                        }
                                        else
                                        {
+                                               // NOTE compression not 
available for appsession table
                                                
$GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                                        }
                                }

                                $data = array();
                                unset($data);
-                               if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did 
SET data for location: [email][dat][$acctnum][$data_name][$extra_keys] :: 
[email][dat]['.$acctnum.']['.$data_name.'] <br>'); }
+                               if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did 
SET data for location: [email][dat][$acctnum][$data_name][$extra_keys] :: 
[email][dat]['.$acctnum.']['.$data_name.']['.$folder_name.'] <br>'); }
                                return True;
                        }
                        // DEFANG special handler for data that might b0rk a 
database, stuff like ' " / \ and maybe some others, only "mailsvr_callstr" 
needs this right now
@@ -3824,6 +4211,8 @@
                                // we will not waste time making a sub array, 
instead we add the "extra_keys" to the "location"
                                // that way we can directly access this 
individual datUM without the hastle of a sub array

+                               // "flat_pgw_struct" also known as "part_nice"
+
                                /*!
                                @capability msg_structure and phpgw_header 
unique handling
                                @abstract The theory is correct and still 
applied, but the sub-array style is OLD OLD OLD
@@ -3906,6 +4295,69 @@
                                if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did 
SET data for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.'] 
<br>'); }
                                return True;
                        }
+                       elseif ($data_name == 'phpgw_fetchbody')
+                       {
+                               if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): 
(extreme-mode) data exists for "'.$data_name.'" AND has a handler<br>'); }
+                               if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): 
"'.$data_name.'" ARRIVING param $data as it is passed into this function 
DUMP:', $data); }
+
+                               //(1) Data Param ARRIVES to this function like 
this
+                               //msg_structure $data param arrives into this 
function like this:
+                               //      $data['msgball'] = $msgball;
+                               //      $data['phpgw_fetchbody'] = $data;
+                               //
+                               //(2) Data Param $data['msgball'] SHOULD HAVE 
ELEMENT "part_no" !!!!
+                               //      $data['msgball']['acctnum']
+                               //      $data['msgball']['folder']
+                               //      $data['msgball']['msgnum']
+                               //      $data['msgball']['part_no']
+
+                               if ((!isset($data['msgball']['part_no']))
+                               || (!$data['msgball']['part_no']))
+                               {
+                                       // LEAVING
+                                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with 
ERROR, returning FALSE, insufficient data for ['.$data_name.'] because NOT 
GIVEN $data[msgball][part_no];  $data[msgball] was 
['.serialize($data['msgball']).'] <br>'); }
+                                       return False;
+                               }
+                               $strlen_phpgw_fetchbody = 
strlen($data['phpgw_fetchbody']);
+                               if ($strlen_phpgw_fetchbody > 60000)
+                               {
+                                       // LEAVING
+                                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with 
ERROR, returning FALSE, data TOO LARGE for ['.$data_name.']; 
$strlen_phpgw_fetchbody;  $data[msgball] was ['.$strlen_phpgw_fetchbody.'] 
<br>'); }
+                                       return False;
+                               }
+
+                               $ex_folder = $data['msgball']['folder'];
+                               $ex_msgnum = $data['msgball']['msgnum'];
+                               $ex_part_no = $data['msgball']['part_no'];
+                               // we know what to do here, so this data "has a 
handler"
+                               $has_handler = True;
+
+                               // RECAST DATA ready for saving in appsession
+                               //$data = serialize($data[$data_name]);
+                               $data = $data[$data_name];
+                               if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.']
 DUMP:', $data); }
+                               // SET DATA
+                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]
 = $data;
+                               // for DB sessions_db ONLY
+                               if 
(($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
+                               || ($this->use_private_table == True))
+                               {
+                                       $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum.';'.$ex_part_no;
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): AM Table in 
use or sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] 
SO we have this additional step to put data into a table table, $my_location 
['.$my_location.'], this is always needed for AM table<br>'); }
+                                       if ($this->use_private_table == True)
+                                       {
+                                               
$this->so->so_set_data($my_location, $data);
+                                       }
+                                       else
+                                       {
+                                               
$GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
+                                       }
+                               }
+                               $data = array();
+                               unset($data);
+                               if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did 
SET data for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.']
 <br>'); }
+                               return True;
+                       }
                        else
                        {
                                // this data_name has no specific handler
@@ -3975,10 +4427,10 @@
                NOTE: ALL INFO SUBJECT TO CHANGE.
                @access private
                */
-               function read_session_cache_item($data_name='misc', 
$acctnum='', $ex_folder='', $ex_msgnum='')
+               function read_session_cache_item($data_name='misc', 
$acctnum='', $ex_folder='', $ex_msgnum='', $ex_part_no='')
                {
-                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): ENTERED, 
$data_name: ['.$data_name.']; optional: $acctnum: ['.$acctnum.'], $ex_folder: 
['.$ex_folder.'], $ex_msgnum: ['.$ex_msgnum.'] '.''); }
-                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('AND 
$this->session_cache_enabled='.serialize($this->session_cache_enabled).'; 
$this->session_cache_extreme='.serialize($this->session_cache_extreme).''); }
+                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): ENTERED, 
$data_name: ['.$data_name.']; optional: $acctnum: ['.$acctnum.'], $ex_folder: 
['.$ex_folder.'], $ex_msgnum: ['.$ex_msgnum.'], $ex_part_no: ['.$ex_part_no.'] 
'.'<br>'); }
+                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('AND 
$this->session_cache_enabled='.serialize($this->session_cache_enabled).'; 
$this->session_cache_extreme='.serialize($this->session_cache_extreme).'<br>'); 
}
                        if ($this->debug_session_caching > 0) { 
$this->dbug->out('<br>'); }
                        $font_start = '<font color="purple">';
                        $font_end = '</font>';
@@ -4116,31 +4568,70 @@
                $validity_test['mailsvr_account_username'] = 
$this->get_arg_value('mailsvr_account_username', $acctnum);
                                @author Angles
                                */
+
+                               // NEW: NOW WE NEED A FOLDER NAME TO COMPLETE 
THE KEY
+                               // if one is not provided as a param,
+                               // (a) WE MUST GET ONE, and
+                               // (b) it must be URLENCODED, or preped_out
+                               if ($ex_folder != '')
+                               {
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): handling 
['.$data_name.'] we DID get passed param $ex_folder ['.$ex_folder.']<br>'); }
+                               }
+                               else
+                               {
+                                       $ex_folder = 
$this->prep_folder_out($this->get_arg_value('folder', $acctnum));
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): handling 
['.$data_name.'] we did NOT get param $ex_folder so we just obtained and set it 
to this: ['.$ex_folder.']<br>'); }
+                               }
+
                                // GET DATA
                                // for DB sessions_db ONLY
                                if 
(($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                                || ($this->use_private_table == True))
                                {
-                                       $my_location = 
(string)$acctnum.';'.$data_name;
-                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): 
sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we 
have this additional step to read data from phpgw_app_sessions table, 
$my_location ['.$my_location.']<br>'); }
+                                       //$my_location = 
(string)$acctnum.';'.$data_name;
+                                       // WE N OW USE FOLDER DATA TOO
+                                       $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder;
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): 
sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we 
have this additional step to read data from a database table, $my_location 
['.$my_location.']<br>'); }
                                        if ($this->use_private_table == True)
                                        {
-                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
-                                                       = 
$this->so->so_get_data($my_location);
+                                               //$got_data = array();
+                                               //$got_data = 
$this->so->so_get_data($my_location);
+                                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
+                                               //      = $got_data;
+
+                                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
+                                               //      = 
$this->so->so_get_data($my_location);
+
+                                               // TRY USING COMPRESSION
+                                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
+                                               //      = 
$this->so->so_get_data($my_location, True);
+
+                                               // TRY USING COMPRESSION
+                                               $got_data = array();
+                                               $got_data = 
$this->so->so_get_data($my_location, True);
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder]
+                                                       = $got_data;
                                        }
                                        else
                                        {
-                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
-                                                       = 
$GLOBALS['phpgw']->session->appsession($my_location, 'email');
+                                               // NOTE: no compression 
available for appsession
+                                               $got_data = array();
+                                               $got_data = 
$GLOBALS['phpgw']->session->appsession($my_location, 'email');
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder]
+                                                       = $got_data;
+
+                                               // NOTE: no compression 
available for appsession
+                                               
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder]
+                                               //      = 
$GLOBALS['phpgw']->session->appsession($my_location, 'email');
                                        }
-                                       if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.'] DUMP:', 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]);
 }
+                                       if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.'] DUMP:', 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder]);
 }
                                }
-                               $got_data = 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name];
+                               //$got_data = 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name];

                                if (($this->debug_session_caching > 2) && 
($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: 
read_session_cache_item: $data_name ['.$data_name.'] verified NOT Stale, 
restored data DUMP:', $got_data); }
                                if (!$got_data)
                                {
-                                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): LEAVING, 
returning False, $data_name ['.$data_name.'] had NO data stored, $acctnum: 
['.$acctnum.']<br>'); }
+                                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): LEAVING, 
returning False, <font color="red">$data_name ['.$data_name.'] had NO data 
stored</font>, $acctnum: ['.$acctnum.'], $ex_folder ['.$ex_folder.']<br>'); }
                                        return False;
                                }
                                else
@@ -4193,17 +4684,19 @@
                                        && 
($got_data['validity']['mailsvr_account_username'] == 
$this->get_arg_value('mailsvr_account_username', $acctnum)))
                                        {
                                                if 
(($this->debug_session_caching > 2) && ($this->debug_allow_magball_list_dumps)) 
{ $this->dbug->out('mail_msg: read_session_cache_item: $data_name 
['.$data_name.'] verified NOT Stale, restored data DUMP:', $got_data); }
-                                               if 
($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): LEAVING, '.$font_start.'successfully 
restored ['.$data_name.']'.$font_end.' VALID and NOT Stale session data, 
$acctnum: ['.$acctnum.']<br>'); }
+                                               if 
($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): LEAVING, '.$font_start.'successfully 
restored ['.$data_name.']'.$font_end.' VALID and NOT Stale session data, 
$acctnum: ['.$acctnum.'] param (or obtained) $ex_folder ['.$ex_folder.']<br>'); 
}
                                                return 
$got_data['msgball_list'];
                                        }
                                        else
                                        {
-                                               if 
($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): EXPIRE STALE ['.$data_name.'] session 
data for $acctnum: ['.$acctnum.']<br>'); }
+                                               if 
($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): EXPIRE STALE ['.$data_name.'] session 
data for $acctnum: ['.$acctnum.'], $ex_folder ['.$ex_folder.']<br>'); }
                                                
//$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
 = array();
                                                
//unset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]);
                                                // this is better to use
-                                               
$this->expire_session_cache_item($data_name, $acctnum);
-                                               if 
($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): LEAVING, returning False, $data_name 
['.$data_name.'] session was STALE, $acctnum: ['.$acctnum.']<br>'); }
+                                               
//$this->expire_session_cache_item($data_name, $acctnum);
+                                               // NOW WE USE FOLDER IN DATA 
KEY ALSO
+                                               
$this->expire_session_cache_item($data_name, $acctnum, $ex_folder);
+                                               if 
($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: 
read_session_cache_item('.__LINE__.'): LEAVING, returning False, $data_name 
['.$data_name.'] session was STALE, $acctnum: ['.$acctnum.'], $ex_folder 
['.$ex_folder.']<br>'); }
                                                return False;
                                        }
                                }
@@ -4322,6 +4815,41 @@
                                        return $got_data;

                                }
+                       }
+                       elseif (($this->session_cache_extreme == True)
+                       && ($data_name == 'phpgw_fetchbody'))
+                       {
+                               // THIS DATA IS NEVER CACHED IF 
$this->session_cache_extreme IS FALSE
+                               if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): handler 
exists for $data_name ['.$data_name.']<br>'); }
+
+                               // GET DATA
+                               // for DB sessions_db ONLY
+                               if 
(($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
+                               || ($this->use_private_table == True))
+                               {
+                                       $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum.';'.$ex_part_no;
+                                       if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): AM table in 
use or sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] 
SO we have this additional step to read data from a table table, $my_location 
['.$my_location.']<br>'); }
+                                       if ($this->use_private_table == True)
+                                       {
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]
+                                                       = 
$this->so->so_get_data($my_location);
+                                       }
+                                       else
+                                       {
+                                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]
+                                                       = 
$GLOBALS['phpgw']->session->appsession($my_location, 'email');
+                                       }
+                                       //if ($this->debug_session_caching > 2) 
{ echo 'mail_msg: read_session_cache_item('.__LINE__.'): 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.'] 
['.$ex_msgnum.']DUMP:<pre>'; 
print_r($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]);
 echo '</pre>'; }
+                               }
+                               $got_data = 
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no];
+
+                               if ($got_data)
+                               {
+                                       if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): found an 
existing array of items for $data_name ['.$data_name.'] data DUMP:', 
$got_data); }
+                                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): LEAVING, 
'.$font_start.'successfully restored ['.$data_name.']'.$font_end.' session data 
for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.']<br>');
 }
+                                       return $got_data;
+
+                               }
                                else
                                {
                                        if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: read_session_cache_item('.__LINE__.'): LEAVING, 
returning False, $data_name ['.$data_name.'] had NO data stored, $acctnum: 
['.$acctnum.'], $extra_keys: ['.$extra_keys.']<br>'); }
@@ -4338,11 +4866,13 @@
                @abstract ?
                @discussion used with appsession TEMPORARY DATA CACHING 
server-side caching of limited,
                ephermal data, such as a list of messages from an imap search, 
via appsession
+               NOTE we get the old data, if any, to see whether it was an 
array or string, HOWEVER using get_arg_value
+               for "folder_list" WILL ATTEMPT A LOGIN so to avoid that we use 
"_direct_access_arg_value" instead.
                @author Angles
                @access private
                */
                // ---- session-only data cached to appsession  ----
-               function 
expire_session_cache_item($data_name='misc',$acctnum='', $ex_folder='', 
$ex_msgnum='')
+               function 
expire_session_cache_item($data_name='misc',$acctnum='', $ex_folder='', 
$ex_msgnum='', $ex_part_no='')
                {
                        if ((!isset($acctnum))
                        || ((string)$acctnum == ''))
@@ -4379,7 +4909,9 @@
                        && (strstr($data_name, 'folder_status_info') == False))
                        {
                                // NOTE L1 cached "folder_status_info" was (a) 
expired above for non-extreme mode and (b) never uses L1 cached in extreme mode
-                               $old_content = $this->get_arg_value($data_name, 
$acctnum);
+                               //$old_content = 
$this->get_arg_value($data_name, $acctnum);
+                               if ($this->debug_session_caching > 1) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): does L1 
cache/class for ['.$data_name.'], to find out we call 
"_direct_access_arg_value" <b>THUS FOLDER_LIST WILL NOT CAUSE A LOGIN</b> using 
"get_arg_value" for folder_list WILL ATTEMPT A LOGIN!<br>'); }
+                               $old_content = 
$this->_direct_access_arg_value($data_name, $acctnum);
                                if ($this->debug_session_caching > 2) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): found and 
clearing L1 cache/class for ['.$data_name.'] OLD value DUMP:', $old_content); }
                                if (gettype($old_content) == 'array')
                                {
@@ -4404,13 +4936,20 @@
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] 
== 'db')
                        || ($this->use_private_table == True))
                        {
+                               // generic fallback value
                                $my_location = (string)$acctnum.';'.$data_name;
-                               if (($ex_folder)
-                               && ($ex_msgnum))
+                               if (((string)$ex_folder != '')
+                               && ((string)$ex_msgnum != '')
+                               && ((string)$ex_part_no != ''))
+                               {
+                                       $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum.';'.$ex_part_no;
+                               }
+                               elseif (((string)$ex_folder != '')
+                               && ((string)$ex_msgnum != ''))
                                {
                                        $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum;
                                }
-                               elseif ($ex_folder)
+                               elseif ((string)$ex_folder != '')
                                {
                                        $my_location = 
(string)$acctnum.';'.$data_name.';'.$ex_folder;
                                }
@@ -4427,8 +4966,10 @@
                                }
                        }

-                       if ((!$ex_folder)
-                       && (!$ex_msgnum)
+                       //if ((!$ex_folder)
+                       //&& (!$ex_msgnum)
+                       if (((string)$ex_folder == '')
+                       && ((string)$ex_msgnum == '')
                        && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name])))
                        {
                                
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name]
 = '';
@@ -4436,8 +4977,10 @@
                                if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING 
return True, did expire existing data for 
[email][dat]['.$acctnum.']['.$data_name.']<br>'); }
                                return True;
                        }
-                       elseif (($ex_folder)
-                       && (!$ex_msgnum)
+                       //elseif (($ex_folder)
+                       //&& (!$ex_msgnum)
+                       elseif (((string)$ex_folder != '')
+                       && ((string)$ex_msgnum == '')
                        && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder])))
                        {
                                
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder]
 = '';
@@ -4445,8 +4988,10 @@
                                if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING 
return True, did expire existing data for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']<br>'); }
                                return True;
                        }
-                       elseif (($ex_folder)
-                       && ($ex_msgnum)
+                       //elseif (($ex_folder)
+                       //&& ($ex_msgnum)
+                       elseif (((string)$ex_folder != '')
+                       && ((string)$ex_msgnum != '')
                        && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum])))
                        {
                                
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum]
 = '';
@@ -4454,14 +4999,23 @@
                                if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING 
return True, did expire existing data for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']<br>');
 }
                                return True;
                        }
-                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING, 
return False, data did not exist for 
[email][dat]['.$acctnum.']['.$data_name.']['.serialize($ex_folder).']['.serialize($ex_msgnum).']<br>');
 }
+                       elseif (((string)$ex_folder != '')
+                       && ((string)$ex_msgnum != '')
+                       && ((string)$ex_part_no != '')
+                       && 
(isset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no])))
+                       {
+                               
$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]
 = '';
+                               
unset($this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no]);
+                               if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING 
return True, did expire existing data for 
[email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.']<br>');
 }
+                               return True;
+                       }
+                       if ($this->debug_session_caching > 0) { 
$this->dbug->out('mail_msg: expire_session_cache_item('.__LINE__.'): LEAVING, 
return False, data did not exist for 
[email][dat]['.$acctnum.']['.$data_name.']['.serialize($ex_folder).']['.serialize($ex_msgnum).']['.serialize($ex_part_no).']<br>');
 }
                        return False;
                }


                
/**************************************************************************\
-               * END **DEPRECIATED *** UNUSED ***                              
                        *
-               *               SEMI-PERMENANT CACHING HANDLERS                 
                *
+               * END  CACHING HANDLERS                                         
                *
                * - - - - - - - - - - - - - - - - - - - - - - - - -             
                                                        *
                * BEGIN PARAM / ARGS / PREFS  ACCESS FUNCTIONS                  
*
                
\**************************************************************************/
@@ -4732,7 +5286,7 @@
                /*!
                @function set_pref_array
                @abstract set the entire preference data array FOR ONE ACCOUNT
-               @param $pref_array_data  (array) either (a) correctly formed 
emai pref array data, or (b) an empty array
+               @param $pref_array_data  (array) either (a) correctly formed 
email pref array data, or (b) an empty array
                @param $acctnum  (int) OPTIONAL
                @result boolean True is successfully sets $pref_array_data, 
False to indicate all we did was clear the args, no data was fed
                @author Angles

====================================================

====================================================

====================================================

====================================================
Index: email/inc/class.spell.inc.php
diff -u email/inc/class.spell.inc.php:1.2 email/inc/class.spell.inc.php:1.3
--- email/inc/class.spell.inc.php:1.2   Fri Mar 14 04:01:08 2003
+++ email/inc/class.spell.inc.php       Thu Dec 30 23:13:50 2004
@@ -130,16 +130,21 @@
                        // FIXME : what if we want to preserve other stuff ? 
Get rid of this array and use for each loop to iterate thru whatever the user 
wants to preserve
                        $this->preserve_tokens = array(
                                0 => 'action',
-                               1 => 'from',
-                               2 => 'sender',
-                               3 => 'to',
-                               4 => 'cc',
-                               5 => 'bcc',
-                               6 => 'msgtype',
-                               7 => 'attach_sig',
-                               8 => 'req_notify'
+                               // why is this different, "orig_action" can 
have the value "new" meaning new mail
+                               // whereas plain old "action" can not tell us 
of a new mail situation, not right now anyway
+                               // darn, I'm not sure this is needed here, is 
not this value kept in the URI or does that not matter here
+                               1 => 'orig_action',
+                               2 => 'from',
+                               3 => 'sender',
+                               4 => 'to',
+                               5 => 'cc',
+                               6 => 'bcc',
+                               7 => 'msgtype',
+                               8 => 'attach_sig',
+                               9 => 'req_notify'
                        );
                        $this->preserve_vars['action'] = '';
+                       $this->preserve_vars['orig_action'] = '';
                        $this->preserve_vars['from'] = '';
                        $this->preserve_vars['sender'] = '';
                        $this->preserve_vars['to'] ='';
@@ -155,7 +160,7 @@
                        $this->body_display = '';


-                       $this->my_validator = 
CreateObject("phpgwapi.validator");
+                       //$this->my_validator = 
CreateObject("phpgwapi.validator");
                        $this->widgets = CreateObject("email.html_widgets");
                        $this->user_lang = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
                        if ($this->user_lang == '')
@@ -488,16 +493,19 @@
                                $this->reject_reason = "don't spellcheck email 
addresses";
                                return False;
                        }
-                       elseif ($this->my_validator->is_url($str) == True)
+                       //elseif ($this->my_validator->is_url($str) == True)
+                       elseif (preg_match('/[a-zA-Z0-9 
\-\.]+\.([a-zA-Z]{2,4})/', $str))
                        {
-                               $this->reject_reason = "don't spellcheck a URL";
+                               $this->reject_reason = "don't spellcheck a URL 
or hostname";
                                return False;
                        }
+                       /*
                        elseif ($this->my_validator->is_hostname($str) == True)
                        {
                                $this->reject_reason = "don't spellcheck 
internet hostnames";
                                return False;
                        }
+                       */
                        elseif (preg_match('/^<.*>$/', $str))
                        {
                                $this->reject_reason = "don't spellcheck 
bracked markup tags";

====================================================
Index: email/inc/class.so_mail_msg.inc.php
diff -u email/inc/class.so_mail_msg.inc.php:1.1 
email/inc/class.so_mail_msg.inc.php:1.2
--- email/inc/class.so_mail_msg.inc.php:1.1     Thu Mar 13 20:03:17 2003
+++ email/inc/class.so_mail_msg.inc.php Thu Dec 30 23:13:50 2004
@@ -34,7 +34,29 @@
        */
        class so_mail_msg
        {
-
+               var $use_group_data=True;
+               //var $use_group_data=False;
+               var $data_group_array=array();
+               var $data_group_done_filled=0;
+               // when something with a folder triggers gathering of group data
+               // store that something here so we know what triggered 
gathering group data
+               // because if "folder_status_info" is the trigger, it may not 
contain the
+               // folder that is actually what we need later on, because "show 
number new
+               // in combobox" will cache that for ALL folders, so a request 
for that
+               // status info may to fill the combobox and have nothing to do 
with the
+               // folder in which we are later going to need the group data.
+               var $data_group_last_trigger = '';
+
+               /*!
+               @function so_mail_msg
+               @abstract Constructor
+               */
+               function so_mail_msg()
+               {
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: ('.__LINE__.'): 
*constructor*<br>'); }
+                       return;
+               }
+
                /*!
                @cabability appsession TEMPORARY DATA CACHING - data we generate
                @abstract Caching via the the api appsession cache occurs in 2 
basic forms.
@@ -216,9 +238,9 @@
                @access Private
                @author Angles
                */
-               function expire_db_session_bulk_data($called_by='not_specified')
+               function 
expire_db_session_bulk_data($called_by='not_specified', 
$wipe_absolutely_everything=False)
                {
-
+                       $this->so_clear_data_group();
                        // for DB sessions_db, OR used for anglemail table
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] 
== 'db')
                        || ($GLOBALS['phpgw']->msg->use_private_table == True))
@@ -260,43 +282,46 @@
                                        $GLOBALS['phpgw']->db->query($query);
                                }

-                               // RE-INSERT IMPORTANT DATA
-                               for ($i=0; $i < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $i++)
+                               if ($wipe_absolutely_everything == False)
                                {
-                                       if 
($GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['status'] == 'enabled')
+                                       // RE-INSERT IMPORTANT DATA
+                                       for ($i=0; $i < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $i++)
                                        {
-                                               $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['acctnum'];
-                                               if 
($retained_data[$this_acctnum]['mailsvr_callstr'])
+                                               if 
($GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['status'] == 'enabled')
                                                {
-                                                       if 
($GLOBALS['phpgw']->msg->use_private_table == True)
-                                                       {
-                                                               
$this->so_set_data((string)$this_acctnum.';mailsvr_callstr', 
$retained_data[$this_acctnum]['mailsvr_callstr']);
-                                                       }
-                                                       else
+                                                       $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['acctnum'];
+                                                       if 
($retained_data[$this_acctnum]['mailsvr_callstr'])
                                                        {
-                                                               
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';mailsvr_callstr',
 'email', $retained_data[$this_acctnum]['mailsvr_callstr']);
+                                                               if 
($GLOBALS['phpgw']->msg->use_private_table == True)
+                                                               {
+                                                                       
$this->so_set_data((string)$this_acctnum.';mailsvr_callstr', 
$retained_data[$this_acctnum]['mailsvr_callstr']);
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';mailsvr_callstr',
 'email', $retained_data[$this_acctnum]['mailsvr_callstr']);
+                                                               }
                                                        }
-                                               }
-                                               if 
($retained_data[$this_acctnum]['folder_list'])
-                                               {
-                                                       if 
($GLOBALS['phpgw']->msg->use_private_table == True)
+                                                       if 
($retained_data[$this_acctnum]['folder_list'])
                                                        {
-                                                               
$this->so_set_data((string)$this_acctnum.';folder_list', 
$retained_data[$this_acctnum]['folder_list']);
+                                                               if 
($GLOBALS['phpgw']->msg->use_private_table == True)
+                                                               {
+                                                                       
$this->so_set_data((string)$this_acctnum.';folder_list', 
$retained_data[$this_acctnum]['folder_list']);
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';folder_list', 
'email', $retained_data[$this_acctnum]['folder_list']);
+                                                               }
                                                        }
-                                                       else
+                                                       if 
($retained_data[$this_acctnum]['mailsvr_namespace'])
                                                        {
-                                                               
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';folder_list', 
'email', $retained_data[$this_acctnum]['folder_list']);
-                                                       }
-                                               }
-                                               if 
($retained_data[$this_acctnum]['mailsvr_namespace'])
-                                               {
-                                                       if 
($GLOBALS['phpgw']->msg->use_private_table == True)
-                                                       {
-                                                               
$this->so_set_data((string)$this_acctnum.';mailsvr_namespace', 
$retained_data[$this_acctnum]['mailsvr_namespace']);
-                                                       }
-                                                       else
-                                                       {
-                                                               
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';mailsvr_namespace',
 'email', $retained_data[$this_acctnum]['mailsvr_namespace']);
+                                                               if 
($GLOBALS['phpgw']->msg->use_private_table == True)
+                                                               {
+                                                                       
$this->so_set_data((string)$this_acctnum.';mailsvr_namespace', 
$retained_data[$this_acctnum]['mailsvr_namespace']);
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$GLOBALS['phpgw']->session->appsession((string)$this_acctnum.';mailsvr_namespace',
 'email', $retained_data[$this_acctnum]['mailsvr_namespace']);
+                                                               }
                                                        }
                                                }
                                        }
@@ -314,15 +339,37 @@
                function so_am_table_exists()
                {
                        $look_for_me = 'phpgw_anglemail';
+
+                       // have we cached this in SESSION cache - NOT the AM 
table itself!
+                       $appsession_key = $look_for_me.'_exists';
+                       $affirmative_value = 'yes';
+                       $negative_value = 'no';
+                       $appsession_returns = 
$this->so_appsession_passthru($appsession_key);
+                       if ($appsession_returns == $affirmative_value)
+                       {
+                               //echo 'so_am_table_exists: result: Actual 
APPSESSION reports stored info saying table ['.$look_for_me.'] DOES exist<br>';
+                               return True;
+                       }
+                       elseif ($appsession_returns == $negative_value)
+                       {
+                               //echo 'so_am_table_exists: result: Actual 
APPSESSION reports stored info saying table ['.$look_for_me.'] does NOT 
exist<br>';
+                               return False;
+                       }
+
+                       // NO APPSESSION data, continue ...
                        $table_names = $GLOBALS['phpgw']->db->table_names();
                        $table_names_serialized = serialize($table_names);
                        if (strstr($table_names_serialized, $look_for_me))
                        {
+                               // STORE THE POSITIVE ANSWER
+                               $this->so_appsession_passthru($appsession_key, 
$affirmative_value);
                                //echo 'so_am_table_exists: result: table 
['.$look_for_me.'] DOES exist<br>';
                                return True;
                        }
                        else
                        {
+                               // STORE THE NEGATIVE ANSWER
+                               $this->so_appsession_passthru($appsession_key, 
$negative_value);
                                //echo 'so_am_table_exists: result: table 
['.$look_for_me.'] does NOT exist<br>';
                                return False;
                        }
@@ -336,12 +383,45 @@
                @function so_set_data
                @abstract ?
                */
-               function so_set_data($data_key, $content)
+               function so_set_data($data_key, $content, $compression=False)
                {
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_set_data('.__LINE__.'): 
ENTERING, $data_key ['.$data_key.'], $compression 
['.serialize($compression).']<br>'); }
                        $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
                        $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
-                       $content = serialize($content);
-                       $content = 
$GLOBALS['phpgw']->db->db_addslashes($content);
+                       // for compression, first choice is BZ2, second choice 
is GZ
+                       //if (($compression)
+                       //&& (function_exists('bzcompress')))
+                       //{
+                       //      $content_preped = 
base64_encode(bzcompress(serialize($content)));
+                       //      $content = '';
+                       //      unset($content);
+                       //      if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_set_data('.__LINE__.'): 
$compression is ['.serialize($compression).'] AND we did serialize and <font 
color="green">did BZ2 compress</font>, no addslashes for compressed 
content<br>'); }
+                       //}
+                       //else
+                       if (($compression)
+                       && (function_exists('gzcompress')))
+                       {
+                               $content_preped = 
base64_encode(gzcompress(serialize($content)));
+                               $content = '';
+                               unset($content);
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_set_data('.__LINE__.'): 
$compression is ['.serialize($compression).'] AND we did serialize and <font 
color="green">did GZ compress</font>, no addslashes for compressed 
content<br>'); }
+                       }
+                       else
+                       {
+                               // addslashes only if NOT compressing data
+                               // serialize only is NOT a string
+                               if (is_string($content))
+                               {
+                                       $content_preped = 
$GLOBALS['phpgw']->db->db_addslashes($content);
+                               }
+                               else
+                               {
+                                       $content_preped = 
$GLOBALS['phpgw']->db->db_addslashes(serialize($content));
+                               }
+                               $content = '';
+                               unset($content);
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_set_data('.__LINE__.'): 
$compress is ['.serialize($compress).'] AND we did serialize with NO 
compression<br>'); }
+                       }

                        $GLOBALS['phpgw']->db->query("SELECT content FROM 
phpgw_anglemail WHERE "
                                . "account_id = '".$account_id."' AND data_key 
= '".$data_key."'",__LINE__,__FILE__);
@@ -349,42 +429,224 @@
                        if ($GLOBALS['phpgw']->db->num_rows()==0)
                        {
                                $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_anglemail (account_id,data_key,content) "
-                                       . "VALUES ('" . $account_id . "','" . 
$data_key . "','" . $content . "')",__LINE__,__FILE__);
+                                       . "VALUES ('" . $account_id . "','" . 
$data_key . "','" . $content_preped . "')",__LINE__,__FILE__);
                        }
                        else
                        {
-                               $GLOBALS['phpgw']->db->query("UPDATE 
phpgw_anglemail set content='" . $content
+                               $GLOBALS['phpgw']->db->query("UPDATE 
phpgw_anglemail set content='" . $content_preped
                                        . "' WHERE account_id='" . $account_id 
. "' AND data_key='" . $data_key . "'",__LINE__,__FILE__);
                        }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_set_data('.__LINE__.'): 
LEAVING <br>'); }
                }

                /*!
                @function so_get_data
                @abstract ?
                */
-               function so_get_data($data_key)
+               function so_get_data($data_key, $compression=False)
                {
-                       $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
-                       $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
ENTERING, $data_key ['.$data_key.'], $compression 
['.serialize($compression).']<br>'); }

-                       $GLOBALS['phpgw']->db->query("SELECT content FROM 
phpgw_anglemail WHERE "
-                               . "account_id = '".$account_id."' AND data_key 
= '".$data_key."'",__LINE__,__FILE__);
+                       // initialize vars to blank
+                       $my_content = '';
+                       $my_content_preped = '';

-                       if ($GLOBALS['phpgw']->db->num_rows()==0)
+                       if (($this->use_group_data == True)
+                       && ($this->so_have_data_group() == False)
+                       && ($this->data_group_done_filled < 3))
                        {
-                               return False;
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
requesting to fill group data<br>'); }
+                               // TRUE = make this into a generic LIKE match 
string
+                               $func_returns = 
$this->so_fill_data_group($data_key, True);
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
fill group data function returns $func_returns 
['.serialize($func_returns).']<br>'); }
+                       }
+                       elseif (
+                          ($this->use_group_data == True)
+                       && ($this->so_have_data_group() == True)
+                       && ($this->data_group_done_filled < 3)
+                       && (strstr($this->data_group_last_trigger, 
'folder_status_info'))
+                       && (!strstr($data_key, 'folder_status_info'))
+                       )
+                       {
+                               // the folder_status_info retry allowed,
+                               // if folder_status_info was the thing that 
triggered getting group data,
+                               // i.e. the first thing to come in here with a 
folder element in it,
+                               // then we are allowed one more try for the 
next item that is requested
+                               // after that that is NOT folder_status_info
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
folder_ststus_info retry block, first trigger was folder_status_info, so now 
wipe existing group data and retry<br>'); }
+                               $this->so_clear_data_group();
+                               // TRUE = make this into a generic LIKE match 
string
+                               $func_returns = 
$this->so_fill_data_group($data_key, True);
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
retry of fill group data function returns $func_returns 
['.serialize($func_returns).']<br>'); }
+                       }
+
+                       if (($this->use_group_data == False)
+                       || ($this->so_have_data_group() == False))
+                       {
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
group data either disabled or nothing returned, requesting individual data 
record<br>'); }
+                               $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
+                               $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+
+                               $GLOBALS['phpgw']->db->query("SELECT content 
FROM phpgw_anglemail WHERE "
+                                       . "account_id = '".$account_id."' AND 
data_key = '".$data_key."'",__LINE__,__FILE__);
+
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
$GLOBALS[phpgw]->db->num_rows() = ['.$GLOBALS['phpgw']->db->num_rows().'] 
<br>'); }
+
+                               if ($GLOBALS['phpgw']->db->num_rows()==0)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, returning False<br>'); }
+                                       return False;
+                               }
+                       }
+
+                       if (($compression)
+                       //&& ((function_exists('bzdecompress')) || 
(function_exists('gzuncompress')) )
+                       && (function_exists('gzuncompress')))
+                       {
+                               if (($this->use_group_data == True)
+                               && ($this->so_have_data_group() == True))
+                               {
+                                       // no stripslashes for compressed data 
(False)
+                                       $my_content = 
$this->so_lookup_data_group($data_key, False);
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
using SO_LOOKUP_DATA_GROUP <br>'); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
so_lookup_data_group $my_content DUMP:', $my_content); }
+                               }
+                               else
+                               {
+                                       $GLOBALS['phpgw']->db->next_record();
+                                       // no stripslashes for compressed data
+                                       $my_content = 
$GLOBALS['phpgw']->db->f('content');
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
query for individual record, NOT using group data<br>'); }
+                               }
+                               $comp_desc = array();
+                               $comp_desc['before_decomp'] = 'NA';
+                               $comp_desc['after_decomp'] = 'NA';
+                               $comp_desc['ratio_txt'] = 'NA';
+                               $comp_desc['ratio_math'] = 'NA';
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $comp_desc['before_decomp'] = strlen($my_content); }
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
strlen($my_content) is ['.$comp_desc['before_decomp'].'], BEFORE decompress, 
$compression is ['.serialize($compression).']<br>'); }
+                               //if ($GLOBALS['phpgw']->msg->debug_so_class > 
2) { $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
$GLOBALS[phpgw]->db->next_record() yields $my_content DUMP:', $my_content); }
+                               if (!$my_content)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, returning False<br>'); }
+                                       return False;
+                               }
+                               // for compression, first choice is BZ2, second 
choice is GZ
+                               // NEW: BZ2 is SLOWER than zlib
+                               //if (function_exists('bzdecompress'))
+                               //{
+                               //      $my_content_preped = 
unserialize(bzdecompress(base64_decode($my_content)));
+                               //      if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { $comp_desc['after_decomp'] = 
strlen(serialize($my_content_preped)); $comp_desc['ratio_math'] = 
(string)(round(($comp_desc['after_decomp']/$comp_desc['before_decomp']), 1) * 
1).'X'; $comp_desc['ratio_txt'] = 'pre/post is ['.$comp_desc['before_decomp'].' 
to '.$comp_desc['after_decomp']; }
+                               //      if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
$compression: ['.serialize($compression).'] using <font color="brown">BZ2 
decompress</font> pre/post is ['.$comp_desc['ratio_txt'].']; ratio: 
['.$comp_desc['ratio_math'].'] <br>'); }
+                               //}
+                               //else
+                               if (function_exists('gzuncompress'))
+                               {
+                                       $my_content_preped = 
unserialize(gzuncompress(base64_decode($my_content)));
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { $comp_desc['after_decomp'] = 
strlen(serialize($my_content_preped)); $comp_desc['ratio_math'] = 
(string)(round(($comp_desc['after_decomp']/$comp_desc['before_decomp']), 1) * 
1).'X'; $comp_desc['ratio_txt'] = 'pre/post is ['.$comp_desc['before_decomp'].' 
to '.$comp_desc['after_decomp']; }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
$compression: ['.serialize($compression).'] using <font color="brown">GZ 
uncompress</font> pre/post is ['.$comp_desc['ratio_txt'].']; ratio: 
['.$comp_desc['ratio_math'].'] <br>'); }
+                               }
+                               else
+                               {
+                                       $my_content_preped = '';
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
ERROR: $compression: ['.serialize($compression).'] <font 
color="brown">decompression ERROR</font> neither "bzdecompress" (first choice) 
nor "gzuncompress" (second choice) is available<br>'); }
+                               }
+                               $my_content = '';
+                               unset($my_content);
+                               if (!$my_content_preped)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
AFTER DECOMPRESS and UNserialization $my_content_preped is GONE!'); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, returning False, <font color="red">content did not unserialize, 
compression was in use </font> <br>'); }
+                                       return False;
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
AFTER DECOMPRESS and UNserialization $my_content_preped DUMP:', 
$my_content_preped); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, got content, <font color="brown"> did decompress </font> , returning 
that content<br>'); }
+                                       return $my_content_preped;
+                               }
                        }
                        else
                        {
-                               $GLOBALS['phpgw']->db->next_record();
-                               //return 
unserialize($GLOBALS['phpgw']->db->f('content', 'stripslashes'));
-                               $my_content = 
$GLOBALS['phpgw']->db->f('content', 'stripslashes');
+                               if (($this->use_group_data == True)
+                               && ($this->so_have_data_group() == True))
+                               {
+                                       // not using compression so we will 
stripslashes
+                                       $my_content = 
$this->so_lookup_data_group($data_key, True);
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
using SO_LOOKUP_DATA_GROUP <br>'); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
so_lookup_data_group $my_content DUMP:', $my_content); }
+                               }
+                               else
+                               {
+                                       $GLOBALS['phpgw']->db->next_record();
+                                       // NOTE: we only stripslashes when NOT 
using compression
+                                       $my_content = 
$GLOBALS['phpgw']->db->f('content', 'stripslashes');
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
query for individual record, NOT using group data<br>'); }
+                               }
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
strlen($my_content) is ['.strlen($my_content).']<br>'); }
+                               //if ($GLOBALS['phpgw']->msg->debug_so_class > 
2) { $GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
$GLOBALS[phpgw]->db->next_record() yields $my_content DUMP:', $my_content); }
                                if (!$my_content)
                                {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, returning False<br>'); }
                                        return False;
                                }
-                               $my_content = unserialize($my_content);
-                               return $my_content;
+                               // we serialize only NON-strings,
+                               // so unserialize only if content is already 
serialized
+                               //if 
($GLOBALS['phpgw']->msg->is_serialized_str($my_content) == True)
+                               if 
($GLOBALS['phpgw']->msg->is_serialized_smarter($my_content) == True)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): we 
need to unserialize this <br>'); }
+                                       $my_content_preped = 
unserialize($my_content);
+                                       // DID IT WORK
+                                       //$try_recover = True;
+                                       $try_recover = False;
+                                       if (!$my_content_preped)
+                                       {
+                                               if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): <b> 
<font color="red">ERROR unserializing </font> </b> , probably a slashes 
problem<br>'); }
+                                               if ($try_recover == True)
+                                               {
+                                                       // try some recovery 
methods
+                                                       $my_content_recover = 
$my_content;
+                                                       $my_content_recover = 
str_replace(':"',':_LEGITQUOTE_',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('":','_LEGITQUOTE_:',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('";','_LEGITQUOTE_;',$my_content_recover);
+                                                       //$my_content_recover = 
str_replace('\/','_ESCAPEDSLASH_',$my_content_recover);
+                                                       //$my_content_recover = 
str_replace('/','\/',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('\\','\\\\',$my_content_recover);
+                                                       // HACK
+                                                       //$my_content_recover = 
str_replace('/','//',$my_content_recover);
+                                                       //$my_content_recover = 
str_replace('"','/"',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('\"','\_LEGITQUOTE_',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('"','\"',$my_content_recover);
+                                                       $my_content_recover = 
str_replace('_LEGITQUOTE_','"',$my_content_recover);
+                                                       //$my_content_recover = 
str_replace('_ESCAPEDSLASH_','\/',$my_content_recover);
+                                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
so_lookup_data_group $my_content_recover DUMP:', $my_content_recover); }
+                                                       $my_content_preped = 
unserialize($my_content_recover);
+                                                       if (!$my_content_preped)
+                                                       {
+                                                               if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): <b> 
<font color="red">2nd ERROR unserializing </font> </b> , recovery did not work, 
probably a slashes problem<br>'); }
+                                                       }
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       $my_content_preped = $my_content;
+                               }
+                               $my_content = '';
+                               unset($my_content);
+                               if (!$my_content_preped)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
AFTER UNserialization $my_content_preped is GONE!'); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, returning False, <font color="red">content did not unserialize </font> 
<br>'); }
+                                       return False;
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
AFTER UNserialization $my_content_preped DUMP:', $my_content_preped); }
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: so_get_data('.__LINE__.'): 
LEAVING, got content, returning that content<br>'); }
+                                       return $my_content_preped;
+                               }
                        }
                }

@@ -398,6 +660,7 @@
                        $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
                        $GLOBALS['phpgw']->db->query("DELETE FROM 
phpgw_anglemail "
                                . " WHERE account_id='" . $account_id . "' AND 
data_key='" . $data_key . "'",__LINE__,__FILE__);
+                       $this->so_clear_data_group($data_key);
                }

                /*!
@@ -409,7 +672,387 @@
                        $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
                        $GLOBALS['phpgw']->db->query("DELETE FROM 
phpgw_anglemail "
                                . " WHERE account_id='" . $account_id . 
"'",__LINE__,__FILE__);
+                       $this->so_clear_data_group();
                }

+               /*!
+               @function so_prop_use_group_data
+               @abstract Delphi style property function for "use_group_data"
+               @discussion This Delphi style property function replaces the 
typical "get" and
+               "set" function. No arg passed will return the current value. 
Passing False
+               or an empty string sets "use_group_data" to False,
+               passing anything else as an arg sets "use_group_data" to true.
+               @author Angles
+               */
+               function so_prop_use_group_data($feed_value='##NOTHING##')
+               {
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 ENTERING, current $this->use_group_data 
['.serialize($this->use_group_data).'], $feed_value 
['.serialize($feed_value).']<br>'); }
+                       if ((string)$feed_value == '##NOTHING##')
+                       {
+                               // do nothing skip down to the return statement
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 do nothing, $feed_value ['.serialize($feed_value).'] == "##NOTHING##" means 
only return current property<br>'); }
+                               //return $this->use_group_data;
+                       }
+                       elseif ($feed_value)
+                       {
+                               if ($this->use_group_data != True)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 toggle $this->use_group_data to True, and thus call "so_clear_data_group" and 
set "data_group_done_filled" to 0 and then set to True<br>'); }
+                                       // maybe we should clear any stored 
data, huh?
+                                       $this->so_clear_data_group();
+                                       // and maybe we should reset this 
excess query counter too, huh?
+                                       $this->data_group_done_filled = 0;
+                                       $this->use_group_data = True;
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 do nothing, use_group_data is already TRUE<br>'); }
+                               }
+                       }
+                       elseif (!$feed_value)
+                       {
+                               if ($this->use_group_data != False)
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 toggle $this->use_group_data to False, and thus call "so_clear_data_group" and 
then set to False<br>'); }
+                                       // maybe we should clear any stored 
data, huh?
+                                       $this->so_clear_data_group();
+                                       $this->use_group_data = False;
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 do nothing, use_group_data is already FALSE<br>'); }
+                               }
+                       }
+                       else
+                       {
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 ERROR why am I here?<br>'); }
+                       }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_prop_use_group_data('.__LINE__.'):
 LEAVING, returning $this->use_group_data 
['.serialize($this->use_group_data).']<br>'); }
+                       return $this->use_group_data;
+               }
+
+               /*!
+               @function so_fill_data_group
+               @abstract ?
+               */
+               function so_fill_data_group($data_key_partial='', 
$make_like=True)
+               {
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 ENTERING, $data_key_partial ['.$data_key_partial.']  $make_like 
['.serialize($make_like).']<br>'); }
+                       if ($this->use_group_data == False)
+                       {
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 0) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 LEAVING returning False<br>'); }
+                               return False;
+                       }
+
+                       $this->data_group_array = array();
+                       if (!$data_key_partial)
+                       {
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 0) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 LEAVING returning False<br>'); }
+                               return False;
+                       }
+
+                       if ($make_like)
+                       {
+                               $orig_data_key_partial = $data_key_partial;
+                               $data_key_exploded = array();
+                               $data_key_exploded = 
explode(';',$orig_data_key_partial);
+                               //SQL pattern matching allows you to use `_' to 
match any single character
+                               //and `%' to match an arbitrary number of 
characters (including zero characters)
+                               // make acctnum;ANY THING;folder for our LIKE 
querey
+                               if ((isset($data_key_exploded[0]))
+                               && (isset($data_key_exploded[2])))
+                               {
+                                       // fill this class var, what triggered 
the gathering of group data?
+                                       // because if it was 
"folder_status_info" then later we are allowed to try again
+                                       // since cached folder stats may be 
simply to fill the combobox and not related
+                                       // to the folder we really need the 
group data for
+                                       $this->data_group_last_trigger = 
$data_key_partial;
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
  setting $this->data_group_last_trigger 
['.$this->data_group_last_trigger.']<br>'); }
+                                       // prep for group data query
+                                       $data_key = 
$data_key_exploded[0].';%;'.$data_key_exploded[2].';%';
+                                       //$data_key = 
$data_key_exploded[0].'\;%\;'.$data_key_exploded[2].'\;%';
+                                       //$data_key = 
(string)$data_key_exploded[0].'%'.$data_key_exploded[2].'%';
+                                       // HOWEVER 2 things also are kept in 
the DB that do NOT HAVE A ";" after the folder name
+                                       $data_key_msgball = 
(string)$data_key_exploded[0].';msgball_list;'.$data_key_exploded[2];
+                                       //$data_key_folder_status_info = 
(string)$data_key_exploded[0].';folder_status_info;'.$data_key_exploded[2];
+                                       // so below we use the LIKE and then OR 
= for those 2 additional things, all in one query
+                                       // without the ";" after the folder 
name, the wildcard "%" could match INBOX[anything]
+                                       // that is bad because if inbox is the 
namespace, we get  the ENITRE database instead if just INBOX with "INBOX%"
+                                       // so we use "INBOX;%" to avoid that 
madness,
+                                       // but add those other 2 items so we do 
not EXCLUSE them because of the lack of trailing ";" as their data_key
+
+                                       // DAMN get the folder status info for 
EVERY FOLDER in case we need it for the combo box
+                                       $data_key_folder_status_info = 
(string)$data_key_exploded[0].';folder_status_info;%';
+
+                                       // OK there are some other things we 
should get too
+                                       // these are data that are associated 
with the account in general, no folder value is used
+                                       // NOTE IT IS RARE these are actually 
needed one we do fill the group data
+                                       // because the first data_key with a 
folder in it will trigger the filling of group data
+                                       // this means these things probably 
were requested earlier on in the page view anyway
+                                       $data_key_folder_list = 
(string)$data_key_exploded[0].';folder_list';
+                                       $data_key_mailsvr_callstr = 
(string)$data_key_exploded[0].';mailsvr_callstr';
+                                       $data_key_mailsvr_namespace = 
(string)$data_key_exploded[0].';mailsvr_namespace';
+                               }
+                               //elseif (isset($data_key_exploded[0]))
+                               //{
+                               //      // NO FOLDER means the way we get mass 
group data will not work
+                               //      $data_key =
+                               //      // NO FOLDER so we can not get these 2 
things we would also look for
+                               //      $data_key_msgball = '';
+                               //      $data_key_folder_status_info = '';
+                               //      // HOWEVER ...
+                               //      // OK there are some other things we 
can still get
+                               //      // these are data that are associated 
with the account in general, no folder value is used
+                               //      $data_key_folder_list = 
(string)$data_key_exploded[0].';folder_list';
+                               //      $data_key_mailsvr_callstr = 
(string)$data_key_exploded[0].';mailsvr_callstr';
+                               //      $data_key_mailsvr_namespace = 
(string)$data_key_exploded[0].';mailsvr_namespace';
+                               //}
+                               else
+                               {
+                                       // Data Key does NOT have a folder name
+                                       // means the way we get mass group data 
will not be worth it
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 LEAVING returning False<br>'); }
+                                       return False;
+                               }
+                       }
+                       else
+                       {
+                               $data_key = $data_key_partial;
+                               $data_key_msgball = '';
+                               $data_key_folder_status_info = '';
+                               $data_key_folder_list = '';
+                               $data_key_mailsvr_callstr = '';
+                               $data_key_mailsvr_namespace = '';
+                       }
+
+                       $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
+                       //if (($data_key)
+                       //&& ($data_key_msgball)
+                       //&& ($data_key_folder_status_info))
+                       //{
+                       //      $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+                       //      $data_key_msgball = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_msgball);
+                       //      $data_key_folder_status_info = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_folder_status_info);
+                       //      $GLOBALS['phpgw']->db->query("SELECT * FROM 
phpgw_anglemail WHERE "
+                       //              . "account_id = '".$account_id
+                       //              ."' AND (data_key LIKE '".$data_key
+                       //              ."' OR data_key = '".$data_key_msgball
+                       //              ."' OR data_key LIKE 
'".$data_key_folder_status_info
+                       //              ."')"
+                       //              ,__LINE__,__FILE__);
+                       //}
+                       if (($data_key)
+                       && ($data_key_msgball)
+                       && ($data_key_folder_status_info)
+                       && ($data_key_folder_list)
+                       && ($data_key_mailsvr_callstr)
+                       && ($data_key_mailsvr_namespace))
+                       {
+                               $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+                               $data_key_msgball = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_msgball);
+                               $data_key_folder_status_info = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_folder_status_info);
+                               $data_key_folder_list = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_folder_list);
+                               $data_key_mailsvr_callstr = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_mailsvr_callstr);
+                               $data_key_mailsvr_namespace = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_mailsvr_namespace);
+                               $GLOBALS['phpgw']->db->query("SELECT * FROM 
phpgw_anglemail WHERE "
+                                       . "account_id = '".$account_id
+                                       ."' AND (data_key LIKE '".$data_key
+                                       ."' OR data_key = '".$data_key_msgball
+                                       ."' OR data_key LIKE 
'".$data_key_folder_status_info
+                                       ."' OR data_key = 
'".$data_key_folder_list
+                                       ."' OR data_key = 
'".$data_key_mailsvr_callstr
+                                       ."' OR data_key = 
'".$data_key_mailsvr_namespace
+                                       ."')"
+                                       ,__LINE__,__FILE__);
+                       }
+                       //elseif (($data_key_folder_list)
+                       //&& ($data_key_mailsvr_callstr)
+                       //&& ($data_key_mailsvr_namespace))
+                       //{
+                       //      $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+                       //      $data_key_msgball = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_msgball);
+                       //      $data_key_folder_status_info = 
$GLOBALS['phpgw']->db->db_addslashes($data_key_folder_status_info);
+                       //      $GLOBALS['phpgw']->db->query("SELECT * FROM 
phpgw_anglemail WHERE "
+                       //              . "account_id = '".$account_id
+                       //              ."' AND (data_key = 
'".$data_key_folder_list
+                       //              ."' OR data_key = 
'".$data_key_mailsvr_callstr
+                       //              ."' OR data_key = 
'".$data_key_mailsvr_namespace
+                       //              ."')"
+                       //              ,__LINE__,__FILE__);
+                       //}
+                       else
+                       {
+                               $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
+                               $GLOBALS['phpgw']->db->query("SELECT * FROM 
phpgw_anglemail WHERE "
+                                       . "account_id = '".$account_id."' AND 
data_key LIKE '".$data_key."'",__LINE__,__FILE__);
+                       }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: 
so_fill_data_group('.__LINE__.'): $data_key ['.htmlspecialchars($data_key).'] 
$data_key_msgball ['.htmlspecialchars($data_key_msgball).'] 
$data_key_folder_status_info 
['.htmlspecialchars($data_key_folder_status_info).']<br>'); }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: 
so_fill_data_group('.__LINE__.'): $data_key_folder_list 
['.htmlspecialchars($data_key_folder_list).'] $data_key_mailsvr_callstr 
['.htmlspecialchars($data_key_mailsvr_callstr).'] $data_key_mailsvr_namespace 
['.htmlspecialchars($data_key_mailsvr_namespace).']<br>'); }
+                       $num_rows = $GLOBALS['phpgw']->db->num_rows();
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: 
so_fill_data_group('.__LINE__.'): $num_rows ['.$num_rows.']<br>'); }
+                       if ($num_rows == 0)
+                       {
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 0) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 LEAVING returning False<br>'); }
+                               return False;
+                       }
+                       // increment counter how many times we have filled 
group data
+                       // maybe some day we use to tell us when this is not 
appropriate if overused for some transactions
+                       $this->data_group_done_filled++;
+
+                       for ($i = 0; $i < $num_rows; $i++)
+                       {
+                               $GLOBALS['phpgw']->db->next_record();
+                               $my_data_key = 
$GLOBALS['phpgw']->db->f('data_key', 'stripslashes');
+                               // NOTE: we only stripslashes when NOT using 
compression
+                               // so we will stripslashes later if we need to
+                               $my_content = 
$GLOBALS['phpgw']->db->f('content');
+                               $this->data_group_array[$my_data_key] = 
$my_content;
+                       }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg: 
so_fill_data_group('.__LINE__.'): $this->data_group_array DUMP:', 
$this->data_group_array); }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_fill_data_group('.__LINE__.'):
 LEAVING returning TRUE, did fill group data<br>'); }
+                       return True;
+               }
+
+               /*!
+               @function so_have_data_group
+               @abstract ?
+               */
+               function so_have_data_group()
+               {
+                       if (!$this->data_group_array)
+                       {
+                               return False;
+                       }
+                       else
+                       {
+                               return True;
+                       }
+               }
+
+               /*!
+               @function so_clear_data_group
+               @abstract ?
+               */
+               function so_clear_data_group($data_key='')
+               {
+                       if (!$this->data_group_array)
+                       {
+                               return False;
+                       }
+
+                       if (!$data_key)
+                       {
+                               // wipe everything
+                               $this->data_group_array = array();
+                               return True;
+                       }
+                       elseif (isset($this->data_group_array[$data_key]))
+                       {
+                               // erease only one element
+                               $this->data_group_array[$data_key] = '';
+                               unset($this->data_group_array[$data_key]);
+                               return True;
+                       }
+                       else
+                       {
+                               // supposed to erease a single element but it 
is not set
+                               return False;
+                       }
+               }
+
+               /*!
+               @function so_lookup_data_group
+               @abstract ?
+               */
+               function so_lookup_data_group($data_key, $do_stripslashes='')
+               {
+                       if ($this->use_group_data == False)
+                       {
+                               return False;
+                       }
+                       if (!$this->data_group_array)
+                       {
+                               return False;
+                       }
+                       if (!isset($this->data_group_array[$data_key]))
+                       {
+                               return False;
+                       }
+
+                       if ($do_stripslashes)
+                       {
+                               return 
stripslashes($this->data_group_array[$data_key]);
+                       }
+                       else
+                       {
+                               return $this->data_group_array[$data_key];
+                       }
+               }
+
+
+               /*!
+               @function so_appsession_passthru
+               @abstract this will ONLY use the ACTUAL REAL APPSESSION of 
phpgwapi
+               @param $location (string) in phpgwapi session speak this is the 
"name" of the information aka the
+               key in a key value pair
+               @param $location (string) OPTIONAL the value in the key value 
pair. Empty will erase I THINK the
+               apsession data stored for the "name" aka the "location".
+               @discussion This is a SIMPLE PASSTHRU for the real phpgwapi 
session call. This function will
+               never use the anglemail table, it is intended for stuff we 
REALLY want to last only for one session.
+               @author Angles
+               */
+               function 
so_appsession_passthru($location='',$data='##NOTHING##', $compression=False)
+               {
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 ENTERING: $location ['.$location.'], $compression 
['.serialize($compression).']<br>'); }
+                       if ($GLOBALS['phpgw']->msg->session_cache_enabled == 
False)
+                       {
+                               // flag means we do not use any session caching
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 0) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 LEAVING, msg->session_cache_enabled False, so disabled session caching, 
returning False<br>'); }
+                               return False;
+                       }
+                       // ok we are allowed to do session caching ...
+                       // since $data may be boolean, boolean True will == any 
filled string
+                       // so for accuracy here we need to case $data as a 
string to do a real == statement
+                       if ((string)$data == '##NOTHING##')
+                       {
+                               // means we are GETTING data from appsession
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 request to get data<br>'); }
+                               if (($compression)
+                               && (function_exists('gzuncompress')))
+                               {
+                                       $content = 
$GLOBALS['phpgw']->session->appsession($location, 'email');
+                                       $content_preped = 
base64_encode(gzuncompress(serialize($content)));
+                                       $content = '';
+                                       unset($content);
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 LEAVING, returning passthru data hopefully<br>'); }
+                                       return $content_preped;
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 LEAVING, returning passthru data<br>'); }
+                                       return 
$GLOBALS['phpgw']->session->appsession($location, 'email');
+                               }
+                       }
+                       else
+                       {
+                               // means we are SETTING data to appsession
+                               if ($GLOBALS['phpgw']->msg->debug_so_class > 1) 
{ 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 request to SET data<br>'); }
+                               if (($compression)
+                               && (function_exists('gzcompress')))
+                               {
+                                       $content_preped = 
base64_encode(gzcompress(serialize($data)));
+                                       $data = '';
+                                       unset($data);
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 LEAVING, returning passthru value<br>'); }
+                                       return 
$GLOBALS['phpgw']->session->appsession($location, 'email', $content_preped);
+                               }
+                               else
+                               {
+                                       if 
($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 LEAVING, returning passthru value<br>'); }
+                                       return 
$GLOBALS['phpgw']->session->appsession($location, 'email', $data);
+                               }
+                       }
+                       if ($GLOBALS['phpgw']->msg->debug_so_class > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('so_mail_msg.so_appsession_passthru('.__LINE__.'):
 ERROR: we should have returned by now<br>'); }
+               }
        }
 ?>

====================================================
Index: email/inc/class.mail_send.inc.php
diff -u email/inc/class.mail_send.inc.php:1.11 
email/inc/class.mail_send.inc.php:1.12
--- email/inc/class.mail_send.inc.php:1.11      Fri Mar 14 04:01:08 2003
+++ email/inc/class.mail_send.inc.php   Thu Dec 30 23:13:50 2004
@@ -202,12 +202,42 @@
                        $mymachine = $mail_out['mta_elho_mymachine'];
                        $fromuser = $mail_out['mta_from'];
                        // START SMTP SESSION - now we can send our message. 
1st we identify ourselves and the sender
-                       $cmds = array (
-                               "\$src = \$this->msg2socket(\$socket,\"EHLO 
\$mymachine\r\n\");",
-                               "\$rrc = \$this->socket2msg(\$socket);",
-                               "\$src = \$this->msg2socket(\$socket,\"MAIL 
FROM:\$fromuser\r\n\");",
-                               "\$rrc = \$this->socket2msg(\$socket);"
-                       );
+// START CHANGES JF
+// lets assume for the purpose of testing that these variables were already 
set up somewhere.
+// That still needs to be done properly.
+// angles: this is a temp handler until it gets in the email site setup page 
as site option
+$smtp_auth_login_required = False;
+//$smtp_auth_login_required = true;
+$mylogin = "xxxxxx";
+$mypassword = "xxxxxxxxxx";
+
+                       if ($smtp_auth_login_required)
+                       {
+                               $mybase64login=base64_encode($mylogin);
+                               $mybase64password=base64_encode($mypassword);
+                               $cmds = array (
+                                       "\$src = 
\$this->msg2socket(\$socket,\"EHLO \$mymachine\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);",
+                                       "\$src = 
\$this->msg2socket(\$socket,\"AUTH LOGIN\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);",
+                                       "\$src = 
\$this->msg2socket(\$socket,\"\$mybase64login\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);",
+                                       "\$src = 
\$this->msg2socket(\$socket,\"\$mybase64password\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);",
+                                       "\$src = 
\$this->msg2socket(\$socket,\"MAIL FROM:\$fromuser\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);"
+                               );
+                       }
+                       else
+                       {
+                               $cmds = array (
+                                       "\$src = 
\$this->msg2socket(\$socket,\"EHLO \$mymachine\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);",
+                                       "\$src = 
\$this->msg2socket(\$socket,\"MAIL FROM:\$fromuser\r\n\");",
+                                       "\$rrc = \$this->socket2msg(\$socket);"
+                               );
+                       }
+// END CHANGES JF
                        if ($this->debug_fake_send)
                        {
                                echo '<pre>';

====================================================
Index: email/inc/class.msg_bootstrap.inc.php
diff -u email/inc/class.msg_bootstrap.inc.php:1.2 
email/inc/class.msg_bootstrap.inc.php:1.3
--- email/inc/class.msg_bootstrap.inc.php:1.2   Fri Mar 14 04:01:08 2003
+++ email/inc/class.msg_bootstrap.inc.php       Thu Dec 30 23:13:50 2004
@@ -48,6 +48,9 @@
                //var $do_login = False;
                var $do_login_ex = 0;

+               var $debug_level=0;
+               //var $debug_level=3;
+
                function msg_bootstrap()
                {
                        if (defined(BS_LOGIN_NEVER) == False)
@@ -122,7 +125,7 @@
                */
                function set_do_login($do_login='##NOTHING##', 
$called_by='not_provided')
                {
-                       if ($debug_level > 0) { echo 'ENTERING: msg_bootstrap: 
set_do_login: (called_by: '.$called_by.') param $do_login: 
['.serialize($do_login).']'.'<br>'; }
+                       if ($this->debug_level > 0) { echo 'ENTERING: 
msg_bootstrap: set_do_login: (called_by: '.$called_by.') param $do_login: 
['.serialize($do_login).']'.'<br>'; }
                        // backward compat, when this was only true or false
                        if (is_bool($do_login))
                        {
@@ -137,7 +140,7 @@
                                        $this->do_login_ex = BS_LOGIN_NEVER;
                                }
                                // LEAVING HERE
-                               if ($debug_level > 0) { echo 'LEAVING: 
msg_bootstrap: set_do_login: (bool input) (called_by: '.$called_by.') 
$this->do_login: ['.$this->do_login.'] $this->do_login_ex: 
['.$this->do_login_ex.'] '.'<br>'; }
+                               if ($this->debug_level > 0) { echo 'LEAVING: 
msg_bootstrap: set_do_login: (bool input) (called_by: '.$called_by.') 
$this->do_login: ['.$this->do_login.'] $this->do_login_ex: 
['.$this->do_login_ex.'] '.'<br>'; }
                                return $this->do_login;
                        }
                        elseif (is_int($do_login))
@@ -175,7 +178,7 @@
                                $this->do_login = True;
                                $this->do_login_ex = BS_LOGIN_ONLY_IF_NEEDED;
                        }
-                       if ($debug_level > 0) { echo 'LEAVING: msg_bootstrap: 
set_do_login: (not bool input) (called_by: '.$called_by.') $this->do_login: 
['.$this->do_login.'] $this->do_login_ex: ['.$this->do_login_ex.'] '.'<br>'; }
+                       if ($this->debug_level > 0) { echo 'LEAVING: 
msg_bootstrap: set_do_login: (not bool input) (called_by: '.$called_by.') 
$this->do_login: ['.$this->do_login.'] $this->do_login_ex: 
['.$this->do_login_ex.'] '.'<br>'; }
                        return $this->do_login_ex;
                }

@@ -233,7 +236,11 @@
                */
                function ensure_mail_msg_exists($called_by='not_provided', 
$debug_level=0)
                {
-                       if ($debug_level > 0) { echo 'ENTERING: msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.')'.'<br>'; }
+                       if ($debug_level > $this->debug_level)
+                       {
+                               $this->debug_level = $debug_level;
+                       }
+                       if ($this->debug_level > 0) { echo 'ENTERING: 
msg_bootstrap: ensure_mail_msg_exists: (called_by: '.$called_by.')'.'<br>'; }

                        // make sure do_login has been set
                        if ($this->get_do_login_ex() == BS_LOGIN_NOT_SPECIFIED)
@@ -241,37 +248,48 @@
                                // this gives us a good general default value
                                $tmp_prev_value = $this->get_do_login();
                                $this->set_do_login($tmp_prev_value);
-                       }
+                       }

                        // make sure utility classes (like html widgets) exist 
for global access
                        //$this->ensure_utility_classes($debug_level);

                        if (is_object($GLOBALS['phpgw']->msg))
+                       //if ((isset($GLOBALS['phpgw']->msg))
+                       //&& (isset($GLOBALS['phpgw']->msg->been_constructed))
+                       //&& ($GLOBALS['phpgw']->msg->been_constructed == True)
+                       //)
                        {
-                               if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): is_object test: 
$GLOBALS[phpgw]->msg is already set, do not create again<br>'; }
+                               if ($this->debug_level > 1) { echo 
'msg_bootstrap: ensure_mail_msg_exists('.__LINE__.'): (called_by: 
'.$called_by.'): is_object test: $GLOBALS[phpgw]->msg is already set, do not 
create again<br>'; }
                        }
                        else
                        {
-                               if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): $GLOBALS[phpgw]->msg is 
NOT set, creating mail_msg object<br>'; }
+                               if ($this->debug_level > 1) { echo 
'msg_bootstrap: ensure_mail_msg_exists('.__LINE__.'): (called_by: 
'.$called_by.'): $GLOBALS[phpgw]->msg is NOT set, creating mail_msg 
object<br>'; }
                                $GLOBALS['phpgw']->msg = 
CreateObject("email.mail_msg");
+                               //$GLOBALS['phpgw']->msg =& 
CreateObject("email.mail_msg");
+                               
//include_once(PHPGW_INCLUDE_ROOT.'/email/inc/class.mail_msg_base.inc.php');
+                               
//include_once(PHPGW_INCLUDE_ROOT.'/email/inc/class.mail_msg_wrappers.inc.php');
+                               
//include_once(PHPGW_INCLUDE_ROOT.'/email/inc/class.mail_msg_display.inc.php');
+                               //$GLOBALS['phpgw']->msg =& new mail_msg;
+                               if ($this->debug_level > 1) { echo 
'msg_bootstrap: ensure_mail_msg_exists('.__LINE__.'): $GLOBALS[phpgw]->msg 
created mail_msg object, now calling needed initialization function aka manual 
constructor function, "initialize_mail_msg"<br>'; }
+                               $GLOBALS['phpgw']->msg->initialize_mail_msg();
                        }

                        if 
($GLOBALS['phpgw']->msg->get_isset_arg('already_grab_class_args_gpc'))
                        {
                                // mail_msg had already run thru 
"begin_request", do not call it again
-                               if ($debug_level > 0) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): LEAVING , msg object 
already initialized<br>'; }
+                               if ($this->debug_level > 0) { echo 
'msg_bootstrap: ensure_mail_msg_exists('.__LINE__.'): (called_by: 
'.$called_by.'): LEAVING , msg object already initialized<br>'; }
                                return True;
                        }

                        $args_array = Array();
                        // should we log in or not
-                       if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): $this->do_login: 
['.serialize($this->do_login).']<br>'; }
+                       if ($this->debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): $this->do_login: 
['.serialize($this->do_login).']<br>'; }
                        $args_array['do_login'] = $this->do_login;
-                       if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): $this->do_login_ex: 
['.serialize($this->do_login_ex).']<br>'; }
+                       if ($this->debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): $this->do_login_ex: 
['.serialize($this->do_login_ex).']<br>'; }
                        $args_array['do_login_ex'] = $this->do_login_ex;

                        // "start your engines"
-                       if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): call msg->begin_request 
with args array:<pre>'; print_r($args_array); echo '</pre>'; }
+                       if ($this->debug_level > 1) { echo 'msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.'): call msg->begin_request 
with args array:<pre>'; print_r($args_array); echo '</pre>'; }
                        $some_stream = 
$GLOBALS['phpgw']->msg->begin_request($args_array);
                        // error if login failed
                        if (($args_array['do_login'] == True)
@@ -281,7 +299,8 @@
                        }
                        // login error will halt this script execution
                        // else all is good to go and script continues...
-                       if ($debug_level > 0) { echo 'EXIT: msg_bootstrap: 
ensure_mail_msg_exists: (called_by: '.$called_by.')'.'<br>'; }
+                       if ($this->debug_level > 2) { echo 'msg_bootstrap: 
about to leave ensure_mail_msg_exists, $GLOBALS[] DUMP:<pre>'; 
print_r($GLOBALS); echo '</pre>'; }
+                       if ($this->debug_level > 0) { echo 'EXIT: 
msg_bootstrap: ensure_mail_msg_exists: (called_by: '.$called_by.')'.'<br>'; }
                }

                /*!
@@ -300,21 +319,21 @@
                        // DEBUG - override debug_level param
                        //$debug_level = 3;

-                       if ($debug_level > 0) { echo 'ENTERING: msg_bootstrap: 
ensure_utility_classes: <br>'; }
+                       if ($this->debug_level > 0) { echo 'ENTERING: 
msg_bootstrap: ensure_utility_classes: <br>'; }

                        if (is_object($GLOBALS['phpgw']->widgets))
                        {
-                               if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_utility_classes: is_object test: $GLOBALS[phpgw]->widgets is already 
set, do not create again<br>'; }
+                               if ($this->debug_level > 1) { echo 
'msg_bootstrap: ensure_utility_classes: is_object test: 
$GLOBALS[phpgw]->widgets is already set, do not create again<br>'; }
                        }
                        else
                        {
-                               if ($debug_level > 1) { echo 'msg_bootstrap: 
ensure_utility_classes: $GLOBALS[phpgw]->widgets is NOT set, creating 
html_widgets object<br>'; }
+                               if ($this->debug_level > 1) { echo 
'msg_bootstrap: ensure_utility_classes: $GLOBALS[phpgw]->widgets is NOT set, 
creating html_widgets object<br>'; }
                                $my_widgets = 
CreateObject("email.html_widgets");
                                $GLOBALS['phpgw']->widgets = $my_widgets;
                        }


-                       if ($debug_level > 0) { echo 'EXIT: msg_bootstrap: 
ensure_utility_classes: <br>'; }
+                       if ($this->debug_level > 0) { echo 'EXIT: 
msg_bootstrap: ensure_utility_classes: <br>'; }
                }

        }

====================================================
Index: email/inc/class.mail_dcom_base.inc.php
diff -u email/inc/class.mail_dcom_base.inc.php:1.9 
email/inc/class.mail_dcom_base.inc.php:1.10
--- email/inc/class.mail_dcom_base.inc.php:1.9  Fri Mar 14 04:00:44 2003
+++ email/inc/class.mail_dcom_base.inc.php      Thu Dec 30 23:13:50 2004
@@ -140,7 +140,16 @@
                                // get rid of that 'needle' "}"
                                $name['folder_before'] = 
substr($name['folder_before'], 1);
                                // translate
-                               $name['folder_after'] = 
imap_utf7_encode($name['folder_before']);
+                               if (function_exists('recode_string') == False)
+                               {
+                                       $name['folder_after'] = 
imap_utf7_encode($name['folder_before']);
+                               }
+                               else
+                               {
+                                       // Modif UTF-8 by Sam Przyswa so now 
compatible with MS-Outlook and Netscape accentued folder name
+                                       $name_tmp = 
recode_string("ISO-8859-1..UTF-7", $name['folder_before']);
+                                       $name['folder_after'] = 
str_replace("+", "&", $name_tmp);
+                               }
                                // replace old folder name with new folder name
                                $name['translated'] = 
str_replace($name['folder_before'], $name['folder_after'], $data_str);
                        }
@@ -253,7 +262,16 @@
                                // get rid of that 'needle' "}"
                                $name['folder_before'] = 
substr($name['folder_before'], 1);
                                // translate
-                               $name['folder_after'] = 
imap_utf7_decode($name['folder_before']);
+                               if (function_exists('recode_string') == False)
+                               {
+                                       $name['folder_after'] = 
imap_utf7_decode($name['folder_before']);
+                               }
+                               else
+                               {
+                                       // Modif UTF-8 by Sam Przyswa so now 
compatible with MS-Outlook and Netscape accentued folder name
+                                       $name_tmp = str_replace("&", "+", 
$name['folder_before']);
+                                       $name['folder_after'] = 
recode_string("UTF-7..ISO-8859-1", $name_tmp);
+                               }
                                // "imap_utf7_decode" returns False if no 
translation occured (supposed to, can return identical string too)
                                if ( ($name['folder_after'] == False)
                                || ($name['folder_before'] == 
$name['folder_after']) )
@@ -294,6 +312,28 @@
                }

                /*!
+               @function folder_list_did_change
+               @abstract if folder is created, deleted, or renamed this this 
function handles cleanup of stale data in main msg object.
+               @author Angles
+               */
+               function folder_list_did_change()
+               {
+                       // NOTE THIS FLAG "folder_list_changed" IS NOW 
OBSOLETED SINCE THIS
+                       // CALLBACK FUNCTION IS PROVEN TO WORK
+                       $this->folder_list_changed = True;
+                       if (is_object($GLOBALS['phpgw']->msg))
+                       {
+                               // call that classes "callback" function 
designed to handle cleaning stale folder_list there
+                               $sucess = 
$GLOBALS['phpgw']->msg->folder_list_change_callback();
+                               // if it was handled correctly, then reset the 
"folder_list_changed" because we did our job
+                               if ($sucess)
+                               {
+                                       $this->folder_list_changed = False;
+                               }
+                       }
+               }
+
+               /*!
                @function get_flag
                @abstract ?
                */

====================================================
Index: email/inc/class.mail_dcom.inc.php
diff -u email/inc/class.mail_dcom.inc.php:1.10 
email/inc/class.mail_dcom.inc.php:1.11
--- email/inc/class.mail_dcom.inc.php:1.10      Fri Mar 14 04:00:42 2003
+++ email/inc/class.mail_dcom.inc.php   Thu Dec 30 23:13:50 2004
@@ -46,9 +46,13 @@
        )
        {
                $mail_server_type = $p1;
+               if ($debug_dcom) { echo 'DCOM DEBUG: found class feed arg $p1 
['.serialize($p1).']<br>'; }
+               //{ echo 'DCOM DEBUG: found class feed arg $p1 
['.serialize($p1).']<br>'; }
        }
        else
        {
+               if ($debug_dcom) { echo 'DCOM DEBUG: did NOT find class feed 
arg $p1 ['.serialize($p1).']<br>'; }
+               //{ echo 'DCOM DEBUG: did NOT find class feed arg $p1 
['.serialize($p1).']<br>'; }
                $mail_server_type = 
$GLOBALS['phpgw_info']['user']['preferences']['email']['mail_server_type'];
        }


====================================================
Index: email/inc/class.boaction.inc.php
diff -u email/inc/class.boaction.inc.php:1.17 
email/inc/class.boaction.inc.php:1.18
--- email/inc/class.boaction.inc.php:1.17       Fri Mar 14 04:00:10 2003
+++ email/inc/class.boaction.inc.php    Thu Dec 30 23:13:50 2004
@@ -25,6 +25,8 @@
                        'get_attach'    => True,
                        'view_html'     => True
                );
+               // class var to hold content to be downloaded
+               var $output_data='';
                // if bomessage wants this preserves, we detect that and store 
it here
                var $no_fmt='';
                var $debug = 0;
@@ -32,6 +34,7 @@
                //var $debug = 4;

                var $debug_new_env = 0;
+               //var $debug_new_env = 3;
                //var $debug_new_env = 4;

                var $msg_bootstrap;
@@ -58,7 +61,7 @@

                function boaction()
                {
-                       return;
+                       //return;
                }

                /*!
@@ -75,11 +78,18 @@
                */
                function delmov()
                {
-                       if ($this->debug > 0) { echo 'ENTERING 
emai.boaction.delmov'.'<br>'; }
+                       //if ($this->debug > 0) { echo 'ENTERING 
email.boaction.delmov'.'<br>'; }
+
+                       if( $GLOBALS['phpgw']->session->is_repost() ) //stop 
double deletion
+                       {
+                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/email/index.php'));
+                               exit;
+                       }

                        // make sure we have msg object and a server stream
                        $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.boaction.delmov', 
$this->debug);
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('email.boaction.delmov', 
$this->debug);
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('ENTERING email.boaction.delmov'.'<br>'); }

                        // initialize this to an "ignore me" value, we change 
it later only if it should have a meaning
                        // MOVED TO MSG CLASS
@@ -140,7 +150,7 @@
                                "nextmatches" view, then the code _SHOULD_ page 
back to where there are messages to show,
                                BUT this is not done yet.
                                */
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov: get_arg_value(what) == "move") <br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: get_arg_value(what) 
== "move") <br>'); }

                                /*
                                $fromacctnum = 
(int)$GLOBALS['phpgw']->msg->get_arg_value('acctnum');
@@ -188,7 +198,7 @@

                                for ($i = 0; $i < count($delmov_list); $i++)
                                {
-                                       if ($this->debug > 2) { echo 
'email.boaction.delmov: in mail move loop ['.(string)($i+1).'] of 
['.$tm.']<br>'; }
+                                       if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: in mail move loop 
['.(string)($i+1).'] of ['.$tm.']<br>'); }
                                        $mov_msgball = $delmov_list[$i];
                                        // WHY URLDECODE SO SOON?
                                        //$mov_msgball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_in($mov_msgball['folder']);
@@ -196,7 +206,7 @@
                                        $did_move = False;
                                        //if ($this->debug > 2) { echo 
'email.boaction.delmov: calling  
$GLOBALS[phpgw]->msg->interacct_mail_move('.serialize($mov_msgball).', 
'.serialize($to_fldball).'<br>'; }
                                        //$did_move = 
$GLOBALS['phpgw']->msg->interacct_mail_move($mov_msgball, $to_fldball);
-                                       if ($this->debug > 2) { echo 
'email.boaction.delmov: calling  
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move('.serialize($mov_msgball).',
 '.serialize($to_fldball).'<br>'; }
+                                       if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: calling  
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move('.serialize($mov_msgball).',
 '.serialize($to_fldball).'<br>'); }
                                        // single move, NO NEED to use the move 
grouping stuff, NOTE $tm was filled above as count($delmov_list)
                                        // MOVED TO FLUSH MOVES LOGIG
                                        //if ($tm == 1)
@@ -206,19 +216,19 @@
                                        //}
                                        //else
                                        //{
-                                               if ($this->debug > 2) { echo 
'email.boaction.delmov: calling  
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move('.serialize($mov_msgball).',
 '.serialize($to_fldball).'<br>'; }
+                                               if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: calling  
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move('.serialize($mov_msgball).',
 '.serialize($to_fldball).'<br>'); }
                                                $did_move = 
$GLOBALS['phpgw']->msg->industrial_interacct_mail_move($mov_msgball, 
$to_fldball);
                                        //}
                                        if ($did_move == False)
                                        {
                                                // error
-                                               if ($this->debug > 0) { echo 
'email.boaction.delmov ('.__LINE__.'): ***ERROR**** 
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move() returns FALSE, ERROR, 
break out of loop<br>'
-                                                               .' * * Server 
reports error: '.$GLOBALS['phpgw']->msg->phpgw_server_last_error().'<br>'; }
+                                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
***ERROR**** $GLOBALS[phpgw]->msg->industrial_interacct_mail_move() returns 
FALSE, ERROR, break out of loop<br>'
+                                                               .' * * Server 
reports error: '.$GLOBALS['phpgw']->msg->phpgw_server_last_error().'<br>'); }
                                                break;
                                        }
                                        else
                                        {
-                                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move() returns True<br>'; }
+                                               if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->industrial_interacct_mail_move() returns True<br>'); }
                                                //$did_expunge = False;
                                                //$did_expunge = 
$GLOBALS['phpgw']->msg->phpgw_expunge($mov_msgball['acctnum'], $mov_msgball);
                                                //if ($this->debug > 2) { echo 
'email.boaction.delmov: $GLOBALS[phpgw]->msg->phpgw_expunge() returns 
'.serialize($did_expunge).'<br>'; }
@@ -226,10 +236,10 @@
                                }

                                // ok, done moving, now expunge, 
"industrial_interacct_mail_move" uses ""
-                               if ($this->debug > 0) { echo 
'email.boaction.delmov ('.__LINE__.'): done moving, now call 
$GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): done 
moving, now call $GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'); }
                                $did_expunge = False;
                                $did_expunge = 
$GLOBALS['phpgw']->msg->expunge_expungable_folders('email.boaction.delmov LINE 
'.__LINE__);
-                               if ($this->debug > 2) { echo 
'email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'; }
+                               if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'); }

                                if (! $did_move)
                                {
@@ -238,7 +248,10 @@
                                        //echo 'Server reports error: 
'.$GLOBALS['phpgw']->msg->dcom->server_last_error();
                                }
                                // report folder messages were moved to
-                               $tf = 
$GLOBALS['phpgw']->msg->prep_folder_out($to_fldball['folder']);
+                               //$tf = 
$GLOBALS['phpgw']->msg->prep_folder_out($to_fldball['folder']);
+                               // folder in this array was never changed from 
its "prepped out" state, it is still urlencoded from when we first picked it up
+                               $tf = $to_fldball['folder'];
+                               //echo 'boaction: $tf ['.$tf.'] <br>';

                                // folder or message we should go back to
                                if 
(($GLOBALS['phpgw']->msg->get_isset_arg('move_postmove_goto'))
@@ -247,15 +260,18 @@
                                        // THIS MEANS WE WERE CALLED BY 
UIMESSAGE
                                        // treat the post-move navigation like 
a "delete_single_msg", as per data passed to us from that page
                                        $move_postmove_goto = 
$GLOBALS['phpgw']->msg->get_arg_value('move_postmove_goto');
-                                       if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): move single *called by uimessage*: 
$move_postmove_goto: : '.$move_postmove_goto.'<br>'; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): move 
single *called by uimessage*: $move_postmove_goto: : 
'.$move_postmove_goto.'<br>'); }
                                        // ----  "Go To Previous Message" 
Handling  -----
                                        // these insrustions passed from 
uimessage when prev_next_navigation is obtained anyway
                                        $this->redirect_to = 
$move_postmove_goto;
-                                       if ($this->debug > 1) { echo 
'emai.boaction.delmov: ('.__LINE__.') move single *called by uimessage*: 
determination of $this->redirect_to : ['.$this->redirect_to.']<br>'; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: ('.__LINE__.') move 
single *called by uimessage*: determination of $this->redirect_to : 
['.$this->redirect_to.']<br>'); }
                                }
                                else
                                {
-                                       $return_to_fldball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($delmov_list[0]['folder']);
+                                       //$return_to_fldball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($delmov_list[0]['folder']);
+                                       // folder in this array was never 
changed from its "prepped out" state, it is still urlencoded from when we first 
picked it up
+                                       $return_to_fldball['folder'] = 
$delmov_list[0]['folder'];
+                                       //echo 'boaction: 
$return_to_fldball[folder] ['.$return_to_fldball['folder'].'] <br>';
                                        $return_to_fldball['acctnum'] = 
$delmov_list[0]['acctnum'];

                                        $this->redirect_to = 
$GLOBALS['phpgw']->link(
@@ -269,7 +285,7 @@
                                                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start'));

-                                       if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): NOT called by uimessage, determination of 
$this->redirect_to : ['.$this->redirect_to.']<br>'; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): NOT 
called by uimessage, determination of $this->redirect_to : 
['.$this->redirect_to.']<br>'); }
                                }
                        }
                        // ---- DELETE (MULTIPLE) MESSAGES ----
@@ -284,7 +300,7 @@
                                using its "folder" and "acctnum" values.
                                */

-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov: get_arg_value(what) == "delall") <br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: get_arg_value(what) 
== "delall") <br>'); }
                                // this is called from the index pge after you 
check some boxes and click "delete" button

                                $delmov_list = 
$GLOBALS['phpgw']->msg->get_arg_value('delmov_list');
@@ -304,7 +320,7 @@
                                $loops = count($delmov_list);
                                for ($i = 0; $i < $loops; $i++)
                                {
-                                       if ($this->debug > 2) { echo 
'email.boaction.delmov: (delete) in mail delete loop ['.(string)($i+1).'] of 
['.$loops.']<br>'; }
+                                       if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: (delete) in mail 
delete loop ['.(string)($i+1).'] of ['.$loops.']<br>'); }
                                        $this_msgnum = 
$delmov_list[$i]['msgnum'];
                                        // was_in_folder is used in Trash 
handling in the ->phpgw_delete function
                                        // if a message "was_in_folder" Trash, 
it gets deleted for real, no option to move to Trash in that case
@@ -314,13 +330,13 @@
                                        if ($did_delete == False)
                                        {
                                                // error
-                                               if ($this->debug > 0) { echo 
'email.boaction.delmov: (delete) ***ERROR**** 
$GLOBALS[phpgw]->msg->phpgw_delete() returns FALSE, ERROR, break out of 
loop<br>'
-                                                               .' * * Server 
reports error: '.$GLOBALS['phpgw']->msg->phpgw_server_last_error().'<br>'; }
+                                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: (delete) ***ERROR**** 
$GLOBALS[phpgw]->msg->phpgw_delete() returns FALSE, ERROR, break out of 
loop<br>'
+                                                               .' * * Server 
reports error: '.$GLOBALS['phpgw']->msg->phpgw_server_last_error().'<br>'); }
                                                break;
                                        }
                                        else
                                        {
-                                               if ($this->debug > 1) { echo 
'email.boaction.delmov: (delete) $GLOBALS[phpgw]->msg->phpgw_delete() returns 
True (so it buffered the command, really does not mean anything not that we 
buffer commands)<br>'; }
+                                               if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: (delete) 
$GLOBALS[phpgw]->msg->phpgw_delete() returns True (so it buffered the command, 
really does not mean anything not that we buffer commands)<br>'); }

                                                //if ($this->debug > 0) { echo 
'email.boaction.delmov: (delete) calling 
$GLOBALS[phpgw]->msg->phpgw_expunge('.$delmov_list[$i]['acctnum'].', 
$delmov_list[$i])<br>'; }
                                                //$did_expunge = False;
@@ -330,10 +346,10 @@
                                }

                                // ok, done deleting, now expunge
-                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): done deleting, now call 
$GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'; }
+                               if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): done 
deleting, now call $GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'); }
                                $did_expunge = False;
                                $did_expunge = 
$GLOBALS['phpgw']->msg->expunge_expungable_folders('email.boaction.delmov LINE 
'.__LINE__);
-                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'; }
+                               if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'); }

                                $totaldeleted = $i;
                                //$GLOBALS['phpgw']->msg->phpgw_expunge();
@@ -419,14 +435,14 @@
                                {
                                        $this->no_fmt = '&no_fmt=1';
                                }
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): get_arg_value(what) == 
"delete_single_msg") <br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
get_arg_value(what) == "delete_single_msg") <br>'); }
                                // called by clicking the "X" dutton while 
reading an individual message
                                $msgball = 
$GLOBALS['phpgw']->msg->get_arg_value('msgball');
-                               if ($this->debug > 2) { echo 
'emai.boaction.delmov ('.__LINE__.'): delete_single_msg: pre-delete $msgball[] 
dump <pre>: '; print_r($msgball); echo '</pre>'; }
+                               if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
delete_single_msg: pre-delete $msgball[] DUMP:', $msgball); }

                                // BEFORE we delete, if there is no mext 
message, then we will go back to index page
                                $nav_data = 
$GLOBALS['phpgw']->msg->prev_next_navigation($folder_info['number_all']);
-                               if ($this->debug > 2) { echo 
'emai.boaction.delmov ('.__LINE__.'): delete_single_msg: pre-delete $nav_data[] 
dump <pre>: '; print_r($nav_data); echo '</pre>'; }
+                               if ($this->debug > 2) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
delete_single_msg: pre-delete $nav_data[] DUMP:', $nav_data); }
                                // ----  "Go To Previous Message" Handling  
-----
                                if ($nav_data['prev_msg'] != $not_set)
                                {
@@ -455,36 +471,36 @@
                                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start'));
                                }
-                               if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): delete_single_msg: pre-delete 
determination of $this->redirect_to : ['.$this->redirect_to.']<br>'; }
+                               if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
delete_single_msg: pre-delete determination of $this->redirect_to : 
['.$this->redirect_to.']<br>'); }


                                if ($this->debug > 3)
                                {
-                                       echo 'emai.boaction.delmov: 
delete_single_msg ('.__LINE__.'): debug flag = 4 or higher, _SKIP_ the delete 
and expunge action<br>';
+                                       
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: delete_single_msg 
('.__LINE__.'): debug flag = 4 or higher, _SKIP_ the delete and expunge 
action<br>');
                                }
                                else
                                {
                                        // ok, now do the delete
-                                       if ($this->debug > 1) { echo 
'emai.boaction.delmov: delete_single_msg: ('.__LINE__.') : (single delete) 
calling $GLOBALS[phpgw]->msg->phpgw_delete('.$msgball['msgnum'].', " 
",'.$msgball['folder'].', '.$msgball['acctnum'].', True) '; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: delete_single_msg: 
('.__LINE__.') : (single delete) calling 
$GLOBALS[phpgw]->msg->phpgw_delete('.$msgball['msgnum'].', " 
",'.$msgball['folder'].', '.$msgball['acctnum'].', True) '); }
                                        // True = just a single delete call, 
don't use the buffer commands
                                        // " just a single delete call" logic 
MOVED TO BUFFERED COMMANDS function
                                        
//$GLOBALS['phpgw']->msg->phpgw_delete($msgball['msgnum'],'',$msgball['folder'],
 (int)$msgball['acctnum'], True);
                                        
$GLOBALS['phpgw']->msg->phpgw_delete($msgball['msgnum'],'',$msgball['folder'], 
(int)$msgball['acctnum']);
                                        // now do the expunge, both IMAP and 
POP3 require this, or the message is not really deleted
-                                       //if ($this->debug > 1) { echo 
'emai.boaction.delmov: delete_single_msg: ('.__LINE__.') : calling 
$GLOBALS[phpgw]->msg->phpgw_expunge('.$msgball['acctnum'].', $msgball) '; }
+                                       //if ($this->debug > 1) { echo 
'email.boaction.delmov: delete_single_msg: ('.__LINE__.') : calling 
$GLOBALS[phpgw]->msg->phpgw_expunge('.$msgball['acctnum'].', $msgball) '; }
                                        // MOVED to "expunge_expungable_folders"
                                        
//$GLOBALS['phpgw']->msg->phpgw_expunge((int)$msgball['acctnum'], $msgball);

                                        // ok, done deleting, now expunge
-                                       if ($this->debug > 1) { echo 
'email.boaction.delmov: delete_single_msg: ('.__LINE__.'): done deleting, now 
call $GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: delete_single_msg: 
('.__LINE__.'): done deleting, now call 
$GLOBALS[phpgw]->msg->expunge_expungable_folders<br>'); }
                                        $did_expunge = False;
                                        $did_expunge = 
$GLOBALS['phpgw']->msg->expunge_expungable_folders('email.boaction.delmov 
(delete_single_msg) LINE '.__LINE__);
-                                       if ($this->debug > 1) { echo 
'email.boaction.delmov: delete_single_msg: ('.__LINE__.'): 
$GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'; }
+                                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov: delete_single_msg: 
('.__LINE__.'): $GLOBALS[phpgw]->msg->expunge_expungable_folders() returns 
['.serialize($did_expunge).']<br>'); }
                                }
                        }
                        else
                        {
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): get_arg_value(what) == 
unknown_value<br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
get_arg_value(what) == unknown_value<br>'); }
                                $error_str = '<p><center><b>'.lang('UNKNOWN 
ACTION')."<br> \r\n"
                                                .'called from 
'.$GLOBALS['PHP_SELF'].', delmov()'."<br> \r\n"
                                                .'</b></center></p>'."<br> 
\r\n";
@@ -492,7 +508,7 @@
                        }

                        // GOTO NECT PAGEVIEW VIA REDIRECT OR OBJECT CALL
-                       if ($this->debug > 0) { echo 'emai.boaction.delmov 
('.__LINE__.'): about to enter logic to display page defined in this URI: 
$this->redirect_to ['.$this->redirect_to.']<br>'; }
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): about 
to enter logic to display page defined in this URI: $this->redirect_to 
['.$this->redirect_to.']<br>'); }

                        /*!
                        @capability use_old_redirect_method
@@ -503,7 +519,7 @@
                        */
                        if ($this->use_old_redirect_method == True)
                        {
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): EXITING with OLD REDIRECT CODE : 
$this->use_old_redirect_method: 
['.serialize($this->use_old_redirect_method).']<br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
EXITING with OLD REDIRECT CODE : $this->use_old_redirect_method: 
['.serialize($this->use_old_redirect_method).']<br>'); }
                                $GLOBALS['phpgw']->redirect($this->redirect_to);
                                // kill this script, we re outa here...
                                if (is_object($GLOBALS['phpgw']->msg))
@@ -533,34 +549,44 @@
                                //sessionid
                                //kp3
                                //domain
-                       if ($this->debug > 1) { echo 'emai.boaction.delmov 
('.__LINE__.'): calling $this->set_expected_args($expected_args) ; 
$expected_args DUMP<pre>'; print_r($expected_args); echo '</pre>'; }
+                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
calling $this->set_expected_args($expected_args) ; $expected_args DUMP:', 
$expected_args); }
                        $this->set_expected_args($expected_args);
                        // the URI of the redirect string contains data needed 
for the next page view
-                       if ($this->debug > 1) { echo 'emai.boaction.delmov 
('.__LINE__.'): calling $this->set_new_args_uri($this->redirect_to) ; 
$this->redirect_to ['.$this->redirect_to.']<br>'; }
+                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
calling $this->set_new_args_uri($this->redirect_to) ; $this->redirect_to 
['.$this->redirect_to.']<br>'); }
                        $this->set_new_args_uri($this->redirect_to);
                        // clear existing args, apply the new arg enviornment,
                        // we get back the menuaction the redirect would have 
asked for
-                       if ($this->debug > 1) { echo 'emai.boaction.delmov 
('.__LINE__.'): calling $this->apply_new_args_env()<br>'; }
+                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
calling $this->apply_new_args_env()<br>'); }
                        $my_menuaction = $this->apply_new_args_env();
-                       if ($this->debug > 1) { echo 'emai.boaction.delmov 
('.__LINE__.'): $my_menuaction is ['.$my_menuaction.'] which was returned from 
$this->apply_new_args_env()<br>'; }
+                       if ($this->debug > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
$my_menuaction is ['.$my_menuaction.'] which was returned from 
$this->apply_new_args_env()<br>'); }
                        // (c) IF A "BIG MOVE", THEN TURN BACK ON THE SMART 
CACHE
                        // MOVED TO MSG CLASS
                        //if ((isset($initial_session_cache_extreme))
                        //&& ($initial_session_cache_extreme != '-1'))
                        //{
-                       //      if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): $initial_session_cache_extreme is set and 
is NOT "-1", meaning we issued a "big move" cache event, 
$initial_session_cache_extreme is 
['.serialize($initial_session_cache_extreme).'] <br>'; }
-                       //      if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): "big move" will turn off 
session_cache_extreme if it was TRUE, so we undo that for the next page view 
with: $GLOBALS[phpgw]->msg->session_cache_extreme = 
$initial_session_cache_extreme<br>'; }
+                       //      if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): $initial_session_cache_extreme is set 
and is NOT "-1", meaning we issued a "big move" cache event, 
$initial_session_cache_extreme is 
['.serialize($initial_session_cache_extreme).'] <br>'; }
+                       //      if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): "big move" will turn off 
session_cache_extreme if it was TRUE, so we undo that for the next page view 
with: $GLOBALS[phpgw]->msg->session_cache_extreme = 
$initial_session_cache_extreme<br>'; }
                        //      $GLOBALS['phpgw']->msg->session_cache_extreme = 
$initial_session_cache_extreme;
                        //}
                        //else
                        //{
-                       //      if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): $initial_session_cache_extreme is either 
NOT set or is "-1", meaning we did NOT issued a "big move" cache event 
earlier<br>'; }
+                       //      if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): $initial_session_cache_extreme is either 
NOT set or is "-1", meaning we did NOT issued a "big move" cache event 
earlier<br>'; }
                        //}

                        // imitate the next menuaction command with direct 
object calls
-                       if ($this->debug > 0) { echo 'emai.boaction.delmov 
('.__LINE__.'): LEAVING by creating "next_obj" and calling its menuaction verb 
...<br>'; }
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
LEAVING by creating "next_obj" and calling its menuaction verb ...<br>'); }
                        if (stristr($my_menuaction, 'uimessage'))
                        {
+                               //// NEW: mail so object group fill may need to 
be reset
+                               //// we DO NOT use group data capability on the 
message view page
+                               //// this allows the SO class to query for each 
individual thing it needs
+                               //// which is OK for a message view, but not 
for an index page
+                               
//$GLOBALS['phpgw']->msg->so->so_prop_use_group_data(False);
+                               // NEW: mail so object group fill may need to 
be reset
+                               //clear existing data, if any, and reset the 
query attempt excess counter
+                               
$GLOBALS['phpgw']->msg->so->so_prop_use_group_data(False);
+                               // then make sure group data capability it 
turned on
+                               
$GLOBALS['phpgw']->msg->so->so_prop_use_group_data(True);
                                // MAKE THE UIMESSAGE PAGE OBJECT
                                $this->next_obj = 
CreateObject('email.uimessage');
                                // CALL THE FUNCTION THAT DISPLAYS THE PAGE VIEW
@@ -569,6 +595,11 @@
                        // else just ASSUME uiindex, it is the most forgiving 
about missing values, it has fallback defaults to use if needed
                        else
                        {
+                               // NEW: mail so object group fill may need to 
be reset
+                               //clear existing data, if any, and reset the 
query attempt excess counter
+                               
$GLOBALS['phpgw']->msg->so->so_prop_use_group_data(False);
+                               // then make sure group data capability it 
turned on
+                               
$GLOBALS['phpgw']->msg->so->so_prop_use_group_data(True);
                                // MAKE THE INDEX PAGE OBJECT
                                $this->next_obj = CreateObject('email.uiindex');
                                // CALL THE FUNCTION THAT DISPLAYS THE PAGE VIEW
@@ -577,7 +608,7 @@
                        // (e) cleanup
                        if (is_object($GLOBALS['phpgw']->msg))
                        {
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): oops, not LEFT yet, cleanup and unset 
->msg object<br>'; }
+                               if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): oops, 
not LEFT yet, cleanup and unset ->msg object<br>'); }
                                // close down ALL mailserver streams
                                $GLOBALS['phpgw']->msg->end_request();
                                // destroy the object
@@ -585,11 +616,11 @@
                                unset($GLOBALS['phpgw']->msg);
                        }
                        // shut down this transaction
-                       if ($this->debug > 0) { echo 'emai.boaction.delmov 
('.__LINE__.'): LEAVING for <b>real</b> with 
$GLOBALS[phpgw]->common->phpgw_exit(False)<br>'; }
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.delmov ('.__LINE__.'): 
LEAVING for <b>real</b> with $GLOBALS[phpgw]->common->phpgw_exit(False)<br>'); }
                        $GLOBALS['phpgw']->common->phpgw_exit(False);
                }

-
+               /*
                // placeholder for previous test code
                function just_a_placeholder()
                {
@@ -597,7 +628,7 @@
                        // VIA REDIRECT OR DIRECT OBJECT CALL
                        if ($this->redirect_to != '')
                        {
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): next pageview redirect data to use is: 
['.$this->redirect_to.']<br>'; }
+                               if ($this->debug > 0) { echo 
'email.boaction.delmov ('.__LINE__.'): next pageview redirect data to use is: 
['.$this->redirect_to.']<br>'; }

                                // Experimental:
                                // NO REDIRECT - DIRECTLY MANUFACTURE THE NEXT 
PAGE VIEW RIGHT NOW
@@ -605,7 +636,7 @@
                                $recovered_data = array();
                                parse_str($this->redirect_to, $recovered_data);

-                               if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): redirect_to parsed_str $recovered_data 
DUMP:<pre>'; print_r($recovered_data); echo '</pre>'; }
+                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): redirect_to parsed_str $recovered_data 
DUMP:<pre>'; print_r($recovered_data); echo '</pre>'; }
                                // ALL POSSIBLE VARS WE MIGHT FIND IN THE 
REDIRECT URI:
                                $new_args_env = array(
                                        '/mail/index_php?menuaction'  => '-1',
@@ -618,7 +649,7 @@
                                        'order'         => '-1',
                                        'start'         => '-1'
                                );
-                               if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): known possible recovered_data elements 
init $new_args_env DUMP:<pre>'; print_r($new_args_env); echo '</pre>'; }
+                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): known possible recovered_data elements 
init $new_args_env DUMP:<pre>'; print_r($new_args_env); echo '</pre>'; }
                                // loop thru KNOWN POSSIBLE new_args_env 
elements, GATHER the ones that are filled for later use
                                reset($new_args_env);
                                while(list($key,$value) = each($new_args_env))
@@ -653,10 +684,10 @@
                                }
                                else
                                {
-                                       echo 'emai.boaction.delmov: LINE 
'.__LINE__.': ERROR getting valid acctnum for goto pageview, NO fldball NO 
msgball found <br>';
+                                       echo 'email.boaction.delmov: LINE 
'.__LINE__.': ERROR getting valid acctnum for goto pageview, NO fldball NO 
msgball found <br>';
                                }
-                               if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): known possible recovered_data elements 
<b>Post-Gather</b> $new_args_env DUMP:<pre>'; print_r($new_args_env); echo 
'</pre>'; }
-                               if ($this->debug > 1) { echo 
'emai.boaction.delmov ('.__LINE__.'): will use $new_acctnum ['.$new_acctnum.']; 
 and $new_folder ['.$new_folder.'], BUT FIRST unset selected existing class 
args <br>'; }
+                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): known possible recovered_data elements 
<b>Post-Gather</b> $new_args_env DUMP:<pre>'; print_r($new_args_env); echo 
'</pre>'; }
+                               if ($this->debug > 1) { echo 
'email.boaction.delmov ('.__LINE__.'): will use $new_acctnum 
['.$new_acctnum.'];  and $new_folder ['.$new_folder.'], BUT FIRST unset 
selected existing class args <br>'; }

                                // UNSET ARGS WE USED IN THIS PAGE BUT ARE NO 
LONGER NEEDED
                                
$GLOBALS['phpgw']->msg->unset_arg('delmov_list', $new_acctnum);
@@ -676,7 +707,7 @@
                                
$GLOBALS['phpgw']->msg->set_acctnum($new_acctnum);
                                $GLOBALS['phpgw']->msg->set_arg_value('folder', 
$new_folder, $new_acctnum);

-                               // (b) LOOP thru Gathered Args, setting the 
class args to those values
+                               // (b) LOOP thru Gathered Args, setting the 
class args to those values
                                reset($new_args_env);
                                while(list($key,$value) = each($new_args_env))
                                {
@@ -698,7 +729,7 @@
                                //}
                                // (d) make object and issue command
                                $new_menuaction = 
$new_args_env['index_php?menuaction'];
-                               if ($this->debug > 1 || $this->debug_new_env > 
1) { echo 'emai.boaction.delmov ('.__LINE__.'): $new_menuaction 
['.$new_menuaction.'] <br>'; }
+                               if ($this->debug > 1 || $this->debug_new_env > 
1) { echo 'email.boaction.delmov ('.__LINE__.'): $new_menuaction 
['.$new_menuaction.'] <br>'; }
                                if (stristr($new_menuaction, 'uimessage'))
                                {
                                        // MAKE THE UIMESSAGE PAGE OBJECT
@@ -728,7 +759,7 @@
                        }
                        else
                        {
-                               if ($this->debug > 0) { echo 
'emai.boaction.delmov ('.__LINE__.'): LEAVING, with ERROR, unhandled "where to 
go from here" condition<br>'; }
+                               if ($this->debug > 0) { echo 
'email.boaction.delmov ('.__LINE__.'): LEAVING, with ERROR, unhandled "where to 
go from here" condition<br>'; }
                                echo 'error: no redirect specified in 
'.$GLOBALS['PHP_SELF'].', delmov()'."<br> \r\n"
                                        .'error_str: '.$error_str."<br> \r\n";
                                // close down ALL mailserver streams
@@ -740,7 +771,7 @@
                                $GLOBALS['phpgw']->common->phpgw_exit(False);
                        }
                }
-
+               */

                /*!
                @function set_expected_args
@@ -760,11 +791,11 @@
                */
                function set_expected_args($comma_set_str='-1')
                {
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.set_expected_args ('.__LINE__.'): ENTERING<br>'; }
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.set_expected_args ('.__LINE__.'): param $comma_set_str: 
['.$comma_set_str.'] <br>'; }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_expected_args 
('.__LINE__.'): ENTERING<br>'); }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_expected_args 
('.__LINE__.'): param $comma_set_str: ['.$comma_set_str.'] <br>'); }
                        $exploded_expected_args = array();
                        $exploded_expected_args = explode(',',$comma_set_str);
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.set_expected_args ('.__LINE__.'): $exploded_expected_args 
DUMP:<pre>'; print_r($exploded_expected_args); echo '</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_expected_args 
('.__LINE__.'): $exploded_expected_args DUMP:', $exploded_expected_args); }

                        //$this->expected_args = array();
                        $this->expected_args = array();
@@ -774,8 +805,8 @@
                                $arg_name = $exploded_expected_args[$i];
                                $this->expected_args[$arg_name] = '-1';
                        }
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.set_expected_args ('.__LINE__.'): $this->expected_args 
DUMP:<pre>'; print_r($this->expected_args); echo '</pre>'; }
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.set_expected_args ('.__LINE__.'): LEAVING<br>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_expected_args 
('.__LINE__.'): $this->expected_args DUMP:', $this->expected_args); }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_expected_args 
('.__LINE__.'): LEAVING<br>'); }
                }

                /*!
@@ -790,9 +821,9 @@
                */
                function set_new_args_uri($new_args_uri='-1')
                {
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.set_new_args_uri ('.__LINE__.'): ENTERING, $new_args_uri 
['.$new_args_uri.']<br>'; }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.set_new_args_uri 
('.__LINE__.'): ENTERING, $new_args_uri ['.$new_args_uri.']<br>'); }
                        $this->new_args_uri = $new_args_uri;
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): LEAVING<br>'; }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): LEAVING<br>'); }
                }

                /*!
@@ -821,22 +852,42 @@
                */
                function apply_new_args_env()
                {
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): ENTERING<br>'; }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): ENTERING<br>'); }
                        $recovered_data = array();
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): source data is 
$this->new_args_uri DUMP:<pre>'; print_r($this->new_args_uri); echo '</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): source data is $this->new_args_uri DUMP:', 
$this->new_args_uri); }
                        parse_str($this->new_args_uri, $recovered_data);
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): used command "parsed_str" on 
that to get this $recovered_data DUMP:<pre>'; print_r($recovered_data); echo 
'</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): used command "parsed_str" on that to get this $recovered_data 
DUMP:', $recovered_data); }
+
+                       // NOTE PARSE_STR ***WILL ADD SLASHES*** TO ESCAPE 
QUOTES
+                       // NO MATTER WHAT YOUR MAGIC SLASHES SETTING IS
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): NOTE PARSE_STR ***WILL ADD SLASHES*** TO ESCAPE QUOTES NO 
MATTER WHAT YOUR MAGIC SLASHES SETTING IS **stripping slashes NOW*** from any 
folder names'.'<br>'); }
+                       if (isset($recovered_data['fldball']['folder']))
+                       {
+                               $recovered_data['fldball']['folder'] = 
stripslashes($recovered_data['fldball']['folder']);
+                               $recovered_data['fldball']['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($recovered_data['fldball']['folder']);
+                       }
+                       if (isset($recovered_data['msgball']['folder']))
+                       {
+                               $recovered_data['msgball']['folder'] = 
stripslashes($recovered_data['msgball']['folder']);
+                               $recovered_data['msgball']['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($recovered_data['msgball']['folder']);
+                       }
+                       if (isset($recovered_data['tf']))
+                       {
+                               $recovered_data['tf'] = 
stripslashes($recovered_data['tf']);
+                               $recovered_data['tf'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($recovered_data['tf']);
+                       }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): AFTER STRIPSLASH: used command "parsed_str" on that to get this 
$recovered_data DUMP:', $recovered_data); }

                        $new_args_env = array();
                        $new_args_env = $this->expected_args;
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): $this->expected_args 
DUMP:<pre>'; print_r($new_args_env); echo '</pre>'; }
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): initial $new_args_env 
DUMP:<pre>'; print_r($new_args_env); echo '</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): $this->expected_args DUMP:', $new_args_env); }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): initial $new_args_env DUMP:', $new_args_env); }

                        // loop thru KNOWN POSSIBLE new_args_env elements, 
GATHER the ones that are filled for later use
                        reset($new_args_env);
                        while(list($key,$value) = each($new_args_env))
                        {
-                               if ($this->debug_new_env > 1) { echo ' * 
('.__LINE__.') $key: ['.$key.']  $value: ['.$value.']<br>'; }
+                               if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out(' * ('.__LINE__.') $key: ['.$key.']  $value: 
['.$value.']<br>'); }
                                $known_arg = $key;
                                //handle the special URI not match case
                                if ($key == 'index_php?menuaction')
@@ -845,7 +896,7 @@
                                        reset($recovered_data);
                                        
while(list($recovered_key,$recovered_value) = each($recovered_data))
                                        {
-                                               if ($this->debug_new_env > 1) { 
echo ' * * ('.__LINE__.') $recovered_key: ['.$recovered_key.']  
$recovered_value: ['.$recovered_value.']<br>'; }
+                                               if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out(' * * ('.__LINE__.') $recovered_key: 
['.$recovered_key.']  $recovered_value: ['.$recovered_value.']<br>'); }
                                                if (stristr($recovered_key, 
'menuaction'))
                                                {
                                                        $new_args_env[$key] = 
$recovered_data[$recovered_key];
@@ -853,7 +904,7 @@
                                                        break;
                                                }
                                        }
-                                       if ($this->debug_new_env > 1) { echo ' 
** found menuaction ** ('.__LINE__.') 
['.$recovered_data[$recovered_key].']<br>'; }
+                                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out(' ** found menuaction ** ('.__LINE__.') 
['.$recovered_data[$recovered_key].']<br>'); }
                                }
                                elseif ((isset($recovered_data[$known_arg]))
                                && ((string)$recovered_data[$known_arg] != ''))
@@ -863,10 +914,10 @@
                                }
                        }
                        reset($new_args_env);
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): FIRST PASS filled available 
known possible recovered_data elements <b>Post-Gather</b> $new_args_env 
DUMP:<pre>'; print_r($new_args_env); echo '</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): FIRST PASS filled available known possible recovered_data 
elements <b>Post-Gather</b> $new_args_env DUMP:', $new_args_env); }

                        // we are NOT DONE yet, extract some more args that we 
derive from what we gathered so far
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): ADDITIONALLY extract embedded 
"*ball" items "acctnum" and "folder" AND if a "msgball", add a "uri" element to 
it<br>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): ADDITIONALLY extract embedded "*ball" items "acctnum" and 
"folder" AND if a "msgball", add a "uri" element to it<br>'); }
                        // GET GOOD ACCTNUM FOR THE UNSET COMMANDS BELOW
                        // and also get other useful info while we are at it 
(folder), and if we find a "msgball", make and add to it a "uri" element
                        if ($new_args_env['fldball'] != '-1')
@@ -881,44 +932,47 @@
                                // IMITATION: during grab_args_gpc, the code 
add an element [uri] to the existing msgball
                                // NOTE that for this uri element, the "folder" 
string shoulf be urlencoded
                                $new_uri_element =       
'msgball[msgnum]='.$new_args_env['msgball']['msgnum']
-                                                               
.'&msgball[folder]='.urlencode($new_args_env['msgball']['folder'])
+                                                               
//.'&msgball[folder]='.urlencode($new_args_env['msgball']['folder'])
+                                                               
//.'&msgball[folder]='.$GLOBALS['phpgw']->msg->prep_folder_out($new_args_env['msgball']['folder'])
+                                                               
.'&msgball[folder]='.$new_args_env['msgball']['folder']
                                                                
.'&msgball[acctnum]='.$new_args_env['msgball']['acctnum'];
                                $new_args_env['msgball']['uri'] = 
$new_uri_element;
                        }
                        else
                        {
-                               echo 'emai.boaction.apply_new_args_env: LINE 
'.__LINE__.': ERROR getting valid acctnum for goto pageview, NO fldball NO 
msgball found <br>';
+                               echo 'email.boaction.apply_new_args_env: LINE 
'.__LINE__.': ERROR getting valid acctnum for goto pageview, NO fldball NO 
msgball found <br>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env: LINE 
'.__LINE__.': ERROR getting valid acctnum for goto pageview, NO fldball NO 
msgball found <br>');
                        }
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): extracted additional data: 
will use $new_acctnum ['.$new_acctnum.'];  and $new_folder ['.$new_folder.'] 
<br>'; }
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): FINAL filled available known 
possible recovered_data elements <b>Post-Gather</b> $new_args_env DUMP:<pre>'; 
print_r($new_args_env); echo '</pre>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): extracted additional data: will use $new_acctnum 
['.$new_acctnum.'];  and $new_folder ['.$new_folder.'] <br>'); }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): FINAL filled available known possible recovered_data elements 
<b>Post-Gather</b> $new_args_env DUMP:', $new_args_env); }

                        // UNSET ARGS WE USED IN THIS PAGE BUT ARE NO LONGER 
NEEDED
                        // HELL, JUST UNSET ALL EXTERNAL ARGS
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): unset ALL known external 
class args as defined in array $GLOBALS[phpgw]->msg->known_external_args<br>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): unset ALL known external class args as defined in array 
$GLOBALS[phpgw]->msg->known_external_args<br>'); }
                        $loops = 
count($GLOBALS['phpgw']->msg->known_external_args);
                        for ($i = 0; $i < $loops; $i++)
                        {
                                $arg_name = 
$GLOBALS['phpgw']->msg->known_external_args[$i];
                                if 
($GLOBALS['phpgw']->msg->get_isset_arg($arg_name, $new_acctnum) == True)
                                {
-                                       if ($this->debug_new_env > 2) { echo ' 
* emai.boaction.apply_new_args_env ('.__LINE__.'):UNSETTING with 
$GLOBALS[phpgw]->msg->unset_arg('.$arg_name.', '.$new_acctnum.') <br>'; }
+                                       if ($this->debug_new_env > 2) { 
$GLOBALS['phpgw']->msg->dbug->out(' * email.boaction.apply_new_args_env 
('.__LINE__.'):UNSETTING with $GLOBALS[phpgw]->msg->unset_arg('.$arg_name.', 
'.$new_acctnum.') <br>'); }
                                        
$GLOBALS['phpgw']->msg->unset_arg($arg_name, $new_acctnum);
                                }
                                else
                                {
-                                       if ($this->debug_new_env > 2) { echo ' 
* emai.boaction.apply_new_args_env ('.__LINE__.'): <i>was not set $arg_name 
['.$arg_name.'];  and $new_acctnum ['.$new_acctnum.']</i><br>'; }
+                                       if ($this->debug_new_env > 2) { 
$GLOBALS['phpgw']->msg->dbug->out(' * email.boaction.apply_new_args_env 
('.__LINE__.'): <i>was not set $arg_name ['.$arg_name.'];  and $new_acctnum 
['.$new_acctnum.']</i><br>'); }
                                }
                        }

                        // REFILL ARGS WITH NEW PAGE VIEW VALUES
                        // (a) set the very important acctnum arg we collected 
earlier, and also the folder arg, because these values are _derived_ values
                        // they are not plainly in the $new_args_env as simple 
key and value elements, they were derived from some of them, though
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): BEGIN setting new arg env by 
setting the "new_acctnum" and "new_folder"<br>'; }
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): BEGIN setting new arg env by setting the "new_acctnum" and 
"new_folder"<br>'); }
                        $GLOBALS['phpgw']->msg->set_acctnum($new_acctnum);
                        $GLOBALS['phpgw']->msg->set_arg_value('folder', 
$new_folder, $new_acctnum);

-                       // (b) LOOP thru Gathered Args, setting the class args 
to those values
-                       if ($this->debug_new_env > 1) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): continue by LOOPING thru 
Final Gathered Args, setting the class args to those values that are not still 
"-1" (that data was found for)<br>'; }
+                       // (b) LOOP thru Gathered Args, setting the class args 
to those values
+                       if ($this->debug_new_env > 1) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): continue by LOOPING thru Final Gathered Args, setting the class 
args to those values that are not still "-1" (that data was found for)<br>'); }
                        reset($new_args_env);
                        while(list($key,$value) = each($new_args_env))
                        {
@@ -928,24 +982,24 @@
                                if ((!stristr($arg_name, 
'index_php?menuaction'))
                                && ($arg_value != '-1'))
                                {
-                                       if ($this->debug_new_env > 2) { echo ' 
* emai.boaction.apply_new_args_env ('.__LINE__.'): calling 
$GLOBALS[phpgw]->msg->set_arg_value('.$arg_name.', '.$arg_value.', 
'.$new_acctnum.') <br>'; }
+                                       if ($this->debug_new_env > 2) { 
$GLOBALS['phpgw']->msg->dbug->out(' * email.boaction.apply_new_args_env 
('.__LINE__.'): calling $GLOBALS[phpgw]->msg->set_arg_value('.$arg_name.', 
'.$arg_value.', '.$new_acctnum.') <br>'); }
                                        
$GLOBALS['phpgw']->msg->set_arg_value($arg_name, $arg_value, $new_acctnum);
                                }
                        }
                        //$my_menuaction = 
$new_args_env['/mail/index_php?menuaction'];
-                       if ($this->debug_new_env > 0) { echo 
'emai.boaction.apply_new_args_env ('.__LINE__.'): LEAVING, returning next 
menuaction command $my_menuaction ['.$my_menuaction.'] <br>'; }
+                       if ($this->debug_new_env > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.apply_new_args_env 
('.__LINE__.'): LEAVING, returning next menuaction command $my_menuaction 
['.$my_menuaction.'] <br>'); }
                        return $my_menuaction;
                }

                /*!
                @function get_attach
-               @abstract browser requests a specific MIME part number, this 
function will get it from the mail server
+               @abstract browser requests a specific MIME part number, this 
function will get it from the mail server
                and send it to the browser.
                @author Angles and previous maintainers
-               @discussion Uses the phpgw api browser class to generate the 
headers which preceed the actual attachment
-               data. Note this is tricky because different browsers, 
especially the MSIE versions, require different headers
-               to be present in order to handle the data effectively at the 
clients browser. Incorrect headers can cause things
-               like the browser not getting the name of the attachment, or not 
starting the associated viewer for the attachment,
+               @discussion Uses the phpgw api browser class to generate the 
headers which preceed the actual attachment
+               data. Note this is tricky because different browsers, 
especially the MSIE versions, require different headers
+               to be present in order to handle the data effectively at the 
clients browser. Incorrect headers can cause things
+               like the browser not getting the name of the attachment, or not 
starting the associated viewer for the attachment,
                or even several save_or_open dialogs in a row.
                */
                function get_attach()
@@ -955,46 +1009,51 @@
                        $GLOBALS['phpgw_info']['flags']['nofooter'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-
+
                        $this->msg_bootstrap = 
CreateObject('email.msg_bootstrap');
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.boaction.get_attach', 
$this->debug);
-
-                       if ($this->debug > 0) { echo 'emai.boaction.get_attach: 
creating $this->browser <br>'; }
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('email.boaction.get_attach', 
$this->debug);
+
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.get_attach: creating 
$this->browser <br>'); }
                        $this->browser = CreateObject('phpgwapi.browser');
-
+
                        $msgball = 
$GLOBALS['phpgw']->msg->get_arg_value('msgball');
                        if (!isset($msgball['part_no']))
                        {
                                $part_no = 
$GLOBALS['phpgw']->msg->get_arg_value('part_no');
                                $msgball['part_no'] = $part_no;
                        }
-
+
                        // decode rfc2047 encoded attachment name MIME part 
headers
                        // see RFC2047 "Message Header Extensions for Non-ASCII 
Text"
-                       $att_name = 
$GLOBALS['phpgw']->msg->decode_rfc_header($GLOBALS['phpgw']->msg->get_arg_value('name'));
-                       if (($att_name != 
$GLOBALS['phpgw']->msg->get_arg_value('name'))
+                       
$defanged_name=urldecode($GLOBALS['phpgw']->msg->get_arg_value('name'));
+                       $att_name = 
$GLOBALS['phpgw']->msg->decode_rfc_header($defanged_name);
+                       //Check if the name changed thru the header decoding im 
not shure
+                       if (($att_name != 
urldecode($GLOBALS['phpgw']->msg->get_arg_value('name')))
                        && (trim($att_name) != '')
-                       && (trim($GLOBALS['phpgw']->msg->get_arg_value('name')) 
!= ''))
+                       && 
(trim(urldecode($GLOBALS['phpgw']->msg->get_arg_value('name'))) != ''))
                        {
                                $GLOBALS['phpgw']->msg->set_arg_value('name', 
$att_name);
                        }
-
+
                        $mime = 
strtolower($GLOBALS['phpgw']->msg->get_arg_value('type')) .'/' 
.strtolower($GLOBALS['phpgw']->msg->get_arg_value('subtype'));
-                       
$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime);
-
-                       //echo 'get all args dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->get_all_args()); echo '</pre>';
-                       //echo '$mime: ['.$mime.']<br>';
-                       //echo '$GLOBALS[phpgw]->msg->get_arg_value(encoding): 
['.$GLOBALS['phpgw']->msg->get_arg_value('encoding').']<br>';
-
+                       // do not do this until we get a length
+                       
//$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime);
+
+                       ////echo 'get all args dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->get_all_args()); echo '</pre>';
+                       ////echo '$mime: ['.$mime.']<br>';
+                       ////echo 
'$GLOBALS[phpgw]->msg->get_arg_value(encoding): 
['.$GLOBALS['phpgw']->msg->get_arg_value('encoding').']<br>';
+
                        // ----  'irregular' "view raw message" functionality  
----
                        if ($msgball['part_no'] == 'raw_message')
                        {
+                               // NOTE no length for this purpose
+                               
$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime);
                                // to dump out the whole raw message, do this:
                                // 1) output the headers, 2) output the raw 
body 3) output a "closing" CRLF
                                //headers_msgball will be used get the message 
headers, by specifying "part_no" = 0
                                $headers_msgball = $msgball;
                                $headers_msgball['part_no'] = 0;
-                               // that can also be used to ge tthe raw message 
body because phpgw_body() doesn't care about "part_no"
+                               // that can also be used to ge tthe raw message 
body because phpgw_body() doesn't care about "part_no"
                                echo 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($headers_msgball);
                                echo 
$GLOBALS['phpgw']->msg->phpgw_body($headers_msgball);
                                echo "\r\n";
@@ -1002,15 +1061,30 @@
                        // ---- "regular" attachment handling  ----
                        elseif 
($GLOBALS['phpgw']->msg->get_arg_value('encoding') == 'base64')
                        {
-                               echo 
$GLOBALS['phpgw']->msg->de_base64($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               //echo 
$GLOBALS['phpgw']->msg->de_base64($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               $this->output_data = 
$GLOBALS['phpgw']->msg->de_base64($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               $size = strlen($this->output_data);
+                               
$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime, $size);
+                               echo $this->output_data;
+                               $this->output_data = '';
                        }
                        elseif 
($GLOBALS['phpgw']->msg->get_arg_value('encoding') == 'qprint')
                        {
-                               echo 
$GLOBALS['phpgw']->msg->qprint($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               //echo 
$GLOBALS['phpgw']->msg->qprint($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               $this->output_data = 
$GLOBALS['phpgw']->msg->qprint($GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball));
+                               $size = strlen($this->output_data);
+                               
$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime, $size);
+                               echo $this->output_data;
+                               $this->output_data = '';
                        }
                        else
                        {
-                               echo 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
+                               //echo 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
+                               $this->output_data = 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
+                               $size = strlen($this->output_data);
+                               
$this->browser->content_header($GLOBALS['phpgw']->msg->get_arg_value('name'), 
$mime, $size);
+                               echo $this->output_data;
+                               $this->output_data = '';
                        }
                        // you may feed "end_request" a msgball or a fldball 
and "end_request" will close the acctnum specified therein
                        //$GLOBALS['phpgw']->msg->end_request($msgball);
@@ -1023,25 +1097,25 @@
                        // shut down this transaction
                        $GLOBALS['phpgw']->common->phpgw_exit(False);
                }
-
+
                /*!
                @function view_html
                @abstract special handler to view certain types of html mail
                @author Angles
-               @discussion Used in special cases when simply giving the client 
browser unprocessed html MIME part(s)
-               is not a good idea or needs special attention. Not a good idea 
means that there is CSS in the html part which would
-               totally b0rk the look of the clients browser, or certain 
unusual script. Special Handling means a MULTIPART
-               RELATED message such as Outkrook stationary or Evolutions 
version of the same, where the html has IMG
-               tags in it that are not real HREFs but rather a reference to 
another MIME part in the same message. To handle
-               that this message display code swaps that IMG mime part 
reference with an actual URL used by "get_attach" function
-               to retrieve that particular MIME part from the email server and 
send it to the browser, this the IMG appears in the
-               HTML message as intended. In that case the processing is done 
before the message is dispayed, and the processed HTML
-               part is stored as a form hiddenvar in base64 encoded format. 
The user sees a button saying "View HTML", if clicked this
-               processed HTML part is submitted to this function which base64 
decodes it and sends it to the browser as a simgle
-               html page, not a part of a mail like is typical. In either case 
the user gets that button and the buttons associated form
-               submits data to this function. If the part is not RELATED, i.e. 
did not require special IMG tag swapping, then this
-               function gets submitted to is a reference to the particular 
HTML part of the message and it is sent to the browser
-               as a page unto itself. In either case, the part is not 
displayed inline with other MIME parts, not displayed in the same
+               @discussion Used in special cases when simply giving the client 
browser unprocessed html MIME part(s)
+               is not a good idea or needs special attention. Not a good idea 
means that there is CSS in the html part which would
+               totally b0rk the look of the clients browser, or certain 
unusual script. Special Handling means a MULTIPART
+               RELATED message such as Outkrook stationary or Evolutions 
version of the same, where the html has IMG
+               tags in it that are not real HREFs but rather a reference to 
another MIME part in the same message. To handle
+               that this message display code swaps that IMG mime part 
reference with an actual URL used by "get_attach" function
+               to retrieve that particular MIME part from the email server and 
send it to the browser, this the IMG appears in the
+               HTML message as intended. In that case the processing is done 
before the message is dispayed, and the processed HTML
+               part is stored as a form hiddenvar in base64 encoded format. 
The user sees a button saying "View HTML", if clicked this
+               processed HTML part is submitted to this function which base64 
decodes it and sends it to the browser as a simgle
+               html page, not a part of a mail like is typical. In either case 
the user gets that button and the buttons associated form
+               submits data to this function. If the part is not RELATED, i.e. 
did not require special IMG tag swapping, then this
+               function gets submitted to is a reference to the particular 
HTML part of the message and it is sent to the browser
+               as a page unto itself. In either case, the part is not 
displayed inline with other MIME parts, not displayed in the same
                browser window as the rest of the groupware template, instead 
this part will be viewed in its own page.
                */
                function view_html()
@@ -1051,13 +1125,13 @@
                        $GLOBALS['phpgw_info']['flags']['nofooter'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-
+
                        $this->msg_bootstrap = 
CreateObject('email.msg_bootstrap');
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.boaction.get_attach', 
$this->debug);
-
-                       if ($this->debug > 0) { echo 'emai.boaction.view_html: 
creating $this->browser <br>'; }
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('email.boaction.get_attach', 
$this->debug);
+
+                       if ($this->debug > 0) { 
$GLOBALS['phpgw']->msg->dbug->out('email.boaction.view_html: creating 
$this->browser <br>'); }
                        $this->browser = CreateObject('phpgwapi.browser');
-
+
                        //$this->browser->content_header($name,$mime);
                        if 
((($GLOBALS['phpgw']->msg->get_isset_arg('html_part')))
                        && ($GLOBALS['phpgw']->msg->get_arg_value('html_part') 
!= ''))

====================================================
Index: email/inc/class.boattach_file.inc.php
diff -u email/inc/class.boattach_file.inc.php:1.4 
email/inc/class.boattach_file.inc.php:1.5
--- email/inc/class.boattach_file.inc.php:1.4   Fri Mar 14 04:00:10 2003
+++ email/inc/class.boattach_file.inc.php       Thu Dec 30 23:13:50 2004
@@ -146,7 +146,7 @@
                @abstract there are 2 vars this script needs to do somethig, 
"this->action" and "this->delete", so
                we use this function to fill those vars from GPC values here, 
but in the future they could be filled
                via some external method.  In the days before superglobals, 
these were simple vars "$action" and
-               also "$delete", but such simple days are over.
+               also "$delete", but such simple days are over.
                */
                function fill_control_data_gpc()
                {
@@ -277,7 +277,7 @@
                        if (isset($this->var_holder) == False)
                        {
                                echo 'emai.boattach_file.attach ('.__LINE__.'): 
ERROR: initial $this->var_holder needs to be set by this point in the code 
<br>';
-                       }
+                       }

                        // initialize some variables
                        $alert_msg = '';
@@ -372,7 +372,7 @@
                        {
                                srand((double)microtime()*1000000);
                                $random_number = rand(100000000,999999999);
-                               $newfilename = 
md5($this->file_data['file_tmp_name'].', '.$this->file_data['file_name'].', 
'.$GLOBALS['phpgw_info']['user']['sessionid'].time().getenv('REMOTE_ADDR').$random_number);
+                               $newfilename = 
md5($this->file_data['file_tmp_name'].', '.$this->file_data['file_name'].', 
'.$GLOBALS['phpgw_info']['user']['sessionid'].time().$_SERVER['REMOTE_ADDR'].$random_number);

                                // Check for uploaded file of 0-length, or no 
file (patch from Zone added by Milosch)
                                //if ($this->file_data['file_tmp_name'] == 
"none" && $this->file_data['file_size'] == 0) This could work also
@@ -382,7 +382,7 @@
                                }
                                else
                                {
-                                       copy($this->file_data['file_tmp_name'], 
$this->uploaddir.SEP.$newfilename);
+                                       
move_uploaded_file($this->file_data['file_tmp_name'], 
$this->uploaddir.SEP.$newfilename);
                                }

                                $ftp = fopen($this->uploaddir.SEP.$newfilename 
. '.info','wb');
@@ -395,7 +395,7 @@
                                $langed_attach_file = lang("Attach File");
                                $alert_msg = lang('Input Error:').'<br>'
                                        . lang('Please submit a filename to 
attach').'<br>'
-                                       . lang('You must click').' 
"'.lang('Attach File').'" '.lang('for the file to actually upload').'<br>'
+                                       . lang('You must click %1 for the file 
to actually upload','"'.lang('Attach File').'"').'.<br>'
                                        . '<br>';
                        }


====================================================
Index: email/inc/class.bocompose.inc.php
diff -u email/inc/class.bocompose.inc.php:1.8 
email/inc/class.bocompose.inc.php:1.9
--- email/inc/class.bocompose.inc.php:1.8       Fri Mar 14 04:00:10 2003
+++ email/inc/class.bocompose.inc.php   Thu Dec 30 23:13:50 2004
@@ -27,6 +27,12 @@
                var $my_validator;
                var $msg_bootstrap;

+               // reply messages get this "quoting" prefix to each line
+               // NEW we use the global msg->reply_prefix instead of this one 
here
+               //var $reply_prefix = '>';
+               //var $reply_prefix = '> ';
+               //var $reply_prefix = '| ';
+
                // CHOOSE YOUR ADDRESSBOOK
                var $addybook_choice;

@@ -50,8 +56,57 @@
                }

                /*!
+               @function recall_desired_action
+               @abstract used to preserve if this originated as a reply, 
replyall, forward, or new mail
+               @author Angles
+               @discussion Line lengths will differ for new mail and forwarded 
orig body, vs. reply mail that has longer
+               lines. So this preserves this info for later use. Particularly 
we like to preserve this thru the spelling pass also.
+               We look for GPC args "action" or "orig_action", as keys, and 
their
+               values are limited to "reply", "replyall", "forward", and 
"new", with "new" being deduced on the
+               initial compose page call and put into "orig_action" for later 
use, while the others possible "action"
+               values simply get stored in "orig_action" no deduction is 
required, it is specified.
+               If new future actions are added, adjust this function 
accordingly.
+               @access public
+               // MOVED TO MAIL_MSG_BASE BECAUSE WE ALSO NEED THIS IN CLASS 
BOSEND
+               function recall_desired_action()
+               {
+                       // what action are we dealing with here, reply(all), 
forward, or newmail
+                       // we care because new and forward get different line 
length then reply mail that has ">"
+                       $orig_action = 'unknown';
+                       if (($GLOBALS['phpgw']->msg->get_isset_arg('action'))
+                       && (
+                               
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'forward')
+                               || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'reply')
+                               || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'replyall')
+                               )
+                       )
+                       {
+                               $orig_action = 
$GLOBALS['phpgw']->msg->get_arg_value('action');
+                       }
+                       elseif 
(($GLOBALS['phpgw']->msg->get_isset_arg('orig_action'))
+                       && (
+                               
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'forward')
+                               || 
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'reply')
+                               || 
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'replyall')
+                               || 
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'new')
+                               )
+                       )
+                       {
+                               $orig_action = 
$GLOBALS['phpgw']->msg->get_arg_value('orig_action');
+                       }
+                       else
+                       {
+                               // if not reply, replyall, nor forward 
"action", then we have NEW message
+                               // if this is set now then the above 
"orig_action" should preserve it
+                               $orig_action = 'new';
+                       }
+                       return $orig_action;
+               }
+               */
+
+               /*!
                @function get_compose_form_action_url
-               @abstract ?
+               @abstract makes the html action target for the send button on 
the compose page
                @param $menuaction_target (string)
                @author Angles
                @discussion Used by this class and also exposes some usefull 
functionality, mail.spell uses this function, for example.
@@ -86,6 +141,8 @@
                                                
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                                
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                                
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
+                                               // this is somewhat redundant 
in this particular case
+                                               
.'&orig_action='.$GLOBALS['phpgw']->msg->recall_desired_action()
                                );
                                if 
(($GLOBALS['phpgw']->msg->get_isset_arg('action'))
                                && 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'forward')
@@ -118,6 +175,8 @@
                                                
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                                
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                                
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
+                                               // when this hits bosend it is 
useful to know if it is a reply  or not for linebreak purposes
+                                               
.'&orig_action='.$GLOBALS['phpgw']->msg->recall_desired_action()
                                );
                        }
                        else
@@ -136,10 +195,13 @@
                                                
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                                
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                                
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
+                                               // when this hits bosend it is 
useful to know if it is a reply  or not for linebreak purposes
+                                               
.'&orig_action='.$GLOBALS['phpgw']->msg->recall_desired_action()
                                );
                        }
                        return $send_btn_action;
                }
+
                /*!
                @function quote_inline_message
                @abstract Handle quoting, cleaning up of replied or inline 
forwarded messages
@@ -167,6 +229,7 @@
                                                $msgball['part_no'] = '1';
                                        }

+                                       $bodystring = '';
                                        $bodystring = 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
                                        // see if we have to un-do qprint (or 
other) encoding of the part we are about to quote
                                        if 
(($GLOBALS['phpgw']->msg->get_isset_arg('encoding'))
@@ -224,6 +287,8 @@
                                        }
                                        // explode into an array
                                        $body_array = explode("\r\n", 
$bodystring);
+                                       // cleanup, we do not need $bodystring 
var anymore
+                                       $bodystring = '';
                                        // add the ">" quoting char to the 
beginning of each line
                                        // note, this *will* loop at least once 
assuming the body has one line at least
                                        // therefor the var "body" *will* get 
filled
@@ -231,9 +296,13 @@
                                        {
                                                // add the ">" so called 
"quoting" char to the original body text
                                                // NOTE: do NOT trim the LEFT 
part of the string, use RTRIM instead
-                                               $this_line = '>' . 
rtrim($body_array[$bodyidx]) ."\r\n";
+                                               //$this_line = '>' . 
rtrim($body_array[$bodyidx]) ."\r\n";
+                                               //$this_line = 
$this->reply_prefix . rtrim($body_array[$bodyidx]) ."\r\n";
+                                               $this_line = 
$GLOBALS['phpgw']->msg->reply_prefix . rtrim($body_array[$bodyidx]) ."\r\n";
                                                $body .= $this_line;
                                        }
+                                       // cleanup
+                                       $body_array = array();

                                        // email needs to be sent with NO 
ENCODED HTML ENTITIES
                                        // it's up to the endusers MUA to 
handle any htmlspecialchars
@@ -276,6 +345,7 @@
                                $body = 
$GLOBALS['phpgw']->msg->htmlspecialchars_decode($body);
                                // now we know all (all ?) html specialchars 
are decoded, so we will not get that erronious encoding of the ampersand that 
is actually itself part of an html specialchar
                                $body = 
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($body);
+                               // NOTE this goes back into the textbox with 
out changing the line lengths yet, that happens later

                        // ----  Handle Replying and Forwarding  -----
                        }
@@ -382,11 +452,14 @@
                                        // ----  Begin The Message Body  (of 
the body we are replying to) -----
                                        $who_wrote = 
$GLOBALS['phpgw']->msg->get_who_wrote($msg_headers);
                                        $lang_wrote = lang('wrote');
+                                       // 2 blank lines (humm, why 3 crlf  
then)
                                        $body =  "\r\n"
                                                ."\r\n"
-                                               ."\r\n".$who_wrote .' 
'.$lang_wrote.': '
-                                               ."\r\n".'>'
-                                               ."\r\n";
+                                               ."\r\n"
+                                               // the who wrote line
+                                               .$who_wrote .' '.$lang_wrote.': 
'."\r\n"
+                                               // then one blank quoted line 
b4 the quoted body
+                                               
.$GLOBALS['phpgw']->msg->reply_prefix."\r\n";

                                        // ----  Quoted Bodystring of Re: 
Message is the "First Presentable" part  -----
                                        // as determimed in class.bomessage and 
passed in the uri as "msgball[part_no]=X.X"
@@ -405,6 +478,7 @@
                                                $msgball['part_no'] = '1';
                                        }

+                                       $bodystring = '';
                                        $bodystring = 
$GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
                                        // see if we have to un-do qprint (or 
other) encoding of the part we are about to quote
                                        if 
(($GLOBALS['phpgw']->msg->get_isset_arg('encoding'))
@@ -444,34 +518,58 @@
                                        //$bodystring = 
preg_replace("/--\s{0,1}\r\n(.{1,}\r\n){1,5}/smx", "", $bodystring);
                                        // sig = "dash dash space CRLF 
(anything and CRLF) repeated 1 to 5 times"
                                        //$bodystring = 
preg_replace("/--\s{0,1}\r\n.(?!>)(.{1,}\r\n){1,5}/smx", "", $bodystring);
+                                       // THIS ONE DOES IT - USE THIS ONE
                                        $bodystring = 
preg_replace("/\r\n[-]{2}\s{0,1}\r\n\w.{0,}\r\n(.{1,}\r\n){0,4}/", "\r\n", 
$bodystring);
                                        // sig = "CRLF dash dash space(0or1) 
CRLF anyWordChar anything CRLF (anything and CRLF) repeated 0 to 4 times"

-                                       //now is a good time to trim the body
+                                       //now is a good time to trim the 
retireved bodystring
                                        trim($bodystring);

                                        // ----- Quote The Body You Are 
Replying To With ">"  ------
                                        $body_array = array();
+                                       // NOTE compose page html has a 
textarea with "cols" set to 84
+                                       // this means on submit the text 
automatically is hardwrapped to 84 chars
+                                       // NEW - NOT ANY MORE, no more 
wrap=hard in the html-textbox tags
+                                       // I did this so replies to messages 
already having "> " added will not wrap to early
+                                       // because the message lines are 
lengthened by 1 or 2 chars already due to the
+                                       // already existing "> " and there may 
be many of them already.
+                                       // HOWEVER a new message should go out 
with standard 78 char line length (see below)
+
                                        // we need *some* line breaks in the 
body so we know where to add the ">" quoting char(s)
                                        // some relatively short emails may not 
have any CRLF pairs, but may have a few real long lines
                                        //so, add linebreaks to the body if 
none are already existing
                                        if (!ereg("\r\n", $bodystring))
                                        {
                                                // aim for a 74-80 char line 
length
-                                               $bodystring = 
$GLOBALS['phpgw']->msg->body_hard_wrap($bodystring, 74);
+                                               //$bodystring = 
$GLOBALS['phpgw']->msg->body_hard_wrap($bodystring, 74);
+                                               $bodystring = 
$GLOBALS['phpgw']->msg->body_hard_wrap($bodystring, 78);
+                                       }
+                                       else
+                                       {
+                                               // NEW CHANGE: compose page no 
longer wraps hard
+                                               // this bodystring is the text 
we are about to add reply quotes to
+                                               // it may already have CRLF but 
the line lengths could be too darn long
+                                               // AND so we need to have 
somewhat sane line lengths fed to the textbox
+                                               // AND we need to have sane 
line lengths before we add the quote char
+                                               // since textbox will happily 
submit any length line to the send code and look stupid maybe
+                                               $bodystring = 
$GLOBALS['phpgw']->msg->body_hard_wrap($bodystring, 88);
                                        }
-                                       // explode into an array
                                        $body_array = explode("\r\n", 
$bodystring);
+                                       // cleanup, we do not need $bodystring 
var anymore
+                                       $bodystring = '';
                                        // add the ">" quoting char to the 
beginning of each line
                                        // note, this *will* loop at least once 
assuming the body has one line at least
                                        // therefor the var "body" *will* get 
filled
-                                       for ($bodyidx = 0; $bodyidx < 
count($body_array); ++$bodyidx)
+                                       $body_array_count = count($body_array);
+                                       for ($bodyidx = 0; $bodyidx < 
$body_array_count; ++$bodyidx)
                                        {
                                                // add the ">" so called 
"quoting" char to the original body text
                                                // NOTE: do NOT trim the LEFT 
part of the string, use RTRIM instead
-                                               $this_line = '>' . 
rtrim($body_array[$bodyidx]) ."\r\n";
+                                               $this_line = 
$GLOBALS['phpgw']->msg->reply_prefix . rtrim($body_array[$bodyidx]) ."\r\n";
                                                $body .= $this_line;
                                        }
+                                       // cleanup
+                                       $body_array = array();

                                        // email needs to be sent with NO 
ENCODED HTML ENTITIES
                                        // it's up to the endusers MUA to 
handle any htmlspecialchars
@@ -613,9 +711,10 @@
                        $addylink_lex = $GLOBALS['phpgw']->link(
                                "/index.php",
                                        array(
-                                               
"menuaction"=>"email.uijsaddressbook.show",
+                                               
"menuaction"=>"phpgwapi.uijsaddressbook.show",
                                                "viewmore" => "1",
-                                               "cat_id" => "-1"
+                                               "cat_id" => "-1",
+                                               "update_opener" => "1"
                                        )
                        );
                        //echo '$addylink_lex: '.$addylink_lex.'<br>';
@@ -730,7 +829,7 @@
                                $bccval="<a 
href=\"javascript:addybook('&hideto=1&hidecc=1')\">".lang("bcc")."</a>";
                                //another thing to do is this: if we hit a 
compose page this is a new mesage
                                //the little addressbook should forget all its 
cache
-                               
$jsaddybookui=CreateObject('email.uijsaddressbook');
+                               
$jsaddybookui=CreateObject('phpgwapi.uijsaddressbook',true);
                                $jsaddybookui->forget_all(1);
                        }
                        else

====================================================
Index: email/inc/class.bofilters.inc.php
diff -u email/inc/class.bofilters.inc.php:1.14 
email/inc/class.bofilters.inc.php:1.15
--- email/inc/class.bofilters.inc.php:1.14      Fri Mar 14 04:00:10 2003
+++ email/inc/class.bofilters.inc.php   Thu Dec 30 23:13:50 2004
@@ -721,6 +721,11 @@
                        // 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
+
+                       // NEW we need to wipe the cached filters
+                       $my_location = '0;cached_prefs';
+                       if ($this->debug_set_prefs > 1) { echo 
'bofilters.save_all_filters_to_repository('.__LINE__.'): NEW: EXPIRE CACHED 
PREFERENCES, calling ->msg->so->so_appsession_passthru('.$my_location.', " 
")<br>'; }
+                       
$GLOBALS['phpgw']->msg->so->so_appsession_passthru($my_location, ' ');

                        // first we delete any existing data at the desired 
prefs location
                        $pref_struct_str = '["filters"]';
@@ -796,7 +801,7 @@
                                // $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"
+                               // $this_filter['actions'][X]['stop_filtering'] 
UNSET | SET string "True"
                                for ($i=0; $i < count($this_filter['actions']); 
$i++)
                                {
                                        // judgement
@@ -886,27 +891,32 @@
                */
                function do_filter()
                {
-                       if ($this->debug > 0) { echo 'bofilters.do_filter: 
ENTERING<br>'; }
+                       if ($this->debug > 0) { echo 
'bofilters.do_filter('.__LINE__.'): ENTERING<br>'; }
                        if (count($this->all_filters) == 0)
                        {
-                               if ($this->debug > 0) { echo 
'bofilters.do_filter: LEAVING with ERROR, no filters exist<br>'; }
+                               if ($this->debug > 0) { echo 
'bofilters.do_filter('.__LINE__.'): LEAVING with ERROR, no filters exist<br>'; }
                                return False;
                        }

                        //if ($this->debug > 0) { echo 'bofilters.do_filter: 
LINE '.__LINE__.' call "->msg->event_begin_big_move" to notice event of 
impending big batch moves or deletes<br>'; }
+                       // CORRECTION: the move function now buffers the 
commands and the count of those buffered commands is kept there, where big move 
or not is now determined
                        //$GLOBALS['phpgw']->msg->event_begin_big_move(array(), 
'bofilters.do_filter: LINE '.__LINE__);

+                       // filtering thousands of messages can require more time
+                       if ($this->debug > 0) { echo 
'bofilters.do_filter('.__LINE__.'): calling set_time_limit giving value of 120 
ie 2 minutes? <br>'; }
+                       set_time_limit(120);
+
                        // "False" means  return $this->not_set  if no filter 
number was found anywhere
                        $found_filter_num = $this->obtain_filer_num(False);
-                       if ($this->debug > 1) { echo 
'bofilters.obtain_filer_num: $found_filter_num : 
[<code>'.serialize($found_filter_num).'</code>]<br>'."\r\n"; }
+                       if ($this->debug > 1) { echo 
'bofilters.do_filter('.__LINE__.'): $found_filter_num : 
[<code>'.serialize($found_filter_num).'</code>]<br>'."\r\n"; }

                        if ($found_filter_num == $this->not_set)
-                       {
+                       {
                                // NO filter number was specified, that means 
run ALL filters
                                $this->do_filter_apply_all = True;
                                for ($filter_idx=0; $filter_idx < 
count($this->all_filters); $filter_idx++)
                                {
-                                       if ($this->debug > 1) { echo 
'bofilters.do_filter: run_all_finters_mode: calling 
$this->run_single_filter['.$filter_idx.']<br>'; }
+                                       if ($this->debug > 1) { echo 
'bofilters.do_filter('.__LINE__.'): run_all_finters_mode: calling 
$this->run_single_filter['.$filter_idx.']<br>'; }
                                        
$this->run_single_filter((int)$filter_idx);
                                        if ($this->just_testing())
                                        {
@@ -919,7 +929,7 @@
                        {
                                // we were given a filter_num, that means run 
THAT FILTER ONLY
                                $this->do_filter_apply_all = False;
-                               if ($this->debug > 1) { echo 
'bofilters.do_filter: run_single_filter mode: calling 
$this->run_single_filter['.$found_filter_num.']<br>'; }
+                               if ($this->debug > 1) { echo 
'bofilters.do_filter('.__LINE__.'): run_single_filter mode: calling 
$this->run_single_filter['.$found_filter_num.']<br>'; }
                                
$this->run_single_filter((int)$found_filter_num);
                                if ($this->just_testing())
                                {
@@ -955,32 +965,34 @@
                                $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
                                $GLOBALS['phpgw']->common->phpgw_header();

-                               echo '<h4>Apply Filters Report:</h4>'."\r\n";
+                               echo '<h4>'.lang('Apply Filters 
Report:').'</h4>'."\r\n";
                                for ($filter_idx=0; $filter_idx < 
count($this->all_filters); $filter_idx++)
                                {
                                        $this_filter = 
$this->all_filters[$filter_idx];
                                        $num_matches = 
count($this->each_filter_mball_list[$filter_idx]);
                                        
parse_str($this_filter['actions'][0]['folder'], $target_folder);
                                        echo '<p>'."\r\n"
-                                       .'<strong>Filter number 
'.(string)$filter_idx.':</strong>'.'<br>'."\r\n"
-                                       .'&nbsp;&nbsp;&nbsp;'.'filter name: 
['.$this_filter['filtername'].']<br>'."\r\n"
-                                       .'&nbsp;&nbsp;&nbsp;'.'number of 
matches: ['.(string)$num_matches.']'.'<br>'."\r\n"
-                                       .'&nbsp;&nbsp;&nbsp;'.'requested filter 
action: ['.$this_filter['actions'][0]['judgement'].'] ; Acctnum 
['.(string)$target_folder['acctnum'].'] ;  Folder: 
['.htmlspecialchars($target_folder['folder']).']<br>'."\r\n"
+                                       .'<strong>'.lang('Filter number').' 
'.(string)$filter_idx.':</strong>'.'<br>'."\r\n"
+                                       .'&nbsp;&nbsp;&nbsp;'.lang('filter 
name:').' ['.$this_filter['filtername'].']<br>'."\r\n"
+                                       .'&nbsp;&nbsp;&nbsp;'.lang('number of 
matches:').' ['.(string)$num_matches.']'.'<br>'."\r\n"
+
+                                       .'&nbsp;&nbsp;&nbsp;'.lang('requested 
filter action:').' ['.$this_filter['actions'][0]['judgement'].'] ; Acctnum 
['.(string)$target_folder['acctnum'].'] ;  '.lang('Folder').': 
['.htmlspecialchars($target_folder['folder']).']<br>'."\r\n"
                                        .'</p>'."\r\n"
                                        .'<p>&nbsp;</p>'."\r\n";
                                }
                        }
-                       if ($this->debug > 1) { echo 'bofilters.do_filter: 
calling end_request<br>'; }
+                       if ($this->debug > 1) { echo 
'bofilters.do_filter('.__LINE__.'): calling end_request<br>'; }
                        $GLOBALS['phpgw']->msg->end_request();
-                       if ($this->debug > 0) { echo 'bofilters.do_filter: 
LEAVING<br>'; }
+                       if ($this->debug > 0) { echo 
'bofilters.do_filter('.__LINE__.'): LEAVING<br>'; }
                        $take_me_to_url = $GLOBALS['phpgw']->link(
                                                                                
'/index.php',
-                                                                               
'menuaction=email.uifilters.filters_list');
-                       $take_me_to_href = '<a href="'.$take_me_to_url.'"> Go 
Back </a>';
+                                                                               
//'menuaction=email.uifilters.filters_list');
+                                                                               
'menuaction=email.uiindex.index');
+                       $take_me_to_href = '<a href="'.$take_me_to_url.'"> 
'.lang('Go Back').' </a>';
                        //Header('Location: ' . $take_me_to_url);
-                       echo 
'<br><p>'.'&nbsp;&nbsp;&nbsp;'.$take_me_to_href.'</p>';
+                       echo 
'<br><p>'.'&nbsp;&nbsp;&nbsp;'.$take_me_to_href.'</p><BR>';

-                       if ($this->debug > 0) { echo 'bofilters.do_filter: 
LEAVING<br>'; }
+                       if ($this->debug > 0) { echo 
'bofilters.do_filter('.__LINE__.'): LEAVING<br>'; }
                }

                // PRIVATE
@@ -992,24 +1004,24 @@
                */
                function run_single_filter($filter_num='')
                {
-                       if ($this->debug > 0) { echo 
'bofilters.run_single_filter: ENTERING, feed  $filter_num : 
[<code>'.serialize($filter_num).'</code>]<br>'; }
+                       if ($this->debug > 0) { echo 
'bofilters.run_single_filter('.__LINE__.'): ENTERING, feed  $filter_num : 
[<code>'.serialize($filter_num).'</code>]<br>'; }
                        if (count($this->all_filters) == 0)
                        {
-                               if ($this->debug > 0) { echo 
'bofilters.run_single_filter: LEAVING with ERROR, no filters exist<br>'; }
+                               if ($this->debug > 0) { echo 
'bofilters.run_single_filter('.__LINE__.'): LEAVING with ERROR, no filters 
exist<br>'; }
                        }
                        $filter_exists = $this->filter_exists($filter_num);
                        if (!$filter_exists)
                        {
-                               if ($this->debug > 0) { echo 
'bofilters.run_single_filter: LEAVING with ERROR, filter data for $filter_num 
['.$filter_num.'] does not exist, return False<br>'; }
+                               if ($this->debug > 0) { echo 
'bofilters.run_single_filter('.__LINE__.'): LEAVING with ERROR, filter data for 
$filter_num ['.$filter_num.'] does not exist, return False<br>'; }
                                return False;
                        }
                        $this_filter = $this->all_filters[$filter_num];
-                       if ($this->debug > 2) { echo 
'bofilters.run_single_filter: $filter_num ['.$filter_num.'] ; $this_filter 
DUMP:<pre>'; print_r($this_filter); echo "</pre>\r\n"; }
+                       if ($this->debug > 2) { echo 
'bofilters.run_single_filter('.__LINE__.'): $filter_num ['.$filter_num.'] ; 
$this_filter DUMP:<pre>'; print_r($this_filter); echo "</pre>\r\n"; }

                        // WE NEED TO DO THIS FOR EVERY SOURCE ACCOUNT 
specified in this filter
                        for ($src_acct_loop_num=0; $src_acct_loop_num < 
count($this_filter['source_accounts']); $src_acct_loop_num++)
                        {
-                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter: source_accounts loop 
['.$src_acct_loop_num.']<br>'; }
+                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): source_accounts loop 
['.$src_acct_loop_num.']<br>'; }

                                // ACCOUNT TO SEARCH (always filter source is 
INBOX)
                                $fake_fldball = array();
@@ -1021,12 +1033,12 @@
                                if 
((isset($this->inbox_full_msgball_list[$src_acct_loop_num]))
                                || 
(count($this->inbox_full_msgball_list[$src_acct_loop_num]) > 0))
                                {
-                                       if ($this->debug > 1) { echo 
'bofilters.run_single_filter: already obtained inbox_full_msgball_list, during 
a previous filter, for $src_acct_loop_num ['.$src_acct_loop_num.']<br>'; }
-                               }
+                                       if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): already obtained 
inbox_full_msgball_list, during a previous filter, for $src_acct_loop_num 
['.$src_acct_loop_num.']<br>'; }
+                               }
                                else
                                {
                                        // get FULL msgball list for this INBOX 
(we always filter INBOXs only)
-                                       if ($this->debug > 1) { echo 
'bofilters.run_single_filter: get_msgball_list for later XOR ing for 
<code>['.serialize($fake_fldball).']</code><br>'; }
+                                       if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): get_msgball_list for later XOR ing 
for <code>['.serialize($fake_fldball).']</code><br>'; }
                                        
//$this->inbox_full_msgball_list[$src_acct_loop_num] = 
$GLOBALS['phpgw']->msg->get_msgball_list($fake_fldball['acctnum'], 
$fake_fldball['folder']);
                                        // FIXME: FOR BACKWARDS COMPAT WE GET 
AN OLD STYLE MSGBALL LIST
                                        
$this->inbox_full_msgball_list[$src_acct_loop_num] = 
$GLOBALS['phpgw']->msg->get_msgball_list_oldschool($fake_fldball['acctnum'], 
$fake_fldball['folder']);
@@ -1035,7 +1047,7 @@

                                // FOR EACH MSG, GET IT'S RAW HEADERS
                                // only if we have not got them yet
-                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter: get headers for each msg in $src_acct_loop_num 
['.$src_acct_loop_num.']<br>'; }
+                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): get headers for each msg in 
$src_acct_loop_num ['.$src_acct_loop_num.']<br>'; }
                                for ($msg_iteration=0; $msg_iteration < 
count($this->inbox_full_msgball_list[$src_acct_loop_num]); $msg_iteration++)
                                {
                                        if 
((isset($this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['headers_text']))
@@ -1043,7 +1055,7 @@
                                        {
                                                // we ALREADY hav the headers
                                                // continue to the next message
-                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter: already obtained headers, during a previous 
filter, for $src_acct_loop_num ['.$src_acct_loop_num.']<br>'; }
+                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): already obtained headers, during a 
previous filter, for $src_acct_loop_num ['.$src_acct_loop_num.']<br>'; }
                                                continue;
                                        }
                                        // we need to get the headers
@@ -1118,20 +1130,20 @@
                                        if 
($this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['msgnum'] 
== $this->not_set)
                                        {
                                                // this message had already 
been filtered AND MOVED OR DELETED, continue to next loop
-                                               if ($this->debug > 1) { echo 
'<br>bofilters.run_single_filter: skipping... this message has already been 
moved, deleted by a previous filter, $src_acct_loop_num 
['.$src_acct_loop_num.'] $msg_iteration ['.$msg_iteration.']<br><br>'; }
+                                               if ($this->debug > 1) { echo 
'<br>bofilters.run_single_filter('.__LINE__.'): skipping... this message has 
already been moved, deleted by a previous filter, $src_acct_loop_num 
['.$src_acct_loop_num.'] $msg_iteration ['.$msg_iteration.']<br><br>'; }
                                                continue;
                                        }
                                        // we have a message to be filtered...
                                        $headers_text = 
$this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['headers_text'];
                                        // this patiular message has not been 
looked at yet, initialize it match keeper value
                                        
$this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['match_keeper']
 = 0;
-                                       if ($this->debug > 2) { echo 
'bofilters.run_single_filter: 
$this->inbox_full_msgball_list['.$src_acct_loop_num.']['.$msg_iteration.'][headers_text]
 DUMP:<pre>'; 
print_r($this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['headers_text']);
 echo "</pre>\r\n"; }
+                                       if ($this->debug > 2) { echo 
'bofilters.run_single_filter('.__LINE__.'): 
$this->inbox_full_msgball_list['.$src_acct_loop_num.']['.$msg_iteration.'][headers_text]
 DUMP:<pre>'; 
print_r($this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['headers_text']);
 echo "</pre>\r\n"; }

                                        // every header line gets looked at by 
every row of match criteria
                                        // WE NEED TO DO THIS FOR EVERY MATCH 
ROW
                                        for ($matches_row=0; $matches_row < 
count($this_filter['matches']); $matches_row++)
                                        {
-                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter: source_accounts loop ['.$src_acct_loop_num.'] ; 
$msg_iteration ['.$msg_iteration.'] ; $matches_row ['.$matches_row.']<br>'; }
+                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): source_accounts loop 
['.$src_acct_loop_num.'] ; $msg_iteration ['.$msg_iteration.'] ; $matches_row 
['.$matches_row.']<br>'; }
                                                // Note on "RECIPIENT" :  
to,cc, bcc  "tri-fecta" all three headers must be considered
                                                // this is why we made a faux 
header line that contains all three of those in one line
                                                // NOTE: recipient Contains vs. 
NotContains
@@ -1153,7 +1165,7 @@
                                                // if this is really the 1st 
word of the header string, it will be preceeded by CRLF
                                                $inspect_me = 
stristr($headers_text, "\r\n".$search_key_imap);
                                                // inspect_me will be 
everything to the right of the "neede" INCLUDING the "needle" itself and the 
REST of the headers
-                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter: $search_key_imap  ['.$search_key_imap.'] ; 
$comparator ['.$comparator.'] ; $search_for ['.$search_for.']<br>'; }
+                                               if ($this->debug > 1) { echo 
'bofilters.run_single_filter('.__LINE__.'): $search_key_imap  
['.$search_key_imap.'] ; $comparator ['.$comparator.'] ; $search_for 
['.$search_for.']<br>'; }
                                                if ($inspect_me)
                                                {
                                                        // get rid of that 
"needle"  search_key_imap (it's included from the stristr above)
@@ -1164,7 +1176,7 @@
                                                        $cut_here = 
strpos($inspect_me, "\r\n");
                                                        // get everything FROM 
beginning of string TO  pos $cut_here (the end of the line);
                                                        $inspect_me = 
substr($inspect_me, 0, $cut_here);
-                                                       if ($this->debug > 1) { 
echo 'bofilters.run_single_filter: GOT HEADER TO LOOK IN: $inspect_me 
['.htmlspecialchars($inspect_me).']<br>'; }
+                                                       if ($this->debug > 1) { 
echo 'bofilters.run_single_filter('.__LINE__.'): GOT HEADER TO LOOK IN: 
$inspect_me ['.htmlspecialchars($inspect_me).']<br>'; }
                                                        // look for EXISTS or 
NOT EXISTS our search string
                                                        if
                                                        (
@@ -1174,7 +1186,7 @@
                                                                && 
(stristr($inspect_me, $search_for) == False))
                                                        )
                                                        {
-                                                               if 
($this->debug > 1) { echo 'bofilters.run_single_filter: ** GOT ROW CRITERIA 
MATCH ** $matches_row '.$matches_row.'<br>'; }
+                                                               if 
($this->debug > 1) { echo 'bofilters.run_single_filter('.__LINE__.'): ** GOT 
ROW CRITERIA MATCH ** $matches_row '.$matches_row.'<br>'; }
                                                                // MATCH: this 
row matches the search criteria
                                                                // i.e. this 
header line does -or- does not have the seach for text, as requested
                                                                if 
($matches_row == 0)
@@ -1197,7 +1209,7 @@
                                                                {
                                                                        echo 
'match keeper error<br>';
                                                                        
$this->inbox_full_msgball_list[$src_acct_loop_num][$msg_iteration]['match_keeper']
 = 'ERROR1';
-                                                               }
+                                                               }

                                                        }
                                                        else
@@ -1209,7 +1221,7 @@
                                                {
                                                        // header we are 
looking for does not exist in this messages headers
                                                        // probably lookinf for 
an "X-" header, like "X-Mailer:"
-                                                       if ($this->debug > 1) { 
echo 'bofilters.run_single_filter: requested header $search_key_imap  
['.$search_key_imap.'] not in this messages headers<br>'; }
+                                                       if ($this->debug > 1) { 
echo 'bofilters.run_single_filter('.__LINE__.'): requested header 
$search_key_imap  ['.$search_key_imap.'] not in this messages headers<br>'; }
                                                }
                                                // this is the last code that 
gets run BEFORE we move on to the next row of match criteria
                                                // this code is INSIDE the 
match criteria rows
@@ -1870,7 +1882,7 @@
                                // skip this
                        }
                        else
-                       {
+                       {
                                // 2nd Line
                                if ($num_search_criteria == 1)
                                {

====================================================
Index: email/inc/class.bosend.inc.php
diff -u email/inc/class.bosend.inc.php:1.11 email/inc/class.bosend.inc.php:1.12
--- email/inc/class.bosend.inc.php:1.11 Fri Mar 14 04:00:21 2003
+++ email/inc/class.bosend.inc.php      Thu Dec 30 23:13:50 2004
@@ -39,11 +39,16 @@
                var $debug_send = 0;
                var $debug_struct = 0;
                //var $debug_struct = 3;
+               var $company_disclaimer = '';

                function bosend()
                {
                        if ($this->debug_constructor > 0) { echo 'email.bosend 
*constructor*: ENTERING<br>'; }

+                       // May 9, 2003 Ryan Bonham adds company disclaimer code
+                       // This Disclaimer will be added to any out going mail
+                       //var $company_disclaimer = "\r\n\r\n-- \r\n This 
message was sent using Forester GroupWare. Visit the Forest City Regional 
website at http://www.forestcityschool.org.\r\nThis message does not 
necessarily reflect the views of the Forest City Regional School District, nor 
has it been approved or sanctioned by it. \r\n";
+
                        $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
                        
$this->msg_bootstrap->ensure_mail_msg_exists('email.bosend.constructor', 
$this->debug_send);

@@ -218,6 +223,8 @@
                        $this->mail_spell = CreateObject("email.spell");
                        // preserve these vars
                        $this->mail_spell->set_preserve_var('action', 
$GLOBALS['phpgw']->msg->get_arg_value('action'));
+                       // experimental, should this go here? is not this 
already in the URI or something?
+                       //$this->mail_spell->set_preserve_var('orig_action', 
$GLOBALS['phpgw']->msg->recall_desired_action());
                        $this->mail_spell->set_preserve_var('from', 
$GLOBALS['phpgw']->msg->get_arg_value('from'));
                        $this->mail_spell->set_preserve_var('sender', 
$GLOBALS['phpgw']->msg->get_arg_value('sender'));
                        $this->mail_spell->set_preserve_var('to', 
$GLOBALS['phpgw']->msg->stripslashes_gpc($GLOBALS['phpgw']->msg->get_arg_value('to')));
@@ -519,8 +526,121 @@
                                $user_sig = 
$GLOBALS['phpgw']->msg->get_pref_value('email_sig');
                                // html_quotes_decode may be obsoleted someday: 
 workaround for a preferences database issue (<=pgpgw ver 0.9.13)
                                $user_sig = 
$GLOBALS['phpgw']->msg->html_quotes_decode($user_sig);
-                               $body = $body ."\r\n"."\r\n".'-- '."\r\n" 
.$user_sig ."\r\n";
+                               $body = $body."\r\n"
+                                               ."\r\n"
+                                               .'-- '."\r\n"
+                                               .$user_sig ."\r\n";
+                       }
+                       if ($this->company_disclaimer)
+                       {
+                               $body = $body .$this->company_disclaimer;
+                       }
+
+                       // LINE LENGTH for "new" and our text of a forwarded 
text are 78 chars,
+                       // which is SHORTER than for reply quoted bodies that 
have ">" chars
+                       // this is only for text WE have written, not any other 
part of the body
+                       // html textbox no longer adds hard wrap on submit, so 
we handle it here now
+                       // NOTE reply bodies have already been handled as to 
length when we quoted the text
+                       //if 
(($GLOBALS['phpgw']->msg->get_isset_arg('orig_action'))
+                       //&& (
+                       //      
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'new')
+                       //      || 
($GLOBALS['phpgw']->msg->get_arg_value('orig_action') == 'forward')
+                       //      )
+                       //)
+                       if (($GLOBALS['phpgw']->msg->recall_desired_action()== 
'new')
+                       || ($GLOBALS['phpgw']->msg->recall_desired_action() == 
'forward'))
+                       {
+                               // WRAP BODY to lines of 78 chars then CRLF
+                               // IS THIS TOO SHORT? what about code snippets 
and stuff?or long URLs
+                               $body = 
$GLOBALS['phpgw']->msg->body_hard_wrap($body, 78);
+                       }
+                       elseif 
(($GLOBALS['phpgw']->msg->recall_desired_action()== 'reply')
+                       || ($GLOBALS['phpgw']->msg->recall_desired_action()== 
'replyall'))
+                       {
+                               //echo 'entering recall_desired_action == reply 
line length handling'."\r\n";
+                               // ok we have already quoted the text of the 
message we are replying to
+                               // BUT we have yet to standardize line length 
for the text WE just typed
+                               // in this message, our own text,
+                               // BUT we really should skip doing linebreaking 
it _again_ for the quoted text, though
+                               $body_array = array();
+                               $body_array = explode("\r\n", $body);
+                               // we do not use this again till we put 
$new_body into it, so clear the memory
+                               $body = '';
+                               // process only our unquoted text
+                               $body_array_count = count($body_array);
+                               $in_unquoted_block = False;
+                               $unquoted_text = '';
+                               $new_body = '';
+                               for ($bodyidx = 0; $bodyidx < 
$body_array_count; ++$bodyidx)
+                               {
+                                       // skip text that starts with the ">" 
so called "quoting" char to the original body text
+                                       // because it has already been line 
length normalized in bocompose
+                                       $this_line = $body_array[$bodyidx];
+                                       if ((strlen($this_line) > 1)
+                                       && ($this_line[0] == 
$GLOBALS['phpgw']->msg->reply_prefix[0]))
+                                       {
+                                               // ... this line starts with 
the quoting char
+                                               if ($in_unquoted_block == True)
+                                               {
+                                                       //echo 'line ength 
handling: processing MY text block'."\r\n";
+                                                       // TOGGLE - we are 
exiting block of our text
+                                                       // process the 
preceeding block of unquoted text, if any
+                                                       $unquoted_text = 
$GLOBALS['phpgw']->msg->body_hard_wrap($unquoted_text, 78);
+                                                       // now pass it into the 
new body var
+                                                       $new_body .= 
$unquoted_text;
+                                                       // clear this var
+                                                       $unquoted_text = '';
+                                                       // toggle this flag
+                                                       $in_unquoted_block = 
False;
+                                                       // for THIS line, it is 
the first in a quoted block, so pass straight to new body var
+                                                       //   I _think_ the CRLF 
is needed before this line because hard_wrap may not
+                                                       //   put one at the end 
of the last line of the unquoted text block ?
+                                                       //$new_body .=  "\r\n" 
. $this_line . "\r\n";
+                                                       $new_body .= $this_line 
. "\r\n";
+                                               }
+                                               else
+                                               {
+                                                       // we are in a block of 
QUOTED text, simply pass it into the new body var
+                                                       $new_body .= $this_line 
. "\r\n";
+                                               }
+                                       }
+                                       elseif (($body_array_count - $bodyidx) 
== 1)
+                                       {
+                                               // this is the last line, and 
it is NOT quoted, so if we were in an unquoted block (of our text) process it 
now
+                                               // even if this is the only 
single line of unquoted text in the message, process it now
+                                               // otherwise we may leave off 
the end of the message, if it is our text
+                                               $unquoted_text .= $this_line;
+                                               $unquoted_text = 
$GLOBALS['phpgw']->msg->body_hard_wrap($unquoted_text, 78);
+                                               $new_body .= $unquoted_text;
+                                               $unquoted_text = '';
+                                               // this really is not needed, 
but so it anyway
+                                               $in_unquoted_block = False;
+                                       }
+                                       else
+                                       {
+                                               // ... this line does NOT start 
with the quoting char, i.e. it is text we typed in
+                                               // make sure flag is correct
+                                               if ($in_unquoted_block == False)
+                                               {
+                                                       // toggle this flag
+                                                       $in_unquoted_block = 
True;
+                                                       // there is just no 
real special action of a change into this block of our text,
+                                                       // the real action is 
when switching out of a block or our (unqouted) text
+                                               }
+                                               // compile this block of 
unquoted text, our text, in a var for later processing
+                                               $unquoted_text .= $this_line . 
"\r\n";
+                                       }
+                               }
+                               // cleanup
+                               $body_array = array();
+                               // ok we have gone through the whole message, 
put it in the bldy var
+                               $body = '';
+                               $body = $new_body;
+                               $new_body = '';
+                               $unquoted_text = '';
+                               // end reply body line length landling block
                        }
+
                        // Step One Addition
                        // ---- Request Delivery Notification in Headers ----
                        if 
(($GLOBALS['phpgw']->msg->get_isset_arg('req_notify'))
@@ -910,7 +1030,7 @@
                                                        while ($datachunk = 
fread($fh, 57))
                                                        {
                                                                if 
($this->debug_struct > 2) { echo '$next_pos ['.$next_pos.'] :: string 
['.$datachunk.'] :: b64 version ['.base64_encode($datachunk).']<br>'."\r\n"; }
-                                                               
$this->mail_out['body'][$body_part_num]['mime_body'][$next_pos] = 
base64_encode($datachunk);
+                                                               
$this->mail_out['body'][$body_part_num]['mime_body'][$next_pos] = 
base64_encode($datachunk);
                                                                $next_pos++;
                                                        }
                                                        $b64_part = '';

====================================================
Index: email/inc/class.html_widgets.inc.php
diff -u email/inc/class.html_widgets.inc.php:1.3 
email/inc/class.html_widgets.inc.php:1.4
--- email/inc/class.html_widgets.inc.php:1.3    Fri Mar 14 04:00:42 2003
+++ email/inc/class.html_widgets.inc.php        Thu Dec 30 23:13:50 2004
@@ -1,1629 +1,1699 @@
-<?php
-       
/**************************************************************************\
-       * AngleMail - E-Mail Module for phpGroupWare                            
        *
-       * http://www.anglemail.org                                              
                        *
-       * http://www.phpgroupware.org                                           
                        *
-       */
-       
/**************************************************************************\
-       * AngleMail - HTML Widgets                                              
                        *
-       * This file written by "Angles" Angelo Puglisi <address@hidden> *
-       * Email related HTML Widgets and Utility Functions                      
                *
-       * Copyright (C) 2002 Angelo Tony Puglisi (Angles)                       
                *
-       * 
-------------------------------------------------------------------------       
      *
-       * This library is free software; you can redistribute it and/or modify 
it               *
-       * under the terms of the GNU Lesser General Public License as published 
by      *
-       * the Free Software Foundation; either version 2.1 of the License,      
                *
-       * or any later version.                                                 
                                *
-       * This library is distributed in the hope that it will be useful, but   
                *
-       * WITHOUT ANY WARRANTY; without even the implied warranty of    *
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  *
-       * See the GNU Lesser General Public License for more details.           
        *
-       * You should have received a copy of the GNU Lesser General Public 
License      *
-       * along with this library; if not, write to the Free Software 
Foundation,               *
-       * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
        *
-       
\**************************************************************************/
-
-       /* $Id$ */
-       /*!
-       @class html_option
-       @abstract data structure used with class html_widgets
-       @param $value (class var) (string) this options value that will be 
submitted if selected
-       @param $text (class var) (string) the text the user sees, a description 
of this option
-       @param $selected  (class var) (boolean)  whether this option should be 
pre-selected in a combobox, default False
-       @author Angles
-       @discussion used in making select text, value items, such as in the 
combobox widget.
-       @access private
-       */
-       class html_option
-       {
-               var $value;
-               var $text;
-               var $selected;
-
-               function html_option()
-               {
-                       $this->value = '';
-                       $this->text = '';
-                       $this->selected = False;
-               }
-       }
-
-       /*!
-       @class hiddenvar_option
-       @abstract data structure used with hidden data in forms
-       @discussion ?
-       @access private
-       */
-       class hiddenvar_option
-       {
-               var $name;
-               var $value;
-
-               function hiddenvar_option()
-               {
-                       $this->name = '';
-                       $this->value = '';
-               }
-       }
-
-       /*!
-       @class html_widgets
+<?php
+       
/**************************************************************************\
+       * AngleMail - E-Mail Module for phpGroupWare                            
        *
+       * http://www.anglemail.org                                              
                        *
+       * http://www.phpgroupware.org                                           
                        *
+       */
+       
/**************************************************************************\
+       * AngleMail - HTML Widgets                                              
                        *
+       * This file written by "Angles" Angelo Puglisi <address@hidden> *
+       * Email related HTML Widgets and Utility Functions                      
                *
+       * Copyright (C) 2002 Angelo Tony Puglisi (Angles)                       
                *
+       * 
-------------------------------------------------------------------------       
      *
+       * This library is free software; you can redistribute it and/or modify 
it               *
+       * under the terms of the GNU Lesser General Public License as published 
by      *
+       * the Free Software Foundation; either version 2.1 of the License,      
                *
+       * or any later version.                                                 
                                *
+       * This library is distributed in the hope that it will be useful, but   
                *
+       * WITHOUT ANY WARRANTY; without even the implied warranty of    *
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  *
+       * See the GNU Lesser General Public License for more details.           
        *
+       * You should have received a copy of the GNU Lesser General Public 
License      *
+       * along with this library; if not, write to the Free Software 
Foundation,               *
+       * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
        *
+       
\**************************************************************************/
+
+       /* $Id$ */
+       /*!
+       @class html_option
+       @abstract data structure used with class html_widgets
+       @param $value (class var) (string) this options value that will be 
submitted if selected
+       @param $text (class var) (string) the text the user sees, a description 
of this option
+       @param $selected  (class var) (boolean)  whether this option should be 
pre-selected in a combobox, default False
+       @author Angles
+       @discussion used in making select text, value items, such as in the 
combobox widget.
+       @access private
+       */
+       class html_option
+       {
+               var $value;
+               var $text;
+               var $selected;
+
+               function html_option()
+               {
+                       $this->value = '';
+                       $this->text = '';
+                       $this->selected = False;
+               }
+       }
+
+       /*!
+       @class hiddenvar_option
+       @abstract data structure used with hidden data in forms
+       @discussion ?
+       @access private
+       */
+       class hiddenvar_option
+       {
+               var $name;
+               var $value;
+
+               function hiddenvar_option()
+               {
+                       $this->name = '';
+                       $this->value = '';
+               }
+       }
+
+       /*!
+       @class html_widgets
        @abstract generate HTML widgets for use in web pages.
-       @author Angles
-       @access public
-       @discussion OOP style class for producing common widgets in html pages, 
such as a combobox.
-       Designed to reduce bain damage to the developer by hiding the details 
of the html tags and by
-       treating these things as widgets which is what they are, more than just 
simple html markup.
-       */
-       class html_widgets
-       {
-               
/**************************************************************************\
-               *       VARS
-               
\**************************************************************************/
-               //var $debug = 3;
-               var $debug_init = 0;
+       @author Angles
+       @access public
+       @discussion OOP style class for producing common widgets in html pages, 
such as a combobox.
+       Designed to reduce bain damage to the developer by hiding the details 
of the html tags and by
+       treating these things as widgets which is what they are, more than just 
simple html markup.
+       */
+       class html_widgets
+       {
+               
/**************************************************************************\
+               *       VARS
+               
\**************************************************************************/
+               var $debug = 0;
+               var $debug_init = 0;
+
+               // if calling from home page it is optional to force currentapp 
as a constructor param
+               var $my_currentapp='';
+               // bootstraper for the msg class
+               var $msg_bootstrap;
+               // private template to var names do not collide
+               var $tpl;
+
+               // A HREF OOP properties
+               var $href_link='';
+               var $href_target='';
+               var $href_clickme='not_provided';
+               var $href='';
+
+               // combo box OOP properties
+               var $cbox_name='not_provided';
+               var $cbox_onChange='';
+               var $cbox_items=array();
+               var $combobox='';
+
+               // form OOP properties
+               var $form_name='';
+               var $form_action='';
+               var $form_method='';
+               var $form_hiddenvars=array();
+               var $form='';
+
+               // TOOLBAR
+               var $toolbar_msg='';
+               var $toolbar_row_one='';
+               var $toolbar_row_two='';
+               var $toolbar='';
+
+               // ALL FOLDERS ALL ACCOUNTS MEGA LISTBOX
+               var $F_megalist_form_reference='';
+               var $F_megalist_widget_name='';
+               var $F_megalist_preselected_fldball='';
+               var $F_megalist_skip_fldball='';
+               var $F_megalist_first_item_text = '';
+
+               // RELOAD WIDGET
+               var $refresh_js='';
+
+               // GENERIC ERROR REPORT
+               var $F_mindless_default_txt = 'error text not provided';
+               var $F_error_report_text='';
+               var $F_go_somewhere_link='';
+               var $F_go_home_link='';
+
+
+               
/**************************************************************************\
+               *       CONSTRUCTOR
+               
\**************************************************************************/
+               function html_widgets()
+               {
+                       if ($this->debug_init > 0) { echo 'ENTER: 
email.html_widgets.CONSTRUCTOR'.'<br>'."\r\n"; }
+                       /*!
+                       @class requires including spell_struct header file
+                       @discussion  class html_widgets needs the special 
C-Style Include .h like file,
+                       class.spell_struct which holds data structure class 
correction_info used here for integration
+                       with the mail.spell  spellchecking class.
+                       */
+                       $required_class = 'spell_struct';
+
+                       // if calling this class from the home page, then the 
currentapp will be
+                       //set to "home" instead of "email", which messes up the 
include statement below,
+                       // so set a local var to "email" to force considering 
the currentapp to be "email".
+                       $this->my_currentapp = 'email';
+                       
//require_once(PHPGW_INCLUDE_ROOT.'/'.$GLOBALS['phpgw_info']['flags']['currentapp'].'/inc/class.'.$required_class.'.inc.php');
+                       
require_once(PHPGW_INCLUDE_ROOT.'/'.$this->my_currentapp.'/inc/class.'.$required_class.'.inc.php');
+
+                       if ($this->debug_init > 0) { echo 'EXIT: 
email.html_widgets.CONSTRUCTOR'.'<br>'."\r\n"; }
+                       return;
+               }
+
+
+               
/**************************************************************************\
+               *       HREF LINK WIDGET
+               
\**************************************************************************/
+
+               /*!
+               @capability HREF LINK WIDGET
+               @discussion generate an a href item, includes link, target, 
text. CLEARS ITSELF after each "get_href"
+               @author Angles
+               @example $this->widgets->set_href_link('index.php');
+               $this->widgets->set_href_target('top');
+               $this->widgets->get_href_clickme(lang('click here for more info 
in a new window'));
+               $my_href_tag = $this->widgets->get_href();
+               */
+               /*!
+               @function clear_href_vars
+               @abstract after every call to "->get_href" all internal vars 
are cleared automatically with this function.
+               @author Angles
+               @discussion href class vars for link, target, text. CLEARS 
ITSELF after each "get_href". This utilty
+               function does that. It is RARE that you would ever need to call 
this directly.
+               @access private
+               */
+               function clear_href_vars()
+               {
+                       $this->set_href_link('');
+                       $this->set_href_target('');
+                       $this->set_href_clickme('');
+               }
+
+               /*!
+               @function set_href_link
+               @abstract set the URL link of this this HREF widget
+               @param $href_link (string)
+               @author Angles
+               @access public
+               */
+               function set_href_link($href_link='')
+               {
+                       $this->href_link = $href_link;
+               }
+               /*!
+               @function get_href_link
+               @abstract used check or verify the value if the "href_link" 
property
+               @author Angles
+               @access public
+               */
+               function get_href_link()
+               {
+                       return $this->href_link;
+               }
+
+               /*!
+               @function set_href_target
+               @abstract OPTIONAL set the "target", i.e. what browser window 
this HREF should apply to,
+               default is not to specify any target in the HREF tag.
+               @param $href_target (string)
+               @author Angles
+               @access public
+               */
+               function set_href_target($href_target='')
+               {
+                       $this->href_target = $href_target;
+               }
+               /*!
+               @function get_href_target
+               @abstract used check or verify the value if the "href_target" 
property
+               @author Angles
+               @access public
+               */
+               function get_href_target()
+               {
+                       return $this->href_target;
+               }
+
+               /*!
+               @function set_href_clickme
+               @abstract what the user needs to click on to activate the HREF 
link, can be text or a COMPLETE img tag.
+               @param $href_clickme (string)  text or a COMPLETE img tag
+               @author Angles
+               @access public
+               */
+               function set_href_clickme($href_clickme='')
+               {
+                       $this->href_clickme = $href_clickme;
+               }
+               /*!
+               @function get_href_clickme
+               @abstract used check or verify the value if the "href_clickme" 
property
+               @author Angles
+               @access public
+               */
+               function get_href_clickme()
+               {
+                       return $this->href_clickme;
+               }
+
+               /*!
+               @function get_href
+               @abstract generate and return an HREF tag using information you 
set in the OOP "set_href_" functions
+               @author Angles
+               @result (string) a complete HREF tag generated from data you 
set in the "set_href_" functions,
+               @discussion After you set "href_target", "href_clickme" and 
other optional properties ("href_target") this
+               function generates an HREF tag from that data and returns it. 
NOTE after generating the HREF tag, and
+               before returning it, this function CLEARS ALL PROPERTIES that 
it used to make that href tag, so this
+               "widget" automatically is ready to new usage without having to 
explicitly call any "new" or "clear" function.
+               @access public
+               */
+               function get_href()
+               {
+                       if ($this->href_target != '')
+                       {
+                               $target = ' target="'.$this->href_target.'"';
+                       }
+                       // put the href return value in storage so we can clear 
all href internal vars before we exit this function with a return.
+                       $href = '<a href="' .$this->href_link .'"'.$target.'>' 
.$this->href_clickme .'</a>' ."\r\n";
+                       // this widget clears itself automatically after every 
call to this function.
+                       $this->clear_href_vars();
+                       return $href;
+               }
+
+               
/**************************************************************************\
+               *       QUICK HREF TAG - depreciated
+               
\**************************************************************************/
+               /*!
+               @function href_maketag (not related to the HREF widget)
+               @abstract QUICK way to generate a typical A HREF html item in a 
single function call. NOT PART OF
+               THE HREF WIDGET, not OOP style, just a quick utilty function. 
ALL params must be passed in this function call.
+               @param $href_link (string) URL for this HREF tag
+               @param $href_text (string) what the user clicks on to activate 
this HREF tag, can be text OR a COMPLETE IMG tag.
+               @param $target (string) OPTIONAL target for the link, such as 
when using frames or opening a new browser window.
+               @author Angles
+               @discussion not really a widget, does not use OOP style, but it 
gets the job done quickly. Somewhat Depreciated,
+               use the OOP style href widget instead.
+               @example this->href_maketag("index.jsp", "click here for home 
page", "new");
+               @access public
+               */
+               function href_maketag($href_link='',$href_text='default 
text',$target='')
+               {
+                       if ($target != '')
+                       {
+                               $target = ' target="'.$target.'"';
+                       }
+                       return '<a href="' .$href_link .'"'.$target.'>' 
.$href_text .'</a>' ."\r\n";
+               }
+
+               
/**************************************************************************\
+               *       QUICK IMG TAG
+               
\**************************************************************************/
+               /*!
+               @function img_maketag
+               @abstract quick and dirty to make an IMG html tag in one 
function call.
+               @author Angles
+               @param $location (string int) URL to the image, cal be 
releative or fully qualified
+               @param $alt (string) text displayed (a) in place of the image 
if not displayed, and (b) as a image tooltip on some browsers
+               @param $height (string int) int passed as a string, OPTIONAL, 
not included in img tag if not provided
+               @param $width (string int)  int passed as a string OPTIONAL, 
not included in img tag if not provided
+               @param $border (string int) int passed as string OPTIONAL , not 
included in img tag if not provided ,
+               the size of the border around the image, often set to "0"
+               @discussion not really a widget but it gets the job done. QUICK 
way to generate a typical A IMG html item
+               in a single function call. Not OOP style, just a quick utilty 
function. ALL params must be passed in this function call.
+               @example $my_img = widgets->img_maketag("poweredby.png", 
"powered by RedHat",  "", "", "0");
+               @access public
+               */
+               function 
img_maketag($location='',$alt='',$height='',$width='',$border='')
+               {
+                       $alt_default_txt = 'image';
+                       $alt_unknown_txt = 'unknown';
+                       if ($location == '')
+                       {
+                               return '<img src="" 
alt="['.$alt_unknown_txt.']">';
+                       }
+                       if ($alt != '')
+                       {
+                               $alt_tag = ' alt="['.$alt.']"';
+                               $title_tag = ' title="'.$alt.'"';
+                       }
+                       else
+                       {
+                               $alt_tag = ' alt="['.$alt_default_txt.']"';
+                               $title_tag = '';
+                       }
+                       if ($height != '')
+                       {
+                               $height_tag = ' height="' .$height .'"';
+                       }
+                       else
+                       {
+                               $height_tag = '';
+                       }
+                       if ($width != '')
+                       {
+                               $width_tag = ' width="' .$width .'"';
+                       }
+                       else
+                       {
+                               $width_tag = '';
+                       }
+                       if ($border != '')
+                       {
+                               $border_tag = ' border="' .$border .'"';
+                       }
+                       else
+                       {
+                               $border_tag = '';
+                       }
+                       $image_html = '<img src="'.$location.'"' .$height_tag 
.$width_tag .$border_tag .$title_tag .$alt_tag .'>';
+                       return $image_html;
+               }
+
+               
/**************************************************************************\
+               *       COMBOBOX WIDGET
+               
\**************************************************************************/
+
+               /*!
+               @capability COMBOBOX WIDGET
+               @discussion generate a combo box html widget.
+               @author Angles
+               @example
+               $this->widgets->new_combobox();
+               $this->widgets->set_cbox_name("user_choice");
+               $this->widgets->set_cbox_item("yes"', "Customer is Right");
+               $this->widgets->set_cbox_item("no"', "Customer is Wrong");
+               $my_combobox_wirget = $this->widgets->get_combobox();
+               */
+               // combo box OOP access functions
+               /*!
+               @function set_cbox_name
+               @abstract ?
+               */
+               function set_cbox_name($str='')
+               {
+                       if ($str == '')
+                       {
+                               $this->cbox_name = 'not_provided';
+                       }
+                       else
+                       {
+                               $this->cbox_name = $str;
+                       }
+               }
+               /*!
+               @function get_cbox_name
+               @abstract ?
+               */
+               function get_cbox_name()
+               {
+                       return $this->cbox_name;
+               }
+
+               /*!
+               @function set_cbox_onChange
+               @abstract ?
+               */
+               function set_cbox_onChange($str='')
+               {
+                       if ($str != '')
+                       {
+                               $this->cbox_onChange = $str;
+                       }
+               }
+               /*!
+               @function get_cbox_onChange
+               @abstract ?
+               */
+               function get_cbox_onChange()
+               {
+                       return $this->cbox_onChange;
+               }
+
+               /*!
+               @function set_cbox_item
+               @abstract ?
+               */
+               function set_cbox_item($value='',$text='',$selected=False)
+               {
+                       // make sure $selected is boolean
+                       if (!is_bool($selected))
+                       {
+                               // replace param with a default boolean value 
of False
+                               $selected = False;
+                       }
+                       // I've actually seen bomboboxes with an item (usually 
the first) with no name
+                       if (($value != '') || ($text != ''))
+                       {
+                               $item_idx = count($this->cbox_items);
+                               $this->cbox_items[$item_idx] = new html_option;
+                               $this->cbox_items[$item_idx]->value = $value;
+                               $this->cbox_items[$item_idx]->text = $text;
+                               $this->cbox_items[$item_idx]->selected = 
$selected;
+                       }
+               }
+               /*!
+               @function set_cbox_item_spellcheck
+               @abstract makes a special kind of combobox select item for use 
with spellcheck
+               @param $this_bad_word_element (class "correction_info" 
structued data from file class.spell_struct)
+               @param $suggestion_num (int OR empty string) see discussion 
below.
+               @author Angles
+               @discussion  This function makes use of structure 
"correction_info" which we expose
+               by including file class.spell_struct in the constructor for 
this class. The combobox select item this
+               function makes embeds array data in the items "value" by 
setting it to a string that
+               resembles a URL get request, which we then can recover this 
array by applying php function
+               parse_str to the value when the user submits the form. The idea 
is to provide enough data
+               in the value that the spellcheck replacement code can 
accurately find and replace the desired
+               word, or not change the word at all if special suggestion 
string "K_E_E_P" is present.
+               The first suggestion should be en empty string with special 
value "K_E_E_P"
+               which means no change to the misspelled word, this is indicated 
by passing an empty string
+               for param $suggestion_num.
+               The value for the suggestion item is a URL type string that 
contains as much informaion
+               as we can preserve from the $this_bad_word_element object 
param, but specifying the individual
+               suggestion provieded by the $suggestion_num arg which is the 
index to this particular
+               suggestion in the $this_bad_word_element->suggestions[] 
numbered array of suggestions.
+               Upon submit, we can apply php function parse_str() to this uri 
to recover the desired array structure.
+               Parse_str will even urldecode the items for us.
+               */
+               function set_cbox_item_spellcheck($this_bad_word_element='', 
$suggestion_num='')
+               {
+                       // we included the spell_struct file above, so this 
object knows what
+                       // correction_info struct is
+                       if (is_object($this_bad_word_element))
+                       {
+                               if ((string)$suggestion_num != '')
+                               {
+                                       $suggestion_txt = 
$this_bad_word_element->suggestions[(int)$suggestion_num];
+                                       $suggestion_value = 
$this_bad_word_element->suggestions[(int)$suggestion_num];
+                               }
+                               else
+                               {
+                                       // the first suggestion should be en 
empty string with special value "K_E_E_P"
+                                       // which means no change to the 
misspelled word
+                                       // this is indicated by passing an 
empty string for $suggestion_num
+                                       $suggestion_txt = '';
+                                       $suggestion_value = 'K_E_E_P';
+                               }
+                               // the value for the suggestion item is a URL 
type string that contains as much informaion
+                               // as we can preserve from the 
$this_bad_word_element object, but specifying the individual
+                               // suggection provieded by the $suggestion_num 
arg which is the index to this particular
+                               // suggestion in the 
$this_bad_word_element->suggestions[] numbered array of suggestions
+                               // upon submit, we can apply php function 
parse_str() to this uri to recover the desired array structure.
+                               // parse_str will even urldecode the items for 
us.
+                               /*
+                               $uri_value =
+                                         
'cbox[orig_word]='.urlencode($this_bad_word_element->orig_word)
+                                       
.'&cbox[orig_word_clean]='.urlencode($this_bad_word_element->orig_word_clean)
+                                       
.'&cbox[line_num]='.urlencode($this_bad_word_element->line_num)
+                                       
.'&cbox[word_num]='.urlencode($this_bad_word_element->word_num)
+                                       
.'&cbox[suggestion_value]='.urlencode($suggestion_value);
+                               */
+                               $uri_value =
+                                         
'orig_word='.urlencode($this_bad_word_element->orig_word)
+                                       
.'&orig_word_clean='.urlencode($this_bad_word_element->orig_word_clean)
+                                       
.'&line_num='.urlencode($this_bad_word_element->line_num)
+                                       
.'&word_num='.urlencode($this_bad_word_element->word_num)
+                                       
.'&suggestion_value='.urlencode($suggestion_value);
+
+                               $item_idx = count($this->cbox_items);
+                               $this->cbox_items[$item_idx] = new html_option;
+                               $this->cbox_items[$item_idx]->value = 
$uri_value;
+                               $this->cbox_items[$item_idx]->text = 
$suggestion_txt;
+                       }
+               }
+               /*!
+               @function get_cbox_item
+               @abstract ?
+               */
+               function get_cbox_item($idx='')
+               {
+                       if ((string)$idx == '')
+                       {
+                               return $this->cbox_items;
+                       }
+                       else
+                       {
+                               return $this->cbox_items[$idx];
+                       }
+               }
+
+               /*!
+               @function new_combobox
+               @abstract ALWAYS start a new combobox widget by calling this 
function first. Clears all combobox
+               properties.
+               */
+               function new_combobox()
+               {
+                       $this->cbox_name='not_provided';
+                       $this->cbox_onChange='';
+                       $this->cbox_items=array();
+                       $this->combobox='';
+               }
+
+               /*!
+               @function get_combobox
+               @abstract generate and return a HTML select (combobo) widget 
using the values you set in
+               the "set_cbox_" functions.
+               @author Angles
+               @discussion this function does not clear its properties, so if 
for some reason you want THE SAME
+               comboboxes more then one time, calling "get_combobox" will 
return the same combobox until you
+               clear it by calling "new_combobox", which you should ALWAYS do 
when starting a new combobox
+               widget. VALUES ARE NOT URLENCODED, except that the special 
spellcheck item stuff
+               does it, but before this function, and this does not happen for 
the normal set cbox item. It IS
+               html specialchars encoded here.
+               @access public
+               */
+               function get_combobox()
+               {
+                       if ($this->cbox_onChange != '')
+                       {
+                               $onChange_tag = ' 
onChange="'.$this->cbox_onChange.'"';
+                       }
+                       else
+                       {
+                               $onChange_tag = '';
+                       }
+                       $this->combobox = '<select 
name="'.$this->cbox_name.'"'.$onChange_tag.'>';
+                       $loops = count($this->cbox_items);
+                       if ($loops > 0)
+                       {
+                               for ($i=0; $i < $loops; $i++)
+                               {
+                                       if ($this->cbox_items[$i]->selected == 
True)
+                                       {
+                                               $selected_tag = ' selected';
+                                       }
+                                       else
+                                       {
+                                               $selected_tag = '';
+                                       }
+                                       $this->combobox .=
+                                               '<option 
value="'.$this->cbox_items[$i]->value.'"'.$selected_tag.'>'
+                                               
.htmlspecialchars($this->cbox_items[$i]->text)
+                                               .'</option>';
+                                       $this->combobox .= "\r\n";
+                               }
+                       }
+                       $this->combobox .= '</select>';
+                       return $this->combobox;
+               }
+               // <select name="filter" onChange="this.form.submit();"><option 
value="all">show all</option>
+               // <option value="public">only yours</option>
+               // <option value="private">Private</option>
+               // </select>
+
+               
/**************************************************************************\
+               *       FORM WIDGET
+               
\**************************************************************************/
+
+               /*!
+               @capability FORM WIDGET
+               @discussion generate a opening tag of a form including name, 
action, method, and hiddenvars
+               @author Angles
+               @example
+               $this->widgets->new_form();
+               $this->widgets->set_form_name('spell_review');
+               $this->widgets->set_form_method('POST');
+               $this->widgets->set_form_action('index.php?email.targets.move');
+               $this->widgets->set_form_hiddenvar('subject', 'stock');
+               $this->widgets->set_form_hiddenvar('symbol', 'GM');
+               // OPTIONAL if you have set "preserve_vars" you can include 
them as hidden vars with this command
+               $this->commit_preserve_vars_to_form();
+               $my_form_tag = $this->widgets->get_form();
+               */
+               function new_form()
+               {
+                       $this->form_name='not_provided';
+                       $this->form_action='';
+                       $this->form_method='POST';
+                       $this->form_hiddenvars=array();
+                       $this->form = '';
+               }
+
+               /*!
+               @function set_form_name
+               @abstract ?
+               */
+               function set_form_name($str='')
+               {
+                       if ($str != '')
+                       {
+                               $this->form_name = $str;
+                       }
+               }
+               /*!
+               @function get_form_name
+               @abstract ?
+               */
+               function get_form_name()
+               {
+                       return $this->form_name;
+               }
+
+               /*!
+               @function set_form_action
+               @abstract ?
+               */
+               function set_form_action($str='')
+               {
+                       if ($str != '')
+                       {
+                               $this->form_action = $str;
+                       }
+               }
+               /*!
+               @function
+               @abstract ? get_form_action
+               */
+               function get_form_action()
+               {
+                       return $this->form_action;
+               }
+
+               /*!
+               @function set_form_method
+               @abstract ?
+               */
+               function set_form_method($str='')
+               {
+                       if ($str != '')
+                       {
+                               $this->form_method = $str;
+                       }
+               }
+               /*!
+               @function get_form_method
+               @abstract ?
+               */
+               function get_form_method()
+               {
+                       return $this->form_method;
+               }
+
+               /*!
+               @function set_form_hiddenvar
+               @abstract put hidden  vars in a form tag.
+               @param $name the "key" in the GPC key - value pair
+               @param $value  the "value" in the GPC key - value pair
+               @param $do_urlencode (boolean) OPTIONAL default is True, 
whether or not to urlencode the name and value params.
+               @author Angles
+               @access public
+               */
+               function set_form_hiddenvar($name='',$value='', 
$do_urlencode=True)
+               {
+                       // I've actually seen bomboboxes with an item (usually 
the first) with no name
+                       if (($name != '') || ($value != ''))
+                       {
+                               if ($do_urlencode == True)
+                               {
+                                       $name = urlencode($name);
+                                       $value = urlencode($value);
+                               }
+                               $item_idx = count($this->form_hiddenvars);
+                               $this->form_hiddenvars[$item_idx] = new 
hiddenvar_option;
+                               $this->form_hiddenvars[$item_idx]->name = $name;
+                               $this->form_hiddenvars[$item_idx]->value = 
$value;
+                       }
+               }
+               /*!
+               @function get_form_hiddenvar
+               @abstract ?
+               */
+               function get_form_hiddenvar($idx='')
+               {
+                       if ((string)$idx == '')
+                       {
+                               return $this->form_hiddenvars;
+                       }
+                       else
+                       {
+                               return $this->form_hiddenvars[$idx];
+                       }
+               }
+
+               // <form enctype="multipart/form-data" name="spell_review" 
action="/mail/index.php?menuaction=email.bosend.sendorspell&fldball[folder]=INBOX&fldball[acctnum]=3&sort=1&order=1&start=0"
 method="POST">
+               //<input type="hidden" name="sort" value="1">
+               //<input type="hidden" name="order" value="1">
+               //<input type="hidden" name="start" value="0">
+               //<input type="hidden" name="force_showsize" value="1">
+               /*!
+               @function get_form
+               @abstract generate and return an opening FORM tag using the 
data you set in the "set_form_" functions.
+               @author Angles
+               @discussion Any hiddenvars will be urlencoded. NOTE YOU MUST 
PUT THE CLOSING &lt;&#047;form&gt; somewhere
+               after this form tag. This functions generates the opening tag 
of the form, which is where all the complicated stuff
+               is. The ending tag is a normal html markup closing tag you must 
supply. NOTE on form enctype, HTML 401 says
+               "multipart/form-data" is very strict to MIME rfc2045-49 and 
will add hard wrap CRLF to each line of text
+               in any control. For example, a TEXTAREA input control will hard 
wrap at whatever its column length is,
+               because it represents the end of a line of text, eventhough the 
user did not explicitly press return, and therefor
+               it should be a soft return, not a CRLF. On the other hand, 
"application/x-www-form-urlencoded" is the default
+               value and is assumed if not provided, and is the kind of submit 
we are more used to. NOTE "multipart/form-data"
+               is also designed to handle large amounts of text or binary 
data, so "multipart/form-data" is used with file upload
+               forms, which means "multipart/form-data" WILL NOT WORK if the 
php.ini file does not allow "FILE UPLOADS".
+               This can be a confusing issue because we are not submitting a 
file upload, just some text, but the
+               "multipart/form-data"  is used for file upload forms, hence the 
association.  UPDATE testing shows this
+               may not be true eventhough HTML v401 says so. In a TEXTAREA 
control, using wrap="hard" yields the
+               CRLF hard wrap regardless of the enctype, and without the 
wrap="hard" there is no CRLF line ends to soft
+               wraps, eventhough there should be with "multipart/form-data" 
forms.
+               @access prublic
+               */
+               function get_form()
+               {
+                       $this->form =
+                               // '<form enctype="multipart/form-data" '
+                                '<form 
enctype="application/x-www-form-urlencoded" '
+                               .'name="'.$this->form_name.'" '
+                               .'action="'.$this->form_action.'" '
+                               .'method="'.$this->form_method.'">'
+                               ."\r\n";
+
+                       $loops = count($this->form_hiddenvars);
+                       if ($loops > 0)
+                       {
+                               for ($i=0; $i < $loops; $i++)
+                               {
+                                       $this->form .=
+                                                '<input type="hidden" '
+                                               
.'name="'.$this->form_hiddenvars[$i]->name.'" '
+                                               
.'value="'.$this->form_hiddenvars[$i]->value.'">';
+                                       // just to be safe, send a line break 
after every one of these
+                                       $this->form .= "\r\n";
+                               }
+                       }
+                       return $this->form;
+               }
+
+               /*!
+               @function form_closetag
+               @abstract SIMPLE - returns the closing tag for a form 
&lt;&#047;form&gt;
+               @author Angles
+               @discussion This seems dumb at first, but take the folders 
combobox as an example,
+               when the user selects a folder from the combbox the OnChange 
submits the form associated
+               with that combobox, i.e. the form OnChange and the form name 
should be the same name and
+               the form age should surround the combobox, I think, Anyway, 
IMAP servers have folders but
+               POP servers do now, so we will not show said folder combobox if 
viewing a POP3 mail server.
+               Therefor, in our template we put a non-breaking-space in the 
place of the combobox html.
+               BUT what about that those form tage that surround this 
combobox, we should leave them out
+               too. In typical templaying this is ease to replace the form 
opening tag with a non-breaking-space.
+               BUT the closing tag is such a simple thing we often hard code 
it into the template, not a template
+               var. SO we can not leave out the form open tag but have the 
form close tag still be in the template.
+               This no-brainer function just makes it easy to remember to 
leave out or include, as the case may
+               be, the form closeing tag.
+               @access public
+               */
+               function form_closetag()
+               {
+                       return '</form>';
+               }
+
+               
/**************************************************************************\
+               *       BUTTON WIDGET
+               
\**************************************************************************/
+
+               /*!
+               @function make_button
+               @abstract generate a button in a SINGLE FUNCTION CALL, all 
params must be passed.
+               @author Angles
+               @param $type (string) usually "SUBMIT"
+               @param $name (string) they GPC "key" in the "key - value" pair
+               @param $value (string) they GPC "value" in the "key - value" 
pair AND THE TEXT on the button
+               @param $onClick (string) OPTIONAL usually some javascript for 
the onclick event of the button. Default is none
+               @discussion Since a button is generally considered a "widget", 
I will call this a widget although it does
+               not use "set_" property functions the other widgets do. All 
params must be passed in the function call.
+               @access public
+               @example $my_button = $this->widgets->make_button('submit', 
'btn_send', lang('Send'));
+               */
+               //<input type="submit" name="btn_send" value="Send">
+               function make_button($type='', $name='',$value='', $onClick='')
+               {
+                       if ($type == '')
+                       {
+                               $type='submit';
+                       }
+                       if ($name == '')
+                       {
+                               $name=$type.'_button';
+                       }
+                       if ($value == '')
+                       {
+                               $value=lang('submit');
+                       }
+                       if ($onClick == '')
+                       {
+                               $onClick_tag = '';
+                       }
+                       else
+                       {
+                               $onClick_tag = ' onClick="'.$onClick.'"';;
+                       }
+
+                       $button = '<input type="'.$type.'" name="'.$name.'" 
value="'.$value.'"'.$onClick_tag.'>';
+                       return $button;
+               }

-               // if calling from home page it is optional to force currentapp 
as a constructor param
-               var $my_currentapp='';
-               // bootstraper for the msg class
-               var $msg_bootstrap;
-               // private template to var names do not collide
-               var $tpl;
-
-               // A HREF OOP properties
-               var $href_link='';
-               var $href_target='';
-               var $href_clickme='not_provided';
-               var $href='';
-
-               // combo box OOP properties
-               var $cbox_name='not_provided';
-               var $cbox_onChange='';
-               var $cbox_items=array();
-               var $combobox='';
-
-               // form OOP properties
-               var $form_name='';
-               var $form_action='';
-               var $form_method='';
-               var $form_hiddenvars=array();
-               var $form='';
-
-               // TOOLBAR
-               var $toolbar_msg='';
-               var $toolbar_row_one='';
-               var $toolbar_row_two='';
-               var $toolbar='';
-
-               // ALL FOLDERS ALL ACCOUNTS MEGA LISTBOX
-               var $F_megalist_form_reference='';
-               var $F_megalist_widget_name='';
-               var $F_megalist_preselected_fldball='';
-               var $F_megalist_skip_fldball='';
-               var $F_megalist_first_item_text = '';
-
-               // RELOAD WIDGET
-               var $refresh_js='';
+               
/**************************************************************************\
+               *       TOOLBAR COMPOUND WIDGET
+               
\**************************************************************************/

-               // GENERIC ERROR REPORT
-               var $F_mindless_default_txt = 'error text not provided';
-               var $F_error_report_text='';
-               var $F_go_somewhere_link='';
-               var $F_go_home_link='';
-
-
-               
/**************************************************************************\
-               *       CONSTRUCTOR
-               
\**************************************************************************/
-               function html_widgets()
-               {
-                       if ($this->debug_init > 0) { echo 'ENTER: 
email.html_widgets.CONSTRUCTOR'.'<br>'."\r\n"; }
-                       /*!
-                       @class requires including spell_struct header file
-                       @discussion  class html_widgets needs the special 
C-Style Include .h like file,
-                       class.spell_struct which holds data structure class 
correction_info used here for integration
-                       with the mail.spell  spellchecking class.
-                       */
-                       $required_class = 'spell_struct';
+               /*!
+               @capability TOOLBAR COMPOUND WIDGET
+               @discussion generate a toolbar for use in email pages  NOTE: 
usually only one toolbar made per page view
+               so there is no "new_toolbar" function because we should not 
need it. set_toolbar_msg is the only value
+               that you might want to check if you make more then one toolbar.
+               @author Angles
+               */
+
+               /*!
+               @function set_toolbar_msg
+               @abstract the toolbar has a 3rd row which can display text to 
the user. This function sets that.
+               @param $msg (string)
+               @author Angles
+               @discussion Usually after deleting or moving messages or 
creating, renaming, or deleting folders,
+               the mail_msg generates some kind of message to report to the 
user what actions were just taken.
+               Note a blank string will clear a msg if needed. Currently only 
the uiindex page and the uifolder page
+               might provide a msg.
+               @access public
+               */
+               function set_toolbar_msg($msg='')
+               {
+                       $this->toolbar_msg = $msg;
+               }
+               /*!
+               @function get_toolbar_msg
+               @abstract get whatever value the toolbar_msg property has.
+               @author Angles
+               @access public
+               */
+               function get_toolbar_msg()
+               {
+                       return $this->toolbar_msg;
+               }
+
+               /*!
+               @function get_toolbar
+               @abstract this function returns a complete html toolbar widget 
that is on top of many email pages.
+               @author Angles
+               @discussion generate a toolbar for use in email pages  NOTE:
+               WE NEED globals[phpge]->msg OBJECT and A LOGIN in order to make 
this toolbar,
+               THEREFOR do not put this toolbar on a page where login may not 
be available.Currently,
+               Preferencs pages DO NOT LOGIN, because if you are setting 
preferences you do not need
+               a mailserver stream AND you may not even have enough data set 
to get a mailserver stream.
+               Note: uses a private template object to assemple the toolbar, 
calling function is responsible for
+               putting the result in the global template.
+               @access public
+               */
+               function get_toolbar()
+               {
+                       // WE NEED ->msg OBJECT and A LOGIN in order to make 
this toolbar
+                       $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.html_widgets.get_toolbar', 
0);

-                       // if calling this class from the home page, then the 
currentapp will be
-                       //set to "home" instead of "email", which messes up the 
include statement below,
-                       // so set a local var to "email" to force considering 
the currentapp to be "email".
-                       $this->my_currentapp = 'email';
-                       
//require_once(PHPGW_INCLUDE_ROOT.'/'.$GLOBALS['phpgw_info']['flags']['currentapp'].'/inc/class.'.$required_class.'.inc.php');
-                       
require_once(PHPGW_INCLUDE_ROOT.'/'.$this->my_currentapp.'/inc/class.'.$required_class.'.inc.php');
+                       // we use a PRIVATE template object to produce this 
toolbar
+                       $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);

-                       if ($this->debug_init > 0) { echo 'EXIT: 
email.html_widgets.CONSTRUCTOR'.'<br>'."\r\n"; }
-                       return;
-               }
-
-
-               
/**************************************************************************\
-               *       HREF LINK WIDGET
-               
\**************************************************************************/
-
-               /*!
-               @capability HREF LINK WIDGET
-               @discussion generate an a href item, includes link, target, 
text. CLEARS ITSELF after each "get_href"
-               @author Angles
-               @example $this->widgets->set_href_link('index.php');
-               $this->widgets->set_href_target('top');
-               $this->widgets->get_href_clickme(lang('click here for more info 
in a new window'));
-               $my_href_tag = $this->widgets->get_href();
-               */
-               /*!
-               @function clear_href_vars
-               @abstract after every call to "->get_href" all internal vars 
are cleared automatically with this function.
-               @author Angles
-               @discussion href class vars for link, target, text. CLEARS 
ITSELF after each "get_href". This utilty
-               function does that. It is RARE that you would ever need to call 
this directly.
-               @access private
-               */
-               function clear_href_vars()
-               {
-                       $this->set_href_link('');
-                       $this->set_href_target('');
-                       $this->set_href_clickme('');
-               }
-
-               /*!
-               @function set_href_link
-               @abstract set the URL link of this this HREF widget
-               @param $href_link (string)
-               @author Angles
-               @access public
-               */
-               function set_href_link($href_link='')
-               {
-                       $this->href_link = $href_link;
-               }
-               /*!
-               @function get_href_link
-               @abstract used check or verify the value if the "href_link" 
property
-               @author Angles
-               @access public
-               */
-               function get_href_link()
-               {
-                       return $this->href_link;
-               }
-
-               /*!
-               @function set_href_target
-               @abstract OPTIONAL set the "target", i.e. what browser window 
this HREF should apply to,
-               default is not to specify any target in the HREF tag.
-               @param $href_target (string)
-               @author Angles
-               @access public
-               */
-               function set_href_target($href_target='')
-               {
-                       $this->href_target = $href_target;
-               }
-               /*!
-               @function get_href_target
-               @abstract used check or verify the value if the "href_target" 
property
-               @author Angles
-               @access public
-               */
-               function get_href_target()
-               {
-                       return $this->href_target;
-               }
-
-               /*!
-               @function set_href_clickme
-               @abstract what the user needs to click on to activate the HREF 
link, can be text or a COMPLETE img tag.
-               @param $href_clickme (string)  text or a COMPLETE img tag
-               @author Angles
-               @access public
-               */
-               function set_href_clickme($href_clickme='')
-               {
-                       $this->href_clickme = $href_clickme;
-               }
-               /*!
-               @function get_href_clickme
-               @abstract used check or verify the value if the "href_clickme" 
property
-               @author Angles
-               @access public
-               */
-               function get_href_clickme()
-               {
-                       return $this->href_clickme;
-               }
-
-               /*!
-               @function get_href
-               @abstract generate and return an HREF tag using information you 
set in the OOP "set_href_" functions
-               @author Angles
-               @result (string) a complete HREF tag generated from data you 
set in the "set_href_" functions,
-               @discussion After you set "href_target", "href_clickme" and 
other optional properties ("href_target") this
-               function generates an HREF tag from that data and returns it. 
NOTE after generating the HREF tag, and
-               before returning it, this function CLEARS ALL PROPERTIES that 
it used to make that href tag, so this
-               "widget" automatically is ready to new usage without having to 
explicitly call any "new" or "clear" function.
-               @access public
-               */
-               function get_href()
-               {
-                       if ($this->href_target != '')
-                       {
-                               $target = ' target="'.$this->href_target.'"';
-                       }
-                       // put the href return value in storage so we can clear 
all href internal vars before we exit this function with a return.
-                       $href = '<a href="' .$this->href_link .'"'.$target.'>' 
.$this->href_clickme .'</a>' ."\r\n";
-                       // this widget clears itself automatically after every 
call to this function.
-                       $this->clear_href_vars();
-                       return $href;
-               }
-
-               
/**************************************************************************\
-               *       QUICK HREF TAG - depreciated
-               
\**************************************************************************/
-               /*!
-               @function href_maketag (not related to the HREF widget)
-               @abstract QUICK way to generate a typical A HREF html item in a 
single function call. NOT PART OF
-               THE HREF WIDGET, not OOP style, just a quick utilty function. 
ALL params must be passed in this function call.
-               @param $href_link (string) URL for this HREF tag
-               @param $href_text (string) what the user clicks on to activate 
this HREF tag, can be text OR a COMPLETE IMG tag.
-               @param $target (string) OPTIONAL target for the link, such as 
when using frames or opening a new browser window.
-               @author Angles
-               @discussion not really a widget, does not use OOP style, but it 
gets the job done quickly. Somewhat Depreciated,
-               use the OOP style href widget instead.
-               @example this->href_maketag("index.jsp", "click here for home 
page", "new");
-               @access public
-               */
-               function href_maketag($href_link='',$href_text='default 
text',$target='')
-               {
-                       if ($target != '')
-                       {
-                               $target = ' target="'.$target.'"';
-                       }
-                       return '<a href="' .$href_link .'"'.$target.'>' 
.$href_text .'</a>' ."\r\n";
-               }
-
-               
/**************************************************************************\
-               *       QUICK IMG TAG
-               
\**************************************************************************/
-               /*!
-               @function img_maketag
-               @abstract quick and dirty to make an IMG html tag in one 
function call.
-               @author Angles
-               @param $location (string int) URL to the image, cal be 
releative or fully qualified
-               @param $alt (string) text displayed (a) in place of the image 
if not displayed, and (b) as a image tooltip on some browsers
-               @param $height (string int) int passed as a string, OPTIONAL, 
not included in img tag if not provided
-               @param $width (string int)  int passed as a string OPTIONAL, 
not included in img tag if not provided
-               @param $border (string int) int passed as string OPTIONAL , not 
included in img tag if not provided ,
-               the size of the border around the image, often set to "0"
-               @discussion not really a widget but it gets the job done. QUICK 
way to generate a typical A IMG html item
-               in a single function call. Not OOP style, just a quick utilty 
function. ALL params must be passed in this function call.
-               @example $my_img = widgets->img_maketag("poweredby.png", 
"powered by RedHat",  "", "", "0");
-               @access public
-               */
-               function 
img_maketag($location='',$alt='',$height='',$width='',$border='')
-               {
-                       $alt_default_txt = 'image';
-                       $alt_unknown_txt = 'unknown';
-                       if ($location == '')
-                       {
-                               return '<img src="" 
alt="['.$alt_unknown_txt.']">';
-                       }
-                       if ($alt != '')
-                       {
-                               $alt_tag = ' alt="['.$alt.']"';
-                       }
-                       else
-                       {
-                               $alt_tag = ' alt="['.$alt_default_txt.']"';
-                       }
-                       if ($height != '')
-                       {
-                               $height_tag = ' height="' .$height .'"';
-                       }
-                       else
-                       {
-                               $height_tag = '';
-                       }
-                       if ($width != '')
-                       {
-                               $width_tag = ' width="' .$width .'"';
-                       }
-                       else
-                       {
-                               $width_tag = '';
-                       }
-                       if ($border != '')
-                       {
-                               $border_tag = ' border="' .$border .'"';
-                       }
-                       else
-                       {
-                               $border_tag = '';
-                       }
-                       $image_html = '<img src="'.$location.'"' .$height_tag 
.$width_tag .$border_tag .$alt_tag .'>';
-                       return $image_html;
-               }
-
-               
/**************************************************************************\
-               *       COMBOBOX WIDGET
-               
\**************************************************************************/
-
-               /*!
-               @capability COMBOBOX WIDGET
-               @discussion generate a combo box html widget.
-               @author Angles
-               @example
-               $this->widgets->new_combobox();
-               $this->widgets->set_cbox_name("user_choice");
-               $this->widgets->set_cbox_item("yes"', "Customer is Right");
-               $this->widgets->set_cbox_item("no"', "Customer is Wrong");
-               $my_combobox_wirget = $this->widgets->get_combobox();
-               */
-               // combo box OOP access functions
-               /*!
-               @function set_cbox_name
-               @abstract ?
-               */
-               function set_cbox_name($str='')
-               {
-                       if ($str == '')
-                       {
-                               $this->cbox_name = 'not_provided';
-                       }
-                       else
-                       {
-                               $this->cbox_name = $str;
-                       }
-               }
-               /*!
-               @function get_cbox_name
-               @abstract ?
-               */
-               function get_cbox_name()
-               {
-                       return $this->cbox_name;
-               }
-
-               /*!
-               @function set_cbox_onChange
-               @abstract ?
-               */
-               function set_cbox_onChange($str='')
-               {
-                       if ($str != '')
-                       {
-                               $this->cbox_onChange = $str;
-                       }
-               }
-               /*!
-               @function get_cbox_onChange
-               @abstract ?
-               */
-               function get_cbox_onChange()
-               {
-                       return $this->cbox_onChange;
-               }
-
-               /*!
-               @function set_cbox_item
-               @abstract ?
-               */
-               function set_cbox_item($value='',$text='',$selected=False)
-               {
-                       // make sure $selected is boolean
-                       if (!is_bool($selected))
-                       {
-                               // replace param with a default boolean value 
of False
-                               $selected = False;
-                       }
-                       // I've actually seen bomboboxes with an item (usually 
the first) with no name
-                       if (($value != '') || ($text != ''))
-                       {
-                               $item_idx = count($this->cbox_items);
-                               $this->cbox_items[$item_idx] = new html_option;
-                               $this->cbox_items[$item_idx]->value = $value;
-                               $this->cbox_items[$item_idx]->text = $text;
-                               $this->cbox_items[$item_idx]->selected = 
$selected;
-                       }
-               }
-               /*!
-               @function set_cbox_item_spellcheck
-               @abstract makes a special kind of combobox select item for use 
with spellcheck
-               @param $this_bad_word_element (class "correction_info" 
structued data from file class.spell_struct)
-               @param $suggestion_num (int OR empty string) see discussion 
below.
-               @author Angles
-               @discussion  This function makes use of structure 
"correction_info" which we expose
-               by including file class.spell_struct in the constructor for 
this class. The combobox select item this
-               function makes embeds array data in the items "value" by 
setting it to a string that
-               resembles a URL get request, which we then can recover this 
array by applying php function
-               parse_str to the value when the user submits the form. The idea 
is to provide enough data
-               in the value that the spellcheck replacement code can 
accurately find and replace the desired
-               word, or not change the word at all if special suggestion 
string "K_E_E_P" is present.
-               The first suggestion should be en empty string with special 
value "K_E_E_P"
-               which means no change to the misspelled word, this is indicated 
by passing an empty string
-               for param $suggestion_num.
-               The value for the suggestion item is a URL type string that 
contains as much informaion
-               as we can preserve from the $this_bad_word_element object 
param, but specifying the individual
-               suggestion provieded by the $suggestion_num arg which is the 
index to this particular
-               suggestion in the $this_bad_word_element->suggestions[] 
numbered array of suggestions.
-               Upon submit, we can apply php function parse_str() to this uri 
to recover the desired array structure.
-               Parse_str will even urldecode the items for us.
-               */
-               function set_cbox_item_spellcheck($this_bad_word_element='', 
$suggestion_num='')
-               {
-                       // we included the spell_struct file above, so this 
object knows what
-                       // correction_info struct is
-                       if (is_object($this_bad_word_element))
-                       {
-                               if ((string)$suggestion_num != '')
-                               {
-                                       $suggestion_txt = 
$this_bad_word_element->suggestions[(int)$suggestion_num];
-                                       $suggestion_value = 
$this_bad_word_element->suggestions[(int)$suggestion_num];
-                               }
-                               else
-                               {
-                                       // the first suggestion should be en 
empty string with special value "K_E_E_P"
-                                       // which means no change to the 
misspelled word
-                                       // this is indicated by passing an 
empty string for $suggestion_num
-                                       $suggestion_txt = '';
-                                       $suggestion_value = 'K_E_E_P';
-                               }
-                               // the value for the suggestion item is a URL 
type string that contains as much informaion
-                               // as we can preserve from the 
$this_bad_word_element object, but specifying the individual
-                               // suggection provieded by the $suggestion_num 
arg which is the index to this particular
-                               // suggestion in the 
$this_bad_word_element->suggestions[] numbered array of suggestions
-                               // upon submit, we can apply php function 
parse_str() to this uri to recover the desired array structure.
-                               // parse_str will even urldecode the items for 
us.
-                               /*
-                               $uri_value =
-                                         
'cbox[orig_word]='.urlencode($this_bad_word_element->orig_word)
-                                       
.'&cbox[orig_word_clean]='.urlencode($this_bad_word_element->orig_word_clean)
-                                       
.'&cbox[line_num]='.urlencode($this_bad_word_element->line_num)
-                                       
.'&cbox[word_num]='.urlencode($this_bad_word_element->word_num)
-                                       
.'&cbox[suggestion_value]='.urlencode($suggestion_value);
-                               */
-                               $uri_value =
-                                         
'orig_word='.urlencode($this_bad_word_element->orig_word)
-                                       
.'&orig_word_clean='.urlencode($this_bad_word_element->orig_word_clean)
-                                       
.'&line_num='.urlencode($this_bad_word_element->line_num)
-                                       
.'&word_num='.urlencode($this_bad_word_element->word_num)
-                                       
.'&suggestion_value='.urlencode($suggestion_value);
-
-                               $item_idx = count($this->cbox_items);
-                               $this->cbox_items[$item_idx] = new html_option;
-                               $this->cbox_items[$item_idx]->value = 
$uri_value;
-                               $this->cbox_items[$item_idx]->text = 
$suggestion_txt;
-                       }
-               }
-               /*!
-               @function get_cbox_item
-               @abstract ?
-               */
-               function get_cbox_item($idx='')
-               {
-                       if ((string)$idx == '')
-                       {
-                               return $this->cbox_items;
-                       }
-                       else
-                       {
-                               return $this->cbox_items[$idx];
-                       }
-               }
-
-               /*!
-               @function new_combobox
-               @abstract ALWAYS start a new combobox widget by calling this 
function first. Clears all combobox
-               properties.
-               */
-               function new_combobox()
-               {
-                       $this->cbox_name='not_provided';
-                       $this->cbox_onChange='';
-                       $this->cbox_items=array();
-                       $this->combobox='';
-               }
-
-               /*!
-               @function get_combobox
-               @abstract generate and return a HTML select (combobo) widget 
using the values you set in
-               the "set_cbox_" functions.
-               @author Angles
-               @discussion this function does not clear its properties, so if 
for some reason you want THE SAME
-               comboboxes more then one time, calling "get_combobox" will 
return the same combobox until you
-               clear it by calling "new_combobox", which you should ALWAYS do 
when starting a new combobox
-               widget. VALUES ARE NOT URLENCODED, except that the special 
spellcheck item stuff
-               does it, but before this function, and this does not happen for 
the normal set cbox item. It IS
-               html specialchars encoded here.
-               @access public
-               */
-               function get_combobox()
-               {
-                       if ($this->cbox_onChange != '')
-                       {
-                               $onChange_tag = ' 
onChange="'.$this->cbox_onChange.'"';
-                       }
-                       else
-                       {
-                               $onChange_tag = '';
-                       }
-                       $this->combobox = '<select 
name="'.$this->cbox_name.'"'.$onChange_tag.'>';
-                       $loops = count($this->cbox_items);
-                       if ($loops > 0)
-                       {
-                               for ($i=0; $i < $loops; $i++)
-                               {
-                                       if ($this->cbox_items[$i]->selected == 
True)
-                                       {
-                                               $selected_tag = ' selected';
-                                       }
-                                       else
-                                       {
-                                               $selected_tag = '';
-                                       }
-                                       $this->combobox .=
-                                               '<option 
value="'.$this->cbox_items[$i]->value.'"'.$selected_tag.'>'
-                                               
.htmlspecialchars($this->cbox_items[$i]->text)
-                                               .'</option>';
-                                       $this->combobox .= "\r\n";
-                               }
-                       }
-                       $this->combobox .= '</select>';
-                       return $this->combobox;
-               }
-               // <select name="filter" onChange="this.form.submit();"><option 
value="all">show all</option>
-               // <option value="public">only yours</option>
-               // <option value="private">Private</option>
-               // </select>
-
-               
/**************************************************************************\
-               *       FORM WIDGET
-               
\**************************************************************************/
-
-               /*!
-               @capability FORM WIDGET
-               @discussion generate a opening tag of a form including name, 
action, method, and hiddenvars
-               @author Angles
-               @example
-               $this->widgets->new_form();
-               $this->widgets->set_form_name('spell_review');
-               $this->widgets->set_form_method('POST');
-               $this->widgets->set_form_action('index.php?email.targets.move');
-               $this->widgets->set_form_hiddenvar('subject', 'stock');
-               $this->widgets->set_form_hiddenvar('symbol', 'GM');
-               // OPTIONAL if you have set "preserve_vars" you can include 
them as hidden vars with this command
-               $this->commit_preserve_vars_to_form();
-               $my_form_tag = $this->widgets->get_form();
-               */
-               function new_form()
-               {
-                       $this->form_name='not_provided';
-                       $this->form_action='';
-                       $this->form_method='POST';
-                       $this->form_hiddenvars=array();
-                       $this->form = '';
-               }
-
-               /*!
-               @function set_form_name
-               @abstract ?
-               */
-               function set_form_name($str='')
-               {
-                       if ($str != '')
-                       {
-                               $this->form_name = $str;
-                       }
-               }
-               /*!
-               @function get_form_name
-               @abstract ?
-               */
-               function get_form_name()
-               {
-                       return $this->form_name;
-               }
-
-               /*!
-               @function set_form_action
-               @abstract ?
-               */
-               function set_form_action($str='')
-               {
-                       if ($str != '')
-                       {
-                               $this->form_action = $str;
-                       }
-               }
-               /*!
-               @function
-               @abstract ? get_form_action
-               */
-               function get_form_action()
-               {
-                       return $this->form_action;
-               }
-
-               /*!
-               @function set_form_method
-               @abstract ?
-               */
-               function set_form_method($str='')
-               {
-                       if ($str != '')
-                       {
-                               $this->form_method = $str;
-                       }
-               }
-               /*!
-               @function get_form_method
-               @abstract ?
-               */
-               function get_form_method()
-               {
-                       return $this->form_method;
-               }
-
-               /*!
-               @function set_form_hiddenvar
-               @abstract put hidden  vars in a form tag.
-               @param $name the "key" in the GPC key - value pair
-               @param $value  the "value" in the GPC key - value pair
-               @param $do_urlencode (boolean) OPTIONAL default is True, 
whether or not to urlencode the name and value params.
-               @author Angles
-               @access public
-               */
-               function set_form_hiddenvar($name='',$value='', 
$do_urlencode=True)
-               {
-                       // I've actually seen bomboboxes with an item (usually 
the first) with no name
-                       if (($name != '') || ($value != ''))
-                       {
-                               if ($do_urlencode == True)
-                               {
-                                       $name = urlencode($name);
-                                       $value = urlencode($value);
-                               }
-                               $item_idx = count($this->form_hiddenvars);
-                               $this->form_hiddenvars[$item_idx] = new 
hiddenvar_option;
-                               $this->form_hiddenvars[$item_idx]->name = $name;
-                               $this->form_hiddenvars[$item_idx]->value = 
$value;
-                       }
-               }
-               /*!
-               @function get_form_hiddenvar
-               @abstract ?
-               */
-               function get_form_hiddenvar($idx='')
-               {
-                       if ((string)$idx == '')
-                       {
-                               return $this->form_hiddenvars;
-                       }
-                       else
-                       {
-                               return $this->form_hiddenvars[$idx];
-                       }
-               }
-
-               // <form enctype="multipart/form-data" name="spell_review" 
action="/mail/index.php?menuaction=email.bosend.sendorspell&fldball[folder]=INBOX&fldball[acctnum]=3&sort=1&order=1&start=0"
 method="POST">
-               //<input type="hidden" name="sort" value="1">
-               //<input type="hidden" name="order" value="1">
-               //<input type="hidden" name="start" value="0">
-               //<input type="hidden" name="force_showsize" value="1">
-               /*!
-               @function get_form
-               @abstract generate and return an opening FORM tag using the 
data you set in the "set_form_" functions.
-               @author Angles
-               @discussion Any hiddenvars will be urlencoded. NOTE YOU MUST 
PUT THE CLOSING &lt;&#047;form&gt; somewhere
-               after this form tag. This functions generates the opening tag 
of the form, which is where all the complicated stuff
-               is. The ending tag is a normal html markup closing tag you must 
supply. NOTE on form enctype, HTML 401 says
-               "multipart/form-data" is very strict to MIME rfc2045-49 and 
will add hard wrap CRLF to each line of text
-               in any control. For example, a TEXTAREA input control will hard 
wrap at whatever its column length is,
-               because it represents the end of a line of text, eventhough the 
user did not explicitly press return, and therefor
-               it should be a soft return, not a CRLF. On the other hand, 
"application/x-www-form-urlencoded" is the default
-               value and is assumed if not provided, and is the kind of submit 
we are more used to. NOTE "multipart/form-data"
-               is also designed to handle large amounts of text or binary 
data, so "multipart/form-data" is used with file upload
-               forms, which means "multipart/form-data" WILL NOT WORK if the 
php.ini file does not allow "FILE UPLOADS".
-               This can be a confusing issue because we are not submitting a 
file upload, just some text, but the
-               "multipart/form-data"  is used for file upload forms, hence the 
association.  UPDATE testing shows this
-               may not be true eventhough HTML v401 says so. In a TEXTAREA 
control, using wrap="hard" yields the
-               CRLF hard wrap regardless of the enctype, and without the 
wrap="hard" there is no CRLF line ends to soft
-               wraps, eventhough there should be with "multipart/form-data" 
forms.
-               @access prublic
-               */
-               function get_form()
-               {
-                       $this->form =
-                               // '<form enctype="multipart/form-data" '
-                                '<form 
enctype="application/x-www-form-urlencoded" '
-                               .'name="'.$this->form_name.'" '
-                               .'action="'.$this->form_action.'" '
-                               .'method="'.$this->form_method.'">'
-                               ."\r\n";
-
-                       $loops = count($this->form_hiddenvars);
-                       if ($loops > 0)
-                       {
-                               for ($i=0; $i < $loops; $i++)
-                               {
-                                       $this->form .=
-                                                '<input type="hidden" '
-                                               
.'name="'.$this->form_hiddenvars[$i]->name.'" '
-                                               
.'value="'.$this->form_hiddenvars[$i]->value.'">';
-                                       // just to be safe, send a line break 
after every one of these
-                                       $this->form .= "\r\n";
-                               }
-                       }
-                       return $this->form;
-               }
-
-               /*!
-               @function form_closetag
-               @abstract SIMPLE - returns the closing tag for a form 
&lt;&#047;form&gt;
-               @author Angles
-               @discussion This seems dumb at first, but take the folders 
combobox as an example,
-               when the user selects a folder from the combbox the OnChange 
submits the form associated
-               with that combobox, i.e. the form OnChange and the form name 
should be the same name and
-               the form age should surround the combobox, I think, Anyway, 
IMAP servers have folders but
-               POP servers do now, so we will not show said folder combobox if 
viewing a POP3 mail server.
-               Therefor, in our template we put a non-breaking-space in the 
place of the combobox html.
-               BUT what about that those form tage that surround this 
combobox, we should leave them out
-               too. In typical templaying this is ease to replace the form 
opening tag with a non-breaking-space.
-               BUT the closing tag is such a simple thing we often hard code 
it into the template, not a template
-               var. SO we can not leave out the form open tag but have the 
form close tag still be in the template.
-               This no-brainer function just makes it easy to remember to 
leave out or include, as the case may
-               be, the form closeing tag.
-               @access public
-               */
-               function form_closetag()
-               {
-                       return '</form>';
-               }
-
-               
/**************************************************************************\
-               *       BUTTON WIDGET
-               
\**************************************************************************/
-
-               /*!
-               @function make_button
-               @abstract generate a button in a SINGLE FUNCTION CALL, all 
params must be passed.
-               @author Angles
-               @param $type (string) usually "SUBMIT"
-               @param $name (string) they GPC "key" in the "key - value" pair
-               @param $value (string) they GPC "value" in the "key - value" 
pair AND THE TEXT on the button
-               @param $onClick (string) OPTIONAL usually some javascript for 
the onclick event of the button. Default is none
-               @discussion Since a button is generally considered a "widget", 
I will call this a widget although it does
-               not use "set_" property functions the other widgets do. All 
params must be passed in the function call.
-               @access public
-               @example $my_button = $this->widgets->make_button('submit', 
'btn_send', lang('Send'));
-               */
-               //<input type="submit" name="btn_send" value="Send">
-               function make_button($type='', $name='',$value='', $onClick='')
-               {
-                       if ($type == '')
-                       {
-                               $type='submit';
-                       }
-                       if ($name == '')
-                       {
-                               $name=$type.'_button';
-                       }
-                       if ($value == '')
-                       {
-                               $value=lang('submit');
-                       }
-                       if ($onClick == '')
-                       {
-                               $onClick_tag = '';
-                       }
-                       else
-                       {
-                               $onClick_tag = ' onClick="'.$onClick.'"';;
-                       }
-
-                       $button = '<input type="'.$type.'" name="'.$name.'" 
value="'.$value.'"'.$onClick_tag.'>';
-                       return $button;
-               }
-
-               
/**************************************************************************\
-               *       TOOLBAR COMPOUND WIDGET
-               
\**************************************************************************/
-
-               /*!
-               @capability TOOLBAR COMPOUND WIDGET
-               @discussion generate a toolbar for use in email pages  NOTE: 
usually only one toolbar made per page view
-               so there is no "new_toolbar" function because we should not 
need it. set_toolbar_msg is the only value
-               that you might want to check if you make more then one toolbar.
-               @author Angles
-               */
-
-               /*!
-               @function set_toolbar_msg
-               @abstract the toolbar has a 3rd row which can display text to 
the user. This function sets that.
-               @param $msg (string)
-               @author Angles
-               @discussion Usually after deleting or moving messages or 
creating, renaming, or deleting folders,
-               the mail_msg generates some kind of message to report to the 
user what actions were just taken.
-               Note a blank string will clear a msg if needed. Currently only 
the uiindex page and the uifolder page
-               might provide a msg.
-               @access public
-               */
-               function set_toolbar_msg($msg='')
-               {
-                       $this->toolbar_msg = $msg;
-               }
-               /*!
-               @function get_toolbar_msg
-               @abstract get whatever value the toolbar_msg property has.
-               @author Angles
-               @access public
-               */
-               function get_toolbar_msg()
-               {
-                       return $this->toolbar_msg;
-               }
-
-               /*!
-               @function get_toolbar
-               @abstract this function returns a complete html toolbar widget 
that is on top of many email pages.
-               @author Angles
-               @discussion generate a toolbar for use in email pages  NOTE:
-               WE NEED globals[phpge]->msg OBJECT and A LOGIN in order to make 
this toolbar,
-               THEREFOR do not put this toolbar on a page where login may not 
be available.Currently,
-               Preferencs pages DO NOT LOGIN, because if you are setting 
preferences you do not need
-               a mailserver stream AND you may not even have enough data set 
to get a mailserver stream.
-               Note: uses a private template object to assemple the toolbar, 
calling function is responsible for
-               putting the result in the global template.
-               @access public
-               */
-               function get_toolbar()
-               {
-                       // WE NEED ->msg OBJECT and A LOGIN in order to make 
this toolbar
-                       $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.html_widgets.get_toolbar', 
0);
-
-                       // we use a PRIVATE template object to produce this 
toolbar
-                       $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-
-                       // if we already made this toolbar, retuen it from L1 
cache ????
-                       //$my_acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
-                       $this->tpl->set_file(array('T_widget_toolbar' => 
'widget_toolbar.tpl'));
-                       
$this->tpl->set_block('T_widget_toolbar','B_toolbar_row_one','V_toolbar_row_one');
-                       
$this->tpl->set_block('T_widget_toolbar','B_toolbar_row_two','V_toolbar_row_two');
-
-                       // We use these over and over, so figure them out now
+                       // if we already made this toolbar, retuen it from L1 
cache ????
+                       //$my_acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
+                       $this->tpl->set_file(array('T_widget_toolbar' => 
'widget_toolbar.tpl'));
+                       
$this->tpl->set_block('T_widget_toolbar','B_toolbar_row_one','V_toolbar_row_one');
+                       
$this->tpl->set_block('T_widget_toolbar','B_toolbar_row_two','V_toolbar_row_two');
+
+                       // We use these over and over, so figure them out now
                        // some fonts and font sizes
-                       $row1_rowcolor_key = 'row_off';
+                       $row1_rowcolor_key = 'row_off';
                        $row2_rowcolor_key = 'row_on';
                        
$this->tpl->set_var('row1_rowcolor_key',$row1_rowcolor_key);
                        
$this->tpl->set_var('row2_rowcolor_key',$row2_rowcolor_key);
-                       
$this->tpl->set_var('toolbar_row1_bgcolor',$GLOBALS['phpgw_info']['theme'][$row1_rowcolor_key]);
-                       
$this->tpl->set_var('toolbar_row2_bgcolor',$GLOBALS['phpgw_info']['theme'][$row2_rowcolor_key]);
-                       
$this->tpl->set_var('toolbar_font',$GLOBALS['phpgw_info']['theme']['font']);
-                       $this->tpl->set_var('toolbar_font_size','2');
-                       $this->tpl->set_var('report_this_font_size','1');
-
-                       $this->tpl->set_var('report_this', 
$GLOBALS['phpgw']->msg->report_moved_or_deleted());
-
-                       $icon_theme = 
$GLOBALS['phpgw']->msg->get_pref_value('icon_theme',$acctnum);
-                       $icon_size = 
$GLOBALS['phpgw']->msg->get_pref_value('icon_size',$acctnum);
-                       $svr_image_dir = PHPGW_IMAGES_DIR;
-                       $image_dir = PHPGW_IMAGES;
-
-                       // this is optional
-                       $this->clear_href_vars();
-                       // Create Links for all the buttons
-                       $folders_link = 
$GLOBALS['phpgw']->link('/index.php',array(
-                                                                       
'menuaction' => 'email.uifolder.folder',
-                                                                       // 
going to the folder list page, we only need log into the INBOX folder
-                                                                       
'fldball[folder]' => 'INBOX',
-                                                                       
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum()));
-                       $compose_link = 
$GLOBALS['phpgw']->link('/index.php',array(
-                                                                       
'menuaction' => 'email.uicompose.compose',
-                                                                       // this 
data tells us where to return to after sending a message
-                                                                       
'fldball[folder]' => $GLOBALS['phpgw']->msg->prep_folder_out(),
-                                                                       
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum(),
-                                                                       'sort' 
=> $GLOBALS['phpgw']->msg->get_arg_value('sort'),
-                                                                       'order' 
=> $GLOBALS['phpgw']->msg->get_arg_value('order'),
-                                                                       'start' 
=> $GLOBALS['phpgw']->msg->get_arg_value('start')));
-                       $filters_link = 
$GLOBALS['phpgw']->link('/index.php',array(
-                                                               'menuaction' => 
'email.uifilters.filters_list',
-                                                               // this data 
tells us what folder and account was last active
-                                                               
'fldball[folder]' => $GLOBALS['phpgw']->msg->prep_folder_out(),
-                                                               
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum()));
-                       $accounts_link = 
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uipreferences.ex_accounts_list');
-                       $email_prefs_link = 
$GLOBALS['phpgw']->link('/index.php',array(
-                                                               'menuaction' => 
'email.uipreferences.preferences',
-                                                               'ex_acctnum' => 
$GLOBALS['phpgw']->msg->get_acctnum()));
-                       // Check to see if mailserver supports folders.
-                       $has_folders = 
$GLOBALS['phpgw']->msg->get_mailsvr_supports_folders();
-                       // Create Buttons
-                       switch 
($GLOBALS['phpgw']->msg->get_pref_value('button_type'))
-                       {
-                               case 'text':
-                                       //Create Compose Button
-                                       $this->set_href_link($compose_link);
-                                       
$this->set_href_clickme(lang('Compose'));
-                                       $this->tpl->set_var('compose_txt_link', 
$this->get_href());
-                                       $this->tpl->set_var('compose_img_link', 
'&nbsp;');
-                                       //Create Filter Button
-                                       $this->set_href_link($filters_link);
-                                       
$this->set_href_clickme(lang('Filters'));
-                                       $this->tpl->set_var('filters_txt_link', 
$this->get_href());
-                                       $this->tpl->set_var('filters_img_link', 
'&nbsp;');
-                                       //Create Accounts Button
-                                       $this->set_href_link($accounts_link);
-                                       
$this->set_href_clickme(lang('Accounts'));
-                                       
$this->tpl->set_var('accounts_txt_link', $this->get_href());
-                                       
$this->tpl->set_var('accounts_img_link', '&nbsp;');
-                                       //Create Settings Button
-                                       $this->set_href_link($email_prefs_link);
-                                       
$this->set_href_clickme(lang('Settings'));
-                                       
$this->tpl->set_var('settings_txt_link', $this->get_href());
-                                       
$this->tpl->set_var('settings_img_link', '&nbsp;');
-                                       //Check for folder support and create 
Folder Button
-                                       if ($has_folders == True)
-                                       {
-                                               
//$this->set_href_clickme($this->img_maketag($image_dir.'/'.$icon_theme.'-folder-'.$icon_size.'.gif',lang('Folders'),'','','0'));
-                                               
//$this->tpl->set_var('folders_img_link', $this->get_href());
-                                               //Create Folder Text Link
-                                               
$this->set_href_link($folders_link);
-                                               
$this->set_href_clickme(lang('Folders'));
-                                               
$this->tpl->set_var('folders_txt_link', $this->get_href());
-                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
-                                       }
-                                       else
-                                       {
-                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
-                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
-                                       }
-                                       break;
-                               case 'image':
-                                       //Create Compose Button
-                                       $this->set_href_link($compose_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/compose-message-'.$icon_size,'_on'),lang('Compose'),'','','0'));
-                                       $this->tpl->set_var('compose_img_link', 
$this->get_href());
-                                       $this->tpl->set_var('compose_txt_link', 
'&nbsp;');
-                                       //Create Filter Button
-                                       $this->set_href_link($filters_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/filters-'.$icon_size,'_on'),lang('Filters'),'','','0'));
-                                       $this->tpl->set_var('filters_img_link', 
$this->get_href());
-                                       $this->tpl->set_var('filters_txt_link', 
'&nbsp;');
-                                       //Create Accounts Button
-                                       $this->set_href_link($accounts_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/accounts-'.$icon_size,'_on'),lang('Accounts'),'','','0'));
-                                       
$this->tpl->set_var('accounts_img_link', $this->get_href());
-                                       
$this->tpl->set_var('accounts_txt_link', '&nbsp;');
-                                       //Create Settings Button
-                                       $this->set_href_link($email_prefs_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/customize-'.$icon_size,'_on'),lang('Settings'),'','','0'));
-                                       
$this->tpl->set_var('settings_img_link', $this->get_href());
-                                       
$this->tpl->set_var('settings_txt_link', '&nbsp;');
-                                       //Check for folder support and create 
Folder Button
-                                       if ($has_folders == True)
-                                       {
-                                               //Create Folder Image Link
-                                               
$this->set_href_link($folders_link);
-                                               
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/folder-'.$icon_size,'_on'),lang('Folders'),'','','0'));
-                                               
$this->tpl->set_var('folders_img_link', $this->get_href());
-                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
-
-                                       }
-                                       else
-                                       {
-                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
-                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
-                                       }
-                                       break;
-                               case 'both':
-                                       //Create Compose Button
-                                       $this->set_href_link($compose_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/compose-message-'.$icon_size,'_on'),lang('Compose'),'','','0'));
-                                       $this->tpl->set_var('compose_img_link', 
$this->get_href());
-                                       $this->set_href_link($compose_link);
-                                       
$this->set_href_clickme(lang('Compose'));
-                                       $this->tpl->set_var('compose_txt_link', 
$this->get_href());
-                                       //Create Filter Button
-                                       $this->set_href_link($filters_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/filters-'.$icon_size,'_on'),lang('Filters'),'','','0'));
-                                       $this->tpl->set_var('filters_img_link', 
$this->get_href());
-                                       $this->set_href_link($filters_link);
-                                       
$this->set_href_clickme(lang('Filters'));
-                                       $this->tpl->set_var('filters_txt_link', 
$this->get_href());
-                                       //Create Accounts Button
-                                       $this->set_href_link($accounts_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/accounts-'.$icon_size,'_on'),lang('Accounts'),'','','0'));
-                                       
$this->tpl->set_var('accounts_img_link', $this->get_href());
-                                       $this->set_href_link($accounts_link);
-                                       
$this->set_href_clickme(lang('Accounts'));
-                                       
$this->tpl->set_var('accounts_txt_link', $this->get_href());
-                                       //Create Settings Button
-                                       $this->set_href_link($email_prefs_link);
-                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/customize-'.$icon_size,'_on'),lang('Settings'),'','','0'));
-                                       
$this->tpl->set_var('settings_img_link', $this->get_href());
-                                       $this->set_href_link($email_prefs_link);
-                                       
$this->set_href_clickme(lang('Settings'));
-                                       
$this->tpl->set_var('settings_txt_link', $this->get_href());
-                                       //Check for folder support and create 
Folder Button
-                                       if ($has_folders == True)
-                                       {
-                                               //Create Folder Image Link
-                                               
$this->set_href_link($folders_link);
-                                               
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/folder-'.$icon_size,'_on'),lang('Folders'),'','','0'));
-                                               
$this->tpl->set_var('folders_img_link', $this->get_href());
-                                               //Create Folder Text Link
-                                               
$this->set_href_link($folders_link);
-                                               
$this->set_href_clickme(lang('Folders'));
-                                               
$this->tpl->set_var('folders_txt_link', $this->get_href());
-                                       }
-                                       else
-                                       {
-                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
-                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
-                                       }
-                                       break;
-                               }
-                       // make the 1st row
-                       $this->toolbar_row_one = 
$this->tpl->parse('V_toolbar_row_one','B_toolbar_row_one');
-                       // END TOOL BAR ROW 1
-
-                       // BEGIN TOOL BAR ROW2
-                       // ---- folders switchbox  ----
-                       //<form name="folders_cbox" 
action="/mail/index.php?menuaction=email.uiindex.index" method="post">
-                       if ($has_folders == True)
-                       {
-                               $this->new_form();
-                               $this->set_form_name('folders_cbox');
-                               
$this->set_form_action($GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'));
-                               $this->set_form_method('post');
-                               
$this->tpl->set_var('form_folders_cbox_opentag', $this->get_form());
-                               $this->tpl->set_var('folders_combobox', 
$this->all_folders_combobox());
-                               
$this->tpl->set_var('form_folders_cbox_closetag', $this->form_closetag());
-                       }
-                       else
-                       {
-                               
$this->tpl->set_var('form_folders_cbox_opentag', '');
-                               $this->tpl->set_var('folders_combobox', 
'&nbsp;');
-                               
$this->tpl->set_var('form_folders_cbox_closetag', '');
-                       }
-                       // associated image is still filled from row one
-
-
-                       // ---- account switchbox  ----
-                       // <form name="acctbox" 
action="/mail/index.php?menuaction=email.uiindex.index" method="post">
-                       $this->new_form();
-                       $this->set_form_name('accounts_cbox');
-                       
$this->set_form_action($GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'));
-                       $this->set_form_method('post');
-                       $this->tpl->set_var('form_acctbox_opentag', 
$this->get_form());
-                       $this->tpl->set_var('acctbox_combobox', 
$this->all_accounts_combobox());
-                       // associated image is still filled from row one
-
-                       // show he user a message if this property is filled, 
if empty then output a nbsp for html sanity
-                       if (trim($this->get_toolbar_msg()) != '')
-                       {
-                               $toolbar_report_msg = $this->get_toolbar_msg();
-                       }
-                       else
-                       {
-                               $toolbar_report_msg = '&nbsp;';
-                       }
-                       $this->tpl->set_var('toolbar_report_msg', 
$toolbar_report_msg);
-
-
-                       // make the 2nd row AND the 3rd row
-                       $this->toolbar_row_two = 
$this->tpl->parse('V_toolbar_row_two','B_toolbar_row_two');
-
-                       return $this->toolbar_row_one . $this->toolbar_row_two;
-
-               }
-
-
-               /*!
-               @function all_folders_combobox
-               @abstract high level function, uses functions in mail_msg and 
this class html_widgets to make an acct switchbox
-               UNDER DEVELOPMENT.
-               @param $form_reference (string) this bombobox sets an 
"onChange" event, which will submit the form you put here.
-               Default value is "document.folders_cbox.submit()" where "" is 
the default value for the $form_reference param
-               @result string representing an HTML listbox widget
-               @author Angles
-               @discussion The first item in this folder combo box tells the 
user to "pick a folder to change to", and has
-               no "value", the value is an empty string, this is more like a 
label than a combobox item.
-               @access private, maybe made public
-               */
-               function all_folders_combobox($form_reference='')
-               {
-                       if ($form_reference == '')
-                       {
-                               $form_reference = 'folders_cbox';
-                       }
-                       $acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
-
-                       $this->new_combobox();
-                       $this->set_cbox_name('fldball_fake_uri');
-                       // default is "document.folders_cbox.submit()"
-                       
$this->set_cbox_onChange('document.'.$form_reference.'.submit()');
-                       // set_cbox_item(value, text, selected(optional, 
boolean, default false)
-                       $this->set_cbox_item('', lang('switch current folder 
to'));
-
-                       // get the actual list of folders we are going to put 
into the combobox
-                       //$folder_list = 
$GLOBALS['phpgw']->msg->get_folder_list();
-                       $folder_list = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list', $acctnum);
-                       //$folder_list =& 
$GLOBALS['phpgw']->msg->get_arg_value_ref('folder_list');
-
-                       $listbox_show_unseen = 
$GLOBALS['phpgw']->msg->get_isset_pref('newmsg_combobox', $acctnum);
-
-                       for ($i=0; $i<count($folder_list);$i++)
-                       {
-                               // folder long needs urlencoding ONCE, string 
can NOT be plain and can NOT be urlencoded more once.
-                               $folder_long = 
$GLOBALS['phpgw']->msg->ensure_one_urlencoding($folder_list[$i]['folder_long']);
+                       
$this->tpl->set_var('toolbar_row1_bgcolor',$GLOBALS['phpgw_info']['theme'][$row1_rowcolor_key]);
+                       
$this->tpl->set_var('toolbar_row2_bgcolor',$GLOBALS['phpgw_info']['theme'][$row2_rowcolor_key]);
+                       
$this->tpl->set_var('toolbar_font',$GLOBALS['phpgw_info']['theme']['font']);
+                       $this->tpl->set_var('toolbar_font_size','2');
+                       $this->tpl->set_var('report_this_font_size','1');
+
+                       $this->tpl->set_var('report_this', 
$GLOBALS['phpgw']->msg->report_moved_or_deleted());
+
+                       $icon_theme = 
$GLOBALS['phpgw']->msg->get_pref_value('icon_theme',$acctnum);
+                       $icon_size = 
$GLOBALS['phpgw']->msg->get_pref_value('icon_size',$acctnum);
+                       $svr_image_dir = PHPGW_IMAGES_DIR;
+                       $image_dir = PHPGW_IMAGES;
+
+                       // this is optional
+                       $this->clear_href_vars();
+                       // Create Links for all the buttons
+                       $folders_link = 
$GLOBALS['phpgw']->link('/index.php',array(
+                                                                       
'menuaction' => 'email.uifolder.folder',
+                                                                       // 
going to the folder list page, we only need log into the INBOX folder
+                                                                       
'fldball[folder]' => 'INBOX',
+                                                                       
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum()));
+                       $compose_link = 
$GLOBALS['phpgw']->link('/index.php',array(
+                                                                       
'menuaction' => 'email.uicompose.compose',
+                                                                       // this 
data tells us where to return to after sending a message
+                                                                       
'fldball[folder]' => $GLOBALS['phpgw']->msg->prep_folder_out(),
+                                                                       
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum(),
+                                                                       'sort' 
=> $GLOBALS['phpgw']->msg->get_arg_value('sort'),
+                                                                       'order' 
=> $GLOBALS['phpgw']->msg->get_arg_value('order'),
+                                                                       'start' 
=> $GLOBALS['phpgw']->msg->get_arg_value('start')));
+                       $search_link = $GLOBALS['phpgw']->link('/index.php', 
array(
+                                                                       
'menuaction' => 'email.uisearch.form',
+                                                                       // this 
data tells us what account we are operating in
+                                                                       
'fldball[folder]' => $GLOBALS['phpgw']->msg->prep_folder_out(),
+                                                                       
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum()
+));
+
+                       $filters_link = 
$GLOBALS['phpgw']->link('/index.php',array(
+                                                               'menuaction' => 
'email.uifilters.filters_list',
+                                                               // this data 
tells us what folder and account was last active
+                                                               
'fldball[folder]' => $GLOBALS['phpgw']->msg->prep_folder_out(),
+                                                               
'fldball[acctnum]' => $GLOBALS['phpgw']->msg->get_acctnum()));
+                       $accounts_link = 
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uipreferences.ex_accounts_list');
+                       $email_prefs_link = 
$GLOBALS['phpgw']->link('/index.php',array(
+                                                               'menuaction' => 
'email.uipreferences.preferences',
+                                                               'ex_acctnum' => 
$GLOBALS['phpgw']->msg->get_acctnum()));
+                       // Check to see if mailserver supports folders.
+                       $has_folders = 
$GLOBALS['phpgw']->msg->get_mailsvr_supports_folders();
+                       // Create Buttons
+                       switch 
($GLOBALS['phpgw']->msg->get_pref_value('button_type'))
+                       {
+                               case 'text':
+                                       //Create Compose Button
+                                       $this->set_href_link($compose_link);
+                                       
$this->set_href_clickme(lang('Compose'));
+                                       $this->tpl->set_var('compose_txt_link', 
$this->get_href());
+                                       $this->tpl->set_var('compose_img_link', 
'&nbsp;');
+                                       //Create Search Button
+                                       $this->set_href_link($search_link);
+                                       $this->set_href_clickme(lang('Search'));
+                                       $this->tpl->set_var('search_txt_link', 
$this->get_href());
+                                       $this->tpl->set_var('search_img_link', 
'&nbsp;');
+                                       //Create Filter Button
+                                       $this->set_href_link($filters_link);
+                                       
$this->set_href_clickme(lang('Filters'));
+                                       $this->tpl->set_var('filters_txt_link', 
$this->get_href());
+                                       $this->tpl->set_var('filters_img_link', 
'&nbsp;');
+                                       //Create Accounts Button
+                                       $this->set_href_link($accounts_link);
+                                       
$this->set_href_clickme(lang('Accounts'));
+                                       
$this->tpl->set_var('accounts_txt_link', $this->get_href());
+                                       
$this->tpl->set_var('accounts_img_link', '&nbsp;');
+                                       //Create Settings Button
+                                       $this->set_href_link($email_prefs_link);
+                                       
$this->set_href_clickme(lang('Settings'));
+                                       
$this->tpl->set_var('settings_txt_link', $this->get_href());
+                                       
$this->tpl->set_var('settings_img_link', '&nbsp;');
+                                       //Check for folder support and create 
Folder Button
+                                       if ($has_folders == True)
+                                       {
+                                               
//$this->set_href_clickme($this->img_maketag($image_dir.'/'.$icon_theme.'-folder-'.$icon_size.'.gif',lang('Folders'),'','','0'));
+                                               
//$this->tpl->set_var('folders_img_link', $this->get_href());
+                                               //Create Folder Text Link
+                                               
$this->set_href_link($folders_link);
+                                               
$this->set_href_clickme(lang('Folders'));
+                                               
$this->tpl->set_var('folders_txt_link', $this->get_href());
+                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
+                                       }
+                                       else
+                                       {
+                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
+                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
+                                       }
+                                       break;
+                               case 'image':
+                                       //Create Compose Button
+                                       $this->set_href_link($compose_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/compose-message-'.$icon_size,'_on'),lang('Compose'),'','','0'));
+                                       $this->tpl->set_var('compose_img_link', 
$this->get_href());
+                                       $this->tpl->set_var('compose_txt_link', 
'&nbsp;');
+                                       //Create Search Button
+                                       $this->set_href_link($search_link);
+                                       
//$this->set_href_clickme($this->img_maketag($image_dir.'/'.$icon_theme.'-search-16.gif',lang('Search'),'','','0'));
+                                       // will fix this later when new images 
are made
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/search-'.$icon_size,'_on'),lang('Search'),'','','0'));
+                                       $this->tpl->set_var('search_img_link', 
$this->get_href());
+                                       $this->tpl->set_var('search_txt_link', 
'&nbsp;');
+                                       //Create Filter Button
+                                       $this->set_href_link($filters_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/filters-'.$icon_size,'_on'),lang('Filters'),'','','0'));
+                                       $this->tpl->set_var('filters_img_link', 
$this->get_href());
+                                       $this->tpl->set_var('filters_txt_link', 
'&nbsp;');
+                                       //Create Accounts Button
+                                       $this->set_href_link($accounts_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/accounts-'.$icon_size,'_on'),lang('Accounts'),'','','0'));
+                                       
$this->tpl->set_var('accounts_img_link', $this->get_href());
+                                       
$this->tpl->set_var('accounts_txt_link', '&nbsp;');
+                                       //Create Settings Button
+                                       $this->set_href_link($email_prefs_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/customize-'.$icon_size,'_on'),lang('Settings'),'','','0'));
+                                       
$this->tpl->set_var('settings_img_link', $this->get_href());
+                                       
$this->tpl->set_var('settings_txt_link', '&nbsp;');
+                                       //Check for folder support and create 
Folder Button
+                                       if ($has_folders == True)
+                                       {
+                                               //Create Folder Image Link
+                                               
$this->set_href_link($folders_link);
+                                               
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/folder-'.$icon_size,'_on'),lang('Folders'),'','','0'));
+                                               
$this->tpl->set_var('folders_img_link', $this->get_href());
+                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
+
+                                       }
+                                       else
+                                       {
+                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
+                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
+                                       }
+                                       break;
+                               case 'both':
+                                       //Create Compose Button
+                                       $this->set_href_link($compose_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/compose-message-'.$icon_size,'_on'),lang('Compose'),'','','0'));
+                                       $this->tpl->set_var('compose_img_link', 
$this->get_href());
+                                       $this->set_href_link($compose_link);
+                                       
$this->set_href_clickme(lang('Compose'));
+                                       $this->tpl->set_var('compose_txt_link', 
$this->get_href());
+                                       //Create Search Button
+                                       $this->set_href_link($search_link);
+                                       
//$this->set_href_clickme($this->img_maketag($image_dir.'/'.$icon_theme.'-search-16.gif',lang('Search'),'','','0'));
+                                       // will fix this later when new images 
are made
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/search-'.$icon_size,'_on'),lang('Search'),'','','0'));
+                                       $this->tpl->set_var('search_img_link', 
$this->get_href());
+                                       $this->set_href_link($search_link);
+                                       $this->set_href_clickme(lang('Search'));
+                                       $this->tpl->set_var('search_txt_link', 
$this->get_href());
+                                       //Create Filter Button
+                                       $this->set_href_link($filters_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/filters-'.$icon_size,'_on'),lang('Filters'),'','','0'));
+                                       $this->tpl->set_var('filters_img_link', 
$this->get_href());
+                                       $this->set_href_link($filters_link);
+                                       
$this->set_href_clickme(lang('Filters'));
+                                       $this->tpl->set_var('filters_txt_link', 
$this->get_href());
+                                       //Create Accounts Button
+                                       $this->set_href_link($accounts_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/accounts-'.$icon_size,'_on'),lang('Accounts'),'','','0'));
+                                       
$this->tpl->set_var('accounts_img_link', $this->get_href());
+                                       $this->set_href_link($accounts_link);
+                                       
$this->set_href_clickme(lang('Accounts'));
+                                       
$this->tpl->set_var('accounts_txt_link', $this->get_href());
+                                       //Create Settings Button
+                                       $this->set_href_link($email_prefs_link);
+                                       
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/customize-'.$icon_size,'_on'),lang('Settings'),'','','0'));
+                                       
$this->tpl->set_var('settings_img_link', $this->get_href());
+                                       $this->set_href_link($email_prefs_link);
+                                       
$this->set_href_clickme(lang('Settings'));
+                                       
$this->tpl->set_var('settings_txt_link', $this->get_href());
+                                       //Check for folder support and create 
Folder Button
+                                       if ($has_folders == True)
+                                       {
+                                               //Create Folder Image Link
+                                               
$this->set_href_link($folders_link);
+                                               
$this->set_href_clickme($this->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$icon_theme.'/folder-'.$icon_size,'_on'),lang('Folders'),'','','0'));
+                                               
$this->tpl->set_var('folders_img_link', $this->get_href());
+                                               //Create Folder Text Link
+                                               
$this->set_href_link($folders_link);
+                                               
$this->set_href_clickme(lang('Folders'));
+                                               
$this->tpl->set_var('folders_txt_link', $this->get_href());
+                                       }
+                                       else
+                                       {
+                                               
$this->tpl->set_var('folders_img_link', '&nbsp;');
+                                               
$this->tpl->set_var('folders_txt_link', '&nbsp;');
+                                       }
+                                       break;
+                               }
+                       // WAIT if this is NOT IMAP then we can NOT search
+                       // use the has_folders var from above, it should be a 
good enough indicator
+                       if ($has_folders == False)
+                       {
+                                       $this->tpl->set_var('search_img_link', 
'&nbsp;');
+                                       $this->tpl->set_var('search_txt_link', 
'&nbsp;');
+                       }
+                       // make the 1st row
+                       $this->toolbar_row_one = 
$this->tpl->parse('V_toolbar_row_one','B_toolbar_row_one');
+                       // END TOOL BAR ROW 1
+
+                       // BEGIN TOOL BAR ROW2
+                       // ---- folders switchbox  ----
+                       //<form name="folders_cbox" 
action="/mail/index.php?menuaction=email.uiindex.index" method="post">
+                       if ($has_folders == True)
+                       {
+                               $this->new_form();
+                               $this->set_form_name('folders_cbox');
+                               
$this->set_form_action($GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'));
+                               $this->set_form_method('post');
+                               
$this->tpl->set_var('form_folders_cbox_opentag', $this->get_form());
+                               $this->tpl->set_var('folders_combobox', 
$this->all_folders_combobox());
+                               
$this->tpl->set_var('form_folders_cbox_closetag', $this->form_closetag());
+                       }
+                       else
+                       {
+                               
$this->tpl->set_var('form_folders_cbox_opentag', '');
+                               $this->tpl->set_var('folders_combobox', 
'&nbsp;');
+                               
$this->tpl->set_var('form_folders_cbox_closetag', '');
+                       }
+                       // associated image is still filled from row one
+
+
+                       // ---- account switchbox  ----
+                       // <form name="acctbox" 
action="/mail/index.php?menuaction=email.uiindex.index" method="post">
+                       $this->new_form();
+                       $this->set_form_name('accounts_cbox');
+                       
$this->set_form_action($GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'));
+                       $this->set_form_method('post');
+                       $this->tpl->set_var('form_acctbox_opentag', 
$this->get_form());
+                       $this->tpl->set_var('acctbox_combobox', 
$this->all_accounts_combobox());
+                       // associated image is still filled from row one
+
+                       // show he user a message if this property is filled, 
if empty then output a nbsp for html sanity
+                       if (trim($this->get_toolbar_msg()) != '')
+                       {
+                               $toolbar_report_msg = $this->get_toolbar_msg();
+                       }
+                       else
+                       {
+                               $toolbar_report_msg = '&nbsp;';
+                       }
+                       $this->tpl->set_var('toolbar_report_msg', 
$toolbar_report_msg);
+
+
+                       // make the 2nd row AND the 3rd row
+                       $this->toolbar_row_two = 
$this->tpl->parse('V_toolbar_row_two','B_toolbar_row_two');
+
+                       return $this->toolbar_row_one . $this->toolbar_row_two;
+
+               }
+
+
+               /*!
+               @function all_folders_combobox
+               @abstract high level function, uses functions in mail_msg and 
this class html_widgets to make an acct switchbox
+               UNDER DEVELOPMENT.
+               @param $form_reference (string) this bombobox sets an 
"onChange" event, which will submit the form you put here.
+               Default value is "document.folders_cbox.submit()" where 
"folders_cbox" is the default value
+               for the $form_reference param.
+               @param $is_move_box (boolean) OPTIONAL default is False, use is 
making a Move Messages To combo box,
+               which requires a different cbox name and different first line 
text.
+               @result string representing an HTML listbox widget
+               @author Angles
+               @discussion The first item in this folder combo box tells the 
user to "pick a folder to change to", and has
+               no "value", the value is an empty string, this is more like a 
label than a combobox item.
+               @access private, maybe made public
+               */
+               function 
all_folders_combobox($form_reference='',$is_move_box=False,$skip_fldball='',$first_line_txt='')
+               {
+                       if ($form_reference == '')
+                       {
+                               $form_reference = 'folders_cbox';
+                       }
+                       $acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
+
+                       $this->new_combobox();
+                       if ($is_move_box)
+                       {
+                               // right now ONLY the "Move Message To" combo 
box needs to use this
+                               $this->set_cbox_name('to_fldball_fake_uri');
+                               $this->set_cbox_onChange('do_action(\'move\')');
+                               if ($first_line_txt)
+                               {
+                                       // right now ONLY the Message View page 
"Move This Message To" combo box uses this
+                                       $this->set_cbox_item('', 
$first_line_txt);
+                               }
+                               else
+                               {
+                                       $this->set_cbox_item('', lang('move 
selected messages into'));
+                               }
+                       }
+                       else
+                       {
+                               $this->set_cbox_name('fldball_fake_uri');
+                               // default is "document.folders_cbox.submit()"
+                               
$this->set_cbox_onChange('document.'.$form_reference.'.submit()');
+                               // set_cbox_item(value, text, 
selected(optional, boolean, default false)
+                               $this->set_cbox_item('', lang('switch current 
folder to'));
+                       }
+
+                       // get the actual list of folders we are going to put 
into the combobox
+                       //$folder_list = 
$GLOBALS['phpgw']->msg->get_folder_list();
+                       $folder_list = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list', $acctnum);
+                       //$folder_list =& 
$GLOBALS['phpgw']->msg->get_arg_value_ref('folder_list');
+
+                       $listbox_show_unseen = 
$GLOBALS['phpgw']->msg->get_isset_pref('newmsg_combobox', $acctnum);
+
+                       for ($i=0; $i<count($folder_list);$i++)
+                       {
+                               // folder long needs urlencoding ONCE, string 
can NOT be plain and can NOT be urlencoded more once.
+                               //$folder_long = 
$GLOBALS['phpgw']->msg->ensure_one_urlencoding($folder_list[$i]['folder_long']);
+                               $folder_long = 
$GLOBALS['phpgw']->msg->prep_folder_out($folder_list[$i]['folder_long']);
                                // for display to the user, if this is the 
INBOX, then translate that using lang INBOX
                                if ($folder_list[$i]['folder_short'] == 'INBOX')
                                {
                                    //$folder_short = lang('INBOX');
                                        // try this for common folder related 
lang strings
-                                       //$common_langs = 
$GLOBALS['phpgw']->msg->get_common_langs();
-                                       //$folder_short = 
$common_langs['lang_inbox'];
-                                       // or try this shortcut, it works too
                                        $folder_short = 
$GLOBALS['phpgw']->msg->get_common_langs('lang_inbox');
                                }
                                else
                                {
-                                       // not inINBOX, so use actual folder 
name, no translation for the user is done
+                                       // not inINBOX, so use actual folder 
name, no translation for the user is done
                                        $folder_short = 
$folder_list[$i]['folder_short'];
-                               }
-                               $folder_acctnum = $folder_list[$i]['acctnum'];
-
-                               if ($listbox_show_unseen == True)
-                               {
-                                       $tmp_fldball = array();
-                                       $tmp_fldball['folder'] = $folder_long;
-                                       $tmp_fldball['acctnum'] = 
$folder_acctnum;
-                                       $folder_status = 
$GLOBALS['phpgw']->msg->get_folder_status_info($tmp_fldball);
-                                       $folder_unseen = 
number_format($folder_status['number_new']);
-                                       $tmp_fldball = array();
-                               }
-
-                               // set_cbox_item(value, text, 
selected(optional, boolean, default false)
-                               if ($listbox_show_unseen == True)
-                               {
-                                       
$this->set_cbox_item('&folder='.$folder_long.'&acctnum='.$folder_acctnum, 
$folder_short . ' (' . $folder_unseen . ')');
-                               }
-                               else
-                               {
-                                       
$this->set_cbox_item('&folder='.$folder_long.'&acctnum='.$folder_acctnum, 
$folder_short);
-                               }
-                       }
-                       return $this->get_combobox();
-
-               }
-
-
-               /*!
-               @function all_folders_mega_combobox
-               @abstract high level function, uses functions in mail_msg and 
this class html_widgets to make a listbox for
-               all folders in all accounts.  DEPRECIATED.
-               @param $form_reference (string) this combobox sets an 
"onChange" event, which will submit the form you put here.
+                               }
+                               $folder_acctnum = $folder_list[$i]['acctnum'];
+                               $skip_me = False;
+                               if ($skip_fldball)
+                               {
+                                       // move folder lists usually skip the 
current folder because you can not move to current folder
+                                       if (($skip_fldball['folder'] == 
$folder_long)
+                                       && ($skip_fldball['acctnum'] == 
$acctnum))
+                                       {
+                                               $skip_me = True;
+                                       }
+                               }
+                               if ($skip_me)
+                               {
+                                       continue;
+                               }
+
+                               if ($listbox_show_unseen == True)
+                               {
+                                       $tmp_fldball = array();
+                                       $tmp_fldball['folder'] = $folder_long;
+                                       $tmp_fldball['acctnum'] = 
$folder_acctnum;
+                                       $folder_status = 
$GLOBALS['phpgw']->msg->get_folder_status_info($tmp_fldball);
+                                       $folder_unseen = 
number_format($folder_status['number_new']);
+                                       $tmp_fldball = array();
+                               }
+
+                               // set_cbox_item(value, text, 
selected(optional, boolean, default false)
+                               if ($listbox_show_unseen == True)
+                               {
+                                       
$this->set_cbox_item('&folder='.$folder_long.'&acctnum='.$folder_acctnum, 
$folder_short . ' (' . $folder_unseen . ')');
+                               }
+                               else
+                               {
+                                       
$this->set_cbox_item('&folder='.$folder_long.'&acctnum='.$folder_acctnum, 
$folder_short);
+                               }
+                       }
+                       return $this->get_combobox();
+
+               }
+
+
+               /*!
+               @function all_folders_mega_combobox
+               @abstract high level function, uses functions in mail_msg and 
this class html_widgets to make a listbox for
+               all folders in all accounts.  DEPRECIATED.
+               @param $form_reference (string) this combobox sets an 
"onChange" event, which will submit the form you put here.
                Default value is "document.folders_cbox.submit()" where "" is 
the default value for the $form_reference param.
-               DEPRECIATED in favor of all_folders_megalist.
-               @result string representing an HTML listbox widget
-               @author Angles
-               @discussion ?
-               @access private, maybe made public
-               */
-               function all_folders_mega_combobox_OLD($form_reference='')
-               {
-                               $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,
-                                       'widget_name'           => 
$folder_listbox_name,
-                                       'folder_key_name'       => 'folder',
-                                       'acctnum_key_name'      => 'acctnum',
-                                       'on_change'                     => '',
-                                       'first_line_txt'        => lang('if 
fileto then select destination folder')
-                               );
-                               $folder_listbox = 
$GLOBALS['phpgw']->msg->folders_mega_listbox($feed_args);
-               }
-
-               /*!
-               @function new_all_folders_megalist
-               @abstract Resets all Properties all_folders_megalist
-               @discussion Delphi style OOP property GetSet functions are 
used, this resets them all.
-               @author Angles
-               */
-               function new_all_folders_megalist()
-               {
-                               $this->F_megalist_form_reference = '';
-                               // this is the only think that actually needs a 
value
-                               $this->F_megalist_widget_name = 'not_provided';
-                               $this->F_megalist_preselected_fldball = '';
-                               $this->F_megalist_skip_fldball = '';
-                               // the first item can be used to display 
instructional text to the user
-                               $this->F_megalist_first_item_text = '';
-               }
-
-               /*!
-               @function prop_megalist_form_reference
-               @abstract Property function form_reference for 
folders_mega_listbox, form_reference is used in onChange JS.
-               @discussion Delphi style OOP property GetSet function.
-               @author Angles
-               */
-               function prop_megalist_form_reference($form_reference='')
-               {
-                       if ($form_reference)
-                       {
-                               $this->F_megalist_form_reference = 
$form_reference;
-                       }
-                       return $this->F_megalist_form_reference;
-               }
-
-               /*!
-               @function prop__megalist_widget_name
-               @abstract Property function widget name for folders_mega_listbox
-               @discussion Delphi style OOP property GetSet function.
-               @author Angles
-               */
-               function prop_megalist_widget_name($widget_name='')
-               {
-                       if ($widget_name)
-                       {
-                               $this->F_megalist_widget_name = $widget_name;
-                       }
-                       return $this->F_megalist_widget_name;
-               }
-
-               /*!
-               @function prop_megalist_preselected_fldball
-               @abstract Property function preselected folder (in fldball 
form) for folders_mega_listbox
-               @discussion Delphi style OOP property GetSet function.
-               @author Angles
-               */
-               function prop_megalist_preselected_fldball($fldball='')
-               {
-                       if ((isset($fldball))
-                       && ($fldball['folder'] != '')
-                       && ((string)$fldball['acctnum'] != ''))
-                       {
-                               $this->F_megalist_preselected_fldball = 
$fldball;
-                       }
-                       return $this->F_megalist_preselected_fldball;
-               }
-
-               /*!
-               @function prop_megalist_skip_fldball
-               @abstract Property function folder (in fldball form) to NOT 
show in the folders_mega_listbox
-               @discussion Delphi style OOP property GetSet function.
-               @author Angles
-               */
-               function prop_megalist_skip_fldball($fldball='')
-               {
-                       if ((isset($fldball))
-                       && ($fldball['folder'] != '')
-                       && ((string)$fldball['acctnum'] != ''))
-                       {
-                               $this->F_megalist_skip_fldball = $fldball;
-                       }
-                       return $this->F_megalist_skip_fldball;
-               }
-
-               /*!
-               @function prop__megalist_widget_name
-               @abstract Property function for folders_mega_listbox, the first 
item can be used to display instructional text to the user
-               @discussion Delphi style OOP property GetSet function.
-               @author Angles
-               */
-               function prop_megalist_first_item_text($first_item_text='')
-               {
-                       if ($first_item_text)
-                       {
-                               $this->F_megalist_first_item_text = 
$first_item_text;
-                       }
-                       return $this->F_megalist_first_item_text;
-               }
-
-               /*!
-               @function all_folders_megalist
-               @abstract All accounts All Folders in a html listbox
-               @discussion UNDER DEVELOPMENT, right now the leading candidate 
to be THE folder list
-               function, but now sure yet.
-               @author Angles
-               */
-               function all_folders_megalist()
-               {
-                       $debug_mega_listbox = 0;
-                       //$debug_mega_listbox = 3;
-
-                       if ($debug_mega_listbox > 0) { echo 
'folders_mega_listbox('.__LINE__.'): ENTERING<br>'; }
-
-                       $this->new_combobox();
-                       $this->set_cbox_name($this->F_megalist_widget_name);
-
-                       // there is NO ON change right now, this is currently 
used on the filters page, we do not need action onChange there
-                       // default is "document.mega_folders_cbox.submit()"
-                       
//$this->set_cbox_onChange('document.'.$form_reference.'.submit()');
-
-                       // set_cbox_item(value, text, selected(optional, 
boolean, default false)
-                       if ($this->F_megalist_first_item_text)
-                       {
-                               $this->set_cbox_item('', 
$this->F_megalist_first_item_text);
-                       }
-
-                       // we need the loop to include the default account AS 
WELL AS the extra accounts
-                       for ($x=0; $x < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $x++)
-                       {
-                               $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$x]['acctnum'];
-                               $this_status = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$x]['status'];
-                               // do not enable this yet, maybe later
-                               //$listbox_show_unseen = 
$GLOBALS['phpgw']->msg->get_isset_pref('newmsg_combobox', $acctnum);
-                               $listbox_show_unseen = False;
-                               if ($this_status != 'enabled')
-                               {
-                                       // Do Nothing, This account is not in 
use
-                                       if ($debug_mega_listbox > 1) { echo 
'folders_mega_listbox('.__LINE__.'): $this_acctnum ['.$this_acctnum.'] is not 
in use, so skip folderlist<br>'; }
-                               }
-                               else
-                               {
-                                       $folder_list = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list', $this_acctnum);
-                                       if ($debug_mega_listbox > 1) { echo 
'folders_mega_listbox('.__LINE__.'): $this_acctnum ['.$this_acctnum.'] IS 
enabled, got folder list<br>'; }
-                                       if ($debug_mega_listbox > 2) { echo 
'folders_mega_listbox('.__LINE__.'): $folder_list for $this_acctnum 
['.$this_acctnum.'] DUMP<pre>'; print_r($folder_list); echo '</pre>'; }
-
-                                       // iterate thru the folder list for 
this acctnum
-                                       for ($i=0; $i<count($folder_list);$i++)
-                                       {
-                                               $folder_long = 
$folder_list[$i]['folder_long'];
-                                               $folder_long_preped_out = 
$GLOBALS['phpgw']->msg->prep_folder_out($folder_long);
-                                               $folder_short = 
$folder_list[$i]['folder_short'];
-                                               // yes we need $folder_acctnum 
to help make the "folder ball", yes I know it *should* be the same as 
$this_acctnum
-                                               $folder_acctnum = 
$folder_list[$i]['acctnum'];
-
-                                               // this logic determines we 
should not include a certain folder in the combobox list
-                                               if 
(($this->F_megalist_skip_fldball)
-                                               && ($folder_long_preped_out == 
$this->F_megalist_skip_fldball['folder'])
-                                               && ($folder_acctnum == 
$this->F_megalist_skip_fldball['acctnum']))
-                                               {
-                                                       // Do Nothing, this 
folder should not be included
-                                                       if ($debug_mega_listbox 
> 1) { echo 'folders_mega_listbox('.__LINE__.'): skipping 
$this->F_megalist_skip_fldball 
['.htmlspecialchars(serialize($this->F_megalist_skip_fldball)).'] has been 
matched<br>'; }
-                                               }
-                                               else
-                                               {
-                                                       // this logic 
determines if the combobox should be initialized with certain folder already 
selected
-                                                       // we use "folder 
short" as the comparator because that way at least we know we are comparing 
syntatic-ally similar items
-                                                       if 
(($this->F_megalist_preselected_fldball)
-                                                       && 
($folder_long_preped_out == $this->F_megalist_preselected_fldball['folder'])
-                                                       && ($folder_acctnum == 
$this->F_megalist_preselected_fldball['acctnum']))
-                                                       {
-                                                               $preselected = 
True;
-                                                       }
-                                                       else
-                                                       {
-                                                               $preselected = 
False;
-                                                       }
-
-                                                       if 
($listbox_show_unseen == True)
-                                                       {
-                                                               $tmp_fldball = 
array();
-                                                               
$tmp_fldball['folder'] = $folder_long;
-                                                               
$tmp_fldball['acctnum'] = $folder_acctnum;
-                                                               $folder_status 
= $GLOBALS['phpgw']->msg->get_folder_status_info($tmp_fldball);
-                                                               $folder_unseen 
= number_format($folder_status['number_new']);
-                                                               // complete the 
text here so we do not need another if ... then below
-                                                               $folder_unseen 
= ' ('. $folder_unseen.')';
-                                                               $tmp_fldball = 
array();
-                                                       }
-                                                       else
-                                                       {
-                                                               $folder_unseen 
= '';
-                                                       }
-
-                                                       $option_value = 
'&folder='.$folder_long_preped_out.'&acctnum='.$folder_acctnum;
-                                                       //$option_value =       
'&folder='.$folder_long.'&acctnum='.$folder_acctnum;
-                                                       // if $folder_unseen 
has anything it gets added to the string here
-                                                       $text_blurb = 
'['.$folder_acctnum.'] '.$folder_short.$folder_unseen;
-
-                                                       // set_cbox_item(value, 
text, selected(optional, boolean, default false)
-                                                       
$this->set_cbox_item($option_value, $text_blurb, $preselected);
-                                               }
-                                       }
-                               }
-                       }
-                       if ($debug_mega_listbox > 0) { echo 
'folders_mega_listbox('.__LINE__.'): LEAVING<br>'; }
-                       return $this->get_combobox();
-               }
-
-
-
-               /*!
-               @function all_accounts_combobox
-               @abstract UNDER DEVELOPMENT
-               @author Angles
-               @discussion the "values" are in the form of a URI request 
string, since a combobox can
-               only submit a single string as its value. This way we put alot 
of information if the form
-               of the URI request and use php function "parse_str" to 
"recover" all this data on the submit.
-               Accounts have a "status" associated with them, can be 
"enabled", "disabled", or "empty".
-               In this combobox we show "enabled" and "disabled" accounts, not 
"empty" accounts.
-               NOTE "disabled" really has no use, and "empty" I am not sure if 
that is ever used anywhere at all.
-               Also note that a "disabled" account should never be 
"pre-selected" in this combobox, which seems logical.
-               Almost always there is an email account that can be considered 
"active" because the user is viewing its
-               data (folders, messages, its preferences) or if the user is 
composing a message then the last "active"
-               account is considered the account which this mail will be 
"from". Therefor, generally all mail activity
-               have an account that it applies to. So when this combobox comes 
across the account that is currently
-               "active", that account will be "pre-selected" in the combobox. 
This serves two purposes, ONE, the user
-               can not swicth to an account that is currently the "active" 
account, the user can only switch do
-               a different account, and TWO, this gives the user visual 
feedback about which account is currently
-               "active", on some pages, such as the compose page, this remines 
the user who the mail will be "from",
-               i.e. which account sent the mail. In making this thing we 
iterate thru the "extra_and_default_acounts list",
-               which is an numbered array whose members are structured array 
data describing the account.
-               */
-               function all_accounts_combobox()
-               {
-                       // $GLOBALS['phpgw']->msg->ex_accounts_count
-                       // $GLOBALS['phpgw']->msg->extra_accounts
-
-                       //$debug_widget = True;
-                       $debug_widget = False;
-                       $acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
-
-                       $this->new_combobox();
-                       $this->set_cbox_name('fldball_fake_uri');
-                       
$this->set_cbox_onChange('document.accounts_cbox.submit()');
-
-                       for ($i=0; $i < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $i++)
-                       {
-                               $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['acctnum'];
-                               $this_acct_status = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['status'];
-                               $this_acct_fullname = 
$GLOBALS['phpgw']->msg->get_pref_value('fullname', $this_acctnum);
-
-                               if ($this_acct_status == 'disabled')
-                               {
-                                       // set_cbox_item(value, text, 
selected(optional, boolean, default false)
-                                       
$this->set_cbox_item('&folder=INBOX&acctnum=0',
-                                               lang('account').' 
['.$this_acctnum.'] '.lang('disabled'));
-                               }
-                               elseif ($this_acct_status == 'enabled')
-                               {
-                                       // set_cbox_item(value, text, 
selected(optional, boolean, default false)
-                                       if 
($GLOBALS['phpgw']->msg->get_pref_value('account_name', $this_acctnum))
-                                       {
-                                               
$this->set_cbox_item('&folder=INBOX&acctnum='.$this_acctnum,
-                                               
$GLOBALS['phpgw']->msg->get_pref_value('account_name', $this_acctnum),
-                                               ((string)$acctnum == 
(string)$this_acctnum));
-
-                                       } else {
-                                               
$this->set_cbox_item('&folder=INBOX&acctnum='.$this_acctnum,
-                                                       lang('account').' 
'.$this_acctnum.':  '.$this_acct_fullname,
-                                                       ((string)$acctnum == 
(string)$this_acctnum));
-                                       }
-                               }
-                       }
-                       return $this->get_combobox();
-               }
-
-               /*!
-               @function auto_refresh
-               @example I know of 3 ways to get a page to reload, 2 of those 
ways are pretty much the same
-               1. the http header
-                       Refresh: 5;
-               2. the META http-equiv
-                       &lt;META HTTP-EQUIV="Refresh" CONTENT="60"&gt>
-               both 1 and 2 have the same effect as hitting the "reload" 
button, which in *many* browsers will
-               force a re-download of all the images on the page, i.e. the 
browser will NOT use the cached images
-               3. java script combo of "window.setTimeout" with 
"window.location"
-                       
window.setTimeout('window.location="http://example.com/phpgw/email/index.php";; 
',1800000);
-               method 3 is the only one I know of that will use the images 
from the cache.
-               also, 3 takes a reload value in miliseconds, so a value of 
180000 is really 3 minutes
-               ALSO, use if..then code to only auto-refresh certain pages, 
such as email/index.php
-               @author Angles
-               */
-               function auto_refresh($reload_me='', $feed_refresh_ms='')
-               {
-                       if 
($GLOBALS['phpgw']->msg->get_isset_pref('refresh_ms'))
-                       {
-                               $pref_refresh_ms = 
$GLOBALS['phpgw']->msg->get_pref_value('refresh_ms');
-                       }
-                       else
-                       {
-                               $pref_refresh_ms = '';
-                       }
-                       // which do we use
-                       $refresh_ms = '';
-                       if ($feed_refresh_ms)
-                       {
-                               $refresh_ms = $feed_refresh_ms;
-                       }
-                       elseif ($pref_refresh_ms)
-                       {
-                               $refresh_ms = $pref_refresh_ms;
-                       }
-                       else
-                       {
-                               // user pref is NOT to refresh AND we were not 
given another value to use
-                               // LEAVING
-                               return '';
-                       }
-
-                       /*
-                       // if NOT supplied a "reload_me" URI then we must 
figure one out
-                       if ($reload_me == '')
-                       {
-                               if ((stristr($GLOBALS['PHP_SELF'], 
'/email/index.php'))
-                               ||  (   
((isset($GLOBALS['phpgw']->msg->ref_GET['menuaction']))
-                                       && 
(stristr($GLOBALS['phpgw']->msg->ref_GET['menuaction'], 'email.uiindex.index')))
-                                       )
-                               )
-                               {
-                                       if 
((isset($GLOBALS['phpgw_info']['flags']['email_refresh_uri']))
-                                       && 
($GLOBALS['phpgw_info']['flags']['email_refresh_uri'] != ''))
-                                       {
-                                               $reload_me = 
$GLOBALS['phpgw']->link('/index.php',$GLOBALS['phpgw_info']['flags']['email_refresh_uri']);
-                                       }
-                                       else
-                                       {
-                                               $reload_me = 
$GLOBALS['phpgw']->link('/email/index.php');
-                                       }
-                               }
-                               elseif 
(eregi("^.*\/home\.php.*$",$GLOBALS['PHP_SELF']))
-                               {
-                                       $reload_me = 
$GLOBALS['phpgw']->link('/home.php');
-                               }
-                       }
-                       */
-
-                       // reality check
-                       $int_refresh_ms = (int)$refresh_ms;
-                       if ($int_refresh_ms < 60000)
-                       {
-                               // less than 1 minute us BS, use a fallback 
value of 4 minutes
-                               $refresh_ms = 240000;
-                       }
-
-                       // make the $refresh_ms into a string
-                       $refresh_ms = (string)$refresh_ms;
-                       // now if we have a reload_me URI, then
-                       // make the JS command string if necessary
-                       if (($reload_me != '')
-                       && ($refresh_ms != ''))
-                       {
-                               $reload_me_full = 
$GLOBALS['phpgw']->link('/index.php',$reload_me);
-                               // set refresh time in miliseconds  (1000 = 1 
sec)  (180000 = 180 sec = 3 minutes)
-                               //  ( 240000 = 240 sec = 4 min)   (300000 = 5 
min)   (600000 = 10 min)
-                               //$refresh_ms = '240000';
-                               $reload_js =
-                                        '<script language="javascript">'."\r\n"
-                                       
.'window.setTimeout('."'".'window.location="'
-                                       .$reload_me_full.'"; 
'."'".','.$refresh_ms.');'."\r\n"
-                                       .'</script>'."\r\n";
-                       }
-                       else
-                       {
-                               // we have no URI to reload
-                               $reload_js = '';
-                       }
-                       // returning  $reload_js which may be '' if we did not 
have enough info
-                       return $reload_js;
-               }
+               DEPRECIATED in favor of all_folders_megalist.
+               @result string representing an HTML listbox widget
+               @author Angles
+               @discussion ?
+               @access private, maybe made public
+               */
+               function all_folders_mega_combobox_OLD($form_reference='')
+               {
+                               $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,
+                                       'widget_name'           => 
$folder_listbox_name,
+                                       'folder_key_name'       => 'folder',
+                                       'acctnum_key_name'      => 'acctnum',
+                                       'on_change'                     => '',
+                                       'first_line_txt'        => lang('if 
fileto then select destination folder')
+                               );
+                               $folder_listbox = 
$GLOBALS['phpgw']->msg->folders_mega_listbox($feed_args);
+               }
+
+               /*!
+               @function new_all_folders_megalist
+               @abstract Resets all Properties all_folders_megalist
+               @discussion Delphi style OOP property GetSet functions are 
used, this resets them all.
+               @author Angles
+               */
+               function new_all_folders_megalist()
+               {
+                               $this->F_megalist_form_reference = '';
+                               // this is the only think that actually needs a 
value
+                               $this->F_megalist_widget_name = 'not_provided';
+                               $this->F_megalist_preselected_fldball = '';
+                               $this->F_megalist_skip_fldball = '';
+                               // the first item can be used to display 
instructional text to the user
+                               $this->F_megalist_first_item_text = '';
+               }
+
+               /*!
+               @function prop_megalist_form_reference
+               @abstract Property function form_reference for 
folders_mega_listbox, form_reference is used in onChange JS.
+               @discussion Delphi style OOP property GetSet function.
+               @author Angles
+               */
+               function prop_megalist_form_reference($form_reference='')
+               {
+                       if ($form_reference)
+                       {
+                               $this->F_megalist_form_reference = 
$form_reference;
+                       }
+                       return $this->F_megalist_form_reference;
+               }
+
+               /*!
+               @function prop__megalist_widget_name
+               @abstract Property function widget name for folders_mega_listbox
+               @discussion Delphi style OOP property GetSet function.
+               @author Angles
+               */
+               function prop_megalist_widget_name($widget_name='')
+               {
+                       if ($widget_name)
+                       {
+                               $this->F_megalist_widget_name = $widget_name;
+                       }
+                       return $this->F_megalist_widget_name;
+               }
+
+               /*!
+               @function prop_megalist_preselected_fldball
+               @abstract Property function preselected folder (in fldball 
form) for folders_mega_listbox
+               @discussion Delphi style OOP property GetSet function.
+               @author Angles
+               */
+               function prop_megalist_preselected_fldball($fldball='')
+               {
+                       if ((isset($fldball))
+                       && ($fldball['folder'] != '')
+                       && ((string)$fldball['acctnum'] != ''))
+                       {
+                               $this->F_megalist_preselected_fldball = 
$fldball;
+                       }
+                       return $this->F_megalist_preselected_fldball;
+               }
+
+               /*!
+               @function prop_megalist_skip_fldball
+               @abstract Property function folder (in fldball form) to NOT 
show in the folders_mega_listbox
+               @discussion Delphi style OOP property GetSet function.
+               @author Angles
+               */
+               function prop_megalist_skip_fldball($fldball='')
+               {
+                       if ((isset($fldball))
+                       && ($fldball['folder'] != '')
+                       && ((string)$fldball['acctnum'] != ''))
+                       {
+                               $this->F_megalist_skip_fldball = $fldball;
+                       }
+                       return $this->F_megalist_skip_fldball;
+               }
+
+               /*!
+               @function prop__megalist_widget_name
+               @abstract Property function for folders_mega_listbox, the first 
item can be used to display instructional text to the user
+               @discussion Delphi style OOP property GetSet function.
+               @author Angles
+               */
+               function prop_megalist_first_item_text($first_item_text='')
+               {
+                       if ($first_item_text)
+                       {
+                               $this->F_megalist_first_item_text = 
$first_item_text;
+                       }
+                       return $this->F_megalist_first_item_text;
+               }
+
+               /*!
+               @function all_folders_megalist
+               @abstract All accounts All Folders in a html listbox
+               @discussion UNDER DEVELOPMENT, right now the leading candidate 
to be THE folder list
+               function, but now sure yet.
+               @author Angles
+               */
+               function all_folders_megalist()
+               {
+                       $debug_mega_listbox = 0;
+                       //$debug_mega_listbox = 3;
+
+                       if ($debug_mega_listbox > 0) { echo 
'folders_mega_listbox('.__LINE__.'): ENTERING<br>'; }
+
+                       $this->new_combobox();
+                       $this->set_cbox_name($this->F_megalist_widget_name);
+
+                       // there is NO ON change right now, this is currently 
used on the filters page, we do not need action onChange there
+                       // default is "document.mega_folders_cbox.submit()"
+                       
//$this->set_cbox_onChange('document.'.$form_reference.'.submit()');
+
+                       // set_cbox_item(value, text, selected(optional, 
boolean, default false)
+                       if ($this->F_megalist_first_item_text)
+                       {
+                               $this->set_cbox_item('', 
$this->F_megalist_first_item_text);
+                       }
+
+                       // we need the loop to include the default account AS 
WELL AS the extra accounts
+                       for ($x=0; $x < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $x++)
+                       {
+                               $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$x]['acctnum'];
+                               $this_status = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$x]['status'];
+                               // do not enable this yet, maybe later
+                               //$listbox_show_unseen = 
$GLOBALS['phpgw']->msg->get_isset_pref('newmsg_combobox', $acctnum);
+                               $listbox_show_unseen = False;
+                               if ($this_status != 'enabled')
+                               {
+                                       // Do Nothing, This account is not in 
use
+                                       if ($debug_mega_listbox > 1) { echo 
'folders_mega_listbox('.__LINE__.'): $this_acctnum ['.$this_acctnum.'] is not 
in use, so skip folderlist<br>'; }
+                               }
+                               else
+                               {
+                                       $folder_list = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list', $this_acctnum);
+                                       if ($debug_mega_listbox > 1) { echo 
'folders_mega_listbox('.__LINE__.'): $this_acctnum ['.$this_acctnum.'] IS 
enabled, got folder list<br>'; }
+                                       if ($debug_mega_listbox > 2) { echo 
'folders_mega_listbox('.__LINE__.'): $folder_list for $this_acctnum 
['.$this_acctnum.'] DUMP<pre>'; print_r($folder_list); echo '</pre>'; }
+
+                                       // iterate thru the folder list for 
this acctnum
+                                       for ($i=0; $i<count($folder_list);$i++)
+                                       {
+                                               $folder_long = 
$folder_list[$i]['folder_long'];
+                                               $folder_long_preped_out = 
$GLOBALS['phpgw']->msg->prep_folder_out($folder_long);
+                                               $folder_short = 
$folder_list[$i]['folder_short'];
+                                               // yes we need $folder_acctnum 
to help make the "folder ball", yes I know it *should* be the same as 
$this_acctnum
+                                               $folder_acctnum = 
$folder_list[$i]['acctnum'];
+
+                                               // this logic determines we 
should not include a certain folder in the combobox list
+                                               if 
(($this->F_megalist_skip_fldball)
+                                               && ($folder_long_preped_out == 
$this->F_megalist_skip_fldball['folder'])
+                                               && ($folder_acctnum == 
$this->F_megalist_skip_fldball['acctnum']))
+                                               {
+                                                       // Do Nothing, this 
folder should not be included
+                                                       if ($debug_mega_listbox 
> 1) { echo 'folders_mega_listbox('.__LINE__.'): skipping 
$this->F_megalist_skip_fldball 
['.htmlspecialchars(serialize($this->F_megalist_skip_fldball)).'] has been 
matched<br>'; }
+                                               }
+                                               else
+                                               {
+                                                       // this logic 
determines if the combobox should be initialized with certain folder already 
selected
+                                                       // we use "folder 
short" as the comparator because that way at least we know we are comparing 
syntatic-ally similar items
+                                                       if 
(($this->F_megalist_preselected_fldball)
+                                                       && 
($folder_long_preped_out == $this->F_megalist_preselected_fldball['folder'])
+                                                       && ($folder_acctnum == 
$this->F_megalist_preselected_fldball['acctnum']))
+                                                       {
+                                                               $preselected = 
True;
+                                                       }
+                                                       else
+                                                       {
+                                                               $preselected = 
False;
+                                                       }
+
+                                                       if 
($listbox_show_unseen == True)
+                                                       {
+                                                               $tmp_fldball = 
array();
+                                                               
$tmp_fldball['folder'] = $folder_long;
+                                                               
$tmp_fldball['acctnum'] = $folder_acctnum;
+                                                               $folder_status 
= $GLOBALS['phpgw']->msg->get_folder_status_info($tmp_fldball);
+                                                               $folder_unseen 
= number_format($folder_status['number_new']);
+                                                               // complete the 
text here so we do not need another if ... then below
+                                                               $folder_unseen 
= ' ('. $folder_unseen.')';
+                                                               $tmp_fldball = 
array();
+                                                       }
+                                                       else
+                                                       {
+                                                               $folder_unseen 
= '';
+                                                       }
+
+                                                       $option_value = 
'&folder='.$folder_long_preped_out.'&acctnum='.$folder_acctnum;
+                                                       //$option_value =       
'&folder='.$folder_long.'&acctnum='.$folder_acctnum;
+                                                       // if $folder_unseen 
has anything it gets added to the string here
+                                                       $text_blurb = 
'['.$folder_acctnum.'] '.$folder_short.$folder_unseen;
+
+                                                       // set_cbox_item(value, 
text, selected(optional, boolean, default false)
+                                                       
$this->set_cbox_item($option_value, $text_blurb, $preselected);
+                                               }
+                                       }
+                               }
+                       }
+                       if ($debug_mega_listbox > 0) { echo 
'folders_mega_listbox('.__LINE__.'): LEAVING<br>'; }
+                       return $this->get_combobox();
+               }
+
+
+
+               /*!
+               @function all_accounts_combobox
+               @abstract UNDER DEVELOPMENT
+               @author Angles
+               @discussion the "values" are in the form of a URI request 
string, since a combobox can
+               only submit a single string as its value. This way we put alot 
of information if the form
+               of the URI request and use php function "parse_str" to 
"recover" all this data on the submit.
+               Accounts have a "status" associated with them, can be 
"enabled", "disabled", or "empty".
+               In this combobox we show "enabled" and "disabled" accounts, not 
"empty" accounts.
+               NOTE "disabled" really has no use, and "empty" I am not sure if 
that is ever used anywhere at all.
+               Also note that a "disabled" account should never be 
"pre-selected" in this combobox, which seems logical.
+               Almost always there is an email account that can be considered 
"active" because the user is viewing its
+               data (folders, messages, its preferences) or if the user is 
composing a message then the last "active"
+               account is considered the account which this mail will be 
"from". Therefor, generally all mail activity
+               have an account that it applies to. So when this combobox comes 
across the account that is currently
+               "active", that account will be "pre-selected" in the combobox. 
This serves two purposes, ONE, the user
+               can not swicth to an account that is currently the "active" 
account, the user can only switch do
+               a different account, and TWO, this gives the user visual 
feedback about which account is currently
+               "active", on some pages, such as the compose page, this remines 
the user who the mail will be "from",
+               i.e. which account sent the mail. In making this thing we 
iterate thru the "extra_and_default_acounts list",
+               which is an numbered array whose members are structured array 
data describing the account.
+               */
+               function all_accounts_combobox()
+               {
+                       // $GLOBALS['phpgw']->msg->ex_accounts_count
+                       // $GLOBALS['phpgw']->msg->extra_accounts
+
+                       //$debug_widget = True;
+                       $debug_widget = False;
+                       $acctnum = $GLOBALS['phpgw']->msg->get_acctnum();
+
+                       $this->new_combobox();
+                       $this->set_cbox_name('fldball_fake_uri');
+                       
$this->set_cbox_onChange('document.accounts_cbox.submit()');
+
+                       for ($i=0; $i < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $i++)
+                       {
+                               $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['acctnum'];
+                               $this_acct_status = 
$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['status'];
+                               $this_acct_fullname = 
$GLOBALS['phpgw']->msg->get_pref_value('fullname', $this_acctnum);
+
+                               if ($this_acct_status == 'disabled')
+                               {
+                                       // set_cbox_item(value, text, 
selected(optional, boolean, default false)
+                                       
$this->set_cbox_item('&folder=INBOX&acctnum=0',
+                                               lang('account').' 
['.$this_acctnum.'] '.lang('disabled'));
+                               }
+                               elseif ($this_acct_status == 'enabled')
+                               {
+                                       // set_cbox_item(value, text, 
selected(optional, boolean, default false)
+                                       if 
($GLOBALS['phpgw']->msg->get_pref_value('account_name', $this_acctnum))
+                                       {
+                                               
$this->set_cbox_item('&folder=INBOX&acctnum='.$this_acctnum,
+                                               
$GLOBALS['phpgw']->msg->get_pref_value('account_name', $this_acctnum),
+                                               ((string)$acctnum == 
(string)$this_acctnum));
+
+                                       } else {
+                                               
$this->set_cbox_item('&folder=INBOX&acctnum='.$this_acctnum,
+                                                       lang('account').' 
'.$this_acctnum.':  '.$this_acct_fullname,
+                                                       ((string)$acctnum == 
(string)$this_acctnum));
+                                       }
+                               }
+                       }
+                       return $this->get_combobox();
+               }
+
+               /*!
+               @function auto_refresh
+               @example I know of 3 ways to get a page to reload, 2 of those 
ways are pretty much the same
+               1. the http header
+                       Refresh: 5;
+               2. the META http-equiv
+                       &lt;META HTTP-EQUIV="Refresh" CONTENT="60"&gt>
+               both 1 and 2 have the same effect as hitting the "reload" 
button, which in *many* browsers will
+               force a re-download of all the images on the page, i.e. the 
browser will NOT use the cached images
+               3. java script combo of "window.setTimeout" with 
"window.location"
+                       
window.setTimeout('window.location="http://example.com/phpgw/email/index.php";; 
',1800000);
+               method 3 is the only one I know of that will use the images 
from the cache.
+               also, 3 takes a reload value in miliseconds, so a value of 
180000 is really 3 minutes
+               ALSO, use if..then code to only auto-refresh certain pages, 
such as email/index.php
+               @author Angles
+               */
+               function auto_refresh($reload_me='', $feed_refresh_ms='')
+               {
+                       if 
($GLOBALS['phpgw']->msg->get_isset_pref('refresh_ms'))
+                       {
+                               $pref_refresh_ms = 
$GLOBALS['phpgw']->msg->get_pref_value('refresh_ms');
+                       }
+                       else
+                       {
+                               $pref_refresh_ms = '';
+                       }
+                       // which do we use
+                       $refresh_ms = '';
+                       if ($feed_refresh_ms)
+                       {
+                               $refresh_ms = $feed_refresh_ms;
+                       }
+                       elseif ($pref_refresh_ms)
+                       {
+                               $refresh_ms = $pref_refresh_ms;
+                       }
+                       else
+                       {
+                               // user pref is NOT to refresh AND we were not 
given another value to use
+                               // LEAVING
+                               return '';
+                       }
+
+                       /*
+                       // if NOT supplied a "reload_me" URI then we must 
figure one out
+                       if ($reload_me == '')
+                       {
+                               if ((stristr($GLOBALS['PHP_SELF'], 
'/email/index.php'))
+                               ||  (   
((isset($GLOBALS['phpgw']->msg->ref_GET['menuaction']))
+                                       && 
(stristr($GLOBALS['phpgw']->msg->ref_GET['menuaction'], 'email.uiindex.index')))
+                                       )
+                               )
+                               {
+                                       if 
((isset($GLOBALS['phpgw_info']['flags']['email_refresh_uri']))
+                                       && 
($GLOBALS['phpgw_info']['flags']['email_refresh_uri'] != ''))
+                                       {
+                                               $reload_me = 
$GLOBALS['phpgw']->link('/index.php',$GLOBALS['phpgw_info']['flags']['email_refresh_uri']);
+                                       }
+                                       else
+                                       {
+                                               $reload_me = 
$GLOBALS['phpgw']->link('/email/index.php');
+                                       }
+                               }
+                               elseif 
(eregi("^.*\/home\.php.*$",$GLOBALS['PHP_SELF']))
+                               {
+                                       $reload_me = 
$GLOBALS['phpgw']->link('/home.php');
+                               }
+                       }
+                       */
+
+                       // reality check
+                       $int_refresh_ms = (int)$refresh_ms;
+                       if ($int_refresh_ms < 60000)
+                       {
+                               // less than 1 minute us BS, use a fallback 
value of 4 minutes
+                               $refresh_ms = 240000;
+                       }
+
+                       // make the $refresh_ms into a string
+                       $refresh_ms = (string)$refresh_ms;
+                       // now if we have a reload_me URI, then
+                       // make the JS command string if necessary
+                       if (($reload_me != '')
+                       && ($refresh_ms != ''))
+                       {
+                               $reload_me_full = 
$GLOBALS['phpgw']->link('/index.php',$reload_me);
+                               // set refresh time in miliseconds  (1000 = 1 
sec)  (180000 = 180 sec = 3 minutes)
+                               //  ( 240000 = 240 sec = 4 min)   (300000 = 5 
min)   (600000 = 10 min)
+                               //$refresh_ms = '240000';
+                               $reload_js =
+                                        '<script language="javascript">'."\r\n"
+                                       
.'window.setTimeout('."'".'window.location="'
+                                       .$reload_me_full.'"; 
'."'".','.$refresh_ms.');'."\r\n"
+                                       .'</script>'."\r\n";
+                       }
+                       else
+                       {
+                               // we have no URI to reload
+                               $reload_js = '';
+                       }
+                       // returning  $reload_js which may be '' if we did not 
have enough info
+                       return $reload_js;
+               }

                
/**************************************************************************\
                *       GENERIC ERROR REPORT
@@ -1749,5 +1819,99 @@
                        }
                }

-       }
-?>
+               /*!
+               @function get_geek_bar
+               @abstract TESTING goes on bottom of index page
+               @author Angles
+               */
+               function get_geek_bar()
+               {
+                       $row_on = $GLOBALS['phpgw_info']['theme']['row_on'];
+                       $this_server_type = 
$GLOBALS['phpgw']->msg->get_pref_value('mail_server_type');
+                       if (extension_loaded('imap') && 
function_exists('imap_open'))
+                       {
+                               $library_usage = 'builtin';
+                       }
+                       else
+                       {
+                               $library_usage = 'AM sockets';
+                       }
+                       $anglemail_table_exists = 'installed';
+                       if ($GLOBALS['phpgw']->msg->so->so_am_table_exists() == 
False)
+                       {
+                               $anglemail_table_exists = 'NOT 
'.$anglemail_table_exists;
+                       }
+                       $compression = 'NOT available';
+                       //if (function_exists('bzcompress'))
+                       //{
+                       //      $compression = 'bz2';
+                       //}
+                       //else
+                       if (function_exists('gzcompress'))
+                       {
+                               $compression = 'gzip';
+                       }
+                       $spell_available = 'available';
+                       if (function_exists('pspell_check') == False)
+                       {
+                               $spell_available = 'NOT '.$spell_available;
+                       }
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == True)
+                       {
+                               $using_xslt = 'no';
+                       }
+                       else
+                       {
+                               $using_xslt = 'yes';
+                       }
+
+                       // did we connect
+                       $accts_connected = '';
+                       // put together a list of all enabled accounts so we 
will check them for an open stream
+                       for ($i=0; $i < 
count($GLOBALS['phpgw']->msg->extra_and_default_acounts); $i++)
+                       {
+                               if 
($GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['status'] == 'enabled')
+                               {
+                                       $this_acctnum = 
(int)$GLOBALS['phpgw']->msg->extra_and_default_acounts[$i]['acctnum'];
+                                       if 
(($GLOBALS['phpgw']->msg->get_isset_arg('mailsvr_stream', $this_acctnum) == 
True)
+                                       && 
((string)$GLOBALS['phpgw']->msg->get_arg_value('mailsvr_stream', $this_acctnum) 
!= ''))
+                                       {
+                                               $accts_connected .= 
(string)$this_acctnum.',';
+                                       }
+                               }
+                       }
+                       // get rid of trailing , if it exists
+                       if (stristr($accts_connected, ','))
+                       {
+                               $accts_connected = 
substr($accts_connected,0,-1);
+                               $did_connect = 'yes ('.$accts_connected.')';
+
+                       }
+                       else
+                       {
+                               $did_connect = 'no';
+                       }
+
+                       $geek_bar =
+                       '<br>
+                       <table border="0" cellpadding="4" cellspacing="0" 
width="100%" align="center">
+                       <tr bgcolor="'.$row_on.'" class="row_on">
+                               <td width="100%" align="left">'."\r\n"
+                                       //.'<small style="font-size: 10pt;">'
+                                       .'<small style="font-size: xx-small;">'
+                                       .'<font color="brown">GeekBar:</font> '
+                                       .'Server Type: ['.$this_server_type.'] 
-- '
+                                       .'IMAP library: ['.$library_usage.'] -- 
'
+                                       .'AngleMail Table: 
['.$anglemail_table_exists.'] -- '
+                                       .'compression: ['.$compression.'] -- '
+                                       .'spelling: ['.$spell_available.'] -- '
+                                       .'using XSLT: ['.$using_xslt.'] -- '
+                                       .'did connect: ['.$did_connect.'] '
+                                       .'</small>'
+                               ."\r\n"
+                       .'      </td>
+                       </table>';
+                       return $geek_bar;
+               }
+       }
+?>

====================================================
Index: email/inc/class.bopreferences.inc.php
diff -u email/inc/class.bopreferences.inc.php:1.23 
email/inc/class.bopreferences.inc.php:1.24
--- email/inc/class.bopreferences.inc.php:1.23  Fri Mar 14 04:00:15 2003
+++ email/inc/class.bopreferences.inc.php       Thu Dec 30 23:13:50 2004
@@ -32,6 +32,8 @@
                        'ex_accounts_delete' => True
                );
                var $msg_bootstrap;
+               // convience reference to the msg object
+               var $msg='##NOTHING##';
                var $not_set='-1';
                var $std_prefs=array();
                var $cust_prefs=array();
@@ -50,6 +52,7 @@
                var $args=array();
                var $debug_set_prefs = 0;
                //var $debug_set_prefs = 3;
+               //var $debug_set_prefs = 4;


                function bopreferences()
@@ -71,9 +74,13 @@
                        $this->msg_bootstrap->set_do_login(BS_LOGIN_NEVER);
                        if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences. *constructor*: call 
this->msg_bootstrap->ensure_mail_msg_exists, msg_bootstrap->get_do_login(): 
'.serialize($this->msg_bootstrap->get_do_login()).'<br>'; }
                        
$this->msg_bootstrap->ensure_mail_msg_exists('email.bopreferences. 
*constructor*', $this->debug_set_prefs);
-
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences. *constructor*: LEAVING<br>'; }
-                       return;
+                       // make the convience reference
+                       if ($this->msg == '##NOTHING##')
+                       {
+                               $this->msg =& $GLOBALS['phpgw']->msg;
+                       }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences. *constructor*: LEAVING<br>'); }
+                       //return;
                }

                /*!
@@ -100,7 +107,7 @@
                */
                function init_available_prefs()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.init_available_prefs: ENTERING, use debug level 4 for a 
data dump on leaving<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.init_available_prefs: ENTERING, use 
debug level 4 for a data dump on leaving<br>'); }

                        $this->std_prefs = Array();
                        $i = 0;
@@ -113,15 +120,7 @@
                                'lang_blurb'    => lang('enable this email 
account'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'THIS PREF CURRENTLY DOES NOTHING
-                                       Users may have more than one email 
account. In the future
-                                       it is anticipated that automatic 
actions may be performed
-                                       on these accounts, such as automatic 
new mail checks,
-                                       auto filtering, etc... Perhaps the user 
may want to disable
-                                       an account so that these automatic 
actions do not occur for
-                                       that account. This is one possible use.
-                                       Also, an admin may want to disable 
accounts from time to time.'
+                               'long_desc' => lang('THIS PREF CURRENTLY DOES 
NOTHING Users may have more than one email account. In the future it is 
anticipated that automatic actions may be performed on these accounts, such as 
automatic new mail checks,auto filtering, etc... Perhaps the user may want to 
disable an account so that these automatic actions do not occur for that 
account. This is one possible use. Also, an admin may want to disable accounts 
from time to time.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -134,15 +133,7 @@
                                // note that after the comma there is NO space, 
this means default is no value
                                'init_default'  => 'string,',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'This is the name that appears in the 
account combobox. If for
-                                       leave this blank, your accounts will be 
given a standard name like
-                                       Account[1]: Jane Doe, where Jane Doe is 
the name you give below as
-                                       '.lang('Your full name').'. If you want 
to give an account a special name
-                                       you can fill this in. No matter what, 
this is for your use,
-                                       your emails will still use '.lang('Your 
full name').' as
-                                       your FROM name for email messages. Note 
that '.lang('Your full name').' for your
-                                       email account 0 is the name you gave in 
the phpgroupware setup.'
+                               'long_desc' => lang('This is the name that 
appears in the account combobox. If for leave this blank, your accounts will be 
given a standard name like Account[1]: Jane Doe, where Jane Doe is the name you 
give below as Your full name. If you want to give an account a special name you 
can fill this in. No matter what, this is for your use, your emails will still 
use Your full name as your FROM name for email messages. Note that Your full 
name for your email account 0 is the name you gave in the phpgroupware setup.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -154,12 +145,7 @@
                                'lang_blurb'    => lang('Your full name'),
                                'init_default'  => 
'varEVAL,$GLOBALS["phpgw_info"]["user"]["fullname"];',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'This is the name that appears in the 
users FROM address.
-                                       The default mail account gets this 
value automatically from
-                                       the phpgwapi. Additional accounts are 
created with the phpgwapi
-                                       supplied fullname you can specify a 
different fullname for each
-                                       extra email account.'
+                               'long_desc' => lang('This is the name that 
appears in the users FROM address. The default mail account gets this value 
automatically from the phpgwapi. Additional accounts are created with the 
phpgwapi supplied fullname you can specify a different fullname for each extra 
email account.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -171,13 +157,7 @@
                                'lang_blurb'    => lang('email signature'),
                                'init_default'  => 'string, ',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'This text will be appended to the 
bottom of the users emails for
-                                       this email account. Currently, html 
tags are not supported. Also,
-                                       forwarded email will NOT get this email 
sig appended to it for reasons
-                                       such as it clutters the email, the 
forwarded part probably has its own
-                                       email sig from the original author, 
which is really the information
-                                       that matters the most.'
+                               'long_desc' => lang('This text will be appended 
to the bottom of the users emails for this email account. Currently, html tags 
are not supported. Also, forwarded email will NOT get this email sig appended 
to it for reasons such as it clutters the email, the forwarded part probably 
has its own email sig from the original author, which is really the information 
that matters the most.')
                        );
                        $lang_oldest = lang('oldest');
                        $lang_newest = lang('newest');
@@ -194,13 +174,7 @@
                                        'old_new' => $lang_oldest.' -> 
'.$lang_newest,
                                        'new_old' => $lang_newest.' -> 
'.$lang_oldest
                                ),
-                               'long_desc' =>
-                                       'In the email index page, the page 
which lists all the mails in a
-                                       folder, mail may be sorted by date, 
author, size, or subject,
-                                       HOWEVER all of these need to be ordered 
from first to last, this
-                                       options controlls what is first and 
last. For example,
-                                       if sorting by date, the newest to 
oldest displays the most recent
-                                       emails first, in decending order down 
to the oldest emails last. '
+                               'long_desc' => lang('In the email index page, 
the page which lists all the mails in a folder, mail may be sorted by date, 
author, size, or subject, HOWEVER all of these need to be ordered from first to 
last, this options controlls what is first and last. For example, if sorting by 
date, the newest to oldest displays the most recent emails first, in decending 
order down to the oldest emails last. ')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -215,11 +189,7 @@
                                        '1' => lang('Layout 1'),
                                        '2' => lang('Layout 2')
                                ),
-                               'long_desc' =>
-                                       'The email application offers 2 
different layouts for the index page,
-                                       that is the page that lists the emails 
in a folder. This page may be
-                                       the page the user looks at the most and 
so different layouts, or looks,
-                                       are offered.'
+                               'long_desc' => lang('The email application 
offers 2 different layouts for the index page, that is the page that lists the 
emails in a folder. This page may be the page the user looks at the most and so 
different layouts, or looks, are offered.')
                        );
                        $i++;

@@ -275,14 +245,10 @@
                                'values'        => array(
                                        'evo' => lang('Evolution Style'),
                                        'moz' => lang('Mozilla Modern Style'),
-                                       'noia' => lang('Noia &#64; Carlitus 
Style')
+                                       'noia' => lang('Noia &#64; Carlitus 
Style'),
+                                       'AquaFusion' => lang('Aqua Fusion')
                                ),
-                               'long_desc' =>
-                                       'The email application offers different 
icon image themes, groups of
-                                       images of a similar style which are 
used in this email application.
-                                       Currently the available themes are 
images based on Evolution by Ximian
-                                       and the Netscape6 / Mozilla browser 
buttons. Additional themes are
-                                       anticipated and welcome.'
+                               'long_desc' => lang('The email application 
offers different icon image themes, groups of images of a similar style which 
are used in this email application. Currently the available themes are images 
based on Evolution by Ximian and the Netscape7, Mozilla browser buttons. 
Additional themes are anticipated and welcome.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -297,9 +263,7 @@
                                        '16' => lang('Small'),
                                        '24' => lang('Big')
                                ),
-                               'long_desc' =>
-                                       'The email application offers different 
icon image themes, these
-                                       icons can be big or small.'
+                               'long_desc' => lang('The email application 
offers different icon image themes, these icons can be big or small.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -315,9 +279,7 @@
                                        'image' => lang('Image'),
                                        'both' => lang('Both')
                                ),
-                               'long_desc' =>
-                                       'The email application offers different 
button displays, these
-                                       buttons can be text, images, or both.'
+                               'long_desc' => lang('The email application 
offers different button displays, these buttons can be text, images, or both.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -333,19 +295,7 @@
                                        'From' => lang('From'),
                                        'ReplyTo' => lang('ReplyTo')
                                ),
-                               'long_desc' =>
-                                       'This confusing and often misunderstood 
option is left over from
-                                       this email apps origins as Aeromail by 
Mark Cushman. When viewing
-                                       a list of emails in a folder, the FROM 
column may show you
-                                       a) the senders name only, if a name was 
provided,
-                                       b) the senders From email address, in 
addition to the senders name, or
-                                       c) the senders reply to address if it 
is different from the senders
-                                       from address, in addition to the 
senders name if it was provided.
-                                       Typically users set this to none, which 
will show only the senders
-                                       name. If no name was supplied by the 
sender, then the senders FROM
-                                       email address will be shown, whether a 
seperate reply to address is
-                                       provided has no effect on this, the 
FROM address is always used if the
-                                       senders name is not provided.'
+                               'long_desc' => lang('This confusing and often 
misunderstood option is left over from this email apps origins as Aeromail by 
Mark Cushman. When viewing a list of emails in a folder, the FROM column may 
show you a) the senders name only, if a name was provided, b) the senders From 
email address, in addition to the senders name, or c) the senders reply to 
address if it is different from the senders from address, in addition to the 
senders name if it was provided. Typically users set this to none, which will 
show only the senders name. If no name was supplied by the sender, then the 
senders FROM email address will be shown, whether a seperate reply to address 
is provided has no effect on this, the FROM address is always used if the 
senders name is not provided.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -357,11 +307,7 @@
                                'lang_blurb'    => lang('show new messages on 
main screen'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Each user has a summary page which can 
display a variety
-                                       of information. This option will show a 
small list of email
-                                       messages in the INBOX of the users 
default email account on
-                                       the users summary home page.'
+                               'long_desc' => lang('Each user has a summary 
page which can display a variety of information. This option will show a small 
list of email messages in the INBOX of the users default email account on the 
users summary home page.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -375,11 +321,7 @@
                                'lang_blurb'    => lang('Deleted messages go to 
Trash'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'If checked, Deleted message will be 
sent to the &quot;Trash&quot;
-                                       folder name which you specify in the 
box for &quot;'
-                                       .lang('Deleted messages (Trash) 
folder').'&quot;.
-                                       Only works with IMAP servers, POP 
servers do not have folders.'
+                               'long_desc' => lang('If checked, Deleted 
message will be sent to the &quot;Trash&quot; folder name which you specify in 
the box for &quot; Deleted messages (Trash) folder &quot;. Only works with IMAP 
servers, POP servers do not have folders.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -392,14 +334,7 @@
                                'lang_blurb'    => lang('Deleted messages 
(Trash) folder'),
                                'init_default'  => 'string,Trash',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'If &quot;'.lang('Deleted messages go 
to Trash').'&quot; is checked,
-                                       Deleted message will be sent to the 
folder name you type in
-                                       this box. If this folder does not 
exist, it will be created
-                                       for you automatically. Default name is 
&quot;Trash&quot;.
-                                       This will be your &quot;Trash&quot; 
folder, but it does not have to
-                                       actually be called &quot;Trash&quot;, 
you can name it anything.
-                                       Only works with IMAP servers, POP 
servers do not have folders.'
+                               'long_desc' => lang('If &quot; Deleted messages 
go to Trash &quot; is checked, Deleted message will be sent to the folder name 
you type in this box. If this folder does not exist, it will be created for you 
automatically. Default name is &quot;Trash&quot;. This will be your 
&quot;Trash&quot; folder, but it does not have to actually be called 
&quot;Trash&quot;, you can name it anything. Only works with IMAP servers, POP 
servers do not have folders.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -413,11 +348,7 @@
                                'lang_blurb'    => lang('Sent messages saved in 
&quot;Sent&quot; folder'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'If checked, a copy of your sent mail 
will be stored in
-                                       the &quot;Sent&quot; folder name which 
you specify in the box
-                                       for &quot;'.lang('Sent messages 
folder').'&quot;.
-                                       Only works with IMAP servers, POP 
servers do not have folders.'
+                               'long_desc' => lang('If checked, a copy of your 
sent mail will be stored in the &quot;Sent&quot; folder name which you specify 
in the box for &quot;Sent messages folder &quot;. Only works with IMAP servers, 
POP servers do not have folders.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -430,14 +361,7 @@
                                'lang_blurb'    => lang('Sent messages folder'),
                                'init_default'  => 'string,Sent',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'If &quot;'.lang('Sent messages 
folder').'&quot; is checked,
-                                       a copy of your sent mail will be stored 
in the folder
-                                       name you type in this box. If this 
folder does not exist,
-                                       it will be created for you 
automatically. Default name is &quot;Sent&quot;.
-                                       This will be your &quot;Sent&quot; 
folder, but it does not have to
-                                       actually be called &quot;Sent&quot;, 
you can name it anything.
-                                       Only works with IMAP servers, POP 
servers do not have folders.'
+                               'long_desc' => lang('If &quot; Sent messages 
folder &quot; is checked, a copy of your sent mail will be stored in the folder 
name you type in this box. If this folder does not exist, it will be created 
for you automatically. Default name is &quot;Sent&quot;. This will be your 
&quot;Sent&quot; folder, but it does not have to actually be called 
&quot;Sent&quot;, you can name it anything. Only works with IMAP servers, POP 
servers do not have folders.')
                        );
                        /*
                        $i++;
@@ -497,13 +421,7 @@
                                'lang_blurb'    => lang('enable UTF-7 encoded 
folder names'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Most US and European users do not need 
to enable this.
-                                       If this option is checked then your 
email server can handle
-                                       folder names with non US-ASCII 
charactors in them/ Default
-                                       is disabled, not checked. Only use if 
you are really sure
-                                       you need it.
-                                       Only works with IMAP servers, POP 
servers do not have folders.'
+                               'long_desc'     => lang('Most US and European 
users do not need to enable this. If this option is checked then your email 
server can handle folder names with non US-ASCII charactors in them/ Default is 
disabled, not checked. Only use if you are really sure you need it. Only works 
with IMAP servers, POP servers do not have folders.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -515,10 +433,7 @@
                                'lang_blurb'    => lang('Send forwarded mail as 
quoted attachment'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Select this box if you want the text 
body of the message you are forwarding to appear
-                                       inline in the body of your sent message
-                                       '
+                               'long_desc'     => lang('Select this box if you 
want the text body of the message you are forwarding to appear inline in the 
body of your sent message')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -530,9 +445,7 @@
                                'init_default'  => 'string,simple',
                                'values'        => array('orig'=>'Simple',
                                                        'lex' => 'Javascript'),
-                               'long_desc' =>
-                                       'We have recently added this new 
addressbook so that users can choose to have a more complex addressbook that 
features a) Easy, point and click searching, b) Best suited for organizations 
with large central addressbooks with many categories. You can choose here which 
addressbook do you prefer.
-                                       '
+                               'long_desc' => lang('We have recently added 
this new addressbook so that users can choose to have a more complex 
addressbook that features a) Easy, point and click searching, b) Best suited 
for organizations with large central addressbooks with many categories. You can 
choose here which addressbook do you prefer.')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -545,11 +458,7 @@
                                'values'        => array('900'=>'1200x1600',
                                                        '800' => '1024x768',
                                                        '700' => '800x600'),
-                               'long_desc' =>
-                                       'We have three sizes that tell us how 
to better render the addressbook for you: 800x600 (addressbook
-                                       will popout in a 700 pixel wide box), 
1024x768 (it will be a 800 box), 1200x1600 (will be a 900 box).
-                                       The fonts for all html stuff will be, 
respectively set to xx-small, x-small and normal (no font setting).
-                                       '
+                               'long_desc' => lang('We have three sizes that 
tell us how to better render the addressbook for you: 800x600 (addressbook will 
popout in a 700 pixel wide box), 1024x768 (it will be a 800 box), 1200x1600 
(will be a 900 box). The fonts for all html stuff will be, respectively set to 
xx-small, x-small and normal (no font setting).')
                        );
                        $i++;
                        $this->std_prefs[$i] = Array(
@@ -561,8 +470,7 @@
                                'lang_blurb'    => lang('Show New Messages in 
ComboBox'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'This specifies whether or not to show 
the number of new message in the folders combo box on the index screen.'
+                               'long_desc' => lang('This specifies whether or 
not to show the number of new message in the folders combo box on the index 
screen.')
                        );
                        $i++;
                         $this->std_prefs[$i] = Array(
@@ -574,8 +482,7 @@
                                 'lang_blurb'    => lang('Show total folder 
size by default'),
                                 'init_default'  => 'set_or_not,not_set',
                                 'values'        => array(),
-                                'long_desc' =>
-                                        'This specifies whether or not to show 
the total size of folders by default. If this is not checked, you will be 
presented with a button allowing you to display folder size..'
+                                'long_desc' => lang('This specifies whether or 
not to show the total size of folders by default. If this is not checked, you 
will be presented with a button allowing you to display folder size..')
                         );
                        // Custom Settings
                        $this->cust_prefs = Array();
@@ -591,22 +498,7 @@
                                'lang_blurb'    => lang('Use custom settings'),
                                'init_default'  => 'set_or_not,not_set',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Your server administrator will set the 
default values for the
-                                       following options. You may never need 
to change any of them.
-                                       If you do need to use settings that are 
different from
-                                       the defaults for the options below 
here, then check this
-                                       box. Default is disabled, not checked. 
If you fill in some
-                                       of the options, but later decide to go 
back to the default
-                                       values, unchecking this box will erase 
your custom values
-                                       and put back the default values. All of 
the following options
-                                       start out with the default value, so 
you may see some
-                                       settings below even if you have never 
filled them in.
-                                       This checkbox only shows up for the 
default email account.
-                                       If you are setting up additional email 
accounts, you will
-                                       be required to fill in the following 
options and this
-                                       checkbox will not be displayed, it will 
be checked for
-                                       all extra email accounts.'
+                               'long_desc' => lang('Your server administrator 
will set the default values for the following options. You may never need to 
change any of them. If you do need to use settings that are different from the 
defaults for the options below here, then check this box. Default is disabled, 
not checked. If you fill in some of the options, but later decide to go back to 
the default values, unchecking this box will erase your custom values and put 
back the default values. All of the following options start out with the 
default value, so you may see some settings below even if you have never filled 
them in. This checkbox only shows up for the default email account. If you are 
setting up additional email accounts, you will be required to fill in the 
following options and this checkbox will not be displayed, it will be checked 
for all extra email accounts.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -619,18 +511,7 @@
                                'lang_blurb'    => lang('Email Account Name'),
                                'init_default'  => 
'function,sub_default_userid',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'The login name to use when checking 
mail for this email
-                                       account. This may be the same as your 
phpGroupWare login
-                                       name, or the server administrator may 
have set it for you.
-                                       If your have multiple email accounts 
set up, you will need
-                                       to fill this in. If you have only one 
email account set
-                                       up, then you can probably leave this 
alone. If you clear this
-                                       box, then it goes back to the default 
value. If you only need
-                                       some custom settings but want this one 
to be the default value,
-                                       then leave this box blank, the default 
value will be used, and
-                                       you will see that default value in this 
box the next time you
-                                       come to this preferences page.'
+                               'long_desc' => lang('The login name to use when 
checking mail for this email account. This may be the same as your phpGroupWare 
login name, or the server administrator may have set it for you. If your have 
multiple email accounts set up, you will need to fill this in. If you have only 
one email account set up, then you can probably leave this alone. If you clear 
this box, then it goes back to the default value. If you only need some custom 
settings but want this one to be the default value, then leave this box blank, 
the default value will be used, and you will see that default value in this box 
the next time you come to this preferences page.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -643,20 +524,7 @@
                                'lang_blurb'    => lang('Email Password'),
                                'init_default'  => 'init_no_fill',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'The login name to use when checking 
mail for this email
-                                       account. This may be the same as your 
phpGroupWare login
-                                       name, or the server administrator may 
have set it for you.
-                                       If your have multiple email accounts 
set up, you will need
-                                       to fill this in. If you have only one 
email account set
-                                       up, then you can probably leave this 
alone. If you do set
-                                       a custom password, this box will be 
blank the next time you
-                                       come to this settings page. This is a 
security feature because
-                                       your custom email password is not sent 
to your browser after
-                                       you set it. To change your custom 
password, simply enter a new
-                                       password in the box. Exra email 
accounts require you to set this.
-                                       For your default email account, you can 
clear your custom password
-                                       by unchecking the &quot;Use Custom 
Settings&quot; option.'
+                               'long_desc' => lang('The password to use when 
checking mail for this email account. This may be the same as your phpGroupWare 
password, or the server administrator may have set it for you. If your have 
multiple email accounts set up, you will need to fill this in. If you have only 
one email account set up, then you can probably leave this alone. If you do set 
a custom password, this box will be blank the next time you come to this 
settings page. This is a security feature because your custom email password is 
not sent to your browser after you set it. To change your custom password, 
simply enter a new password in the box. Extra email accounts require you to set 
this. For your default email account, you can clear your custom password by 
unchecking the &quot;Use Custom Settings&quot; option.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -670,13 +538,7 @@
                        //      'init_default'  => 
'function,$this->sub_default_address($account_id);',
                                'init_default'  => 
'function,sub_default_address',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Mail you send will use this address as 
the &quot;From&quot; address.
-                                       This may be the same as your 
phpGroupWare login name,
-                                       or the server administrator may have 
set it for you.
-                                       When the recipient clicks reply, this 
address will
-                                       be used. You can leave this box blank 
and the default value
-                                       will be used.'
+                               'long_desc' => lang('Mail you send will use 
this address as the &quot;From&quot; address. This may be the same as your 
phpGroupWare login name, or the server administrator may have set it for you. 
When the recipient clicks reply, this address will be used. You can leave this 
box blank and the default value will be used.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -689,10 +551,7 @@
                                'lang_blurb'    => lang('Mail Server'),
                                'init_default'  => 
'varEVAL,$GLOBALS["phpgw_info"]["server"]["mail_server"];',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Name of the mail server you want to 
access. Should be a
-                                       name like &quot;mail.example.com&quot;. 
If you leave this box
-                                       blank then the default value will be 
used.'
+                               'long_desc' => lang('Name of the mail server 
you want to access. Should be a name like &quot;mail.example.com&quot;. If you 
leave this box blank then the default value will be used.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -709,13 +568,7 @@
                                        'imaps'         => 'IMAPS',
                                        'pop3s'         => 'POP-3S'
                                ),
-                               'long_desc' =>
-                                       'The type of mail server you want to 
access. IMAP mail
-                                       servers have folders, such as the Sent 
and Trash folders.
-                                       POP servers do not have folders. POP, 
POP-3, and POP3 are the same thing.
-                                       You can have the server connection 
encrypted by using IMAPS or POPS,
-                                       only if the mailserver supports it and 
if your phpGroupWare installation
-                                       has a &quot;SSL&quot; capabable version 
of PHP.'
+                               'long_desc' => lang('The type of mail server 
you want to access. IMAP mail servers have folders, such as the Sent and Trash 
folders. POP servers do not have folders. POP, POP-3, and POP3 are the same 
thing. You can have the server connection encrypted by using IMAPS or POPS, 
only if the mailserver supports it and if your phpGroupWare installation has a 
&quot;SSL&quot; capabable version of PHP.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -731,19 +584,7 @@
                                        'UWash'         => 'UWash',
                                        'UW-Maildir'    => 'UW-Maildir'
                                ),
-                               'long_desc' =>
-                                       'If using an IMAP server, what kind is 
it, most often
-                                       this option can safely be set to
-                                       &quot;Cyrus '.lang('or').' 
Courier&quot;. Technically, this
-                                       means the server uses a dot between the 
different parts of the
-                                       folder names, such as 
&quot;INBOX.Sent&quot;. The other major kind
-                                       of IMAP server is the University of 
Washington &quot;UWash&quot; IMAP server.
-                                       It uses slashes instead of the dots the 
other servers use, and
-                                       although it has a folder called 
&quot;INBOX&quot;, it is not
-                                       considered the &quot;Namespace&quot; 
for the other folder names.
-                                       The &quot;UW-Maildir&quot; is a rare 
combination of the two above
-                                       types. This is the least used kind of 
IMAP server. If you are unsure,
-                                       ask your IT administrator. Only applies 
to IMAP servers.'
+                               'long_desc' => lang('If using an IMAP server, 
what kind is it, most often this option can safely be set to &quot;Cyrus or 
Courier&quot;. Technically, this means the server uses a dot between the 
different parts of the folder names, such as &quot;INBOX.Sent&quot;. The other 
major kind of IMAP server is the University of Washington &quot;UWash&quot; 
IMAP server. It uses slashes instead of the dots the other servers use, and 
although it has a folder called &quot;INBOX&quot;, it is not considered the 
&quot;Namespace&quot; for the other folder names. The &quot;UW-Maildir&quot; is 
a rare combination of the two above types. This is the least used kind of IMAP 
server. If you are unsure, ask your IT administrator. Only applies to IMAP 
servers.')
                        );
                        $i++;
                        $this->cust_prefs[$i] = Array(
@@ -756,21 +597,10 @@
                                'lang_blurb'    => lang('U-Wash Mail Folder').' 
- ' .lang('If Applicable'),
                                'init_default'  => 
'varEVAL,$GLOBALS["phpgw_info"]["server"]["mail_folder"];',
                                'values'        => array(),
-                               'long_desc' =>
-                                       'Only needed with the University of 
Washington &quot;UWash&quot; IMAP server.
-                                       The default value is &quot;mail&quot; 
which means your mail folders, other
-                                       then INBOX, are located in a directory 
called &quot;mail&quot; directly
-                                       under your &quot;HOME&quot; directory. 
This box may be left empty, which
-                                       means your mail folders are located in 
your &quot;HOME&quot; directory, not
-                                       a subdirectory. If your mail folders 
are located in a subdirectory of
-                                       &quot;HOME&quot; then put the name of 
that subdirectory here. Generally,
-                                       it is not necessary to use any special 
slashes or tildes, &quot;HOME&quot;
-                                       is always considered the base 
directory, and the slash bewteen &quot;HOME&quot;
-                                       and the subdirectory will be added for 
you automatically, do not put the slash
-                                       in this box.'
+                               'long_desc' => lang('Only needed with the 
University of Washington &quot;UWash&quot; IMAP server. The default value is 
&quot;mail&quot; which means your mail folders, other then INBOX, are located 
in a directory called &quot;mail&quot; directly under your &quot;HOME&quot; 
directory. This box may be left empty, which means your mail folders are 
located in your &quot;HOME&quot; directory, not a subdirectory. If your mail 
folders are located in a subdirectory of &quot;HOME&quot; then put the name of 
that subdirectory here. Generally, it is not necessary to use any special 
slashes or tildes, &quot;HOME&quot; is always considered the base directory, 
and the slash bewteen &quot;HOME&quot; and the subdirectory will be added for 
you automatically, do not put the slash in this box.')
                        );
-                       if ($this->debug_set_prefs > 3) { echo 
'email.bopreferences.init_available_prefs: data dump: calling 
debug_dump_prefs<pre>';  $this->debug_dump_prefs(); }
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.init_available_prefs: LEAVING<br>'; }
+                       if ($this->debug_set_prefs > 3) { 
$this->msg->dbug->out('email.bopreferences.init_available_prefs: data dump: 
calling debug_dump_prefs<br>');  $this->debug_dump_prefs(); }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.init_available_prefs: LEAVING<br>'); 
}
                }


@@ -778,9 +608,9 @@
                function debug_dump_prefs()
                {
                        // DEBUG begin
-                       echo '<br><br>';
-                       echo '<b>std_prefs var dump:</b><pre>'; 
print_r($this->std_prefs); echo '</pre>';
-                       echo '<b>cust_prefs var dump:</b><pre>'; 
print_r($this->cust_prefs); echo '</pre>';
+                       //$this->msg->dbug->out('<br><br>');
+                       
$this->msg->dbug->out('email.bopreferences.debug_dump_prefs: std_prefs var 
DUMP:', $this->std_prefs);
+                       
$this->msg->dbug->out('email.bopreferences.debug_dump_prefs: cust_prefs var 
DUMP:', $this->cust_prefs);
                        //Header('Location: ' . 
$GLOBALS['phpgw']->link('/preferences/index.php'));
                        //return;
                        // DEBUG end
@@ -793,7 +623,9 @@
                @discussion EXPIRE ANY CACHED ITEM THAT WAS DERIVED FROM A 
CHANGED PREF ITEM.
                We should be precise and only expire if necessary, but for now 
just expire any cached item that could
                be effected by a change in preferences. NOTE: we locate this 
after we have obtained a reliable
-               acctnum which these prefs apply to.
+               acctnum which these prefs apply to.  Currently expires these 
things, mailsvr_callstr, mailsvr_namespace,
+               mailsvr_delimiter, and folder_list. Note that "folder_list" 
requires expiration here because the elements that
+               make up all the folder long, or fully qualified, folder name 
probably have changed too.
                @author Angles
                */
                function expire_related_cached_items($acctnum='')
@@ -803,10 +635,15 @@
                        {
                                $acctnum = $this->acctnum;
                        }
-
+
                        
$GLOBALS['phpgw']->msg->expire_session_cache_item('mailsvr_callstr', $acctnum);
                        
$GLOBALS['phpgw']->msg->expire_session_cache_item('mailsvr_namespace', 
$acctnum);
                        
$GLOBALS['phpgw']->msg->expire_session_cache_item('mailsvr_delimiter', 
$acctnum);
+                       // DAAA! the folder list probably also changes if the 
components that make up the Fully Qualified folder name have changed
+                       
$GLOBALS['phpgw']->msg->expire_session_cache_item('folder_list', $acctnum);
+                       // NEW: now we cache all the prefs in bulk cache in the 
appsession
+                       $my_location = '0;cached_prefs';
+                       
$GLOBALS['phpgw']->msg->so->so_appsession_passthru($my_location, ' ');
                }

                /*!
@@ -820,7 +657,7 @@
                */
                function grab_set_prefs()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences: call to grab_set_prefs<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences: call to grab_set_prefs<br>'); }
                        // better make sure we have created the available prefs 
schema
                        $this->init_available_prefs();

@@ -834,7 +671,7 @@
                        }
                        else
                        {
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences: call to grab_set_prefs CALLER UNKNOWN<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences: call to grab_set_prefs CALLER 
UNKNOWN<br>'); }
                                $this->pref_errors .= 'email: bopreferences: 
grab_set_prefs: unsupported "caller" variable<br>';
                        }
                }
@@ -860,7 +697,7 @@
                */
                function grab_set_prefs_args_gpc()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences: call to grab_set_prefs_args_gpc<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences: call to 
grab_set_prefs_args_gpc<br>'); }
                        // ----  HANDLE GRABBING PREFERENCE GPC HTTP_POST_VARS 
ARGS  -------
                        // for abstraction from phpgw UI and from PHP's GPC 
data, put the submitted GPC data
                        // into a class var $this->args[] array. This array is 
then used to represent the submitted
@@ -870,7 +707,7 @@
                        // ----  DEFAULT EMAIL ACCOUNT  ----
                        if 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this->submit_token]))
                        {
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences: INSIDE grab_set_prefs_args_gpc for Default Email Account 
data<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences: INSIDE grab_set_prefs_args_gpc for 
Default Email Account data<br>'); }

                                // EXPIRE stuff that may get stale by changing 
prefs
                                $this->expire_related_cached_items(0);
@@ -886,14 +723,14 @@
                                        // existence of $this->submit_token 
indicates this data is intended for the default email account
                                        if 
(!stristr($this->std_prefs[$i]['accts_usage'], 'default'))
                                        {
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) _SKIP_ this item ['.$this->std_prefs[$i]['id'].'], it 
does not apply to the default email account<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) _SKIP_ this item 
['.$this->std_prefs[$i]['id'].'], it does not apply to the default email 
account<br>'); }
                                        }
                                        else
                                        {
                                                // ok, we have a pref item that 
applies to the default email account
                                                $this_pref_name = 
$this->std_prefs[$i]['id'];
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) $this_pref_name: '.$this_pref_name.'<br>'; }
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) $GLOBALS[HTTP_POST_VARS][$this_pref_name]: 
'.$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name].'<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) $this_pref_name: 
'.$this_pref_name.'<br>'); }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) 
$GLOBALS[HTTP_POST_VARS][$this_pref_name]: 
'.$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name].'<br>'); }
                                                if 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this_pref_name]))
                                                {
                                                        
$this->args[$this_pref_name] = 
$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name];
@@ -909,14 +746,14 @@
                                        // existence of $this->submit_token 
indicates this data is intended for the default email account
                                        if 
(!stristr($this->cust_prefs[$i]['accts_usage'], 'default'))
                                        {
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) _SKIP_ this item ['.$this->cust_prefs[$i]['id'].'], it 
does not apply to the default email account<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) _SKIP_ this item 
['.$this->cust_prefs[$i]['id'].'], it does not apply to the default email 
account<br>'); }
                                        }
                                        else
                                        {
                                                // ok, we have a pref item that 
applies to the default email account
                                                $this_pref_name = 
$this->cust_prefs[$i]['id'];
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) $this_pref_name: '.$this_pref_name.'<br>'; }
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) $GLOBALS[HTTP_POST_VARS][$this_pref_name]: 
'.$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name].'<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) $this_pref_name: 
'.$this_pref_name.'<br>'); }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) 
$GLOBALS[HTTP_POST_VARS][$this_pref_name]: 
'.$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name].'<br>'); }
                                                if 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this_pref_name]))
                                                {
                                                        
$this->args[$this_pref_name] = 
$GLOBALS['phpgw']->msg->ref_POST[$this_pref_name];
@@ -927,7 +764,7 @@
                        // ----  EXTRA EMAIL ACCOUNTS  ----
                        elseif 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this->submit_token_extra_accounts]))
                        {
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences: INSIDE grab_set_prefs_args_gpc for EXTRA EMAIL ACCOUNTS 
data<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences: INSIDE grab_set_prefs_args_gpc for 
EXTRA EMAIL ACCOUNTS data<br>'); }

                                //$this->args['submit_prefs'] = 
$GLOBALS['phpgw']->msg->ref_POST['submit_prefs'];
                                $this->args[$this->submit_token_extra_accounts] 
= $GLOBALS['phpgw']->msg->ref_POST[$this->submit_token_extra_accounts];
@@ -952,14 +789,14 @@
                                        // extra email accounts
                                        if 
(!stristr($this->std_prefs[$i]['accts_usage'], 'extra_accounts'))
                                        {
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) _SKIP_ this item ['.$this->std_prefs[$i]['id'].'], it 
does not apply to extra email accounts<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) _SKIP_ this item 
['.$this->std_prefs[$i]['id'].'], it does not apply to extra email 
accounts<br>'); }
                                        }
                                        else
                                        {
                                                // ok, we have a pref item that 
applies to the default email account
                                                $this_pref_name = 
$this->std_prefs[$i]['id'];
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) $this_pref_name: '.$this_pref_name.'<br>'; }
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (std pref) 
$GLOBALS[HTTP_POST_VARS][$this->acctnum('.$this->acctnum.')][$this_pref_name('.$this_pref_name.')]:
 ['.$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name].']<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) $this_pref_name: 
'.$this_pref_name.'<br>'); }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (std pref) 
$GLOBALS[HTTP_POST_VARS][$this->acctnum('.$this->acctnum.')][$this_pref_name('.$this_pref_name.')]:
 ['.$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name].']<br>'); 
}
                                                if 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name]))
                                                {
                                                        
$this->args[$this->acctnum][$this_pref_name] = 
$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name];
@@ -976,14 +813,14 @@
                                        // extra email accounts
                                        if 
(!stristr($this->cust_prefs[$i]['accts_usage'], 'extra_accounts'))
                                        {
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) _SKIP_ this item ['.$this->cust_prefs[$i]['id'].'], it 
does not apply to extra email accounts<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) _SKIP_ this item 
['.$this->cust_prefs[$i]['id'].'], it does not apply to extra email 
accounts<br>'); }
                                        }
                                        else
                                        {
                                                // ok, we have a pref item that 
applies to extra email accounts
                                                $this_pref_name = 
$this->cust_prefs[$i]['id'];
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) $this_pref_name: '.$this_pref_name.'<br>'; }
-                                               if ($this->debug_set_prefs > 1) 
{ echo ' * * (cust pref) 
$GLOBALS[HTTP_POST_VARS][$this->acctnum('.$this->acctnum.')][$this_pref_name('.$this_pref_name.')]:
 ['.$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name].']<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) $this_pref_name: 
'.$this_pref_name.'<br>'); }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out(' * * (cust pref) 
$GLOBALS[HTTP_POST_VARS][$this->acctnum('.$this->acctnum.')][$this_pref_name('.$this_pref_name.')]:
 ['.$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name].']<br>'); 
}
                                                if 
(isset($GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name]))
                                                {
                                                        
$this->args[$this->acctnum][$this_pref_name] = 
$GLOBALS['phpgw']->msg->ref_POST[$this->acctnum][$this_pref_name];
@@ -1008,7 +845,7 @@
                function grab_set_prefs_args_xmlrpc()
                {
                        // STUB, for future use
-                       echo 'email boprefs: call to un-implemented function 
grab_set_prefs_args_xmlrpc';
+                       $this->msg->dbug->out('email boprefs: call to 
un-implemented function grab_set_prefs_args_xmlrpc<br>');
                }

                /*!
@@ -1031,13 +868,13 @@
                        $c_prefs = count($prefs_set);
                        if ($c_prefs == 0)
                        {
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences: process_submitted_prefs: empty array, no prefs set supplied, 
exiting<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: process_submitted_prefs: empty 
array, no prefs set supplied, exiting<br>'); }
                                return False;
                        }

                        for($i=0;$i<$c_prefs;$i++)
                        {
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences: process_submitted_prefs: inside preferences loop ['.$i.']<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: process_submitted_prefs: inside 
preferences loop ['.$i.']<br>'); }

                                $this_pref = $prefs_set[$i];

@@ -1049,7 +886,7 @@
                                        // we are not supposed to show this 
item for the default account, skip this pref item
                                        // continue is used within looping 
structures to skip the rest of the current loop
                                        // iteration and continue execution at 
the beginning of the next iteration
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_submitted_prefs: _SKIP_ this item 
["'.$this_pref['id'].'"], it does not apply to the default email account<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: process_submitted_prefs: _SKIP_ 
this item ["'.$this_pref['id'].'"], it does not apply to the default email 
account<br>'); }
                                        continue;
                                }

@@ -1061,7 +898,7 @@
                                        // ----  OR an empty string was 
submitted for this pref item  ----

                                        // so how do we handle this, for this 
pref...
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_submitted_prefs: submitted_pref for 
["'.$this_pref['id'].'"] not set or empty string<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: process_submitted_prefs: 
submitted_pref for ["'.$this_pref['id'].'"] not set or empty string<br>'); }
                                        if (stristr($this_pref['write_props'], 
'empty_no_delete'))
                                        {
                                                // DO NOT DELETE
@@ -1069,7 +906,7 @@
                                                // note there may or may not 
actually be an existing value in the prefs table
                                                // but it does not matter here, 
because we do not touch this items value at all.
                                                // Typical Usage: passwords
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: no change to repository for empty or blank 
["'.$this_pref['id'].'"] because of "empty_no_delete"<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: no change to repository for 
empty or blank ["'.$this_pref['id'].'"] because of "empty_no_delete"<br>'); }
                                        }
                                        elseif 
(stristr($this_pref['write_props'], 'empty_string_ok'))
                                        {
@@ -1077,7 +914,7 @@
                                                // i.e. this pref can take an 
empty string as a valid value
                                                // whereas most other prefs are 
simply deleted from the repository if value is empty
                                                // Typical Usage: email sig, 
UWash Mail Folder
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: save empty string to repository for 
["'.$this_pref['id'].'"] because of "empty_string_ok"<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: save empty string to repository 
for ["'.$this_pref['id'].'"] because of "empty_string_ok"<br>'); }
                                                // a) as always, delete the 
pref before we assign a value
                                                
$GLOBALS['phpgw']->preferences->delete('email',$this_pref['id']);
                                                // b) now assign a blank string 
value
@@ -1086,7 +923,7 @@
                                        else
                                        {
                                                // just delete it from the 
preferences repository
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: deleting empty or blank pref 
["'.$this_pref['id'].'"] from the repository<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: deleting empty or blank pref 
["'.$this_pref['id'].'"] from the repository<br>'); }
                                                
$GLOBALS['phpgw']->preferences->delete('email',$this_pref['id']);
                                        }
                                }
@@ -1098,7 +935,7 @@
                                        $submitted_pref = 
$this->args[$this_pref['id']];
                                        // init a var to hold the processed 
submitted_pref
                                        $processed_pref = '';
-                                       if ($this->debug_set_prefs > 1) { echo 
'* * ** email: bopreferences: process_submitted_prefs:  submitted_pref: 
['.$submitted_pref.']<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('* * ** email: bopreferences: process_submitted_prefs:  
submitted_pref: ['.$submitted_pref.']<br>'); }

                                        // most "user_string"s need special 
processing before they can go into the repository
                                        if ($this_pref['type'] == 'user_string')
@@ -1149,7 +986,7 @@
                                                // all other data needs no 
special processing before going into the repository
                                                $processed_pref = 
$submitted_pref;
                                        }
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_submitted_prefs: about to assign pref 
["'.$this_pref['id'].'"] this value, post processing (if any): 
<pre>'.$GLOBALS['phpgw']->strip_html($processed_pref).'</pre><br>'."\r\n"; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: process_submitted_prefs: about to 
assign pref ["'.$this_pref['id'].'"] this value, post processing (if any):', 
$GLOBALS['phpgw']->strip_html($processed_pref)); }

                                        // a) as always, delete the pref before 
we assign a value
                                        
$GLOBALS['phpgw']->preferences->delete('email',$this_pref['id']);
@@ -1170,13 +1007,13 @@
                */
                function preferences()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.preferences(): ENTERING<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.preferences(): ENTERING<br>'); }
                        // establish all available prefs for email
-                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences(): about to call 
$this->init_available_prefs()<br>'; }
+                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences(): about to call 
$this->init_available_prefs()<br>'); }
                        $this->init_available_prefs();

                        // this will fill $this->args[] array with any 
submitted prefs args
-                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences(): about to call $this->grab_set_prefs()<br>'; 
}
+                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences(): about to call 
$this->grab_set_prefs()<br>'); }
                        $this->grab_set_prefs();

                        // ----  HANDLE SETING PREFERENCE   -------
@@ -1188,25 +1025,25 @@
                                // constructor will initialize 
$GLOBALS['phpgw']->msg

                                // ---  Process Standard Prefs  ---
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences: about to process Standard Prefs<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences: about to process 
Standard Prefs<br>'); }
                                
$this->process_submitted_prefs($this->std_prefs);

                                // ---  Process Custom Prefs  ---
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences: about to process Custom Prefs<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences: about to process Custom 
Prefs<br>'); }
                                if (isset($this->args['use_custom_settings']))
                                {
                                        // custom settings are in use, process 
them
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences: custom prefs are in use, calling 
$this->process_submitted_prefs($this->cust_prefs)<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences: custom prefs are in 
use, calling $this->process_submitted_prefs($this->cust_prefs)<br>'); }
                                        
$this->process_submitted_prefs($this->cust_prefs);
                                }
                                else
                                {
                                        // custom settings are NOT being used, 
DELETE them from the repository
                                        $c_prefs = count($this->cust_prefs);
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences: custom prefs NOT in use, deleting them<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences: custom prefs NOT in 
use, deleting them<br>'); }
                                        for($i=0;$i<$c_prefs;$i++)
                                        {
-                                               if ($this->debug_set_prefs > 2) 
{ echo ' *(loop)* email.bopreferences: preferences: deleting custom pref 
$this->cust_prefs['.$i.'][id] : ['.$this->cust_prefs[$i]['id'].']<br>'; }
+                                               if ($this->debug_set_prefs > 2) 
{ $this->msg->dbug->out(' *(loop)* email.bopreferences: preferences: deleting 
custom pref $this->cust_prefs['.$i.'][id] : 
['.$this->cust_prefs[$i]['id'].']<br>'); }
                                                
$GLOBALS['phpgw']->preferences->delete('email',$this->cust_prefs[$i]['id']);
                                        }
                                }
@@ -1214,11 +1051,11 @@
                                // DONE processing prefs, SAVE to the Repository
                                if ($this->debug_set_prefs > 1)
                                {
-                                       echo 
'email.bopreferences.preferences(): *debug* at ['.$this->debug_set_prefs.'] so 
skipping save_repository<br>';
+                                       
$this->msg->dbug->out('email.bopreferences.preferences(): *debug* at 
['.$this->debug_set_prefs.'] so skipping save_repository<br>');
                                }
                                else
                                {
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.preferences(): SAVING REPOSITORY<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.preferences(): SAVING 
REPOSITORY<br>'); }
                                        
$GLOBALS['phpgw']->preferences->save_repository();
                                }
                                // end the email session
@@ -1228,14 +1065,14 @@
                                $take_me_to_url = $GLOBALS['phpgw']->link(
                                                                                
        '/preferences/index.php');

-                               if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.preferences(): almost LEAVING, about to issue a redirect 
to:<br>'.$take_me_to_url.'<br>'; }
+                               if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.preferences(): almost LEAVING, about 
to issue a redirect to:<br>'.$take_me_to_url.'<br>'); }
                                if ($this->debug_set_prefs > 1)
                                {
-                                       echo 
'email.bopreferences.preferences(): LEAVING, *debug* at 
['.$this->debug_set_prefs.'] so skipping Header redirection to: 
['.$take_me_to_url.']<br>';
+                                       
$this->msg->dbug->out('email.bopreferences.preferences(): 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 
'email.bopreferences.preferences: LEAVING with redirect to: 
<br>'.$take_me_to_url.'<br>'; }
+                                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.preferences: LEAVING with redirect 
to: <br>'.$take_me_to_url.'<br>'); }
                                        Header('Location: ' . $take_me_to_url);
                                }
                        }
@@ -1403,7 +1240,7 @@
                */
                function process_ex_accounts_submitted_prefs($prefs_set='')
                {
-                       if ($this->debug_set_prefs > 0) { echo 'email: 
bopreferences: process_ex_accounts_submitted_prefs: ENTERING<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: ENTERING<br>'); }
                        // basicly, copy and paste the real 
"process_submitted_prefs" and tweak for extra_accounts applicablility
                        if(!$prefs_set)
                        {
@@ -1412,25 +1249,25 @@
                        $c_prefs = count($prefs_set);
                        if ($c_prefs == 0)
                        {
-                               if ($this->debug_set_prefs > 0) { echo 'email: 
bopreferences: process_ex_accounts_submitted_prefs: LEAVING, empty array, no 
prefs set supplied<br>'; }
+                               if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: LEAVING, empty array, no prefs set 
supplied<br>'); }
                                return False;
                        }

                        // ==== ACCTNUM ====
-                       if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences: process_ex_accounts_submitted_prefs: pre discovery 
$this->acctnum : ['.serialize($this->acctnum).']<br>'; }
+                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: pre discovery $this->acctnum : 
['.serialize($this->acctnum).']<br>'); }
                        if ((!isset($this->acctnum))
                        || ((string)$this->acctnum == ''))
                        {
                                $this->acctnum = $this->obtain_ex_acctnum();
                        }
-                       if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences: process_ex_accounts_submitted_prefs: post discovery 
$this->acctnum : ['.serialize($this->acctnum).']<br>'; }
+                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: post discovery $this->acctnum : 
['.serialize($this->acctnum).']<br>'); }

                        for($i=0;$i<$c_prefs;$i++)
                        {
-                               if ($this->debug_set_prefs > 1) { echo ' <b>* 
(next loop) *</b> email: bopreferences: process_ex_accounts_submitted_prefs: 
inside preferences loop ['.$i.']<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out(' <b>* (next loop) *</b> email: bopreferences: 
process_ex_accounts_submitted_prefs: inside preferences loop ['.$i.']<br>'); }

                                $this_pref = $prefs_set[$i];
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences: process_ex_accounts_submitted_prefs: $this_pref = 
$prefs_set['.$i.'] : $this_pref DUMP:<pre>'; print_r($prefs_set[$i]); echo 
'</pre>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: $this_pref = $prefs_set['.$i.'] : 
$this_pref DUMP:', $prefs_set[$i]); }

                                // ----  skip this item logic  ----
                                // we are ONLY concerned with items that apply 
to the extra email accounts
@@ -1439,7 +1276,7 @@
                                        // we are not supposed to handle this 
item for the extra email accounts, skip this pref item
                                        // continue is used within looping 
structures to skip the rest of the current loop
                                        // iteration and continue execution at 
the beginning of the next iteration
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_ex_accounts_submitted_prefs: _SKIP_ this item 
["'.$this_pref['id'].'"], it does not apply to Extra Email Accounts <br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: _SKIP_ this item ["'.$this_pref['id'].'"], 
it does not apply to Extra Email Accounts <br>'); }
                                        continue;
                                }

@@ -1449,7 +1286,7 @@
                                {
                                        // nothing submitted for this 
preference item
                                        // OR an empty string was submitted for 
this pref item
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_ex_accounts_submitted_prefs: submitted_pref for 
["'.$this_pref['id'].'"] not set or empty string<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: submitted_pref for 
["'.$this_pref['id'].'"] not set or empty string<br>'); }
                                        if (stristr($this_pref['write_props'], 
'empty_no_delete'))
                                        {
                                                // DO NOT DELETE
@@ -1457,7 +1294,7 @@
                                                // note there may or may not 
actually be an existing value in the prefs table
                                                // but it does not matter here, 
because we do not touch this items value at all.
                                                // Typical Usage: passwords
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: process_ex_accounts_submitted_prefs: no change to 
repository for empty or blank ["'.$this_pref['id'].'"] because of 
"empty_no_delete"<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: no change to repository for empty or blank 
["'.$this_pref['id'].'"] because of "empty_no_delete"<br>'); }
                                        }
                                        elseif 
(stristr($this_pref['write_props'], 'empty_string_ok'))
                                        {
@@ -1465,21 +1302,21 @@
                                                // i.e. this pref can take an 
empty string as a valid value
                                                // whereas most other prefs are 
simply deleted from the repository if value is empty
                                                // Typical Usage: email sig, 
UWash Mail Folder
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences process_ex_accounts_submitted_prefs: save empty 
string to repository for ["'.$this_pref['id'].'"] because of 
"empty_string_ok"<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences 
process_ex_accounts_submitted_prefs: save empty string to repository for 
["'.$this_pref['id'].'"] because of "empty_string_ok"<br>'); }
                                                // a) as always, delete the 
pref before we assign a value
                                                $pref_struct_str = 
'["ex_accounts"]['.$this->acctnum.']["'.$this_pref['id'].'"]';
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences process_ex_accounts_submitted_prefs: using 
preferences->delete_struct("email", $pref_struct_str) which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences 
process_ex_accounts_submitted_prefs: 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);
                                                // b) now assign a blank string 
value
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: process_ex_accounts_submitted_prefs: using 
preferences->add_struct("email", $pref_struct_str, \'\') which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: using preferences->add_struct("email", 
$pref_struct_str, \'\') which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'); }
                                                
$GLOBALS['phpgw']->preferences->add_struct('email',$pref_struct_str,'');
                                        }
                                        else
                                        {
                                                // just delete it from the 
preferences repository
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: process_ex_accounts_submitted_prefs deleting 
empty or blank pref ["'.$this_pref['id'].'"] from the repository<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs deleting empty or blank pref 
["'.$this_pref['id'].'"] from the repository<br>'); }
                                                $pref_struct_str = 
'["ex_accounts"]['.$this->acctnum.']["'.$this_pref['id'].'"]';
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email: bopreferences: process_ex_accounts_submitted_prefs: using 
preferences->delete_struct("email", $pref_struct_str) which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: 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);
                                        }
                                }
@@ -1489,7 +1326,7 @@
                                        $submitted_pref = 
$this->args[$this->acctnum][$this_pref['id']];
                                        // init a var to hold the processed 
submitted_pref
                                        $processed_pref = '';
-                                       if ($this->debug_set_prefs > 1) { echo 
'* * email: bopreferences: process_ex_accounts_submitted_prefs:  
submitted_pref: ['.$submitted_pref.']<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('* * email: bopreferences: 
process_ex_accounts_submitted_prefs:  submitted_pref: 
['.$submitted_pref.']<br>'); }

                                        // most "user_string"s need special 
processing before they can go into the repository
                                        if ($this_pref['type'] == 'user_string')
@@ -1529,14 +1366,14 @@
                                                // all other data needs no 
special processing before going into the repository
                                                $processed_pref = 
$submitted_pref;
                                        }
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_ex_accounts_submitted_prefs: about to assign 
pref ["'.$this_pref['id'].'"] this value, post processing (if any): 
<pre>'.$GLOBALS['phpgw']->strip_html($processed_pref).'</pre><br>'."\r\n"; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: about to assign pref 
["'.$this_pref['id'].'"] this value, post processing (if any):', 
$GLOBALS['phpgw']->strip_html($processed_pref)); }

                                        // a) as always, delete the pref before 
we assign a value
                                        $pref_struct_str = 
'["ex_accounts"]['.$this->acctnum.']["'.$this_pref['id'].'"]';
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences process_ex_accounts_submitted_prefs: using 
preferences->delete_struct("email", $pref_struct_str) which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences 
process_ex_accounts_submitted_prefs: 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);
                                        // b) now assign that processed data to 
this pref item in the repository
-                                       if ($this->debug_set_prefs > 1) { echo 
'email: bopreferences: process_ex_accounts_submitted_prefs: using 
preferences->add_struct("email", $pref_struct_str, $processed_pref) which will 
eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences: 
process_ex_accounts_submitted_prefs: using preferences->add_struct("email", 
$pref_struct_str, $processed_pref) which will eval 
$pref_struct_str='.$pref_struct_str.'<br>'); }
                                        
$GLOBALS['phpgw']->preferences->add_struct('email', $pref_struct_str, 
$processed_pref);
                                        // SORT THAT ARRAY by key, so the 
integer array heys go from lowest to hightest
                                        
ksort($GLOBALS['phpgw']->preferences->data['email']['ex_accounts']);
@@ -1556,9 +1393,9 @@
                */
                function ex_accounts_delete($acctnum='')
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_delete ENTERING feed acctnum: 
['.serialize($acctnum).']<br>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.ex_accounts_delete: $GLOBALS[HTTP_POST_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_POST); echo '</pre>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.ex_accounts_delete: $GLOBALS[HTTP_GET_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_GET); echo '</pre>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete ENTERING feed 
acctnum: ['.serialize($acctnum).']<br>'); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_delete: 
$GLOBALS[HTTP_POST_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_POST); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_delete: 
$GLOBALS[HTTP_GET_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_GET); }

                        $this->account_group = 'extra_accounts';

@@ -1576,19 +1413,19 @@
                        }

                        $actually_did_something = False;
-                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_delete obtained acctnum 
['.$this->acctnum.']<br>'; }
+                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete obtained acctnum 
['.$this->acctnum.']<br>'); }

                        if ((isset($this->acctnum))
                        && ((string)$this->acctnum != ''))
                        {
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_delete obtained VALID acctnum 
['.$this->acctnum.'], proceed...<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete obtained VALID 
acctnum ['.$this->acctnum.'], proceed...<br>'); }

                                // delete the extra account pref item
                                $pref_struct_str = 
'["ex_accounts"]['.$this->acctnum.']';
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences.ex_accounts_delete: using preferences->delete_struct("email", 
$pref_struct_str) which will eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_delete: 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);

-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences.ex_accounts_delete: $GLOBALS[phpgw]->preferences->data 
dump<pre>'; print_r($GLOBALS['phpgw']->preferences->data); echo '</pre>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_delete: 
$GLOBALS[phpgw]->preferences->data DUMP:', 
$GLOBALS['phpgw']->preferences->data); }
                                // let the code below this block know we 
actually did something that requires saving the repository
                                $actually_did_something = True;
                        }
@@ -1597,12 +1434,12 @@
                        if (!$actually_did_something)
                        {
                                // nothing happened above that requires saving 
the repository
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_delete: nothing happened that requires 
save_repository, 
$actually_did_something='.serialize($actually_did_something).'<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete: nothing happened 
that requires save_repository, 
$actually_did_something='.serialize($actually_did_something).'<br>'); }
                        }
                        elseif ($this->debug_set_prefs > 2)
                        {
                                // we actually did something that requires 
saving repository, but are we in debug mode
-                               echo 'email.bopreferences.ex_accounts_delete: 
*debug* skipping save_repository<br>';
+                               
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete: *debug* skipping 
save_repository<br>');
                        }
                        else
                        {
@@ -1617,7 +1454,7 @@
                        // redirect user back to main preferences page
                        if ($this->debug_set_prefs > 2)
                        {
-                               echo 'email.bopreferences.ex_accounts_delete: 
*debug* skipping Header redirection<br>';
+                               
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete: *debug* skipping 
Header redirection<br>');
                        }
                        else
                        {
@@ -1625,7 +1462,7 @@
                                                                                
        '/index.php',
                                                                                
        'menuaction=email.uipreferences.ex_accounts_list');

-                               if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_delete: LEAVING with redirect to: 
['.$take_me_to_url.']<br>'; }
+                               if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_delete: LEAVING with 
redirect to: ['.$take_me_to_url.']<br>'); }
                                Header('Location: ' . $take_me_to_url);
                        }
                }
@@ -1639,9 +1476,9 @@
                */
                function ex_accounts_edit($acctnum='')
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_edit ENTERING <br>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.ex_accounts_edit: $GLOBALS[HTTP_POST_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_POST); echo '</pre>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.ex_accounts_edit: $GLOBALS[HTTP_GET_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_GET); echo '</pre>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit ENTERING <br>'); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_edit: 
$GLOBALS[HTTP_POST_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_POST); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_edit: 
$GLOBALS[HTTP_GET_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_GET); }

                        // ==== ACCTNUM ====
                        // this tells people that we are dealing with the extra 
email accounts
@@ -1667,7 +1504,7 @@
                        // this will fill $this->args[] array with any 
submitted prefs args
                        $this->grab_set_prefs();

-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_edit(): just passed this->grab_set_prefs<br>'; 
}
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): just passed 
this->grab_set_prefs<br>'); }

                        // ----  HANDLE SETING PREFERENCE   -------
                        if 
(isset($this->args[$this->submit_token_extra_accounts]))
@@ -1681,18 +1518,18 @@
                                // constructor will (has taken care of) 
initialize $GLOBALS['phpgw']->msg

                                // ---  Process Standard Prefs  ---
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_edit(): about to 
process_ex_accounts_submitted_prefs Standard Prefs<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): about to 
process_ex_accounts_submitted_prefs Standard Prefs<br>'); }
                                
$this->process_ex_accounts_submitted_prefs($this->std_prefs);

                                // ---  Process Custom Prefs  ---
                                // CUSTOM PREFS ARE MANDATORY! FOR EXTRA 
ACCOUNTS
                                // first, delete whatever value was there for 
"use custom settings" (during pre-release, at times this actually was an 
option, make sure it's gone grom the db)
                                $pref_struct_str = 
'["ex_accounts"]['.$this->acctnum.']["'.$this->cust_prefs[0]['id'].'"]';
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences.ex_accounts_edit(): "use_custom_settings" pref, delete it, 
reference it by 
["ex_accounts"][$this->acctnum]["$this->cust_prefs[0][id]"]<br>'; }
-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences.ex_accounts_edit(): using preferences->delete_struct("email", 
$pref_struct_str) which will eval $pref_struct_str='.$pref_struct_str.'<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_edit(): 
"use_custom_settings" pref, delete it, reference it by 
["ex_accounts"][$this->acctnum]["$this->cust_prefs[0][id]"]<br>'); }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_edit(): 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);

-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_edit(): about to 
process_ex_accounts_submitted_prefs Custom Prefs, which are MANDATORY for extra 
email accounts<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): about to 
process_ex_accounts_submitted_prefs Custom Prefs, which are MANDATORY for extra 
email accounts<br>'); }
                                
$this->process_ex_accounts_submitted_prefs($this->cust_prefs);

                                /*
@@ -1719,24 +1556,24 @@
                                }
                                */

-                               if ($this->debug_set_prefs > 1) { echo 'email: 
bopreferences.ex_accounts_edit: $GLOBALS[phpgw]->preferences->data dump<pre>'; 
print_r($GLOBALS['phpgw']->preferences->data); echo '</pre>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email: bopreferences.ex_accounts_edit: 
$GLOBALS[phpgw]->preferences->data DUMP:', 
$GLOBALS['phpgw']->preferences->data); }
                        }

                        // DONE processing prefs, SAVE to the Repository
                        if (!$actually_did_something)
                        {
                                // nothing happened above that requires saving 
the repository
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_edit(): nothing happened that requires 
save_repository, 
$actually_did_something='.serialize($actually_did_something).'<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): nothing happened 
that requires save_repository, 
$actually_did_something='.serialize($actually_did_something).'<br>'); }
                        }
                        elseif ($this->debug_set_prefs > 1)
                        {
                                // we actually did something that requires 
saving repository, but are we in debug mode
-                               echo 'email.bopreferences.ex_accounts_edit(): 
*debug* at ['.$this->debug_set_prefs.'] so skipping save_repository<br>';
+                               
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): *debug* at 
['.$this->debug_set_prefs.'] so skipping save_repository<br>');
                        }
                        else
                        {
                                // we actually did something that requires 
saving repository, and we have the go-ahead
-                               if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_edit(): SAVING REPOSITORY<br>'; }
+                               if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): SAVING 
REPOSITORY<br>'); }
                                
$GLOBALS['phpgw']->preferences->save_repository();
                        }

@@ -1751,14 +1588,14 @@
                                                                                
'/index.php',
                                                                                
'menuaction=email.uipreferences.ex_accounts_list');

-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_edit(): almost LEAVING, about to issue a 
redirect to:<br>'.$take_me_to_url.'<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): almost LEAVING, 
about to issue a redirect to:<br>'.$take_me_to_url.'<br>'); }
                        if ($this->debug_set_prefs > 1)
                        {
-                               echo 'email.bopreferences.ex_accounts_edit(): 
LEAVING, *debug* at ['.$this->debug_set_prefs.'] so skipping Header redirection 
to: ['.$take_me_to_url.']<br>';
+                               
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit(): 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 
'email.bopreferences.ex_accounts_edit: LEAVING with redirect to: 
<br>'.$take_me_to_url.'<br>'; }
+                               if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_edit: LEAVING with 
redirect to: <br>'.$take_me_to_url.'<br>'); }
                                Header('Location: ' . $take_me_to_url);
                        }
                }
@@ -1771,7 +1608,7 @@
                */
                function ex_accounts_list()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_list: ENTERING<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: ENTERING<br>'); }

                        // list accounts, except "empty" ones (show "enabled" 
and "disabled"
                        $return_list = array();
@@ -1781,14 +1618,14 @@
                                $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_accounts[$i]['acctnum'];
                                $this_status = 
$GLOBALS['phpgw']->msg->extra_accounts[$i]['status'];

-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][acctnum]=['.$this_acctnum.'] ;  
[status]=['.$this->extra_accounts[$i]['status'].'] <br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][acctnum]=['.$this_acctnum.'] ;  
[status]=['.$this->extra_accounts[$i]['status'].'] <br>'); }
                                if ($this_status == 'empty')
                                {
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][status] == empty <br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][status] == empty <br>'); }
                                }
                                else
                                {
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][status] != empty <br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: 
$GLOBALS[phpgw]->msg->extra_accounts['.$i.'][status] != empty <br>'); }
                                        $next_pos = count($return_list);
                                        //$next_pos = $this_acctnum - 1;
                                        $return_list[$next_pos]['acctnum'] = 
$this_acctnum;
@@ -1857,11 +1694,11 @@
                                        }
                                        // NEXT: html encode the acctname string
                                        // html encode entities on the fullname 
so it's safe to display in the browser, and prefix with the acctnum
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: fullname raw: 
<code>'.serialize($accountname).'</code><br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: fullname raw: 
<code>'.serialize($accountname).'</code><br>'); }
                                        $accountname = 
$GLOBALS['phpgw']->msg->htmlspecialchars_decode($accountname);
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: fullname B: 
<code>'.serialize($accountname).'</code><br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: fullname B: 
<code>'.serialize($accountname).'</code><br>'); }
                                        $accountname = 
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($accountname);
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.ex_accounts_list: fullname C: 
<code>'.serialize($accountname).'</code><br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: fullname C: 
<code>'.serialize($accountname).'</code><br>'); }
                                        // FINALLY we have a string we are 
going to display to the user that is the name of the account
                                        
$return_list[$next_pos]['display_string'] = '['.$this_acctnum.'] '.$accountname;

@@ -1878,8 +1715,8 @@
                                        $return_list[$next_pos]['delete_href'] 
= '<a href="'.$return_list[$next_pos]['delete_url'].'">'.lang('Delete').'</a>';
                                }
                        }
-                       if ($this->debug_set_prefs > 2) { echo 
'email.bopreferences.ex_accounts_list: returning $return_list[] : <pre>'; 
print_r($return_list); echo '</pre>'; }
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.ex_accounts_list: LEAVING, returning $return_list <br>'; }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: returning 
$return_list[] DUMP:', $return_list); }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.ex_accounts_list: LEAVING, returning 
$return_list <br>'); }
                        return $return_list;
                }

@@ -1891,12 +1728,12 @@
                */
                function get_first_empty_ex_acctnum()
                {
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.get_first_empty_ex_acctnum: ENTERING<br>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.get_first_empty_ex_acctnum: $GLOBALS[phpgw]->msg->extra_accounts 
dump<pre>'; print_r($GLOBALS['phpgw']->msg->extra_accounts); echo '</pre>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: 
ENTERING<br>'); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.get_first_empty_ex_acctnum: 
$GLOBALS[phpgw]->msg->extra_accounts DUMP:', 
$GLOBALS['phpgw']->msg->extra_accounts); }
                        $loops = count($GLOBALS['phpgw']->msg->extra_accounts);
                        if ($loops == 0)
                        {
-                               if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.get_first_empty_ex_acctnum: 
count($GLOBALS[phpgw]->msg->extra_accounts 
=['.serialize(count($GLOBALS['phpgw']->msg->extra_accounts)).']<br>'; }
+                               if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: 
count($GLOBALS[phpgw]->msg->extra_accounts 
=['.serialize(count($GLOBALS['phpgw']->msg->extra_accounts)).']<br>'); }
                                $first_empty_ex_acctnum = 1;
                        }
                        else
@@ -1907,10 +1744,10 @@
                                        $this_acctnum = 
$GLOBALS['phpgw']->msg->extra_accounts[$i]['acctnum'];
                                        $this_status = 
$GLOBALS['phpgw']->msg->extra_accounts[$i]['status'];
                                        // loop =0 *would* = acctnum 1 *if* 
acctnum slots are filled in order, they'd always be 1 apart
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.get_first_empty_ex_acctnum: in loop ['.$i.'] : status: 
['.$this_status.'] ; acctnum: ['.$this_acctnum.']<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: in loop 
['.$i.'] : status: ['.$this_status.'] ; acctnum: ['.$this_acctnum.']<br>'); }
                                        if ($this_status == 'empty')
                                        {
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email.bopreferences.get_first_empty_ex_acctnum: [status] == empty for 
acctnum ['.$this_acctnum.']<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: 
[status] == empty for acctnum ['.$this_acctnum.']<br>'); }
                                                $first_empty_ex_acctnum = 
(int)$this_acctnum;
                                                $did_get_acctnum = True;
                                                break;
@@ -1918,7 +1755,7 @@
                                        elseif ((int)($i+1) != 
(int)$this_acctnum)
                                        {
                                                $first_empty_ex_acctnum = 
(int)($i+1);
-                                               if ($this->debug_set_prefs > 1) 
{ echo 'email.bopreferences.get_first_empty_ex_acctnum: slots have an empty 
spot, unused $acctnum is ['.$first_empty_ex_acctnum.']<br>'; }
+                                               if ($this->debug_set_prefs > 1) 
{ $this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: slots 
have an empty spot, unused $acctnum is ['.$first_empty_ex_acctnum.']<br>'); }
                                                $did_get_acctnum = True;
                                                break;
                                        }
@@ -1929,10 +1766,10 @@
                                        $first_empty_ex_acctnum = 
count($GLOBALS['phpgw']->msg->extra_accounts);
                                        // since extra accounts are not zero 
based, add one to that count to get real next available
                                        $first_empty_ex_acctnum++;
-                                       if ($this->debug_set_prefs > 1) { echo 
'email.bopreferences.get_first_empty_ex_acctnum: no empty spaces 
extra_accounts[], advance to next int: $first_empty_ex_acctnum 
['.$first_empty_ex_acctnum.']<br>'; }
+                                       if ($this->debug_set_prefs > 1) { 
$this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: no empty 
spaces extra_accounts[], advance to next int: $first_empty_ex_acctnum 
['.$first_empty_ex_acctnum.']<br>'); }
                                }
                        }
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.get_first_empty_ex_acctnum: LEAVING, returning 
$first_empty_ex_acctnum ['.serialize($first_empty_ex_acctnum).']<br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.get_first_empty_ex_acctnum: LEAVING, 
returning $first_empty_ex_acctnum 
['.serialize($first_empty_ex_acctnum).']<br>'); }
                        return $first_empty_ex_acctnum;
                }

@@ -1944,9 +1781,9 @@
                */
                function obtain_ex_acctnum()
                {
-                       if ($this->debug_set_prefs > 0) { echo 'email: 
bopreferences.obtain_ex_acctnum: ENTERING<br>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.obtain_ex_acctnum: $GLOBALS[HTTP_POST_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_POST); echo '</pre>'; }
-                       if ($this->debug_set_prefs > 2) { echo 'email: 
bopreferences.obtain_ex_acctnum: $GLOBALS[HTTP_GET_VARS] dump<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_GET); echo '</pre>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email: bopreferences.obtain_ex_acctnum: ENTERING<br>'); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.obtain_ex_acctnum: 
$GLOBALS[HTTP_POST_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_POST); }
+                       if ($this->debug_set_prefs > 2) { 
$this->msg->dbug->out('email: bopreferences.obtain_ex_acctnum: 
$GLOBALS[HTTP_GET_VARS] DUMP:', $GLOBALS['phpgw']->msg->ref_GET); }
                        // get fromPOST or GET
                        $prelim_acctnum = '##NOTHING##';
                        if 
((isset($GLOBALS['phpgw']->msg->ref_POST['ex_acctnum'])
@@ -1975,7 +1812,7 @@
                        {
                                $final_acctnum = $prelim_acctnum;
                        }
-                       if ($this->debug_set_prefs > 0) { echo 
'email.bopreferences.obtain_ex_acctnum: LEAVING, returning $final_acctnum: 
['.serialize($final_acctnum).'] <br>'; }
+                       if ($this->debug_set_prefs > 0) { 
$this->msg->dbug->out('email.bopreferences.obtain_ex_acctnum: LEAVING, 
returning $final_acctnum: ['.serialize($final_acctnum).'] <br>'); }
                        return $final_acctnum;
                }


====================================================
Index: email/inc/class.bomessage.inc.php
diff -u email/inc/class.bomessage.inc.php:1.14 
email/inc/class.bomessage.inc.php:1.15
--- email/inc/class.bomessage.inc.php:1.14      Fri Mar 14 04:00:10 2003
+++ email/inc/class.bomessage.inc.php   Thu Dec 30 23:13:50 2004
@@ -26,14 +26,30 @@
                var $public_functions = array(
                        'message_data'          => True
                );
+               // Convience var REFERENCE to globals[phpgw]->msg
+               var $msg='##NOTHING##';
+
                var $preserve_no_fmt = True;
                //var $preserve_no_fmt = False;
                var $no_fmt='';

+               // maximum number of TO and CC addresses to show, too many will 
error message display
+               var $max_to_loops = 15;
+               var $max_cc_loops = 15;
+
+               // do we show both plain and enhanced (html, apple "enriched") 
parts of an alternative set
+               // or do we hide the simpler plain part of the pair
+               var $hide_alt_hide = True;
+               //var $hide_alt_hide = False;
+
                var $debug = 0;
                //var $debug = 2;
                //var $debug = 3;

+               // Special Debug data assembled about the message
+               var $show_debug_parts_summary=0;
+               //var $show_debug_parts_summary=1;
+
                var $debug_nav = 0;

                // prefs should fill this in with users preference
@@ -53,7 +69,7 @@
                @function bomessage
                @abtract *constructor*
                @discussion fills the "langs" vars including the "lang_warn" 
langs which are use to notify user
-               of some common "bad" message attachments or other bad content.
+               of some common "bad" message attachments or other bad content.
                */
                function bomessage()
                {
@@ -135,12 +151,21 @@
                        so that the lang files have something directly to match 
up to.
                        @author Angles
                        */
-                       $this->xi['lang_warn_has_iframe_maybe_klez'] = 
lang('warn_has_iframe_maybe_klez');
-                       $this->xi['lang_warn_script_tags'] = 
lang('warn_script_tags');
-                       $this->xi['lang_warn_b64_encoded_displayable'] = 
lang('warn_b64_encoded_displayable');
-                       $this->xi['lang_warn_attachment_only_mail'] = 
lang('warn_attachment_only_mail');
-                       $this->xi['lang_warn_attachment_name_dangerous'] = 
lang('warn_attachment_name_DANGEROUS');
-                       $this->xi['lang_warn_style_sheet'] = 
lang('warn_style_sheet');
+                       //$this->xi['lang_warn_has_iframe_maybe_klez'] = 
lang('warn_has_iframe_maybe_klez');
+                       //$this->xi['lang_warn_script_tags'] = 
lang('warn_script_tags');
+                       //$this->xi['lang_warn_b64_encoded_displayable'] = 
lang('warn_b64_encoded_displayable');
+                       //$this->xi['lang_warn_attachment_only_mail'] = 
lang('warn_attachment_only_mail');
+                       //$this->xi['lang_warn_attachment_name_dangerous'] = 
lang('warn_attachment_name_DANGEROUS');
+                       //$this->xi['lang_warn_style_sheet'] = 
lang('warn_style_sheet');
+                       // Reiner Jung recommends putting the whole phrase 
right here instead of the lang file
+                       // it seems to make it easier for the translator to see 
the these as an example to translate
+                       $this->xi['lang_warn_has_iframe_maybe_klez'] = 
lang('html messages with the IFRAME  tag may be KLEZ or other worm emails.');
+                       $this->xi['lang_warn_script_tags'] = lang(' a scrips 
tag block of code, javascript or otherwise, is in an inline html message. Not 
necessarily bad, but user may want to know. This is SCRIPT ... code ... SCRIPT 
blocks, not the "OnMouseOver"  stuff.');
+                       $this->xi['lang_warn_b64_encoded_displayable'] = 
lang('It is not RFC standard to base64 encode a part of a message that is NOT 
an attachment. NOTE this check is currently done after the message is already 
being viewed, it should probably stop the message from being automatically 
displayed, i.e. give a "show this" button instead.');
+                       $this->xi['lang_warn_attachment_only_mail'] = 
lang('There is no text or other part of the email to display to the user, all 
part(s) are attachments.');
+                       $this->xi['lang_warn_attachment_name_dangerous'] = 
lang('Message has an attachment that is some kind of script or exe file that 
Windows users should be warned not to click on it. These are filenames like 
attachments the end with the usual "bad stuff", such as bat, inf, pif, com, 
exe, reg, vbs, and scr');
+                       $this->xi['lang_warn_style_sheet'] = lang('This is 
really a visual template conflict issue. The phpGW template already has it own 
CSS, and style sheets are cascading, subsequent CSS can be inherited by the 
page and TOTALLY B0RK the look of the template theme. Or maybe not, only 
certain CSS tags are really capable of this such as the css BODY property, or 
the A (href) properties.');
+

                        if ($this->debug > 2) { echo 
'class.bomessage.*constructor* ('.__LINE__.'): langs put in $this->xi 
DUMP:<pre>'; print_r($this->xi); echo '</pre>'; }

@@ -158,12 +183,19 @@
                ui and bomessage classes is located here.
                */
                function message_data()
-               {
-                       if ($this->debug > 0) { echo 'ENTERING: 
email.bomessage.message_data'.'<br>'; }
-
+               {
                        // make sure we have msg object and a server stream
-                       $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('email.bomessage.message_data', 
$this->debug);
+                       $this->msg_bootstrap = 
CreateObject('email.msg_bootstrap');
+                       
//$this->msg_bootstrap->ensure_mail_msg_exists('email.bomessage.message_data('.__LINE__.')',
 $this->debug);
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('email.bomessage.message_data('.__LINE__.')');
+                       // we know we have msg object, now make convience 
reference
+                       if ($this->msg == '##NOTHING##')
+                       {
+                               $this->msg =& $GLOBALS['phpgw']->msg;
+                       }
+                       // now we can use msg object debug calls
+                       if ($this->debug > 0) { 
$this->msg->dbug->out('ENTERING: 
email.bomessage.message_data('.__LINE__.')'.'<br>'); }
+

                        // ---- BEGIN BOMESSAGE ----

@@ -246,6 +278,7 @@
                        $this->xi['mailsvr_supports_folders'] = 
$GLOBALS['phpgw']->msg->get_mailsvr_supports_folders();
                        if ($this->xi['mailsvr_supports_folders'])
                        {
+                               /*
                                $feed_args = Array();
                                $feed_args = Array(
                                        'mailsvr_stream'        => '',
@@ -259,6 +292,13 @@
                                        'first_line_txt'        => 
$this->xi['lang_move_this_message_into']
                                );
                                $this->xi['delmov_listbox'] = 
$GLOBALS['phpgw']->msg->all_folders_listbox($feed_args);
+                               */
+                               // UPDATE use the newer widgets high level 
function
+                               $my_cbox_widgets = 
CreateObject('email.html_widgets');
+                               $skip_fldball = array();
+                               $skip_fldball['acctnum'] = 
$GLOBALS['phpgw']->msg->get_acctnum();
+                               $skip_fldball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($GLOBALS['phpgw']->msg->get_arg_value('folder'));
+                               $this->xi['delmov_listbox'] = 
$my_cbox_widgets->all_folders_combobox('delmov', True, $skip_fldball, 
$this->xi['lang_move_this_message_into']);
                        }
                        else
                        {
@@ -275,10 +315,14 @@

                        // ----  General Information about The Message  -----
                        $msgball = 
$GLOBALS['phpgw']->msg->get_arg_value('msgball');
-                       if ($this->debug > 2) { echo 
'email.bomessage.message_data:  get_arg_value("msgball") dump: <pre>'; 
print_r($msgball); echo '</pre>'; }
+
+                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'):  processed 
msgball DUMP:', $msgball); }
                        $msg_struct = 
$GLOBALS['phpgw']->msg->phpgw_fetchstructure($msgball);
                        $msg_headers = 
$GLOBALS['phpgw']->msg->phpgw_header($msgball);

+                       if ($this->debug > 2) { 
$this->msg->dbug->out('class.bomessage.message_data('.__LINE__.'): $msg_struct 
DUMP:', $msg_struct);  }
+                       if ($this->debug > 2) { 
$this->msg->dbug->out('class.bomessage.message_data('.__LINE__.'): $msg_headers 
DUMP:', $msg_headers);  }
+
                        /*
                        // MOVED TO EVENT, TRIGGERED BY GETTING A BODY OR BODY 
PART
                        // CACHE NOTE: FLAGS: if this message we are about to 
read has flags saying it is UNREAD
@@ -296,10 +340,63 @@

                        $folder_info = array();
                        $folder_info = 
$GLOBALS['phpgw']->msg->get_folder_status_info();
-                       if ($this->debug > 2) { echo 
'email.bomessage.message_data:  get_folder_status_info() dump: <pre>'; 
print_r($folder_info); echo '</pre>'; }
+                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'):  
get_folder_status_info() DUMP:', $folder_info); }
                        $totalmessages = $folder_info['number_all'];

                        $subject = 
$GLOBALS['phpgw']->msg->get_subject($msg_headers,'');
+
+                       /*
+# begin GMT handling by "acros"
+#le quitamos el offset a los mensajes de correo electrnico.
+######
+$msg_date2=$msg_headers->date;
+$comma = strpos($msg_date2,',');
+
+                       if($comma)
+                       {
+                               $msg_date2 = substr($msg_date2,$comma + 2);
+                       }
+                       //echo 'Msg Date : '.$msg_date."<br>\n";
+                       $dta = array();
+                       $ta = array();
+
+                       $dta = explode(' ',$msg_date2);
+                       $ta = explode(':',$dta[3]);
+
+                       if(substr($dta[4],0,3) <> 'GMT')
+                       {
+                               $tzoffset = substr($dta[4],0,1);
+                               (int)$tzhours = substr($dta[4],1,2);
+                               (int)$tzmins = substr($dta[4],3,2);
+#echo"$ta[0] y $tzoffset";
+                               switch ($tzoffset)
+                               {
+                                       case '+':
+                                               (int)$ta[0] -= (int)$tzhours;
+                                               (int)$ta[1] -= (int)$tzmins;
+#echo"$ta[0]";
+                                               break;
+                                       case '-':
+                                               (int)$ta[0] += (int)$tzhours;
+                                               (int)$ta[1] += (int)$tzmins;
+                                               break;
+                               }
+                       }
+
+                       $new_time = 
mktime($ta[0],$ta[1],$ta[2],$GLOBALS['month_array'][strtolower($dta[1])],$dta[0],$dta[2])
 - ((60 * 60) * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tzoffset']));
+
+
+$new_time2=gmdate("D, d M Y H:m:s",$new_time)." GMT";
+$msg_headers->date = $new_time2;
+$msg_headers->udate = $new_time;
+#echo("<br>Hora cojonuda: $new_time2");
+#echo"udate $msg_headers->udate<br>";
+#echo"date $msg_headers->date<br>";
+#echo"$new_time<br>";
+#echo("estamos en bomessage 589<br>");
+# end GMT handling by "acros"
+                       */
+
                        $message_date = 
$GLOBALS['phpgw']->common->show_date($msg_headers->udate);

                        // addressbook needs to know what to return to, give it 
ALL VARS we can possibly want preserved
@@ -313,13 +410,21 @@
                                
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
                                .$this->no_fmt);

-                       if ($this->debug > 2) { echo 
'class.bomessage.message_data: $msg_struct DUMP:<pre>'; print_r($msg_struct); 
echo '</pre>';  }
                        address@hidden(0);

                        // ----  Special X-phpGW-Type Message Flag  -----
                        // this is used at least by the calendar for the 
notifications
                        $this->xi['application'] = '';
-                       $msgtype = 
$GLOBALS['phpgw']->msg->phpgw_get_flag('X-phpGW-Type');
+                       // THIS IS NOT CACHED DATA, only call this is 
session_cache_extreme is FALSE
+                       // or else we will connect even if we ALREADY HAVE THE 
BODY IN CACHE!!!
+                       if ($GLOBALS['phpgw']->msg->session_cache_extreme == 
True)
+                       {
+                               $msgtype = '';
+                       }
+                       else
+                       {
+                               $msgtype = 
$GLOBALS['phpgw']->msg->phpgw_get_flag('X-phpGW-Type');
+                       }
                        $this->xi['msgtype'] = $msgtype;

                        if (!empty($msgtype))
@@ -351,7 +456,8 @@
                        }

                        // ----  What Folder To Return To  -----
-                       $lnk_goback_folder = 
$GLOBALS['phpgw']->msg->href_maketag(
+                       //$lnk_goback_folder = 
$GLOBALS['phpgw']->msg->href_maketag(
+                       $lnk_goback_folder = 
$GLOBALS['phpgw']->msg->href_maketag_class(
                                $GLOBALS['phpgw']->link(
                                         '/index.php',
                                        'menuaction=email.uiindex.index'
@@ -361,7 +467,9 @@
                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')),
                                
//$GLOBALS['phpgw']->msg->get_folder_short($msgball['folder']));
-                               $nice_folder_name);
+                               $nice_folder_name,
+                               // his class name is reference to a css on the 
page itself, for the A item
+                               'c_backto');

                        // NOTE: msgnum int 0 is NOT to be confused with 
"empty" nor "boolean False"

@@ -369,7 +477,7 @@
                        // NOTE: the one arg for this function is only there to 
support the old, broken method
                        // in the event that the "get_msgball_list()" returns 
bogus data or is not available
                        $nav_data = 
$GLOBALS['phpgw']->msg->prev_next_navigation($folder_info['number_all']);
-                       if ($this->debug_nav > 2) { echo 
'email.bomessage.message_data: $nav_data[] dump <pre>: '; print_r($nav_data); 
echo '</pre>'; }
+                       if ($this->debug_nav > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): $nav_data[] 
DUMP:', $nav_data); }

                        // ----  "Go To Previous Message" Handling  -----
                        if ($nav_data['prev_msg'] != $not_set)
@@ -383,11 +491,13 @@
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
                                        .$this->no_fmt);
                                $prev_msg_img = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/arrow-left-24','_on'),$this->xi['lang_previous_message'],'','','0');
-
+                               $href_prev_msg = 
$GLOBALS['phpgw']->msg->href_maketag_class($prev_msg_link,'[&lt; 
'.$this->xi['lang_previous_message'].']', 'c_replybar');
                                $ilnk_prev_msg = 
$GLOBALS['phpgw']->msg->href_maketag($prev_msg_link,$prev_msg_img);
                        }
                        else
                        {
+                               // not a clickable link, just text saying "no 
prev message"
+                               $href_prev_msg = 
'['.$this->xi['lang_no_previous_message'].']';
                                $ilnk_prev_msg = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/arrow-left-no-24','_on'),$this->xi['lang_no_previous_message'],'','','0');

                        }
@@ -407,15 +517,22 @@
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
                                        .$this->no_fmt);
                                $next_msg_img = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/arrow-right-24','_on'),$this->xi['lang_next_message'],'','','0');
+                               $href_next_msg = 
$GLOBALS['phpgw']->msg->href_maketag_class($next_msg_link,'['.$this->xi['lang_next_message'].'
 &gt;]', 'c_replybar');
                                $ilnk_next_msg = 
$GLOBALS['phpgw']->msg->href_maketag($next_msg_link,$next_msg_img);
                        }
                        else
                        {
+                               // not a clickable link, just text saying "no 
next message"
+                               $href_next_msg = 
'['.$this->xi['lang__no_next_message'].']';
                                $ilnk_next_msg = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/arrow-right-no-24','_on'),$this->xi['lang__no_next_message'],'','','0');
                        }

                        //if ($this->debug > 0) { echo 'messages.php step4 
$nav_data[] $ilnk_next_msg: '.$ilnk_next_msg.'<br>'; }

+                       // these are HREF clickable text for prev and next text 
navigation
+                       $this->xi['href_prev_msg'] = $href_prev_msg;
+                       $this->xi['href_next_msg'] = $href_next_msg;
+                       // these are the clickable images for prev and next 
message navigation
                        $this->xi['ilnk_prev_msg'] = $ilnk_prev_msg;
                        $this->xi['ilnk_next_msg'] = $ilnk_next_msg;

@@ -481,6 +598,8 @@
                                {
                                        $from_personal = 
$GLOBALS['phpgw']->msg->decode_header_string($from->personal);
                                }
+                               // escape certain undesirable chars before HTML 
display
+                               $from_personal =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($from_personal);
                                // display "From" according to user preferences
                                if 
(($GLOBALS['phpgw']->msg->get_isset_pref('show_addresses'))
                                && 
($GLOBALS['phpgw']->msg->get_pref_value('show_addresses') != 'none')
@@ -488,6 +607,8 @@
                                {
                                        // user wants to see "personal" info 
AND the plain address, and we have both available to us
                                        $from_extra_info = ' ('.$from_plain.') 
';
+                                       // escape certain undesirable chars 
before HTML display
+                                       $from_extra_info =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($from_extra_info);
                                }
                                else
                                {
@@ -541,7 +662,13 @@
                        }
                        else
                        {
-                               for ($i = 0; $i < count($msg_headers->to); $i++)
+                               $to_loops = count($msg_headers->to);
+                               // begin test of Maz Num of To loop limitation
+                               if ($to_loops > $this->max_to_loops)
+                               {
+                                       $to_loops = $this->max_to_loops;
+                               }
+                               for ($i = 0; $i < $to_loops; $i++)
                                {
                                        $topeople = $msg_headers->to[$i];
                                        $to_plain = 
$topeople->mailbox.'@'.$topeople->host;
@@ -553,10 +680,14 @@
                                        {
                                                $to_personal = 
$GLOBALS['phpgw']->msg->decode_header_string($topeople->personal);
                                        }
+                                       // escape certain undesirable chars 
before HTML display
+                                       $to_personal =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($to_personal);
                                        if 
(($GLOBALS['phpgw']->msg->get_pref_value('show_addresses') != 'none')
                                        && ($to_personal != $to_plain))
                                        {
                                                $to_extra_info = ' 
('.$to_plain.') ';
+                                               // escape certain undesirable 
chars before HTML display
+                                               $to_extra_info =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($to_extra_info);
                                        }
                                        else
                                        {
@@ -603,7 +734,13 @@
                        $this->xi['cc_data_final'] = '';
                        if (isset($msg_headers->cc) && count($msg_headers->cc) 
> 0)
                        {
-                               for ($i = 0; $i < count($msg_headers->cc); $i++)
+                               $cc_loops = count($msg_headers->cc);
+                               // begin test of Maz Num of CC loop limitation
+                               if ($cc_loops > $this->max_cc_loops)
+                               {
+                                       $cc_loops = $this->max_cc_loops;
+                               }
+                               for ($i = 0; $i < $cc_loops; $i++)
                                {
                                        $ccpeople = $msg_headers->cc[$i];
                                        $cc_plain = 
@$ccpeople->mailbox.'@'address@hidden>host;
@@ -615,11 +752,15 @@
                                        {
                                                $cc_personal = 
$GLOBALS['phpgw']->msg->decode_header_string($ccpeople->personal);
                                        }
+                                       // escape certain undesirable chars 
before HTML display
+                                       $cc_personal =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($cc_personal);
                                        //if 
(($GLOBALS['phpgw_info']['user']['preferences']['email']['show_addresses'] != 
'none')
                                        if 
(($GLOBALS['phpgw']->msg->get_pref_value('show_addresses') != 'none')
                                        && ($cc_personal != $cc_plain))
                                        {
                                                $cc_extra_info = ' 
('.$cc_plain.') ';
+                                               // escape certain undesirable 
chars before HTML display
+                                               $cc_extra_info =  
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($cc_extra_info);
                                        }
                                        else
                                        {
@@ -671,8 +812,9 @@

                        // ---- Generate phpgw CUSTOM FLATTENED FETCHSTRUCTURE 
ARRAY  -----
                        $this->part_nice = Array();
+                       // NO NEED TO CACHE THIS DATA, NO CONTACT WITH 
MAILSERVER IS NEEDED FOR THIS DATA
                        $this->part_nice = 
$GLOBALS['phpgw']->msg->get_flat_pgw_struct($msg_struct);
-                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: $this->part_nice dump <pre>: '; 
print_r($this->part_nice); echo '</pre>'; }
+                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): 
$this->part_nice DUMP:', $this->part_nice); }


                        // ---- Attachments List Creation  -----
@@ -761,6 +903,7 @@
                                        
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start'));
+                       $href_reply = 
$GLOBALS['phpgw']->msg->href_maketag_class($reply_url, $this->xi['lang_reply'], 
'c_replybar');
                        $ilnk_reply = 
$GLOBALS['phpgw']->msg->href_maketag($reply_url, $reply_img);

                        $replyall_img = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/reply-all','_on'),$this->xi['lang_reply_all'],'','','0');
@@ -774,6 +917,7 @@
                                        
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start'));
+                       $href_replyall = 
$GLOBALS['phpgw']->msg->href_maketag_class($replyall_url, 
$this->xi['lang_reply_all'], 'c_replybar');
                        $ilnk_replyall = 
$GLOBALS['phpgw']->msg->href_maketag($replyall_url, $replyall_img);

                        $forward_img = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/forward','_on'),$this->xi['lang_forward'],'','','0');
@@ -788,6 +932,7 @@
                                        
.'&sort='.$GLOBALS['phpgw']->msg->get_arg_value('sort')
                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start'));
+                       $href_forward = 
$GLOBALS['phpgw']->msg->href_maketag_class($forward_url, 
$this->xi['lang_forward'], 'c_replybar');
                        $ilnk_forward = 
$GLOBALS['phpgw']->msg->href_maketag($forward_url, $forward_img);

                        $delete_img = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/delete-message','_on'),$this->xi['lang_delete'],'','','0');
@@ -801,6 +946,7 @@
                                        
.'&order='.$GLOBALS['phpgw']->msg->get_arg_value('order')
                                        
.'&start='.$GLOBALS['phpgw']->msg->get_arg_value('start')
                                        .$this->no_fmt);
+                       $href_delete= 
$GLOBALS['phpgw']->msg->href_maketag_class($delete_url, 
$this->xi['lang_delete'], 'c_replybar');
                        $ilnk_delete = 
$GLOBALS['phpgw']->msg->href_maketag($delete_url, $delete_img);

                        $this->xi['theme_font'] = 
$GLOBALS['phpgw_info']['theme']['font'];
@@ -808,17 +954,17 @@
                        $this->xi['reply_btns_text'] = 
$GLOBALS['phpgw_info']['theme']['em_folder_text'];
                        $this->xi['lnk_goback_folder'] = $lnk_goback_folder;
                        $this->xi['go_back_to'] = $this->xi['lang_go_back_to'];
+                       $this->xi['href_reply'] = $href_reply;
+                       $this->xi['href_replyall'] = $href_replyall;
+                       $this->xi['href_forward'] = $href_forward;
+                       $this->xi['href_delete'] = $href_delete;
                        $this->xi['ilnk_reply'] = $ilnk_reply;
                        $this->xi['ilnk_replyall'] = $ilnk_replyall;
                        $this->xi['ilnk_forward'] = $ilnk_forward;
                        $this->xi['ilnk_delete'] = $ilnk_delete;

                        // ---- DEBUG: Show Information About Each Part  -----
-                       // --- UPDATE THIS debug output (gotta be a better way) 
and move it somewhere else ---
-                       $show_debug_parts = False;
-                       //$show_debug_parts = True;
-
-                       if ($this->debug > 3)
+                       if ($this->show_debug_parts_summary > 0)
                        {
                                // what's the count in the array?
                                $max_parts = count($this->part_nice);
@@ -831,15 +977,26 @@
                                $msg_raw_headers = 
$GLOBALS['phpgw']->msg->htmlspecialchars_encode($msg_raw_headers);

                                $crlf = "\r\n";
-                               $msg_body_info = '<pre>' .$crlf;
+                               //$msg_body_info = '<pre>' .$crlf;
                                $msg_body_info .= 'Top Level Headers:' .$crlf;
                                $msg_body_info .= $msg_raw_headers .$crlf;
                                $msg_body_info .= $crlf;

+                               // what is the deepest level debth
+                               $deepest_level = 0;
+                               for ($i = 0; $i < count($this->part_nice); $i++)
+                               {
+                                       if 
($this->part_nice[$i]['ex_level_debth'] > $deepest_level)
+                                       {
+                                               $deepest_level = 
$this->part_nice[$i]['ex_level_debth'];
+                                       }
+                               }
+
                                $msg_body_info .= 'This message has 
'.$max_parts.' part(s)' .$crlf;
                                $msg_body_info .= 'deepest_level: 
'.$deepest_level .$crlf;
                                $msg_body_info .= 'Array Keys: 
'.$GLOBALS['phpgw']->msg->array_keys_str($this->part_nice) .$crlf;
                                $msg_body_info .= $crlf;
+
                                for ($i = 0; $i < count($this->part_nice); $i++)
                                {
                                        //$msg_body_info .= 'Information for 
primary part number '.$i .$crlf;
@@ -930,9 +1087,11 @@
                                        $msg_body_info .= $crlf;
                                }

-                               $msg_body_info .= '</pre>' .$crlf;
-                               $this->xi['msg_body_info'] = $msg_body_info;
-                               
//$GLOBALS['phpgw']->template->parse('V_debug_parts','B_debug_parts');
+                               //$msg_body_info .= '</pre>' .$crlf;
+                               //$this->xi['msg_body_info'] = $msg_body_info;
+                               $this->xi['msg_body_info'] = '';
+                               
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): assembled 
debug data $msg_body_info DUMP:', $msg_body_info);
+
                        }
                        else
                        {
@@ -940,6 +1099,7 @@
                                $this->xi['msg_body_info'] = '';
                        }

+
                        // -----  Message_Display Template Handles it from here 
 -------
                        $this->xi['theme_font'] = 
$GLOBALS['phpgw_info']['theme']['font'];
                        $this->xi['theme_th_bg'] = 
$GLOBALS['phpgw_info']['theme']['th_bg'];
@@ -1015,7 +1175,8 @@

                        // Force Echo Out Unformatted Text for email with 1 
part which is a large text messages (in bytes) , such as a system report from 
cron
                        // php (4.0.4pl1 last tested) and some imap servers 
(courier and uw-imap are confirmed) will time out retrieving this type of 
message
-                       $force_echo_size = 20000;
+                       //$force_echo_size = 20000;
+                       $force_echo_size = 60000;



@@ -1058,8 +1219,8 @@
                        $count_part_nice = count($this->part_nice);
                        for ($i = 0; $i < $count_part_nice; $i++)
                        {
-                               if ($this->debug > 2) { echo 
'email.bomessage.message_data: disp loop: '.($i+1).' of 
'.$count_part_nice.'<br>'; }
-                               if ($this->debug > 3) { echo 
'email.bomessage.message_data: d_loop: $this->part_nice[$i] DUMP<pre>'; 
print_r($this->part_nice[$i]); echo '</pre>'; }
+                               if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): disp loop: 
'.($i+1).' of '.$count_part_nice.'<br>'); }
+                               if ($this->debug > 3) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: 
$this->part_nice[$i] DUMP:', $this->part_nice[$i]); }
                                // Do We Break out of this Loop Block
                                if ($done_processing)
                                {
@@ -1080,7 +1241,7 @@
                                &&  (($this->part_nice[$i]['m_description'] == 
'container')
                                || ($this->part_nice[$i]['m_description'] == 
'packagelist')) )
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: "Mime-Ignorant Email Server", Num Parts 
is 1 AND part is a container OR packagelist <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: 
"Mime-Ignorant Email Server", Num Parts is 1 AND part is a container OR 
packagelist <br>'); }

                                        // ====  MIME IGNORANT SERVER  ====
                                        $title_text = '&nbsp;Mime-Ignorant 
Email Server: ';
@@ -1142,7 +1303,7 @@
                                && (($this->part_nice[$i]['m_part_num_mime'] == 
1) || ((string)$this->part_nice[$i]['m_part_num_mime'] == '1.1'))
                                && ((int)$this->part_nice[$i]['bytes'] > 
$force_echo_size))
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: ECHO OUT: part meets five criteria 
<br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: ECHO 
OUT: part meets five criteria <br>'); }

                                        $title_text = 
'&nbsp;'.$this->xi['lang_message'].': ';
                                        $display_str = 
$this->xi['lang_keywords'].': '.$this->part_nice[$i]['m_keywords'].' - 
'.$GLOBALS['phpgw']->msg->format_byte_size($this->part_nice[$i]['bytes'])
@@ -1191,8 +1352,10 @@
                                }
                                elseif (($this->part_nice[$i]['m_description'] 
== 'presentable')
                                && (stristr($this->part_nice[$i]['m_keywords'], 
'HTML')))
+                               // enriched = part of APPLE MAIL multipart / 
alternative subpart where the html part usually is
+                               // HOWEVER enriched is not complete html so it 
will not render anything special in a browser so we can NOT treat enriched like 
html
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: part is HTML, presentable <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is HTML, presentable <br>'); }

                                        // get the body
                                        $this_msgball = $msgball;
@@ -1231,17 +1394,21 @@

                                        // ---- HTML Related Parts Handling  
----
                                        $parent_idx = 
$this->part_nice[$i]['ex_parent_flat_idx'];
-                                       $msg_raw_headers = 
$GLOBALS['phpgw']->msg->phpgw_fetchheader($msgball);
                                        // NEEDS UPDATING !!!!!
-                                       $ms_related_str = 'X-MimeOLE: Produced 
By Microsoft MimeOLE';
+                                       //$msg_raw_headers = 
$GLOBALS['phpgw']->msg->phpgw_fetchheader($msgball);
+                                       //$ms_related_str = 'X-MimeOLE: 
Produced By Microsoft MimeOLE';
+                                       // NEW: use $msg_struct object to check 
for top level "RELATED" subtype

                                        // ---- Replace "Related" part's ID 
with a mime reference link
                                        // this for the less-standard 
multipart/RELATED subtype ex. Outl00k's Stationary email
                                        // update: now common in Ximian
                                        if 
(($this->part_nice[$parent_idx]['m_html_related_kids'])
-                                       || (stristr($msg_raw_headers, 
$ms_related_str)))
+                                       //|| (stristr($msg_raw_headers, 
$ms_related_str)))
+                                       //|| (stristr($msg_struct->subtype, 
'RELATED'))
+                                       //|| 
(stristr($this->part_nice[$parent_idx]['subtype'], 'RELATED')))
+                                       )
                                        {
-                                               if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: * part is RELATED, HTML, presentable 
<br>'; }
+                                               if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: * 
part is RELATED, HTML, presentable <br>'); }
                                                // typically it's the NEXT mime 
part that should be inserted into this one
                                                for ($rel = $i+1; $rel < 
count($this->part_nice)+1; $rel++)
                                                {
@@ -1284,7 +1451,7 @@

                                                if 
(preg_match("/<iframe.*>.*<\/iframe>/ismx", $dsp))
                                                {
-                                                       if ($this->debug > 2) { 
echo 'email.bomessage.message_data: d_loop: part ** HAS IFRAME <br>'; }
+                                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
** HAS IFRAME <br>'); }
                                                        
//$this->part_nice[$i]['d_threat_level'] .= 'warn_HAS_IFRAME_maybe_KLEZ ';
                                                        
$this->part_nice[$i]['d_threat_level'] .= 
$this->xi['lang_warn_has_iframe_maybe_klez'].' ';
                                                }
@@ -1308,7 +1475,10 @@
                                                // if we replaced id(s) with 
href'(s) above (RELATED) then
                                                // stuff the modified html in a 
hidden var, submit it then echo it back
                                                if 
(($this->part_nice[$parent_idx]['m_html_related_kids'])
-                                               || (stristr($msg_raw_headers, 
$ms_related_str)))
+                                               //|| (stristr($msg_raw_headers, 
$ms_related_str)))
+                                               //|| 
(stristr($msg_struct->subtype, 'RELATED'))
+                                               //|| 
(stristr($this->part_nice[$parent_idx]['subtype'], 'RELATED')))
+                                               )
                                                {
                                                        // -- View As HTML 
Button With Special HTML RELATED handling

@@ -1407,9 +1577,23 @@
                                        $this->part_nice[$i]['message_body'] = 
"$dsp";
                                        
//$GLOBALS['phpgw']->template->parse('V_display_part','B_display_part', True);
                                }
+                               elseif (($this->part_nice[$i]['m_description'] 
== 'presentable')
+                               && (stristr($this->part_nice[$i]['m_keywords'], 
'alt_hide'))
+                               && ($this->hide_alt_hide == True))
+                               {
+                                       // is this a multipart alternative set, 
and this is the plain part, and do not want to show it
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is presentable BUT it is alt_hide so we do NOT want to show it <br>'); }
+
+                                       // ----  DISPLAY INSTRUCTIONS  ----
+                                       $this->part_nice[$i]['d_instructions'] 
= 'skip';
+                                       // is this necessary here?
+                                       $this->part_nice[$i]['d_processed_as'] 
= 'empty_part';
+                                       // LOOP CONTROL
+                                       $done_processing = False;
+                               }
                                elseif ($this->part_nice[$i]['m_description'] 
== 'presentable')
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: part is presentable (non-html) <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is presentable (non-html) <br>'); }

                                        // ----- get the part from the server
                                        $this_msgball = $msgball;
@@ -1555,9 +1739,23 @@
                                                $done_processing = False;
                                        }
                                }
+                               elseif (($this->part_nice[$i]['m_description'] 
== 'presentable/image')
+                               && (stristr($this->part_nice[$i]['m_keywords'], 
'alt_hide'))
+                               && ($this->hide_alt_hide == True))
+                               {
+                                       // is this a multipart alternative set, 
and this is the plain part, and do not want to show it
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is presentable IMAGE BUT it is alt_hide because it is html related to a parent 
so we do NOT want to show it again<br>'); }
+
+                                       // ----  DISPLAY INSTRUCTIONS  ----
+                                       $this->part_nice[$i]['d_instructions'] 
= 'skip';
+                                       // is this necessary here?
+                                       $this->part_nice[$i]['d_processed_as'] 
= 'empty_part';
+                                       // LOOP CONTROL
+                                       $done_processing = False;
+                               }
                                elseif ($this->part_nice[$i]['m_description'] 
== 'presentable/image')
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: part is presentable image <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is presentable image <br>'); }

                                        $title_text = 
$this->xi['lang_section'].': '.$this->part_nice[$i]['m_part_num_mime'];
                                        $display_str = 
$GLOBALS['phpgw']->msg->decode_header_string($this->part_nice[$i]['ex_part_name'])
@@ -1579,12 +1777,12 @@
                                }
                                elseif ($this->part_nice[$i]['m_description'] 
== 'attachment')
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: part is attachment <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is attachment <br>'); }

                                        // if this is a 1 part message with 
only this attachment, WARN
                                        if (count($this->part_nice) == 1)
                                        {
-                                               if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: * WARN message has only 1 part and it is 
an attachment <br>'; }
+                                               if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: * 
WARN message has only 1 part and it is an attachment <br>'); }
                                                
//$this->part_nice[$i]['d_threat_level'] .= 'warn_attachment_only_mail ';
                                                
$this->part_nice[$i]['d_threat_level'] .= 
$this->xi['lang_warn_attachment_only_mail'].' ';
                                        }
@@ -1592,7 +1790,7 @@
                                        // warn for typically BAD attachments 
bat, inf, pif, con, reg, vbs, scr
                                        if 
(preg_match('/^.*\.(bat|inf|pif|com|exe|reg|vbs|scr)$/', 
$this->part_nice[$i]['ex_part_name']))
                                        {
-                                               if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: * WARN attachment has NEFARIOUS filename 
extension, ex_part_name: '.$this->part_nice[$i]['ex_part_name'].'<br>'; }
+                                               if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: * 
WARN attachment has NEFARIOUS filename extension, ex_part_name: 
'.$this->part_nice[$i]['ex_part_name'].'<br>'); }
                                                
//$this->part_nice[$i]['d_threat_level'] .= 'warn_attachment_name_DANGEROUS ';
                                                
$this->part_nice[$i]['d_threat_level'] .= 
$this->xi['lang_warn_attachment_name_dangerous'].' ';
                                        }
@@ -1622,7 +1820,7 @@
                                elseif (($this->part_nice[$i]['m_description'] 
!= 'container')
                                && ($this->part_nice[$i]['m_description'] != 
'packagelist'))
                                {
-                                       if ($this->debug > 2) { echo 
'email.bomessage.message_data: d_loop: part is ERROR - unknown <br>'; }
+                                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'): d_loop: part 
is ERROR - unknown <br>'); }

                                        // if we get here then we've got some 
kind of error, all things we know about are handle above
                                        $title_text = 
$this->xi['lang_section'].': '.$this->part_nice[$i]['m_part_num_mime'];
@@ -1687,7 +1885,7 @@

                        // DO NOT end request yet because the "echo_out" part 
(if exists) will require this connection
                        //$GLOBALS['phpgw']->msg->end_request();
-                       if ($this->debug > 2) { echo 
'email.bomessage.message_data:  $this->part_nice (With Instructions) dump: 
<pre>'; print_r($this->part_nice); echo '</pre>'; }
+                       if ($this->debug > 2) { 
$this->msg->dbug->out('email.bomessage.message_data('.__LINE__.'):  
$this->part_nice (With Instructions) DUMP:', $this->part_nice); }

                }
        }

====================================================
Index: email/inc/class.bofolder.inc.php
diff -u email/inc/class.bofolder.inc.php:1.8 
email/inc/class.bofolder.inc.php:1.9
--- email/inc/class.bofolder.inc.php:1.8        Fri Mar 14 04:00:10 2003
+++ email/inc/class.bofolder.inc.php    Thu Dec 30 23:13:50 2004
@@ -3,7 +3,7 @@
        * AngleMail - email BO Class    for Folder Actions and List Display     
        *
        * http://www.anglemail.org                                              
        *
        * Written by Angelo (Angles) Puglisi <address@hidden>           *
-       * Copyright 2001, 2002 Angelo (Angles) Puglisi                          
*
+       * Copyright 2001, 2003 Angelo (Angles) Puglisi                          
*
        * --------------------------------------------                          
                        *
        *  This program is free software; you can redistribute it and/or modify 
it              *
        *  under the terms of the GNU General Public License as published by 
the        *
@@ -25,7 +25,10 @@
                // use the cachable function or the non-cachable status function
                var $use_cachable_status = True;
                //var $use_cachable_status = False;
+
                var $debug = 0;
+               //var $debug = 3;
+
                var $xi;

                function bofolder()
@@ -94,6 +97,9 @@
                                {
                                        $source_fldball = 
$GLOBALS['phpgw']->msg->get_arg_value('source_fldball');
                                        $target_fldball = 
$GLOBALS['phpgw']->msg->get_arg_value('target_fldball');
+                                       if ($this->debug > 1) { echo 
'email.bofolder.folder_action('.__LINE__.'): we will delete, rename, or create 
a folder; ->msg->get_arg_value("action") is 
['.$GLOBALS['phpgw']->msg->get_arg_value('action').']'.'<br>'; }
+                                       if ($this->debug > 2) { echo 
'email.bofolder.folder_action('.__LINE__.'): $source_fldball DUMP<pre>'; 
print_r($source_fldball); echo '<pre>'; }
+                                       if ($this->debug > 2) { echo 
'email.bofolder.folder_action('.__LINE__.'): $target_fldball DUMP<pre>'; 
print_r($target_fldball); echo '<pre>'; }

                                        //  ----  Establish Email Server 
Connectivity Conventions  ----
                                        $server_str = 
$GLOBALS['phpgw']->msg->get_arg_value('mailsvr_callstr');
@@ -141,7 +147,12 @@
                                        }

                                        // add server string to target folder
-                                       $target_fldball['folder'] = 
$server_str.$target_fldball['folder'];
+                                       //$target_fldball['folder'] = 
$server_str.$target_fldball['folder'];
+                                       //$target_fldball['folder'] = 
$target_fldball['folder'];
+                                       $re_encoded = 
$GLOBALS['phpgw']->msg->prep_folder_out($target_fldball['folder']);
+                                       $target_fldball['folder'] = $re_encoded;
+
+                                       if ($this->debug > 2) { echo 
'email.bofolder.folder_action('.__LINE__.'): processed $target_fldball 
DUMP<pre>'; print_r($target_fldball); echo '<pre>'; }

                                        // NOTE the dcom class will set a flag 
indicating a folder list change, ->dcom->folder_list_changed=True
                                        // function ->msg->get_folder_list()  
checks for this flag to know when to expire cached folder list and get a new one
@@ -152,38 +163,92 @@
                                        if 
(($GLOBALS['phpgw']->msg->get_arg_value('action') == 'create')
                                        || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'create_expert'))
                                        {
-                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_createmailbox($target_fldball);
+                                               if ($this->debug > 1) { echo 
'email.bofolder.folder_action('.__LINE__.'): calling 
->phpgw_createmailbox_ex($target_fldball) DUMP<pre>'; print_r($target_fldball); 
echo '<pre>'; }
+                                               //$success = 
$GLOBALS['phpgw']->msg->phpgw_createmailbox($target_fldball);
+                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_createmailbox_ex($target_fldball);
+                                               // UPDATE: use new 
phpgw_createmailbox_ex, it wants NO server str, and a urlENcoded foldername
+                                               //$no_server_str = 
str_replace($server_str, '', $target_fldball['folder']);
+                                               //$re_encoded = 
$GLOBALS['phpgw']->msg->prep_folder_out($no_server_str);
+                                               //$target_fldball['folder'] = 
$re_encoded;
+                                               //if ($this->debug > 1) { echo 
'email.bofolder.folder_action('.__LINE__.'): calling 
->phpgw_createmailbox_ex($target_fldball) DUMP<pre>'; print_r($target_fldball); 
echo '<pre>'; }
+                                               //$success = 
$GLOBALS['phpgw']->msg->phpgw_createmailbox_ex($target_fldball);
                                        }
                                        elseif 
(($GLOBALS['phpgw']->msg->get_arg_value('action') == 'delete')
                                        || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'delete_expert'))
                                        {
-                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_deletemailbox($target_fldball);
+                                               //$success = 
$GLOBALS['phpgw']->msg->phpgw_deletemailbox($target_fldball);
+                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_deletemailbox_ex($target_fldball);
                                        }
                                        elseif 
(($GLOBALS['phpgw']->msg->get_arg_value('action') == 'rename')
                                        || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'rename_expert'))
                                        {
                                                // 
phpgw->msg->get_arg_value('source_folder') is taken directly from the listbox, 
so it *should* be official long name already
                                                // but it does need to be 
prep'd in because we prep out the foldernames put in that listbox
-                                               $source_preped = 
$GLOBALS['phpgw']->msg->prep_folder_in($source_fldball['folder']);
-                                               $source_fldball['folder'] = 
$source_preped;
+                                               //$source_preped = 
$GLOBALS['phpgw']->msg->prep_folder_in($source_fldball['folder']);
+                                               //$source_fldball['folder'] = 
$source_preped;
                                                // add server string to source 
folder
-                                               $source_fldball['folder'] = 
$server_str.$source_fldball['folder'];
-                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_renamemailbox($source_fldball, $target_fldball);
+                                               //$source_fldball['folder'] = 
$server_str.$source_fldball['folder'];
+                                               //$success = 
$GLOBALS['phpgw']->msg->phpgw_renamemailbox($source_fldball, $target_fldball);
+                                               $src_re_encoded = 
$GLOBALS['phpgw']->msg->prep_folder_out($source_fldball['folder']);
+                                               $source_fldball['folder'] = 
$src_re_encoded;
+                                               $success = 
$GLOBALS['phpgw']->msg->phpgw_renamemailbox_ex($source_fldball, 
$target_fldball);
                                        }

                                        // Result Message
+                                       // we are not sure which folder will 
actually exists, new or old, so we can not really use "prep_folder_in" unless 
we check
+                                       if (isset($target_fldball['folder']))
+                                       {
+                                               if 
($GLOBALS['phpgw']->msg->prep_folder_in($target_fldball['folder']))
+                                               {
+                                                       $target_folder_decoded 
= $GLOBALS['phpgw']->msg->prep_folder_in($target_fldball['folder']);
+                                               }
+                                               elseif 
(urldecode($target_fldball['folder']))
+                                               {
+                                                       $target_folder_decoded 
= urldecode($target_fldball['folder']);
+                                               }
+                                               else
+                                               {
+                                                       $target_folder_decoded 
= lang('Unable to get target folder name');
+                                               }
+                                       }
+                                       if (isset($source_fldball['folder']))
+                                       {
+                                               if 
($GLOBALS['phpgw']->msg->prep_folder_in($source_fldball['folder']))
+                                               {
+                                                       $source_folder_decoded 
= $GLOBALS['phpgw']->msg->prep_folder_in($source_fldball['folder']);
+                                               }
+                                               elseif 
(urldecode($source_fldball['folder']))
+                                               {
+                                                       $source_folder_decoded 
= urldecode($source_fldball['folder']);
+                                               }
+                                               else
+                                               {
+                                                       $source_folder_decoded 
= lang('Unable to get source folder name');
+                                               }
+                                       }
+
                                        if 
(($GLOBALS['phpgw']->msg->get_arg_value('action') == 'rename')
                                        || 
($GLOBALS['phpgw']->msg->get_arg_value('action') == 'rename_expert'))
                                        {
                                                $action_report =
-                                                       
$GLOBALS['phpgw']->msg->get_arg_value('action') .' '.lang('folder').' 
&quot;'.htmlspecialchars($source_fldball['folder']).'&quot; '
-                                                       .lang('to').' 
&quot;'.htmlspecialchars($target_fldball['folder']) .'&quot; '
+                                                       
'<em>'.$GLOBALS['phpgw']->msg->get_arg_value('action') .' 
'.lang('folder').'</em>'
+                                                       .'<br>'
+                                                       
.htmlspecialchars($source_folder_decoded)
+                                                       .'<br>'
+                                                       
.'<em>'.lang('to').'</em>'
+                                                       .'<br>'
+                                                       
.htmlspecialchars($target_folder_decoded)
+                                                       .'<br>'
                                                        .lang('result').' : ';
                                        }
                                        else
                                        {
-                                               $action_report = 
$GLOBALS['phpgw']->msg->get_arg_value('action').' '.lang('folder').' 
&quot;'.htmlspecialchars($target_fldball['folder']).'&quot; '
-                                               .lang('result').' : ';
+                                               $action_report =
+                                                       
'<em>'.$GLOBALS['phpgw']->msg->get_arg_value('action').' 
'.lang('folder').'</em>'
+                                                       .'<br>'
+                                                       
.htmlspecialchars($target_folder_decoded)
+                                                       .'<br>'
+                                                       .lang('result').' : ';
                                        }
                                        // did it work or not
                                        if ($success)

====================================================
Index: email/inc/class.boindex.inc.php
diff -u email/inc/class.boindex.inc.php:1.30 
email/inc/class.boindex.inc.php:1.31
--- email/inc/class.boindex.inc.php:1.30        Fri Mar 14 04:00:10 2003
+++ email/inc/class.boindex.inc.php     Thu Dec 30 23:13:50 2004
@@ -73,7 +73,9 @@
                                'lang_total'            => lang('Total'),
                                'lang_total2'           => lang('Total 
Messages'),
                                'lang_size2'            => lang('Folder Size'),
-                               'stats_to_txt'          => lang('to'),
+                               //'stats_to_txt'                => lang('to'),
+                               // ralfbecker: this is not the word in other 
lang's as the other lang('to')'s
+                               'stats_to_txt'          => '-',
                                'lang_to'                       => lang('to'),
                                'lang_get_size'         => lang('get size'),
                                'lang_date'                     => lang('date'),
@@ -82,7 +84,12 @@
                                'lang_empty_folder'     => lang('this folder is 
empty'),
                                'lang_delete'           => lang('delete'),
                                'mlist_attach_txt'      => lang('file'),
-                               'lang_inbox'            => lang('INBOX')
+                               'lang_inbox'            => lang('INBOX'),
+                               'lang_flagged'          => lang('flagged'),
+                               'lang_answered'         => lang('answered'),
+                               'lang_draft'            => lang('draft'),
+                               'lang_deleted'          => lang('deleted'),
+                               'lang_important'                => 
lang('important')

                        );
                        // put these into $this->xi[] array
@@ -604,6 +611,7 @@
                                $this->xi['ctrl_bar_current_acctnum'] = 'extra 
'.(string)$GLOBALS['phpgw']->msg->get_acctnum();
                        }

+                       /*
                        // DEPRECIATED
                        $this->xi['ctrl_bar_acct_0_link'] = 
$GLOBALS['phpgw']->link(
                                                                '/index.php',
@@ -627,7 +635,7 @@
                                                                .'&order='
                                                                .'&start=');
                        $this->xi['ctrl_bar_acct_1_link'] = '<a 
href="'.$this->xi['ctrl_bar_acct_1_link'].'">'.'goto extra 1'.'</a>';
-
+                       */
                        $this->xi['ctrl_bar_back1'] = 
$GLOBALS['phpgw_info']['theme']['row_on'];

                        $sort_selected = Array(
@@ -766,7 +774,11 @@
                        // are we IN THE SENT folder or not
                        //if (  
$GLOBALS['phpgw']->msg->get_folder_short($GLOBALS['phpgw']->msg->get_arg_value('folder'))
                        // != 
$GLOBALS['phpgw']->msg->get_folder_short($GLOBALS['phpgw']->msg->get_pref_value('sent_folder_name')))
-                       // try this new core function
+                       // UPDATE use this new core function
+                       // NOTE how to do the querey we need a folder name 
"prepped out" i.e. urlencoded
+                       // and also note that for some backwards reason the arg 
"folder" is one of the only times a folder name is stored "prepped in", this is 
a grandfathered in situation
+                       // NOTE: this common_folder_is querey for "Sent" folder 
can not be true unless user has pref "Use Sent Folder" set to True!
+                       // i.e. a folder named "Sent" is not THE sent folder 
unless the prefs say so
                        $querey_fldball = array();
                        $querey_fldball['acctnum'] = 
$GLOBALS['phpgw']->msg->get_acctnum();
                        $querey_fldball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($GLOBALS['phpgw']->msg->get_arg_value('folder'));
@@ -797,23 +809,36 @@
                        $this->xi['attach_img'] = 
$GLOBALS['phpgw']->common->image_on('email','attach','_on');
                        $this->xi['check_image'] = 
$GLOBALS['phpgw']->common->image_on('email','check','_on');
                        //$this->xi['mlist_attach'] = '<div 
align="right">'.'<img src="'.$this->xi['attach_img'].'" 
alt="'.$this->xi['mlist_attach_txt'].'">'.'</div>';
-                       $this->xi['mlist_attach'] = '<img 
src="'.$this->xi['attach_img'].'" alt="'.$this->xi['mlist_attach_txt'].'">';
+                       $this->xi['mlist_attach'] = '<img 
src="'.$this->xi['attach_img'].'" title="'.$this->xi['mlist_attach_txt'].'" 
alt="'.$this->xi['mlist_attach_txt'].'">';
                        $this->xi['flagged_img'] =
                                        '<img src="'
                                        
.$GLOBALS['phpgw']->common->image_on('email','flag-for-followup-16','_on')
-                                       .'" 
alt="'.$this->xi['FIXME_flagged'].'">';
+                                       .'" 
title="'.$this->xi['lang_flagged'].'"'
+                                       .'" 
alt="'.$this->xi['lang_flagged'].'">';
                        $this->xi['answered_img'] =
                                        '<img src="'
                                        
.$GLOBALS['phpgw']->common->image_on('email','replied','_on')
-                                       .'" 
alt="'.$this->xi['FIXME_answered'].'">';
+                                       .'" 
title="'.$this->xi['lang_answered'].'"'
+                                       .'" 
alt="'.$this->xi['lang_answered'].'">';
                        $this->xi['draft_img'] =
                                        '<img src="'
                                        
.$GLOBALS['phpgw']->common->image_on('email','regular_draft','_on')
-                                       .'" 
alt="'.$this->xi['FIXME_draft'].'">';
+                                       .'" title="'.$this->xi['lang_draft'].'"'
+                                       .'" alt="'.$this->xi['lang_draft'].'">';
                        $this->xi['deleted_img'] =
                                        '<img src="'
                                        
.$GLOBALS['phpgw']->common->image_on('email','deleted','_on')
-                                       .'" 
alt="'.$this->xi['FIXME_deleted'].'">';
+                                       .'" 
title="'.$this->xi['lang_deleted'].'"'
+                                       .'" 
alt="'.$this->xi['lang_deleted'].'">';
+                       /*
+                       // FUTURE USE: MS mail puts "important" indicator in 
the message headers
+                       // note do we have an image for this yet?
+                       $this->xi['important_img'] =
+                                       '<img src="'
+                                       
.$GLOBALS['phpgw']->common->image_on('email','important','_on')
+                                       .'" 
title="'.$this->xi['lang_important'].'"'
+                                       .'" 
alt="'.$this->xi['lang_important'].'">';
+                       */

                        // loop thru the messages and get the data that the UI 
will display
                        if ($this->xi['folder_info']['number_all'] == 0)
@@ -861,6 +886,7 @@
                        $this->xi['frm_delmov_name'] = 'delmov';
                        if ($this->xi['mailsvr_supports_folders'])
                        {
+                               /*
                                $feed_args = Array();
                                $feed_args = Array(
                                        'mailsvr_stream'        => '',
@@ -874,26 +900,31 @@
                                        'first_line_txt'        => lang('move 
selected messages into')
                                );
                                $this->xi['delmov_listbox'] = 
$GLOBALS['phpgw']->msg->all_folders_listbox($feed_args);
+                               */
+                               // UPDATE use the newer widgets high level 
function
+                               $my_widgets = 
CreateObject('email.html_widgets');
+                               $skip_fldball = array();
+                               $skip_fldball['acctnum'] = 
$GLOBALS['phpgw']->msg->get_acctnum();
+                               $skip_fldball['folder'] = 
$GLOBALS['phpgw']->msg->prep_folder_out($GLOBALS['phpgw']->msg->get_arg_value('folder'));
+                               $this->xi['delmov_listbox'] = 
$my_widgets->all_folders_combobox('delmov', True, $skip_fldball);
                        }
                        else
                        {
                                $this->xi['delmov_listbox'] = '&nbsp;';
                        }
-                       $delmov_text = lang('Delete');
-                       $delmov_image = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/trash-'.$this->icon_size,'_on'),$delmov_text,'','','0');
-                       $this->xi['delmov_image'] = $delmov_image;
-                       //$delmov_image = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->common->image_on('email',$icon_theme.'-trash-'.$icon_size,'_on'),$delmov_text,'','','0');
-                       //$delmov_image = 
$GLOBALS['phpgw']->msg->img_maketag($this->xi['image_dir'].'/'.$this->icon_theme.'-trash-'.$this->icon_size.'.gif',$this->xi['delmov_text'],'','','0');
+                       $this->xi['delmov_image'] = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->msg->_image_on('email',$this->icon_theme.'/trash-'.$this->icon_size,'_on'),$this->xi['lang_delete'],'','','0');
+                       //$this->xi['delmov_image'] = 
$GLOBALS['phpgw']->msg->img_maketag($GLOBALS['phpgw']->common->image_on('email',$icon_theme.'-trash-'.$icon_size,'_on'),$this->xi['lang_delete'],'','','0');
+                       //$this->xi['delmov_image'] = 
$GLOBALS['phpgw']->msg->img_maketag($this->xi['image_dir'].'/'.$this->icon_theme.'-trash-'.$this->icon_size.'.gif',$this->xi['lang_delete'],'','','0');
                        $delmov_onclick = "javascript:do_action('delall')";
                        switch 
($GLOBALS['phpgw']->msg->get_pref_value('button_type',$acctnum)){
                                case 'text':
-                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$delmov_text.'</a>';
+                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$this->xi['lang_delete'].'</a>';
                                        break;
                                case 'image':
-                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$delmov_image.'</a>';
+                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$this->xi['delmov_image'].'</a>';
                                        break;
                                case 'both':
-                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$delmov_image.'&nbsp;'.$delmov_text.'</a>';
+                                       $this->xi['delmov_button'] = '<a 
href="'.$delmov_onclick.'">'.$this->xi['delmov_image'].'&nbsp;'.$this->xi['lang_delete'].'</a>';
                                        break;
                        }


====================================================
Index: email/inc/class.svc_debug.inc.php
diff -u email/inc/class.svc_debug.inc.php:1.1 
email/inc/class.svc_debug.inc.php:1.2
--- email/inc/class.svc_debug.inc.php:1.1       Thu Mar 13 20:03:17 2003
+++ email/inc/class.svc_debug.inc.php   Thu Dec 30 23:13:50 2004
@@ -37,6 +37,11 @@
                // UNDER DEVELOPMENT debug info can be stored in array for 
later retrieval
                var $debugdata=array();

+               // for timimg, this is filled with data the first CALL to a 
class functions
+               var $t_first_call = '##NOTHING##';
+               // this is filled on CREATION of this class
+               var $t_on_creation = '##NOTHING##';
+
                // available debug output types
                var 
$available_debug_outputs=array('echo_out','fill_array','fill_array__another_window','FUTURE');

@@ -51,7 +56,113 @@
                */
                function svc_debug()
                {
-                       // do nothing here
+                       // fill a timestamp
+                       if ($this->t_on_creation == '##NOTHING##')
+                       {
+                               $this->t_on_creation = array();
+                               $this->t_on_creation['raw'] = microtime();
+                               // we'll finish it later
+                               $this->t_on_creation['useful'] == '##NOTHING##';
+                       }
+                       return;
+               }
+
+
+               /*!
+               @function ensure_time_stamps
+               @abstract ?
+               */
+               function ensure_time_stamps()
+               {
+                       // get a useful timestamp out of the constructor filled 
creation mtime
+                       if (!isset($this->t_on_creation['useful'])
+                       || ($this->t_on_creation['useful'] == '##NOTHING##'))
+                       {
+                               list($this->t_on_creation['t_micro'], 
$this->t_on_creation['t_int']) = explode(' ', $this->t_on_creation['raw']);
+                               $this->t_on_creation['full_str'] = '';
+                               $this->t_on_creation['full_str'] = 
(string)$this->t_on_creation['t_int'].(string)substr($this->t_on_creation['t_micro'],
 1);
+                               $this->t_on_creation['useful'] = 
$this->microtime_to_useful($this->t_on_creation['raw']);
+                               // add one second in for use when time rolls 
over from 9 sec to "10" sec
+                               //$this->t_on_creation['useful_plus_one_sec'] = 
$this->useful_add_one_sec($this->t_on_creation['useful']);
+                       }
+                       // not the "since first call to a function here" 
timestamp
+                       if ($this->t_first_call == '##NOTHING##')
+                       {
+                               $this->t_first_call = array();
+                               $this->t_first_call['raw'] = microtime();
+                               list($this->t_first_call['t_micro'], 
$this->t_first_call['t_int']) = explode(' ', $this->t_first_call['raw']);
+                               $this->t_first_call['full_str'] = '';
+                               $this->t_first_call['full_str'] = 
(string)$this->t_first_call['t_int'].(string)substr($this->t_first_call['t_micro'],
 1);
+
+                               $this->t_first_call['useful'] = 
$this->microtime_to_useful($this->t_first_call['raw']);
+                               //$this->t_on_creation['useful_plus_one_sec'] = 
$this->useful_add_one_sec($this->t_on_creation['useful']);
+                       }
+               }
+
+               /*!
+               @function microtime_to_useful
+               @abstract ?
+               */
+               function microtime_to_useful($feed_micro_str)
+               {
+                       // microtime gives us "0.26469400 1050637805"
+                       // split the parts
+                       list($t_micro, $t_int) = explode(' ', $feed_micro_str);
+                       // shorten the microsec by 2 numbers
+                       $t_micro_short = substr($t_micro,0, -2);
+                       // replace the "0." at pos 1 of microsec with the2  
final sec digit (05 in this example)
+                       $last_sec_digits = substr($t_int,-2);
+                       $useful_t_micro = 
str_replace('0.',$last_sec_digits,$t_micro_short);
+                       // now return an int that is last_sec_digitS concat 
with t_micro into one BIG INT
+                       return (int)$useful_t_micro;
+               }
+
+               /*!
+               @function microtime_to_useful
+               @abstract ?
+               */
+               function diff_to_seconds($feed_diff)
+               {
+                       // microtime gives us "0.26469400 1050637805"
+                       // micro part is 8 digits
+                       // cut that by 2 digits, then add the last 2 second 
digits from the seconds part
+                       // so we have S=seconds M=microseconds
+                       // SSMMMMMM
+                       // so the diff between 2 of these variable length, 
let's standardize it
+                       // also, the diff of length 6 or less is not yet a 
second of difference
+                       $feed_diff = (string)$feed_diff;
+                       $feed_diff_length = strlen($feed_diff);
+                       $return_diff = '';
+                       if ($feed_diff_length <= 6)
+                       {
+                               if (function_exists('str_pad') == False)
+                               {
+                                       // we need to add 0 digits preappended 
to this diff
+                                       $return_diff = $feed_diff;
+                                       $add_digits = 6 - $feed_diff_length;
+                                       for ($i = 0; $i < $add_digits; $i++)
+                                       {
+                                               $return_diff = '0'.$return_diff;
+                                       }
+                               }
+                               else
+                               {
+                                       // same thing using str_pad
+                                       $return_diff = str_pad($feed_diff, 6, 
'0', STR_PAD_LEFT);
+                               }
+                               // now add the dot "."
+                               $return_diff = '0.'.$return_diff;
+                       }
+                       else
+                       {
+                               // diff of length 7 or more, then digit 1 out 
of 7 is a second second+ diff.
+                               // position to add dot "." to the string is 
leaving 6 digits after the dot
+                               $micro_part = substr($feed_diff, -6);
+                               $return_diff = str_replace($micro_part, 
'.'.$micro_part, $feed_diff);
+
+                       }
+
+                       return $return_diff;
                }

                /*!
@@ -70,7 +181,7 @@
                @author Angles
                */
                function out($str='', $dump_obj='', $output_to='')
-               {
+               {
                        // normalize some params
                        if ((!$output_to)
                        || ( ($output_to) && (in_array($output_to, 
$this->available_debug_outputs) == False) ) )
@@ -79,10 +190,26 @@
                        }
                        $output_to = $this->debugoutput_to;

+                       $this->ensure_time_stamps();
+                       $current_mtime = microtime();
+                       // this returns mtime as an INTEGER so we can actually 
use it
+                       $current_useful = 
$this->microtime_to_useful($current_mtime);
+                       //$diff = $current_useful - 
$this->t_first_call['useful'];
+                       $diff = $current_useful - 
$this->t_on_creation['useful'];
+                       $diff = $this->diff_to_seconds($diff);
+                       $diff = (string)$diff;
+
                        if (!$str)
                        {
-                               $str = 'mail_msg_display: out: no debug message 
provided';
+                               $str = 'svc_debug: out('.__LINE__.'): out: no 
debug message provided';
                        }
+
+                       // add time stamp
+                       //$str = '<small>('.$this->t_first_call['raw'].' :: 
'.$this->t_first_call['useful'].')</small> '.$str;
+                       //$str = 
'<small>('.$this->t_first_call['full_str'].')</small> '.$str;
+                       //$str = 
'<small>('.$this->t_first_call['float'].')</small> '.$str;
+                       $str = '<small><font 
color="brown">(+'.$diff.')</font></small> '.$str;
+
                        // output the debug info
                        if ($output_to == 'echo_out')
                        {
@@ -90,9 +217,9 @@
                                if ((isset($dump_obj))
                                && ($dump_obj))
                                {
-                                       echo '<pre>';
-                                       print_r($dump_obj);
-                                       echo '</pre>';
+                                       echo '<pre>'; print_r($dump_obj); echo 
'</pre>';
+                                       // EXPIREMENTAL
+                                       //echo 
'<br><small>'.$this->fake_print_r($dump_obj).'</small></br>';
                                }
                        }
                        elseif (($output_to == 'fill_array')
@@ -100,12 +227,22 @@
                        {
                                // do this for simple "fill_array" and for 
"fill_array__another_window"
                                $this->debugdata[] = $str;
+                               // fake_print_r does not yet work on objects
                                if ((isset($dump_obj))
+                               && (is_object($dump_obj)))
+                               {
+                                       //$this->debugdata[] = '<br 
/>'.serialize($dump_obj).'<br />';
+                                       $this->debugdata[] = '<br /> 
<pre>'.$this->print_r_log($dump_obj).'</pre> <br />';
+                               }
+                               elseif ((isset($dump_obj))
                                && ($dump_obj))
                                {
                                        //$this->debugdata[] = 
'<pre>'.serialize($dump_obj).'</pre>';
-                                       $this->debugdata[] = '<br 
/>'.serialize($dump_obj).'<br />';
+                                       //$this->debugdata[] = '<br 
/>'.serialize($dump_obj).'<br />';
                                        //$this->debugdata[] = '<br 
/>'.$this->htmlspecialchars_encode(serialize($dump_obj)).'<br />';
+                                       // this works ok
+                                       //$this->debugdata[] = '<br 
/><small>'.$this->fake_print_r($dump_obj).'</small><br />';
+                                       $this->debugdata[] = '<br /> 
<pre>'.$this->print_r_log($dump_obj).'</pre> <br />';
                                }
                        }
                        else
@@ -174,6 +311,33 @@
                                        //$this_line = preg_replace('/(&lt;font 
color=&quot;)(.*)(&quot;&gt;)(.*)(&lt;\/font&gt;)/','FONTREPLACEMENT \2 \4 
FONTREPLACEMENT',$this_line);
                                        $this_line = preg_replace('/(&lt;font 
color=&quot;)(.*)(&quot;&gt;)(.*)(&lt;\/font&gt;)/U','<font color="\2"> \4 
</font>',$this_line);
                                        $this_line = str_replace(' 
__LINEBREAK_BR__ ', '<br />', $this_line);
+                                       $this_line = str_replace(' 
__LINEBREAK__ ', '<br />', $this_line);
+                                       // NEW STUFF
+                                       // <small> .. </small>
+                                       $this_line = 
str_replace('&lt;small&gt;', '<small>', $this_line);
+                                       $this_line = 
str_replace('&lt;/small&gt;', '</small>', $this_line);
+                                       // <li> .. </li>
+                                       $this_line = str_replace('&lt;li&gt;', 
'<li>', $this_line);
+                                       $this_line = str_replace('&lt;/li&gt;', 
'</li>', $this_line);
+                                       // <u> .. </u>
+                                       $this_line = str_replace('&lt;u&gt;', 
'<u>', $this_line);
+                                       $this_line = str_replace('&lt;/u&gt;', 
'</u>', $this_line);
+                                       // =&gt
+                                       $this_line = str_replace('=&amp;gt;', 
'=&gt;', $this_line);
+                                       // <code> .. </code>
+                                       $this_line = 
str_replace('&lt;code&gt;', '<code>', $this_line);
+                                       $this_line = 
str_replace('&lt;/code&gt;', '</code>', $this_line);
+                                       // <pre> .. </pre>
+                                       $this_line = str_replace('&lt;pre&gt;', 
'<pre>', $this_line);
+                                       $this_line = 
str_replace('&lt;/pre&gt;', '</pre>', $this_line);
+                                       // <ul style="list-style-type: none;"> 
.. </ul>
+                                       $this_line = str_replace('&lt;ul 
style=&quot;list-style-type: none;&quot;&gt;', '<ul style="list-style-type: 
none;">', $this_line);
+                                       $this_line = str_replace('&lt;/ul&gt;', 
'</ul>', $this_line);
+                                       //$this_line = preg_replace('/(&lt;font 
color=&quot;)(.*)(&quot;&gt;)(.*)(&lt;\/font&gt;)/U','<font color="\2"> \4 
</font>',$this_line);
+                                       // &gt .. &lt
+                                       $this_line = str_replace('&amp;lt;', 
'&lt;', $this_line);
+                                       $this_line = str_replace('&amp;gt;', 
'&gt;', $this_line);
+
                                        $temp_data .= '<br />+ '.$this_line;
                                }

@@ -234,6 +398,10 @@
 <script type="text/javascript">
 var _console = null;
 var _did_output = 0;
+// do we close it every page view and start blank with next page
+// do we keep the window open and keep appending
+var _append_to_console = 0;
+//var _append_to_console = 1;
 function do_debug(msg)
 {
        if ((_console == null) || (_console.closed)) {
@@ -252,7 +420,9 @@
        // calling close will end the page and the next page starts a new page
        // or not calling close will add the next page view debug data to the 
existing text here
        // ALSO calling close requires the open statement check above
-       //_console.document.close();
+       if (_append_to_console == 0) {
+               _console.document.close();
+       }
        _did_output = 1;
 }
 </script>
@@ -273,5 +443,58 @@
                        return $other_window_js;
                }

+
+               /*!
+               @function fake_print_r
+               @abstract like php print_r EXCEPT it returns an html string 
instead of echoing out
+               @discussion This made by Seek3r as part of the phpgwapi file 
"php3_support_functions", it
+               is simply copied here for easier use. I, Angles, made almost no 
changes to the original Seek3r code
+               in this function which had been called "print_r" in said file.
+               @author Seek3r, Angles
+               */
+               function fake_print_r($array,$print=False)
+               {
+                       $str = '';
+                       if(gettype($array)=="array")
+                       {
+                               //$str .= '<ul>';
+                               $str .= '<ul style="list-style-type: none;">';
+                               while (list($index, $subarray) = each($array) )
+                               {
+                                       $str .= '<li>'.$index.' 
<code>=&gt;</code>';
+                                       //$str .= print_r($subarray,$print);
+                                       $str .= 
$this->fake_print_r($subarray,$print);
+                                       $str .= '</li>';
+                               }
+                               $str .= '</ul>';
+                       }
+                       else
+                       {
+                               $str .= $array;
+                       }
+                       if($print)
+                       {
+                               echo $str;
+                       }
+                       else
+                       {
+                               return $str;
+                       }
+               }
+
+               /*!
+               @function print_r_log
+               @abstract user example on php site about print_r as a var 
string using OB
+               @discussion ?
+               */
+               function print_r_log($var)
+               {
+                       ob_start();
+                       print_r($var);
+                       $ret_str = ob_get_contents();
+                       ob_end_clean();
+                       return $ret_str;
+               }
+
        }
 ?>

====================================================

====================================================
Index: email/inc/class.svc_nextmatches.inc.php
diff -u email/inc/class.svc_nextmatches.inc.php:1.2 
email/inc/class.svc_nextmatches.inc.php:1.3
--- email/inc/class.svc_nextmatches.inc.php:1.2 Fri Mar 14 04:01:12 2003
+++ email/inc/class.svc_nextmatches.inc.php     Thu Dec 30 23:13:50 2004
@@ -332,7 +332,7 @@
                        {
                                //$img_full = 
$GLOBALS['phpgw']->common->image('email',$img);
                                $img_full = 
$GLOBALS['phpgw']->msg->_image_on('email',$img,'_on');
-                               $image_part = '<img src="'.$img_full.'" 
border="0" alt="'.$alt_text.'">';
+                               $image_part = '<img src="'.$img_full.'" 
border="0" title="'.$alt_text.'"  alt="'.$alt_text.'">';
                                return '<a 
href="'.$out_vars['common_uri'].'&start='.$out_vars['start'].'">'.$image_part.'</a>';
                        }
                }
@@ -362,7 +362,7 @@
                        {
                                //$img_full = 
$GLOBALS['phpgw']->common->image('email',$img);
                                $img_full = 
$GLOBALS['phpgw']->msg->_image_on('email',$img,'_on');
-                               return '<img src="'.$img_full.'" border="0" 
alt="'.$alt_text.'">'."\r\n";
+                               return '<img src="'.$img_full.'" border="0" 
title="'.$alt_text.'" alt="'.$alt_text.'">'."\r\n";
                        }
                }
        }

====================================================
Index: email/inc/hook_preferences.inc.php
diff -u email/inc/hook_preferences.inc.php:1.14 
email/inc/hook_preferences.inc.php:1.15
--- email/inc/hook_preferences.inc.php:1.14     Fri Mar 14 04:01:54 2003
+++ email/inc/hook_preferences.inc.php  Thu Dec 30 23:13:50 2004
@@ -18,6 +18,27 @@
                'Extra E-Mail Accounts' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uipreferences.ex_accounts_list'),
                'E-Mail Filters'        => 
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uifilters.filters_list')
        );
+       // relfbecker recommends NOT using a version test for xslt check
+       if (is_object($GLOBALS['phpgw']->xslttpl))
+       {
+               $phpgw_before_xslt = False;
+       }
+       else
+       {
+               $phpgw_before_xslt = True;
+       }
+       // now display according to the version of the template system in use
+       if ($phpgw_before_xslt == True)
+       {
+               // the is the OLD, pre-xslt way to display pref items
+               display_section($appname,$title,$file);
+       }
+       else
+       {
+               // this is the xslt template era
+               display_section($appname,$file);
+       }
+       /*
        $this_ver = $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'];
        $pre_xslt_ver = '0.9.14.0.1.1';
        if (function_exists(amorethanb))
@@ -46,5 +67,6 @@
                        display_section($appname,$title,$file);
                }
        }
+       */
 }
 ?>

====================================================
Index: email/inc/class.uiindex.inc.php
diff -u email/inc/class.uiindex.inc.php:1.22 
email/inc/class.uiindex.inc.php:1.23
--- email/inc/class.uiindex.inc.php:1.22        Sun Apr 20 20:47:50 2003
+++ email/inc/class.uiindex.inc.php     Thu Dec 30 23:13:50 2004
@@ -14,7 +14,7 @@

        class uiindex
        {
-               var $bo;
+               var $bo;
                var $debug = False;
                var $widgets;
                var $tpl;
@@ -28,23 +28,23 @@
                {
                        //return;
                }
-
+
                /*!
                @function index
                @abstract assembles data used for the index page, the list of 
messages in a folder
                @author Angles
-               @description Uses the BO to do the work, then this hands off 
the disply handling
-               to either the old phplib template handling or the new xslt 
handler index_ function.
+               @description Uses the BO to do the work, then this hands off 
the disply handling
+               to either the old phplib template handling or the new xslt 
handler index_ function.
                */
                function index()
                {
-                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 'email';
+                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 'email';
                        print_debug('relevant phpgw_info data', 
$GLOBALS['phpgw_info']['user']['preferences']['email']);
-
+
                        $this->bo = CreateObject('email.boindex');
                        $this->bo->index_data();
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->index_old_tpl();
                        }
@@ -53,7 +53,7 @@
                                $this->index_xslt_tpl();
                        }
                }
-
+
                /*!
                @function index_old_tpl
                @abstract assembles data used for the index page, the list of 
messages in a folder
@@ -61,10 +61,10 @@
                @description ?
                */
                function index_old_tpl()
-               {
+               {
                        // we point to the global template for this version of 
phpgw templatings
                        $this->tpl =& $GLOBALS['phpgw']->template;
-
+
                        // NOW we can out the header, because "index_data()" 
filled this global
                        //      
$GLOBALS['phpgw_info']['flags']['email_refresh_uri']
                        // which is needed to preserve folder and sort settings 
during the auto-refresh-ing
@@ -77,11 +77,11 @@
                        // HOWEVER still this class must NOT invoke 
$GLOBALS['phpgw']->common->phpgw_header()
                        // even though we had to output the header (go 
figure... :)
                        // later: What does that mean ?
-
+
                        $this->bo->xi['my_layout'] = 
$GLOBALS['phpgw']->msg->get_pref_value('layout');
                        $this->bo->xi['my_browser'] = 
$GLOBALS['phpgw']->msg->browser;
-
-                       $this->tpl->set_file(array(
+
+                       $this->tpl->set_file(array(
                                //'T_form_delmov_init' => 
'index_form_delmov_init.tpl',
                                'T_index_blocks' => 'index_blocks.tpl',
                                'T_index_main' => 
'index_main_b'.$this->bo->xi['my_browser'].'_l'.$this->bo->xi['my_layout']. 
'.tpl'
@@ -94,13 +94,13 @@
                        
$this->tpl->set_block('T_index_main','B_msg_list','V_msg_list');
                        
$this->tpl->set_block('T_index_blocks','B_mlist_form_init','V_mlist_form_init');
                        
$this->tpl->set_block('T_index_blocks','B_arrows_form_table','V_arrows_form_table');
-
+
                        
$this->tpl->set_var('frm_delmov_action',$this->bo->xi['frm_delmov_action']);
                        
$this->tpl->set_var('frm_delmov_name',$this->bo->xi['frm_delmov_name']);
                        
$this->tpl->parse('V_mlist_form_init','B_mlist_form_init');
-                       $this->bo->xi['V_mlist_form_init'] = 
$this->tpl->get_var('V_mlist_form_init');
-
-
+                       $this->bo->xi['V_mlist_form_init'] = 
$this->tpl->get_var('V_mlist_form_init');
+
+
                        $tpl_vars = Array(
                                // fonts and font sizes
                        //      'ctrl_bar_font'         => 
$this->bo->xi['ctrl_bar_font'],
@@ -115,7 +115,7 @@
                                'hdr_font_size'         => 
$this->bo->xi['hdr_font_size'],
                                'hdr_font_size_sm'      => 
$this->bo->xi['hdr_font_size_sm'],
                                'ftr_font'              => 
$this->bo->xi['ftr_font'],
-                               // other message list stuff, we parse the mlist 
block before the rest of the tpl vars are needed
+                               // other message list stuff, we parse the mlist 
block before the rest of the tpl vars are needed
                                'mlist_newmsg_char'     => 
$this->bo->xi['mlist_newmsg_char'],
                                'mlist_newmsg_color'    => 
$this->bo->xi['mlist_newmsg_color'],
                                'mlist_newmsg_txt'      => 
$this->bo->xi['mlist_newmsg_txt'],
@@ -129,18 +129,19 @@
                                'compose_img'           => 
$this->bo->xi['compose_img'],
                                'compose_clickme'               => 
$this->bo->xi['compose_clickme'],
                                'auto_refresh_widget'   => 
$this->bo->xi['auto_refresh_widget']
-
+
                        );
                        $this->tpl->set_var($tpl_vars);
-
-                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
+
+                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        // this will have a msg to the user if messages were 
moved or deleted
                        
$this->widgets->set_toolbar_msg($GLOBALS['phpgw']->msg->report_moved_or_deleted());
                        
$this->tpl->set_var('widget_toolbar',$this->widgets->get_toolbar());
+                       
$this->tpl->set_var('geek_bar',$this->widgets->get_geek_bar());
                        // stats row, generated in a single function call
                        $this->tpl->set_var('stats_data_display', 
$this->bo->get_index_stats_block((string)$GLOBALS['phpgw']->msg->get_pref_value('layout')));
-
+
                        if ($this->bo->xi['folder_info']['number_all'] == 0)
                        {
                                $tpl_vars = Array(
@@ -156,9 +157,9 @@
                        else
                        {
                                $this->tpl->set_var('V_no_messages','');
-
+
                                
$this->tpl->set_var('stats_last',$this->bo->xi['totaltodisplay']);
-
+
                                for ($i=0; $i < 
count($this->bo->xi['msg_list_dsp']); $i++)
                                {
                                        if 
($this->bo->xi['msg_list_dsp'][$i]['first_item'])
@@ -169,7 +170,7 @@
                                        {
                                                
$this->tpl->set_var('V_mlist_form_init', '');
                                        }
-                                       // new, unseen
+                                       // new, unseen
                                        if 
($this->bo->xi['msg_list_dsp'][$i]['is_unseen'])
                                        {
                                                
$this->tpl->set_var('mlist_new_msg',$this->bo->xi['mlist_new_msg']);
@@ -222,7 +223,7 @@
                                                $all_flags_images .= 
$this->bo->xi['deleted_img'];
                                        }
                                        
$this->tpl->set_var('all_flags_images',$all_flags_images);
-
+
                                        // are we IN THE SENT folder or not
                                        if (    
$GLOBALS['phpgw']->msg->get_folder_short($GLOBALS['phpgw']->msg->get_arg_value('folder'))
                                         != 
$GLOBALS['phpgw']->msg->get_folder_short($GLOBALS['phpgw']->msg->get_pref_value('sent_folder_name')))
@@ -384,10 +385,10 @@
                                $this->tpl->set_var('V_show_size','');
                        }
                        */
-
+
                        // new way to handle debug data, if this array has 
anything, put it in the template source data vars
                        
$this->tpl->set_var('debugdata',$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-
+
                        // COMMENT NEXT LINE OUT for producvtion use, (unknowns 
should be "remove"d in production use)
                        $this->tpl->set_unknowns('comment');
                        // production use, use this:    
$this->tpl->set_unknowns("remove");
@@ -395,7 +396,7 @@
                        $this->tpl->pfp('out','T_index_main');
                        // note, for some reason, eventhough it seems we 
*should* call common->phpgw_footer(),
                        // if we do that, the client browser will get TWO page 
footers, so we do not call it here
-
+
                        // close down ALL mailserver streams
                        $GLOBALS['phpgw']->msg->end_request();
                        // destroy the object
@@ -411,25 +412,26 @@
                */
                function index_xslt_tpl()
                {
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail').' - '.lang('list messages');
-
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
                        $GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
-
+
                        $this->bo->xi['my_layout'] = 
$GLOBALS['phpgw']->msg->get_pref_value('layout');
                        $this->bo->xi['my_browser'] = 
$GLOBALS['phpgw']->msg->browser;
-
+
                        //$this->bo->xi['compose_text'] = lang('Compose');
-
-                       //= = = =  TOOLBAR WIDGET = = =
+
+                       //= = = =  TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        // this will have a msg to the user if messages were 
moved or deleted
                        
$this->widgets->set_toolbar_msg($GLOBALS['phpgw']->msg->report_moved_or_deleted());
                        $widget_toolbar = $this->widgets->get_toolbar();
-
+                       $geek_bar = $this->widgets->get_geek_bar();
+
                        $data = array(
+                               //'appname' => lang('E-Mail'),
+                               //'function_msg' => lang('list messages'),
                                'index_js' => $this->index_xslt_javascript(),
                                'widget_toolbar' => $widget_toolbar,
+                               'geek_bar' => $geek_bar,
                                'stats_data_display' => 
$this->bo->get_index_stats_block((string)$GLOBALS['phpgw']->msg->get_pref_value('layout')),
                                'arrows_backcolor_class' => 
$this->bo->xi['arrows_backcolor_class'],
                                'first_page' => $this->bo->xi['first_page'],
@@ -464,14 +466,13 @@
                                'auto_refresh_widget' => 
$this->bo->xi['auto_refresh_widget']
                        );
                        // new way to handle debug data, if this array has 
anything, put it in the template source data vars
-                       //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
-                       //{
-                       //      $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                       //}
                        $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone();
-
+
+                       $GLOBALS['phpgw_info']['flags']['email']['app_header'] 
= lang('E-Mail') . ': ' . lang('list messages');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail') . ': ' . lang('list messages');
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('index' => $data));
-
+                       $GLOBALS['phpgw']->xslttpl->pp();
+
                        // close down ALL mailserver streams
                        $GLOBALS['phpgw']->msg->end_request();
                        // destroy the object
@@ -481,13 +482,13 @@

                /*!
                @function index_xslt_javascript
-               @abstract xsl file does not seem to like this stuff in it, so 
put it here.
+               @abstract xsl file does not seem to like this stuff in it, so 
put it here.
                @author Angles
                @description ?
                */
                function index_xslt_javascript()
                {
-                       // I think indenting screws this up
+                       // I think indenting screws this up
 $index_js = <<<EOD

 <script type="text/javascript">
@@ -519,15 +520,15 @@
                        } else {
                                document.delmov.elements[i].checked = true;
                        }
-               }
+               }
        }
 }
 </script>
 EOD;
                        return $index_js;
                }
-
-
+
+
                // DISPLAY A PRE-DEFINED MESSAGE SET ARRAY
                /*!
                @function mlist  DEPRECIATED
@@ -539,10 +540,10 @@
                {
                        //raw HTTP_POST_VARS dump
                        //echo 'HTTP_POST_VARS print_r dump:<b><pre>'."\r\n"; 
print_r($GLOBALS['HTTP_POST_VARS']); echo '</pre><br><br>'."\r\n";
-
+
                        $this->bo = CreateObject("email.boindex");
                        $this->bo->mlist_data();
-
+
                        // we are the BO and the UI, we take care of outputting 
the HTML to the client browser
                        // NOW we can out the header, because "index_data()" 
filled this global
                        //      
$GLOBALS['phpgw_info']['flags']['email_refresh_uri']
@@ -557,12 +558,12 @@
                        // HOWEVER still this class must NOT invoke 
$GLOBALS['phpgw']->common->phpgw_header()
                        // even though we had to output the header and navbar, 
(go figure... :)

-                       // MUCH of this data may not be necessary nor used for 
mlists
+                       // MUCH of this data may not be necessary nor used for 
mlists
                        $this->bo->xi['my_layout'] = 
$GLOBALS['phpgw']->msg->prefs['layout'];
                        $this->bo->xi['my_browser'] = 
$GLOBALS['phpgw']->msg->browser;
-
+
                        //$GLOBALS['phpgw']->template = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-                       $GLOBALS['phpgw']->template->set_file(array(
+                       $GLOBALS['phpgw']->template->set_file(array(
                                //'T_form_delmov_init' => 
'index_form_delmov_init.tpl',
                                'T_index_blocks' => 'index_blocks.tpl',
                                'T_mlist_main' => 'index_mlist.tpl'
@@ -574,17 +575,17 @@
                        
$GLOBALS['phpgw']->template->set_block('T_mlist_main','B_msg_list','V_msg_list');
                        
$GLOBALS['phpgw']->template->set_block('T_index_blocks','B_mlist_form_init','V_mlist_form_init');
                        
$GLOBALS['phpgw']->template->set_block('T_index_blocks','B_arrows_form_table','V_arrows_form_table');
-
+
                        
$GLOBALS['phpgw']->template->set_var('frm_delmov_action',$this->bo->xi['frm_delmov_action']);
                        
$GLOBALS['phpgw']->template->set_var('frm_delmov_name',$this->bo->xi['frm_delmov_name']);
                        
$GLOBALS['phpgw']->template->parse('V_mlist_form_init','B_mlist_form_init');
                        $this->bo->xi['V_mlist_form_init'] = 
$GLOBALS['phpgw']->template->get_var('V_mlist_form_init');
-
+
                        // font size options (this feature currently BROKEN)
                        $this->bo->xi['font_size_offset'] = 0;
                        //$this->bo->xi['font_size_offset'] = 2;
                        // FIXME:  font_size_offset  needs to be put into the 
prefs db, bo, and ui
-
+
                        $font_size = Array (
                                0 => ((-5) + $this->bo->xi['font_size_offset']),
                                1 => ((-4) + $this->bo->xi['font_size_offset']),
@@ -626,14 +627,14 @@
                                'hdr_font_size'         => 
$this->bo->xi['hdr_font_size'],
                                'hdr_font_size_sm'      => 
$this->bo->xi['hdr_font_size_sm'],
                                'ftr_font'              => 
$this->bo->xi['ftr_font'],
-                               // other message list stuff, we parse the mlist 
block before the rest of the tpl vars are needed
+                               // other message list stuff, we parse the mlist 
block before the rest of the tpl vars are needed
                                'mlist_newmsg_char'     => 
$this->bo->xi['mlist_newmsg_char'],
                                'mlist_newmsg_color'    => 
$this->bo->xi['mlist_newmsg_color'],
                                'mlist_newmsg_txt'      => 
$this->bo->xi['mlist_newmsg_txt'],
                                'images_dir'            => 
$this->bo->xi['svr_image_dir']
                        );
                        $GLOBALS['phpgw']->template->set_var($tpl_vars);
-
+
                        if ($this->bo->xi['folder_info']['number_all'] == 0)
                        {
                                $tpl_vars = Array(
@@ -649,9 +650,9 @@
                        else
                        {
                                
$GLOBALS['phpgw']->template->set_var('V_no_messages','');
-
+
                                
$GLOBALS['phpgw']->template->set_var('stats_last',$this->bo->xi['totaltodisplay']);
-
+
                                for ($i=0; $i < 
count($this->bo->xi['msg_list_dsp']); $i++)
                                {
                                        // NOT SUPPORTED YET IN MLIST
@@ -769,7 +770,7 @@
                                'delmov_listbox'        => 
$this->bo->xi['delmov_listbox']
                        );
                        $GLOBALS['phpgw']->template->set_var($tpl_vars);
-
+
                        // make the voluminous MLIST hidden vars array
                        $loop_to = 
count($GLOBALS['phpgw']->msg->args['mlist_set']);
                        $mlist_hidden_vars = '';
@@ -778,10 +779,10 @@
                                $this_msg_num = 
$GLOBALS['phpgw']->msg->args['mlist_set'][$i];
                                $mlist_hidden_vars .= '<input type="hidden" 
name="mlist_set['.(string)$i.']" value="'.$this_msg_num.'">'."\r\n";
                        }
-                       // make the first prev next last arrows
+                       // make the first prev next last arrows
                        
$GLOBALS['phpgw']->template->set_var('mlist_hidden_vars',$mlist_hidden_vars);
-                       
$GLOBALS['phpgw']->template->parse('V_arrows_form_table','B_arrows_form_table');
-
+                       
$GLOBALS['phpgw']->template->parse('V_arrows_form_table','B_arrows_form_table');
+
                        // FOLDER SIZE N/A FOR MLIST SETS
                        
$GLOBALS['phpgw']->template->set_var('V_get_size',$this->bo->xi['stats_size']);
                        
$GLOBALS['phpgw']->template->set_var('V_show_size',$this->bo->xi['stats_size']);
@@ -803,14 +804,14 @@
                                
$GLOBALS['phpgw']->template->set_var('V_show_size','');
                        }
                        */
-
+
                        $GLOBALS['phpgw']->msg->end_request();
-
+
                        // we are the BO and the UI, we take care of outputting 
the HTML to the client browser
                        // Template->pparse means "print parse" which parses 
the template and uses php print command
                        // to output the HTML, note "unknowns" are never 
handled ("finished") in that method.
                        
//$GLOBALS['phpgw']->template->pparse('out','T_index_main');
-
+
                        // COMMENT NEXT LINE OUT for producvtion use, (unknowns 
should be "remove"d in production use)
                        //$GLOBALS['phpgw']->template->set_unknowns("comment");
                        // production use, use this:    
$GLOBALS['phpgw']->template->set_unknowns("remove");
@@ -819,7 +820,7 @@
                        // note, for some reason, eventhough it seems we 
*should* call common->phpgw_footer(),
                        // if we do that, the client browser will get TWO page 
footers, so we do not call it here
                }
-
-
+
+
        }
 ?>

====================================================

====================================================
Index: email/inc/class.uimessage.inc.php
diff -u email/inc/class.uimessage.inc.php:1.11 
email/inc/class.uimessage.inc.php:1.12
--- email/inc/class.uimessage.inc.php:1.11      Mon Apr 21 15:28:30 2003
+++ email/inc/class.uimessage.inc.php   Thu Dec 30 23:13:50 2004
@@ -35,14 +35,14 @@

                /*!
                @function message
-               @abstract display the message indicated by the msgball data.
+               @abstract display the message indicated by the msgball data.
                */
                function message()
                {
                        $this->bo = CreateObject("email.bomessage");
                        $this->bo->message_data();
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -53,9 +53,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // NOW we can out the header, because 
"index_data()" filled this global
                                //      
$GLOBALS['phpgw_info']['flags']['email_refresh_uri']
@@ -71,10 +70,9 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        // ---- BEGIN UIMESSAGE
                        $this->tpl->set_file(array(
                                'T_message_main' => 'message_main.tpl',
@@ -87,11 +85,13 @@
                        
$this->tpl->set_block('T_message_main','B_display_part','V_display_part');
                        
$this->tpl->set_block('T_message_echo_dump','B_setup_echo_dump','V_setup_echo_dump');
                        
$this->tpl->set_block('T_message_echo_dump','B_done_echo_dump','V_done_echo_dump');
-
-                       //= = = = TOOLBAR WIDGET = = =
+
+                       //= = = = TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        
$this->tpl->set_var('widget_toolbar',$this->widgets->get_toolbar());
-
+                       // geek_bar
+                       
$this->tpl->set_var('geek_bar',$this->widgets->get_geek_bar());
+
                        if (!empty($this->xi['msgtype']))
                        {
                                
$this->tpl->set_var('application',$this->bo->xi['application']);
@@ -101,18 +101,18 @@
                        {
                                $this->tpl->set_var('V_x-phpgw-type','');
                        }
-
+
                        //  ----  TOOL BAR / MENU BAR ----
                        $tpl_vars = Array(
                                //'accounts_label'              => 
$this->bo->xi['accounts_label'],
                                //'ctrl_bar_font'                       => 
$this->bo->xi['ctrl_bar_font'],
                                //'ctrl_bar_font_size'  => 
$this->bo->xi['ctrl_bar_font_size'],
                                //'ctrl_bar_back1'              => 
$this->bo->xi['ctrl_bar_back1'],
-
+
                                'bar_back1'             => '',
                                //'bar_back1'           => 
$GLOBALS['phpgw_info']['theme']['table_bg'],
                                //'bar_back1'           => 
$GLOBALS['phpgw_info']['theme']['bg08'],
-
+
                                // ---- account switchbox  ----
                                //'acctbox_listbox'             => 
$this->bo->xi['acctbox_listbox'],
                                //'ilnk_accounts'                       => 
$this->bo->xi['ilnk_accounts'],
@@ -123,23 +123,24 @@
                                'move_current_order'    => 
$this->bo->xi['move_current_order'],
                                'move_current_start'    => 
$this->bo->xi['move_current_start'],
                                'mlist_checkbox_name'   => 
$this->bo->xi['mlist_checkbox_name'],
-
+
                                'mlist_embedded_uri'    => 
$this->bo->xi['mlist_embedded_uri'],
                                'frm_delmov_action'             => 
$this->bo->xi['frm_delmov_action'],
                                'frm_delmov_name'               => 
$this->bo->xi['frm_delmov_name'],
                                'delmov_listbox'                => 
$this->bo->xi['delmov_listbox'],
                                'move_postmove_goto_name'       => 
$this->bo->xi['move_postmove_goto_name'],
                                'move_postmove_goto_value'      => 
$this->bo->xi['move_postmove_goto_value'],
-
-                               'ilnk_prev_msg'                 => 
$this->bo->xi['ilnk_prev_msg'],
-                               'ilnk_next_msg'                 => 
$this->bo->xi['ilnk_next_msg'],
-
+
+                               // moved to case block for text, image, or text 
and image pref
+                               //'ilnk_prev_msg'                       => 
$this->bo->xi['ilnk_prev_msg'],
+                               //'ilnk_next_msg'                       => 
$this->bo->xi['ilnk_next_msg'],
+
                                // ----  Labels and Colors for From, To, CC, 
Files, and Subject  -----
                                'tofrom_labels_bkcolor' => 
$this->bo->xi['tofrom_labels_bkcolor'],
                                'tofrom_labels_class'   => 
$this->bo->xi['tofrom_labels_class'],
                                'tofrom_data_bkcolor'   => 
$this->bo->xi['tofrom_data_bkcolor'],
                                'tofrom_data_class'     => 
$this->bo->xi['tofrom_data_class'],
-
+
                                'lang_inbox_folder'     => 
$this->bo->xi['lang_inbox'],
                                'lang_from'             => 
$this->bo->xi['lang_from'],
                                'lang_to'               => 
$this->bo->xi['lang_to'],
@@ -147,14 +148,14 @@
                                'lang_date'             => 
$this->bo->xi['lang_date'],
                                'lang_files'    => $this->bo->xi['lang_files'],
                                'lang_subject'  => 
$this->bo->xi['lang_subject'],
-
+
                                // ----  From:  Message Data  -----
                                'from_data_final'               => 
$this->bo->xi['from_data_final'],
                                // ----  To:  Message Data  -----
                                'to_data_final'                 => 
$this->bo->xi['to_data_final']
                        );
                        $this->tpl->set_var($tpl_vars);
-
+
                        // ----  Cc:  Message Data  -----
                        //if (isset($msg_headers->cc) && 
count($msg_headers->cc) > 0)
                        //      $this->bo->xi['
@@ -168,12 +169,12 @@
                        {
                                $this->tpl->set_var('V_cc_data','');
                        }
-
+
                        // ---- Message Date  (set above)  -----
                        
$this->tpl->set_var('message_date',$this->bo->xi['message_date']);
                        // ---- Message Subject  (set above)  -----
                        
$this->tpl->set_var('message_subject',$this->bo->xi['message_subject']);
-
+
                        // ---- Attachments List  -----
                        if ($this->bo->xi['list_of_files'] != '')
                        {
@@ -184,8 +185,8 @@
                        {
                                $this->tpl->set_var('V_attach_list','');
                        }
-
-
+
+
                        $tpl_vars = Array(
                                // ----  Images and Hrefs For Reply, ReplyAll, 
Forward, and Delete  -----
                                'theme_font'            => 
$this->bo->xi['theme_font'],
@@ -193,17 +194,18 @@
                                'theme_row_on'          => 
$this->bo->xi['theme_row_on'],
                                'reply_btns_bkcolor' => 
$this->bo->xi['reply_btns_bkcolor'],
                                'reply_btns_text'       => 
$this->bo->xi['reply_btns_text'],
-
+
                                'go_back_to'            => 
$this->bo->xi['lang_go_back_to'],
                                'lnk_goback_folder'     => 
$this->bo->xi['lnk_goback_folder'],
-                               'ilnk_reply'            => 
$this->bo->xi['ilnk_reply'],
-                               'ilnk_replyall'         => 
$this->bo->xi['ilnk_replyall'],
-                               'ilnk_forward'          => 
$this->bo->xi['ilnk_forward'],
-                               'ilnk_delete'           => 
$this->bo->xi['ilnk_delete']
+                               // moved to case block for text, image, or text 
and image pref
+                               //'ilnk_reply'          => 
$this->bo->xi['ilnk_reply'],
+                               //'ilnk_replyall'               => 
$this->bo->xi['ilnk_replyall'],
+                               //'ilnk_forward'                => 
$this->bo->xi['ilnk_forward'],
+                               //'ilnk_delete'         => 
$this->bo->xi['ilnk_delete']
                        );
                        $this->tpl->set_var($tpl_vars);
-
-
+
+
                        // ---- DEBUG: Show Information About Each Part  -----
                        //  the debug output needs updating
                        if ($this->bo->debug > 0)
@@ -215,12 +217,12 @@
                        {
                                $this->tpl->set_var('V_debug_parts','');
                        }
-
+
                        // -----  Message_Display Template Handles it from here 
 -------
                        
$this->tpl->set_var('theme_font',$this->bo->xi['theme_font']);
                        
$this->tpl->set_var('theme_th_bg',$this->bo->xi['theme_th_bg']);
                        
$this->tpl->set_var('theme_row_on',$this->bo->xi['theme_row_on']);
-
+
                        // ----  so called "TOOLBAR" between the msg header 
data and the message siaplay
                        switch 
($GLOBALS['phpgw']->msg->get_pref_value('button_type'))
                        {
@@ -233,6 +235,20 @@
                                        
$this->tpl->set_var('view_raw_message_ilnk','');
                                        
$this->tpl->set_var('view_printable_href',$this->bo->xi['view_printable_href']);
                                        
$this->tpl->set_var('view_printable_ilnk','');
+                                       // reply and navigation toolbar thing
+                                       
$this->tpl->set_var('href_reply',$this->bo->xi['href_reply']);
+                                       
$this->tpl->set_var('href_replyall',$this->bo->xi['href_replyall']);
+                                       
$this->tpl->set_var('href_forward',$this->bo->xi['href_forward']);
+                                       
$this->tpl->set_var('href_delete',$this->bo->xi['href_delete']);
+                                       $this->tpl->set_var('ilnk_reply','');
+                                       $this->tpl->set_var('ilnk_replyall','');
+                                       $this->tpl->set_var('ilnk_forward','');
+                                       $this->tpl->set_var('ilnk_delete','');
+                                       
$this->tpl->set_var('href_prev_msg',$this->bo->xi['href_prev_msg']);
+                                       
$this->tpl->set_var('href_next_msg',$this->bo->xi['href_next_msg']);
+                                       
//$this->tpl->set_var('text_nbsp','&nbsp;');
+                                       $this->tpl->set_var('ilnk_prev_msg','');
+                                       $this->tpl->set_var('ilnk_next_msg','');
                                        break;
                                case 'image':
                                        $this->tpl->set_var('view_option','');
@@ -243,6 +259,20 @@
                                        
$this->tpl->set_var('view_raw_message_ilnk',$this->bo->xi['view_raw_message_ilnk']);
                                        
$this->tpl->set_var('view_printable_href','');
                                        
$this->tpl->set_var('view_printable_ilnk',$this->bo->xi['view_printable_ilnk']);
+                                       // reply and navigation toolbar thing
+                                       $this->tpl->set_var('href_reply','');
+                                       $this->tpl->set_var('href_replyall','');
+                                       $this->tpl->set_var('href_forward','');
+                                       $this->tpl->set_var('href_delete','');
+                                       
$this->tpl->set_var('ilnk_reply',$this->bo->xi['ilnk_reply']);
+                                       
$this->tpl->set_var('ilnk_replyall',$this->bo->xi['ilnk_replyall']);
+                                       
$this->tpl->set_var('ilnk_forward',$this->bo->xi['ilnk_forward']);
+                                       
$this->tpl->set_var('ilnk_delete',$this->bo->xi['ilnk_delete']);
+                                       $this->tpl->set_var('href_prev_msg','');
+                                       $this->tpl->set_var('href_next_msg','');
+                                       //$this->tpl->set_var('text_nbsp','');
+                                       
$this->tpl->set_var('ilnk_prev_msg',$this->bo->xi['ilnk_prev_msg']);
+                                       
$this->tpl->set_var('ilnk_next_msg',$this->bo->xi['ilnk_next_msg']);
                                        break;
                                //case 'both':
                                default:
@@ -254,12 +284,35 @@
                                        
$this->tpl->set_var('view_raw_message_ilnk',$this->bo->xi['view_raw_message_ilnk']);
                                        
$this->tpl->set_var('view_printable_href',$this->bo->xi['view_printable_href']);
                                        
$this->tpl->set_var('view_printable_ilnk',$this->bo->xi['view_printable_ilnk']);
+                                       // reply and navigation toolbar thing
+                                       
$this->tpl->set_var('href_reply',$this->bo->xi['href_reply']);
+                                       
$this->tpl->set_var('href_replyall',$this->bo->xi['href_replyall']);
+                                       
$this->tpl->set_var('href_forward',$this->bo->xi['href_forward']);
+                                       
$this->tpl->set_var('href_delete',$this->bo->xi['href_delete']);
+                                       
$this->tpl->set_var('ilnk_reply',$this->bo->xi['ilnk_reply']);
+                                       
$this->tpl->set_var('ilnk_replyall',$this->bo->xi['ilnk_replyall']);
+                                       
$this->tpl->set_var('ilnk_forward',$this->bo->xi['ilnk_forward']);
+                                       
$this->tpl->set_var('ilnk_delete',$this->bo->xi['ilnk_delete']);
+                                       $this->tpl->set_var('href_prev_msg','');
+                                       $this->tpl->set_var('href_next_msg','');
+                                       
//$this->tpl->set_var('href_prev_msg',$this->bo->xi['href_prev_msg']);
+                                       
//$this->tpl->set_var('href_next_msg',$this->bo->xi['href_next_msg']);
+                                       
//$this->tpl->set_var('text_nbsp','&nbsp;');
+                                       
$this->tpl->set_var('ilnk_prev_msg',$this->bo->xi['ilnk_prev_msg']);
+                                       
$this->tpl->set_var('ilnk_next_msg',$this->bo->xi['ilnk_next_msg']);
                                        break;
                        }
-
-
+
+
                        // -----  SHOW MESSAGE  -------
                        //@set_time_limit(120);
+
+                       //if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == 
False)
+                       //{
+                               // fix a b0rk in template showing last item 2 
times under XSLT
+                               $final_V_display_part = '';
+                       //}
+
                        $count_part_nice = count($this->bo->part_nice);
                        for ($i = 0; $i < $count_part_nice; $i++)
                        {
@@ -268,7 +321,16 @@
                                        
$this->tpl->set_var('title_text',$this->bo->part_nice[$i]['title_text']);
                                        
$this->tpl->set_var('display_str',$this->bo->part_nice[$i]['display_str']);
                                        
$this->tpl->set_var('message_body',$this->bo->part_nice[$i]['message_body']);
-                                       
$this->tpl->parse('V_display_part','B_display_part', True);
+                                       
//$this->tpl->parse('V_display_part','B_display_part', True);
+                                       //if 
($GLOBALS['phpgw']->msg->phpgw_before_xslt)
+                                       //{
+                                       //      
$this->tpl->parse('V_display_part','B_display_part', True);
+                                       //}
+                                       //else
+                                       //{
+                                               // fix a b0rk in template 
showing last item 2 times under XSLT
+                                               $final_V_display_part .= 
$this->tpl->parse('V_display_part','B_display_part');
+                                       //}
                                }
                                elseif 
($this->bo->part_nice[$i]['d_instructions'] == 'echo_out')
                                {
@@ -276,18 +338,18 @@
                                        
$this->tpl->set_var('V_display_part','');
                                        // -----  Finished With Message_Mail 
Template, Output It
                                        $this->tpl->pfp('out','T_message_main');
-
+
                                        // -----  Prepare a Table for this Echo 
Dump
                                        
$this->tpl->set_var('title_text',$this->bo->part_nice[$i]['title_text']);
                                        
$this->tpl->set_var('display_str',$this->bo->part_nice[$i]['display_str']);
                                        
$this->tpl->parse('V_setup_echo_dump','B_setup_echo_dump');
                                        
$this->tpl->set_var('V_done_echo_dump','');
                                        
$this->tpl->pfp('out','T_message_echo_dump');
-
+
                                        // -----  Prepare $msgball data for 
phpgw_fetchbody()
                                        $msgball = 
$GLOBALS['phpgw']->msg->get_arg_value('msgball');
                                        $msgball['part_no'] = 
$this->bo->part_nice[$i]['m_part_num_mime'];
-
+
                                        // -----  Echo This Data Directly to 
the Client
                                        // since the php version of this of 
b0rked for large msgs, perhaps use sockets code?
                                        echo '<pre>';
@@ -297,24 +359,32 @@
                                        
$this->tpl->set_var('V_setup_echo_dump','');
                                        
$this->tpl->parse('V_done_echo_dump','B_done_echo_dump');
                                        
$this->tpl->pfp('out','T_message_echo_dump');
-
+
                                        //  = = = =  = =======  CLEANUP AND 
EXIT PAGE ======= = = = = = =
                                        $did_echo_dump = True;
                                        break;
                                }
                        }
                        //@set_time_limit(0);
-
+
+                       //if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == 
False)
+                       //{
+                       //      // fix a b0rk in template showing last item 2 
times under XSLT
+                               
$this->tpl->set_var('V_display_part',$final_V_display_part);
+                               $final_V_display_part = '';
+                               unset($final_V_display_part);
+                       //}
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
                        $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-
+
                        if ((isset($did_echo_dump))
                        && ($did_echo_dump == True))
                        {
                                // DO NOTHING!
                                // echo dump already outputted the template
                        }
-                       elseif ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       elseif ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->tpl->pfp('out','T_message_main');
                                //$GLOBALS['phpgw']->common->phpgw_footer();
@@ -324,8 +394,9 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('show message');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('show message');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('show message');
                                $data['email_page'] = 
$this->tpl->parse('out','T_message_main');
                                // new way to handle debug data, if this array 
has anything, put it in the template source data vars
                                //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
@@ -334,8 +405,9 @@
                                //}
                                
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
-
+
                        // ralfbecker patch dated 021124
                        if (isset($this->bo->xi['application']))
                        {
@@ -344,7 +416,16 @@
                                
$GLOBALS['phpgw']->hooks->single('email',$this->bo->xi['application']);
                        }
                        // tell apache to release emeory back to the system on 
script end
-                       //apache_child_terminate();
+                       //if ((isset($_SERVER['SERVER_SOFTWARE']))
+                       //&& (stristr($_SERVER['SERVER_SOFTWARE'], 'apache'))
+                       if ((getenv('SERVER_SOFTWARE'))
+                       && (stristr(getenv('SERVER_SOFTWARE'), 'apache'))
+                       && (function_exists('apache_child_terminate'))
+                       && (ini_get('child_terminate')))
+                       {
+                               //echo 'doing apache_child_terminate';
+                               apache_child_terminate();
+                       }

                        // close down ALL mailserver streams
                        $GLOBALS['phpgw']->msg->end_request();
@@ -352,19 +433,19 @@
                        $GLOBALS['phpgw']->msg = '';
                        unset($GLOBALS['phpgw']->msg);
                }
-
+
                /*!
                @function printable
-               @abstract display the message indicated by the msgball data in 
Printer Friendly style.
-               @author Angles
+               @abstract display the message indicated by the msgball data in 
Printer Friendly style.
+               @author Angles
                */
                function printable()
                {
                        // get the data we need to fill the template
                        $this->bo = CreateObject("email.bomessage");
                        $this->bo->message_data();
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -372,15 +453,35 @@
                        }
                        else
                        {
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['noheader'] = True;
-                       $GLOBALS['phpgw_info']['flags']['nonavbar'] = True;
-                       $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
-                       $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
+                       {
+                               $GLOBALS['phpgw_info']['flags']['noheader'] = 
True;
+                               $GLOBALS['phpgw_info']['flags']['nonavbar'] = 
True;
+                               $GLOBALS['phpgw_info']['flags']['noappheader'] 
= True;
+                               $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
+                       }
+                       else
+                       {
+                               $GLOBALS['phpgw_info']['flags']['printview'] = 
True;
+                               $GLOBALS['phpgw_info']['flags']['headonly'] = 
True;
+
+                               //$GLOBALS['phpgw_info']['navbar'] = '';
+
+                               
//$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
+
+                               // FIXME how to get rid of other template stuff 
here for XSLT?
+                               $GLOBALS['phpgw_info']['flags']['noheader'] = 
True;
+                               $GLOBALS['phpgw_info']['flags']['nonavbar'] = 
True;
+                               $GLOBALS['phpgw_info']['flags']['noappheader'] 
= True;
+                               $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
+                       }
+
+
                        $this->tpl->set_file(array(
                                'T_message_printable' => 
'message_printable.tpl',
                                'T_message_echo_dump' => 'message_echo_dump.tpl'
@@ -390,14 +491,14 @@
                        
$this->tpl->set_block('T_message_printable','B_display_part','V_display_part');
                        
$this->tpl->set_block('T_message_echo_dump','B_setup_echo_dump','V_setup_echo_dump');
                        
$this->tpl->set_block('T_message_echo_dump','B_done_echo_dump','V_done_echo_dump');
-
+
                        $tpl_vars = Array(
                                'user_fullname' => 
$GLOBALS['phpgw_info']['user']['fullname'],
                                'font_family'   => $this->bo->xi['theme_font'],
                                'theme_font'    => $this->bo->xi['theme_font'],
                                // in the echo out template, this is a TD 
background color
                                'theme_row_on'  => '#ffffff',
-
+
                                'lang_from'             => 
$this->bo->xi['lang_from'],
                                'lang_to'               => 
$this->bo->xi['lang_to'],
                                'lang_cc'               => 
$this->bo->xi['lang_cc'],
@@ -417,7 +518,7 @@
                                'page_title'    => 
$this->bo->xi['message_subject'],
                        );
                        $this->tpl->set_var($tpl_vars);
-
+
                        // ----  Cc:  Message Data  -----
                        //if (isset($msg_headers->cc) && 
count($msg_headers->cc) > 0)
                        //      $this->bo->xi['
@@ -431,7 +532,7 @@
                        {
                                $this->tpl->set_var('V_cc_data','');
                        }
-
+
                        // ---- Attachments List  -----
                        if ($this->bo->xi['list_of_files'] != '')
                        {
@@ -442,7 +543,7 @@
                        {
                                $this->tpl->set_var('V_attach_list','');
                        }
-
+
                        // -----  SHOW MESSAGE  -------
                        //@set_time_limit(120);
                        $count_part_nice = count($this->bo->part_nice);
@@ -461,18 +562,18 @@
                                        
$this->tpl->set_var('V_display_part','');
                                        // -----  Finished With Message_Mail 
Template, Output It
                                        
$this->tpl->pfp('out','T_message_printable');
-
+
                                        // -----  Prepare a Table for this Echo 
Dump
                                        
$this->tpl->set_var('title_text',$this->bo->part_nice[$i]['title_text']);
                                        
$this->tpl->set_var('display_str',$this->bo->part_nice[$i]['display_str']);
                                        
$this->tpl->parse('V_setup_echo_dump','B_setup_echo_dump');
                                        
$this->tpl->set_var('V_done_echo_dump','');
                                        
$this->tpl->pfp('out','T_message_echo_dump');
-
+
                                        // -----  Prepare $msgball data for 
phpgw_fetchbody()
                                        $msgball = 
$GLOBALS['phpgw']->msg->get_arg_value('msgball');
                                        $msgball['part_no'] = 
$this->bo->part_nice[$i]['m_part_num_mime'];
-
+
                                        // -----  Echo This Data Directly to 
the Client
                                        // since the php version of this of 
b0rked for large msgs, perhaps use sockets code?
                                        echo '<pre>';
@@ -482,30 +583,44 @@
                                        
$this->tpl->set_var('V_setup_echo_dump','');
                                        
$this->tpl->parse('V_done_echo_dump','B_done_echo_dump');
                                        
$this->tpl->pfp('out','T_message_echo_dump');
-
+
                                        //  = = = =  = =======  CLEANUP AND 
EXIT PAGE ======= = = = = = =
                                        $did_echo_dump = True;
                                        break;
                                }
                        }
                        //@set_time_limit(0);
-
+
                        if ((isset($did_echo_dump))
                        && ($did_echo_dump == True))
                        {
                                // DO NOTHING!
                                // echo dump already outputted the template
                        }
-                       else
+                       elseif ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->tpl->pfp('out','T_message_printable');
                                //$GLOBALS['phpgw']->common->phpgw_footer();
+                               // ----  Finish The HTML Tags  ----
+                               echo "</body> \r\n";
+                               echo "</html> \r\n";
                        }
-
-                       // ----  Finish The HTML Tags  ----
-                       echo "</body> \r\n";
-                       echo "</html> \r\n";
-
+                       else
+                       {
+                               $this->tpl->set_unknowns('comment');
+                               $this->tpl->pfp('out','T_message_printable');
+                               //// ----  Finish The HTML Tags  ----
+                               echo "</body> \r\n";
+                               echo "</html> \r\n";
+                               ////$this->tpl->set_unknowns('remove');
+
+                               $data = array();
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('show message');
+                               //$data['email_page'] = 
$this->tpl->parse('out','T_message_printable');
+                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                       }
+
                        if (is_object($GLOBALS['phpgw']->msg))
                        {
                                // close down ALL mailserver streams
@@ -517,6 +632,6 @@
                        // shut down this transaction
                        $GLOBALS['phpgw']->common->phpgw_exit(False);
                }
-
+
        }
 ?>

====================================================
Index: email/inc/class.uifolder.inc.php
diff -u email/inc/class.uifolder.inc.php:1.5 
email/inc/class.uifolder.inc.php:1.6
--- email/inc/class.uifolder.inc.php:1.5        Sun Apr 20 20:47:50 2003
+++ email/inc/class.uifolder.inc.php    Thu Dec 30 23:13:50 2004
@@ -27,13 +27,13 @@
                {
                        //return;
                }
-
+
                function folder()
                {
                        $this->bo = CreateObject('email.bofolder');
                        $this->bo->folder();
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -44,9 +44,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail').' - '.lang('Folder');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -58,24 +57,23 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_folder_out' => 'folder.tpl'
                                )
                        );
-                       
$this->tpl->set_block('T_folder_out','B_folder_list','V_folder_list');
-
-                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
+                       
$this->tpl->set_block('T_folder_out','B_folder_list','V_folder_list');
+
+                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        // this will have a msg to the user if folder was 
renamed, created, or deleted
                        
$this->widgets->set_toolbar_msg($this->bo->xi['action_report']);
                        
$this->tpl->set_var('widget_toolbar',$this->widgets->get_toolbar());
-
-
+
+
                        for ($i=0; 
$i<count($this->bo->xi['folder_list_display']);$i++)
                        {
                                
$this->tpl->set_var('list_backcolor',$this->bo->xi['folder_list_display'][$i]['list_backcolor']);
@@ -90,12 +88,12 @@


                        
$this->tpl->set_var('all_folders_listbox',$this->bo->xi['all_folders_listbox']);
-
+
                        // ----  Set Up Form Variables  ---
                        
$this->tpl->set_var('form_action',$this->bo->xi['form_action']);
                        
//$this->tpl->set_var('all_folders_listbox',$GLOBALS['phpgw']->msg->all_folders_listbox('','','',False));
                        
//$this->tpl->set_var('select_name_rename','source_folder');
-
+
                        
$this->tpl->set_var('form_create_txt',$this->bo->xi['form_create_txt']);
                        
$this->tpl->set_var('form_delete_txt',$this->bo->xi['form_delete_txt']);
                        
$this->tpl->set_var('form_rename_txt',$this->bo->xi['form_rename_txt']);
@@ -103,12 +101,12 @@
                        
$this->tpl->set_var('form_delete_expert_txt',$this->bo->xi['form_delete_expert_txt']);
                        
$this->tpl->set_var('form_rename_expert_txt',$this->bo->xi['form_rename_expert_txt']);
                        
$this->tpl->set_var('form_submit_txt',$this->bo->xi['form_submit_txt']);
-
+
                        
$this->tpl->set_var('hiddenvar_target_acctnum_name',$this->bo->xi['hiddenvar_target_acctnum_name']);
                        
$this->tpl->set_var('hiddenvar_target_acctnum_value',$this->bo->xi['hiddenvar_target_acctnum_value']);
                        
$this->tpl->set_var('target_fldball_boxname',$this->bo->xi['target_fldball_boxname']);
-
-                       // ----  Set Up Other Variables  ---
+
+                       // ----  Set Up Other Variables  ---
                        
$this->tpl->set_var('title_backcolor',$this->bo->xi['title_backcolor']);
                        
$this->tpl->set_var('title_textcolor',$this->bo->xi['title_textcolor']);
                        
$this->tpl->set_var('title_text',$this->bo->xi['title_text']);
@@ -116,23 +114,22 @@
                        
//$this->tpl->set_var('label_messages_text',$this->bo->xi['label_messages_text']);
                        
$this->tpl->set_var('label_new_text',$this->bo->xi['label_new_text']);
                        
$this->tpl->set_var('label_total_text',$this->bo->xi['label_total_text']);
-
+
                        
$this->tpl->set_var('view_txt',$this->bo->xi['view_txt']);
                        
$this->tpl->set_var('view_lnk',$this->bo->xi['view_lnk']);
-
+
                        
//$this->tpl->set_var('view_long_txt',$this->bo->xi['view_long_txt']);
                        
//$this->tpl->set_var('view_long_lnk',$this->bo->xi['view_long_lnk']);
                        
//$this->tpl->set_var('view_short_txt',$this->bo->xi['view_short_txt']);
                        
//$this->tpl->set_var('view_short_lnk',$this->bo->xi['view_short_lnk']);
-
+
                        
$this->tpl->set_var('the_font',$this->bo->xi['the_font']);
                        
$this->tpl->set_var('th_backcolor',$this->bo->xi['th_backcolor']);
-
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
                        $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
-                               //$this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
                                // COMMENT NEXT LINE OUT for producvtion use, 
(unknowns should be "remove"d in production use)
                                $this->tpl->set_unknowns('comment');
                                // production use, use this:    
$this->tpl->set_unknowns("remove");
@@ -146,15 +143,14 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('Folders');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('Folders');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('Folders');
                                $data['email_page'] = 
$this->tpl->parse('out','T_folder_out');
-                               // new way to handle debug data, if there is 
debug data, this will put it in the template source data vars
-                               //$data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone();
-                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
-
+
                        // close down ALL mailserver streams
                        $GLOBALS['phpgw']->msg->end_request();
                        // destroy the object

====================================================
Index: email/inc/class.uifilters.inc.php
diff -u email/inc/class.uifilters.inc.php:1.14 
email/inc/class.uifilters.inc.php:1.15
--- email/inc/class.uifilters.inc.php:1.14      Mon Apr 21 15:28:30 2003
+++ email/inc/class.uifilters.inc.php   Thu Dec 30 23:13:50 2004
@@ -15,15 +15,15 @@

        /*!
        @class uifilters
-       @abstract UI code for display of filter list and creating or editing 
individual filters.
-       NOTE that class bofilters will leave the pref filter data with any html 
encoding AS-IS if
-       it sees "uifilters" in the menuaction. So the UI functions should call 
functions in this
-       class because "ui" is in the menuaction. HOWEVER any real action or use 
or submission
-       of the filter data MUST actually call a function in class "bofilters" 
so that the lack of
-       "uifilters" in the menuaction triggers the database defanging (html 
decoding) of the
-       pref filter data. So actually showing the filters requires leaving the 
html encoding intact.
-       This encoding is referring to the pref table "database defanging" of 
certain offensive chars,
-       like slashes and quote chars.
+       @abstract UI code for display of filter list and creating or editing 
individual filters.
+       NOTE that class bofilters will leave the pref filter data with any html 
encoding AS-IS if
+       it sees "uifilters" in the menuaction. So the UI functions should call 
functions in this
+       class because "ui" is in the menuaction. HOWEVER any real action or use 
or submission
+       of the filter data MUST actually call a function in class "bofilters" 
so that the lack of
+       "uifilters" in the menuaction triggers the database defanging (html 
decoding) of the
+       pref filter data. So actually showing the filters requires leaving the 
html encoding intact.
+       This encoding is referring to the pref table "database defanging" of 
certain offensive chars,
+       like slashes and quote chars.
        @author Angles
        */
        class uifilters
@@ -41,10 +41,10 @@

                /*!
                @function uifilters
-               @abstract constructor
-               @discussion This actually creates the bofilters object, in 
which the bo constructor reads
-               the filter data from prefs, leaving the html encoding in tact 
if the string "uifilters" is in the
-               menuaction.
+               @abstract constructor
+               @discussion This actually creates the bofilters object, in 
which the bo constructor reads
+               the filter data from prefs, leaving the html encoding in tact 
if the string "uifilters" is in the
+               menuaction.
                @author Angles
                */
                function uifilters()
@@ -55,16 +55,16 @@
                        $this->bo = CreateObject("email.bofilters");
                        //return;
                }
-
+
                /*!
                @function filters_edit
-               @abstract Display an html form with an individual filter for 
the user to see or edit,
-               also called when makign a new filter.
+               @abstract Display an html form with an individual filter for 
the user to see or edit,
+               also called when makign a new filter.
                @author Angles
                */
                function filters_edit()
-               {
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+               {
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -75,9 +75,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('EMail Filters');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -87,10 +86,9 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_filters_out' => 'filters.tpl',
@@ -103,11 +101,11 @@
                        
$this->tpl->set_block('T_filters_blocks','B_action_with_ignore_me','V_action_with_ignore_me');
                        
$this->tpl->set_block('T_filters_out','B_matches_row','V_matches_row');
                        
$this->tpl->set_block('T_filters_out','B_actions_row','V_actions_row');
-
+
                        //  ---- LANGS  ----
                        $this->tpl->set_var('lang_email_filters',lang('EMail 
Filters'));
                        $this->tpl->set_var('lang_filter_name',lang('Filter 
Name'));
-                       $this->tpl->set_var('lang_filter_number',lang('Filter 
Number'));
+                       $this->tpl->set_var('lang_filter_number',lang('Filter 
Number'));
                        $this->tpl->set_var('lang_if_messages_match',lang('If 
Messages Match'));
                        
$this->tpl->set_var('lang_inbox_for_account',lang('Filter INBOX for accounts'));
                        $not_available_yet = ' &#040;NA&#041;';
@@ -131,7 +129,7 @@
                        $this->tpl->set_var('lang_contains',lang('Contains'));
                        $this->tpl->set_var('lang_notcontains',lang('Does Not 
Contain'));
                        $this->tpl->set_var('lang_take_actions',lang('Then do 
this'));
-                       $this->tpl->set_var('lang_or_enter_text',lang('or enter 
text'));
+                       $this->tpl->set_var('lang_or_enter_text',lang('or enter 
text'));
                        $this->tpl->set_var('lang_stop_if_matched',lang('and 
stop filtering'));
                        $this->tpl->set_var('lang_ignore_me2',lang('not used'));
                        $this->tpl->set_var('lang_keep',lang('Keep'));
@@ -146,27 +144,27 @@
                        $this->tpl->set_var('lang_submit',lang('Submit'));
                        $this->tpl->set_var('lang_clear',lang('Clear'));
                        $this->tpl->set_var('lang_cancel',lang('Cancel'));
-
-
-                       //= = = = TESTING NEW LISTBOX WIDGET = = =
+
+
+                       //= = = = TESTING NEW LISTBOX WIDGET = = =
                        if (!(isset($this->widgets))
                        || (!is_object($this->widgets)))
                        {
                                $this->widgets = 
CreateObject('email.html_widgets');
                        }
-
+
                        // get all filters
                        // THIS IS DONE AUTOMATICALLY in boaction constructor
                        // AND the if the constructor sees "uifilters" in the 
menuaction, it LEAVES the pref data html encoded for use in the form
                        //$this->bo->read_filter_data_from_prefs();
-
+
                        // ---- Filter Number  ----
                        // what filter are we supposed to edit
                        $filter_num = $this->bo->obtain_filer_num();
                        $this->tpl->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"; }
-
+
                        // setup some form vars
                        //$form_edit_filter_action = $GLOBALS['phpgw']->link(
                        //                                      '/index.php',
@@ -174,24 +172,24 @@
                        $form_edit_filter_action = $GLOBALS['phpgw']->link(
                                                                '/index.php',
                                                                
'menuaction=email.bofilters.process_submitted_data');
-
+
                        $form_cancel_action = $GLOBALS['phpgw']->link(
                                                                '/index.php',
                                                                
'menuaction=email.uifilters.filters_list');
-
+
                        $apply_this_filter_url = $GLOBALS['phpgw']->link(
                                                                '/index.php',
                                                                
'menuaction=email.bofilters.do_filter'
                                                                
.'&filter_num='.$filter_num);
-                       $apply_this_filter_href = '<a 
href="'.$apply_this_filter_url.'"><b>*APPLY*</b> This Filter</a>';
-
+                       $apply_this_filter_href = '<a 
href="'.$apply_this_filter_url.'">'.lang('<b>*apply*</b> this filter').'</a>';
+
                        $test_this_filter_url = 
$apply_this_filter_url.'&filter_test=1';
-                       $test_this_filter_href = '<a 
href="'.$test_this_filter_url.'">Test Run This Filter</a>';
-
+                       $test_this_filter_href = '<a 
href="'.$test_this_filter_url.'">'.lang('Test Run This Filter').'</a>';
+
                        
$this->tpl->set_var('apply_this_filter_href',$apply_this_filter_href);
                        
$this->tpl->set_var('test_this_filter_href',$test_this_filter_href);
-
-
+
+
                        // does the data exist or is this a new filter
                        /*
                        if ((isset($this->bo->all_filters[$filter_num]))
@@ -205,7 +203,7 @@
                        }
                        */
                        $filter_exists = $this->bo->filter_exists($filter_num);
-
+
                        // ----  Filter Name  ----
                        $filter_name_box_name = 'filtername';
                        if ($filter_exists)
@@ -217,10 +215,10 @@
                                //$filter_name_box_value = 'Filter 
'.$filter_num;
                                $filter_name_box_value = 'My Mail Filter';
                        }
-
+
                        
$this->tpl->set_var('filter_name_box_name',$filter_name_box_name);
                        
$this->tpl->set_var('filter_name_box_value',$filter_name_box_value);
-
+
                        // ----  source_account_listbox_name Selected logic ----
                        if ($filter_exists)
                        {
@@ -245,7 +243,7 @@
                                // 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 ---
                        // ---  for now we will offer 2 rows ---
@@ -276,7 +274,7 @@
                                        // get you custom built HTML combobox 
(a.k.a. selectbox) widget
                                        $account_multi_box = 
$GLOBALS['phpgw']->msg->all_ex_accounts_listbox($feed_args);
                                        
$this->tpl->set_var('account_multi_box', $account_multi_box);
-                                       $V_match_left_td = 
$this->tpl->parse('V_match_account_box','B_match_account_box');
+                                       $V_match_left_td = 
$this->tpl->parse('V_match_account_box','B_match_account_box');
                                }
                                else
                                {
@@ -307,7 +305,7 @@
                                        
$this->tpl->set_var('or_selected',$or_selected);
                                        
$this->tpl->set_var('and_selected',$and_selected);
                                        
$this->tpl->set_var('ignore_me_selected',$ignore_me_selected);
-                                       $V_match_left_td = 
$this->tpl->parse('V_match_and_or_ignore','B_match_and_or_ignore');
+                                       $V_match_left_td = 
$this->tpl->parse('V_match_and_or_ignore','B_match_and_or_ignore');
                                }
                                // things both rows have
                                $examine_selectbox_name = 
'match_'.(string)$i.'[examine]';
@@ -397,7 +395,7 @@
                                
$this->tpl->set_var('matchthis_textbox_name',$matchthis_textbox_name);
                                
$this->tpl->set_var('match_textbox_txt',$match_textbox_txt);
                                
$this->tpl->set_var('V_match_left_td',$V_match_left_td);
-                               if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                               if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                                {
                                        
$this->tpl->parse('V_matches_row','B_matches_row',True);
                                }
@@ -406,7 +404,7 @@
                                        $V_matches_row = $V_matches_row . 
$this->tpl->parse('V_matches_row','B_matches_row');
                                }
                        }
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless == False)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == False)
                        {
                                
$this->tpl->set_var('V_matches_row',$V_matches_row);
                        }
@@ -432,7 +430,7 @@
                                {
                                        $V_action_widget = 
$this->tpl->parse('V_action_with_ignore_me','B_action_with_ignore_me');
                                }
-
+
                                // --- Folders Listbox  ---
                                $folder_listbox_name = 
'action_'.$action_rownum.'[folder]';
                                $listbox_show_unseen = False;
@@ -455,14 +453,14 @@
                                        $pre_select_fldball['acctnum'] = 
(int)$parsed_folder['acctnum'];
                                        //echo '$pre_select_folder: 
['.$pre_select_folder.'] ; pre_select_folder_acctnum 
['.$pre_select_folder_acctnum.']';
                                }
-
+
                                // TESTING new all folders listbox widget
                                $this->widgets->new_all_folders_megalist();
                                
$this->widgets->prop_megalist_widget_name($folder_listbox_name);
                                
$this->widgets->prop_megalist_preselected_fldball($pre_select_fldball);
                                
$this->widgets->prop_megalist_first_item_text(lang('if fileto then select 
destination folder'));
                                $folder_listbox = 
$this->widgets->all_folders_megalist();
-
+
                                /*
                                $feed_args = Array(
                                        'mailsvr_stream'        => '',
@@ -479,7 +477,7 @@
                                $folder_listbox = 
$GLOBALS['phpgw']->msg->folders_mega_listbox($feed_args);
                                */
                                // ACTIONTEXT
-                               $action_textbox_name = 
'action_'.$action_rownum.'[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'] == ''))
                                {
@@ -500,52 +498,52 @@
                                {
                                        $stop_filtering_checkbox_checked = 
'checked';
                                }
-
+
                                
$this->tpl->set_var('V_action_widget',$V_action_widget);
                                $this->tpl->set_var('folder_listbox', 
$folder_listbox);
                                
$this->tpl->set_var('action_textbox_name',$action_textbox_name);
                                
$this->tpl->set_var('action_textbox_txt',$action_textbox_txt);
                                
$this->tpl->set_var('stop_filtering_checkbox_name',$stop_filtering_checkbox_name);
                                
$this->tpl->set_var('stop_filtering_checkbox_checked',$stop_filtering_checkbox_checked);
-                               
//$this->tpl->parse('V_actions_row','B_actions_row',True);
-                               
$this->tpl->parse('V_actions_row','B_actions_row');
+                               
//$this->tpl->parse('V_actions_row','B_actions_row',True);
+                               
$this->tpl->parse('V_actions_row','B_actions_row');
                        }
-
+
                        
$this->tpl->set_var('form_edit_filter_action',$form_edit_filter_action);
                        
$this->tpl->set_var('form_cancel_action',$form_cancel_action);
-
+
                        
$this->tpl->set_var('body_bg_color',$this->theme['bg_color']);
                        $this->tpl->set_var('row_on',$this->theme['row_on']);
                        $this->tpl->set_var('row_off',$this->theme['row_off']);
                        
$this->tpl->set_var('row_text',$this->theme['row_text']);
-
-
-
+
+
+
                        // debugging result list
                        $mlist_html = '';
                        if (count($this->bo->filters) > 0)
                        {
-
+
                                if ($this->debug > 1) { echo 
'uifilters.filters_edit: count($this->bo->filters): 
['.count($this->bo->filters).'] ; <br>'."\r\n"; }
                                //$this->bo->sieve_to_imap_string();
                                // WHAT THE F*** IS THIS - this is OLD left 
over code
                                //$this->bo->do_imap_search();
                                //if ($this->debug > 0) { echo 'message list 
print_r dump:<b><pre>'."\r\n"; print_r($this->bo->result_set_mlist); echo 
'</pre><br><br>'."\r\n"; }
                                $this->bo->make_mlist_box();
-                               $mlist_html =
+                               $mlist_html =
                                        '<table border="0" cellpadding="4" 
cellspacing="1" width="90%" align="center">'."\r\n"
                                        .$this->bo->finished_mlist."\r\n"
                                        .'</table>'."\r\n"
                                        .'<p>&nbsp;</p>'."\r\n"
                                        .$this->bo->submit_mlist_to_class_form
                                        .'<p>&nbsp;</p>'."\r\n";
-
+
                        }
                        $this->tpl->set_var('V_mlist_html',$mlist_html);
-
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
-                       $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       $this->tpl->set_var('debugdata', 
trim($GLOBALS['phpgw']->msg->dbug->notice_pagedone()));
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                //$this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
                                // COMMENT NEXT LINE OUT for producvtion use, 
(unknowns should be "remove"d in production use)
@@ -558,46 +556,41 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('Edit Filters');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('Edit Filters');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('Edit Filters');
                                $data['email_page'] = 
$this->tpl->parse('out','T_filters_out');
-                               // new way to handle debug data, if this array 
has anything, put it in the template source data vars
-                               //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
-                               //{
-                               //      $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                               //}
-                               //$data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone();
-                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
-
+
                        // tell the msg object we are done with it
                        $GLOBALS['phpgw']->msg->end_request();
                }

                /*!
                @function useless_function_echo_constants
-               @abstract Echos out certain constants associated with php email 
usage. Info can be obtained
-               in other ways, but I leave this here in case using the sockets 
classes (which must define this
-               constants in the absence of the php imap extension) is perhaps 
more easily debugged with
-               this function. However, until that is proven I leave this as a 
useless function.
-               Also note the things output here may not be all the constants 
anyway.
+               @abstract Echos out certain constants associated with php email 
usage. Info can be obtained
+               in other ways, but I leave this here in case using the sockets 
classes (which must define this
+               constants in the absence of the php imap extension) is perhaps 
more easily debugged with
+               this function. However, until that is proven I leave this as a 
useless function.
+               Also note the things output here may not be all the constants 
anyway.
                @author Angles
                */
                function useless_function_echo_constants()
-               {
+               {

                        // GENERAL INFO
                        //echo 'get_loaded_extensions returns:<br><pre>'; 
print_r(get_loaded_extensions()); echo '</pre>';
                        //echo 'phpinfo returns:<br><pre>'; print_r(phpinfo()); 
echo '</pre>';
-
+
                        echo 'SA_MESSAGES: 
['.(string)SA_MESSAGES.']<br>'."\r\n";
                        echo 'SA_RECENT: ['.(string)SA_RECENT.']<br>'."\r\n";
                        echo 'SA_UNSEEN: ['.(string)SA_UNSEEN.']<br>'."\r\n";
                        echo 'SA_UIDNEXT: ['.(string)SA_UIDNEXT.']<br>'."\r\n";
                        echo 'SA_UIDVALIDITY: 
['.(string)SA_UIDVALIDITY.']<br>'."\r\n";
                        echo 'SA_ALL: ['.(string)SA_ALL.']<br>'."\r\n";
-
+
                        echo 'SORTDATE: ['.(string)SORTDATE.']<br>'."\r\n";
                        echo 'SORTARRIVAL: 
['.(string)SORTARRIVAL.']<br>'."\r\n";
                        echo 'SORTFROM: ['.(string)SORTFROM.']<br>'."\r\n";
@@ -605,7 +598,7 @@
                        echo 'SORTTO: ['.(string)SORTTO.']<br>'."\r\n";
                        echo 'SORTCC: ['.(string)SORTCC.']<br>'."\r\n";
                        echo 'SORTSIZE: ['.(string)SORTSIZE.']<br>'."\r\n";
-
+
                        echo 'TYPETEXT: ['.(string)TYPETEXT.']<br>'."\r\n";
                        echo 'TYPEMULTIPART: 
['.(string)TYPEMULTIPART.']<br>'."\r\n";
                        echo 'TYPEMESSAGE: 
['.(string)TYPEMESSAGE.']<br>'."\r\n";
@@ -615,7 +608,7 @@
                        echo 'TYPEVIDEO: ['.(string)TYPEVIDEO.']<br>'."\r\n";
                        echo 'TYPEOTHER: ['.(string)TYPEOTHER.']<br>'."\r\n";
                        echo 'TYPEMODEL: ['.(string)TYPEMODEL.']<br>'."\r\n";
-
+
                        echo 'ENC7BIT: ['.(string)ENC7BIT.']<br>'."\r\n";
                        echo 'ENC8BIT: ['.(string)ENC8BIT.']<br>'."\r\n";
                        echo 'ENCBINARY: ['.(string)ENCBINARY.']<br>'."\r\n";
@@ -623,31 +616,31 @@
                        echo 'ENCQUOTEDPRINTABLE: 
['.(string)ENCQUOTEDPRINTABLE.']<br>'."\r\n";
                        echo 'ENCOTHER: ['.(string)ENCOTHER.']<br>'."\r\n";
                        echo 'ENCUU: ['.(string)ENCUU.']<br>'."\r\n";
-
+
                        echo 'FT_UID: ['.(string)FT_UID.']<br>'."\r\n";
                        echo 'FT_PEEK: ['.(string)FT_PEEK.']<br>'."\r\n";
                        echo 'FT_NOT: ['.(string)FT_NOT.']<br>'."\r\n";
                        echo 'FT_INTERNAL: 
['.(string)FT_INTERNAL.']<br>'."\r\n";
                        echo 'FT_PREFETCHTEXT: 
['.(string)FT_PREFETCHTEXT.']<br>'."\r\n";
-
+
                        echo 'SE_UID: ['.(string)SE_UID.']<br>'."\r\n";
                        echo 'SE_FREE: ['.(string)SE_FREE.']<br>'."\r\n";
                        echo 'SE_NOPREFETCH: 
['.(string)SE_NOPREFETCH.']<br>'."\r\n";
-
+
                }
-
-
+
+
                /*!
                @function filters_list
-               @abstract Display the list of all filters stored in the users 
pref table.
-               @discussion From here the user can choose to create or edit an 
individual filter, or to test or apply
-               ALL filters, or rearrange the sequence in which the filters are 
applied.
-               Note this may change before this doc text is updated, so see 
the actual page for its exact current content.
+               @abstract Display the list of all filters stored in the users 
pref table.
+               @discussion From here the user can choose to create or edit an 
individual filter, or to test or apply
+               ALL filters, or rearrange the sequence in which the filters are 
applied.
+               Note this may change before this doc text is updated, so see 
the actual page for its exact current content.
                @author Angles
                */
                function filters_list()
                {
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -658,9 +651,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail INBOX Filters List');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -670,21 +662,20 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_filters_list'        => 
'filters_list.tpl'
                                )
                        );
                        
$this->tpl->set_block('T_filters_list','B_filter_list_row','V_filter_list_row');
-
-                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
+
+                       //= = = = TESTING NEW TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        
$this->tpl->set_var('widget_toolbar',$this->widgets->get_toolbar());
-
+
                        $var = Array(
                                'pref_errors'           => '',
                                'font'                          => 
$this->theme['font'],
@@ -699,17 +690,17 @@
                                'lang_test_or_apply' => lang('test or apply ALL 
filters')
                        );
                        $this->tpl->set_var($var);
-
+
                        $filters_list = array();
                        // get all filters
                        // THIS IS DONE AUTOMATICALLY in boaction constructor
                        // AND the if the constructor sees "uifilters" in the 
menuaction, it LEAVES the pref data html encoded for use in the form
                        //$filters_list = 
$this->bo->read_filter_data_from_prefs();
                        $filters_list = $this->bo->all_filters;
-
-
+
+
                        if ($this->debug > 2) { echo 
'email.uifilters.filters_list: $filters_list dump<pre>'; 
print_r($filters_list); echo '</pre>'; }
-
+
                        $tr_color = $this->theme['row_off'];
                        $loops = count($filters_list);
                        if ($loops == 0)
@@ -719,7 +710,7 @@
                                //$tr_color = 
$this->nextmatchs->alternate_row_color($tr_color);
                                $tr_color = 
$GLOBALS['phpgw_info']['theme']['row_on'];
                                $tr_color_class = 'row_on';
-
+
                                $this->tpl->set_var('tr_color',$tr_color);
                                
$this->tpl->set_var('tr_color_class',$tr_color_class);
                                $this->tpl->set_var('filter_identity',$nothing);
@@ -739,31 +730,56 @@
                                        //$tr_color = 
$this->nextmatchs->alternate_row_color($tr_color);
                                        $tr_color = (($i + 1)/2 == floor(($i + 
1)/2)) ? $GLOBALS['phpgw_info']['theme']['row_off'] : 
$GLOBALS['phpgw_info']['theme']['row_on'];
                                        $tr_color_class = (($i + 1)/2 == 
floor(($i + 1)/2)) ? 'row_off' : 'row_on';
-
-                                       $filters_list[$i]['move_up_url'] = 
$GLOBALS['phpgw']->link(
-                                                                       
'/index.php',
-                                                                        
'menuaction=email.bofilters.move_up'
-                                                                       
.'&filter_num='.$i);
-                                       $filters_list[$i]['move_up_href'] = '<a 
href="'.$filters_list[$i]['move_up_url'].'">'.lang('Move Up').'</a>';
-
-                                       $filters_list[$i]['move_down_url'] = 
$GLOBALS['phpgw']->link(
-                                                                       
'/index.php',
-                                                                        
'menuaction=email.bofilters.move_down'
-                                                                       
.'&filter_num='.$i);
-                                       $filters_list[$i]['move_down_href'] = 
'<a href="'.$filters_list[$i]['move_down_url'].'">'.lang('Move Down').'</a>';
-
+
+                                                                               
// Don't move up the first filter (Sam Przyswa)
+                                       if ($i != 0)
+                                       {
+                                               
$filters_list[$i]['move_up_url'] = $GLOBALS['phpgw']->link(
+                                                                               
'/index.php',
+                                                                               
 'menuaction=email.bofilters.move_up'
+                                                                               
.'&filter_num='.$i);
+                                               
$filters_list[$i]['move_up_href'] = '<a 
href="'.$filters_list[$i]['move_up_url'].'">'.lang('Move Up').'</a>';
+                                       }
+                                       else
+                                       {
+                                               
$filters_list[$i]['move_up_url'] = $GLOBALS['phpgw']->link(
+                                                                               
'/index.php',
+                                                                               
 'menuaction=email.bofilters.move_up'
+                                                                               
.'&filter_num='.$i);
+                                               
$filters_list[$i]['move_up_href'] = '<a 
href="'.$filters_list[$i]['move_up_url'].'"></a>';
+                                       }
+
+                                       // Don't move down the last filter (Sam 
Przyswa)
+                                       if ($i != $loops-1)
+                                       {
+                                               
$filters_list[$i]['move_down_url'] = $GLOBALS['phpgw']->link(
+                                                                               
'/index.php',
+                                                                               
 'menuaction=email.bofilters.move_down'
+                                                                               
.'&filter_num='.$i);
+                                               
$filters_list[$i]['move_down_href'] = '<a 
href="'.$filters_list[$i]['move_down_url'].'">'.lang('Move Down').'</a>';
+                                       }
+                                       else
+                                       {
+                                               
$filters_list[$i]['move_down_url'] = $GLOBALS['phpgw']->link(
+                                                                               
'/index.php',
+                                                                               
 'menuaction=email.bofilters.move_down'
+                                                                               
.'&filter_num='.$i);
+                                               
$filters_list[$i]['move_down_href'] = '<a 
href="'.$filters_list[$i]['move_down_url'].'"></a>';
+                                       }
+                                       // end of changes (Sam Przyswa)
+
                                        $filters_list[$i]['edit_url'] = 
$GLOBALS['phpgw']->link(
                                                                        
'/index.php',
                                                                         
'menuaction=email.uifilters.filters_edit'
                                                                        
.'&filter_num='.$i);
                                        $filters_list[$i]['edit_href'] = '<a 
href="'.$filters_list[$i]['edit_url'].'">'.lang('Edit').'</a>';
-
+
                                        $filters_list[$i]['delete_url'] = 
$GLOBALS['phpgw']->link(
                                                                        
'/index.php',
                                                                         
'menuaction=email.bofilters.delete_filter'
                                                                        
.'&filter_num='.$i);
                                        $filters_list[$i]['delete_href'] = '<a 
href="'.$filters_list[$i]['delete_url'].'">'.lang('Delete').'</a>';
-
+
                                        
$this->tpl->set_var('tr_color',$tr_color);
                                        
$this->tpl->set_var('tr_color_class',$tr_color_class);
                                        
$this->tpl->set_var('filter_identity',$filters_list[$i]['display_string']);
@@ -771,7 +787,7 @@
                                        
$this->tpl->set_var('move_down_href',$filters_list[$i]['move_down_href']);
                                        
$this->tpl->set_var('edit_href',$filters_list[$i]['edit_href']);
                                        
$this->tpl->set_var('delete_href',$filters_list[$i]['delete_href']);
-                                       if 
($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                                       if 
($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                                        {
                                                
$this->tpl->parse('V_filter_list_row','B_filter_list_row', True);
                                        }
@@ -781,7 +797,7 @@
                                        }
                                }
                        }
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless == False)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == False)
                        {
                                        
$this->tpl->set_var('V_filter_list_row',$V_filter_list_row);
                        }
@@ -792,24 +808,26 @@
                                                                        
.'&filter_num='.$this->bo->add_new_filter_token);
                        $add_new_filter_href = '<a 
href="'.$add_new_filter_url.'">'.lang('New Filter').'</a>';
                        
$this->tpl->set_var('add_new_filter_href',$add_new_filter_href);
-
+
                        $done_url = $GLOBALS['phpgw']->link(
                                                                        
'/preferences/index.php');
                        $done_href = '<a 
href="'.$done_url.'">'.lang('Done').'</a>';
                        $this->tpl->set_var('done_href',$done_href);
-
+
                        // TEST AND APPLY LINKS
                        $run_all_filters_url = $GLOBALS['phpgw']->link(
                                                                        
'/index.php',
                                                                         
'menuaction=email.bofilters.do_filter');
                        $run_all_filters_href = '<a 
href="'.$run_all_filters_url.'">'.lang('<b>APPLY ALL</b> Filters').'</a>';
                        
$this->tpl->set_var('run_all_filters_href',$run_all_filters_href);
-
+
                        $test_all_filters_url = 
$run_all_filters_url.'&filter_test=1';
-                       $test_all_filters_href = '<a 
href="'.$test_all_filters_url.'">Test All Filters</a>';
+                       $test_all_filters_href = '<a 
href="'.$test_all_filters_url.'">'.lang('Test All Filters').'</a>';
                        
$this->tpl->set_var('test_all_filters_href',$test_all_filters_href);
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
+                       $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // COMMENT NEXT LINE OUT for producvtion use, 
(unknowns should be "remove"d in production use)
                                $this->tpl->set_unknowns("comment");
@@ -821,17 +839,19 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('Filters List');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('Filters List');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('Filters List');
                                $data['email_page'] = 
$this->tpl->parse('out','T_filters_list');
                                
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
-
+
                        // tell the msg object we are done with it
                        $GLOBALS['phpgw']->msg->end_request();
                }
-
-
+
+
        }
 ?>

====================================================
Index: email/inc/class.ui_mail_debug.inc.php
diff -u email/inc/class.ui_mail_debug.inc.php:1.2 
email/inc/class.ui_mail_debug.inc.php:1.3
--- email/inc/class.ui_mail_debug.inc.php:1.2   Fri Mar 14 04:01:12 2003
+++ email/inc/class.ui_mail_debug.inc.php       Thu Dec 30 23:13:50 2004
@@ -2,7 +2,7 @@
        
/**************************************************************************\
        * AngleMail - E-Mail Module for phpGroupWare                            
        *
        * http://www.anglemail.org                                              
                        *
-       * http://www.phpgroupware.org                                           
                        *
+       * http://www.phpgroupware.org                                           
                        *
        */
        
/**************************************************************************\
        * AngleMail - E-Mail Debug Page                                         
                *
@@ -22,25 +22,25 @@
        * along with this library; if not, write to the Free Software 
Foundation,               *
        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
        *
        
\**************************************************************************/
-
+
        /* $Id$ */
-
+
        /*!
        @class ui_mail_debug
        @abstract Useful debug and inline docs access page.
-       @discussion Uncomment the "public_functions" line to enable the Email 
Debug Page.
+       @discussion Uncomment the "public_functions" line to enable the Email 
Debug Page.
        Should be disabled by default, this is a developers tool.
        @author Angles
-       */
+       */
        class ui_mail_debug
        {
                
/**************************************************************************\
                *       VARS
                
\**************************************************************************/
-
+
                /*!
                @capability Debug Page
-               @discussion Uncomment the next line of code to enable the Email 
Debug Page.
+               @discussion Uncomment the next line of code to enable the Email 
Debug Page.
                This is file email / class.ui_mail_debug.inc.php
                */
                // UNCOMMENT TO ENABLE THIS PAGE
@@ -48,8 +48,8 @@
                var $widgets;
                var $debug=0;
                //var $debug=1;
-
-
+               var $tpl='##NOTHING##';
+
                /*!
                @function ui_mail_debug
                @abstract CONSTRUCTOR
@@ -57,17 +57,17 @@
                function ui_mail_debug()
                {
                        if ($this->debug > 0) { echo 'ENTERING: 
email.ui_mail_debug.CONSTRUCTOR'.'<br>'."\r\n"; }
-
+
                        $this->widgets = CreateObject("email.html_widgets");
-
+                       $this->ensure_tpl_object();
                        if ($this->debug > 0) { echo 'EXIT: 
email.ui_mail_debug.CONSTRUCTOR'.'<br>'."\r\n"; }
                }
-
+
                /*!
                @function invoke_bootatrap
                @abstract convience function to bootstrap msg object
-               @discussion in debugging we may not have or want a ->msg 
object, but if we do
-               need one, like now we need it just to get the GPC vars (or 
change the code here to _GET),
+               @discussion in debugging we may not have or want a ->msg 
object, but if we do
+               need one, like now we need it just to get the GPC vars (or 
change the code here to _GET),
                or just make -> msg object an use ->ref_GET or whatever else 
you need it for
                @author Angles
                */
@@ -78,10 +78,11 @@
                        $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
                        // FIX ME: do_login False when using msg for UTILITY, 
does that still work?
                        //$this->msg_bootstrap->set_do_login(False);
-                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.ui_mail_debug.invoke_bootatrap',
 $this->debug);
+                       
$this->msg_bootstrap->ensure_mail_msg_exists('emai.ui_mail_debug.invoke_bootatrap',
 $this->debug);
+
                        if ($this->debug > 0) { echo 'EXITing: 
email.ui_mail_debug.invoke_bootatrap'.'<br>'; }
                }
-
+
                /*!
                @function end_msg_session_object
                @abstract convience function to logout and then clear and unset 
the msg object, if it exists
@@ -102,171 +103,250 @@
                        //$GLOBALS['phpgw']->common->phpgw_exit(False);
                        if ($this->debug > 0) { echo 'EXITing: 
email.ui_mail_debug.end_msg_session_object'.'<br>'; }
                }
-
+
+               /*!
+               @function ensure_tpl_object
+               @abstract sets class var "tpl" depending on whether or not XSLT 
is in use or not.
+               @author Angles
+               */
+               function ensure_tpl_object()
+               {
+                       // NOW WE KNOW WE HAVE A MSG OBJECT so handle xslt tpl 
issue now
+                       if ($this->tpl == '##NOTHING##')
+                       {
+                               if (is_object($GLOBALS['phpgw']->xslttpl) == 
False)
+                               {
+                                       // we point to the global template for 
this version of phpgw templatings
+                                       $this->tpl =& 
$GLOBALS['phpgw']->template;
+                                       //$this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+                               }
+                               else
+                               {
+                                       // we use a PRIVATE template object for 
0.9.14 conpat and during xslt porting
+                                       $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+                               }
+                       }
+               }
+
                
/**************************************************************************\
                *       CODE
                
\**************************************************************************/
                /*!
                @function index
                @abstract This page is displayed by exposing this as a public 
function then calling it .
-               @discussion Uncomment the "public_functions" line to enable the 
Email Debug Page.
-               Should be disabled by default, this is a developers tool. If 
enabled, call this function to
+               @discussion Uncomment the "public_functions" line to enable the 
Email Debug Page.
+               Should be disabled by default, this is a developers tool. If 
enabled, call this function to
                display the page.
                @example /index.php?menuaction=email.ui_mail_debug.index
                @author Angles
-               */
+               */
                function index()
                {
                        if ($this->debug > 0) { echo 'ENTERING: 
email.ui_mail_debug.index'.'<br>'; }
-
-                       unset($GLOBALS['phpgw_info']['flags']['noheader']);
-                       unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
-                       $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
-                       $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-                       $GLOBALS['phpgw']->common->phpgw_header();
-
-                       $GLOBALS['phpgw']->template->set_file(array(
+
+                       if (is_object($GLOBALS['phpgw']->xslttpl) == False)
+                       {
+                               
unset($GLOBALS['phpgw_info']['flags']['noheader']);
+                               
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+                               $GLOBALS['phpgw_info']['flags']['noappheader'] 
= True;
+                               $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
+                               $GLOBALS['phpgw']->common->phpgw_header();
+                       }
+                       else
+                       {
+                               
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
+                       }
+
+                       $this->tpl->set_file(array(
                                'T_debug_main' => 'debug.tpl'
                        ));
-                       
$GLOBALS['phpgw']->template->set_block('T_debug_main','B_before_echo','V_before_echo');
-                       
$GLOBALS['phpgw']->template->set_block('T_debug_main','B_after_echo','V_after_echo');
-
-
-                       $GLOBALS['phpgw']->template->set_var('page_desc', 
'Email Debug Stuff');
-
+                       
$this->tpl->set_block('T_debug_main','B_before_echo','V_before_echo');
+                       
$this->tpl->set_block('T_debug_main','B_after_echo','V_after_echo');
+
+
+                       $this->tpl->set_var('page_desc', 'Email Debug Stuff');
+
                        // make a list of available debub calls
                        // Enviornment data
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=phpinfo'));
                        //$this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('phpinfo page');
-                       $GLOBALS['phpgw']->template->set_var('func_E1', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_E1', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=get_defined_constants'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('get_defined_constants 
DUMP');
-                       $GLOBALS['phpgw']->template->set_var('func_E2', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_E2', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=globals_dump'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('dump the entire 
globals[] array');
-                       $GLOBALS['phpgw']->template->set_var('func_E3', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_E3', 
$this->widgets->get_href());
+
                        // DUMP functions
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=common.debug_list_core_functions'));
                        
$this->widgets->set_href_clickme('common.debug_list_core_functions');
-                       $GLOBALS['phpgw']->template->set_var('func_D1', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_D1', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=globals_phpgw_dump'));
                        $this->widgets->set_href_clickme('dump the entire 
globals[phpgw] structure');
-                       $GLOBALS['phpgw']->template->set_var('func_D2', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_D2', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=globals_phpgw_info_dump'));
                        $this->widgets->set_href_clickme('dump the entire 
globals[phpgw_info] structure');
-                       $GLOBALS['phpgw']->template->set_var('func_D3', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_D3', 
$this->widgets->get_href());
+
                        
//$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=globals_phpgw_session_dump'));
                        //$this->widgets->set_href_clickme('dump the entire 
globals[phpgw_session] structure');
-                       //$GLOBALS['phpgw']->template->set_var('func_D4', 
$this->widgets->get_href());
+                       //$this->tpl->set_var('func_D4', 
$this->widgets->get_href());
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=ref_session_dump'));
                        $this->widgets->set_href_clickme('dump the entire 
msg->ref_SESSION structure');
-                       $GLOBALS['phpgw']->template->set_var('func_D4', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_D4', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=msg_object_dump'));
                        $this->widgets->set_href_clickme('dump the entire 
globals[phpgw]->msg object');
-                       $GLOBALS['phpgw']->template->set_var('func_D5', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_D5', 
$this->widgets->get_href());
+
+                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=preferences_object_dump'));
+                       $this->widgets->set_href_clickme('dump the entire 
$GLOBALS[phpgw]->preferences object');
+                       $this->tpl->set_var('func_D6', 
$this->widgets->get_href());
+
                        // inline docs
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=phpgwapi'));
                        $this->widgets->set_href_target('new');
-                       $this->widgets->set_href_clickme('inlinedocparser for 
phpgwapi');
-                       $GLOBALS['phpgw']->template->set_var('func_I1', 
$this->widgets->get_href());
-
+                       $this->widgets->set_href_clickme('inlinedocparser for 
phpgwapi');
+                       $this->tpl->set_var('func_I1', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=phpwebhosting'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
phpwebhosing VFS');
-                       $GLOBALS['phpgw']->template->set_var('func_I2', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I2', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=email'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
email');
-                       $GLOBALS['phpgw']->template->set_var('func_I3', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I3', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=email&fn=class.mail_msg_base.inc.php'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
email, file "class.mail_msg_base.inc.php"');
-                       $GLOBALS['phpgw']->template->set_var('func_I4', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I4', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=email&fn=class.mail_msg_display.inc.php'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
email, file "class.mail_msg_display.inc.php"');
-                       $GLOBALS['phpgw']->template->set_var('func_I5', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I5', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=email&fn=class.mail_msg_wrappers.inc.php'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
email, file "class.mail_msg_wrappers.inc.php"');
-                       $GLOBALS['phpgw']->template->set_var('func_I6', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I6', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/doc/inlinedocparser.php?app=email&fn=class.mail_dcom_imap_sock.inc.php'));
                        $this->widgets->set_href_target('new');
                        $this->widgets->set_href_clickme('inlinedocparser for 
email, file "class.mail_dcom_imap_sock.inc.php"');
-                       $GLOBALS['phpgw']->template->set_var('func_I7', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_I7', 
$this->widgets->get_href());
+
                        // other stuff
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=copyinteresting'));
                        $this->widgets->set_href_clickme('copy emails in BOB 
interesting to Local folder (no workie)');
-                       $GLOBALS['phpgw']->template->set_var('func_O1', 
$this->widgets->get_href());
-
+                       $this->tpl->set_var('func_O1', 
$this->widgets->get_href());
+
                        
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=env_test'));
                        $this->widgets->set_href_clickme('utility for testing 
env code parts');
-                       $GLOBALS['phpgw']->template->set_var('func_O2', 
$this->widgets->get_href());
-
-                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=make_table'));
+                       $this->tpl->set_var('func_O2', 
$this->widgets->get_href());
+
+                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=db_admin_make_table'));
                        $this->widgets->set_href_clickme('Create the email DB 
table');
-                       $GLOBALS['phpgw']->template->set_var('func_O3', 
$this->widgets->get_href());
-
-                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=rm_table'));
+                       $this->tpl->set_var('func_O3', 
$this->widgets->get_href());
+
+                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=db_admin_rm_table'));
                        $this->widgets->set_href_clickme('Delete the email DB 
table');
-                       $GLOBALS['phpgw']->template->set_var('func_O4', 
$this->widgets->get_href());
-
-                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=so_am_table_exists'));
+                       $this->tpl->set_var('func_O4', 
$this->widgets->get_href());
+
+                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=db_admin_clear_entire_table'));
+                       $this->widgets->set_href_clickme('Wipe the email DB 
table');
+                       $this->tpl->set_var('func_O5', 
$this->widgets->get_href());
+
+                       
$this->widgets->set_href_link($GLOBALS['phpgw']->link('/index.php','menuaction=email.ui_mail_debug.index&dfunc=db_am_table_exists'));
                        $this->widgets->set_href_clickme('Check if email DB 
table exists');
-                       $GLOBALS['phpgw']->template->set_var('func_O5', 
$this->widgets->get_href());
-
-                       
$GLOBALS['phpgw']->template->parse('V_before_echo','B_before_echo');
-                       $GLOBALS['phpgw']->template->pfp('out','T_debug_main');
-
-                       // IF we need to show debug data, now is the time
-                       $this->show_desired_data();
-
-
+                       $this->tpl->set_var('func_O6', 
$this->widgets->get_href());
+
+                       if (is_object($GLOBALS['phpgw']->xslttpl) == False)
+                       {
+                               
$this->tpl->parse('V_before_echo','B_before_echo');
+                               $this->tpl->pfp('out','T_debug_main');
+                               // IF we need to show debug data, now is the 
time
+                               $this->show_desired_data();
+                               // new way to handle debug data, if there is 
debug data, this will put it in the template source data vars
+                               $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
+                               // clear the previous tpl var and fill the 
ending one
+                               $this->tpl->set_var('V_before_echo','');
+                               
$this->tpl->parse('V_after_echo','B_after_echo');
+                               $this->tpl->pfp('out','T_debug_main');
+                       }
+                       else
+                       {
+                               $this->tpl->set_unknowns('comment');
+                               //$this->tpl->set_unknowns('remove');
+                               $data = array();
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('Folders');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('Debugging Page');
+                               // IF we need to show debug data, now is the 
time
+                               $this->show_desired_data();
+                               // new way to handle debug data, if there is 
debug data, this will put it in the template source data vars
+                               $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
+                               $data['email_page'] = 
$this->tpl->parse('out','T_debug_main');
+                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
+                       }
+
                        if ($this->debug > 0) { echo 'EXITing...: 
email.ui_mail_debug.index'.'<br>'; }
-
-                       // clear the previous tpl var and fill the ending one
-                       
$GLOBALS['phpgw']->template->set_var('V_before_echo','');
-                       
$GLOBALS['phpgw']->template->parse('V_after_echo','B_after_echo');
-                       $GLOBALS['phpgw']->template->pfp('out','T_debug_main');
+
+                       $this->end_msg_session_object();
                }
-
+
                function show_desired_data()
                {
-                       // DAMN, we need a ->msg just to do the ref_GET stuff
-                       $this->invoke_bootatrap();
-
-                       echo 'REQUEST_URI: 
'.$GLOBALS['phpgw']->msg->ref_SERVER['REQUEST_URI'].'<br>';
-                       echo 'QUERY_STRING: 
'.$GLOBALS['phpgw']->msg->ref_SERVER['QUERY_STRING'].'<br>';
-
+                       // DAMN, we need a ->msg just to do the ref_GET stuff 
and tpl stuff
+                       $this->invoke_bootatrap();
+
+                       // NOW WE HAVE A MSG OBJECT!!! we can use its debug 
functions now
+
+                       //echo 'REQUEST_URI: 
'.$GLOBALS['phpgw']->msg->ref_SERVER['REQUEST_URI'].'<br>';
+                       //echo 'QUERY_STRING: 
'.$GLOBALS['phpgw']->msg->ref_SERVER['QUERY_STRING'].'<br>';
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 REQUEST_URI: '.$GLOBALS['phpgw']->msg->ref_SERVER['REQUEST_URI'].'<br>');
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 QUERY_STRING: '.$GLOBALS['phpgw']->msg->ref_SERVER['QUERY_STRING'].'<br>');
+
+                       $desired_function = '';
+                       $uri_confirm = '';
+
                        if ((isset($GLOBALS['phpgw']->msg->ref_GET['dfunc']))
                        && ($GLOBALS['phpgw']->msg->ref_GET['dfunc'] != ''))
                        {
                                $desired_function = 
$GLOBALS['phpgw']->msg->ref_GET['dfunc'];
-                               echo "You requested: 
".$desired_function.'<br>'."\r\n";
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 You requested: '.$desired_function.'<br>');
+
+                               // some things require you manually type in 
"&confirn=1" to really make it work
+                               if 
((isset($GLOBALS['phpgw']->msg->ref_GET['confirm']))
+                               && ($GLOBALS['phpgw']->msg->ref_GET['confirm'] 
!= ''))
+                               {
+                                       $uri_confirm = 
$GLOBALS['phpgw']->msg->ref_GET['confirm'];
+                                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 confirm token is present in URI: '.$uri_confirm.'<br>');
+                               }
+                               else
+                               {
+                                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 no confirm token is in the URI'.'<br>');
+                               }
                        }
                        else
                        {
-                               echo "no desired data";
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 no desired data'.'<br>');
                                return;
                        }
-
+
                        // check against a list of available debug stuff
                        if ($desired_function == 'phpinfo')
                        {
@@ -275,16 +355,15 @@
                        elseif ($desired_function == 'get_defined_constants')
                        {
                                // this function echos out its data
-                               echo 'get_defined_constants DUMP:<pre>';
-                               print_r(get_defined_constants());
-                               echo '</pre>';
+                               //echo 'get_defined_constants DUMP:<pre>'; 
print_r(get_defined_constants()); echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 get_defined_constants DUMP:', get_defined_constants());
+
                        }
                        elseif ($desired_function == 'globals_dump')
                        {
                                // this function echos out its data
-                               echo 'GLOBALS[] array dump:<pre>';
-                               print_r($GLOBALS) ;
-                               echo '</pre>';
+                               //echo 'GLOBALS[] array dump:<pre>'; 
print_r($GLOBALS) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[] array DUMP:', $GLOBALS);

                        }
                        elseif ($desired_function == 
'common.debug_list_core_functions')
@@ -295,38 +374,38 @@
                        elseif ($desired_function == 'globals_phpgw_dump')
                        {
                                // this function echos out its data
-                               echo 'GLOBALS[phpgw] dump:<pre>';
-                               print_r($GLOBALS['phpgw']) ;
-                               echo '</pre>';
-
+                               //echo 'GLOBALS[phpgw] dump:<pre>'; 
print_r($GLOBALS['phpgw']) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[phpgw] DUMP:', $GLOBALS['phpgw']);
                        }
                        elseif ($desired_function == 'globals_phpgw_info_dump')
                        {
                                // this function echos out its data
-                               echo 'GLOBALS[phpgw_info] dump:<pre>';
-                               print_r($GLOBALS['phpgw_info']) ;
-                               echo '</pre>';
+                               //echo 'GLOBALS[phpgw_info] dump:<pre>'; 
print_r($GLOBALS['phpgw_info']) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[phpgw_info] DUMP:', $GLOBALS['phpgw_info']);
                        }
                        elseif ($desired_function == 
'globals_phpgw_session_dump')
                        {
                                // this function echos out its data
-                               echo 'GLOBALS[phpgw_session] dump:<pre>';
-                               print_r($GLOBALS['phpgw_session']) ;
-                               echo '</pre>';
+                               //echo 'GLOBALS[phpgw_session] dump:<pre>'; 
print_r($GLOBALS['phpgw_session']) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[phpgw_session] DUMP:', $GLOBALS['phpgw_session']);
                        }
                        elseif ($desired_function == 'ref_session_dump')
                        {
                                // this function echos out its data
-                               echo 'msg->ref_SESSION dump:<pre>';
-                               print_r($GLOBALS['phpgw']->msg->ref_SESSION) ;
-                               echo '</pre>';
+                               //echo 'msg->ref_SESSION dump:<pre>'; 
print_r($GLOBALS['phpgw']->msg->ref_SESSION); echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 msg->ref_SESSION DUMP:', $GLOBALS['phpgw']->msg->ref_SESSION);
                        }
                        elseif ($desired_function == 'msg_object_dump')
                        {
                                // this function echos out its data
-                               echo 'GLOBALS[phpgw]->msg dump:<pre>';
-                               print_r($GLOBALS['phpgw']->msg) ;
-                               echo '</pre>';
+                               //echo 'GLOBALS[phpgw]->msg dump:<pre>'; 
print_r($GLOBALS['phpgw']->msg) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[phpgw]->msg DUMP:', $GLOBALS['phpgw']->msg);
+                       }
+                       elseif ($desired_function == 'preferences_object_dump')
+                       {
+                               // this function echos out its data
+                               //echo '$GLOBALS[phpgw]->preferences 
dump:<pre>'; print_r($GLOBALS['phpgw']->preferences) ; echo '</pre>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 GLOBALS[phpgw]->preferences DUMP:', $GLOBALS['phpgw']->preferences);
                        }
                        elseif ($desired_function == 'copyinteresting')
                        {
@@ -336,39 +415,47 @@
                        {
                                $this->env_test();
                        }
-                       elseif ($desired_function == 'make_table')
+                       elseif ($desired_function == 'db_admin_make_table')
                        {
-                               $this->make_table();
+                               $this->db_admin_make_table($uri_confirm);
                        }
-                       elseif ($desired_function == 'rm_table')
+                       elseif ($desired_function == 'db_admin_rm_table')
                        {
-                               $this->rm_table();
+                               $this->db_admin_rm_table($uri_confirm);
                        }
-                       elseif ($desired_function == 'so_am_table_exists')
+                       elseif ($desired_function == 
'db_admin_clear_entire_table')
                        {
-                               $this->so_am_table_exists();
+                               
$this->db_admin_clear_entire_table($uri_confirm);
+                       }
+                       elseif ($desired_function == 'db_am_table_exists')
+                       {
+                               $this->db_am_table_exists();
                        }
                        else
                        {
-                               echo 'unknown desired debug request: 
"'.$desired_function.'"<br>';
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 unknown desired debug request: '.$desired_function.']<br>');
                        }
-
+
                        // DAMN, since we invoked bootstrap above, we should 
kill the msg session
                        // BUT WILL WE NEED IT AGAIN?
                        // php does not have a definitive destructor, so we 
have to guess where script will end
-                       echo 'emai.ui_mail_debug. line '.__LINE__.': calling 
"end_msg_session_object" so I hope you do not need it anymore<br>';
-                       $this->end_msg_session_object();
-               }
-
-
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.show_desired_data('.__LINE__.'):
 calling "end_msg_session_object" so I hope you do not need it anymore<br>');
+
+                       // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
+                       //$this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
+                       // TOO SOON to end msg object
+                       //$this->end_msg_session_object();
+               }
+
+               // THIS NEVER WORKED
                function copyinteresting()
                {
                        // this function echos out its data
                        echo 'This will copy from devel mail account folder 
"Phpgw Interesting" to Brick sysmail folder "Interesting 
Emails"<br><br>'."\r\n";
                        // FROM: 
&fldball[folder]=INBOX.Phpgw+Interesting&fldball[acctnum]=1
                        // TO: 
&fldball[folder]=mail%2FInteresting+Emails&fldball[acctnum]=3
-
-
+
+
                        // begin TYPICAL CLASS MSG INITALIZATION ROUTINE
                        if (is_object($GLOBALS['phpgw']->msg))
                        {
@@ -379,19 +466,19 @@
                                if ($this->debug > 0) { echo 
'emai.ui_mail_debug.copyinteresting: is_object test: $GLOBALS[phpgw]->msg is 
NOT set, creating mail_msg object<br>'; }
                                $GLOBALS['phpgw']->msg = 
CreateObject("email.mail_msg");
                        }
-
+
                        // for EXTERNAL CONTROL of msg class (i.e. not a result 
of  GET POST) it seems very important
                        // to specify the account number and folder in the args 
array
                        // acctnum is expected to be an integer
                        $my_acctnum = 1;
                        // it is customary to feed the folder name in the style 
of a URL encoded name, ex. SPACE is represented as a PLUS, etc...
                        $my_folder = urlencode("INBOX.Phpgw Interesting");
-
+
                        $args_array = Array();
                        $args_array['acctnum']  = $my_acctnum;
                        $args_array['folder'] = $my_folder;
                        $args_array['do_login'] = True;
-
+
                        $some_stream = 
$GLOBALS['phpgw']->msg->begin_request($args_array);
                        if (($args_array['do_login'] == True)
                        && (!$some_stream))
@@ -399,8 +486,8 @@
                                
$GLOBALS['phpgw']->msg->login_error($GLOBALS['PHP_SELF'].', copyinteresting()');
                        }
                        // end TYPICAL CLASS MSG INITALIZATION ROUTINE
-
-
+
+
                        // function get_msgball_list($acctnum='', $folder='')
                        //not necessary and is discouraged to actually provide 
any args to get_msgball_list()
                        // instead, a well done begin request opens the desired 
accftnum folder and get_msgball_list uses that info.
@@ -408,13 +495,14 @@
                        echo 'Msgball List for account number ['.$my_acctnum.'] 
folder name ['.$my_folder.']:<pre>';
                        print_r($my_from_list) ;
                        echo '</pre>';
-
+
                        $GLOBALS['phpgw']->msg->end_request();
                }
-
+
+               // this evenually made it to boaction and is not used there
                function env_test()
                {
-                       $expected_args =
+                       $expected_args =
                                '/mail/index_php?menuaction'.','.
                                'fldball'.','.
                                'msgball'.','.
@@ -424,12 +512,12 @@
                                'sort'.','.
                                'order'.','.
                                'start';
-
+
                        echo '$expected_args ['.$expected_args.']<br>';
                        /*
                        $exploded_expected_args = array();
                        $exploded_expected_args = explode(',',$expected_args);
-                       if (2 > 1) { echo '$exploded_expected_args DUMP:<pre>'; 
print_r($exploded_expected_args); echo '</pre>'; }
+                       if (2 > 1) { echo '$exploded_expected_args DUMP:<pre>'; 
print_r($exploded_expected_args); echo '</pre>'; }
                        $expected_args = array();
                        $loops = count($exploded_expected_args);
                        for ($i = 0; $i < $loops; $i++)
@@ -437,14 +525,14 @@
                                $arg_name = $exploded_expected_args[$i];
                                $expected_args[$arg_name] = '-1';
                        }
-                       if (2 > 1) { echo '$expected_args DUMP:<pre>'; 
print_r($expected_args); echo '</pre>'; }
-
+                       if (2 > 1) { echo '$expected_args DUMP:<pre>'; 
print_r($expected_args); echo '</pre>'; }
+
                        // make sure we have msg object and a server stream
                        $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
                        $this->msg_bootstrap->set_do_login(False);
                        
$this->msg_bootstrap->ensure_mail_msg_exists('emai.ui_mail_debug.env_test', 1);
-
-                       if (2 > 1) { echo 
'$GLOBALS[phpgw]->msg->known_external_args DUMP:<pre>'; 
print_r($GLOBALS['phpgw']->msg->known_external_args); echo '</pre>'; }
+
+                       if (2 > 1) { echo 
'$GLOBALS[phpgw]->msg->known_external_args DUMP:<pre>'; 
print_r($GLOBALS['phpgw']->msg->known_external_args); echo '</pre>'; }
                        */
                        // make sure we have msg object and a server stream
                        $this->msg_bootstrap = 
CreateObject("email.msg_bootstrap");
@@ -454,21 +542,28 @@
                        // test run thru the functions
                        $boaction_obj->set_expected_args($expected_args);
                        // the URI of the redirect string contains data needed 
for the next page view
-
+
                        //$redirect_to = 
'/mail/index_php?menuaction=email.uiindex.index&fldball[folder]=INBOX&fldball[acctnum]=4&sort=1&order=1&start=0';
                        $redirect_to = 
'/mail/index_php?menuaction=email.uimessage.message&msgball[msgnum]=102&msgball[folder]=INBOX&msgball[acctnum]=4&sort=1&order=1&start=0';

                        $boaction_obj->set_new_args_uri($redirect_to);
-                       // clear existing args, apply the new arg enviornment,
+                       // clear existing args, apply the new arg enviornment,
                        // we get back the menuaction the redirect would have 
asked for
                        $my_menuaction = $boaction_obj->apply_new_args_env();
                        echo 'returned $my_menuaction ['.$my_menuaction.']<br>';
-
+
                        $GLOBALS['phpgw']->msg->end_request();
                }
-
-               function make_table()
+
+
+               function db_admin_make_table($really_do_it=False)
                {
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_make_table('.__LINE__.'):
 ENTERING<br>');
+                       if ($really_do_it == False)
+                       {
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_make_table('.__LINE__.'):
 param $really_do_it ['.serialize($really_do_it).'] so we are DO NOTHING, and 
we EXIT<br>');
+                               return;
+                       }
                        // this function makes a table for email in the phpgw DB
                        //$account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
                        $sTableName = 'phpgw_anglemail';
@@ -478,11 +573,11 @@
                                        . "content text DEFAULT '' NOT NULL, "
                                        . "PRIMARY KEY (account_id,data_key) )";
                        $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
-
+
                        $table_names = $GLOBALS['phpgw']->db->table_names();
-                       echo '$table_names dump:<pre>';
-                       print_r($table_names) ;
-                       echo '</pre>';
+                       //echo '$table_names dump:<pre>'; 
print_r($table_names); echo '</pre>';
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_make_table('.__LINE__.'):
 $table_names DUMP:', $table_names);
+
                        /*
                        'phpgw_anglemail' => array(
                                'fd' => array(
@@ -495,48 +590,70 @@
                                'ix' => array(),
                                'uc' => array()
                        */
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_make_table('.__LINE__.'):
 LEAVING<br>');
                }
-
-               function rm_table()
+
+               function db_admin_rm_table($really_do_it=False)
                {
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_rm_table('.__LINE__.'):
 ENTERING<br>');
+                       if (!$really_do_it)
+                       {
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_rm_table('.__LINE__.'):
 param $really_do_it ['.serialize($really_do_it).'] so we are DO NOTHING, and 
we EXIT<br>');
+                               return;
+                       }
                        // this function drops the table for email in the phpgw 
DB
                        $sTableName = 'phpgw_anglemail';
                        $query = "DROP TABLE " . $sTableName;
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_rm_table('.__LINE__.'):
 about to CALL 
$GLOBALS[phpgw]->db->query('.$query.','.__LINE__.','.__FILE__.');<br>');
                        $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
-
+
                        $table_names = $GLOBALS['phpgw']->db->table_names();
-                       echo '$table_names dump:<pre>';
-                       print_r($table_names) ;
-                       echo '</pre>';
+                       //echo '$table_names dump:<pre>'; 
print_r($table_names); echo '</pre>';
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_rm_table('.__LINE__.'):
 $table_names DUMP:', $table_names);
                }
-
-               function so_admin_clear_entire_table()
+
+               function db_admin_clear_entire_table($really_do_it=False)
                {
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_clear_entire_table('.__LINE__.'):
 ENTERING<br>');
+                       if (!$really_do_it)
+                       {
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_clear_entire_table('.__LINE__.'):
 param $really_do_it ['.serialize($really_do_it).'] so we are DO NOTHING, and 
we EXIT<br>');
+                               return;
+                       }
                        // If you issue a DELETE with no WHERE clause, all rows 
are deleted.
                        // THIS WIPES THE TABLE CLEAN OF ALL DATA
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_clear_entire_table('.__LINE__.'):
 param $really_do_it ['.serialize($really_do_it).'] so we CALL 
$GLOBALS[phpgw]->db->query("DELETE FROM 
phpgw_anglemail",'.__LINE__.','.__FILE__.');<br>');
                        $GLOBALS['phpgw']->db->query("DELETE FROM 
phpgw_anglemail",__LINE__,__FILE__);
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_admin_clear_entire_table('.__LINE__.'):
 LEAVING<br>');
                }
-
-               function so_am_table_exists()
+
+               function db_am_table_exists()
                {
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 ENTERING<br>');
                        $look_for_me = 'phpgw_anglemail';
+                       $found_table = False;
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 about to call $GLOBALS[phpgw]->db->table_names()<br>');
                        $table_names = $GLOBALS['phpgw']->db->table_names();
                        $table_names_serialized = serialize($table_names);
                        if (strstr($table_names_serialized, $look_for_me))
                        {
-                               echo 'so_am_table_exists: result: table 
['.$look_for_me.'] DOES exist<br>';
-                               // return True;
+
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 result: table ['.$look_for_me.'] DOES exist<br>');
+                               $found_table = True;
                        }
                        else
                        {
-                               echo 'so_am_table_exists: result: table 
['.$look_for_me.'] does NOT exist<br>';
-                               // return False;
+                               
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 result: table ['.$look_for_me.'] does NOT exist<br>');
+                               $found_table = False;
                        }
-                       echo '$table_names dump:<pre>';
-                       print_r($table_names) ;
-                       echo '</pre>';
+                       //echo '$table_names dump:<pre>'; 
print_r($table_names); echo '</pre>';
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 $table_names DUMP:', $table_names);
+
+                       
$GLOBALS['phpgw']->msg->dbug->out('ui_mail_debug.db_am_table_exists('.__LINE__.'):
 LEAVING: returning ['.serialize($found_table).']<br>');
+                       return $found_table;
                }
-
+
+               /*
                // these bext functions will go inti the future SO class
                function so_set_data($data_key, $content)
                {
@@ -544,10 +661,10 @@
                        $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
                        $content = serialize($content);
                        $content = 
$GLOBALS['phpgw']->db->db_addslashes($content);
-
+
                        $GLOBALS['phpgw']->db->query("SELECT content FROM 
phpgw_anglemail WHERE "
                                . "account_id = '".$account_id."' AND data_key 
= '".$data_key."'",__LINE__,__FILE__);
-
+
                        if ($GLOBALS['phpgw']->db->num_rows()==0)
                        {
                                $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_anglemail (account_id,data_key,content) "
@@ -555,19 +672,19 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw']->db->query("UPDATE 
phpgw_anglemail set content='" . $content
+                               $GLOBALS['phpgw']->db->query("UPDATE 
phpgw_anglemail set content='" . $content
                                        . "' WHERE account_id='" . $account_id 
. "' AND data_key='" . $data_key . "'",__LINE__,__FILE__);
                        }
                }
-
+
                function so_get_data($data_key)
                {
                        $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
                        $data_key = 
$GLOBALS['phpgw']->db->db_addslashes($data_key);
-
+
                        $GLOBALS['phpgw']->db->query("SELECT content FROM 
phpgw_anglemail WHERE "
                                . "account_id = '".$account_id."' AND data_key 
= '".$data_key."'",__LINE__,__FILE__);
-
+
                        if ($GLOBALS['phpgw']->db->num_rows()==0)
                        {
                                return False;
@@ -585,7 +702,7 @@
                                return $my_content;
                        }
                }
-
+
                function so_delete_data($data_key)
                {
                        $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
@@ -593,13 +710,14 @@
                        $GLOBALS['phpgw']->db->query("DELETE FROM 
phpgw_anglemail "
                                . " WHERE account_id='" . $account_id . "' AND 
data_key='" . $data_key . "'",__LINE__,__FILE__);
                }
-
+
                function so_clear_all_data_this_user()
                {
                        $account_id = 
get_account_id($accountid,$GLOBALS['phpgw']->session->account_id);
                        $GLOBALS['phpgw']->db->query("DELETE FROM 
phpgw_anglemail "
                                . " WHERE account_id='" . $account_id . 
"'",__LINE__,__FILE__);
                }
-
+               */
+
        }
 ?>

====================================================

====================================================
Index: email/inc/class.uicompose.inc.php
diff -u email/inc/class.uicompose.inc.php:1.5 
email/inc/class.uicompose.inc.php:1.6
--- email/inc/class.uicompose.inc.php:1.5       Sun Apr 20 20:47:50 2003
+++ email/inc/class.uicompose.inc.php   Thu Dec 30 23:13:50 2004
@@ -9,12 +9,12 @@
        *  Free Software Foundation; either version 2 of the License, or (at 
your               *
        *  option) any later version.                                           
                *
        
\**************************************************************************/
-
+
        /* $Id$ */
-
+
        class uicompose
        {
-               var $bo;
+               var $bo;
                var $debug = 0;
                var $tpl;
                var $widgets;
@@ -27,7 +27,7 @@
                {
                        //return;
                }
-
+
                /*!
                @function compose
                @abstract calls bocompose and makes the compose page
@@ -36,23 +36,23 @@
                @access public
                */
                function compose($reuse_feed_args='')
-               {
+               {
                        if ((is_string($reuse_feed_args))
                        && ($reuse_feed_args == ''))
                        {
                                // we were passed an empty string, make it an 
empty array just to be consistant
                                $reuse_feed_args = array();
-
+
                        }
-                       // ok, class.spell will pass $special_instructions as 
$reuse_feed_args string data,
+                       // ok, class.spell will pass $special_instructions as 
$reuse_feed_args string data,
                        // this must be passed onto bocompose->compose()
-
+
                        $this->bo = CreateObject("email.bocompose");
-                       // concept of $reuse_feed_args is depreciated HOWEVER 
the spell code will
+                       // concept of $reuse_feed_args is depreciated HOWEVER 
the spell code will
                        // pass "special_instructions" back to bocompose, so 
leave this here
                        $this->bo->compose($reuse_feed_args);
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -63,9 +63,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail').' - '.lang('Compose');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we are the BO and the UI, we take care of 
outputting the HTML to the client browser
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
@@ -76,23 +75,22 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_compose_out' => 'compose.tpl'
                                )
                        );
                        
$this->tpl->set_block('T_compose_out','B_checkbox_sig','V_checkbox_sig');
-
+
                        if ($this->debug > 2) { echo 'GLOBALS[phpgw_info] 
dump:<pre>'; print_r($GLOBALS['phpgw_info']) ; echo '</pre>'; }
-
-                       //= = = = TOOLBAR WIDGET = = =
+
+                       //= = = = TOOLBAR WIDGET = = =
                        $this->widgets = CreateObject('email.html_widgets');
                        
$this->tpl->set_var('widget_toolbar',$this->widgets->get_toolbar());
-
+
                        // fill template vars
                        $tpl_vars = Array(
                                'to_box_value'          => 
$this->bo->xi['to_box_value'],
@@ -133,7 +131,7 @@
                                'addressbook_button'    => 
$this->bo->xi['addressbook_button'],
                                'send_button'                   => 
$this->bo->xi['send_button'],
                                'spellcheck_button'             => 
$this->bo->xi['spellcheck_button'],
-                               'attachfile_js_button'          => 
$this->bo->xi['attachfile_js_button'],
+                               'attachfile_js_button'          => 
$this->bo->xi['attachfile_js_button'],
                                'attachfile_js_onclick'          => 
$this->bo->xi['attachfile_js_onclick'],
                                'body_box_name'         => 
$this->bo->xi['body_box_name']
                        );
@@ -163,29 +161,28 @@
                        {
                                
$this->tpl->set_var('ischecked_checkbox_req_notify','');
                        }
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
+                       $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we are the BO and the UI, we take care of 
outputting the HTML to the client browser
                                $this->tpl->pfp('out','T_compose_out');
                        }
                        else
                        {
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('compose message');
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('compose message');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('compose 
message');
                                $data['email_page'] = 
$this->tpl->parse('out','T_compose_out');
-                               // new way to handle debug data, if this array 
has anything, put it in the template source data vars
-                               if ($GLOBALS['phpgw']->msg->debugdata)
-                               {
-                                       $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                               }
                                
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
-
+
                        $GLOBALS['phpgw']->msg->end_request();
                }
        }

====================================================
Index: email/inc/class.uipreferences.inc.php
diff -u email/inc/class.uipreferences.inc.php:1.17 
email/inc/class.uipreferences.inc.php:1.18
--- email/inc/class.uipreferences.inc.php:1.17  Sun Apr 20 20:47:50 2003
+++ email/inc/class.uipreferences.inc.php       Thu Dec 30 23:13:50 2004
@@ -10,9 +10,9 @@
        *  Free Software Foundation; either version 2 of the License, or (at 
your               *
        *  option) any later version.                                           
                *
        
\**************************************************************************/
-
+
        /* $Id$ */
-
+
        class uipreferences
        {
                var $public_functions = array(
@@ -39,18 +39,18 @@
                        $temp_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences();
                        $this->prefs = $temp_prefs['email'];
                }
-
+
                /*!
                @function create_prefs_block
-               @abstract create 2 columns TR's (TableRows) from preference 
data as standardized in email
+               @abstract create 2 columns TR's (TableRows) from preference 
data as standardized in email
                bopreferences class vars ->std_prefs[]  and ->cust_prefs[], 
various HTML widgets supported
-               @param $feed_prefs : array : preference data as standardized in 
email bopreferences class
+               @param $feed_prefs : array : preference data as standardized in 
email bopreferences class
                vars ->std_prefs[]  and ->cust_prefs[]
                @result : string : HTML data accumulated for parsed prefernce 
widget TR's
                @discussion  email bopreferences class vars ->std_prefs[]  and 
->cust_prefs[], as filled by
                email bopreferences->init_available_prefs(), represent a 
standardized preferences schema,
-               this function generates TR's from that data, using elements 
"id", "widget", "other_props",
-               "lang_blurb", and "values" from that array structure. This 
function uses that data to fill
+               this function generates TR's from that data, using elements 
"id", "widget", "other_props",
+               "lang_blurb", and "values" from that array structure. This 
function uses that data to fill
                a template block that contatains the requested widget and the 
appropriate data.
                Available HTML widgets are:
                        * textarea
@@ -58,7 +58,7 @@
                        * passwordbox
                        * combobox
                        * checkbox
-               If prefs data "other_props" contains "hidden", as with password 
data, then the actual
+               If prefs data "other_props" contains "hidden", as with password 
data, then the actual
                preference value is not shown and the "text blurb" is appended 
with "(hidden)".
                Array can contain any number of preference "records", all 
generated TR's are cumulative.
                @author Angles
@@ -77,11 +77,11 @@
                                if ($this->debug > 0 ) { echo 
'email.uipreferences.create_prefs_block: LEAVING early, $feed_prefs param was 
empty<br>'; }
                                return $return_block;
                        }
-
+
                        // initialial backcolor, will be alternated between 
row_on and row_off
                        $back_color = $this->theme['row_off'];
                        $back_color_class = 'row_off';
-
+
                        // what existing user preferences data do we use to 
retrieve what the user has already saved for a particular pref
                        if (($this->bo->account_group == 'extra_accounts')
                        && (isset($this->bo->acctnum)))
@@ -100,21 +100,21 @@
                                $actual_user_prefs = $this->prefs;
                        }
                        if ($this->debug > 2) { echo 
'email.uipreferences.create_prefs_block: $this->bo->account_group: 
['.$this->bo->account_group.'] ; $this->bo->acctnum: ['.$this->bo->acctnum.'] ; 
$actual_user_prefs dump:<pre>'; print_r($actual_user_prefs); echo '</pre>'; }
-
+
                        $c_prefs = count($feed_prefs);
                        // ---  Prefs Loops  ---
                        for($i=0;$i<$c_prefs;$i++)
                        {
                                $this_item = $feed_prefs[$i];
                                if ($this->debug > 2) { echo '** loop ['.$i.'] 
**: email.uipreferences.create_prefs_block: $this_item = $feed_prefs['.$i.'] = 
[<code>'.serialize($this_item).'</code>] ; $this_item DUMP <pre>'; 
print_r($this_item); echo '</pre>'; }
-
+
                                // ---- do not show logic  ----
                                // do we show this for "default" account and/or 
"extra_accounts"
                                if (($this->bo->account_group == 'default')
                                && (!stristr($this_item['accts_usage'] , 
'default')))
                                {
                                        // we are not supposed to show this 
item for the default account, skip this pref item
-                                       // continue is used within looping 
structures to skip the rest of the current loop
+                                       // continue is used within looping 
structures to skip the rest of the current loop
                                        // iteration and continue execution at 
the beginning of the next iteration
                                        if ($this->debug > 1) { echo ' * 
email.uipreferences.create_prefs_block: skip showing this item because it is 
not applicable to the default account<br>'; }
                                        continue;
@@ -133,14 +133,14 @@
                                        if ($this->debug > 1) { echo ' * 
email.uipreferences.create_prefs_block: skip showing this item because 
"INACTIVE" is in $this_item[type] : ['.$this_item['type'].']<br>'; }
                                        continue;
                                }
-
+
                                // ----  ok to show this, continue...  ----
                                if ($this->debug > 1) { echo ' * 
email.uipreferences.create_prefs_block:  ... this item passed skip test, so it 
should be displayed ...<br>'; }
                                // ROW BACK COLOR
                                //$back_color = 
$this->nextmatchs->alternate_row_color($back_color);
                                $back_color = (($i + 1)/2 == floor(($i + 1)/2)) 
? $this->theme['row_off'] : $this->theme['row_on'];
                                $back_color_class = (($i + 1)/2 == floor(($i + 
1)/2)) ? 'row_off' : 'row_on';
-
+
                                $var = Array(
                                        'back_color'    => $back_color,
                                        'back_color_class'      => 
$back_color_class,
@@ -148,7 +148,7 @@
                                        'extra_text'    => ''
                                );
                                $this->tpl->set_var($var);
-
+
                                // this will be the HTTP_POST_VARS[*key*] key 
value, the "id" for the submitted pref item
                                if ($this->bo->account_group == 'default')
                                {
@@ -165,7 +165,7 @@
                                        if ($this->debug > 1) { echo ' * 
email.uipreferences.create_prefs_block: html post array $key for this item is 
$html_pref_id: '.$html_pref_id.'<br>'; }
                                        $this->tpl->set_var('pref_id', 
$html_pref_id);
                                }
-
+
                                // we don't want to show a hidden value
                                if (!stristr($this_item['write_props'], 
'hidden'))
                                {
@@ -193,7 +193,7 @@
                                        $this->tpl->set_var('lang_blurb', 
$prev_lang_blurb.'&nbsp('.lang('hidden').')');
                                }
                                if ($this->debug > 1) { echo ' * 
email.uipreferences.create_prefs_block: after processing, $this_item_value: 
[<code>'.serialize($this_item_value).'</code>] ; $this_item DUMP <pre>'; 
print_r($this_item); echo '</pre>'; }
-
+
                                // ** possible widget are: **
                                // textarea
                                // textbox
@@ -205,13 +205,13 @@
                                        //$this_item_value = 
$actual_user_prefs[$this_item['id']];
                                        $this->tpl->set_var('pref_value', 
$this_item_value);
                                        
$this->tpl->parse('V_tr_textarea','B_tr_textarea');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_textarea');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_textarea');
                                }
                                elseif ($this_item['widget'] == 'textbox')
                                {
                                        $this->tpl->set_var('pref_value', 
$this_item_value);
                                        
$this->tpl->parse('V_tr_textbox','B_tr_textbox');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_textbox');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_textbox');
                                }
                                elseif ($this_item['widget'] == 'passwordbox')
                                {
@@ -219,14 +219,14 @@
                                        // if $this_item['write_props'] 
contains the word "hidden"
                                        $this->tpl->set_var('pref_value', 
$this_item_value);
                                        
$this->tpl->parse('V_tr_passwordbox','B_tr_passwordbox');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_passwordbox');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_passwordbox');
                                }
                                elseif ($this_item['widget'] == 'combobox')
                                {
                                        // set up combobox available options as 
KEYS array with empty VALUES
                                        reset($this_item['values']);
                                        $combo_availables = Array();
-                                       $x = 0;
+                                       $x = 0;
                                        while ( list ($key,$prop) = each 
($this_item['values']))
                                        {
                                                $combo_availables[$key] = '';
@@ -240,14 +240,14 @@
                                        $x = 0;
                                        while ( list ($key,$prop) = each 
($this_item['values']))
                                        {
-                                               $combobox_html .=
+                                               $combobox_html .=
                                                        '<option 
value="'.$key.'"'.$combo_available[$key].'>'.$prop.'</option>' ."\r\n";
                                                $x++;
                                        }
                                        $this_item_value = $combobox_html;
                                        $this->tpl->set_var('pref_value', 
$this_item_value);
                                        
$this->tpl->parse('V_tr_combobox','B_tr_combobox');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_combobox');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_combobox');
                                }
                                elseif ($this_item['widget'] == 'checkbox')
                                {
@@ -261,7 +261,7 @@
                                        }
                                        $this->tpl->set_var('pref_value', 
$this_item_value);
                                        
$this->tpl->parse('V_tr_checkbox','B_tr_checkbox');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_checkbox');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_checkbox');
                                }
                                else
                                {
@@ -270,7 +270,7 @@
                                        $this->tpl->set_var('back_color_class', 
$back_color_class);
                                        $this->tpl->set_var('section_title', 
'call for unsupported widget:'.$this_item['widget']);
                                        
$this->tpl->parse('V_tr_sec_title','B_tr_sec_title');
-                                       $done_widget = 
$this->tpl->get_var('V_tr_sec_title');
+                                       $done_widget = 
$this->tpl->get_var('V_tr_sec_title');
                                }
                                // add long help if requested
                                if 
((isset($GLOBALS['phpgw']->msg->ref_GET['show_help']))
@@ -285,7 +285,7 @@
                        if ($this->debug > 0 ) { echo 
'email.uipreferences.create_prefs_block: LEAVING, returning $return_block if 
widgets<br>'; }
                        return $return_block;
                }
-
+
                /*!
                @function preferences
                @abstract call this function to display the typical UI html 
page for email preferences
@@ -316,7 +316,7 @@
                                $this->preferences_default_acct_zero();
                        }
                }
-
+
                /*!
                @function preferences_default_acct_zero
                @abstract call this function to display the UI html page for 
email preferences for the Default Account
@@ -333,8 +333,8 @@
                        if ($this->debug > 1) { echo 
'email.uipreferences.preferences: about to set $this->bo->account_group<br>'; }
                        $this->bo->account_group = 'default';
                        if ($this->debug > 1) { echo 
'email.uipreferences.preferences: just set $this->bo->account_group to 
['.$this->bo->account_group.']<br>'; }
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -345,9 +345,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail preferences');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -357,10 +356,9 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_prefs_ui_out'        => 
'class_prefs_ui.tpl',
@@ -377,7 +375,7 @@
                        
$this->tpl->set_block('T_pref_blocks','B_tr_checkbox','V_tr_checkbox');
                        
$this->tpl->set_block('T_pref_blocks','B_submit_btn_only','V_submit_btn_only');
                        
$this->tpl->set_block('T_pref_blocks','B_submit_and_cancel_btns','V_submit_and_cancel_btns');
-
+
                        $var = Array(
                                'pref_errors'           => '',
                                'page_title'            => lang('E-Mail 
preferences'),
@@ -398,16 +396,16 @@
                                'btn_cancel_url'        => 
$GLOBALS['phpgw']->link('/preferences/index.php',array())
                        );
                        $this->tpl->set_var($var);
-
+
                        // this will fill the $this->bo->std_prefs[] and 
cust_prefs[]  "schema" arrays
                        if ($this->debug > 1) { echo 
'email.uipreferences.preferences: calling $this->bo->init_available_prefs() to 
init $this->bo->std_prefs[] and cust_prefs[]  "schema" arrays<br>'; }
-                       $this->bo->init_available_prefs();
-
+                       $this->bo->init_available_prefs();
+
                        if ($this->debug > 3) { echo 
'email.uipreferences.preferences: initiated schema dump:'; 
$this->bo->debug_dump_prefs(); }
-
+
                        // initialize a local var to hold the cumulative main 
block data
                        $prefs_ui_rows = '';
-
+
                        // ---  Standars Prefs  ---
                        // section title for standars prefs
                        $this->tpl->set_var('section_title', lang('Standard 
E-Mail preferences'));
@@ -439,12 +437,12 @@
                        // generate Std Prefs HTML Block
                        if ($this->debug > 1) { echo 
'email.uipreferences.preferences: about to generate the html for standard email 
prefs block<br>'; }
                        $prefs_ui_rows .= 
$this->create_prefs_block($this->bo->std_prefs);
-
+
                        // blank row
                        $this->tpl->set_var('back_color', 
$this->theme['bg_color']);
                        $done_widget = 
$this->tpl->parse('V_tr_blank','B_tr_blank');
                        $prefs_ui_rows .= $done_widget;
-
+
                        // ---  Custom Prefs  ---
                        $this->tpl->set_var('section_title', lang('Custom 
E-Mail preferences'));
                        $done_widget = 
$this->tpl->parse('V_tr_sec_title','B_tr_sec_title');
@@ -452,29 +450,29 @@
                        // generate Custom Prefs HTML Block
                        if ($this->debug > 1) { echo 
'email.uipreferences.preferences: about to generate the html for custom email 
prefs block<br>'; }
                        $prefs_ui_rows .= 
$this->create_prefs_block($this->bo->cust_prefs);
-
+
                        // blank row
                        $this->tpl->set_var('back_color', 
$this->theme['bg_color']);
                        $done_widget = 
$this->tpl->parse('V_tr_blank','B_tr_blank');
                        $prefs_ui_rows .= $done_widget;
-
+
                        // ---  Commit HTML Prefs rows to Main Template
                        // put all widget rows data into the template var
                        $this->tpl->set_var('prefs_ui_rows', $prefs_ui_rows);
-
+
                        // Submit Button only
                        //$submit_btn_row = 
$this->tpl->parse('V_submit_btn_only','B_submit_btn_only');
                        //$this->tpl->set_var('submit_btn_row', 
$submit_btn_row);
                        // Submit Button and Cancel button
                        $submit_btn_row = 
$this->tpl->parse('V_submit_and_cancel_btns','B_submit_and_cancel_btns');
                        $this->tpl->set_var('submit_btn_row', $submit_btn_row);
-
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
                        $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-
+
                        // output the template
                        if ($this->debug > 0) { echo 
'email.uipreferences.preferences: LEAVING, about to output the template<br>'; }
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
@@ -485,19 +483,15 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('E-Mail 
preferences');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('E-Mail 
preferences');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('E-Mail preferences');
                                $data['email_page'] = 
$this->tpl->parse('out','T_prefs_ui_out');
-                               // new way to handle debug data, if this array 
has anything, put it in the template source data vars
-                               //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
-                               //{
-                               //      $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                               //}
-                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
                }
-
+
                /*!
                @function ex_accounts_edit
                @abstract call this function to display the typical UI html 
page Extra Email Accounts Preferences
@@ -511,14 +505,14 @@
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: about to set 
$this->bo->account_group<br>'; }
                        $this->bo->account_group = 'extra_accounts';
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: just set $this->bo->account_group to 
['.$this->bo->account_group.']<br>'; }
-
+
                        // obtain the acctnum for the extra email account we 
are dealing with here
                        $acctnum = $this->bo->obtain_ex_acctnum();
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: $this->bo->obtain_ex_acctnum() returns 
['.serialize($acctnum).']<br>'; }
                        $this->bo->acctnum = $acctnum;
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: we just set $this->bo->acctnum to 
['.serialize($this->bo->acctnum).']<br>'; }
-
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -530,8 +524,7 @@
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }

-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail Extra Accounts');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -541,10 +534,9 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_prefs_ui_out'        => 
'class_prefs_ui.tpl',
@@ -561,7 +553,7 @@
                        
$this->tpl->set_block('T_pref_blocks','B_tr_checkbox','V_tr_checkbox');
                        
$this->tpl->set_block('T_pref_blocks','B_submit_btn_only','V_submit_btn_only');
                        
$this->tpl->set_block('T_pref_blocks','B_submit_and_cancel_btns','V_submit_and_cancel_btns');
-
+
                        $var = Array(
                                'pref_errors'           => '',
                                'page_title'            => lang('E-Mail Extra 
Accounts'),
@@ -588,16 +580,16 @@
                                )
                        );
                        $this->tpl->set_var($var);
-
+
                        // this will fill the $this->bo->std_prefs[] and 
cust_prefs[]  "schema" arrays
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: calling 
$this->bo->init_available_prefs() to init $this->bo->std_prefs[] and 
cust_prefs[]  "schema" arrays<br>'; }
-                       $this->bo->init_available_prefs();
-
+                       $this->bo->init_available_prefs();
+
                        if ($this->debug > 3) { echo 
'email.uipreferences.ex_accounts_edit: initiated schema dump:'; 
$this->bo->debug_dump_prefs(); }
-
+
                        // initialize a local var to hold the cumulative main 
block data
                        $prefs_ui_rows = '';
-
+
                        // ---  Extra Account Pref Items  ---
                        // section title
                        $this->tpl->set_var('section_title', '*** 
'.lang('E-Mail Extra Account').' *** '.lang('Number').' '.$this->bo->acctnum);
@@ -628,7 +620,7 @@
                        $done_widget = 
$this->tpl->parse('V_tr_sec_title','B_tr_sec_title');
                        // add the finished widget row to the main block 
variable
                        $prefs_ui_rows .= $done_widget;
-
+
                        // instructions: fill in everything you need
                        $this->tpl->set_var('section_title', lang('Please fill 
in everything you need'));
                        // parse the block,
@@ -637,10 +629,10 @@
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: about to generate the html for standard 
email prefs block<br>'; }
                        // add the finished widget row to the main block 
variable
                        $prefs_ui_rows .= $done_widget;
-
+
                        // generate Std Prefs HTML Block
                        $prefs_ui_rows .= 
$this->create_prefs_block($this->bo->std_prefs);
-
+
                        // ---  Custom Prefs  ---
                        $this->tpl->set_var('section_title', lang('Custom 
E-Mail Settings').' &#040;'.lang('required').'&#041;');
                        $done_widget = 
$this->tpl->parse('V_tr_sec_title','B_tr_sec_title');
@@ -652,26 +644,26 @@
                        // generate Custom Prefs HTML Block
                        if ($this->debug > 1) { echo 
'email.uipreferences.ex_accounts_edit: about to generate the html for custom 
email prefs block<br>'; }
                        $prefs_ui_rows .= 
$this->create_prefs_block($this->bo->cust_prefs);
-
+
                        // blank row
                        $this->tpl->set_var('back_color', 
$this->theme['bg_color']);
                        $done_widget = 
$this->tpl->parse('V_tr_blank','B_tr_blank');
                        $prefs_ui_rows .= $done_widget;
-
+
                        // ---  Commit HTML Prefs rows to Main Template
                        // put all widget rows data into the template var
                        $this->tpl->set_var('prefs_ui_rows', $prefs_ui_rows);
-
+
                        // Submit Button and Cancel button
                        $submit_btn_row = 
$this->tpl->parse('V_submit_and_cancel_btns','B_submit_and_cancel_btns');
                        $this->tpl->set_var('submit_btn_row', $submit_btn_row);
-
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
                        $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-
+
                        // output the template
                        if ($this->debug > 0) { echo 
'email.uipreferences.ex_accounts_edit: LEAVING, about to output the 
template<br>'; }
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
@@ -682,23 +674,19 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('E-Mail Extra 
Accounts');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('E-Mail Extra 
Accounts');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('E-Mail Extra Accounts');
                                $data['email_page'] = 
$this->tpl->parse('out','T_prefs_ui_out');
-                               // new way to handle debug data, if this array 
has anything, put it in the template source data vars
-                               //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
-                               //{
-                               //      $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                               //}
-                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
                }
-
-
+
+
                function ex_accounts_list()
                {
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                // we point to the global template for this 
version of phpgw templatings
                                $this->tpl =& $GLOBALS['phpgw']->template;
@@ -709,9 +697,8 @@
                                // we use a PRIVATE template object for 0.9.14 
conpat and during xslt porting
                                $this->tpl = 
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                        }
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('E-Mail Extra Accounts List');
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -721,17 +708,16 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('app_data'));
                        }
-
+
                        $this->tpl->set_file(
                                Array(
                                        'T_prefs_ex_accounts'   => 
'class_prefs_ex_accounts.tpl'
                                )
                        );
                        
$this->tpl->set_block('T_prefs_ex_accounts','B_accts_list','V_accts_list');
-
+
                        $var = Array(
                                'pref_errors'           => '',
                                'font'                          => 
$this->theme['font'],
@@ -745,10 +731,10 @@
                                'lang_delete'           => lang('Delete')
                        );
                        $this->tpl->set_var($var);
-
+
                        $acctount_list = array();
                        $acctount_list = $this->bo->ex_accounts_list();
-
+
                        // here's what we get back
                        //$acctount_list[$X]['acctnum']
                        //$acctount_list[$X]['status']
@@ -759,9 +745,9 @@
                        //$acctount_list[$X]['edit_href']
                        //$acctount_list[$X]['delete_url']
                        //$acctount_list[$X]['delete_href']
-
+
                        if ($this->debug) { echo 'email: 
uipreferences.ex_accounts_list: $acctount_list dump<pre>'; 
print_r($acctount_list); echo '</pre>'; }
-
+
                        $tr_color = $this->theme['row_off'];
                        $loops = count($acctount_list);
                        if ($loops == 0)
@@ -802,17 +788,17 @@
                                                                        
.'&ex_acctnum='.$this->bo->add_new_account_token);
                        $add_new_acct_href = '<a 
href="'.$add_new_acct_url.'">'.lang('New Account').'</a>';
                        
$this->tpl->set_var('add_new_acct_href',$add_new_acct_href);
-
+
                        $done_url = $GLOBALS['phpgw']->link(
                                                                        
'/preferences/index.php');
                        $done_href = '<a 
href="'.$done_url.'">'.lang('Done').'</a>';
                        $this->tpl->set_var('done_href',$done_href);
-
+
                        // new way to handle debug data, if there is debug 
data, this will put it in the template source data vars
                        $this->tpl->set_var('debugdata', 
$GLOBALS['phpgw']->msg->dbug->notice_pagedone());
-
+
                        // output the template
-                       if ($GLOBALS['phpgw']->msg->phpgw_0914_orless)
+                       if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
                        {
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
@@ -823,16 +809,12 @@
                                $this->tpl->set_unknowns('comment');
                                //$this->tpl->set_unknowns('remove');
                                $data = array();
-                               $data['appname'] = lang('E-Mail');
-                               $data['function_msg'] = lang('E-Mail Extra 
Accounts List');
+                               //$data['appname'] = lang('E-Mail');
+                               //$data['function_msg'] = lang('E-Mail Extra 
Accounts List');
+                               
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' 
. lang('E-Mail Extra Accounts List');
                                $data['email_page'] = 
$this->tpl->parse('out','T_prefs_ex_accounts');
-                               // new way to handle debug data, if this array 
has anything, put it in the template source data vars
-                               //if ($GLOBALS['phpgw']->msg->dbug->debugdata)
-                               //{
-                               //      $data['debugdata'] = 
$GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
-                               //}
-                               
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('generic_out' => $data));
+                               $GLOBALS['phpgw']->xslttpl->pp();
                        }
                }
        }

====================================================

====================================================

====================================================
Index: email/inc/hook_home.inc.php
diff -u email/inc/hook_home.inc.php:1.56 email/inc/hook_home.inc.php:1.57
--- email/inc/hook_home.inc.php:1.56    Fri Mar 14 04:01:54 2003
+++ email/inc/hook_home.inc.php Thu Dec 30 23:13:50 2004
@@ -1,24 +1,24 @@
-<?php
-  /**************************************************************************\
-  * phpGroupWare - E-Mail                                                    *
-  * http://www.phpgroupware.org                                              *
-  * --------------------------------------------                             *
-  *  This program is free software; you can redistribute it and/or modify it *
-  *  under the terms of the GNU General Public License as published by the   *
-  *  Free Software Foundation; either version 2 of the License, or (at your  *
-  *  option) any later version.                                              *
-  \**************************************************************************/
-
-       /* $Id$ */
-
-       $d1 = 
strtolower(substr($GLOBALS['phpgw_info']['server']['app_inc'],0,3));
-       if($d1 == 'htt' || $d1 == 'ftp' )
-       {
-               echo "Failed attempt to break in via an old Security 
Hole!<br>\n";
-               $GLOBALS['phpgw']->common->phpgw_exit();
-       }
-       unset($d1);
-
+<?php
+  /**************************************************************************\
+  * phpGroupWare - E-Mail                                                    *
+  * http://www.phpgroupware.org                                              *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+       /* $Id$ */
+
+       $d1 = 
strtolower(substr($GLOBALS['phpgw_info']['server']['app_inc'],0,3));
+       if($d1 == 'htt' || $d1 == 'ftp' )
+       {
+               echo "Failed attempt to break in via an old Security 
Hole!<br>\n";
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+       unset($d1);
+

        // does this array item actually exist before we create the mail_msg, 
where is it created?
        //if 
($GLOBALS['phpgw_info']['user']['preferences']['email']['mainscreen_showmail'] 
== True)
@@ -47,108 +47,108 @@
        // (2) by doing a loop testing for accounts other then just account 0
        if ($GLOBALS['phpgw']->msg->get_isset_pref('mainscreen_showmail', 0))
        {
-               // from here on, msg objects opens streams on demand if requied
-               $data = Array();
-
-               /*  class mail_msg "new_message_check()"
-                 // this is the structure you will get
-                 $inbox_data['is_imap'] boolean - pop3 server do not know what 
is "new" or not
-                 $inbox_data['folder_checked'] string - the folder checked, as 
processed by the msg class
-                 $inbox_data['alert_string'] string - what to show the user 
about this inbox check
-                 $inbox_data['number_new'] integer - for IMAP is number 
"unseen"; for pop3 is number messages
-                 $inbox_data['number_all'] integer - for IMAP and pop3 is 
total number messages in that inbox
-               */
-               $inbox_data = Array();
-               $inbox_data = $GLOBALS['phpgw']->msg->new_message_check();
+               // from here on, msg objects opens streams on demand if requied
+               $data = Array();
+
+               /*  class mail_msg "new_message_check()"
+                 // this is the structure you will get
+                 $inbox_data['is_imap'] boolean - pop3 server do not know what 
is "new" or not
+                 $inbox_data['folder_checked'] string - the folder checked, as 
processed by the msg class
+                 $inbox_data['alert_string'] string - what to show the user 
about this inbox check
+                 $inbox_data['number_new'] integer - for IMAP is number 
"unseen"; for pop3 is number messages
+                 $inbox_data['number_all'] integer - for IMAP and pop3 is 
total number messages in that inbox
+               */
+               $inbox_data = Array();
+               $inbox_data = $GLOBALS['phpgw']->msg->new_message_check();
                //if ($debug_hook_home > 2) { echo 'hook_home('.__LINE__.'): 
$inbox_data dump:<pre>'; print_r($inbox_data); echo '</pre>'; }
-
-               $title = '<font color="#FFFFFF">'.lang('EMail').' 
'.$inbox_data['alert_string'].'</font>';
-
-               if($inbox_data['number_all'] >= 5)
-               {
-                       $check_msgs = 5;
-               }
-               else
-               {
-                       $check_msgs = $inbox_data['number_all'];
-               }
-               if ($inbox_data['number_all'] > 0)
-               {
-                       $msgball_list = array();
-                       $msgball_list = 
$GLOBALS['phpgw']->msg->get_msgball_list();
-               }
+
+               $title = '<font color="#FFFFFF">'.lang('EMail').' 
'.$inbox_data['alert_string'].'</font>';
+
+               if($inbox_data['number_all'] >= 5)
+               {
+                       $check_msgs = 5;
+               }
+               else
+               {
+                       $check_msgs = $inbox_data['number_all'];
+               }
+               if ($inbox_data['number_all'] > 0)
+               {
+                       $msgball_list = array();
+                       $msgball_list = 
$GLOBALS['phpgw']->msg->get_msgball_list();
+               }
                //if ($debug_hook_home > 2) { echo 'hook_home('.__LINE__.'): 
call to "get_msgball_list" returns $msgball_list dump:<pre>'; 
print_r($msgball_list); echo '</pre>'; }
-               for($i=0; $i<$check_msgs; $i++)
+               for($i=0; $i<$check_msgs; $i++)
                {
                        $this_loop_msgball = 
$GLOBALS['phpgw']->msg->ball_data_parse_str($msgball_list[$i]);
-                       //if ($debug_hook_home > 1) { echo ' * 
hook_home('.__LINE__.'): $msgball_list['.$i.'] ['.$msgball_list[$i].']; 
$this_loop_msgball: ['.serialize($this_loop_msgball).']<br>'; }
-                       $msg_headers = 
$GLOBALS['phpgw']->msg->phpgw_header($this_loop_msgball);
-                       $subject = 
$GLOBALS['phpgw']->msg->get_subject($msg_headers,'');
-                       if(strlen($subject) > 65)
-                       {
-                               $subject = substr($subject,0,65).' ...';
-                       }
-                       $data[] = array(
-                               'text' => $subject,
-                               'link' => $GLOBALS['phpgw']->link(
-                                               '/index.php',
-                                               
'menuaction=email.uimessage.message'
-                                               .'&'.$this_loop_msgball['uri']
-                               )
-                       );
-               }
-
-               // COMPOSE NEW email link
-               $compose_link = $GLOBALS['phpgw']->link(
-                                       '/index.php',
-                                       'menuaction=email.uicompose.compose'
-                                       // this data tells us where to return 
to after sending a message
-                                       // since we started from home page, 
send can not (at this time) take us back there
-                                       // so instead take user to INBOX for 
the default account (acctnum 0) after clicking the send button
-                                       .'&fldball[folder]=INBOX'
-                                       .'&fldball[acctnum]=0'
-               );
-               $compose_href = '<a href="'.$compose_link.'">'.lang('Compose 
New').'</a>'."\r\n";
-
-               // ADD FOLDER LISTBOX TO HOME PAGE (Needs to be TEMPLATED)
-               // Does This Mailbox Support Folders (i.e. more than just 
INBOX)?
-               if($GLOBALS['phpgw']->msg->get_mailsvr_supports_folders() == 
False)
-               {
-                       $extra_data = '&nbsp; &nbsp;'.$compose_href;
-               }
-               else
-               {
-                       // build the $feed_args array for the 
all_folders_listbox function
-                       // anything not specified will be replace with a 
default value if the function has one for that param
+                       //if ($debug_hook_home > 1) { echo ' * 
hook_home('.__LINE__.'): $msgball_list['.$i.'] ['.$msgball_list[$i].']; 
$this_loop_msgball: ['.serialize($this_loop_msgball).']<br>'; }
+                       $msg_headers = 
$GLOBALS['phpgw']->msg->phpgw_header($this_loop_msgball);
+                       $subject = 
$GLOBALS['phpgw']->msg->get_subject($msg_headers,'');
+                       if(strlen($subject) > 65)
+                       {
+                               $subject = substr($subject,0,65).' ...';
+                       }
+                       $data[] = array(
+                               'text' => $subject,
+                               'link' => $GLOBALS['phpgw']->link(
+                                               '/index.php',
+                                               
'menuaction=email.uimessage.message'
+                                               .'&'.$this_loop_msgball['uri']
+                               )
+                       );
+               }
+
+               // COMPOSE NEW email link
+               $compose_link = $GLOBALS['phpgw']->link(
+                                       '/index.php',
+                                       'menuaction=email.uicompose.compose'
+                                       // this data tells us where to return 
to after sending a message
+                                       // since we started from home page, 
send can not (at this time) take us back there
+                                       // so instead take user to INBOX for 
the default account (acctnum 0) after clicking the send button
+                                       .'&fldball[folder]=INBOX'
+                                       .'&fldball[acctnum]=0'
+               );
+               $compose_href = '<a href="'.$compose_link.'">'.lang('Compose 
New').'</a>'."\r\n";
+
+               // ADD FOLDER LISTBOX TO HOME PAGE (Needs to be TEMPLATED)
+               // Does This Mailbox Support Folders (i.e. more than just 
INBOX)?
+               if($GLOBALS['phpgw']->msg->get_mailsvr_supports_folders() == 
False)
+               {
+                       $extra_data = '&nbsp; &nbsp;'.$compose_href;
+               }
+               else
+               {
+                       // build the $feed_args array for the 
all_folders_listbox function
+                       // anything not specified will be replace with a 
default value if the function has one for that param
                        /*
-                       $feed_args = Array(
-                               'mailsvr_stream'    => '',
-                               'pre_select_folder' => '',
-                               'skip_folder'       => '',
-                               'show_num_new'      => 
$GLOBALS['phpgw_info']['user']['preferences']['email']['newmsg_combobox'],
-                               'widget_name'       => 'fldball_fake_uri',
-                               'folder_key_name'   => 'folder',
-                               'acctnum_key_name'  => 'acctnum',
-                               'on_change'         => 
'document.switchbox.submit()',
-                               'first_line_txt'    => lang('switch current 
folder to')
-                       );
-                       // get you custom built HTML listbox (a.k.a. selectbox) 
widget
-                       $switchbox_listbox = 
$GLOBALS['phpgw']->msg->all_folders_listbox($feed_args);
-                       // make it another TR we can insert into the home page 
portal object
-                       // and surround it in FORM tags so the submit will work
-                       $switchbox_action = $GLOBALS['phpgw']->link(
-                                               '/index.php',
-                                               'menuaction=email.uiindex.index'
-                       );
-                       $extra_data = '<form name="switchbox" 
action="'.$switchbox_action.'" method="post">'."\r\n"
-                               .'<td align="left">'."\r\n"
-                               .'&nbsp;<strong>'.lang('E-Mail 
Folders').':</strong>&nbsp;'.$switchbox_listbox."\r\n"
-                               .'&nbsp; &nbsp;'.$compose_href."\r\n"
-                               .'</td>'."\r\n"
+                       $feed_args = Array(
+                               'mailsvr_stream'    => '',
+                               'pre_select_folder' => '',
+                               'skip_folder'       => '',
+                               'show_num_new'      => 
$GLOBALS['phpgw_info']['user']['preferences']['email']['newmsg_combobox'],
+                               'widget_name'       => 'fldball_fake_uri',
+                               'folder_key_name'   => 'folder',
+                               'acctnum_key_name'  => 'acctnum',
+                               'on_change'         => 
'document.switchbox.submit()',
+                               'first_line_txt'    => lang('switch current 
folder to')
+                       );
+                       // get you custom built HTML listbox (a.k.a. selectbox) 
widget
+                       $switchbox_listbox = 
$GLOBALS['phpgw']->msg->all_folders_listbox($feed_args);
+                       // make it another TR we can insert into the home page 
portal object
+                       // and surround it in FORM tags so the submit will work
+                       $switchbox_action = $GLOBALS['phpgw']->link(
+                                               '/index.php',
+                                               'menuaction=email.uiindex.index'
+                       );
+                       $extra_data = '<form name="switchbox" 
action="'.$switchbox_action.'" method="post">'."\r\n"
+                               .'<td align="left">'."\r\n"
+                               .'&nbsp;<strong>'.lang('E-Mail 
Folders').':</strong>&nbsp;'.$switchbox_listbox."\r\n"
+                               .'&nbsp; &nbsp;'.$compose_href."\r\n"
+                               .'</td>'."\r\n"
                                .'</form>'."\r\n";
                        */
                        // REPLACE all the above with some high levels calls to 
the widget class
-                       // WHY does not lang inbox work here? It is called in 
the base class and works fine except from "home" page.
+                       // WHY does not lang inbox work here? It is called in 
the base class and works fine except from "home" page.
                        $my_widgets = CreateObject('email.html_widgets');
                        $my_widgets->new_form();
                        $my_widgets->set_form_name('switchbox');
@@ -165,48 +165,144 @@
                                .'&nbsp; &nbsp;'.$compose_href
                                .'</td>'."\r\n"
                                .$form_folder_switch_closetag;
-               }
-
-               if ((isset($prev_currentapp))
-               && ($prev_currentapp)
-               && ($GLOBALS['phpgw_info']['flags']['currentapp'] != 
$prev_currentapp))
+               }
+
+               // how to display this data
+               if (is_object($GLOBALS['phpgw']->xslttpl))
+               {
+                       $phpgw_before_xslt = False;
+               }
+               else
                {
-                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$prev_currentapp;
+                       $phpgw_before_xslt = True;
                }

-               $portalbox = CreateObject('phpgwapi.listbox',
-                       Array(
-                               'title'     => $title,
-                               'primary'   => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                               'secondary' => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                               'tertiary'  => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                               'width'     => '100%',
-                               'outerborderwidth' => '0',
-                               'header_background_image' => 
$GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
-                       )
-               );
-               $app_id = $GLOBALS['phpgw']->applications->name2id('email');
-               $GLOBALS['portal_order'][] = $app_id;
-               $var = Array(
-                       'up'       => Array('url' => '/set_box.php', 'app' => 
$app_id),
-                       'down'     => Array('url' => '/set_box.php', 'app' => 
$app_id),
-                       'close'    => Array('url' => '/set_box.php', 'app' => 
$app_id),
-                       'question' => Array('url' => '/set_box.php', 'app' => 
$app_id),
-                       'edit'     => Array('url' => '/set_box.php', 'app' => 
$app_id)
-               );
-
-               while(list($key,$value) = each($var))
-               {
-                       $portalbox->set_controls($key,$value);
-               }
-
-               $portalbox->data = $data;
-
-               // output the portalbox and below it (1) the folders listbox 
(if applicable) and (2) Compose New mail link
-               echo "\n".'<!-- BEGIN Mailbox info 
-->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
+               // now display according to the version of the template system 
in use
+               if ($phpgw_before_xslt == True)
+               {
+                       // the is the OLD, pre-xslt way to display pref items
+                       // reset the currentapp to whatever it was
+                       if ((isset($prev_currentapp))
+                       && ($prev_currentapp)
+                       && ($GLOBALS['phpgw_info']['flags']['currentapp'] != 
$prev_currentapp))
+                       {
+                               $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$prev_currentapp;
+                       }
+                       $portalbox = CreateObject('phpgwapi.listbox',
+                               Array(
+                                       'title'     => $title,
+                                       'primary'   => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                                       'secondary' => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                                       'tertiary'  => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                                       'width'     => '100%',
+                                       'outerborderwidth' => '0',
+                                       'header_background_image' => 
$GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
+                               )
+                       );
+                       $app_id = 
$GLOBALS['phpgw']->applications->name2id('email');
+                       $GLOBALS['portal_order'][] = $app_id;
+                       $var = Array(
+                               'up'       => Array('url' => '/set_box.php', 
'app' => $app_id),
+                               'down'     => Array('url' => '/set_box.php', 
'app' => $app_id),
+                               'close'    => Array('url' => '/set_box.php', 
'app' => $app_id),
+                               'question' => Array('url' => '/set_box.php', 
'app' => $app_id),
+                               'edit'     => Array('url' => '/set_box.php', 
'app' => $app_id)
+                       );
+
+                       while(list($key,$value) = each($var))
+                       {
+                               $portalbox->set_controls($key,$value);
+                       }
+
+                       $portalbox->data = $data;
+
+                       // output the portalbox and below it (1) the folders 
listbox (if applicable) and (2) Compose New mail link
+                       echo "\n".'<!-- BEGIN Mailbox info 
-->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
+               }
+               else
+               {
+                       // this is the xslt template era
+                       // adjust the title for no html tags
+                       $title = lang('EMail').' '.$inbox_data['alert_string'];
+
+                       $GLOBALS['phpgw']->translation->add_app('email');
+                       //$GLOBALS['phpgw']->translation->add_app('E-Mail');
+
+                       $app_id = 
$GLOBALS['phpgw']->applications->name2id('email');
+                       $GLOBALS['portal_order'][] = $app_id;
+
+                       $GLOBALS['phpgw']->portalbox->set_params(
+                               array(
+                                       'app_id'        => $app_id,
+                                       'title'         => $title
+                               )
+                       );
+                       // assemble the data BRUTE FORCE
+                       // FIXME apparently needs an xsl file called 
"portal.xsl"
+                       /*
+                       $main_data = '<table border="0" width="100%">'."\r\n";
+                       for($i=0; $i<count($data); $i++)
+                       {
+                               $main_data .=
+                                       '<tr>'
+                                               .'<td width="2%" align="right"> 
&nbsp; </td>'
+                                               .'<td width="98%" align="left">'
+                                                       .'<a 
href="'.$data[$i]['link'].'">'.$data[$i]['text'].'</a>'
+                                               .'</td>'
+                                       .'</tr>'."\r\n";
+                       }
+                       $main_data .=
+                               '<td width="2%"> &nbsp; </td>'
+                               .$form_folder_switch_opentag
+                               .'<td width="98%" align="left">'."\r\n"
+                                       .'&nbsp;<strong>'.lang('E-Mail 
Folders').':</strong>&nbsp;'
+                                       .$folder_switch_combobox
+                                       .'&nbsp; &nbsp;'.$compose_href
+                               .'</td>'."\r\n"
+                               .$form_folder_switch_closetag;
+
+                       $main_data .= '</table>'."\r\n";
+                       */
+                       $main_data =
+                               '<table border="0" width="100%">'
+                               .'<tr>'."\r\n"
+                                       .'<td width="100%" align="left">'."\r\n"
+                                               .'<ul>'."\r\n";
+                       for($i=0; $i<count($data); $i++)
+                       {
+                               $main_data .= '<li>'.'<a 
href="'.$data[$i]['link'].'">'.$data[$i]['text'].'</a>'.'</li>'."\r\n";
+                       }
+                       $main_data .=
+                                               '</ul>'."\r\n"
+                                       .'</td>'."\r\n"
+                               .'</tr>'."\r\n"
+                               .'<tr><td><hr></td></tr>'."\r\n"
+                               .'<tr>'."\r\n"
+                                       .$form_folder_switch_opentag
+                                       .'<td width="100%" align="left">'."\r\n"
+                                               .'&nbsp;<strong>'.lang('E-Mail 
Folders').':</strong>&nbsp;'
+                                               .$folder_switch_combobox
+                                               .'&nbsp; &nbsp;'.$compose_href
+                                       .'</td>'."\r\n"
+                                       .$form_folder_switch_closetag
+                               .'</tr>'."\r\n"
+                               .'</table>'."\r\n";
+
+                       $GLOBALS['phpgw']->portalbox->draw($main_data);
+
+                       // reset the currentapp to whatever it was
+                       if ((isset($prev_currentapp))
+                       && ($prev_currentapp)
+                       && ($GLOBALS['phpgw_info']['flags']['currentapp'] != 
$prev_currentapp))
+                       {
+                               $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$prev_currentapp;
+                       }
+
+               }
        }
+
        // we create the msg object initially so we can have access to the 
multi-account preferences,
        // so even if we did not output any data here, we still must call this 
"end_request" function, it is kind of like a destructor
        $GLOBALS['phpgw']->msg->end_request();
-
-?>
+
+?>

====================================================
Index: email/inc/hook_admin.inc.php
diff -u email/inc/hook_admin.inc.php:1.7 email/inc/hook_admin.inc.php:1.8
--- email/inc/hook_admin.inc.php:1.7    Wed Apr 23 01:40:17 2003
+++ email/inc/hook_admin.inc.php        Thu Dec 30 23:13:50 2004
@@ -1,21 +1,23 @@
 <?php
-       
/**************************************************************************\
-       * phpGroupWare                                                          
   *
-       * http://www.phpgroupware.org                                           
   *
-       * --------------------------------------------                          
   *
-       *  This program is free software; you can redistribute it and/or modify 
it *
-       *  under the terms of the GNU General Public License as published by 
the   *
-       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
-       *  option) any later version.                                           
   *
-       
\**************************************************************************/
-       /* $Id$ */
-       {
+  /**************************************************************************\
+  * phpGroupWare                                                             *
+  * http://www.phpgroupware.org                                              *
+  * Written by Joseph Engo <address@hidden>                          *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+  /* $Id$ */
+{
 // Only Modify the $file and $title variables.....
-               $file = Array
-               (
-                       'Site Configuration' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' 
. $appname)
-               );
+       $title = $appname;
+       $file = Array(
+               'Site Configuration'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' 
. $appname)
+       );
 //Do not modify below this line
-               $GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
-       }
+       display_section($appname,$title,$file);
+}
 ?>

====================================================

====================================================
Index: email/inc/functions.inc.php
diff -u email/inc/functions.inc.php:1.117 email/inc/functions.inc.php:1.118
--- email/inc/functions.inc.php:1.117   Sun Apr 20 20:47:50 2003
+++ email/inc/functions.inc.php Thu Dec 30 23:13:50 2004
@@ -31,4 +31,5 @@
        this is undesirable - turn it off.
        */
        set_magic_quotes_runtime(0);
+
 ?>

====================================================
Index: class.email_service.inc.php
<?php

/**

 * email module service

 * @author Philipp Kamps <address@hidden>

 * @copyright Copyright (C) 2003 Free Software Foundation http://www.fsf.org/

 * @license http://www.fsf.org/licenses/gpl.html GNU General Public License

 * @package email

 * @subpackage sevice

 * @version $Id:

 */



class email_service

{



        var $msg_bootstrap; //email.msg_bootstrap

        var $bopreferences;



        // constructor

        function email_service()

        {

                $this->bopreferences = CreateObject('email.bopreferences');

        }



/**

* The method provides the list of email folders

* @access public

* @return array

*/

        function getFolderContent()

        {

                $tpl_set = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'];



                // make sure we have msg object and a server stream

                $this->msg_bootstrap = CreateObject("email.msg_bootstrap");

                
$this->msg_bootstrap->ensure_mail_msg_exists('email.bofolder.folder', 
$this->debug);



                $standard_account = array ('acctnum'        => 0,

                                           'status'         => 'enabled',

                                           'display_string' => '[0] standard'

                                           );



                $extra_account_list = $this->bopreferences->ex_accounts_list();



                array_unshift($extra_account_list, $standard_account);

                $account_list = $extra_account_list;



                $return = array();

                for ($i=0; $i < count($account_list); $i++)

                {

                        if ($account_list[$i]['status'] == 'enabled')

                        {

                                $account_name = 
substr($account_list[$i]['display_string'],(strrpos($account_list[$i]['display_string'],']')+2));

                                $account_name = lang('mailbox').' 
\''.$account_name.'\'';

                                $id = 
strval('email_'.$account_list[$i]['acctnum']);

                                $return[$id] = array('text'      => 
$account_name,

                                                     'parent_id' => '0',

                                                     'icon'      => ''

                                                          );



                                $folder_list_i = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list',$account_list[$i]['acctnum']);



                                for ($j=0; $j < count($folder_list_i); $j++)

                                {

                                        $separator = 
$this->get_IMAP_folder_separator($folder_list_i[$j]['folder_long']);

                                        $path = explode($separator, 
$folder_list_i[$j]['folder_long']);



                                        // calculate parent folder

                                        if (count($path) == 1)

                                        {

                                                $parent = 
'email_'.$account_list[$i]['acctnum'];

                                        }

                                        else

                                        {

                                                //special handling for the 
courir server

                                                if ( $path[count($path) - 2] == 
'INBOX' && $separator == '.' )

                                                {

                                                        $parent = 
'email_'.$account_list[$i]['acctnum'];

                                                }

                                                else

                                                {

                                                        $parent = 
'email_'.$account_list[$i]['acctnum'].'_'.$path[count($path) - 2];

                                                }

                                        }



                                        // parse link to view email folder

                                        $folderName = 
$GLOBALS['phpgw']->msg->prep_folder_out($folder_list_i[$j]['folder_long']);

                                        $folderLink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'.

                                                                              
'&fldball[folder]='.$folderName.

                                                                              
'&fldball[acctnum]='.$account_list[$i]['acctnum']

                                                                              );



                                        $id = 
'email_'.$account_list[$i]['acctnum'].'_'.$path[count($path)-1];

                                        $return[$id] = array('text'      => 
$path[count($path)-1],

                                                             'title'     => 
$folder_list_i[$j]['folder_long'],

                                                             'icon'      => 
'email/templates/'.$tpl_set.'/images/folders.png',

                                                             'parent_id' => 
$parent,

                                                             'href'      => 
$folderLink,

                                                             'target'    => 
'_parent'

                                                            );

                                }

                        }

                }

                return array('content' => $return);

        }



/**

* Get the IMAP folder separator

* @access privat

* @return string

*/

        function get_IMAP_folder_separator($string)

        {

                //exchange

                if (strpos($string, '/'))

                {

                        $separator = '/';

                }

                //courir

                elseif (strpos($string, '.'))

                {

                        $separator = '.';

                }

                else

                {

                        $separator = 'I doubt this string is used somewhere';

                }

                return $separator;

        }

}

?>

====================================================
Index: hook_login.inc.php
<?php
        $sql  = 'DELETE FROM phpgw_anglemail ';
        $sql .= "WHERE account_id='" . 
intval($GLOBALS['phpgw_info']["user"]["account_id"]) . "'";
    $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
?>

====================================================
Index: class.uisearch.inc.php
<?php
        
/**************************************************************************\
        * phpGroupWare - email/search                                           
   *
        * Written by Rohan Almeida (address@hidden)                 *
        * -----------------------------------------------                       
   *
        *  This program is free software; you can redistribute it and/or modify 
it *
        *  under the terms of the GNU General Public License as published by 
the   *
        *  Free Software Foundation; either version 2 of the License, or (at 
your  *
        *  option) any later version.                                           
   *
        
\**************************************************************************/

        /* $Id: class.uisearch.inc.php,v 1.2 2004/12/30 23:13:50 skwashd Exp $ 
*/


        class uisearch
        {
                var $debug = False;

                var $flags_array = array ();

                var $month_array = array ();

                var $public_functions = array(
                        'form' => True,
                        'search' => True
                );

                function uisearch()
                {
                        // make sure we have msg object
                        $msg_bootstrap = CreateObject("email.msg_bootstrap");
                        $msg_bootstrap->set_do_login(BS_LOGIN_ONLY_IF_NEEDED);
                        $msg_bootstrap->ensure_mail_msg_exists('email.uisearch 
*constructor*', 0);
                        //return;

                        $this->flags_array = array (  'flg_all'         =>      
lang('All'),
                                                'flg_answered'          =>      
lang('Answered'),
                                                'flg_deleted'           =>      
lang('Deleted'),
                                                'flg_flagged'           =>      
lang('Flagged'),
                                                'flg_new'               =>      
lang('New'),
                                                'flg_old'               =>      
lang('Old'),                                                                    
             'flg_recent'            =>      lang('Recent'),
                                                'flg_seen'              =>      
lang('Seen'),
                                                'flg_unanswered'        =>      
lang('Unanswered'),
                                                'flg_undeleted'         =>      
lang('Undeleted'),
                                                'flg_unflagged'         =>      
lang('Unflagged'),
                                                'flg_unseen'            =>      
lang('Unseen'),
                                                );
                                                                                
                                                                                
                                                                                
                                  $this->month_array = array (  '01'            
        =>      lang('Jan'),
                                                '02'                    =>      
lang('Feb'),
                                                '03'                    =>      
lang('Mar'),
                                                '04'                    =>      
lang('Apr'),
                                                '05'                    =>      
lang('May'),
                                                '06'                    =>      
lang('Jun'),
                                                '07'                    =>      
lang('Jul'),
                                                '08'                    =>      
lang('Aug'),
                                                '09'                    =>      
lang('Sep'),
                                                '10'                    =>      
lang('Oct'),
                                                '11'                    =>      
lang('Nov'),
                                                '12'                    =>      
lang('Dec')
                                        );
                                                                                
                                                                        }

                function form()
                {
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
                        $GLOBALS['phpgw']->common->phpgw_header();

                        //$GLOBALS['phpgw']->msg = 
CreateObject('email.mail_msg');
                        //$GLOBALS['phpgw']->msg->begin_request( 
array("do_login" => True) );
                        //$GLOBALS['phpgw']->msg->ensure_stream_and_folder();

                        $GLOBALS['phpgw']->htmlwid = 
CreateObject('email.html_widgets');
                        print $GLOBALS['phpgw']->htmlwid->get_toolbar();

                        # get folder list
                        //$folder_list = 
$GLOBALS['phpgw']->msg->get_folder_list();
                        $folder_list = 
$GLOBALS['phpgw']->msg->get_arg_value('folder_list');

                        $todays_date = $this->get_date();
                        $week_date = $this->get_week_date(1);
                        $month_date = $this->get_week_date(5);

                        $t = $GLOBALS['phpgw']->template;
                        $t->set_file("frmhandle", "search_form.tpl");

                        # make a "fldball" to remember what account and folder 
we came from initially
                        $fldball = array();


                        # Set form action
                        $t->set_var("form_action", 
$GLOBALS['phpgw']->link('/index.php',
                                array
                                (
                                        'menuaction' => 'email.uisearch.search',
                                        // this data tells us what folder and 
account was last active
                                        // SET GENERIC fldbal to INBOX just so 
we have a folder element
                                        'fldball[folder]' => 
$GLOBALS['phpgw']->msg->prep_folder_out(),
                                        // this preserves the acctnum we want 
to search
                                        'fldball[acctnum]' => 
$GLOBALS['phpgw']->msg->get_acctnum()
                                )
                        ));

                        # parse flag
                        $t->set_block("frmhandle", "flag", "flags");
                        $t->set_var('lang_check_flags',lang('Check Flags for 
type of mails'));
                        while (list($name, $value) = each($this->flags_array)) {
                                $t->set_var("flg_name", $name);
                                $t->set_var("flg_value", $value);
                                $t->parse("flags", "flag", True);
                        }

                        # parse month_on
                        $t->set_block("frmhandle", "month_on", "months_on");
                        $t->set_var('lang_on',lang('On'));
                        $t->set_var('lang_before',lang('Before'));
                        $t->set_var('lang_after',lang('After'));
                        $t->set_var('lang_return_mails_during',lang('Return 
mails during this time period'));
                        $t->set_var('lang_search_button',lang('search'));
                        $t->set_var('lang_clear_form_button',lang('clear 
form'));
                        while (list($name, $value) = each($this->month_array)) {
                                $t->set_var("month_value", $name);
                                $t->set_var("month_option", $value);
                                if ($todays_date["month"] == $name) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("months_on", "month_on", True);
                        }
                        reset($this->month_array);

                        # parse day_on
                        $t->set_block("frmhandle", "day_on", "days_on");
                        for ($i=1;$i<=31;$i++) {
                                $t->set_var("day_option", $i);
                                $t->set_var("day_option", $i);
                                if ($todays_date["day"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("days_on", "day_on", True);
                        }

                        # parse year_on
                        $t->set_block("frmhandle", "year_on", "years_on");
                        for 
($i=$todays_date["year"]-20;$i<=$todays_date["year"];$i++) {
                                $t->set_var("year_option", $i);
                                $t->set_var("year_option", $i);
                                if ($todays_date["year"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("years_on", "year_on", True);
                        }

                        # parse month_before
                        $t->set_block("frmhandle", "month_before", 
"months_before");
                        while (list($name, $value) = each($this->month_array)) {
                                $t->set_var("month_value", $name);
                                $t->set_var("month_option", $value);
                                if ($week_date["month"] == $name) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("months_before", "month_before", 
True);
                        }
                        reset($this->month_array);

                        # parse day_before
                        $t->set_block("frmhandle", "day_before", "days_before");
                        for ($i=1;$i<=31;$i++) {
                                $t->set_var("day_option", $i);
                                $t->set_var("day_option", $i);
                                if ($week_date["day"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("days_before", "day_before", True);
                        }

                        # parse year_before
                        $t->set_block("frmhandle", "year_before", 
"years_before");
                        for 
($i=$todays_date["year"]-20;$i<=$todays_date["year"];$i++) {
                                $t->set_var("year_option", $i);
                                $t->set_var("year_option", $i);
                                if ($week_date["year"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("years_before", "year_before", True);
                        }

                        # parse month_after
                        $t->set_block("frmhandle", "month_after", 
"months_after");
                        while (list($name, $value) = each($this->month_array)) {
                                $t->set_var("month_value", $name);
                                $t->set_var("month_option", $value);
                                if ($month_date["month"] == $name) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("months_after", "month_after", True);
                        }
                        reset($this->month_array);

                        # parse day_after
                        $t->set_block("frmhandle", "day_after", "days_after");
                        for ($i=1;$i<=31;$i++) {
                                $t->set_var("day_option", $i);
                                $t->set_var("day_option", $i);
                                if ($month_date["day"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("days_after", "day_after", True);
                        }

                        # parse year_after
                        $t->set_block("frmhandle", "year_after", "years_after");
                        for 
($i=$todays_date["year"]-20;$i<=$todays_date["year"];$i++) {
                                $t->set_var("year_option", $i);
                                $t->set_var("year_option", $i);
                                if ($month_date["year"] == $i) {
                                        $t->set_var("selected", "SELECTED");
                                } else {
                                        $t->set_var("selected", "");
                                }
                                $t->parse("years_after", "year_after", True);
                        }

                        # parse folder
                        $t->set_block("frmhandle", "folder", "folders");
                        $t->set_var('lang_search',lang('Search for mails in 
these folders'));
                        $t->set_var('lang_search_string',lang('Enter the search 
string in the text boxes'));
                        $t->set_var('lang_subject',lang('subject'));
                        $t->set_var('lang_from',lang('from'));
                        $t->set_var('lang_keyword',lang('keyword'));
                        $t->set_var('lang_bcc',lang('bcc'));
                        $t->set_var('lang_cc',lang('cc'));
                        $t->set_var('lang_to',lang('to'));
                        for ($i=0;$i<count($folder_list);$i++) {
                                $t->set_var("fld_value", 
$folder_list[$i]['folder_short']);
                                if ($folder_list[$i]['folder_short'] == 
'INBOX') {
                                        $t->set_var('fld_checked', 'CHECKED');
                                } else {
                                        $t->set_var('fld_checked', '');
                                }
                                $t->parse("folders", "folder", True);
                        }

                        $t->pparse("frmoutput", "frmhandle");

                        $GLOBALS['phpgw']->msg->end_request();
                        unset($GLOBALS['phpgw']->msg);

                }

                function search()
                {
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
                        $GLOBALS['phpgw']->common->phpgw_header();

                        //$GLOBALS['phpgw']->msg = 
CreateObject('email.mail_msg');
                        //$GLOBALS['phpgw']->msg->begin_request( 
array("do_login" => True) );
                        //$GLOBALS['phpgw']->msg->ensure_stream_and_folder();

                        $GLOBALS['phpgw']->htmlwid = 
CreateObject('email.html_widgets');
                        print $GLOBALS['phpgw']->htmlwid->get_toolbar();


                        # output the javascript stuff
                        $jst = $GLOBALS['phpgw']->template;
                        $jst->set_file('search_js', 'search_results_js.tpl');
                        $jst->pparse('output', 'search_js');

                        # have to loop for selected folders
                        for 
($j=0;$j<count($GLOBALS['HTTP_POST_VARS']['folder_list']);$j++)

                        {


                        $search_vars = array ();
                        $imap_search_str = '';

                        # Get folder to search in
                        $search_vars['fldball']['folder'] = 
$GLOBALS['HTTP_POST_VARS']['folder_list'][$j];
                        // REMEMBER what account we are searching
                        $search_vars['fldball']['acctnum'] = 
$GLOBALS['phpgw']->msg->get_acctnum();

                        # Get and process the textbox values
                        $search_vars['str']['SUBJECT'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_subject']);
                        $search_vars['str']['BODY'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_body']);
                        $search_vars['str']['FROM'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_from']);
                        $search_vars['str']['TO'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_to']);
                        $search_vars['str']['CC'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_cc']);
                        $search_vars['str']['BCC'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_bcc']);
                        $search_vars['str']['KEYWORD'] = 
trim($GLOBALS['HTTP_POST_VARS']['search_keyword']);
                        while (list($name, $value) = each($search_vars['str'])) 
{
                                if ($value != '') {
                                        $value = addslashes($value);
                                        $imap_search_str .= "$name \"$value\" ";
                                }
                        }

                        # Process the flags
                        while (list($name, $value) = each($this->flags_array)) {
                                if ($GLOBALS['HTTP_POST_VARS'][$name] == "on") {
                                        $imap_search_str .= 
strtoupper($value).' ';
                                }
                        }
                        reset($this->flags_array);

                        # Process dates
                        if ($GLOBALS['HTTP_POST_VARS']['date_on'] == "on") {
                                $imap_search_str .= "ON 
\"".$GLOBALS['HTTP_POST_VARS']['date_on_month'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_on_day'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_on_year'];
                                $imap_search_str .= '" ';
                        }
                        if ($GLOBALS['HTTP_POST_VARS']['date_before'] == "on") {
                                $imap_search_str .= "BEFORE 
\"".$GLOBALS['HTTP_POST_VARS']['date_before_month'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_before_day'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_before_year'];
                                $imap_search_str .= '" ';
                        }
                        if ($GLOBALS['HTTP_POST_VARS']['date_after'] == "on") {
                                $imap_search_str .= "SINCE 
\"".$GLOBALS['HTTP_POST_VARS']['date_after_month'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_after_day'].'/';
                                $imap_search_str .= 
$GLOBALS['HTTP_POST_VARS']['date_after_year'];
                                $imap_search_str .= '" ';
                        }

                        $imap_search_str = rtrim($imap_search_str);

                        $search_results = 
$GLOBALS['phpgw']->msg->phpgw_search($search_vars['fldball'], $imap_search_str, 
'');

                        if (is_array($search_results)) {
                                $num_msg = count($search_results);
                        } else {
                                $num_msg = 0;

                                # No messages found
                                echo '<br>'.lang("No message found in folder 
'%1'",$search_vars['fldball']['folder']).'<br><br><br>';

                                continue;
                        }

                        # Process the template for output
                        $t = $GLOBALS['phpgw']->template;
                        $t->set_file("search", "search_results.tpl");
                        
$t->set_var('lang_messages_found_in_folder',lang('Messages found in folder'));
                        $t->set_var('lang_date',lang('Date'));
                        $t->set_var('lang_size',lang('Size'));
                        $t->set_var('lang_from',lang('From'));
                        $t->set_var('lang_subject',lang('Subject'));
                        
$t->set_var('lang_move_selected_messages_into',lang('Move selected messages 
into'));
                        $t->set_var("num_msg", $num_msg);
                        $t->set_var('form_name', 
'delmov_'.$search_vars['fldball']['folder']);

                        # set form action
                        $t->set_var('delmov_action', 
$GLOBALS['phpgw']->link('/index.php', 'menuaction=email.boaction.delmov'));
                        $t->set_var("folder", 
$search_vars['fldball']['folder']);


                        # Get headers of each message in search results
                        $t->set_block("search", "search_result", 
"search_results");
                        for ($i=0;$i<$num_msg;$i++) {

                                $msgball['folder'] = 
$search_vars['fldball']['folder'];
                                $msgball['acctnum'] = 
$search_vars['fldball']['acctnum'];
                                $msgball['msgnum'] = $search_results[$i];

                                $header_info = 
$GLOBALS['phpgw']->msg->phpgw_header($msgball);

                                # fill checkbox value
                                //$t->set_var('checkbox_val', 
'msgball[msgnum]='.$search_results[$i].'&msgball[folder]='.urlencode($GLOBALS['phpgw']->msg->get_folder_long($search_vars['fldball']['folder'])).'&msgball[acctnum]='.$GLOBALS['phpgw']->msg->get_acctnum());
                                $t->set_var('checkbox_val', 
'msgball[msgnum]='.$search_results[$i].'&msgball[folder]='.urlencode($GLOBALS['phpgw']->msg->get_folder_long($search_vars['fldball']['folder'])).'&msgball[acctnum]='.$search_vars['fldball']['acctnum']);

                                $t->set_var("from", $header_info->fromaddress);
                                $msg_link = 
$GLOBALS['phpgw']->link('/index.php', 
'menuaction=email.uimessage.message&msgball[msgnum]='.$search_results[$i].'&msgball[folder]='.$search_vars['fldball']['folder'].'&msgball[acctnum]='.$search_vars['fldball']['acctnum']);
                                $t->set_var("msg_link", $msg_link);
                                $t->set_var("subject", $header_info->subject);
                                $t->set_var("date", strftime("%D", 
$header_info->udate));
                                $t->set_var("size", $header_info->Size);

                                $t->parse("search_results", "search_result", 
True);
                        }

                        # get folder list
                        $folder_list = 
$GLOBALS['phpgw']->msg->get_folder_list();
                        $t->set_block("search", "folder_list", "folders_list");
                        for ($i=0;$i<count($folder_list);$i++) {
                                if ($folder_list[$i]['folder_short'] != 
$search_vars['fldball']['folder']) {
                                        $t->set_var('fld_link', 
'&folder='.urlencode($folder_list[$i]['folder_long']).'&acctnum='.$GLOBALS['phpgw']->msg->get_acctnum());
                                        $t->set_var("fld_value", 
$folder_list[$i]['folder_short']);
                                        $t->parse("folders_list", 
"folder_list", True);
                                }
                        }

                        for ($i=0;$i<count($folder_list);$i++) {
                                if ($folder_list[$i]['folder_short'] == 
$search_vars['fldball']['folder']) {
                                        $t->set_var('folder_short', 
$folder_list[$i]['folder_short']);
                                }
                        }


                        $t->pparse("output", "search");

                        }

                        $GLOBALS['phpgw']->msg->end_request();
                        unset($GLOBALS['phpgw']->msg);
                }



                function get_date()
                {
                        $ret = array();

                        $arr = getdate(time());
                        $ret["day"] = $arr["mday"];
                    $ret["month"] = $arr["mon"];
                    $ret["year"] = $arr["year"];

                    return $ret;
                }

                function get_week_date($f)
                {
                        $ret = array();

                        $now = time();
                        $back = $now - (600000*$f);
                        $arr = getdate($back);
                        $ret["day"] = $arr["mday"];
                        $ret["month"] = $arr["mon"];
                        $ret["year"] = $arr["year"];

                        return $ret;
                }
        }
?>







reply via email to

[Prev in Thread] Current Thread [Next in Thread]