Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: cheongseeker on November 13, 2007, 01:50:48 AM

Title: Global Address Book with additional fields and additional email addresses
Post by: cheongseeker on November 13, 2007, 01:50:48 AM
Hi there,

I would like to start off by thanking all the contributors here for the codes to modify the existing address book into one that can do global address book which contain additional fields and additional email addresses per contact.

After going through the forum, I found different modification codes to achieve each function. Like one code to enable you to have global address book. Another to have additional fields in individual contact. Another to have additional email addresses per contact.

I had merge all these modification codes into one. I'm attaching the merged codes below. I hope you find it helpful.

Again, I will like to stress that I'm not the original creator of these codes. These codes are done by fellow forum users here whom had done a great job.


After having done this, I hope to have another function. I'm hoping that fellow forum users here can help. I want to have only the administrator manage the global address book. Which means only administrator can create, edit and delete global address book. User are not allow to create, edit and delete global address book.

However, user will still be allowed to create, edit and delete individual (personal) contacts.

Thanks.

Code: [Select]
# -------------------------------------------------------------------------------------------------------------
#

# 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 `global_contact` TINYINT(1) NOT NULL default '0';
 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', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');
#
#
#
#locate function...
 function list_records($cols=null, $subset=0)
#locate the code....
   $sql_result = $this->db->limitquery(
    "SELECT * FROM ".$this->db_name."
     WHERE del<>1
     AND  user_id=?&quot; .
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;) .
    &quot; ORDER BY name&quot;,
#
#and replace with
   $sql_result = $this->db->limitquery(
    &quot;SELECT * FROM &quot;.$this->db_name.&quot;
     WHERE del<>1
     AND  (user_id=? OR global_contact = 1)&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;) .
    &quot; ORDER BY name&quot;,
#
#
#
#locate function...
 function count()
#locate the code....
  $sql_result = $this->db->query(
   &quot;SELECT COUNT(contact_id) AS rows
    FROM &quot;.$this->db_name.&quot;
    WHERE del<>1
    AND  user_id=?&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;),
   $this->user_id);
#
#and replace with
  $sql_result = $this->db->query(
   &quot;SELECT COUNT(contact_id) AS rows
    FROM &quot;.$this->db_name.&quot;
    WHERE del<>1
    AND  (user_id=? OR global_contact = 1)&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;),
   $this->user_id);
#
#
#
#locate function...
 function get_record($id, $assoc=false)
#locate the code....
  $this->db->query(
   &quot;SELECT * FROM &quot;.$this->db_name.&quot;
    WHERE contact_id=?
    AND  user_id=?
    AND  del<>1&quot;,
   $id,
   $this->user_id);
#
#and replace with
  $this->db->query(
   &quot;SELECT * FROM &quot;.$this->db_name.&quot;
    WHERE contact_id=?
    AND  (user_id=? OR global_contact = 1)
    AND  del<>1&quot;,
   $id,
   $this->user_id);
#
#
#
#locate function...
 function update($id, $save_cols)
