Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.36.2.15.2.52
diff -c -r1.36.2.15.2.52 class.uiaddressbook.inc.php
*** class.uiaddressbook.inc.php	9 Mar 2004 16:35:30 -0000	1.36.2.15.2.52
--- class.uiaddressbook.inc.php	14 May 2004 15:54:00 -0000
***************
*** 12,18 ****
    *  option) any later version.                                              *
    \**************************************************************************/
  
!   /* $Id: class.uiaddressbook.inc.php,v 1.36.2.15.2.52 2004/03/09 16:35:30 alexbsa Exp $ */
  
  
  	class uiaddressbook
--- 12,18 ----
    *  option) any later version.                                              *
    \**************************************************************************/
  
!   /* $Id: class.uiaddressbook.inc.php,v 1.36.2.15.2.55 2004/05/08 04:43:27 jarg Exp $ */
  
  
  	class uiaddressbook
***************
*** 252,261 ****
  						'per_department'=>'department',
  						'per_title'=> 'title',
  						'addr_add1'=>'address1',
! 						'addr_city'=>'city');
  				}
  				$this->edit_mode = 'edit_person'; 
  				$this->view_mode = 'view_person';
  				$count_function = 'get_count_persons';
  				$get_data_function = 'get_persons';
  
--- 252,264 ----
  						'per_department'=>'department',
  						'per_title'=> 'title',
  						'addr_add1'=>'address1',
! 						'addr_city'=>'city',
! 						'org_name' => 'org_name');
  				}
  				$this->edit_mode = 'edit_person'; 
  				$this->view_mode = 'view_person';
+ $columns_to_display['org_name'] = 1;
+ //jecinc - above line should be deleted when org_name is available for selection in user prefs
  				$count_function = 'get_count_persons';
  				$get_data_function = 'get_persons';
  
***************
*** 302,308 ****
  
  			if(!in_array($this->order, $fields))
  			{
! 				$this->order = 'contact_id';
  			}
  			
  			$fields_comms = array_keys($comms_array);
--- 305,313 ----
  
  			if(!in_array($this->order, $fields))
  			{
! 				$this->order = (($this->section == $this->tab_main_organizations) 
! 						? 'org_name' 
! 						: 'last_name');
  			}
  			
  			$fields_comms = array_keys($comms_array);
***************
*** 411,417 ****
   			$this->template->set_var('th_font',$GLOBALS['phpgw_info']['theme']['font']);
  			$this->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
  			$this->template->set_var('lang_add',lang('Add'));
- 
  			$this->template->set_var('lang_cat_cont',lang('Categorize'));
  			$this->template->set_var('cat_cont_url', $GLOBALS['phpgw']->link('/index.php',
  											 'menuaction=addressbook.uicategorize_contacts.index'));
