phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: addressbook/inc arr.php, NONE, 1.1.2.1 class.boa


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] CVS: addressbook/inc arr.php, NONE, 1.1.2.1 class.boaddressbook_prefs.inc.php, NONE, 1.1.2.1 class.uiaddressbook1.inc.php, NONE, 1.1.2.1 class.uiaddressbook_prefs.inc.php, NONE, 1.1.2.1 hook_sidebox_menu.inc.php, NONE, 1.1.2.1 class.boXport.inc.php, 1.7, 1.7.4.1 class.boaddressbook.inc.php, 1.21.2.2.2.2, 1.21.2.2.2.3 class.pdb.inc.php, 1.3, 1.3.6.1 class.soaddressbook.inc.php, 1.14.2.3, 1.14.2.3.2.1 class.uiXport.inc.php, 1.6.2.4, 1.6.2.4.2.1 class.uiaddressbook.inc.php, 1.36.2.15.2.7, 1.36.2.15.2.8 class.uifields.inc.php, 1.3.2.3.2.3, 1.3.2.3.2.4 class.uivcard.inc.php, 1.5.2.1, 1.5.2.1.2.1 functions.inc.php, 1.101.2.1, 1.101.2.1.2.1 hook_admin.inc.php, 1.9.2.2, 1.9.2.2.2.1 hook_config_validate.inc.php, 1.1, 1.1.6.1 hook_deleteaccount.inc.php, 1.5, 1.5.6.1 hook_home.inc.php, 1.13.2.5, 1.13.2.5.2.1 hook_manual.inc.php, 1.4, 1.4.8.1 hook_notifywindow.inc.php, 1.5.2.1, 1.5.2.1.2.1 hook_preferences.inc.php, 1.21, 1.21.6.1
Date: Mon, 08 Sep 2003 09:26:40 -0400

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

Modified Files:
      Tag: Version-0_9_16-branch
        class.boXport.inc.php class.boaddressbook.inc.php 
        class.pdb.inc.php class.soaddressbook.inc.php 
        class.uiXport.inc.php class.uiaddressbook.inc.php 
        class.uifields.inc.php class.uivcard.inc.php functions.inc.php 
        hook_admin.inc.php hook_config_validate.inc.php 
        hook_deleteaccount.inc.php hook_home.inc.php 
        hook_manual.inc.php hook_notifywindow.inc.php 
        hook_preferences.inc.php 
Added Files:
      Tag: Version-0_9_16-branch
        arr.php class.boaddressbook_prefs.inc.php 
        class.uiaddressbook1.inc.php class.uiaddressbook_prefs.inc.php 
        hook_sidebox_menu.inc.php 
Log Message:
Adding new contacts backend ... and associated code


--- NEW FILE ---
[comm] => Array ( 
                 [0] => Array ( 
                               [description] => asddsadsa 
                               [value] => dsadsa 
                               [type] => 
                               [preferred] => on ) 
                 [1] => Array ( 
                               [description] => weewq 
                               [value] => dssadas 
                               [type] => 
                               [preferred] => ) 
                 [2] => Array ( 
                               [description] => vfdhytjyt 
                               [value] => trher 
                               [type] => 
                               [preferred] => )) 
--- NEW FILE ---
<?php
  /**************************************************************************\
  * phpGroupWare API - Commononly used functions                             *
  * This file written by Alex Borges <address@hidden>                        *
  * UI for addressbook preferences                                           *
  * Copyright (C) 2003 Alex Borges                                           *
  * -------------------------------------------------------------------------*
  * This library is part of the phpGroupWare Addressbook app                 *
  * http://www.phpgroupware.org/                                             * 
  * ------------------------------------------------------------------------ *
  * This library 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.                                            *
  * 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 General Public License for more details.                     *
  * You should have received a copy of the GNU  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            *
  \**************************************************************************/
class boaddressbook_prefs
{
        var $preferences;
        var $person_columns;
        var $person_comtype_descriptions;
        var $org_comtype_descriptions;
        var $org_columns;
        var $default_category='__NONE__';
        var $public=array('read_preferences' => True);
        function boaddressbook_prefs()
        {
                $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() 
        {
                if(is_array($this->person_columns))
                {
                        
$this->preferences->add('addressbook','person_columns',serialize($this->person_columns));
                }
                if(is_array($this->org_columns))
                {
                        
$this->preferences->add('addressbook','org_columns',serialize($this->org_columns));
                }

                if(is_array($this->person_comtype_descriptions))
                {
                        
$this->preferences->add('addressbook','person_comtype_descriptions',serialize($this->person_comtype_descriptions));
                }
                if(is_array($this->org_comtype_descriptions))
                {
                        
$this->preferences->add('addressbook','org_comtype_descriptions',serialize($this->person_comtype_descriptions));
                }
                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();
                $temp=$this->preferences->data['addressbook'];
                $this->person_columns=unserialize($temp['person_columns']);
                $this->org_columns=unserialize($temp['org_columns']);
                $this->default_category=$temp['default_category'];
                
$this->person_comtype_descriptions=unserialize($temp['person_comtype_descriptions']);
                
$this->org_comtype_descriptions=unserialize($temp['org_comtype_descriptions']);
        }

}

***** Error reading new file: [Errno 2] No such file or directory: 
'class.uiaddressbook1.inc.php'
--- NEW FILE ---
<?php
  /**************************************************************************\
  * phpGroupWare API - Commononly used functions                             *
  * This file written by Alex Borges <address@hidden>                        *
  * UI for addressbook preferences                                           *
  * Copyright (C) 2003 Alex Borges                                           *
  * -------------------------------------------------------------------------*
  * This library is part of the phpGroupWare Addressbook app                 *
  * http://www.phpgroupware.org/                                             * 
  * ------------------------------------------------------------------------ *
  * This library 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.                                            *
  * 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  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            *
  \**************************************************************************/
class uiaddressbook_prefs 
{
        var $prefs; 