#locate the code....
  if (!empty($write_sql))
  {
   $this->db->query(
    &quot;UPDATE &quot;.$this->db_name.&quot;
     SET  changed=&quot;.$this->db->now().&quot;, &quot;.join(', ', $write_sql).&quot;
     WHERE contact_id=?
     AND  user_id=?
     AND  del<>1&quot;,
    $id,
    $this->user_id);
#
#and replace with
  if (!empty($write_sql))
  {
   $this->db->query(
    &quot;UPDATE &quot;.$this->db_name.&quot;
     SET  changed=&quot;.$this->db->now().&quot;, &quot;.join(', ', $write_sql).&quot;
     WHERE contact_id=?
     AND  (user_id=? OR global_contact = 1)
     AND  del<>1&quot;,
    $id,
    $this->user_id);
#
#
#
#locate function...
 function insert($save_data, $check=false)
#locate the code....
   $this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
#
#and replace with the following
if ($a_insert_values[4] == &quot;'on'&quot;) {
$this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
} else {
$this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, global_contact, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, '1', 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
}  
#  
#
#
-------------------------------------------------------------------------------------------------------------
#
# 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 == &quot;notice&quot;)
  {
$attrib['rows'] = &quot;8&quot;;
$attrib['size'] = &quot;40&quot;;
$attrib['cols'] = &quot;40&quot;;
$input = new textarea($attrib);
}
 elseif($col == &quot;p_address&quot; | $col == &quot;w_address&quot;)
  {
$attrib['rows'] = &quot;4&quot;;
$attrib['size'] = &quot;40&quot;;
$attrib['cols'] = &quot;40&quot;;
$input = new textarea($attrib);
}
 else if ($type=='checkbox')
#
#
#
-------------------------------------------------------------------------------------------------------------
#
# In File /program/localization/en_US/label.inc
#
#Locate // address boook
#
#and insert the following labels
$labels['global_contact']  = 'Global Contact';
$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']   = 'Notice';

$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&#91;] = format_email_recipient($sql_arr['email'], JQ($sql_arr['name']));
#
#and insert the following code after that
  if ($sql_arr['email2'])
   $a_contacts&#91;] = format_email_recipient($sql_arr['email2'], JQ($sql_arr['name']));
  if ($sql_arr['email3'])
   $a_contacts&#91;] = format_email_recipient($sql_arr['email3'], JQ($sql_arr['name']));
  if ($sql_arr['email4'])
   $a_contacts&#91;] = format_email_recipient($sql_arr['email4'], JQ($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', 'global_contact', '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 =&quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;>\n<fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>Data</b></legend><table>\n\n&quot;;
 $contact =&quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;>\n<fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>Contact</b></legend><table>\n\n&quot;;

 $a_show_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'email3', 'email4', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');
#
#
#Locate the following code
  $out .= sprintf(&quot;<tr><td class=\&quot;title\&quot;>%s</td><td>%s</td></tr>\n&quot;,
          Q(rcube_label($col)),
          $value);
  }
 
 $out .= &quot;\n</table>&quot;;
#
#and replace with the following code
$title = Q(rcube_label($col));
if($col == &quot;notice&quot;){
$out2 = &quot;<td colspan=\&quot;3\&quot; width=\&quot;100%\&quot; valign=\&quot;top\&quot;><fieldset width=\&quot;100%\&quot; class=\&quot;title\&quot;><legend><b>$title</b></legend><table>\n&quot;;
$out2 .= sprintf(&quot;<tr><td>%s</td></tr>\n&quot;, $value);
$out2 .= &quot;</table></fieldset></td>\n\n&quot;;
}
elseif($col == &quot;p_tel&quot; | $col == &quot;p_fax&quot; | $col == &quot;p_mob&quot; | $col == &quot;w_tel&quot; | $col == &quot;w_fax&quot; | $col == &quot;w_mob&quot;){
if(!$value == &quot;&quot;){
  $contact .= sprintf(&quot;<tr><td>%s</td><td>%s</td></tr>\n&quot;,$title, $value);
}
}
elseif($col == &quot;p_address&quot;){
$p_address = &quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;><fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>$title</b></legend><table>\n&quot;;
$p_address .= sprintf(&quot;<tr><td>%s</td></tr>\n&quot;, $value);
$p_address .= &quot;</table></fieldset></td>\n\n&quot;;
}
elseif($col == &quot;w_address&quot;){
$w_address = &quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;><fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>$title</b></legend><table>\n&quot;;
$w_address .= sprintf(&quot;<tr><td>%s</td></tr>\n&quot;, $value);
$w_address .= &quot;</table></fieldset></td>\n\n&quot;;
}
else{
if($col == &quot;global_contact&quot;){
if($value == 1)
  $data .= sprintf(&quot;<tr><td>%s</td><td>%s</td></tr>\n&quot;,$title, 'Yes');
else
  $data .= sprintf(&quot;<tr><td>%s</td><td>%s</td></tr>\n&quot;,$title, 'No');
} else if(!$value == &quot;&quot;)
  $data .= sprintf(&quot;<tr><td>%s</td><td>%s</td></tr>\n&quot;,$title, $value);
}



  }
$data .= &quot;</table></td>&quot;;
$contact .= &quot;</table></td>&quot;;

 $out .= &quot;$data<td width=\&quot;2%\&quot;>$contact\n\n&quot;;
 $out .= &quot;</tr><tr>&quot;;
 $out .= &quot;$p_address<td width=\&quot;2%\&quot;>$w_address\n\n&quot;;
 $out .= &quot;</tr><tr>&quot;;
 $out .= $out2;
 $out .= &quot;\n</tr></table>&quot;;
#
#
#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', 'global_contact', '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($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);
 }
#
#
#
#
# -------------------------------------------------------------------------------------------------------------
#Look in the file /skins/default/templates/addressbook.html.
#
#locate the following code that should be around line 31 and line 32
#<style type=&quot;text/css&quot;>
#addresslist { left:20px; width:440px }
#contacts-box { left:475px }
#abookcountbar { left:20px }
#</style>
#
#
#Modify it to suit your needs. Something like:
#
#addresslist { left:20px; width:250px }
#contacts-box { left:300px }
#
#Note that #addresslist has an initial left position and width. #contacts-box only the initial left position as it uses the rest of the frame width.
#
#
#
#
# -------------------------------------------------------------------------------------------------------------
#
#
# -------------------------------------------------------------------------------------------------------------
#
Title: DB Error: unknown error Query
Post by: justanewuser on April 30, 2008, 10:49:24 PM
First off, I would like to say thank you for the post. It's a wonderful addition. I followed your directions, however when I try to manually add a contact, I get the following error from the "mail/logs/errors" file:
[28-Apr-2008 23:35:56 -0600] DB Error: DB Error: unknown error Query: INSERT INTO contacts (user_id, changed, global_contact, del, `name`, `firstname`, `surname`, `email`, `email2`, `email3`, `email4`, `global_contact`, `firm`, `position`, `p_tel`, `p_fax`, `p_mob`, `p_address`, `w_tel`, `w_fax`, `w_mob`, `w_address`, `notice`) VALUES ('3', now(), '1', 0, 'asd', '', '', 'asd@sdfsdf.com', '', '', '', '0', '', '', '', '', '', '', '', '', '', '', '') [nativecode=1110 ** Column 'global_contact' specified twice] in /home/houdinia/public_html/atailoftwofurs/mail/program/include/rcube_db.inc on line 505
Now, if I open an email and click the "add contact" button, the contact is saved into the address book correctly. Once the contact is in, I can edit it with no problems.

Any ideas on a fix would be greatly appreciated!
Thanks....
Title: Global Address Book with additional fields and additional email addresses
Post by: rosali on May 03, 2008, 05:21:13 AM
Sounds like you missed to adjust the database ...

