Author Topic: Global Address Book with additional fields and additional email addresses  (Read 36757 times)

Offline jonsjava

  • Jr. Member
  • **
  • Posts: 11
Global Address Book with additional fields and additional email addresses
« Reply #15 on: October 16, 2008, 05:11:19 PM »
Here's a mod to the script, to remove Global Address Book
I work for an ISP, and we don't want all users sharing their addresses, so I took what you had, and removed that feature.
<?php
# ----------------
#
# Database Additions for contact multiple emails
# Run in PhpMyAdmin on the database that holds the RC Contacts table. Change the table name rc_contacts to your contacts table name:
#
/*
 ALTER TABLE `contacts` ADD `firm` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `position` VARCHAR(50) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_tel` VARCHAR(30) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_fax` VARCHAR(30) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_address` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `w_tel` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_fax` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_address` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `notice` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `email2` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `email3` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `email4` VARCHAR(128) NOT NULL ;
 */
# -------------------------------------------------------------

#
# In file /program/include/rcube_contacts.inc
#
#Locate
var $table_cols = array('name''email''firstname''surname');
#
# and replace with
 
var $table_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
---------------------------------------------------------
#
# In file /program/include/main.inc
#
#Locate the following function
function rcmail_get_edit_field($col$value$attrib$type='text')
#
#and locate the following code
 
if ($type=='checkbox')
#
#and replace with the following code
 
if($col == "notice")
  {
        
$attrib['rows'] = "8";
        
$attrib['size'] = "40";
        
$attrib['cols'] = "40";
        
$input = new html_textarea($attrib);
        }
 elseif(
$col == "p_address" $col == "w_address")
  {
        
$attrib['rows'] = "4";
        
$attrib['size'] = "40";
        
$attrib['cols'] = "40";
        
$input = new html_textarea($attrib);
        }
 else if (
$type=='checkbox')
#
----------------------------------------------------------
#
# In File /program/localization/en_US/label.inc
#
#Locate // address boook
#
#and insert the following labels
$labels['firm']   = 'Organization';
$labels['position']   = 'Position';
$labels['p_tel']   = 'Telephone';
$labels['p_fax']   = 'Fax';
$labels['p_mob']   = 'Mobile';
$labels['p_address']   = 'Address';
$labels['w_tel']   = 'Business Telephone';
$labels['w_fax']   = 'Business Fax';
$labels['w_mob']   = 'Business Mobile';
$labels['w_address']   = 'Business Address';
$labels['notice']   = 'Notes';

$labels['email2']  = 'E-Mail 2';
$labels['email3']  = 'E-Mail 3';
$labels['email4']  = 'E-Mail 4';
#
# --------------------------------------------------------
#
# In file /program/steps/mail/compose.inc
#
#locate the following if statement
if ($result $CONTACTS->list_records())
#
#locate the following code
 
while ($sql_arr $result->iterate())
  if (
$sql_arr['email'])
           
$a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
#
#and insert the following code after that
  
if ($sql_arr['email2'])
   
$a_contacts[] = format_email_recipient($sql_arr['email2'], $sql_arr['name']);
  if (
$sql_arr['email3'])
   
$a_contacts[] = format_email_recipient($sql_arr['email3'], $sql_arr['name']);
  if (
$sql_arr['email4'])
   
$a_contacts[] = format_email_recipient($sql_arr['email4'], $sql_arr['name']);
#
# --------------------------------------------------------
#
# In file /program/steps/addressbook/edit.inc
#
#locate  // return the complete address edit form as table
#
#and the following code
 
$a_show_cols = array('name''firstname''surname''email');
#
#and replace with the following code
 
$a_show_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
# --------------------------------------------------------
#
# In file /program/steps/addressbook/show.inc
#
#Locate  // return the complete address record as table
#and the following code
 
$a_show_cols = array('name''firstname''surname''email');
#
#and replace with the following code
 
$data ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Data</b></legend><table>\n\n";
 
$contact ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Contact</b></legend><table>\n\n";

 
$a_show_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
#The old version of this had things like $out .=sprint#. I have found that all of this is unnecessary in the new version and also the closing table tags because of how the new
#handles the tags for this area.
#
#
#Locate the following code
  
if ($col=='email' && !empty($record[$col]))
#
#and replace with the following code
  
if (($col=='email' || $col=='email2' || $col=='email3' || $col=='email4') && !empty($record[$col]))
#
# ---------------------------------------------------------
#
# In file /program/steps/addressbook/save.inc
#
#Locate // setup some vars we need
#and the following code
$a_save_cols = array('name''firstname''surname''email');
#
#and replace with the following code
$a_save_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
#Locate the folllowing code
 
