phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: phpgwapi/inc class.preferences.inc.php,1.40,1.41


From: Angelo Tony Puglisi <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.preferences.inc.php,1.40,1.41
Date: Thu, 10 Jan 2002 05:09:13 -0500

Update of /cvsroot/phpgroupware//phpgwapi/inc
In directory subversions:/tmp/cvs-serv25459/phpgwapi/inc

Modified Files:
        class.preferences.inc.php 
Log Message:
add support for sub-level data manipulation in prefs

Index: class.preferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//phpgwapi/inc/class.preferences.inc.php,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** class.preferences.inc.php   3 Jan 2002 18:11:10 -0000       1.40
--- class.preferences.inc.php   10 Jan 2002 10:09:10 -0000      1.41
***************
*** 1,27 ****
  <?php
        
/**************************************************************************\
!       * phpGroupWare API - Preferences                                        
   *
!       * This file written by Joseph Engo <address@hidden>                *
!       * and Mark Peters <address@hidden>                               *
!       * Manages user preferences                                              
   *
!       * Copyright (C) 2000, 2001 Joseph Engo                                  
   *
!       * 
-------------------------------------------------------------------------*
!       * This library is part of the phpGroupWare API                          
   *
!       * http://www.phpgroupware.org/api                                       
   * 
!       * 
------------------------------------------------------------------------ *
!       * 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 preferences 
--- 1,28 ----
  <?php
        
/**************************************************************************\
!       * phpGroupWare API - Preferences                                        
                *
!       * This file written by Joseph Engo <address@hidden>                     
*
!       * and Mark Peters <address@hidden>                                      
*
!       * Manages user preferences                                              
                *
!       * Copyright (C) 2000, 2001 Joseph Engo                                  
        *
!       * 
-------------------------------------------------------------------------       
              *
!       * This library is part of the phpGroupWare API                          
        *
!       * http://www.phpgroupware.org/api                                       
                * 
!       * 
------------------------------------------------------------------------        
              *
!       * 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 preferences 
***************
*** 166,169 ****
--- 167,209 ----
  
                /*!
+               @function add_struct
+               @abstract add complex array data preference to $app_name a 
particular app
+               @discussion Use for sublevels of prefs, such as email app's 
extra accounts preferences
+               @param $app_name name of the app
+               @param $var String to be evaled's as an ARRAY structure, name 
of preference to be stored
+               @param $value value of the preference
+               */
+               function add_struct($app_name,$var,$value = '')
+               {
+                       $code = '$this->data[$app_name]'.$var.' = $value;';
+                       //echo 'class.preferences: add_struct: $code: 
'.$code.'<br>';
+                       eval($code);
+                       //echo 'class.preferences: add_struct: 
$this->data[$app_name] dump:'; _debug_array($this->data[$app_name]); echo 
'<br>';
+                       reset($this->data);
+                       return $this->data;
+               }
+ 
+               /*! 
+               @function delete_struct
+               @abstract delete complex array data preference from $app_name
+               @discussion Use for sublevels of prefs, such as email app's 
extra accounts preferences
+               @param $app_name name of app
+               @param $var String to be evaled's as an ARRAY structure, name 
of preference to be deleted
+               */
+               function delete_struct($app_name, $var = '')
+               {
+                       $code_1 = '$this->data[$app_name]'.$var.' = "";';
+                       //echo 'class.preferences: delete_struct: $code_1: 
'.$code_1.'<br>';
+                       eval($code_1);
+                       $code_2 = 'unset($this->data[$app_name]'.$var.');' ;
+                       //echo 'class.preferences: delete_struct:  $code_2: 
'.$code_2.'<br>';
+                       eval($code_2);
+                       //echo ' * $this->data[$app_name] dump:'; 
_debug_array($this->data[$app_name]); echo '<br>';
+                       reset ($this->data);
+                       return $this->data;
+               }
+ 
+ 
+               /*!
                @function save_repository
                @abstract save the the preferences to the repository
***************
*** 435,439 ****
                @access Public
                */
!               function create_email_preferences($accountid='')
                {
                        if ($this->debug_init_prefs > 0) { echo 
'class.preferences: create_email_preferences: ENTERING<br>'; }
--- 475,479 ----
                @access Public
                */
!               function create_email_preferences($accountid='', $acctnum='')
                {
                        if ($this->debug_init_prefs > 0) { echo 
'class.preferences: create_email_preferences: ENTERING<br>'; }
***************
*** 465,471 ****
                                $prefs = $this->data;
                        }
                        if ($this->debug_init_prefs > 0)
                        {
!                               echo 'class.preferences: 
create_email_preferences: raw $this->data dump';
                                _debug_array($this->data);
                        }
--- 505,537 ----
                                $prefs = $this->data;
                        }