You have to add the new database fields to 'roundcubemail.contacts' table.

-Roland
Title: Global Address Book with additional fields and additional email addresses
Post by: bpat1434 on May 03, 2008, 11:43:36 AM
The issue is that global_contact is used twice in an insert query.  So find this:
if ($a_insert_values[4] == "'on'") {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
} else {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, global_contact, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", '1', 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
}
and replace with:
if ($a_insert_values[4] == "'on'") {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
} else {
  $a_insert_values[7]=1;
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
}
Title: Global Address Book with additional fields and additional email addresses
Post by: pengyou on May 03, 2008, 01:40:03 PM
How is this change made?  Do I copy the file and put it into a folder on the server?  Can I add as many fields as I want?
Title: Global Address Book with additional fields and additional email addresses
Post by: bpat1434 on May 03, 2008, 01:59:29 PM
Execute the SQL statements they have, then read the "#" lines.  It will tell you exactly what you need to do.  For example:
Code: [Select]
#
# 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', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');
#
Means that you need to open the file /program/includes/rcube_contacts.inc and find whatever code and replace it with the new code.
Title: Global Address Book with additional fields and additional email addresses
Post by: justanewuser on May 03, 2008, 09:49:42 PM
Quote from: bpat1434;11802
The issue is that global_contact is used twice in an insert query.  So find this:
if ($a_insert_values[4] == "'on'") {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
} else {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, global_contact, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", '1', 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
}
and replace with:
if ($a_insert_values[4] == "'on'") {
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
} else {
  $a_insert_values[7]=1;
$this->db->query(
    "INSERT INTO ".$this->db_name."
     (user_id, changed, del, ".join(', ', $a_insert_cols).")
     VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
    $this->user_id);
}


That worked. Thank you for your help!
Title: Global Address Book with additional fields and additional email addresses
Post by: grob85 on June 28, 2008, 04:50:43 PM
Hello!

Before == sorry for my english ;)

I have used v0.2-alpha and hint from post doesn't work  correctly :)
i don't know - may be in 1.1 this work great, but...

I have modify some strings from rcube_contacts.php (requesting for DB)

(like "AND user_id=?" (there are link to $this) ) by adding "OR global_contact=1)
and this work  :)

Thanks Much!
Title: Error
Post by: malikhemani on July 06, 2008, 12:39:42 AM
I added to DB and made all the file changes. Once I am in RC under address book i do not see the global address book (i dont see other emails that are on the server). I started to create a new entry and when i hit save i get this:

SERVICE CURRENTLY NOT AVAILABLE!
Error No. [0x01F4]

can anyone help me please!
Title: Global Address Book with additional fields and additional email addresses
Post by: bpat1434 on July 15, 2008, 07:07:31 AM
What's the roundcube error log say?
Title: sorry
Post by: malikhemani on July 16, 2008, 12:14:14 AM
sorry i had steped away from the project. Let me give it another try and get back to you if i have any problems and return error logs

thanks and take care,
Title: Updated Global Address Book Plugin
Post by: NEComputer on September 27, 2008, 02:00:08 AM
Hello everyone,

I have updated the original code to work with the new version of RC v0.2-beta so that when upgrading from v0.1.1 the functionality of the global address book is not loss.

If anyone finds has a problem with this code, mistakes, or instances this doesn't work please let me know and I can investigate into the problem further.

-Pat

The code:

Code: [Select]
# ----------------
#
# 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 `global_contact` TINYINT(1) NOT NULL default '0';
 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', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');
#
#
#
#locate function...
 function list_records($cols=null, $subset=0)
#locate the code....
   $sql_result = $this->db->limitquery(
    &quot;SELECT * FROM &quot;.$this->db_name.&quot;
     WHERE del<>1
     AND  user_id=?&quot; .
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;) .
    &quot; ORDER BY name&quot;,
#
#and replace with
   $sql_result = $this->db->limitquery(
    &quot;SELECT * FROM &quot;.$this->db_name.&quot;
     WHERE del<>1
     AND  (user_id=? OR global_contact = 1)&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;) .
    &quot; ORDER BY name&quot;,
#
#
#
#locate function...
 function count()
#locate the code....
  $sql_result = $this->db->query(
   &quot;SELECT COUNT(contact_id) AS rows
    FROM &quot;.$this->db_name.&quot;
    WHERE del<>1
    AND  user_id=?&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;),
   $this->user_id);
#
#and replace with
  $sql_result = $this->db->query(
   &quot;SELECT COUNT(contact_id) AS rows
    FROM &quot;.$this->db_name.&quot;
    WHERE del<>1
    AND  (user_id=? OR global_contact = 1)&quot;.
    ($this->filter ? &quot; AND (&quot;.$this->filter.&quot;)&quot; : &quot;&quot;),
   $this->user_id);
#
#
#
#locate function...
 function get_record($id, $assoc=false)
#locate the code....
  $this->db->query(
   &quot;SELECT * FROM &quot;.$this->db_name.&quot;
    WHERE contact_id=?
    AND  user_id=?
    AND  del<>1&quot;,
   $id,
   $this->user_id);
#
#and replace with
  $this->db->query(
   &quot;SELECT * FROM &quot;.$this->db_name.&quot;
    WHERE contact_id=?
    AND  (user_id=? OR global_contact = 1)
    AND  del<>1&quot;,
   $id,
   $this->user_id);
#
#
#
#locate function...
 function update($id, $save_cols)
