phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: addressbook/inc class.boaddressbook_prefs.inc.ph


From: Alejandro Borges (lex) <address@hidden>
Subject: [Phpgroupware-cvs] CVS: addressbook/inc class.boaddressbook_prefs.inc.php, 1.1.2.1, 1.1.2.2 class.uiaddressbook.inc.php, 1.36.2.15.2.13, 1.36.2.15.2.14 class.uiaddressbook_prefs.inc.php, 1.1.2.1, 1.1.2.2
Date: Wed, 10 Sep 2003 20:15:58 -0400

Update of /cvsroot/phpgroupware/addressbook/inc
In directory subversions:/tmp/cvs-serv16701/inc

Modified Files:
      Tag: Version-0_9_16-branch
        class.boaddressbook_prefs.inc.php class.uiaddressbook.inc.php 
        class.uiaddressbook_prefs.inc.php 
Log Message:
Better preference management. More respect of the theme in it. Visually better 
and a couple of bugfixes


Index: class.boaddressbook_prefs.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/addressbook/inc/Attic/class.boaddressbook_prefs.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.boaddressbook_prefs.inc.php   8 Sep 2003 13:26:37 -0000       1.1.2.1
--- class.boaddressbook_prefs.inc.php   11 Sep 2003 00:15:55 -0000      1.1.2.2
***************
*** 3,7 ****
    * phpGroupWare API - Commononly used functions                             *
    * This file written by Alex Borges <address@hidden>                        *
!   * UI for addressbook preferences                                           *
    * Copyright (C) 2003 Alex Borges                                           *
    * -------------------------------------------------------------------------*
--- 3,7 ----
    * phpGroupWare API - Commononly used functions                             *
    * This file written by Alex Borges <address@hidden>                        *
!   * Business Logic for addressbook preferences                               *
    * Copyright (C) 2003 Alex Borges                                           *
    * -------------------------------------------------------------------------*
***************
*** 33,49 ****
                $this->preferences=CreateObject('phpgwapi.preferences');
        }
!       /*
!       @function convert_to_struct
!       @discussion yay, function to convert perfectly good arrays to weird 
strings that the preferences
!       class needs. No phun. Mucha policia.
!       */
!       function convert_to_struct($arr,$varname)
!       {
!               foreach($arr as $k=>$v)
!               {
!                       $struct=$struct.'['.$k.']';
!               }
!               return '['.$varname.']'.$struct;
!       }
        function save_preferences() 
        {
--- 33,37 ----
                $this->preferences=CreateObject('phpgwapi.preferences');
        }
!       
        function save_preferences() 
        {
***************
*** 67,76 ****
                if($this->default_category!='__NONE__')
                {
!                       
$this->preferences->add('addressbook','default_category',$this->default_category,'default_category');
                }
                $this->preferences->save_repository();
  
        }
!       function read_preferences()
        {
                $this->preferences->read();
--- 55,67 ----
                if($this->default_category!='__NONE__')
                {
!               /*      print "<B>DSASDADSADSADAS</B>";
!                       print $this->default_category; */
! 
!                       
$this->preferences->add('addressbook','default_category',$this->default_category);
                }
                $this->preferences->save_repository();
  
        }