+                       // are we dealing with the default email account or an 
extra email account?
+                       if (!(isset($acctnum))
+                       || ((string)$acctnum == ''))
+                       {
+                               // account 0 is the default email account
+                               $acctnum = 0;
+                               // $prefs stays AS IS!
+                       }
+                       else
+                       {
+                               // prefs are actually a sub-element of the main 
email prefs
+                               // at location [email][ex_accounts][X][...pref 
names] => pref values
+                               // make this look like "prefs[email] so the 
code below code below will do its job transparently
+                               
+                               // store original prefs
+                               $orig_prefs = array();
+                               $orig_prefs = $prefs;
+                               // obtain the desired sub-array of extra 
account prefs
+                               $sub_prefs = array();
+                               $sub_prefs['email'] = 
$prefs['email']['ex_accounts'][$acctnum];
+                               // make the switch, make it seem like top level 
email prefs
+                               $prefs = array();
+                               $prefs['email'] = $sub_prefs['email'];
+                               // since we return just $prefs, it's up to the 
calling program to put the sub prefs in the right place
+                       }
+ 
                        if ($this->debug_init_prefs > 0)
                        {
!                               echo 'class.preferences: 
create_email_preferences: $acctnum: ['.$acctnum.'] ; raw $this->data dump';
                                _debug_array($this->data);
                        }
***************
*** 475,479 ****
                        // (a) not controlled by email prefs itself (mostly api 
and/or server level stuff)
                        // (b) too complicated to be described in the email 
prefs data array instructions
! 
                        // ---  [server][mail_server_type]  ---
                        // Set API Level Server Mail Type if not defined
--- 541,545 ----
                        // (a) not controlled by email prefs itself (mostly api 
and/or server level stuff)
                        // (b) too complicated to be described in the email 
prefs data array instructions
!                       
                        // ---  [server][mail_server_type]  ---
                        // Set API Level Server Mail Type if not defined
***************
*** 509,513 ****
                        // for the service in question.
                        $prefs['email']['mail_port'] = 
$this->sub_get_mailsvr_port($prefs);
! 
                        // = = = =  SIMPLER PREFS  = = = =
  
--- 575,588 ----
                        // for the service in question.
                        $prefs['email']['mail_port'] = 
$this->sub_get_mailsvr_port($prefs);
!                       
!                       //---  [email][fullname]  ---
!                       // we pick this up from phpgw api for the default 
account
!                       // the user does not directly manipulate this pref for 
the default email account
!                       if ((string)$acctnum == '0')
!                       {
!                               $prefs['email']['fullname'] = 
$GLOBALS['phpgw_info']['user']['fullname'];
!                       }
!                       
!                       
                        // = = = =  SIMPLER PREFS  = = = =
  
***************
*** 570,574 ****
                        // email preference exists that should override that 
default value, in which case we
                        // do not even need to obtain such a default value as 
described in ['init_default'] anyway).
! 
                        // --- loop thru $avail_pref_array and process each 
pref item ---
                        $c_prefs = count($avail_pref_array);
--- 645,649 ----
                        // email preference exists that should override that 
default value, in which case we
                        // do not even need to obtain such a default value as 
described in ['init_default'] anyway).
!                       
                        // --- loop thru $avail_pref_array and process each 
pref item ---
                        $c_prefs = count($avail_pref_array);
***************
*** 725,731 ****
                        if ($this->debug_init_prefs > 1)
                        {
!                               echo 'class.preferences: 
create_email_preferences: $prefs[email]';
                                _debug_array($prefs['email']);
                        }
                        if ($this->debug_init_prefs > 0) { echo 
'class.preferences: create_email_preferences: LEAVING<br>'; }
                        return $prefs;
--- 800,807 ----
                        if ($this->debug_init_prefs > 1)
                        {
!                               echo 'class.preferences: $acctnum: 
['.$acctnum.'] ; create_email_preferences: $prefs[email]';
                                _debug_array($prefs['email']);
                        }
+                       
                        if ($this->debug_init_prefs > 0) { echo 
'class.preferences: create_email_preferences: LEAVING<br>'; }
                        return $prefs;




reply via email to

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