if (isset($_POST[$fname]))
#
#and replace with the following code
if (isset($_POST[$fname])){
  
$a_record[$col] = get_input_value($fnameRCUBE_INPUT_POST);
 }
#
# ---------------------------------------------------------
#I have left out the template piece because this can change depending on the template installed.
# ---------------------------------------------------------

Offline Yann

  • Jr. Member
  • **
  • Posts: 46
Global Address Book with additional fields and additional email addresses
« Reply #16 on: October 23, 2008, 07:38:37 PM »
Quote from: jonsjava;14689
Here's a mod to the script, to remove Global Address Book
I work for an ISP, and we don't want all users sharing their addresses, so I took what you had, and removed that feature.
<?php
# ----------------
#
# Database Additions for contact multiple emails
# Run in PhpMyAdmin on the database that holds the RC Contacts table. Change the table name rc_contacts to your contacts table name:
#
/*
 ALTER TABLE `contacts` ADD `firm` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `position` VARCHAR(50) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_tel` VARCHAR(30) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_fax` VARCHAR(30) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `p_address` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `w_tel` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_fax` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `contacts` ADD `w_address` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `notice` TEXT NOT NULL;
 ALTER TABLE `contacts` ADD `email2` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `email3` VARCHAR(128) NOT NULL ;
 ALTER TABLE `contacts` ADD `email4` VARCHAR(128) NOT NULL ;
 */
# -------------------------------------------------------------

#
# In file /program/include/rcube_contacts.inc
#
#Locate
var $table_cols = array('name''email''firstname''surname');
#
# and replace with
 
var $table_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
---------------------------------------------------------
#
# In file /program/include/main.inc
#
#Locate the following function
function rcmail_get_edit_field($col$value$attrib$type='text')
#
#and locate the following code
 
if ($type=='checkbox')
#
#and replace with the following code
 
if($col == "notice")
  {
        
$attrib['rows'] = "8";
        
$attrib['size'] = "40";
        
$attrib['cols'] = "40";
        
$input = new html_textarea($attrib);
        }
 elseif(
$col == "p_address" $col == "w_address")
  {
        
$attrib['rows'] = "4";
        
$attrib['size'] = "40";
        
$attrib['cols'] = "40";
        
$input = new html_textarea($attrib);
        }
 else if (
$type=='checkbox')
#
----------------------------------------------------------
#
# In File /program/localization/en_US/label.inc
#
#Locate // address boook
#
#and insert the following labels
$labels['firm']   = 'Organization';
$labels['position']   = 'Position';
$labels['p_tel']   = 'Telephone';
$labels['p_fax']   = 'Fax';
$labels['p_mob']   = 'Mobile';
$labels['p_address']   = 'Address';
$labels['w_tel']   = 'Business Telephone';
$labels['w_fax']   = 'Business Fax';
$labels['w_mob']   = 'Business Mobile';
$labels['w_address']   = 'Business Address';
$labels['notice']   = 'Notes';

$labels['email2']  = 'E-Mail 2';
$labels['email3']  = 'E-Mail 3';
$labels['email4']  = 'E-Mail 4';
#
# --------------------------------------------------------
#
# In file /program/steps/mail/compose.inc
#
#locate the following if statement
if ($result $CONTACTS->list_records())
#
#locate the following code
 
while ($sql_arr $result->iterate())
  if (
$sql_arr['email'])
           
$a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
#
#and insert the following code after that
  
if ($sql_arr['email2'])
   
$a_contacts[] = format_email_recipient($sql_arr['email2'], $sql_arr['name']);
  if (
$sql_arr['email3'])
   
$a_contacts[] = format_email_recipient($sql_arr['email3'], $sql_arr['name']);
  if (
$sql_arr['email4'])
   
$a_contacts[] = format_email_recipient($sql_arr['email4'], $sql_arr['name']);
#
# --------------------------------------------------------
#
# In file /program/steps/addressbook/edit.inc
#
#locate  // return the complete address edit form as table
#
#and the following code
 
$a_show_cols = array('name''firstname''surname''email');
#
#and replace with the following code
 
$a_show_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
# --------------------------------------------------------
#
# In file /program/steps/addressbook/show.inc
#
#Locate  // return the complete address record as table
#and the following code
 
