phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] addressbook/inc class.uifields.inc.php, 1.3.2.3.2.4,


From: Jonathan Rivera <address@hidden>
Subject: [Phpgroupware-cvs] addressbook/inc class.uifields.inc.php, 1.3.2.3.2.4, 1.3.2.3.2.5 class.uiaddressbook.inc.php, 1.36.2.15.2.30, 1.36.2.15.2.31 class.soaddressbook.inc.php, 1.14.2.3.2.20, 1.14.2.3.2.21
Date: Wed, 12 Nov 2003 18:42:06 +0000

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

Modified Files:
      Tag: Version-0_9_16-branch
        class.uifields.inc.php class.uiaddressbook.inc.php 
        class.soaddressbook.inc.php 
Log Message:
bugfix #6241, support for custom fields


Index: class.uifields.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uifields.inc.php,v
retrieving revision 1.3.2.3.2.4
retrieving revision 1.3.2.3.2.5
diff -C2 -d -r1.3.2.3.2.4 -r1.3.2.3.2.5
*** class.uifields.inc.php      8 Sep 2003 13:26:37 -0000       1.3.2.3.2.4
--- class.uifields.inc.php      12 Nov 2003 18:42:04 -0000      1.3.2.3.2.5
***************
*** 100,103 ****
--- 100,104 ----
                                $field = $fields[$i]['name'];
                                $title = $fields[$i]['title'];
+                               $apply = $fields[$i]['apply'];
  
                                
$GLOBALS['phpgw']->template->set_var('cfield',$title);
***************
*** 106,109 ****
--- 107,111 ----
                                        'menuaction' => 
'addressbook.uifields.edit',
                                        'field'      => urlencode($field),
+                                       'apply_for'  => urlencode($apply),
                                        'start'      => $start,
                                        'query'      => $query,
***************
*** 137,140 ****
--- 139,143 ----
                        $field      = 
stripslashes($GLOBALS['HTTP_POST_VARS']['field']);
                        $field_name = 
stripslashes($GLOBALS['HTTP_POST_VARS']['field_name']);
+                       $apply_for  = 
stripslashes($GLOBALS['HTTP_POST_VARS']['apply_for']);
                        $start      = $GLOBALS['HTTP_POST_VARS']['start'];
                        $query      = $GLOBALS['HTTP_POST_VARS']['query'];
***************
*** 145,149 ****
                        
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
                        
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
! 
                        if($submit)
                        {
--- 148,152 ----
                        
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
                        
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
!                       
                        if($submit)
                        {
***************
*** 163,167 ****
                                if(!$error)
                                {
!                                       
$this->save_custom_field($field,$field_name);
                                }
                        }
--- 166,170 ----
                                if(!$error)
                                {
!                                       
$this->save_custom_field($field,$field_name,$apply_for);
                                }
                        }
***************
*** 190,193 ****
--- 193,204 ----
                        
$GLOBALS['phpgw']->template->set_var('lang_name',lang('Field name'));
  