!       function read_preferences() 
        {
                $this->preferences->read();

Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.36.2.15.2.13
retrieving revision 1.36.2.15.2.14
diff -C2 -r1.36.2.15.2.13 -r1.36.2.15.2.14
*** class.uiaddressbook.inc.php 10 Sep 2003 20:50:50 -0000      1.36.2.15.2.13
--- class.uiaddressbook.inc.php 11 Sep 2003 00:15:55 -0000      1.36.2.15.2.14
***************
*** 237,241 ****
                        if ($this->section == $this->tab_main_persons)
                        {
!                               if(!$columns_to_display && 
!is_array($columns_to_display))
                                {
                                        $noprefs=lang('Please set your 
preferences for this application');
--- 237,244 ----
                        if ($this->section == $this->tab_main_persons)
                        {
!                               //Check if both the main column array and the 
comtype subarray
!                               //are empty
!                               if((!$columns_to_display && 
!is_array($columns_to_display))
!                                       || 
(count($columns_to_display['comm_types'])<1) && count($columns_to_display) == 1)
                                {
                                        $noprefs=lang('Please set your 
preferences for this application');

Index: class.uiaddressbook_prefs.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/addressbook/inc/Attic/class.uiaddressbook_prefs.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.uiaddressbook_prefs.inc.php   8 Sep 2003 13:26:37 -0000       1.1.2.1
--- class.uiaddressbook_prefs.inc.php   11 Sep 2003 00:15:56 -0000      1.1.2.2
***************
*** 65,69 ****
                 'B_select_columns_comtypes_options' => 'on_constructor',
                 'org_preferences_link' => 'on_constructor',
!                'person_preferences_link' => 'on_constructor'); 
        //@param fields_show_selectbox
        //@discussion fields to show in the selectbox
--- 65,71 ----
                 'B_select_columns_comtypes_options' => 'on_constructor',
                 'org_preferences_link' => 'on_constructor',
!                'person_preferences_link' => 'on_constructor',
!                'cat_options'  =>  'on_contructor'
!                ); 
        //@param fields_show_selectbox
        //@discussion fields to show in the selectbox
***************
*** 96,99 ****
--- 98,102 ----
                                                                                
                )
                                                                                
        );
+                       
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats();
  
  
***************
*** 115,118 ****
--- 118,130 ----
  
        }
+       //@function get_addressbook_cats
+       //Gets the <option> tags of the categories of the addressbook, also 
asks what return selected
+       function get_addressbook_cats($selected=0)
+       {
+               $tmp=CreateObject('phpgwapi.categories');
+               $tmp->app_name='addressbook';
+               return $tmp->formated_list('select','all',$selected,True);
+       }
+ 
        //@function hashify
        //I dislike single dimmension numeric key arrays, i use this function 
to convert them to a hash
***************
*** 221,227 ****
--- 233,287 ----
                        $this->org_or_person=$temp;
                }
+ 
+               $temp=get_var('cat_id',array('get','post'));
+ //            print $temp;
+               if($temp)
+               {
+                       
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats($temp);
+                       $this->map_tpl_to_real['cat_id']=$temp;
+       //              print '<br><b>Selected catid!'.$temp.'</b><br>';
+               }
+               else
+               {
+       ///             print '<br><b>Cached catid</b><br>';
                        
+                       if(!isset($this->map_tpl_to_real['cat_id'])) //is not 
in cache
+                       {
+                               //fetch from preferences
+                               
$this->map_tpl_to_real['cat_id']=$this->bo->default_category;
+       //                      print '<br><b>Preference catid</b><br>';
+                       }
+ 
+               }
+ 
+       }
+       function cache_is_empty()
+       {
+               
if(is_array($this->cached_selected_fields[$this->org_or_person]['comm_types']))
+               {
+                       
if(count($this->cached_selected_fields[$this->org_or_person]['comm_types']) < 1)
+                       {
+                               if(count 
($this->cached_selected_fields[$this->org_or_person]) <= 1)
+                               {
+                                       return true;
+                               }
+                               else
+                               {
+                                       return false;
+                               }
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               elseif(count 
($this->cached_selected_fields[$this->org_or_person]) < 1)
+               {
+                       return true;
+               }
+                       return false;
  
        }
+                               
        function fields_to_show() 
        {
***************
*** 316,319 ****
--- 376,380 ----
  */
                        
$this->cached_selected_fields[$this->org_or_person]=$this->selected_fields[$this->org_or_person]=array_merge_recursive($this->cached_selected_fields[$this->org_or_person],$this->selected_fields[$this->org_or_person]);
+ 
                        /* print '<BR><B>Merging Result</B><BR>';
                        print_r($this->selected_fields[$this->org_or_person]);*/
***************
*** 327,330 ****
--- 388,392 ----
                {
                        
$this->selected_fields[$this->org_or_person]=$this->cached_selected_fields[$this->org_or_person];
+ 
  /*                    print '<BR><B>Cached awright</B><BR>'; */
                }
***************
*** 343,348 ****
        function index()
        {
-               $GLOBALS['phpgw']->common->phpgw_header();
-               echo parse_navbar();
                $this->get_vars();
                /*print '<BR><B>It is a !'.$this->org_or_person.'</B><BR>';*/
--- 405,408 ----
***************
*** 353,362 ****
                                {
                                        $this->save_sessiondata(true);
                                        return;
                                }
                        case 'save':
                                {
-                                       $this->get_exact_fields();
- //                                    print '<BR><B>SAVED FIELDS!</B><BR>';
  //                                    print_r($this->cached_selected_fields);
                                        //Need to get it all, we are in a tab, 
so actual data is
--- 413,421 ----
                                {
                                        $this->save_sessiondata(true);
+                                       
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
                                        return;
                                }
                        case 'save':
                                {
  //                                    print_r($this->cached_selected_fields);
                                        //Need to get it all, we are in a tab, 
so actual data is
***************
*** 382,388 ****
                                        
$this->bo->comtype_description['Organizations']=$org_columns['comtypes'];
                                        
$this->bo->comtype_description['Persons']=$person_columns['comtypes'];
                                        
$this->bo->save_preferences($this->selected_fields);
!                                       $this->save_sessiondata(true);
!                                       return;
                                }
                        case 'remove':
--- 441,455 ----
                                        
$this->bo->comtype_description['Organizations']=$org_columns['comtypes'];
                                        
$this->bo->comtype_description['Persons']=$person_columns['comtypes'];
+ 
+                                       //print 
'<BR><B>Catid'.$this->map_tpl_to_real['cat_id'].'</B><BR>';
+                                       
$this->bo->default_category=$this->map_tpl_to_real['cat_id'];
                                        
$this->bo->save_preferences($this->selected_fields);
!                               //      $this->save_sessiondata(true);
!                               //      print 
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
!                               //      return;
!                                       
$GLOBALS['phpgw']->common->phpgw_header();
!                                       echo parse_navbar();
!                                       $this->get_exact_fields();
!                                       break;
                                }
                        case 'remove':
***************
*** 402,405 ****
--- 469,485 ----
                                                
unset($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me]);
                                        }
+                                       //Look if we remove_me is the last 
field to be removed
+                                       
+                                       if($this->cache_is_empty())
+                                       {
+                                               
if($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me])
+                                               {
+                                                       
unset($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me]);
+                                               }
+                                               else
+                                               {
+                                                       
unset($this->cached_selected_fields[$this->org_or_person][$this->remove_me]);
+                                               }
+                                       }       
  
                                }