#locate the code....
  if (!empty($write_sql))
  {
   $this->db->query(
    &quot;UPDATE &quot;.$this->db_name.&quot;
     SET  changed=&quot;.$this->db->now().&quot;, &quot;.join(', ', $write_sql).&quot;
     WHERE contact_id=?
     AND  user_id=?
     AND  del<>1&quot;,
    $id,
    $this->user_id);
#
#and replace with
  if (!empty($write_sql))
  {
   $this->db->query(
    &quot;UPDATE &quot;.$this->db_name.&quot;
     SET  changed=&quot;.$this->db->now().&quot;, &quot;.join(', ', $write_sql).&quot;
     WHERE contact_id=?
     AND  (user_id=? OR global_contact = 1)
     AND  del<>1&quot;,
    $id,
    $this->user_id);
#
#
#
#locate function...
 function insert($save_data, $check=false)
#locate the code....
   $this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
#
#and replace with the following
     if ($a_insert_values[4] == &quot;'on'&quot;) {
$this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
} else {
  $a_insert_values[7]=1;
$this->db->query(
    &quot;INSERT INTO &quot;.$this->db_name.&quot;
     (user_id, changed, del, &quot;.join(', ', $a_insert_cols).&quot;)
     VALUES (?, &quot;.$this->db->now().&quot;, 0, &quot;.join(', ', $a_insert_values).&quot;)&quot;,
    $this->user_id);
}  
#  
#
---------------------------------------------------------
#
# 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 == &quot;notice&quot;)
  {
$attrib['rows'] = &quot;8&quot;;
$attrib['size'] = &quot;40&quot;;
$attrib['cols'] = &quot;40&quot;;
$input = new html_textarea($attrib);
}
 elseif($col == &quot;p_address&quot; | $col == &quot;w_address&quot;)
  {
$attrib['rows'] = &quot;4&quot;;
$attrib['size'] = &quot;40&quot;;
$attrib['cols'] = &quot;40&quot;;
$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['global_contact']  = 'Global Contact';
$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']   = 'Notice';

$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', 'global_contact', '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 =&quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;>\n<fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>Data</b></legend><table>\n\n&quot;;
 $contact =&quot;<td width=\&quot;45%\&quot; valign=\&quot;top\&quot;>\n<fieldset width=\&quot;45%\&quot; class=\&quot;title\&quot;><legend><b>Contact</b></legend><table>\n\n&quot;;

 $a_show_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'email3', 'email4', 'global_contact', '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', 'global_contact', '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($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);
 }
#
# ---------------------------------------------------------
#I have left out the template piece because this can change depending on the template installed.
# ---------------------------------------------------------
Title: Global Address Book with additional fields and additional email addresses
Post by: Wup.nu on September 28, 2008, 06:22:44 AM
I have installed the last script for the global address book, it works almost fine but I have one problem... 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...

Does anyone know what there is wrong? for the rest is it new installation without any plug-in.

how can you made by global contact a dropdown with yes or no, not everyone on the site understand what the 1 and the 0 doing
Title: Global Address Book with additional fields and additional email addresses
Post by: NEComputer on September 28, 2008, 10:50:05 PM
I will work on the dropdown for the yes and no as to whether or not the contact should be global. I want to say I think in upcoming versions of roundcube when groups get implemented there will be a personal address book and a global address book, but I am not sure. This should be a simple fix for now.

-Pat
Title: Knowledge
Post by: Lihualee on September 29, 2008, 04:24:41 PM
bump up lurk
Title: Global Address Book with additional fields and additional email addresses
Post by: jonsjava 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.
# ----------------
#
# 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 ="\n
Data\n\n";
 $contact ="
\n
Contact\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($fname, RCUBE_INPUT_POST);
 }
#
# ---------------------------------------------------------
#I have left out the template piece because this can change depending on the template installed.
# ---------------------------------------------------------
Title: Global Address Book with additional fields and additional email addresses
Post by: Yann 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.
# ----------------
#
# 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 ="
\n
Data\n\n";
 $contact ="
\n
Contact\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($fname, RCUBE_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.
Title: Global Address Book with additional fields and additional email addresses
Post by: jonsjava 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.
Title: Global Address Book with additional fields and additional email addresses
Post by: Yann 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
Title: Global Address Book with additional fields and additional email addresses
Post by: jonsjava on October 29, 2008, 10:48:26 AM
Glad to be of service
Title: Error in Addressbook
Post by: henlon 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?
Title: saves all as global, also problem adding address from emails
Post by: browndrake 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
Title: Global Address Book with additional fields and additional email addresses
Post by: Wazooka 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?
Title: 2.0 Stable ?
Post by: moody_styley 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.
Title: Global Address Book with additional fields and additional email addresses
Post by: lacri 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
Title: GAL for 0.2 Stable
Post by: tfyisupportteam 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
Title: Global Address Book with additional fields and additional email addresses
Post by: BruderTack 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']);
}
Title: Global Address Book with additional fields and additional email addresses
Post by: jonsjava 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.
Title: port to 0.2 stable / 0.2.1 part 1
Post by: lacri on March 11, 2009, 05:40:58 AM
Title: port to 0.2 stable / 0.2.1 part 2
Post by: lacri 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', null, html::tag('legend', null, Q(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]== 1 ?'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($cid, true))
      $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 > 1 && $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
\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 .= "
".Q(rcube_label($col.'legend'))."
";


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 .= "
";
   }