        var $template;
        //@param selected_fields 
        //@discussion transient selected fields. Allways holds what the fields
        //that are found as selected in GET/POST vars, NOT the ones in session 
data
        var $selected_fields;
        //@param cached_selected_fields
        //@discussion Selected fields that are in the session data
        var $cached_selected_fields;
        var $public_functions = array(
                                        'index' => True,
                                        'remove_me' => True,
                                        'css' => true
                                        );
        /address@hidden remove_me
        @discussion transient field representing the false field to remove from 
the
        table's column
        */
         var $remove_me;
        /*
           @param contacts
           @discussion Should be contacts but for now we are going to make a 
uiaddressbook
           because its where the addressbook caches the com-types catalog 
         */
        var $contacts;
        /*
            @param org_or_person
            @discussion A simple flag that determines if we are editing the 
showable fields for
            orgs or persons.
        */
        var $org_or_person='Persons';
        var $map_tpl_to_real=array( 
                 'select_columns_form_name'=> 'on_constructor',
                 'select_columns_form_action' => 'on_constructor',
                 'select_columns_selectbox_name' => 'var_dependant',
                 'select_columns_submit_value' => 'on_constructor',
                 'lang_select_cols' => 'on_constructor', 
                 'lang_abprefs' => 'on_constructor',
                 'B_select_columns_form_options' => 'on_constructor',
                 'select_columns_comtypes_name' => 'var_dependant',
                 '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
        var $fields_show_selectbox;
        var $lang_fields;
        var $bo;
        var $submit;
        function uiaddressbook_prefs()
        {
                $this->template = $GLOBALS['phpgw']->template;
                if(!$this->session_data_saved())
                {
                        
$this->map_tpl_to_real['lang_select_cols']=$GLOBALS['phpgw']->lang('Fields to 
show in address list');
                        
$this->map_tpl_to_real['lang_abprefs']=$GLOBALS['phpgw']->lang('addressbook 
preferences');
                        
$this->map_tpl_to_real['select_columns_submit_value']=$GLOBALS['phpgw']->lang('select
 fields');
                        
$this->map_tpl_to_real['submit_save_value']=$GLOBALS['phpgw']->lang('save');
                        
$this->map_tpl_to_real['submit_cancel_value']=$GLOBALS['phpgw']->lang('cancel');
                        
$this->map_tpl_to_real['submit_remove_value']=$GLOBALS['phpgw']->lang('remove');
                        
$this->map_tpl_to_real['org_preferences_link']=$GLOBALS['phpgw']->link('/index.php',
                                                                                
        array(
                                                                                
                'menuaction' => 'addressbook.uiaddressbook_prefs.index',
                                                                                
                'org_or_person' => 'Organizations'
                                                                                
                )
                                                                                
        );

                        
$this->map_tpl_to_real['person_preferences_link']=$GLOBALS['phpgw']->link('/index.php',
                                                                                
        array(
                                                                                
                'menuaction' => 'addressbook.uiaddressbook_prefs.index',
                                                                                
                'org_or_person' => 'Persons'
                                                                                
                )
                                                                                
        );


                                                                                
                        
                                                                                
                }
                else
                {
                        $this->read_sessiondata();
                }
                $this->contacts = CreateObject('phpgwapi.contacts');
                $this->bo=CreateObject('addressbook.boaddressbook_prefs');
                $this->bo->read_preferences();
/*              print "<p><b>Preferences</b></p>";
                print_r($this->bo->person_columns);
                print "<p><b>Preferences</b></p>";
                print_r($this->bo->org_columns); 
                */

        }
        //@function hashify
        //I dislike single dimmension numeric key arrays, i use this function 
to convert them to a hash
        function hashify($ar,$exclude)
        {

                if(is_array($ar))
                {
                        reset($ar);
                        while(list($k,$v)=each($ar))
                        {
                                if(!is_array($v))
                                {
                                        
                                        $tmp[$v]=True;
                                }
                                else
                                {
                                        $name=array_pop($exclude);
                                        $tmp[$name]=$this->hashify($v,$exclude);
                                }
                        }
                }
                else
                {
                        if(!empty($ar))
                        {
                                $tmp[$ar]=$ar;
                        }
                        else
                        {
                                return $false;
                        }
                }
                return $tmp;

        }
        function get_vars()
        {
                $temp=get_var('org_or_person',array('get','post'));
                if($temp=='Organizations' || $temp == 'Persons')
                {
                        $this->org_or_person=$temp;
                }
                
$this->map_tpl_to_real['select_columns_form_action']=$GLOBALS['phpgw']->link
                                        ('/index.php',
                                        array(
                                                'menuaction' => 
"addressbook.uiaddressbook_prefs.columns_selected",
                                                'org_or_person' => 
$this->org_or_person
                                                )
                                        );

                
                
$this->map_tpl_to_real['select_columns_selectbox_name']='selected_fields['.$this->org_or_person.'][]';
                
$this->map_tpl_to_real['select_columns_comtypes_name']='selected_fields['.$this->org_or_person.'][comm_types][]';
                
                
$this->selected_fields=get_var('selected_fields',array('post','GET'));
                /*
                print "<p><b>Selected fields</b></p>";
                print_r($this->selected_fields);*/
                if(is_array($this->selected_fields[$this->org_or_person]))
                {
                /*      print "<p><b>There are 
".count($this->selected_fields[$this->org_or_person])." selected</b></p>"; */
                        
$this->selected_fields[$this->org_or_person]=$this->hashify($this->selected_fields[$this->org_or_person],array('comm_types'));
                }
                //three kinds of submit
                //They have hit the button to add selected fields
                if(get_var('select_fields',array('post','get')))
                {
                        /* print '<BR><B>selectfields</B><BR>'; */
                        $temp='select_fields';
                }
                elseif(get_var('save',array('post','get')))
                {
                        $temp='save';
                }
                elseif(get_var('cancel',array('post','get')))
                {
                        $temp='cancel';
                }
                else
                {
                        $temp=get_var('remove_me',array('get','post'));
                        /*print '<BR><B>remove type'.$temp.'</B><BR>';*/
                        
                        if($this->selected_fields[$this->org_or_person][$temp])
                        {
                                //if we have found an element to be removed
                                //remove it from here
                                //This should never happen though
                                
unset($this->select_fields[$this->org_or_person][$temp]);
                        }
                                $this->remove_me=$temp;
                                $temp='remove';
                }
                

                $this->submit=$temp;
                /*print '<BR><B>selected </B>';
                print_r($this->selected_fields);
                print '<BR><B>Submited</B>';
                print $this->submit; */
                $temp=get_var('org_or_person',array('get','post'));
                if($temp=='Organizations' || $temp == 'Persons')
                {
                        $this->org_or_person=$temp;
                }
                        

        }
        function fields_to_show() 
        {
                //have uiaddressbook fill up its field => english array, 
stock_contact_fields 
                
$org_person_array['Persons']=$this->contacts->get_person_properties();
                
$org_person_array['Organizations']=$this->contacts->get_organization_properties();
                /*print "<br><b>catalogs</b><br>";*/
                //now go translating each field
                reset($this->contacts->stock_contact_fields);
                //Constructing simple 'showable' fields
                
while(list($falsefield,$english)=each($this->contacts->stock_contact_fields))
                {
                        //If it in selected_fields, then it has been selected, 
and it doesnt go into
                        //the fields_show_selectbox array
                        
if((!$this->selected_fields[$this->org_or_person][$falsefield]))
                        {
                                if($this->org_or_person=='Persons')
                                {
                                        if(! 
in_array($falsefield,$org_person_array['Organizations']) )
                                        {
                                                
$this->fields_show_selectbox[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);
                                        //      print "<br><br><b> 
$falsefield<\b>";
                                                
$this->lang_fields[$falsefield]=$this->fields_show_selectbox[$falsefield];
                                        }
                                                
unset($org_person_array['Organizations'][$falsefield]);
                                }
                                elseif($this->org_or_person=='Organizations')
                                {
                                        if(! 
in_array($falsefield,$org_person_array['Persons'] ))
                                        {
                                                
$this->fields_show_selectbox[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);
                                                
$this->lang_fields[$falsefield]=$this->fields_show_selectbox[$falsefield];
                                        }
                                                
unset($org_person_array['Persons'][$falsefield]);
                                        
                                }
                        }
                        else
                        {
                                //If it in selected_fields, then it has been 
selected, excluded from the selectbox, and
                                //added to the lang_fields array which shows 
the columns that have been selected
                                
$this->lang_fields[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);

                        }
                //Constructing commtype descriptions
                }
                
$possible_comtypes=$this->linearize_query($this->contacts->get_contact_comm_descr(),'comm_description');
                while(list($k,$v)=each($possible_comtypes))
                {
                        
if(!$this->selected_fields[$this->org_or_person]['comm_types'][$v])
                        {
                        //      print "<B><BR>Commtypes 
$this->selected_fields[$this->org_or_person]['comm_types'][$v]</b><br>";
                                
$this->fields_show_selectbox['comm_types'][$v]=$v;      
                                
                        }
                        else
                        {
                        //      print "<B><BR>langfields 
$this->lang_fields[$v]=$v</b><br>";
                                $this->lang_fields[$v]=$v;

                        }
                }
                /*
                        
                print "<br><b>Columns</b><br>";
                print_r($this->lang_fields);

                print "<br><b>Columns</b><br>"; */
        }
        function linearize_query($qresult,$key)
        {
//              print_r($qresult);
                reset($qresult);
                for($i=0;$i < count($qresult);$i++)
                {
                                $ret[$qresult[$i][$key]]=$qresult[$i][$key];
                }
                return $ret;
        }
        function get_exact_fields()
        {
                //Selecting fields, let it roll
                /*print '<BR><B>SELECTFIELDS!</B><BR>';*/
                
if(is_array($this->cached_selected_fields[$this->org_or_person]) && 
is_array($this->selected_fields[$this->org_or_person]))
                {
                        //We have cached selected fields, and someone selected 
more
                        //Need to agregate the selected to the cached
                        /*print '<BR><B>Merging Selected Fields</B><BR>';
                        print_r($this->selected_fields[$this->org_or_person]);
                        print '<BR><B>Merging Cached Selected Fields</B><BR>';
                        
print_r($this->cached_selected_fields[$this->org_or_person]);
*/
                        
$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]);*/
                }
                elseif(is_array($this->selected_fields[$this->org_or_person]))
                {
                        
$this->cached_selected_fields[$this->org_or_person]=$this->selected_fields[$this->org_or_person];
/*                      print '<BR><B>Selected awright</B><BR>'; */
                }
                
elseif(is_array($this->cached_selected_fields[$this->org_or_person]))
                {
                        
$this->selected_fields[$this->org_or_person]=$this->cached_selected_fields[$this->org_or_person];
/*                      print '<BR><B>Cached awright</B><BR>'; */
                }
                elseif($this->org_or_person == 'Persons' && 
is_array($this->bo->person_columns))
                {
                        /*print '<BR><B>Old preferences found</B><BR>';*/
                        
$this->selected_fields['Persons']=$this->cached_selected_fields['Persons']=$this->bo->person_columns;
                }
                elseif($this->org_or_person == 'Organizations' && 
is_array($this->bo->org_columns))
                {
                        /* print '<BR><B>Old preferences found</B><BR>'; */
                        
$this->selected_fields[$this->org_or_person]['Organizations']=$this->cached_selected_fields['Organizations']=$this->bo->org_columns;
                }
                
        }
        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>';*/
                switch($this->submit)
                {

                        case 'cancel':
                                {
                                        $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
                                        //combinedly in the cache or in the 
selected_fields array
                                        
if(is_array($this->selected_fields['Persons']))
                                        {
                                                
$person_columns=$this->selected_fields['Persons'];
                                        }
                                        else
                                        {
                                                
$person_columns=$this->cached_selected_fields['Persons'];
                                        }
                                        
if(is_array($this->selected_fields['Organizations']))
                                        {
                                                
$org_columns=$this->selected_fields['Organizations'];
                                        }
                                        else
                                        {
                                                
$org_columns=$this->cached_selected_fields['Organizations'];
                                        }
                                        
$this->bo->person_columns=$person_columns;
                                        $this->bo->org_columns=$org_columns;
                                        
$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':
                                {
                                        //if removing
                                        
                                        //print '<BR><B>Removing!</B><BR>';
                                        
if($this->cached_selected_fields[$this->org_or_person][$this->remove_me])
                                        {
                                                //kill the field to be removed
                                                //print 
'<BR><B>Removing!'.$this->remove_me.'</B><BR>';
                                                
unset($this->cached_selected_fields[$this->org_or_person][$this->remove_me]);
                                        }
                                        
elseif($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me])
                                        {
                                                //print 
'<BR><B>Removing!'.$this->remove_me.'</B><BR>';
                                                
unset($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me]);
                                        }

                                }
                                                        
                        default:
                                {
                                        //Selecting fields, let it roll
                                        //print '<BR><B>SELECTFIELDS!</B><BR>';
                                        $this->get_exact_fields();

                                                
                                }
                }
                $this->template->set_file(
                                        array(
                                        'addressbook_preferences_t' 
=>'preferences.tpl',
                                        'preferences_bits_t' => 
'preferences_bits.tpl',
                                        'select_columns_form_options_t' => 
'preferences_bits.tpl',
                                        'select_columns_commtypes_options_t' => 
'preferences_bits.tpl',
                                        'selected_rows_t' => 
'preferences_bits.tpl',
                                        'principal_tabs_t' => 
'principal_tabs.tpl'
                                                )
                                        );
                //first, build the selectbox, select where needed
                $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();
                }
                $this->set_static_vars();
                $this->set_tabs();
                $this->template->parse('out','addressbook_preferences_t');
                $this->template->p('out');
                $this->save_sessiondata();
        }
        function set_static_vars()
        {

                
$this->template->set_var('lang_abprefs',$this->map_tpl_to_real['lang_abprefs']);
                
$this->template->set_var('lang_select_cols',$this->map_tpl_to_real['lang_select_cols']);
                
$this->template->set_var('select_columns_submit_value',$this->map_tpl_to_real['select_columns_submit_value']);

                
$this->template->set_var('select_columns_selectbox_name',$this->map_tpl_to_real['select_columns_selectbox_name']);
                
$this->template->set_var('select_columns_comtypes_name',$this->map_tpl_to_real['select_columns_comtypes_name']);
                
$this->template->set_var('submit_cancel_value',$this->map_tpl_to_real['submit_cancel_value']);
                
$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'));
        }
        
