phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: email/inc class.boindex.inc.php,1.18,1.19 class.


From: Angelo Tony Puglisi <address@hidden>
Subject: [Phpgroupware-cvs] CVS: email/inc class.boindex.inc.php,1.18,1.19 class.mail_msg_base.inc.php,1.57,1.58 class.mail_msg_display.inc.php,1.29,1.30 class.uiindex.inc.php,1.15,1.16
Date: Fri, 11 Jan 2002 05:09:48 -0500

Update of /cvsroot/phpgroupware//email/inc
In directory subversions:/tmp/cvs-serv23269/email/inc

Modified Files:
        class.boindex.inc.php class.mail_msg_base.inc.php 
        class.mail_msg_display.inc.php class.uiindex.inc.php 
Log Message:
add a dropdown listbox for account selection

Index: class.boindex.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.boindex.inc.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** class.boindex.inc.php       10 Jan 2002 10:04:41 -0000      1.18
--- class.boindex.inc.php       11 Jan 2002 10:09:45 -0000      1.19
***************
*** 270,273 ****
--- 270,302 ----
                        $this->xi['show_num_new'] = False;
                        
+                       // ---- account switchbox  ----
+ 
+ 
+                       // make a HTML comobox used to switch accounts
+                       $make_acctbox = True;
+                       //$make_acctbox = False;
+                       if ($make_acctbox)
+                       {
+                               $feed_args = Array(
+                                       'pre_select_acctnum'    => 
$GLOBALS['phpgw']->msg->get_acctnum(),
+                                       'widget_name'           => 
'fldball_fake_uri',
+                                       'folder_key_name'       => 'folder',
+                                       'acctnum_key_name'      => 'acctnum',
+                                       'on_change'             => 
'document.acctbox.submit()'
+                               );
+                               $this->xi['acctbox_listbox'] = 
$GLOBALS['phpgw']->msg->all_ex_accounts_listbox($feed_args);
+                       }
+                       else
+                       {
+                               $this->xi['acctbox_listbox'] = '&nbsp';
+                       }
+                       $this->xi['acctbox_frm_name'] = 'acctbox';
+                       
+                       // switchbox will itself contain "fake_uri" embedded 
data which includes the applicable account number for the folder
+                       $this->xi['acctbox_action'] = $GLOBALS['phpgw']->link(
+                                                               '/index.php',
+                                                                
'menuaction=email.uiindex.index');
+                       
+                       
                        $this->xi['mailsvr_supports_folders'] = 
$GLOBALS['phpgw']->msg->get_mailsvr_supports_folders();
                        // if using folders, make a HTML comobox used to switch 
folders

Index: class.mail_msg_base.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.mail_msg_base.inc.php,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -r1.57 -r1.58
*** class.mail_msg_base.inc.php 10 Jan 2002 10:04:41 -0000      1.57
--- class.mail_msg_base.inc.php 11 Jan 2002 10:09:45 -0000      1.58
***************
*** 79,82 ****
--- 79,89 ----
        );
        
+       // EXTRA ACCOUNTS
+       var $num_ex_accounts = 0;
+       // holds the integer array key(s) of any defined extra account that has 
data, whether enabled or not
+       var $defined_ex_accounts = array();
+       // same as above BUT only has "enabled" extra accounts integer array 
key(s)
+       var $enabled_ex_accounts = array();
+       
        // DEBUG FLAGS generally take int 0, 1, 2, or 3
        var $debug_logins = 0;
***************
*** 154,157 ****
--- 161,165 ----
                //if ($this->debug_logins > 0) { echo '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) { echo 'mail_msg: *constructor*: 