search for
$out .= "\n
$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 `contacts` ADD `global_contact` TINYINT(1) NOT NULL default '0';
 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 ;
# -------------------------------------------------------------
Title: birtday field for Global Addressbook
Post by: lacri on March 13, 2009, 09:30:08 AM
i have add the birtday field to Addressbook Birtday must DD.MM.YYYY onfocus field will blank i have add onfocus to allowed inputfield parameters when Birtday is empty show DD.MM.YYYY on editpage and addpage.
and i have optimized the fieldset html output on show add and editpage for an better display and formating.

Code: [Select]
ALTER  TABLE  `contacts`  ADD  `birth` VARCHAR( 10  )  NOT  NULL ;

view attached diff
Title: Global Address Book with additional fields and additional email addresses
Post by: Aoster on March 13, 2009, 02:50:55 PM
Hello lacri,

would it be possible for you to create a patch for the changes
you have described in your "port to 0.2 stable / 0.2.1 " posting ?
It would be much easier to apply :-)

Thanks for your great work !!!

kind regards

Andreas
Title: Global Address Book with additional fields and additional email addresses
Post by: lacri on March 13, 2009, 04:43:51 PM
i commit a patch at next monday,
the weekend is time for my kids ;)
Title: Global Address Book with additional fields and additional email addresses
Post by: lacri on March 16, 2009, 05:20:53 AM
here is the patch

  not forgett

Code: [Select]
# 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 `global_contact` TINYINT(1) NOT NULL default '0';
 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 ;
 ALTER TABLE `contacts` ADD `birth` VARCHAR(10) NOT NULL ;

Title: Extended add book full compatible with thunderbird ldap
Post by: atuin on March 16, 2009, 07:42:25 AM
Based on work of lacri

I remove global contact from database, we use ldap for this

part 1

Add /etc/ldap/schema/mozillaorgperson.schema (debian)
and include it on /etc/ldap/slapd.conf
Code: [Select]

#
# mozillaOrgPerson schema v. 0.6.3
#

# req. core
# req. cosine
# req. inetorgperson

# attribute defs

attributetype ( 1.3.6.1.4.1.13769.2.1.1
        NAME ( 'mozillaNickname' )
        SUP name )