$a_show_cols = array('name''firstname''surname''email');
#
#and replace with the following code
 
$data ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Data</b></legend><table>\n\n";
 
$contact ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Contact</b></legend><table>\n\n";

 
$a_show_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
#The old version of this had things like $out .=sprint#. I have found that all of this is unnecessary in the new version and also the closing table tags because of how the new
#handles the tags for this area.
#
#
#Locate the following code
  
if ($col=='email' && !empty($record[$col]))
#
#and replace with the following code
  
if (($col=='email' || $col=='email2' || $col=='email3' || $col=='email4') && !empty($record[$col]))
#
# ---------------------------------------------------------
#
# In file /program/steps/addressbook/save.inc
#
#Locate // setup some vars we need
#and the following code
$a_save_cols = array('name''firstname''surname''email');
#
#and replace with the following code
$a_save_cols = array('name''firstname''surname''email''email2''email3''email4''firm''position''p_tel''p_fax''p_mob''p_address''w_tel''w_fax''w_mob''w_address''notice');
#
#
#Locate the folllowing code
 
if (isset($_POST[$fname]))
#
#and replace with the following code
if (isset($_POST[$fname])){
  
$a_record[$col] = get_input_value($fnameRCUBE_INPUT_POST);
 }
#
# ---------------------------------------------------------
#I have left out the template piece because this can change depending on the template installed.
# ---------------------------------------------------------


Any help here, I used the code in RC 0.2Beta, everything displayed correctly but I could NOT save the address book. I received "The website cannot display the page" error.

Offline jonsjava

  • Jr. Member
  • **
  • Posts: 11
Global Address Book with additional fields and additional email addresses
« Reply #17 on: October 27, 2008, 12:29:01 PM »
Quote from: Yann;14821
Any help here, I used the code in RC 0.2Beta, everything displayed correctly but I could NOT save the address book. I received "The website cannot display the page" error.


Here's a compressed version of my patch. It's the latest SVN release already patched.
« Last Edit: October 27, 2008, 03:02:35 PM by jonsjava »

Offline Yann

  • Jr. Member
  • **
  • Posts: 46
Global Address Book with additional fields and additional email addresses
« Reply #18 on: October 28, 2008, 10:59:22 PM »
Quote from: jonsjava;14879
Here's a compressed version of my patch. It's the latest SVN release already patched.


Works like a charm, Thanks

Offline jonsjava

  • Jr. Member
  • **
  • Posts: 11
Global Address Book with additional fields and additional email addresses
« Reply #19 on: October 29, 2008, 10:48:26 AM »
Glad to be of service

Offline henlon

  • Jr. Member
  • **
  • Posts: 40
Error in Addressbook
« Reply #20 on: November 02, 2008, 06:03:31 AM »
Hi
I have just installed rc02-beta and it works fine.
I installed the Plug in Global addressbook with additional fields and got en error when trying to edit/insert a new contact.

I have made the db conversion and the update of the files.

When I try to add a new contact my browser gives me the http 500 error.
I can read this line in my error log:

[02-Nov-2008 11:53:21] PHP Fatal error:  Class 'textarea' not found in C:\Inetpub\wwwroot\rc02\program\include\main.inc on line 665

What's wrong?

Offline browndrake

  • Newbie
  • *
  • Posts: 1
saves all as global, also problem adding address from emails
« Reply #21 on: November 09, 2008, 11:21:18 PM »
I am very new to this type of code but I managed to make the changes from this thread and most things seem to be working well.  There are two issues that I have not been able to fix.

I am using version: v.0.1.1

Wup.nu stated:
Quote
I cannot added the addresses from my e-mail. when I press in the plus button, a message box tell me that I cannot save the receiver...


When I click the pluse (+) I don't get an error message or anything else.  However, it fails to let me add the address. Nothing seems to happen.

I would appreciate it if somebody could send me in the right direction to find a solution for that.

Also, when adding new contacts everything works well EXCEPT: it adds everybody as global.  It does not matter wether I enter 0 or 1, it saves it as global and upon edit shows a "1" .  Upon editing the entry and re-saving, it saves correctly.   I believe that this is the code that affects it but I can not see why it is behaving as it is:

Code: [Select]
// read POST values into hash array
foreach ($a_save_cols as $col)
{
  $fname = '_'.$col;
   if($col == 'global_contact'){
if(isset($_POST[$fname])){
$a_record[$col] = 1;
}else{
$a_record[$col] = 0;
}
 } else if (isset($_POST[$fname])){
  $a_record[$col] = get_input_value($fname, RCUBE_INPUT_POST);
 }
    $a_record[$col] = get_input_value($fname, RCUBE_INPUT_POST);
}

