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

Offline cheongseeker

  • Newbie
  • *
  • Posts: 5
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.
#
#
#
#
# -------------------------------------------------------------------------------------------------------------
#
#
# -------------------------------------------------------------------------------------------------------------
#

Offline justanewuser

  • Newbie
  • *
  • Posts: 2
DB Error: unknown error Query
« Reply #1 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....

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Sounds like you missed to adjust the database ...

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

-Roland
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
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);
« Last Edit: May 03, 2008, 11:47:36 AM by bpat1434 »
 
  

Offline pengyou

  • Newbie
  • *
  • Posts: 3
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?

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
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.
 
  

Offline justanewuser

  • Newbie
  • *
  • Posts: 2
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!

Offline grob85

  • Newbie
  • *
  • Posts: 1
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!

Offline malikhemani

  • Newbie
  • *
  • Posts: 7
Error
« Reply #8 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!
Malik M. Hemani
Graphic Stylus | Print Stylus
Malik@GraphicStylus.net

Visit our latest specials at http://www.graphicstylus.net | http://www.printstylus.net

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
What's the roundcube error log say?
 
  

Offline malikhemani

  • Newbie
  • *
  • Posts: 7
sorry
« Reply #10 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,
Malik M. Hemani
Graphic Stylus | Print Stylus
Malik@GraphicStylus.net

Visit our latest specials at http://www.graphicstylus.net | http://www.printstylus.net

Offline NEComputer

  • Newbie
  • *
  • Posts: 5
Updated Global Address Book Plugin
« Reply #11 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.
# ---------------------------------------------------------

Offline Wup.nu

  • Newbie
  • *
  • Posts: 7
Global Address Book with additional fields and additional email addresses
« Reply #12 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

Offline NEComputer

  • Newbie
  • *
  • Posts: 5
Global Address Book with additional fields and additional email addresses
« Reply #13 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

Lihualee

  • Guest
Knowledge
« Reply #14 on: September 29, 2008, 04:24:41 PM »
bump up lurk