$this->acctnum = ['.$this->acctnum.'] ; $this->a  Dump<pre>'; 
print_r($this->a); echo '</pre>'; }
+               if ($this->debug_logins > 1) { echo 'mail_msg: *constructor*: 
extra data $p1 (if provided): '.serialize($p1).'<br>'; }
                
                $this->known_external_args = array(
***************
*** 667,676 ****
                // === or we are Not Already Logged In?  =====
                // === or we *something* did not work during "re-use existing" 
attempt  =====
!               // === OR we are not attempting to re-use an existing mail_msg 
object  ====
                if ($this->debug_logins > 0) { echo 'mail_msg: begin_request: 
NOT reusing an established logged-in stream-object, will create new'.'<br>'; }
                
                // ----  Things To Be Done Whether You Login Or Not  -----
                
!               //if ($this->debug_logins > 2) { echo 'mail_msg: begin_request: 
PRE create_email_preferences GLOBALS[phpgw_info][user][preferences][email] 
dump:<pre>'; print_r($GLOBALS['phpgw_info']['user']['preferences']['email']) ; 
echo '</pre>';}
                // ----  Obtain Preferences Data  ----
                $tmp_prefs = array();
--- 675,684 ----
                // === or we are Not Already Logged In?  =====
                // === or we *something* did not work during "re-use existing" 
attempt  =====
!               // === OR we are NOT attempting to re-use an existing mail_msg 
object  ====
                if ($this->debug_logins > 0) { echo 'mail_msg: begin_request: 
NOT reusing an established logged-in stream-object, will create new'.'<br>'; }
                
                // ----  Things To Be Done Whether You Login Or Not  -----
                
!               if ($this->debug_logins > 1) { echo 'mail_msg: begin_request: 
about to create_email_preferences and setup extra accounts<br>';}
                // ----  Obtain Preferences Data  ----
                $tmp_prefs = array();
***************
*** 680,694 ****
                $GLOBALS['phpgw_info']['user']['preferences'] = $tmp_prefs;
                // 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, force 
them into acctnum 0
                $this->set_pref_array($tmp_prefs['email'], 0);
                
!               // TEMP - STUFF EXTRA ACCT #1 WHERE IT BELONGS
!               // run thru the create prefs function requesting this 
particular acctnum
!               $tmp_prefs = array();
!               $tmp_prefs = 
$GLOBALS['phpgw']->preferences->create_email_preferences('', 1);
!               $this->set_pref_array($tmp_prefs['email'], 1);
                
                // clear the temp var
                $tmp_prefs = array();
                
                //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>';}
--- 688,748 ----
                $GLOBALS['phpgw_info']['user']['preferences'] = $tmp_prefs;
                // 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) { echo 'mail_msg: begin_request: 
putting top level, default account, pref data in acct 0 with 
$this->set_pref_array($tmp_prefs[email], 0); <br>';}
!               if ($this->debug_logins > 2) { echo 'mail_msg: begin_request:  
$tmp_prefs[email] dump:<pre>'; print_r($tmp_prefs['email']) ; echo '</pre>';}
                $this->set_pref_array($tmp_prefs['email'], 0);
                
!               // ===  EXTRA ACCOUNTS  ===
!               // they are located in an array based at 
$tmp_prefs['email']['ex_accounts'][]
!               // determine what extra accounts have been defined
!               // note: php3 DOES have is_array(), ok to use it here
!               if ((isset($tmp_prefs['email']['ex_accounts']))
!               && (is_array($tmp_prefs['email']['ex_accounts'])))
!               {
!                       $this->num_ex_accounts = 
count($tmp_prefs['email']['ex_accounts']);
!                       if ($this->debug_logins > 1) { echo 'mail_msg: 
begin_request: $tmp_prefs[email][ex_accounts] is set and is_array, its count: 
$this->num_ex_accounts: ['.$this->num_ex_accounts.']<br>';}
!               }
!               else
!               {
!                       $this->num_ex_accounts = 0;
!                       if ($this->debug_logins > 1) { echo 'mail_msg: 
begin_request: $tmp_prefs[email][ex_accounts] NOT set or NOT is_array, 
$this->num_ex_accounts: ['.$this->num_ex_accounts.']<br>';}
!               }
                
+               // ---- what accounts have some data defined
+               while(list($key,$value) = 
each($tmp_prefs['email']['ex_accounts']))
+               {
+                       if ($this->debug_logins > 1) { echo 'mail_msg: 
begin_request: inside loop: for each $tmp_prefs[email][ex_accounts] ; $key: 
['.serialize($key).'] $value: ['.serialize($value).']<br>';}
+                       // if we are here at all then this array item must have 
some data defined
+                       $next_pos = count($this->defined_ex_accounts);
+                       $this->defined_ex_accounts[$next_pos] = $key;
+                       // is this account "enabled"
+                       if ( 
(isset($tmp_prefs['email']['ex_accounts'][$key]['ex_account_enabled']))
+                       && 
((string)$tmp_prefs['email']['ex_accounts'][$key]['ex_account_enabled'] != ''))
+                       {
+                               // this account is defined AND enabled, add it 
to $this->enabled_ex_accounts
+                               if ($this->debug_logins > 1) { echo 'mail_msg: 
begin_request: inside loop: account enabled: 
$tmp_prefs[email][ex_accounts]['.$key.'][ex_account_enabled]:  
['.serialize($tmp_prefs['email']['ex_accounts'][$key]['ex_account_enabled']).']<br>';}
+                               $next_pos = count($this->enabled_ex_accounts);
+                               $this->enabled_ex_accounts[$next_pos] = $key;
+                       }
+               }
+               if ($this->debug_logins > 1) { echo 'mail_msg: begin_request: 
$this->defined_ex_accounts: ['.serialize($this->defined_ex_accounts).'] ; 
$this->enabled_ex_accounts: ['.serialize($this->enabled_ex_accounts).']<br>';}
+               
+               // 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
+               for ($i=0; $i <count($this->enabled_ex_accounts); $i++)
+               {
+                       $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->enabled_ex_accounts[$i];
+                       if ($this->debug_logins > 1) { echo 'mail_msg: 
begin_request: about to call create_email_preferences("", $this_ex_acctnum) 
where $this_ex_acctnum: ['.serialize($this_ex_acctnum).'] <br>'; }
+                       $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($tmp_prefs['email'], 
$this_ex_acctnum);
+               }
                // clear the temp var
                $tmp_prefs = array();
+               // -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>';}

Index: class.mail_msg_display.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.mail_msg_display.inc.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** class.mail_msg_display.inc.php      10 Jan 2002 10:04:41 -0000      1.29
--- class.mail_msg_display.inc.php      11 Jan 2002 10:09:45 -0000      1.30
***************
*** 398,401 ****
--- 398,543 ----
        }
  
+       function all_ex_accounts_listbox($feed_args)
+       {
+               // $this->num_ex_accounts
+               // $this->defined_ex_accounts
+               // $this->enabled_ex_accounts
+               
+               if(!$feed_args)
+               {
+                       $feed_args=array();
+               }
+               //$debug_widget = True;
+               $debug_widget = False;
+               
+               // establish fallback default args
+               $acctnum = $this->get_acctnum();
+               $local_args = Array(
+                       'pre_select_acctnum'    => $acctnum,
+                       'widget_name'           => 'fldball_fake_uri',
+                       'folder_key_name'       => 'folder',
+                       'acctnum_key_name'      => 'acctnum',
+                       'on_change'             => 'document.acctbox.submit()'
+               );              
+               // loop thru $local_args[], replacing defaults with any args 
specified in $feed_args[]
+               if ($debug_widget) { echo 'all_ex_accounts_listbox $feed_args 
data dump<pre>'; print_r($feed_args); echo '</pre>'; }
+               if (count($feed_args) == 0)
+               {
+                       if ($debug_widget) { echo 'all_ex_accounts_listbox 
$feed_args is EMPTY<br>'.serialize($feed_args).'<br>'; }
+               }
+               else
+               {
+                       reset($local_args);
+                       // the feed args may not be an array, the @ will 
supress warnings
+                       @reset($feed_args);             
+                       while(list($key,$value) = each($local_args))
+                       {
+                               // DEBUG
+                               if ($debug_widget) { echo '* a: local_args: 
key=['.$key.'] value=['.(string)$value.']<br>'; }
+                               if ($debug_widget) { echo '* b: feed_args: 
key=['.$key.'] value=['.(string)$feed_args[$key].']<br>'; }
+                               if ((isset($feed_args[$key]))
+                               && ($feed_args[$key] != $value))
+                               {
+                                       // we have a specified arg that should 
replace the default value
+                                       if ($debug_widget) { echo '*** override 
default value of ['.$local_args[$key] .'] with feed_args['.$key.'] of 
['.(string)$feed_args[$key].']<br>'; }
+                                       $local_args[$key] = $feed_args[$key];
+                               }
+                       }
+                       reset($local_args);
+                       @reset($feed_args);
+               }
+               // at this point, local_args[] has anything that was passed in 
the feed_args[]
+               if ($debug_widget) { echo 'all_ex_accounts_listbox: FINAL 
Listbox Local Args:<br>'.serialize($local_args).'<br>'; }
+               
+               $item_tags = '';
+               
+               // this logic determines if the combobox should be initialized 
with certain account already selected
+               if ((string)$local_args['pre_select_acctnum'] == '0')
+               {
+                       $sel = ' selected';
+               }
+               else
+               {
+                       $sel = '';
+               }
+               
+               // add the default email account, account number 0
+               // this fake_uri data will be converted to fldball data on 
submit processing
+               $option_value =  '&'.$local_args['folder_key_name'].'=INBOX'
+                               .'&'.$local_args['acctnum_key_name'].'=0';
+               //$option_text = lang('default account').' '.lang('as').' 
&quot;'.$this->get_pref_value('fullname', 0).'&quot;';
+               //$option_text = 
lang('default').'&nbsp;&nbsp;'.$this->get_pref_value('fullname', 0);
+               $option_text = lang('default: 
').'&nbsp;&nbsp;'.$this->get_pref_value('fullname', 0);
+               
+               $item_tags .= '<option 
value="'.$option_value.'"'.$sel.'>'.$option_text.'</option>'."\r\n";
+               
+               // iterate thru the ex_accounts list, building the HTML tags 
using that data
+               for ($i=0; $i < count($this->defined_ex_accounts); $i++)
+               {
+                       // the option values below are in the form of embedded 
fake_uri
+                       $this_acctnum = $this->defined_ex_accounts[$i];
+                       // is this account "enabled" ?
+                       // array_search_ex($needle='', $haystack='', 
$strict=False)
+                       $enabled = $this->array_search_ex($this_acctnum, 
$this->enabled_ex_accounts);
+                       // note: is_bool is in the php3 compat library
+                       // note: array position 0 != boolean false, thus the 
test below
+                       if ((is_bool($enabled))
+                       && ($enabled == False))
+                       {
+                               // FUTURE: take user to the extra accounts 
management page for this particular account
+                               // now: put the user back to the default account
+                               $option_value =  
'&'.$local_args['folder_key_name'].'=INBOX'
+                                               
.'&'.$local_args['acctnum_key_name'].'=0';
+                               $option_text = lang('account').' 
['.$this_acctnum.'] disabled';
+                               
+                               // note: a disabled account can not be 
pre-selected
+                               $item_tags .= '<option 
value="'.$option_value.'">'.$option_text.'</option>'."\r\n";
+                       }
+                       else
+                       {
+                               // this logic determines if the combobox should 
be initialized with certain account already selected
+                               if ((string)$local_args['pre_select_acctnum'] 
== (string)$this_acctnum)
+                               {
+                                       $sel = ' selected';
+                               }
+                               else
+                               {
+                                       $sel = '';
+                               }
+                               
+                               // 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'].'=INBOX'
+                                               
.'&'.$local_args['acctnum_key_name'].'='.$this_acctnum;
+                               //$option_text = lang('account').' 
['.$this_acctnum.']'.' '.lang('as').' &quot;'.$this->get_pref_value('fullname', 
$this_acctnum).'&quot;';
+                               //$option_text = lang('account').' 
['.$this_acctnum.']'.'&nbsp;&nbsp;'.$this->get_pref_value('fullname', 
$this_acctnum);
+                               $option_text = lang('account 
'.$this_acctnum.':').'&nbsp;&nbsp;'.$this->get_pref_value('fullname', 
$this_acctnum);
+                               
+                               $item_tags .= '<option 
value="'.$option_value.'"'.$sel.'>'.$option_text.'</option>'."\r\n";
+                       }
+               }
+               // now $item_tags contains the internal folder list
+               
+               // ----  add the HTML tags that surround this internal list 
data  ----
+               if ((isset($local_args['on_change']))
+               && ($local_args['on_change'] != ''))
+               {
+                       $on_change_tag = 
'onChange="'.$local_args['on_change'].'"';
+               }
+               else
+               {
+                       $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.'>'
+                               . $item_tags
+                       .'</select>';
+               // return a pre-built HTML listbox (selectbox) widget
+               return $listbox_widget;
+       }
        
        function format_byte_size($feed_size)

Index: class.uiindex.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//email/inc/class.uiindex.inc.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** class.uiindex.inc.php       10 Jan 2002 10:04:41 -0000      1.15
--- class.uiindex.inc.php       11 Jan 2002 10:09:45 -0000      1.16
***************
*** 262,274 ****
                                'ctrl_bar_acct_1_link'  => 
$this->bo->xi['ctrl_bar_acct_1_link'],
  
                                'ctrl_bar_back1'        => 
$this->bo->xi['ctrl_bar_back1'],
-                               'sortbox_action'        => 
$this->bo->xi['sortbox_action'],
                                'switchbox_frm_name'    => 
$this->bo->xi['switchbox_frm_name'],
                                'sortbox_on_change'     => 
$this->bo->xi['sortbox_on_change'],
                                'sortbox_select_name'   => 
$this->bo->xi['sortbox_select_name'],
                                'sortbox_select_options' => 
$this->bo->xi['sortbox_select_options'],
                                'sortbox_sort_by_txt'   => 
$this->bo->xi['lang_sort_by'],
-                               'switchbox_action'      => 
$this->bo->xi['switchbox_action'],
-                               'switchbox_listbox'     => 
$this->bo->xi['switchbox_listbox'],
                                // old version of first prev next last arrows 
for "layout 1"
                                'prev_arrows'           => 
$this->bo->xi['td_prev_arrows'],
--- 262,278 ----
                                'ctrl_bar_acct_1_link'  => 
$this->bo->xi['ctrl_bar_acct_1_link'],
  
+                               'acctbox_frm_name'      => 
$this->bo->xi['acctbox_frm_name'],
+                               'acctbox_action'        => 
$this->bo->xi['acctbox_action'],
+                               'acctbox_listbox'       => 
$this->bo->xi['acctbox_listbox'],
+ 
                                'ctrl_bar_back1'        => 
$this->bo->xi['ctrl_bar_back1'],
                                'switchbox_frm_name'    => 
$this->bo->xi['switchbox_frm_name'],
+                               'switchbox_action'      => 
$this->bo->xi['switchbox_action'],
+                               'switchbox_listbox'     => 
$this->bo->xi['switchbox_listbox'],
+                               'sortbox_action'        => 
$this->bo->xi['sortbox_action'],
                                'sortbox_on_change'     => 
$this->bo->xi['sortbox_on_change'],
                                'sortbox_select_name'   => 
$this->bo->xi['sortbox_select_name'],
                                'sortbox_select_options' => 
$this->bo->xi['sortbox_select_options'],
                                'sortbox_sort_by_txt'   => 
$this->bo->xi['lang_sort_by'],
                                // old version of first prev next last arrows 
for "layout 1"
                                'prev_arrows'           => 
$this->bo->xi['td_prev_arrows'],




reply via email to

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