.......................
note:  until somebody figures out how to make a drop down to select yes or no, as to wether a contact is global or not, I edited the html so that it reads:
Global Contact (1 for yes, 0 for no)
That way users know they need to enter 0 or 1.
.......................

Thanks to anybody that can help with the above issues.

browndrake
« Last Edit: November 09, 2008, 11:24:08 PM by browndrake »

Offline Wazooka

  • Jr. Member
  • **
  • Posts: 22
Global Address Book with additional fields and additional email addresses
« Reply #22 on: November 12, 2008, 07:08:30 AM »
Quote from: jonsjava;14879
Here's a compressed version of my patch. It's the latest SVN release already patched.


Could you explain what's different from your non-Global plugin posted and this patched RC?

moody_styley

  • Guest
2.0 Stable ?
« Reply #23 on: January 18, 2009, 11:23:26 AM »
Hi all,

I have tried to apply the Global Address Book script for 0.2 Stable and nothing worked.

I was running 0.2 Beta before and script was OK.

Can anybody help me to apply this great plugin to 0.2 Stable ?

Thanks in davance for your help.
« Last Edit: January 20, 2009, 09:46:05 AM by moody_styley »

Offline lacri

  • Full Member
  • ***
  • Posts: 179
    • http://www.php-lexikon.de
Global Address Book with additional fields and additional email addresses
« Reply #24 on: January 28, 2009, 04:17:01 AM »
Hi all,

plz modify this plugin to RC 0.2 Stable ?

yea my english is bad ;)

Thx

Offline tfyisupportteam

  • Newbie
  • *
  • Posts: 4
GAL for 0.2 Stable
« Reply #25 on: February 17, 2009, 04:09:29 PM »
Is any going to be working on a mod for 0.2 stable, also i was wondering if anyone has figured out a way to only allow admins access to change information in the global address list.

Thanks

Offline BruderTack

  • Newbie
  • *
  • Posts: 3
Global Address Book with additional fields and additional email addresses
« Reply #26 on: February 18, 2009, 09:38:30 AM »
Quote from: jonsjava;14879
Here's a compressed version of my patch. It's the latest SVN release already patched.

Thanks for your package! It works fine, but I found one bug in the code. The database fields email2, email3, email4 don't popup in the autocomplete list when you enter an recipient. (only email is shown)

File: /program/steps/mail/compose.inc
Line: 915

// search for
while ($sql_arr $result->iterate())
if (
$sql_arr['email'])$a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
if (
$sql_arr['email2'])$a_contacts[] = format_email_recipient($sql_arr['email2'], $sql_arr['name']);
if (
$sql_arr['email3'])$a_contacts[] = format_email_recipient($sql_arr['email3'], $sql_arr['name']);
if (
$sql_arr['email4'])$a_contacts[] = format_email_recipient($sql_arr['email4'], $sql_arr['name']);

// and change this to (took be about an hour to find this *lol*):
while ($sql_arr $result->iterate()) {
	
if (
$sql_arr['email'])$a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
	
if (
$sql_arr['email2'])$a_contacts[] = format_email_recipient($sql_arr['email2'], $sql_arr['name']);
	
if (
$sql_arr['email3'])$a_contacts[] = format_email_recipient($sql_arr['email3'], $sql_arr['name']);
	
if (
$sql_arr['email4'])$a_contacts[] = format_email_recipient($sql_arr['email4'], $sql_arr['name']);
}

Offline jonsjava

  • Jr. Member
  • **
  • Posts: 11
Global Address Book with additional fields and additional email addresses
« Reply #27 on: March 10, 2009, 02:27:43 PM »
I noticed that issue as well.  I'll work on it when I get a chance. I just noticed this post, so I apologize for the delay in response.

Offline lacri

  • Full Member
  • ***
  • Posts: 179
    • http://www.php-lexikon.de
port to 0.2 stable / 0.2.1 part 1
« Reply #28 on: March 11, 2009, 05:40:58 AM »
« Last Edit: March 11, 2009, 06:20:07 AM by lacri »

Offline lacri

  • Full Member
  • ***
  • Posts: 179
    • http://www.php-lexikon.de
port to 0.2 stable / 0.2.1 part 2
« Reply #29 on: March 11, 2009, 05:42:37 AM »
modiefie /program/steps/addressbook/show.inc
search for