attributetype ( 1.3.6.1.4.1.13769.2.1.2
        NAME ( 'mozillaUseHtmlMail' )
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
        SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.13769.2.1.3
        NAME 'mozillaSecondEmail'
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

attributetype ( 1.3.6.1.4.1.13769.2.1.4
        NAME 'mozillaHomeLocalityName'
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )

attributetype ( 1.3.6.1.4.1.13769.2.1.5
        NAME 'mozillaPostalAddress2'
        EQUALITY caseIgnoreListMatch
        SUBSTR caseIgnoreListSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )

attributetype ( 1.3.6.1.4.1.13769.2.1.6
        NAME 'mozillaHomePostalAddress2'
        EQUALITY caseIgnoreListMatch
        SUBSTR caseIgnoreListSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )

attributetype ( 1.3.6.1.4.1.13769.2.1.7
        NAME ( 'mozillaHomeState' ) SUP name )

attributetype ( 1.3.6.1.4.1.13769.2.1.8
        NAME 'mozillaHomePostalCode'
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{40} )

attributetype ( 1.3.6.1.4.1.13769.2.1.9
        NAME ( 'mozillaHomeCountryName' )
        SUP name SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.13769.2.1.10
        NAME ( 'mozillaHomeFriendlyCountryName' )
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )

attributetype ( 1.3.6.1.4.1.13769.2.1.11
        NAME ( 'mozillaHomeUrl' )
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

attributetype ( 1.3.6.1.4.1.13769.2.1.12
        NAME ( 'mozillaWorkUrl' )
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

# un-comment for all LDAP server NOT supporting SYNTAX 2.16.840.1.113730.3.7.1
attributetype ( 1.3.6.1.4.1.13769.2.1.13
        NAME ( 'nsAIMid' )
        DESC 'AOL Instant Messenger (AIM) Identity'
        EQUALITY telephoneNumberMatch
        SUBSTR telephoneNumberSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )

attributetype ( 1.3.6.1.4.1.13769.2.1.14 NAME ( 'mozillaHomeStreet' )
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )

# un-comment for Netscape 6.x and all other LDAP server supporting SYNTAX 2.16.840.1.113730.3.7.1
# attributeTypes ( 2.16.840.1.113730.3.1.2013
#       NAME ( 'nsAIMid' )
#       DESC 'AOL Instant Messenger (AIM) Identity'
#       SYNTAX 2.16.840.1.113730.3.7.1 )

attributetype ( 1.3.6.1.4.1.13769.2.1.96
        NAME ( 'mozillaCustom1' )
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
        SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.13769.2.1.97
        NAME ( 'mozillaCustom2' )
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
        SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.13769.2.1.98
        NAME ( 'mozillaCustom3' )
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
        SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.13769.2.1.99
        NAME ( 'mozillaCustom4' )
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
        SINGLE-VALUE )
 
# defined in &quot;A Summary of the X.500(96) User Schema for use with LDAPv3&quot; - RFC 2256
#
# attributetype ( 2.5.4.6 NAME ( 'c' 'countryName' )
#       DESC 'RFC2256: ISO-3166 country 2-letter code'
#       SUP name SINGLE-VALUE )

# defined in &quot;The COSINE and Internet X.500 Schema&quot; - RFC 1274
#
# attributetype ( 0.9.2342.19200300.100.1.43
#       NAME ( 'co' 'friendlyCountryName' )
#       DESC 'RFC1274: friendly country name'
#       EQUALITY caseIgnoreMatch
#       SUBSTR caseIgnoreSubstringsMatch
#       SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )


# objectClass defs

objectclass ( 1.3.6.1.4.1.13769.2.2.1
        NAME 'mozillaOrgPerson'
        SUP top
        AUXILIARY
        MAY (    
        sn $    
        givenName $
        cn $
        mozillaNickname $
        title $
        telephoneNumber $
        facsimileTelephoneNumber $
        mobile $
        pager $  
        homePhone $
        street $  
        postalCode $
        mozillaPostalAddress2 $
        mozillaHomeStreet $    
        mozillaHomePostalAddress2 $
        l $
        mozillaHomeLocalityName $
        st $
        mozillaHomeState $
        mozillaHomePostalCode $
        c $
        mozillaHomeCountryName $
        co $
        mozillaHomeFriendlyCountryName $
        ou $
        o $  
        mail $
        mozillaSecondEmail $
        mozillaUseHtmlMail $
        nsAIMid $
        mozillaHomeUrl $
        mozillaWorkUrl $
        description $  
        mozillaCustom1 $
        mozillaCustom2 $
        mozillaCustom3 $
        mozillaCustom4 ) )

# not part of the official Mozilla schema but read by Mozilla: 'departmentNumber' and 'postOfficeBox'
#
 


modifie /program/config/main.inc.php
and add this on your $rcmail_config['ldap_public']['XXX'] section

  'writable'      => true,   // Indicates if we can write to the LDAP directory or not.
  // If writable is true then these fields need to be populated:
  // LDAP_Object_Classes, required_fields, LDAP_rdn
  'LDAP_Object_Classes' => array("top", "inetOrgPerson", "mozillaOrgPerson"), // To create a new contact these are the object classes to specify (or any oth
  'required_fields'     => array("cn", "sn", "mail"),     // The required fields needed to build a new contact as required by the object classes (can includ
  'LDAP_rdn'      => 'mail', // The RDN field that is used for new entries, this field needs to be one of the search_fields, the base of base_dn is appended
  'ldap_version'  => 3,       // using LDAPv3
  'search_fields' => array('mail', 'cn','mozillaSecondEmail' ),  // fields to search in

// identity block
  'name_field'    => 'cn',
  'surname_field' => 'sn',
  'firstname_field' => 'givenName',
  'email_field'   => 'mail',
  'email2_field'  => 'mozillaSecondEmail',

// telephone block
  'w_tel_field' => 'telephoneNumber',
  'p_tel_field' => 'homePhone',
  'w_fax_field' => 'facsimileTelephoneNumber',
  'w_mob_field' => 'mobile',
 
// business data block
  'company_field'       => 'o',
  'w_address_field'     => 'street',
  'w_postcode_field'    => 'postalCode',
  'w_city_field'        => 'l',
  'w_url_field'         => 'mozillaWorkUrl',
 
// personel data block
  'p_address_field'     => 'mozillaHomeStreet',
  'p_postcode_field'    => 'mozillaHomePostalCode',
  'p_city_field'        => 'mozillaHomeLocalityName',
  'p_url_field'         => 'mozillaHomeUrl',  

// description block
  'desc_field'          => 'description',
   
  'sort'          => 'cn',    // The field to sort the listing by.
  'scope'         => 'sub',   // search mode: sub|base|list
  'filter'        => '',      // used for basic listing (if not empty) and will be &'d with search queries. example: status=act
  'fuzzy_search'  => true);   // server allows wildcard search




modiefie /program/include/main.inc
search for

if ($type=='checkbox')
     {
     $attrib['value'] = '1';
     $input = new html_checkbox($attrib);


and replace with

  if($col == "desc")
    {
        $attrib['rows'] = "5";
        $attrib['size'] = "60";
        $attrib['cols'] = "60";
        $input = new html_textarea($attrib);
    }
    else if ($type=='checkbox')
     {
     $attrib['value'] = '1';
     $input = new html_checkbox($attrib);



modifie /program/include/rcube_contacts.php
search for

var $table_cols = array('name', 'email', 'firstname', 'surname');  


and replace with

 var $table_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'w_tel', 'p_tel', 'w_fax', 'w_mob', 'company', 'w_address', 'w_postcode', 'w_city', 'w_url', 'p_address', 'p_postcode', 'p_city', 'p_url', 'desc');


modifie /program/localization/fr_FR/labels.inc
add the lines

/* ========================
   Extended Adress Book
   ======================== */

// identity block
$labels['namelegend'] = $labels['surnamelegend'] = 'Identité';

// mail block
$labels['emaillegend'] = $labels['email2legend'] = 'E-mail';
$labels['email2'] = 'Adresse alternative   ';

// telephone block
$labels['w_tellegend'] = $labels['w_moblegend'] = 'Numéros de téléphone';
$labels['w_tel'] = 'Travail   ';
$labels['p_tel'] = 'Domicile';
$labels['w_fax'] = 'Fax';
$labels['w_mob'] = 'Portable';

// business block
$labels['companylegend'] = $labels['w_urllegend'] = 'Professionnel';
$labels['company'] = 'Société';
$labels['w_address'] = 'Adresse';
$labels['w_postcode'] = 'Code postal';
$labels['w_city'] = 'Ville';  
$labels['w_url'] = 'Page Web';

// home block
$labels['p_addresslegend'] = $labels['p_urllegend'] = 'Personnel';
$labels['p_address']   = 'Adresse';
$labels['p_postcode'] = 'Code postal';
$labels['p_city'] = 'Ville';
$labels['p_url'] = 'Page Web';

// description block
$labels['desc']   = ' ';
$labels['desclegend'] = 'Remarques';

Title: Extended add book full compatible with thunderbird ldap
Post by: atuin on March 16, 2009, 08:29:23 AM
part 2

modifie /program/include/rcube_ldap.php
search for

// The field does exist, add it to the entry.
$newentry[$fld] = $val;


and replace with

// The field does exist, add it to the entry.
// correct bug ldap_add() - null values in fields produce an "value #0 invalid per syntax" error on openldap 2.4
if ($val != "" ) $newentry[$fld] = $val;


modiefie /program/steps/addressbook/copy.inc
search for
$success = $TARGET->insert($CONTACTS->search($CONTACTS->primary_key, $cid), true);

and replace with

    $ids = explode( ',', $cid );

  foreach ( $ids as $id )
  {
    $record = $CONTACTS->search( $CONTACTS->primary_key, $id );
    $success[$id] = $TARGET->insert( $record->records[0], true );
  }

modiefie /program/steps/addressbook/edit.inc
search for
$out = "$form_start\n\n";

and replace with
$out = "$form_start\n\n";

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

and replace with
$a_show_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'w_tel', 'p_tel', 'w_fax', 'w_mob', 'company', 'w_address', 'w_postcode', 'w_city'
, 'w_url', 'p_address', 'p_postcode', 'p_city', 'p_url', 'desc');

search for

foreach ($a_show_cols as $col)
   {

and add after

if($col=='name' or $col=='email' or $col=='w_tel' or $col=='company' or $col=='p_address' or $col=='desc')
  $out .= "
".Q(rcube_label($col.'legend'))."
";


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

and replace with

Q(rcube_label($col)),
              $value);
    if($col=='surname' or $col=='email2' or $col=='w_mob' or $col=='w_url' or $col=='p_url' or $col=='desc')
      $out .= "
";
   }


search for
$out .= "\n
$form_end";

and replace with
$out .= "\n$form_end";

modiefie /program/steps/addressbook/save.inc
search for
$a_save_cols = array('name', 'firstname', 'surname', 'email');

and replace with
$a_save_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'w_tel', 'p_tel', 'w_fax', 'w_mob', 'company', 'w_address', 'w_postcode', 'w_city', 'w_url', 'p_address', 'p_postcode', 'p_city', 'p_url', 'desc');