+                       
$GLOBALS['phpgw']->template->set_var('lang_apply_for',lang('Apply for'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_persons',lang('Persons'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_orgs',lang('Organizations'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_both',lang('Both'));
+                       
$GLOBALS['phpgw']->template->set_var('checked_both','checked');
+                       
$GLOBALS['phpgw']->template->set_var('checked_person','');
+                       $GLOBALS['phpgw']->template->set_var('checked_org','');
+ 
                        
$GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
                        
$GLOBALS['phpgw']->template->set_var('lang_reset',lang('Clear Form'));
***************
*** 213,217 ****
  
                        $field      = 
stripslashes($GLOBALS['HTTP_POST_VARS']['field'] ? 
$GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field']);
!                       $field_name = 
stripslashes($GLOBALS['HTTP_POST_VARS']['field_name']);
                        $start      = $GLOBALS['HTTP_POST_VARS']['start'] ? 
$GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
                        $query      = $GLOBALS['HTTP_POST_VARS']['query'] ? 
$GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
--- 224,229 ----
  
                        $field      = 
stripslashes($GLOBALS['HTTP_POST_VARS']['field'] ? 
$GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field']);
!                       $field_name = stripslashes(get_var('field_name'));
!                       $apply_for  = stripslashes(get_var('apply_for'));
                        $start      = $GLOBALS['HTTP_POST_VARS']['start'] ? 
$GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
                        $query      = $GLOBALS['HTTP_POST_VARS']['query'] ? 
$GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
***************
*** 243,247 ****
                                if(!$error)
                                {
!                                       
$this->save_custom_field($field,$field_name);
                                }
                        }
--- 255,259 ----
                                if(!$error)
                                {
!                                       
$this->save_custom_field($field,$field_name,$apply_for);
                                }
                        }
***************
*** 282,285 ****
--- 294,319 ----
                        
$GLOBALS['phpgw']->template->set_var('lang_name',lang('Field name'));
  
+                       
$GLOBALS['phpgw']->template->set_var('lang_apply_for',lang('Apply for'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_persons',lang('Persons'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_orgs',lang('Organizations'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_both',lang('Both'));
+ 
+                       $GLOBALS['phpgw']->template->set_var('checked_both','');
+                       
$GLOBALS['phpgw']->template->set_var('checked_person','');
+                       $GLOBALS['phpgw']->template->set_var('checked_org','');
+ 
+                       if($apply_for=='person')
+                       {
+                               
$GLOBALS['phpgw']->template->set_var('checked_person','checked');
+                       }
+                       elseif($apply_for=='org')
+                       {
+                               
$GLOBALS['phpgw']->template->set_var('checked_org','checked');
+                       }
+                       elseif($apply_for=='both')
+                       {
+                               
$GLOBALS['phpgw']->template->set_var('checked_both','checked');
+                       }
+ 
                        
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
                        
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
***************
*** 355,359 ****
                }
  
!               function read_custom_fields($start=0,$limit=5,$query='')
                {
                        $i = 0;
--- 389,393 ----
                }
  
!               function 
read_custom_fields($start=0,$limit=5,$query='',$sort='',$apply='both')
                {
                        $i = 0;
***************
*** 362,374 ****
                        $this->config->read_repository();
  
!                       while(list($name,$descr) = 
@each($this->config->config_data['custom_fields']))
                        {
!                               /*
!                               if($start < $i)
!                               {
!                                       continue;
!                               }
!                               */
  
                                $test = @strtolower($name);
                                //if($query && 
!strstr($test,strtolower($query)))
--- 396,421 ----
                        $this->config->read_repository();
  
!                       if($apply=='person')
                        {
!                               $this->per_custom_fields = 
$this->config->config_data['custom_fields'];
!                               $this->org_custom_fields = array();
!                               $all_custom_fields = 
$this->config->config_data['custom_fields'];
!                       }
!                       elseif($apply=='org')
!                       {
!                               $this->per_custom_fields = array();
!                               $this->org_custom_fields = 
$this->config->config_data['custom_org_fields'];
!                               $all_custom_fields = 
$this->config->config_data['custom_org_fields'];
!                       }
!                       elseif($apply=='both')
!                       {
!                               $this->per_custom_fields = 
$this->config->config_data['custom_fields'];
!                               $this->org_custom_fields = 
$this->config->config_data['custom_org_fields'];
!                               $all_custom_fields = 
array_merge($this->per_custom_fields,$this->org_custom_fields);
!                       }
  
+                       //while(list($name,$descr) = 
@each($this->config->config_data['custom_fields']))
+                       while(list($name,$descr) = @each($all_custom_fields))
+                       {
                                $test = @strtolower($name);
                                //if($query && 
!strstr($test,strtolower($query)))
***************
*** 381,384 ****
--- 428,432 ----
                                        $fields[$i]['title'] = $descr;
                                        $fields[$i]['id'] = $i;
+                                       $fields[$i]['apply'] = 
$this->get_apply($name);
  
                                        /*
***************
*** 401,427 ****
                        }
                        @reset($fields);
! 
                        return $fields;
                }
  
!               function save_custom_field($old='',$new='')
                {
!                       $this->config->read_repository();
! 
!                       
if(!is_array($this->config->config_data['custom_fields']))
                        {
!                               $this->config->config_data['custom_fields'] = 
array();
                        }
! 
!                       if($old)
                        {
!                               
unset($this->config->config_data['custom_fields'][$old]);
                        }
!                       if($new)
                        {
!                               $tmp = strtolower(ereg_replace(' ','_',$new));
!                               
$this->config->config_data['custom_fields'][$tmp] = $new;
                        }
  
                        $this->config->save_repository();
                }
--- 449,543 ----
                        }
                        @reset($fields);
! //                    var_dump($fields);
                        return $fields;
                }
  
!               function get_apply($key)
                {
!                       if(array_key_exists($key, $this->per_custom_fields) && 
array_key_exists($key, $this->org_custom_fields))
                        {
!                               return 'both';
                        }
!                       elseif(array_key_exists($key, $this->per_custom_fields))
                        {
!                               return 'person';
                        }
!                       elseif(array_key_exists($key, $this->org_custom_fields))
                        {
!                               return 'org';
                        }
+               }
  
+               function save_custom_field($old='',$new='',$apply_for='')
+               {
+                       $this->config->read_repository();
+                       
+                       switch($apply_for)
+                       {
+                       case 'person':
+                               
if(!is_array($this->config->config_data['custom_fields']))
+                               {
+                                       
$this->config->config_data['custom_fields'] = array();
+                               }
+                               
+                               if($old)
+                               {
+                                       
unset($this->config->config_data['custom_fields'][$old]);
+                                       
unset($this->config->config_data['custom_org_fields'][$old]);
+                               }
+                               if($new)
+                               {
+                                       $tmp = strtolower(ereg_replace(' 
','_',$new));
+                                       
$this->config->config_data['custom_fields'][$tmp] = $new;
+                               }
+                               break;
+                       case 'org':
+                               
if(!is_array($this->config->config_data['custom_org_fields']))
+                               {
+                                       
$this->config->config_data['custom_org_fields'] = array();
+                               }
+                               
+                               if($old)
+                               {
+                                       
unset($this->config->config_data['custom_org_fields'][$old]);
+                                       
unset($this->config->config_data['custom_fields'][$old]);
+                               }
+                               if($new)
+                               {
+                                       $tmp = strtolower(ereg_replace(' 
','_',$new));
+                                       
$this->config->config_data['custom_org_fields'][$tmp] = $new;
+                               }
+                               break;
+                       default:
+                               
if(!is_array($this->config->config_data['custom_fields']))
+                               {
+                                       
$this->config->config_data['custom_fields'] = array();
+                               }
+                               
+                               if($old)
+                               {
+                                       
unset($this->config->config_data['custom_fields'][$old]);
+                               }
+                               if($new)
+                               {
+                                       $tmp = strtolower(ereg_replace(' 
','_',$new));
+                                       
$this->config->config_data['custom_fields'][$tmp] = $new;
+                               }
+                               
if(!is_array($this->config->config_data['custom_org_fields']))
+                               {
+                                       
$this->config->config_data['custom_org_fields'] = array();
+                               }
+                               
+                               if($old)
+                               {
+                                       
unset($this->config->config_data['custom_org_fields'][$old]);
+                               }
+                               if($new)
+                               {
+                                       $tmp = strtolower(ereg_replace(' 
','_',$new));
+                                       
$this->config->config_data['custom_org_fields'][$tmp] = $new;
+                               }
+                               break;
+                       }
                        $this->config->save_repository();
                }

Index: class.soaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.soaddressbook.inc.php,v
retrieving revision 1.14.2.3.2.20
retrieving revision 1.14.2.3.2.21
diff -C2 -d -r1.14.2.3.2.20 -r1.14.2.3.2.21
*** class.soaddressbook.inc.php 3 Nov 2003 20:32:47 -0000       1.14.2.3.2.20
--- class.soaddressbook.inc.php 12 Nov 2003 18:42:04 -0000      1.14.2.3.2.21
***************
*** 24,27 ****
--- 24,28 ----
                function soaddressbook($useacl=True)
                {
+                       $this->custom_fields = 
CreateObject('addressbook.uifields');
                        $this->contacts = CreateObject('phpgwapi.contacts');
  
***************
*** 238,242 ****
                //used
                function add_person($fields)
!               {
                        $principal = array_merge($fields['tab_person_data'], 
$fields['tab_extra']);
                        
--- 239,243 ----
                //used
                function add_person($fields)
!               {                       
                        $principal = array_merge($fields['tab_person_data'], 
$fields['tab_extra']);
                        
***************
*** 261,265 ****
                                $addr = $fields['addr_data'];
                        }
!                       
                        $others = $fields['others_data'];
                        
--- 262,273 ----
                                $addr = $fields['addr_data'];
                        }
! 
!                       if(is_array($fields['others_data']))
!                       {
!                               foreach($fields['others_data'] as $key => $data)
!                               {
!                                       
$fields['others_data'][$key]['other_value'] = 
$fields['tab_others']['other_value'][$key];
!                               }
!                       }
                        $others = $fields['others_data'];
                        
***************
*** 305,308 ****
--- 313,323 ----
                        }
                        
+                       if(is_array($fields['others_data']))
+                       {
+                               foreach($fields['others_data'] as $key => $data)
+                               {
+                                       
$fields['others_data'][$key]['other_value'] = 
$fields['tab_others']['other_value'][$key];
+                               }
+                       }
                        $others = $fields['others_data'];
                        
***************
*** 394,399 ****
                                              
$fields['tab_others']['other_value'], $person_id);
                        
!                       $this->execute_queries($queries);
! 
                        /* Update the first and last name in accounts */
                        $account_id = 
$this->contacts->get_account_id($person_id);
--- 409,414 ----
                                              
$fields['tab_others']['other_value'], $person_id);
                        
!                       $this->execute_queries($queries);
!                       
                        /* Update the first and last name in accounts */
                        $account_id = 
$this->contacts->get_account_id($person_id);
***************
*** 544,548 ****
                                $edit_others = array();
                        }
! 
                        foreach($data as $key => $value)
                        {
--- 559,566 ----
                                $edit_others = array();
                        }
!                       if(!is_array($add_others))
!                       {
!                               $add_others = array();
!                       }
                        foreach($data as $key => $value)
                        {
***************
*** 554,558 ****
--- 572,583 ----
                                }
                        }
+ 
+                       foreach($add_others as $key => $fields)
+                       {
+                               $fields['other_value'] = $data[$key];
+                               $this->add_others($fields, $contact_id, 
PHPGW_SQL_RUN_SQL);
+                       }
                        
+                       $this->unlock();
                }
  

Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.36.2.15.2.30
retrieving revision 1.36.2.15.2.31
diff -C2 -d -r1.36.2.15.2.30 -r1.36.2.15.2.31
*** class.uiaddressbook.inc.php 4 Nov 2003 00:17:37 -0000       1.36.2.15.2.30
--- class.uiaddressbook.inc.php 12 Nov 2003 18:42:04 -0000      1.36.2.15.2.31
***************
*** 62,66 ****
                var $tab_address = 'Address';
                var $tab_others = 'Others';
!               var $tab_extra = 'Extra';
  
                //Public functions
--- 62,66 ----
                var $tab_address = 'Address';
                var $tab_others = 'Others';
!               var $tab_extra = 'More data';
  
                //Public functions
***************
*** 92,104 ****
                function uiaddressbook()
                {
!                       $GLOBALS['phpgw']->country    = 
CreateObject('phpgwapi.country');
!                       $GLOBALS['phpgw']->browser    = 
CreateObject('phpgwapi.browser');
!                       $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
!                       $this->fields = CreateObject('addressbook.uifields');
!                       $this->bo       = 
CreateObject('addressbook.boaddressbook');
!                       $this->template = &$GLOBALS['phpgw']->template;
!                       $this->cat      = CreateObject('phpgwapi.categories');
!                       $this->company  = 
CreateObject('phpgwapi.categories','addressbook_company');
!                       $this->prefs    = 
$GLOBALS['phpgw_info']['user']['preferences']['addressbook'];
  
                        $this->contact_type = $this->bo->contact_type;
--- 92,104 ----
                function uiaddressbook()
                {
!                       $GLOBALS['phpgw']->country      = 
CreateObject('phpgwapi.country');
!                       $GLOBALS['phpgw']->browser      = 
CreateObject('phpgwapi.browser');
!                       $this->nextmatchs               = 
CreateObject('phpgwapi.nextmatchs');
!                       $this->custom_fields            = 
CreateObject('addressbook.uifields');
!                       $this->bo                       = 
CreateObject('addressbook.boaddressbook');
!                       $this->template                 = 
&$GLOBALS['phpgw']->template;
!                       $this->cat                      = 
CreateObject('phpgwapi.categories');
!                       $this->company                  = 
CreateObject('phpgwapi.categories','addressbook_company');
!                       $this->prefs                    = 
$GLOBALS['phpgw_info']['user']['preferences']['addressbook'];
  
                        $this->contact_type = $this->bo->contact_type;
***************
*** 454,464 ****
                                                                . 
'&ab_id='.$entry['contact_id']) . '">' . lang('Edit') . '</a>');
                                }                               