$a_show_cols 
= array('name''firstname''surname''email');

and replace with

$a_show_cols 
= array('global_contact''name''firstname''surname''email''notice''firm''position''w_address''w_tel''w_fax''w_mob''email2''email3''email4''p_address''p_tel''p_fax''p_mob');


search for and delete

$table 
= new html_table(array('cols' => 2));


search for

$microformats 
= array('name' => 'fn''email' => 'email');

and add after

$i 
1;
 foreach (
$a_show_cols as $col) {
 if(
$col=='global_contact' or $col=='email2' or $col=='firm' or $col=='p_address')
   
$table = new html_table(array('cols' => 2));


search for and delete
foreach ($a_show_cols as $col) {

search for

}
 
return 
$table->show($attrib + array('class' => 'vcard'));

and replace with

if ($table->size() and ($col=='notice' or $col=='email4' or $col=='w_mob' or $col=='p_mob'))
        {
      
$out .= html::tag('div', array('class' => 'contactdetails-block'),html::tag('fieldset'nullhtml::tag('legend'nullQ(rcube_label($col.'legend'))) . $table->show($attrib + array('class' => 'vcard'))));
        }
 
$i++;
 }
return 
$out;


search for

if ($col == 'email' && !empty($record[$col])) {

and replace with

if (($col=='email' || $col=='email2' || $col=='email3' || $col=='email4') && !empty($record[$col])) {

search for

'class' => $microformats[$col],
       ), 
Q($record[$col]));
     }
     else if (!empty(
$record[$col])) {
       
$value html::span($microformats[$col], Q($record[$col]));
     }

and replace with

'class' => $microformats[$col],
       ), 
Q($record[$col]));
     }
   else if (
$col=='global_contact') {
     
$value html::span($microformats[$col],rcube_label($record[$col]== ?'globalyes':'globalno'));
    }
     else if (!empty(
$record[$col])) {
       
$value html::span($microformats[$col], Q($record[$col]));
     }

search for

$OUTPUT
->add_handler('contactdetails''rcmail_contact_details');
 
$OUTPUT->send('showcontact');

and replace with

$OUTPUT
->add_handler('contactdetails''rcmail_contact_details');
if(
$record['global_contact'] != 1)
{
 
$OUTPUT->send('showcontact');
}
else
{
$OUTPUT->send('noedit_showcontact');
}


modiefie /program/steps/addressbook/delete.inc
search for
preg_match('/^[a-zA-Z0-9=]+(,[a-zA-Z0-9=]+)*$/'$cid))
    )
   {
$deleted $CONTACTS->delete($cid);

and replace with
preg_match('/^[a-zA-Z0-9=]+(,[a-zA-Z0-9=]+)*$/'$cid))
    )
   {
  if (
$record $CONTACTS->get_record($cidtrue))
      
$OUTPUT->set_env('cid'$record['ID']);

// adding not allowed here
if ($CONTACTS->readonly)
{
  
$OUTPUT->show_message('sourceisreadonly');
  
rcmail_overwrite_action('show');
}
elseif(
$record['global_contact'] == 1) {
  
$OUTPUT->show_message('addressisreadonly''error');
  
rcmail_overwrite_action('show');
  
$OUTPUT->send();
  exit();
    }
else
    {
   
$deleted $CONTACTS->delete($cid);

search for

// send error message
exit;

and replace with

$OUTPUT
->show_message('contacterrorsaved''warning');
rcmail_overwrite_action('show');
$OUTPUT->send();
exit();

search for

if ($_GET['_from'] != 'show' && $pages && $CONTACTS->list_page $pages)
     
rcmail_js_contacts_list($CONTACTS->list_records(null, -$deleted));

and add the lines

$OUTPUT
->show_message('successfullysaved''confirmation');
rcmail_overwrite_action('show');


search for

$OUTPUT
->send();
       exit();
     }

   
// count contacts for this user


and replace with

$OUTPUT
->send();
       exit();
     }
  else
    {
    
// count contacts for this user


search for

// send response
   
$OUTPUT->send();
   }

 
?>

and replace with

// send response
   
$OUTPUT->send();
   }
  }
 }
 
?>


modiefie /program/steps/addressbook/edit.inc
search for

rcmail_overwrite_action
('show');
   return;
 }
 
 function 
rcmail_contact_editform($attrib)
 {

and replace with

rcmail_overwrite_action
('show');
   return;
 }