modiefie /program/steps/addressbook/show.inc
search for
$a_show_cols = array('name', 'firstname', 'surname', 'email');

and replace with
$a_show_cols = array('name', 'firstname', 'surname', 'email', 'email2', 'w_tel', 'p_tel', 'w_fax', 'w_mob', 'company', 'w_address', 'w_postcode', 'w_city', 'w_url', 'p_address', 'p_postcode', 'p_city', 'p_url', 'desc');

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

and replace with
    if($col=='name' or $col=='email' or $col=='w_tel' or $col=='company' or $col=='p_address' or $col=='desc')
      $table = new html_table(array('cols' => 2));

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

add just after

         'class' => $microformats[$col],
       ), Q($record[$col]));
     }



    else if (($col=='w_url' || $col=='p_url') && !empty($record[$col])) {  
      $value = html::a(array(
        'href' => $record[$col],
'target' => '_blank',
        'class' => $microformats[$col],
      ), Q($record[$col]));
    }



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

and replace with


    if ($table->size() and ($col=='surname' or $col=='email2' or $col=='w_mob' or $col=='w_url' or $col=='p_url' or $col=='desc'))
      $out .= html::tag('div', array('class' => 'contactdetails-block'),html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label($col.'legend'))) . $table->show($attrib  array('class' => 'vcard'))));
   

  }
  return $out;  