        function set_tabs()
        {
                
$this->template->set_block('principal_tabs_t','principal_button');
                $this->template->set_block('principal_tabs_t','principal_tab');

                //print '<BR><B>Now it is a '.$this->org_or_person.'</B><BR>';
                $this->parse_principal_tabs(
                                                
$this->map_tpl_to_real['person_preferences_link'],
                                                $this->get_class_css(
                                                                'Persons',
                                                                
$this->org_or_person
                                                                ),
                                                'Persons',
                                                'Person'
                                            );
                $this->parse_principal_tabs(
                                                
$this->map_tpl_to_real['org_preferences_link'],
                                                $this->get_class_css(
                                                                'Organizations',
                                                                
$this->org_or_person),          
                                                'Organizations',
                                                'Organization'
                                            );
                
$this->template->set_var('tabs',$this->template->fp('out','principal_tab'));
        
                
        }
        function show_selectbox($org_or_person='')
        {
                if(empty($org_or_person))
                {
                        $org_or_person=$this->org_or_person;
                }

                $this->fields_to_show();
                
$this->template->set_block('select_columns_form_options_t','B_select_columns_form_options','V_select_columns_form_options');
                
$this->template->set_block('select_columns_commtypes_options_t','B_select_ctypes_options','V_select_columns_commtypes_options');
                if(count($this->fields_show_selectbox) > 1)
                {
                        reset($this->fields_show_selectbox);
//                      print "<BR><B> To Show in 
Selectbox<br>".print_r($this->fields_show_selectbox)."</B><BR>";
                        
while(list($field,$lang)=each($this->fields_show_selectbox))
                        {
                                //not a comtype
                                
                                if(!is_array($lang))
                                {
                                        
$this->template->set_var('lang_contact_field',$lang);
                                        
$this->template->set_var('value',$field);
                                        
$this->template->parse('V_select_columns_form_options','B_select_columns_form_options',True);
                                }
                                else
                                {
                                        while(list($k,$description)=each($lang))
                                        {
                                                
$this->template->set_var('lang_comtype_field',$description);
                                                
$this->template->set_var('commtype_description',$description);
                                                
$this->template->parse('V_select_ctypes_options',
                                                                        
'B_select_ctypes_options',True);
                                                                        
                                        }
                                }
                        }
                }
                else
                {
                        
$this->template->set_var('lang_contact_field',$GLOBALS['phpgw']->lang('Empty'));
                        $this->template->set_var('value',"");
                        
$this->template->parse('V_select_columns_form_options','B_select_columns_form_options');
                }
                
$this->template->parse('B_select_columns_form_options','V_select_columns_form_options');
                $this->template->parse('B_select_ctypes_options', 
'V_select_ctypes_options');

        }
        function show_cols($org_or_person='')
        {
                if(empty($org_or_person))
                {
                        $org_or_person=$this->org_or_person;
                }
                
$this->template->set_block('selected_rows_t','B_selected_rows','V_selected_rows');
                reset($this->selected_fields[$this->org_or_person]);
                
while(list($k,$v)=each($this->selected_fields[$this->org_or_person]))
                {
                        if(!is_array($v))
                        {
                                
$this->template->set_var('lang_selected_contact_field',$this->lang_fields[$k]);
                                
$this->template->set_var('remove_me_link',$GLOBALS['phpgw']->link('/index.php',
                                
"menuaction=addressbook.uiaddressbook_prefs.index&remove_me=$k&org_or_person=".$this->org_or_person)
                                                );
                                
$this->template->parse('V_selected_rows','B_selected_rows',True);
                        }
                        else
                        {
                                reset($v);
                                $arrays[]=$v;
                        }
                                
                }
                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);
                        }
                }

                $this->template->parse('B_selected_rows','V_selected_rows');
        }
        
        function save_sessiondata($clear=false)
        {
                if(!$clear)
                {

                        
$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref',
                                        array(
                                                'selected_fields' => 
$this->cached_selected_fields,
                                                'map_tpl_to_real' => 
$this->map_tpl_to_real,
                                                'lang_fields' => 
$this->lang_fields
                                             )
                                        );
                }
                else
                {
                //      print '<BR><B>Clearing Cache </B><BR>';
                        
$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref','');
                }

        }
        function read_sessiondata()
        {

//              print '<BR><B>READING SESSIONDATA!</B><BR>';
                
$data=$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref');
                $this->cached_selected_fields=$data['selected_fields'];
                $this->map_tpl_to_real=$data['map_tpl_to_real'];
                $this->lang_fields=$data['lang_fields'];

        }

        function session_data_saved()
        {
                
$data=$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref');
                //print "<BR><B>Actually got sessiondata</B><BR>";
                //print_r($data);
                return is_array($data);
        }
        function parse_principal_tabs($action,$class_css,$name,$value)
        {
                $button = array('principal_action'      => $action,
                                'principal_class_css'   => $class_css,
                                'principal_name'        => $name,
                                'principal_value'       => $value);
                $this->template->set_var($button);
                $this->template->parse('principal_buttons', 
'principal_button',true);

        }
        function get_class_css($tab, $current_tab)
        {
                //print "<BR><B>ITS AN $tab == $current_tab";
                if ($tab == $current_tab)
                {
                        return 'button_style_sel';
                }
                else
                {
                        return 'button_style';
                }
        
        }

                function css()
                {
                        $tmp = 'input[type="submit"].button_style, 
input[type="button"].button_style {
                                color: #555;
                                margin-left: 1px;
                                margin-right: 1px;
                                background-color: #ddd;
                                border:1px #888 solid;
                                border-bottom-width: 0px;
                                padding: 1px;
                                width: 85px;
                                }

                                input[type="submit"].button_style_sel, 
input[type="button"].button_style_sel {
                                color: #555;
                                margin-left: 1px;
                                margin-right: 1px;
                                /*background-color: #e5e5e5;*/
                                border:1px #888 solid;
                                border-bottom-width: 0px;
                                padding: 1px;
                                width: 85px;
                                }

                                input[type="submit"]:hover.button_style, 
input[type="button"]:hover.button_style {
                                background-color: #eee;
                                color: #36c;
                                }

                                input[type="submit"]:active.button_style, 
input[type="button"]:active.button_style {
                                background-color: #eee;
                                color: #9ac;
                                }';
                        return $tmp;
                }
        
}