- //                            if 
($this->bo->so->contacts->check_perms($this->bo->grants[$myowner],PHPGW_ACL_EDIT)
 || 
- //                                $myowner == 
$GLOBALS['phpgw_info']['user']['account_id'])
- //                            {
- //                                    $this->template->set_var('row_edit','<a 
href="' . $GLOBALS['phpgw']->link('/index.php',
- //                                                            
'menuaction=addressbook.uiaddressbook.' . $this->edit_mode
- //                                                            . 
'&ab_id='.$entry['contact_id']) . '">' . lang('Edit') . '</a>');
- //                            }
                                else
                                {
--- 454,457 ----
***************
*** 469,473 ****
                                $this->template->parse('rows','row',True);
                                $this->template->pparse('out','row');
-                               //reset($all_cols_to_display);
                        }
                        
--- 462,465 ----
***************
*** 661,672 ****
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }
-                       
- //                    $this->owner = 
$this->entry['owner']?$this->entry['owner']:$this->owner;
- //                    if 
(!$this->bo->so->contacts->check_perms($this->bo->grants[$this->owner],PHPGW_ACL_EDIT)
 && 
- //                         ($this->owner != 
$GLOBALS['phpgw_info']['user']['account_id']) )
- //                    {
- //                            Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php', $this->form_index));
- //                            $GLOBALS['phpgw']->common->phpgw_exit();
- //                    }
  
                        //start to draw the add window