elseif(
$record['global_contact'] == 1) {
    
$OUTPUT->show_message('addressisreadonly''error');
  
rcmail_overwrite_action('show');
  return;
  }
 
 function 
rcmail_contact_editform($attrib)
 {


search for

$a_show_cols 
= array('name''firstname''surname''email');

and replace with

$a_show_cols 
= array('name''firstname''surname''email''notice''firm''position''w_address''w_tel''w_fax''w_mob''email2''email3''email4''p_address''p_tel''p_fax''p_mob');

search for

// this will be executed if no template for addcontact exists
$OUTPUT->send('editcontact');

and replace with

// this will be executed if no template for addcontact exists
if($record['global_contact'] != 1)
 
$OUTPUT->send('editcontact');
else
$OUTPUT->send('noedit_editcontact');


search for

$out 
"$form_start<table>\n\n";

and replace with

$out 
"$form_start\n\n";


search for

foreach ($a_show_cols as $col)
   {

and add after

if($col=='name' or $col=='email2' or $col=='firm' or $col=='p_address')
 
$out .= "<div class='contactdetails-block'><fieldset><legend>".Q(rcube_label($col.'legend'))."</legend><table>";


search for

Q
(rcube_label($col)),
                     
$value);
   }

and replace with
Q(rcube_label($col)),
                     
$value);
   if(
$col=='notice' or $col=='email4' or $col=='w_mob' or $col=='p_mob')
   
$out .= "</fieldset></table></div>";
   }


search for
$out .= "\n</table>$form_end";
and replace with
$out .= "\n$form_end";

modiefie /program/steps/mail/autocomplete.inc
search for

if ($result $abook->search(array('email','name'), $search)) {
       while (
$sql_arr $result->iterate()) {
         if (
stripos((string)$sql_arr['email'], $search) !== false || stripos((string)$sql_arr['name'], $search) !== false) {
           
$contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
         }

and replace with

if ($result $abook->search(array('email','name','email2','email3','email4'), $search)) {
       while (
$sql_arr $result->iterate()) {
         if (
stripos((string)$sql_arr['email'], $search) !== false || stripos((string)$sql_arr['name'], $search) !== false) {
           
$contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
         }
        if (
stripos((string)$sql_arr['email2'], $search) !== false) {
          
$contacts[] = format_email_recipient($sql_arr['email2'], $sql_arr['name']);
        }
        if (
stripos((string)$sql_arr['email3'], $search) !== false) {
          
$contacts[] = format_email_recipient($sql_arr['email3'], $sql_arr['name']);
        }
        if (
stripos((string)$sql_arr['email4'], $search) !== false) {
          
$contacts[] = format_email_recipient($sql_arr['email4'], $sql_arr['name']);
        }


to disabled the delete button and DEL/Entf Key add the ID from Global Contact to
/program/js/app.js
search forthis.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly);
and add at the end this replace 275 with your global contacts id you can add more then one id
this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly && id != 275);

and at the end

# ----------------
#
# Database Additions for contact multiple emails
# Run in PhpMyAdmin on the database that holds the RC Contacts table. Change the table name rc_contacts to your contacts table name:
#
 
ALTER TABLE `contactsADD `global_contactTINYINT(1NOT NULL default '0';
 
ALTER TABLE `contactsADD `firmVARCHAR(128NOT NULL ;
 
ALTER TABLE `contactsADD `positionVARCHAR(50NOT NULL ;
 
ALTER TABLE `contactsADD `p_telVARCHAR(30NOT NULL ;
 
ALTER TABLE `contactsADD `p_faxVARCHAR(30NOT NULL ;
 
ALTER TABLE `contactsADD `p_mobVARCHAR(20NOT NULL ;
 
ALTER TABLE `contactsADD `p_addressTEXT NOT NULL;
 
ALTER TABLE `contactsADD `w_telVARCHAR(20NOT NULL ;
 
ALTER TABLE `contactsADD `w_faxVARCHAR(20NOT NULL ;
 
ALTER TABLE `contactsADD `w_mobVARCHAR(20NOT NULL ;
 
ALTER TABLE `contactsADD `w_addressTEXT NOT NULL;
 
ALTER TABLE `contactsADD `noticeTEXT NOT NULL;
 
ALTER TABLE `contactsADD `email2VARCHAR(128NOT NULL ;
 
ALTER TABLE `contactsADD `email3VARCHAR(128NOT NULL ;
 
ALTER TABLE `contactsADD `email4VARCHAR(128NOT NULL ;
# -------------------------------------------------------------