--- NEW FILE ---
<?php
        $menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '. 
lang('Menu');

$file = Array(
        'New Person'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_person'),
        'New Org'       => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_org'),
        '_NewLine_'     => '', // give a newline
        'Add VCard'     => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in'),
        'Import Contacts'=> 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import'),
        'Import CSV'    => 
$GLOBALS['phpgw']->link('/addressbook/csv_import.php'),
        'Export Contacts'=> 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'),
        '_NewLine_'     => '' // give a newline
        );

display_sidebox($appname,$menu_title,$file);
?>

Index: class.boXport.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.boXport.inc.php,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -C2 -r1.7 -r1.7.4.1

Index: class.boaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.boaddressbook.inc.php,v
retrieving revision 1.21.2.2.2.2
retrieving revision 1.21.2.2.2.3
diff -C2 -r1.21.2.2.2.2 -r1.21.2.2.2.3
*** class.boaddressbook.inc.php 21 May 2003 20:58:43 -0000      1.21.2.2.2.2
--- class.boaddressbook.inc.php 8 Sep 2003 13:26:37 -0000       1.21.2.2.2.3
***************
*** 1,9 ****
  <?php
    /**************************************************************************\
!   * phpGroupWare - addressbook                                               *
    * http://www.phpgroupware.org                                              *
!   * Written by Miles Lott <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  *
--- 1,16 ----
  <?php
    /**************************************************************************\
!   * phpGroupWare - boaddressbook                                             *
    * http://www.phpgroupware.org                                              *
!   * This program is part of the GNU project, see http://www.gnu.org/         *
!   *                                                                          *
!   * Copyright 2003 Free Software Foundation, Inc.                            *
!   *                                                                          *
!   * Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx  *
!   * Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx  *
    * --------------------------------------------                             *
!   * Development of this application was funded by http://www.sogrp.com       *
!   * --------------------------------------------                             *
!   *  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  *
***************
*** 11,15 ****
    \**************************************************************************/
  
!   /* $Id$ */
  
        class boaddressbook
--- 18,22 ----
    \**************************************************************************/
  
! /* $Id$ */
  
        class boaddressbook
***************
*** 64,78 ****
                var $use_session = False;
  