--- 653,656 ----
***************
*** 881,891 ****
                        }
  
- //                    if ( 
!$this->bo->so->contacts->check_perms($this->bo->grants[$this->owner],PHPGW_ACL_EDIT)
 && 
- //                         ($this->owner != 
$GLOBALS['phpgw_info']['user']['account_id']) )
- //                    {
- //                            Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php', $this->form_index));
- //                            $GLOBALS['phpgw']->common->phpgw_exit();
- //                    }
- 
                        //start to draw the add window
                        $GLOBALS['phpgw']->common->phpgw_header();
--- 865,868 ----
***************
*** 957,962 ****
                        $fields['owner'] = 
$fields['owner']?$fields['owner']:$this->owner;
                        if ($this->bo->check_delete($this->contact_id))
- //                    if (($this->bo->so->grants[$fields['owner']] & 
PHPGW_ACL_DELETE) || 
- //                        $fields['owner'] == 
$GLOBALS['phpgw_info']['user']['account_id'])
                        {
                                $delete = '<input type="submit" name="delete" 
value="' . lang('Delete') . '">';
--- 934,937 ----
***************
*** 1135,1138 ****
--- 1110,1114 ----
                        case $this->tab_others:
                                return $this->others_form($fields);
+                               //return $this->custom_fields_form($fields);
                                break;
                        default:
***************
*** 1390,1395 ****
                                                             'action'=> 
'other_del_row',
                                                             'extra' => 
'&owner='.$this->owner.'&ab_id='.$this->contact_id.'&record_name='.$this->record_name));
!                       //$this->array_data = $fields['others'];
                        $this->array_data = 