modiefie  how lacri has :
    • /program/steps/mail/autocomplete.inc
    • /skins/default/addresses.css
    • /skins/default/templates/editcontact.html
    • /skins/default/templates/showcontact.html[/I][/B]
    execute on your db this sql script
    ALTER TABLE `contacts` ADD `email2` VARCHAR(128) NOT NULL ;
    ALTER TABLE `contacts` ADD `w_tel` VARCHAR(20) NOT NULL ;
    ALTER TABLE `contacts` ADD `p_tel` VARCHAR(30) 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 `company` VARCHAR(50) NOT NULL ;
    ALTER TABLE `contacts` ADD `w_address` TEXT NOT NULL;
    ALTER TABLE `contacts` ADD `w_postcode` VARCHAR(10) NOT NULL;
    ALTER TABLE `contacts` ADD `w_city` VARCHAR(15) NOT NULL;
    ALTER TABLE `contacts` ADD `w_url` VARCHAR(64) NOT NULL;
    ALTER TABLE `contacts` ADD `p_address` TEXT NOT NULL;
    ALTER TABLE `contacts` ADD `p_postcode` VARCHAR(10) NOT NULL;
    ALTER TABLE `contacts` ADD `p_city` VARCHAR(15) NOT NULL;
    ALTER TABLE `contacts` ADD `p_url` VARCHAR(64) NOT NULL;
    ALTER TABLE `contacts` ADD `desc` TEXT NOT NULL;


    Now, when you add a contact in roundcube, all field are present in your
    thunderbird add book like screenshots
    Title: Global Address Book with additional fields and additional email addresses
    Post by: Aoster on March 16, 2009, 10:43:25 AM
    Hi lacri,

    thank you very much for the patch :-)

    kind regards

    Andreas
    Title: Patch
    Post by: Dan69 on March 19, 2009, 11:19:46 AM
    Hi,
    How can I apply the patch *.diff?
    Thanks
    Dan
    Title: Global Address Book with additional fields and additional email addresses
    Post by: jjhunt on March 24, 2009, 10:02:18 PM
    We're running RoundCube v0.2-stable, and our users are missing the ability to create contact groups.  I just discovered this patch.  We don't really need the global address book feature, but sure could use the ability to allow users to create contact groups, so they can send mail to groups of people easily.  It looks like this patch will do that.

    I also see in the roadmap, that RoundCube will implement contact groups in v0.4.   Will this patch be the basis for that feature implementation?  The reason I ask is that it looks like this patch required changes to the MySQL database.  I'm wondering if that will be compatible with the actual contact group integrated into RoundCube.

    Thanks for any information,
    Jackie
    Title: is this work with virsion 0.3
    Post by: black_13 on August 04, 2009, 11:14:05 AM
    Enybody using global adresbook on version 0.3 ?
    Title: Global Address Book with additional fields and additional email addresses
    Post by: kendokar on August 06, 2009, 03:08:30 AM
    Hi,
    Please I'm sorry for my dumb question..
    Can anyone tell me what for this global addressbook plugin..

    thanks..
    Title: add drop-down menu
    Post by: duyn on September 17, 2009, 11:28:17 AM
    Hi all,

    Thank you for the advanced address book. It's awesome. I would like to know how can I add drop-down menu type in the advanced address book. For example, I want to categorize my contacts list in : friend / family / co-worker etc... It is cool if I can assign each contact to a category using drop-down menu.

    I appreciate for any guidance.


    Thank you
    Title: Global Address book for .3
    Post by: aaronsaks on September 17, 2009, 10:32:50 PM
    Has anyone successfully added the global address patch for version .3?

    I found some lines missing, and it didn't work.

    Any help would be greatly appriciated...

    -Aaron
    Title: HOW TO, current SVN Version for Global Adressbook
    Post by: utiltiy on October 08, 2009, 02:33:15 AM
    Hello,

    i will use the Global Adress Book with the Current SVN Version.

    Have anyone a HOW TO for me in one Post please. I'm not sure whatever it's do change and modified on PHP and MySQL.

    Thanks :)
    Title: Global Address Book with additional fields and additional email addresses
    Post by: JohnDoh on October 08, 2009, 04:26:30 AM
    Making a global address book plugin is really easy - if any one is interested I can put one online this evening. It wont have the extended fields though, since that requires patching the core. I think having a global address book and having more fields are 2 different issues.

    I submitted a patch to the dev mailing list which adds more fields to the address book, I think we are on about version 3 now, you can see the thread here RoundCube Mailing Lists (http://lists.roundcube.net/mail-archive/dev/2009-10/0000006.html) if you want to try it then the SVN version the patch is intended for is in the file name - you need the right SVN version not the 0.3 release.

    Update: A plugin which adds an sql based global address book is available here: http://tehinterweb.co.uk/roundcube/#piglobaladdressbook
    Title: Global Address Book with additional fields and additional email addresses
    Post by: utiltiy on October 08, 2009, 07:22:01 AM
    Did you think the patch comes in one of the next svn-version official?

    For me are the additional settings from the patch enough.
    Title: Global Address Book with additional fields and additional email addresses
    Post by: Xairoo on October 08, 2009, 09:54:14 AM
    I don't think so. They won't add this future.

    Write your own code and never upgrade to the next version :)
    Title: Global Address Book with additional fields and additional email addresses
    Post by: JohnDoh on October 08, 2009, 10:14:15 AM
    utlltiy: the patch wont be applied to the trunk before 0.3.1 but hopefully it or something similar will be added after that. 0.3.1 is mostly bug fixes from 0.3 so it doesnt make sense to add a big new feature which probably has its share of bugs.

    Xairoo: helpful!
    Title: Global Address Book with additional fields and additional email addresses
    Post by: stevetamis on October 09, 2009, 05:36:02 AM
    Hi,Every one

    An electronic mail message consists of two components, the message header, and the message body, which is the email's content. The message header contains control information, including, minimally, an originator's email address and one or more recipient addresses. Usually additional information is added, such as a subject header field.
    Title: Global Address Book with additional fields and additional email addresses
    Post by: voltron81 on February 11, 2010, 05:12:20 AM
    Hello to everybody.
    Does anybody know if there is a plugin like the one of this topic for roundcube 0.3.x?

    I really would like to have a proper address book...

    Thanks
    Michele
    Title: Global Address Book with additional fields and additional email addresses
    Post by: LMSSML on February 12, 2011, 10:49:40 AM
    Hi there,

    Voltron did you found a different solution Iwould like to try another globaladdresscontact plugin

    Is there anyone more ?
    Title: Global Address Book with additional fields and additional email addresses
    Post by: isttoptan on August 15, 2011, 01:26:21 PM
    thank you, nice sharing..