!               function boaddressbook($session=False)
                {
                        $this->so = CreateObject('addressbook.soaddressbook');
                        $this->rights = $this->so->rights;
                        $this->grants = $this->so->grants;
! 
!                       if($session)
!                       {
                                $this->read_sessiondata();
                                $this->use_session = True;
!                       }
                        /* _debug_array($GLOBALS['HTTP_POST_VARS']); */
                        /* Might change this to '' at the end---> */
--- 71,92 ----
                var $use_session = False;
  
!               function boaddressbook($session=True)
                {
                        $this->so = CreateObject('addressbook.soaddressbook');
                        $this->rights = $this->so->rights;
                        $this->grants = $this->so->grants;
!                       $this->contact_type = $this->so->contact_type;
!                       $this->comm_descr = $this->so->comm_descr;
!                       $this->comm_type = $this->so->comm_type;
!                       $this->addr_type = $this->so->addr_type;
!                       $this->note_type = $this->so->note_type;
!                       $this->tab_main_persons = $this->so->tab_main_persons;
!                       $this->tab_main_organizations = 
$this->so->tab_main_organizations;
!                       if($session)
!                       {
                                $this->read_sessiondata();
                                $this->use_session = True;
!                       }
! 
                        /* _debug_array($GLOBALS['HTTP_POST_VARS']); */
                        /* Might change this to '' at the end---> */
***************
*** 100,104 ****
  
                        if(isset($GLOBALS['HTTP_POST_VARS']['fcat_id']) || 
isset($GLOBALS['HTTP_POST_VARS']['fcat_id']))
!                       {
                                $this->cat_id = $_fcat_id;
                        }
--- 114,118 ----
  
                        if(isset($GLOBALS['HTTP_POST_VARS']['fcat_id']) || 
isset($GLOBALS['HTTP_POST_VARS']['fcat_id']))
!                       {                               
                                $this->cat_id = $_fcat_id;
                        }
***************
*** 211,215 ****
                        {
                                if($this->debug) { echo '<br>Save:'; 
_debug_array($data); }
!                               
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
                        }
                }
--- 225,229 ----
                        {
                                if($this->debug) { echo '<br>Save:'; 
_debug_array($data); }
!                               
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
                        }
                }
***************
*** 226,230 ****
                        $this->order  = $data['order'];
                        $this->filter = $data['filter'];
!                       $this->cat_id = $data['cat_id'];
                        if($this->debug) { echo '<br>read_sessiondata();'; 
$this->_debug_sqsof(); }
                }
--- 240,244 ----
                        $this->order  = $data['order'];
                        $this->filter = $data['filter'];
!                       $this->cat_id = $data['cat_id'];                        
                        if($this->debug) { echo '<br>read_sessiondata();'; 
$this->_debug_sqsof(); }
                }
***************
*** 255,258 ****
--- 269,273 ----
                function read_entries($data)
                {
+                       //print 'as'.print_r($data);
                        $entries = $this->so->read_entries($data);
                        $this->total = $this->so->contacts->total_records;
***************
*** 261,267 ****
                }
  
!               function read_entry($data)
                {
!                       $entry = 
$this->so->read_entry($data['id'],$data['fields']);
                        return $this->strip_html($entry);
                }
--- 276,282 ----
                }
  
!               function read_entry($id, $fields)
                {
!                       $entry = $this->so->read_entry($id, $fields);
                        return $this->strip_html($entry);
                }
***************
*** 398,402 ****
                                if ($other['autosave_category'])
                                {
!                                       
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
                                }
                        }
--- 413,417 ----
                                if ($other['autosave_category'])
                                {
!                                       
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
                                }
                        }