***************
*** 407,413 ****
--- 487,499 ----
                        default:
                                {
+                                       
$GLOBALS['phpgw']->common->phpgw_header();
+                                       echo parse_navbar();
+ 
+ 
+                                       
                                        //Selecting fields, let it roll
                                        //print '<BR><B>SELECTFIELDS!</B><BR>';
                                        $this->get_exact_fields();
+                                       //print_r($this->selected_fields);
  
                                                
***************
*** 427,435 ****
                $this->show_selectbox();
                //Obviously Not first time,  fields have been selected
!               if( (is_array($this->selected_fields[$org_or_person])) || 
(is_array($this->cached_selected_fields[$this->org_or_person])))
                {
!                       /*print '<BR><B>Supose!</B><BR>';
!                       print_r($this->selected_fields);
!                       print_r($this->cached_selected_fields);*/
                        $this->show_cols();
                }
--- 513,520 ----
                $this->show_selectbox();
                //Obviously Not first time,  fields have been selected
!               if( (is_array($this->selected_fields[$org_or_person])) || 
(is_array($this->cached_selected_fields[$this->org_or_person])) && 
!$this->cache_is_empty())
                {
! 
!               //      print_r($this->cached_selected_fields);
                        $this->show_cols();
                }
***************
*** 452,455 ****
--- 537,544 ----
                
$this->template->set_var('submit_save_value',$this->map_tpl_to_real['submit_save_value']);
                
$this->template->set_var('lang_remove_field',$GLOBALS['phpgw']->lang('remove'));
+               
$this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
+               
$this->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
+               //Catergories
+               
$this->template->set_var('cat_options',$this->map_tpl_to_real['cat_options']);
        }
        
***************
*** 553,566 ****
                                
                }
!               while(list($k,$v)=each($arrays))
                {
!                       while(list($ok,$ov)=each($v))
                        {
  
!                               
$this->template->set_var('lang_selected_contact_field',$this->lang_fields[$ok]);
!                               
$this->template->set_var('remove_me_link',$GLOBALS['phpgw']->link('/index.php',
!                                                       
"menuaction=addressbook.uiaddressbook_prefs.index&remove_me=$ok&org_or_person=".$this->org_or_person)
!                                               );
!                               
$this->template->parse('V_selected_rows','B_selected_rows',True);
                        }
                }
--- 642,658 ----
                                
                }
!               if(is_array($arrays))
                {
!                       while(list($k,$v)=each($arrays))
                        {
+                               while(list($ok,$ov)=each($v))
+                               {
  
!                                       
$this->template->set_var('lang_selected_contact_field',$this->lang_fields[$ok]);
!                                       
$this->template->set_var('remove_me_link',$GLOBALS['phpgw']->link('/index.php',
!                                                               
"menuaction=addressbook.uiaddressbook_prefs.index&remove_me=$ok&org_or_person=".$this->org_or_person)
!                                                       );
!                                       
$this->template->parse('V_selected_rows','B_selected_rows',True);
!                               }
                        }
                }
***************
*** 596,600 ****
--- 688,694 ----
                $this->cached_selected_fields=$data['selected_fields'];
                $this->map_tpl_to_real=$data['map_tpl_to_real'];
+               $this->cat_id=$this->map_tpl_to_real['cat_id'];
                $this->lang_fields=$data['lang_fields'];
+               $this->cache_is_empty=$data['cache_is_empty'];
  
        }





reply via email to

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