--- 416,421 ----
***************
*** 467,473 ****
  				{
  					$ref = $data='';
  					$coldata = $entry[$column[key]];
! 					if(in_array($column[key], $fields_comms))
  					{
  						$data = $this->get_comm_value($myid, $column[key]);
  						$data = htmlentities($data);
--- 471,497 ----
  				{
  					$ref = $data='';
  					$coldata = $entry[$column[key]];
! 					// jecinc marker
! 					if( $column[key]=='org_name' ) 
! 					{
! 						if($get_data_function == 'get_persons')
! 						{
! 							$org_data = $this->bo->get_orgs_person_data($myid);
! 							$ref = '<a href="' . $GLOBALS['phpgw']->link("/index.php",
! 									"menuaction=addressbook.uiaddressbook.view_org") . 
! 									"&ab_id=" . $org_data[0]['my_org_id'] . '">' ;
! 						}
! 						else
! 						{
! 							$ref = '<a href="' . $GLOBALS['phpgw']->link("/index.php",
! 				                	                "menuaction=addressbook.uiaddressbook.view_org") .
! 				                        	        "&ab_id=" . $myid . '">' ;
! 						}
! 						$data = 		htmlentities($coldata) . '</a>';
! 					}
! 					elseif(in_array($column[key], $fields_comms))
! 					// jecinc marker
! 					// if(in_array($column[key], $fields_comms))
  					{
  						$data = $this->get_comm_value($myid, $column[key]);
  						$data = htmlentities($data);
***************
*** 582,588 ****
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session($this->entry['old_tab'], $this->entry);
  			
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
--- 606,612 ----
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
  			
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
***************
*** 659,665 ****
  			$this->managment_functions($this->action);
  			
  			//save the old tab data
! 			$this->save_tab_session($this->entry['old_tab'], $this->entry);
  
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
--- 683,689 ----
  			$this->managment_functions($this->action);
  			
  			//save the old tab data
! 			$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
  
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
***************
*** 796,802 ****
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session($this->entry['old_tab'], $this->entry);
  			
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
--- 820,826 ----
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
  			
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
***************
*** 870,876 ****
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session($this->entry['old_tab'], $this->entry);
  
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
--- 894,900 ----
  			$this->managment_functions($this->action);
  
  			//save the old tab data
! 			$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
  
  			//if not exist tab selected use as defaul person_data
  			if(!$this->tab)
***************
*** 1262,1268 ****
  		{
  			$this->form_start();
  
! 			$this->template->set_var('lang_general_data', lang('Communication Data for ' . $this->record_name));
  
  			$types_data = array('data1' => array('type'  => 'data',
  							     'field' => 'comm_description'),
--- 1286,1292 ----
  		{
  			$this->form_start();
  
! 			$this->template->set_var('lang_general_data', lang('Communication Data for').' '.$this->record_name);
  
  			$types_data = array('data1' => array('type'  => 'data',
  							     'field' => 'comm_description'),
***************
*** 1308,1314 ****
  			
  			$this->form_start();
  			
! 			$this->template->set_var('lang_general_data', lang('Address Data for ' . $this->record_name));
  
  			$this->template->set_var('current_id_name', $key_addr_id_name);
  			$this->template->set_var('current_id', $key_addr_id);
--- 1332,1338 ----
  			
  			$this->form_start();
  			
! 			$this->template->set_var('lang_general_data', lang('Address Data for').' '.$this->record_name);
  
  			$this->template->set_var('current_id_name', $key_addr_id_name);
  			$this->template->set_var('current_id', $key_addr_id);
***************
*** 1389,1395 ****
  			$this->form_start();
  
  			//set values
! 			$this->template->set_var('lang_general_data', lang('Other Data for ' . $this->record_name));
  
  			$this->template->set_var('current_id_name', $key_other_id_name);
  			$this->template->set_var('current_id', $key_other_id);
--- 1413,1419 ----
  			$this->form_start();
  
  			//set values
! 			$this->template->set_var('lang_general_data', lang('Other Data for').' '.$this->record_name);
  
  			$this->template->set_var('current_id_name', $key_other_id_name);
  			$this->template->set_var('current_id', $key_other_id);
***************
*** 1472,1478 ****
  				. $fields['per_pubkey'] . '">';
  			
  			$this->form_start();
! 			$this->template->set_var('lang_general_data', lang('Person extra fields for ' . $this->record_name));
  			
  			$this->set_form_fields(array(1 => array('Suffix', 'entry[per_suffix]', $fields['per_suffix']),
  						     2 => array('Initials', 'entry[per_initials]', $fields['per_initials']),
--- 1496,1502 ----
  				. $fields['per_pubkey'] . '">';
  			
  			$this->form_start();
! 			$this->template->set_var('lang_general_data', lang('Person extra fields for').' '.$this->record_name);
  			
  			$this->set_form_fields(array(1 => array('Suffix', 'entry[per_suffix]', $fields['per_suffix']),
  						     2 => array('Initials', 'entry[per_initials]', $fields['per_initials']),
***************
*** 1505,1510 ****
--- 1529,1535 ----
  			{
  				$owner_title = 'Org';
  				$owner_value = $this->record_name;
+ 				
  			}
  			
  			$all_data = '<select multiple size="5" name="' 
***************
*** 1525,1543 ****
  			$this->template->set_file(array('person_action'	=> 'many_actions.tpl'));
  			$this->template->set_block('person_action', 'many_actions', 'many_actions');
  
- 			$this->template->set_var('lang_general_data', lang($option.' Data for '.$this->record_name));
- 
- 			$this->template->set_var('lang_person', lang($owner_title));
- 			$this->template->set_var('person', $owner_value);
- 
  			if ($option==$this->tab_orgs)
  			{
! 				$this->template->set_var('lang_defaul', lang('Defaul ' . $option . ':'));
  				$this->template->set_var('options', $defaul_data_cbo);
  			}
  
! 			$this->template->set_var('lang_title_left', lang('All ' . $option));
! 			$this->template->set_var('lang_title_rigth', lang('Current ' . $option));
  
  			$this->template->set_var('options_left', $all_data);
  			$this->template->set_var('options_rigth', $my_data);
--- 1550,1577 ----
  			$this->template->set_file(array('person_action'	=> 'many_actions.tpl'));
  			$this->template->set_block('person_action', 'many_actions', 'many_actions');
  
  			if ($option==$this->tab_orgs)
  			{
! 				$option_label = 'Organizations';
! 				$this->template->set_var('lang_defaul', lang('Default ' . $option_label) . ':');
  				$this->template->set_var('options', $defaul_data_cbo);
  			}
+ 			elseif($option==$this->tab_persons)
+ 			{
+ 				$option_label = 'Persons';
+ 			}
+ 			elseif($option==$this->tab_cats)
+ 			{
+ 				$option_label = 'Categories';
+ 			}
  
! 
! 			$this->template->set_var('lang_general_data', lang($option_label.' Data for').' '.$this->record_name);
! 			$this->template->set_var('lang_title_left', lang('All ' . $option_label));
! 			$this->template->set_var('person', $owner_value);
! 			
! 			$this->template->set_var('lang_person', lang($owner_title). ' ');
! 			$this->template->set_var('lang_title_rigth', lang('Current ' . $option_label));
  
  			$this->template->set_var('options_left', $all_data);
  			$this->template->set_var('options_rigth', $my_data);
***************
*** 1868,1874 ****
  				$this->firsttime = false;
  			}
  
! 			$this->tab = get_var('bname', array('post', 'get'));
  			$this->entry = get_var('entry', array('post','get'));
  
  			$this->contact_id = get_var('ab_id', array('post','get'));
--- 1902,1909 ----
  				$this->firsttime = false;
  			}
  
! 			$_tab = get_var('bname', array('post', 'get'));
! 			$this->tab = stripslashes($_tab);
  			$this->entry = get_var('entry', array('post','get'));
  
  			$this->contact_id = get_var('ab_id', array('post','get'));
***************
*** 2211,2217 ****
  					   'old_comm',
  					   'old_others');
  
! 			if($tabs_data[$tab])
  			{
  				$GLOBALS['phpgw']->session->appsession($tab, 'addressbook', NULL);
  			}
--- 2246,2252 ----
  					   'old_comm',
  					   'old_others');
  
! 			if($tab!='')
  			{
  				$GLOBALS['phpgw']->session->appsession($tab, 'addressbook', NULL);
  			}
***************
*** 2709,2715 ****
  						. $contact_id . '&confirm=true'));
                                  $this->template->set_var('lang_yes',lang('YES'));
                                  $this->template->pparse('out','delete');
-  				$GLOBALS['phpgw']->common->phpgw_exit();
                          }
                          else
                          {
--- 2744,2749 ----
***************
*** 2739,2744 ****
--- 2773,2779 ----
  					$datetime = CreateObject("phpgwapi.datetime");
  					$contacts['per_birthday'] = $datetime->convertDate($contacts['per_birthday'], $this->bo->bday_internformat, $userformat);
  				}
+ 			
  			}
  			elseif($contact_type == $this->tab_main_organizations)
  			{
***************
*** 3049,3055 ****
  		function get_persons($fields_to_search, $current_person)
  		{
  			$criteria = $this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
! 			$persons = $this->bo->get_persons($fields_to_search,'','','','','',$criteria);
  
  			if ($persons)
  			{
--- 3084,3090 ----
  		function get_persons($fields_to_search, $current_person)
  		{
  			$criteria = $this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
! 			$persons = $this->bo->get_persons($fields_to_search,'','','first_name','','',$criteria);
  
  			if ($persons)
  			{
***************
*** 3073,3079 ****
  		function get_orgs($fields_to_search, $current_orgs)
  		{
  			$criteria = $this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
! 			$orgs = $this->bo->get_orgs($fields_to_search,'','','','','',$criteria);
  			if ($orgs)
  			{
  				foreach ($orgs as $k => $v)
--- 3108,3114 ----
  		function get_orgs($fields_to_search, $current_orgs)
  		{
  			$criteria = $this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
! 			$orgs = $this->bo->get_orgs($fields_to_search,'','','org_name','','',$criteria);
  			if ($orgs)
  			{
  				foreach ($orgs as $k => $v)