***************
*** 408,411 ****
--- 423,643 ----
                        /* _debug_array($prefs);exit; */
                        Header('Location: ' . 
$GLOBALS['phpgw']->link('/preferences/index.php'));
+               }
+ 
+               //used
+               function get_orgs_by_person($person_id)
+               {
+                       return $this->so->get_orgs_by_person($person_id);
+               }
+ 
+               //used
+               function add_person($fields)
+               {
+                       return $this->so->add_person($fields);
+               }
+ 
+               //used
+               function add_org($fields)
+               {
+                       return $this->so->add_org($fields);                     
+               }
+               
+               function get_principal_organizations_data($id)
+               {
+                       $entry = 
$this->so->contacts->get_principal_organizations_data($id);
+                       $entry[0]['load']='load';
+                       $entry[0]['my_cats'] = explode(",", 
$entry[0]['cat_id']);
+                       return $entry[0];
+               }
+ 
+               function get_principal_persons_data($id)
+               {
+                       $entry = 
$this->so->contacts->get_principal_persons_data($id);
+                       
+                       $email = $this->so->contacts->get_email($id);
+                       $phone = $this->so->contacts->get_phone($id);
+ 
+                       $entry[0]['email'] = $email[0]['email'];
+                       $entry[0]['wphone'] = $phone[0]['comm_data'];
+ 
+                       $entry[0]['load']='load';
+                       $entry[0]['my_cats'] = explode(",", 
$entry[0]['cat_id']);
+                       return $entry[0];
+               }
+               
+               function get_orgs_person_data($id)
+               {
+                       //get orgs for this person
+                       $entry = 
$this->so->contacts->get_organizations_by_person($id, 
array('my_org_id','org_name', 'my_preferred'));
+                       
+                       if($entry)
+                       {
+                               foreach($entry as $k => $v)
+                               {
+                                       if ($v['my_preferred'] == 'Y')
+                                       {
+                                               $entry['entry']['current_org'] 
= $v['my_org_id'];
+                                       }
+                                       $entry['entry']['my_orgs'][$k] = 
$v['my_org_id'];
+                               }
+                       }
+                       $entry['entry']['my_orgs']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_person_orgs_data($id)
+               {
+                       //get orgs for this person
+                       $entry = 
$this->so->contacts->get_people_by_organizations($id, array('my_person_id', 
'per_first_name'));
+                       if($entry)
+                       {
+                               foreach($entry as $k => $v)
+                               {
+                                       $entry['entry']['my_person'][$k] = 
$v['my_person_id'];
+                               }
+                       }
+                       $entry['entry']['my_person']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_others_contact_data($id)
+               {
+                       $entry['entry']['others'] = 
$this->so->contacts->get_others_contact_data($id);
+                       $entry['entry']['others']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_comm_contact_data($id)
+               {
+                       $entry['entry']['comm'] = 
$this->so->contacts->get_comm_contact_data($id);
+                       $entry['entry']['comm']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_addr_contact_data($id)
+               {
+                       $entry['entry']['addr'] = 
$this->so->contacts->get_addr_contact_data($id);
+                       $entry['entry']['addr']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_others_person_data($id)
+               {
+                       $entry['entry']['others'] = 
$this->so->contacts->get_others_contact_data($id);
+                       $entry['entry']['others']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_comm_person_data($id)
+               {
+                       $entry['entry']['comm'] = 
$this->so->contacts->get_comm_contact_data($id);
+                       $entry['entry']['comm']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_addr_person_data($id)
+               {
+                       $entry['entry']['addr'] = 
$this->so->contacts->get_addr_contact_data($id);
+                       $entry['entry']['addr']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_others_org_data($id)
+               {
+                       $entry['entry']['others'] = 
$this->so->contacts->get_others_contact_data($id);
+                       $entry['entry']['others']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_comm_org_data($id)
+               {
+                       $entry['entry']['comm'] = 
$this->so->contacts->get_comm_contact_data($id);
+                       $entry['entry']['comm']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_addr_org_data($id)
+               {
+                       $entry['entry']['addr'] = 
$this->so->contacts->get_addr_contact_data($id);
+                       $entry['entry']['addr']['load']='load';
+                       return $entry['entry'];
+               }
+ 
+               function get_persons($fields, $start='', $limit='', 
$orderby='', $sort='', $criteria='')
+               {
+                       $entries =  $this->so->get_persons($fields, $start, 
$limit, $orderby, $sort, $criteria);
+                       $this->total = $this->so->contacts->total_records;
+                       return $entries;
+               }
+ 
+               function get_orgs($fields, $start='', $limit='', $orderby='', 
$criteria='')
+               {
+                       $entries =  $this->so->get_orgs($fields, $start, 
$limit, $orderby);
+                       $this->total = $this->so->contacts->total_records;
+                       return $entries;
+               }
+ 
+               function get_insert_other($contact_id, $fields)
+               {
+                       return $this->so->contacts->add_others($fields, 
$contact_id);
+               }
+               
+               function get_update_other($contact_id, $fields)
+               {
+                       unset($fields['key_other_id']);
+                       return $this->so->contacts->edit_other($contact_id, 
$fields);
+               }
+ 
+               function get_insert_comm($contact_id, $fields)
+               {
+                       return 
$this->so->contacts->add_communication_media($fields, $contact_id);
+               }
+               
+               function get_update_comm($contact_id, $fields)
+               {
+                       unset($fields['key_comm_id']);
+                       return $this->so->contacts->edit_comms($contact_id, 
$fields);
+               }
+ 
+               function get_insert_addr($contact_id, $fields)
+               {
+                       return $this->so->contacts->add_location($fields, 
$contact_id);
+               }
+               
+               function get_update_addr($contact_id, $fields)
+               {
+                       unset($fields['key_addr_id']);
+                       return $this->so->contacts->edit_location($contact_id, 
$fields);
+               }
+               function get_columns_to_display($contact_type)
+               {
+                       return $this->so->read_preferences($contact_type);
+               }
+ 
+               function can_delete($contact_id, $function_data='')
+               {
+                       $data = $this->$function_data($contact_id);
+                       if 
($this->so->contacts->check_perms($this->grants[$data['owner']],PHPGW_ACL_DELETE)
 || 
+                           $data['owner'] == 
$GLOBALS['phpgw_info']['user']['account_id'])
+                       {
+                               return True;
+                       }
+                       else
+                       {
+                               return False;
+                       }
+               }
+               function get_preferences_for_organizations()
+               {
+                       return 
$this->so->read_preferences($this->tab_main_organizations);
+               }
+               function get_preferences_for_persons()
+               {
+                       return 
$this->so->read_preferences($this->tab_main_persons);
+                       
+               }
+               function get_generic_preferences()
+               {
+                       return false;
                }
        }

Index: class.pdb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.pdb.inc.php,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -C2 -r1.3 -r1.3.6.1

Index: class.soaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.soaddressbook.inc.php,v
retrieving revision 1.14.2.3
retrieving revision 1.14.2.3.2.1
diff -C2 -r1.14.2.3 -r1.14.2.3.2.1
*** class.soaddressbook.inc.php 15 Sep 2002 00:44:30 -0000      1.14.2.3
--- class.soaddressbook.inc.php 8 Sep 2003 13:26:37 -0000       1.14.2.3.2.1
***************
*** 1,9 ****
  <?php
    /**************************************************************************\
!   * phpGroupWare - addressbook                                               *
    * 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  *
--- 1,16 ----
  <?php
    /**************************************************************************\
!   * phpGroupWare - soaddressbook                                         *
    * http://www.phpgroupware.org                                              *
!   * This program is part of the GNU project, see http://www.gnu.org/         *
!   *                                                                          *
!   * Copyright 2003 Free Software Foundation, Inc.                            *
!   *                                                                          *
!   * Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx  *
!   * Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx  *
    * --------------------------------------------                             *
!   * Development of this application was funded by http://www.sogrp.com       *
!   * --------------------------------------------                             *
!   *  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  *
***************
*** 11,71 ****
    \**************************************************************************/
  
!   /* $Id$ */
  
        class soaddressbook
        {
-               var $contacts;
-               var $rights;
-               var $grants;
-               var $owner;
  
!               function soaddressbook()
                {
                        if(!isset($GLOBALS['owner']))
                        {
                                $GLOBALS['owner'] = 0;
                        }
-                       $owner = $GLOBALS['owner'];
  
!                       $this->contacts = CreateObject('phpgwapi.contacts');
!                       $grants = $this->contacts->grants;
!                       /* _debug_array($GLOBALS['phpgw_info']); */
!                       /* _debug_array($grants); */
! 
!                       if(!isset($owner) || !$owner)
!                       {
!                               $owner = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                               /* echo $owner; */
!                               $rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + 
PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
                                /* echo $rights; */
                        }
                        else
                        {
!                               if($grants[$owner])
                                {
!                                       $rights = $grants[$owner];
!                                       if (!($rights & PHPGW_ACL_READ))
                                        {
!                                               $owner = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                                               $rights = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
                                        }
                                }
                        }
!                       $this->rights = $rights;
!                       $this->grants = $grants;
!                       $this->owner  = $owner;
                }
  
                function read_entries($data)
                {
!                       return $this->contacts->read(
!                               $data['start'],
!                               $data['limit'],
!                               $data['fields'],
!                               $data['query'],
!                               $data['filter'],
!                               $data['sort'],
!                               $data['order']
!                       );
                }
  
--- 18,86 ----
    \**************************************************************************/
  
! /* $Id$ */
  
        class soaddressbook
        {
  
!               function soaddressbook($useacl=True)
                {
+                       $this->contacts = CreateObject('phpgwapi.contacts');
+ 
+                       if($useacl)
+                       {
+                               $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('addressbook');
+                       }
+ 
                        if(!isset($GLOBALS['owner']))
                        {
                                $GLOBALS['owner'] = 0;
                        }
  
!                       $this->owner = $GLOBALS['owner'];
! 
!                       if(!isset($this->owner) || !$this->owner)
!                       {
!                               $this->owner = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                               /* echo $this->owner; */
!                               $this->rights = PHPGW_ACL_READ + PHPGW_ACL_ADD 
+ PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
                                /* echo $rights; */
                        }
                        else
                        {
!                               if($this->grants[$this->owner])
                                {
!                                       $this->rights = 
$this->grants[$this->owner];
!                                       if (!($this->rights & PHPGW_ACL_READ))
                                        {
!                                               $this->owner = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                                               $this->rights = PHPGW_ACL_READ 
+ PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
                                        }
                                }
                        }
! 
!                       $this->contact_type = $this->contacts->contact_type;
!                       $this->comm_descr = $this->contacts->comm_descr;
!                       $this->comm_type = $this->contacts->comm_type;
!                       $this->addr_type = $this->contacts->addr_type;
!                       $this->tab_main_persons = 
$this->contacts->tab_main_persons;
!                       $this->tab_main_organizations = 
$this->contacts->tab_main_organizations;
                }
  
                function read_entries($data)
                {
!                       $data = array('contact_id',
!                                     'owner',
!                                     'n_given',
!                                     'n_family');
!                       return $this->contacts->get_persons($data);
! //                    return $this->contacts->get_persons(
! //                            $data['start'],
! //                            $data['limit'],
! //                            $data['fields'],
! //                            $data['query'],
! //                            $data['filter'],
! //                            $data['sort'],
! //                            $data['order']
! //                    );
                }
  
***************
*** 74,78 ****
                        if ($this->rights & PHPGW_ACL_READ)
                        {
!                               return 
$this->contacts->read_single_entry($id,$fields);
                        }
                        else
--- 89,94 ----
                        if ($this->rights & PHPGW_ACL_READ)
                        {
!                               //return 
$this->contacts->read_single_entry($id,$fields);
!                               return $this->contacts->get_person_data($id, 
$fields);
                        }
                        else
***************
*** 98,120 ****
                function add_entry($fields)
                {
-                       $fields['tid'] = trim($fields['tid']);
-                       if(empty($fields['tid']))
-                       {
-                               $fields['tid'] = 'n';
-                       }
                        if ($this->rights & PHPGW_ACL_ADD)
                        {
!                               $ab_id  = $fields['ab_id'];
!                               $owner  = $fields['owner'];
!                               $access = $fields['access'];
!                               $cat_id = $fields['cat_id'];
!                               $tid    = $fields['tid'];
!                               unset($fields['owner']);
!                               unset($fields['access']);
!                               unset($fields['cat_id']);
!                               unset($fields['ab_id']);
!                               unset($fields['tid']);
! 
!                               $id = 
$this->contacts->add($owner,$fields,$access,$cat_id,$tid);
                        }
                        return $id;
--- 114,131 ----
                function add_entry($fields)
                {
                        if ($this->rights & PHPGW_ACL_ADD)
                        {
!                               $id = $this->contacts->add_person($fields);
! //                            $ab_id  = $fields['ab_id'];
! //                            $this->owner  = $fields['owner'];
! //                            $access = $fields['access'];
! //                            $cat_id = $fields['cat_id'];
! //                            $tid    = $fields['tid'];
! //                            unset($fields['owner']);
! //                            unset($fields['access']);
! //                            unset($fields['cat_id']);
! //                            unset($fields['ab_id']);
! //                            unset($fields['tid']);
! //                            $id = 
$this->contacts->add($this->owner,$fields,$access,$cat_id,$tid);
                        }
                        return $id;
***************
*** 133,137 ****
                        {
                                $ab_id  = $fields['ab_id'];
!                               $owner  = $fields['owner'];
                                $access = $fields['access'];
                                $cat_id = $fields['cat_id'];
--- 144,148 ----
                        {
                                $ab_id  = $fields['ab_id'];
!                               $this->owner  = $fields['owner'];
                                $access = $fields['access'];
                                $cat_id = $fields['cat_id'];
***************
*** 143,147 ****
                                unset($fields['tid']);
  
!                               
$this->contacts->update($ab_id,$owner,$fields,$access,$cat_id,$tid);
                        }
                        return;
--- 154,158 ----
                                unset($fields['tid']);
  
!                               
$this->contacts->update($ab_id,$this->owner,$fields,$access,$cat_id,$tid);
                        }
                        return;
***************
*** 155,158 ****
--- 166,364 ----
                        }
                        return;
+               }
+ 
+               //used
+               function get_comm_descr()
+               {
+                       return $this->contacts->get_contact_comm_descr();
+               }
+ 
+               //used
+               function get_comm_type()
+               {
+                       return $this->contacts->get_contact_comm_type();
+               }
+ 
+               //used
+               function get_addr_type()
+               {
+                       return $this->contacts->get_contact_addr_type();
+               }
+               
+               //used
+               function get_orgs_by_person($person_id)
+               {
+                       return 
$this->contacts->get_organizations_by_person($person_id, 
array('my_org_id','org_name'));
+               }
+ 
+               function get_persons($fields, $start='', $limit='', 
$orderby='', $sort='', $criteria='')
+               {
+                       return $this->contacts->get_persons($fields, $start, 
$limit, $orderby, $sort, $criteria);
+               }
+ 
+               function get_orgs($fields, $start, $limit, $orderby)
+               {
+                       return $this->contacts->get_orgs($fields, $start, 
$limit, $orderby);
+               }
+ 
+               function get_count_persons($criteria='')
+               {
+                       return $this->contacts->get_count_persons($criteria);
+               }
+ 
+               function get_count_orgs($criteria='')
+               {
+                       return $this->contacts->get_count_orgs($criteria);
+               }
+ 
+               //used
+               function add_person($fields)
+               {
+ //                    if (is_array($fields['my_cats']))
+ //                    {
+ //                            $fields['cat_id'] = implode(",", 
$fields['my_cats']);
+ //                    }
+                       
+                       if (is_array($fields['my_orgs']))
+                       {
+                               $my_orgs = $fields['my_orgs'];
+                               foreach($my_orgs as $key => $value)
+                               {
+                                       $fields['orgs'][] = $value;
+                               }
+                       }
+ 
+                       $comms = $fields['comm'];
+                       $addr = $fields['addr'];
+                       $others = $fields['others'];
+                       $orgs = $fields['orgs'];
+                       $cats = $fields['my_cats'];
+                       
+                       unset($fields['tmp_data']);
+                       unset($fields['all_orgs']);
+                       unset($fields['all_cats']);
+                       unset($fields['my_cats']);
+                       unset($fields['my_orgs']);
+                       unset($fields['comm']);
+                       unset($fields['addr']);
+                       unset($fields['others']);
+                       unset($fields['orgs']);
+                       unset($fields['email']);
+                       unset($fields['wphone']);
+                       unset($fields['ispublic']);
+                       unset($fields['old_tab']);
+ 
+ //                    unset($fields['comms']['key_comm_id']);
+ //                    unset($fields['addr']['key_addr_id']);
+ //                    unset($fields['others']['key_other_id']);
+                       
+                       $type = 
$this->contacts->search_contact_type($this->tab_main_persons);
+                       $c_id = $this->contacts->add_contact($type, $fields, 
$comms, $addr, $cats, $others);
+ 
+                       //$this->contacts->add_email();
+                       //$this->contacts->add_phone();
+                       
+                       return $c_id;
+               }
+ 
+               //used
+               function add_org($fields)
+               {
+                       //$fields['cat_id'] = implode(",", $fields['my_cats']);
+                       
+                       if (is_array($fields['my_person']))
+                       {
+                               $my_persons = $fields['my_person'];
+                               foreach($my_persons as $key => $value)
+                               {
+                                       $fields['persons'][] = 
array('person_id' => $value);
+                               }
+                       }
+ 
+                       $comms = $fields['comm'];
+                       $addr = $fields['addr'];
+                       $others = $fields['others'];
+                       $persons = $fields['persons'];
+                       $cats = $fields['my_cats'];
+                       
+                       unset($fields['tmp_data']);
+                       unset($fields['all_person']);
+                       unset($fields['all_cats']);
+                       unset($fields['my_cats']);
+                       unset($fields['my_person']);
+                       unset($fields['comm']);
+                       unset($fields['addr']);
+                       unset($fields['others']);
+                       unset($fields['ispublic']);
+                       unset($fields['old_tab']);
+ 
+                       $type = 
$this->contacts->search_contact_type($this->tab_main_organizations);
+                       $c_id = $this->contacts->add_contact($type, $fields, 
$comms, $addr, $cats, $others);
+                       return $c_id;
+               }
+ 
+               function edit_person($person_id, $fields)
+               {
+                       $principal['owner'] = $fields['owner'];
+                       $principal['access'] = $fields['access'];
+                       $principal['cat_id'] = $fields['my_cats'];
+                       $this->contacts->edit_contact($person_id, $principal, 
PHPGW_SQL_RUN_SQL);
+                       unset($fields['contact_id']);
+                       unset($fields['owner']);
+                       unset($fields['access']);
+                       unset($fields['cat_id']);
+                       unset($fields['email']);
+                       unset($fields['wphone']);
+                       unset($fields['load']);
+                       unset($fields['my_cats']);
+                       unset($fields['ispublic']);
+                       unset($fields['old_tab']);
+                       unset($fields['bday_day']);
+                       unset($fields['bday_month']);
+                       unset($fields['bday_year']);
+                       $this->contacts->edit_person($person_id, $fields, 
PHPGW_SQL_RUN_SQL);
+               }
+ 
+               function edit_org($org_id, $fields)
+               {
+                       $principal['owner'] = $fields['owner'];
+                       $principal['access'] = $fields['access'];
+                       $principal['cat_id'] = $fields['my_cats'];
+                       $this->contacts->edit_contact($org_id, $principal, 
PHPGW_SQL_RUN_SQL);
+                       unset($fields['contact_id']);
+                       unset($fields['owner']);
+                       unset($fields['access']);
+                       unset($fields['cat_id']);
+                       unset($fields['email']);
+                       unset($fields['wphone']);
+                       unset($fields['load']);
+                       unset($fields['my_cats']);
+                       unset($fields['ispublic']);
+                       unset($fields['old_tab']);
+                       unset($fields['bday_day']);
+                       unset($fields['bday_month']);
+                       unset($fields['bday_year']);
+                       $this->contacts->edit_org($org_id, $fields, 
PHPGW_SQL_RUN_SQL);
+               }
+ 
+               function read_preferences($contact_type)
+               {
+                       static $already=false;
+                       if(!$already)
+                       {
+                               
$prefs=CreateObject('addressbook.boaddressbook_prefs');
+                               $prefs->read_preferences();
+                               $already=true;
+                       }
+                       
+                       if($contact_type==$this->tab_main_persons)
+                       {
+                               return $prefs->person_columns;
+                       }
+                       elseif($contact_type==$this->tab_main_organizations)
+                       {
+                               return $prefs->org_columns;
+                       }
+                               
                }
        }

Index: class.uiXport.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiXport.inc.php,v
retrieving revision 1.6.2.4
retrieving revision 1.6.2.4.2.1
diff -C2 -r1.6.2.4 -r1.6.2.4.2.1

Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.36.2.15.2.7
retrieving revision 1.36.2.15.2.8
diff -C2 -r1.36.2.15.2.7 -r1.36.2.15.2.8
*** class.uiaddressbook.inc.php 22 Aug 2003 12:54:19 -0000      1.36.2.15.2.7
--- class.uiaddressbook.inc.php 8 Sep 2003 13:26:37 -0000       1.36.2.15.2.8
***************
*** 3,8 ****
    * phpGroupWare - Addressbook                                               *
    * http://www.phpgroupware.org                                              *
!   * Written by Joseph Engo <address@hidden> and                      *
    * Miles Lott <miloschphpgroupware.org>                                     *
    * --------------------------------------------                             *
    *  This program is free software; you can redistribute it and/or modify it *
--- 3,9 ----
    * phpGroupWare - Addressbook                                               *
    * http://www.phpgroupware.org                                              *
!   * Originally Written by Joseph Engo <address@hidden> and           *
[...4191 lines suppressed...]
!                       if (is_array($this->$my_opt_array))
!                       {
!                               foreach($this->$my_opt_array as $key => $value)
!                               {
!                                       if ($key == $selected)
!                                       {
!                                               $my_opt .= '<option value="' . 
$key . '" selected>'
!                                                       . $value . '</option>';
!                                       }
!                                       else
!                                       {
!                                               $my_opt .= '<option value="' . 
$key . '">'
!                                                       . $value . '</option>';
!                                       }
!                               }
!                       }
!                       return $my_opt;
!               }
        }
  ?>

Index: class.uifields.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uifields.inc.php,v
retrieving revision 1.3.2.3.2.3
retrieving revision 1.3.2.3.2.4
diff -C2 -r1.3.2.3.2.3 -r1.3.2.3.2.4

Index: class.uivcard.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uivcard.inc.php,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.1.2.1
diff -C2 -r1.5.2.1 -r1.5.2.1.2.1

Index: functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/functions.inc.php,v
retrieving revision 1.101.2.1
retrieving revision 1.101.2.1.2.1
diff -C2 -r1.101.2.1 -r1.101.2.1.2.1

Index: hook_admin.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_admin.inc.php,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.2.2.1
diff -C2 -r1.9.2.2 -r1.9.2.2.2.1
*** hook_admin.inc.php  11 Jul 2002 00:27:39 -0000      1.9.2.2
--- hook_admin.inc.php  8 Sep 2003 13:26:37 -0000       1.9.2.2.2.1
***************
*** 19,25 ****
                'Site Configuration' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' 
. $appname),
                'Edit custom fields' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.index'),
!               'Global Categories' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=addressbook')
        );
        //Do not modify below this line
        display_section($appname,$title,$file);
! ?>
\ No newline at end of file
--- 19,29 ----
                'Site Configuration' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' 
. $appname),
                'Edit custom fields' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.index'),
!               'Global Categories' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=addressbook'),
!               'Communication Types Manager' =>  
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_manager.view&catalog=comm_type'),
!               'Communication Descriptions Manager' =>  
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_manager.view&catalog=comm_descr'),
!               'Location Manager' =>  
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_manager.view&catalog=addr_types'),
!               'Notes Types Manager' =>  
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_manager.view&catalog=note_types')
        );
        //Do not modify below this line
        display_section($appname,$title,$file);
! ?>

Index: hook_config_validate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_config_validate.inc.php,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -C2 -r1.1 -r1.1.6.1

Index: hook_deleteaccount.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_deleteaccount.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -C2 -r1.5 -r1.5.6.1

Index: hook_home.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_home.inc.php,v
retrieving revision 1.13.2.5
retrieving revision 1.13.2.5.2.1
diff -C2 -r1.13.2.5 -r1.13.2.5.2.1

Index: hook_manual.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/Attic/hook_manual.inc.php,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -C2 -r1.4 -r1.4.8.1

Index: hook_notifywindow.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_notifywindow.inc.php,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.1.2.1
diff -C2 -r1.5.2.1 -r1.5.2.1.2.1

Index: hook_preferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/hook_preferences.inc.php,v
retrieving revision 1.21
retrieving revision 1.21.6.1
diff -C2 -r1.21 -r1.21.6.1
*** hook_preferences.inc.php    12 Jan 2002 04:15:15 -0000      1.21
--- hook_preferences.inc.php    8 Sep 2003 13:26:37 -0000       1.21.6.1
***************
*** 16,20 ****
        $title = $appname;
        $file = Array(
!               'Preferences'   => 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.preferences'),
                'Grant Access'  => 
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
                'Edit Categories' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app='.$appname
 . '&cats_level=True&global_cats=True')
--- 16,20 ----
        $title = $appname;
        $file = Array(
!               'Preferences'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook_prefs.index')),
                'Grant Access'  => 
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
                'Edit Categories' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app='.$appname
 . '&cats_level=True&global_cats=True')





reply via email to

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