$this->read_tab_session('others_data');
                        if(is_array($fields['other_value']))
                        {
--- 1366,1380 ----
                                                             'action'=> 
'other_del_row',
                                                             'extra' => 
'&owner='.$this->owner.'&ab_id='.$this->contact_id.'&record_name='.$this->record_name));
!                       //$this->array_data = $fields['others'];                
        
!                       $this->array_data = 
$this->read_tab_session('others_data');
!                       $custom_fields = $this->get_custom_fields();
!                       foreach($custom_fields as $data)
!                       {
!                               
$this->entry['tmp_data']['others']['other_name'] = $data['name'];
!                               
$this->entry['tmp_data']['others']['other_value'] = '';
!                               $this->add_general('others');
!                       }
                        $this->array_data = 
$this->read_tab_session('others_data');
+ 
                        if(is_array($fields['other_value']))
                        {
***************
*** 1399,1404 ****
                                }
                        }
!                       
                        //draw the detail form
                        $this->template->set_var('detail_fields', 
$this->get_detail_form('other', 
                                                        array('Description', 
'Value','Delete'),
--- 1384,1390 ----
                                }
                        }
! 
                        //draw the detail form
+                       //$this->template->set_var('custom_fields', 
$this->custom_fields_form($fields));
                        $this->template->set_var('detail_fields', 
$this->get_detail_form('other', 
                                                        array('Description', 
'Value','Delete'),
***************
*** 1409,1412 ****
--- 1395,1411 ----
                }
  
+               function get_custom_fields()
+               {
+                       if($this->section == $this->tab_main_persons)
+                       {
+                               $custom_fields = 
$this->custom_fields->read_custom_fields(0,0,'','','person');
+                       }
+                       elseif($this->section == $this->tab_main_organizations)
+                       {
+                               $custom_fields = 
$this->custom_fields->read_custom_fields(0,0,'','','org');
+                       }
+                       return $custom_fields;
+               }
+               
                /**
                * This function draw the extra person data tab screen
***************
*** 1912,1917 ****
                                                $entry[$value['key_other_id']] 
= $value;
                                        }
-                                       $this->save_tab_session('others_data', 
$entry);
                                        
$GLOBALS['phpgw']->session->appsession('old_others','addressbook',$entry);
                                        $load_vars['others_data'] = 'cache';
                                }
--- 1911,1916 ----
                                                $entry[$value['key_other_id']] 
= $value;
                                        }
                                        
$GLOBALS['phpgw']->session->appsession('old_others','addressbook',$entry);
+                                       $this->save_tab_session('others_data', 
$entry);
                                        $load_vars['others_data'] = 'cache';
                                }
***************
*** 1920,1923 ****
--- 1919,1923 ----
                                        $entry = 
$GLOBALS['phpgw']->session->appsession('others_data','addressbook');
                                }
+                               //$this->save_tab_session('others_data', 
$entry);
                                break;
                        case 'addr_data':
***************
*** 2408,2418 ****
                        }
                        //var_export($add_data);
                        
-                       $this->entry_data[$key_id] = $add_data;
                        //var_export($this->entry_data);
                        $this->save_tab_session($tab_data, $this->entry_data);
  
                        //if is edit mode make a query and save this in stock 
which will be executed in save
!                       if($this->mode == 'edit')
                        {
                                if($get_query == 'get_insert_'.$tab_section)
--- 2408,2442 ----
                        }
                        //var_export($add_data);
+ 
+                       if($tab_section=='others')
+                       {
+                               $exist_name = False;
+                               if(!is_array($this->entry_data))
+                               {
+                                       $this->entry_data = array();
+                               }
+                               foreach($this->entry_data as $key => $data)
+                               {
+                                       if($data['other_name'] == 
$add_data['other_name'])
+                                       {
+                                               $exist_name = True;
+                                       }
+                               }
+                               if($exist_name==False)
+                               {
+                                       $this->entry_data[$key_id] = $add_data;
+                               }
+                       }
+                       else
+                       {
+                               $exist_name==False;
+                               $this->entry_data[$key_id] = $add_data;
+                       }
                        
                        //var_export($this->entry_data);
                        $this->save_tab_session($tab_data, $this->entry_data);
  
                        //if is edit mode make a query and save this in stock 
which will be executed in save
!                       if($this->mode == 'edit' && $exist_name==False && 
$tab_section!='others')
                        {
                                if($get_query == 'get_insert_'.$tab_section)
***************
*** 2627,2638 ****
                        }
  
- //                    if ( 
!$this->bo->so->contacts->check_perms($this->bo->grants[$owner],PHPGW_ACL_READ) 
&& 
- //                         ($owner != 
$GLOBALS['phpgw_info']['user']['account_id']) )
- //                    {
- //                            Header('Location: '
- //                                   . $GLOBALS['phpgw']->link('/index.php',
- //                                                             
'menuaction=addressbook.uiaddressbook.index&section='.$contact_type));
- //                    }
- 
                        foreach($cats as $key => $cat_id)
                        {
--- 2651,2654 ----
***************
*** 2727,2733 ****
                        if($this->bo->check_edit($contact_id))
                        {                               
- //                    if (($this->bo->so->contacts->grants[$owner] & 
PHPGW_ACL_EDIT) || 
- //                        ($owner == 
$GLOBALS['phpgw_info']['user']['account_id']))
- //                    {
                                
$this->template->set_var('edit_button',$this->html_1button_form('edit','Edit',
                                        $GLOBALS['phpgw']->link('/index.php',
--- 2743,2746 ----





reply via email to

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