Author Topic: advanced Adressbook  (Read 50337 times)

Offline keltong

  • Newbie
  • *
  • Posts: 4
Re: advanced Adressbook
« Reply #15 on: May 13, 2007, 11:33:27 AM »
Very cool plugin! :D

Offline phs

  • Newbie
  • *
  • Posts: 9
Re: advanced Adressbook
« Reply #16 on: May 19, 2007, 09:18:21 AM »
Hi helga

very useful plugin, indeed! O0
but i have one little improvement: it would be nice to store multiple email addresses per contact! if you could add this to your advanced addressbook, it would be perfect!

regards
phs

Offline CEC

  • Newbie
  • *
  • Posts: 2
Re: advanced Adressbook
« Reply #17 on: May 27, 2007, 02:25:25 PM »
Is this contribution consistent with the latest stable release. It's not working for me -- significant differences between instructions and what's actually in the files -- e.g., edit, show.  :-\

Offline CEC

  • Newbie
  • *
  • Posts: 2
Re: advanced Adressbook
« Reply #18 on: May 31, 2007, 02:08:55 AM »
Any chance of an updated version of this plugin?  :'(

Offline milko

  • Newbie
  • *
  • Posts: 2
Re: advanced Adressbook
« Reply #19 on: June 08, 2007, 12:40:55 PM »
Vielen Dank für den Service, Helga

Offline kevenages

  • Newbie
  • *
  • Posts: 2
Re: advanced Adressbook
« Reply #20 on: June 15, 2007, 03:47:49 PM »
Quote from: CEC
Is this contribution consistent with the latest stable release. It's not working for me -- significant differences between instructions and what's actually in the files -- e.g., edit, show.  :-\

I'm having the same issue, perhaps someone could do one of 2 things:

1. give updated instructions on the plugin
2. provide the files and simply allow users to overwrite the files to be updated (once backed up, of course)

Thanks, I'd really love to utilize this plugin

Offline Gus

  • Jr. Member
  • **
  • Posts: 16
Re: advanced Adressbook
« Reply #21 on: August 15, 2007, 04:19:45 AM »
Hi,

i've added these changes to the latest RC1 files, and although some of the line numbers were wrong, it all seemed fairly correct and all went OK.
However none of my new contact fields are written back my mySQL table?
I dont get any errors, and i can change the standard fields OK.
Also, i can use phpmyadmin to manually add data to the new fields, and they show OK in the show contact page. but i still cannot edit of the new fields using RC.

Any ideas?

thanks.

Offline oldschool

  • Sr. Member
  • ****
  • Posts: 406
Re: advanced Adressbook
« Reply #22 on: August 15, 2007, 03:00:36 PM »
An update for RC1 would be great...!

Rgds.


Offline fritzferr

  • Newbie
  • *
  • Posts: 1
Re: advanced Adressbook
« Reply #23 on: September 18, 2007, 02:35:08 PM »
This thread looks like it has winded down. After review I'm not sure where it stands - did the latest RC have the advanced address book in it? When I went through the sql statements it didn't appear to be the case, but I don't know enough to be sure.

Personally, I'd love to have advance stuff in there...

FF

GunFro

  • Guest
Re: advanced Adressbook
« Reply #24 on: September 18, 2007, 03:22:23 PM »
.......................
« Last Edit: July 16, 2011, 12:31:18 PM by GunFro »

Offline dloendorf

  • Jr. Member
  • **
  • Posts: 16
Re: advanced Adressbook
« Reply #25 on: September 20, 2007, 09:08:53 PM »
This is an updated version of the advanced addressbook for RC1. Download and unzip the attached file to a temporary folder. Refer to Helga's original post for setting the language specific file. Rename the following files ../program/include/main.php to main.php.orig, ../program/include/rcube_contacts.inc to rcube_contacts.inc.orig, ../program/steps/addressbook/edit.inc to edit.inc.orig, ../program/steps/addressbook/save.inc to save.inc.orig, ../program/steps/addressbook/show.inc to show.inc.orig.

Replace the files renamed above with the files from the temporary zip folder. When you are certain the new files work correctly, you can remove the .orig files.

OK! I am not allowed to post a zip file. If you are interested in receiving a zip file, send me a message. Trying to delineate line numbers where to delete and insert is too hard. :(

David


Offline dloendorf

  • Jr. Member
  • **
  • Posts: 16
Re: advanced Adressbook
« Reply #26 on: October 08, 2007, 12:19:56 AM »
Here are the updates required for the advanced address book in rc1. These updates also include the global contact option.

The line numbers for inserts may not be exact depending on the version of rc1 you are using.

If you have any questions as to where modification should go, do not hesitate to contact me.

Remember - backup or make copies of all original files before making any modifications suggested here.

Code: [Select]
# First posted by Helga as
# [url]http://roundcubeforum.net/forum/index.php?topic=737.msg3238#msg3238[/url]
# Modified by David Loendorf for RC1 and global contact option

# -------------------------------------------------------------------------------------------------------------
#
# In file /program/include/rcube_contacts.inc
#
# Replace Line 31 with
 var $table_cols = array('name', 'firstname', 'surname', 'email', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');
# Replace Line 145 with
     AND  (user_id=? OR global_contact = 1)" .
# Replace Line 216
    AND  (user_id=? OR global_contact = 1)".
# Replace Line 251 with
    AND  (user_id=? OR global_contact = 1)
# Replace Line 342 with
     AND  (user_id=? OR global_contact = 1)

# -------------------------------------------------------------------------------------------------------------
#
# In file /program/include/main.inc
#
# Find the line that reads: if ($type=='checkbox')
# It should be around Line 1230
# Replace with
 if($col == "notice")
  {
$attrib['rows'] = "8";
$attrib['size'] = "40";
$attrib['cols'] = "40";
$input = new textarea($attrib);
}
 elseif($col == "p_address" | $col == "w_address")
  {
$attrib['rows'] = "4";
$attrib['size'] = "40";
$attrib['cols'] = "40";
$input = new textarea($attrib);
}
 else if ($type=='checkbox')

# -------------------------------------------------------------------------------------------------------------
#
# In File /program/localization/en_US/label.inc
# Insert after line 163
$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';

# -------------------------------------------------------------------------------------------------------------
#
# In file /program/steps/addressbook/edit.inc
# Replace Line 64 with
 $a_show_cols = array('name', 'firstname', 'surname', 'global_contact', 'email', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');

# Insert after line that contains: $attrib['id'] = 'rcmfd_'.$col; (should be line 67 or 68)
  if($col == "global_contact")
  $value = rcmail_get_edit_field($col, $record[$col], $attrib, 'checkbox');
  else

# -------------------------------------------------------------------------------------------------------------
#
# In file /program/steps/addressbook/save.inc
# Replace line 40 with
$a_save_cols = array('name', 'firstname', 'surname', 'email', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');

# Replace Line 48 with

 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);
 }

# -------------------------------------------------------------------------------------------------------------
#
# In file /program/steps/addressbook/show.inc
# Replace Line 46 with
 $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', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'w_address', 'notice');

#
# Replace Old Lines that contain the following (beginning around line 59-62)
  $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;;

# with these new lines

$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;;

# -------------------------------------------------------------------------------------------------------------
#

# Database Additions for extended contact information
#
# 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 `rc_contacts` ADD `global_contact` TINYINT(1) NOT NULL default '0';
 ALTER TABLE `rc_contacts` ADD `firm` VARCHAR(128) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `position` VARCHAR(50) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `p_tel` VARCHAR(30) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `p_fax` VARCHAR(30) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `p_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `p_address` TEXT NOT NULL;
 ALTER TABLE `rc_contacts` ADD `w_tel` VARCHAR(20) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `w_fax` VARCHAR(20) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `w_mob` VARCHAR(20) NOT NULL ;
 ALTER TABLE `rc_contacts` ADD `w_address` TEXT NOT NULL;
 ALTER TABLE `rc_contacts` ADD `notice` TEXT NOT NULL;

If you would also like to allow your users to modify their passwords while in RC and your ISP supports CPanel 11 make the following updates
Code: [Select]
# Support password modification using CPanel 11
#
#  Code written by Danny Herran
#  with small modification by David Loendorf
#  Original post is here [url]http://roundcubeforum.net/forum/index.php?topic=711.msg3155#msg3155[/url]
#  You can find original code at [url]http://www.ingeniarte.com/rcpasswd.php[/url]
#  All of this is included below plus the few modifications I have made.

# In file /program/js/app.js

# Replace Line 264 with
    this.enable_command('preferences', 'identities', 'save', 'folders', 'passwd', true);

# Insert after Line 274
    if (this.env.action=='passwd' || this.env.action=='save-passwd')
     {
     var input_curpasswd = rcube_find_object('_curpasswd');
     var input_newpasswd = rcube_find_object('_newpasswd');
     var input_confpasswd = rcube_find_object('_confpasswd');
     if (input_curpasswd && input_curpasswd.value=='')
       input_curpasswd.focus();
     else if (input_confpasswd)
       input_confpasswd.focus();

     this.enable_command('save-passwd', true);
     }

# Insert after old Line 932 new Line 945
    break;

   case 'passwd':
    this.goto_url('passwd');
    break;

   case 'save-passwd':
    var input_curpasswd = rcube_find_object('_curpasswd');
    var input_newpasswd = rcube_find_object('_newpasswd');
    var input_confpasswd = rcube_find_object('_confpasswd');
    if (input_curpasswd && input_curpasswd.value=='')
      {
        alert(this.get_label('nocurrentpassword'));
        input_curpasswd.focus();
      }
    else if ((input_newpasswd && input_newpasswd.value=='') && (input_confpasswd && input_confpasswd.value==''))
      {
        alert(this.get_label('nopassword'));
        input_newpasswd.focus();
      }
    else if ((input_newpasswd && input_confpasswd) && ( input_newpasswd.value != input_confpasswd.value))
      {
        alert(this.get_label('passwordinconsistency'));
        input_newpasswd.focus();
      }
    else
        this.gui_objects.editform.submit();

# -------------------------------------------------------------------------------------------------------------

# In file /program/localizations/en_US/labels.inc

# Insert before the last line

$labels['changepasswd'] = 'Change Password';
$labels['curpasswd'] = 'Current Password';
$labels['newpasswd'] = 'New Password';
$labels['confpasswd'] = 'Confirm New Password';

# -------------------------------------------------------------------------------------------------------------

# In file /program/localizations/en_US/messages.inc

# Insert after line 78
$messages['nocurrentpassword'] = "Please input current password.";
$messages['nopassword'] = "Please input new password.";
$messages['passwordinconsistency'] = "Inconsistency of password, please try again.";

# -------------------------------------------------------------------------------------------------------------

# Add File /program/steps/settings/passwd.inc that contains


/*
 -----------------------------------------------------------------------
 | program/steps/settings/passwd.inc                  |
 |                                   |
 | This file is part of the RoundCube Webmail client          |
 | Copyright (C) 2007, RoundCube Dev. - Switzerland          |
 | Licensed under the GNU GPL                     |
 |                                   |
 | PURPOSE:                              |
 |  Change IMAP user password ONLY FOR cPanel 11 installations!    |
 |                                   |
 | REQUIREMENTS:                            |
 |  PHP with cURL installed, cPanel 11                |
 |                                   |
 -----------------------------------------------------------------------
 | Author: Danny Herran  -----------------------------------------------------------------------

 $Id: passwd.inc,v 0.2 2007/06/08 11:16:03 roundcube Exp $

*/

function rcmail_save_passwd($curpasswd, $newpasswd){
 global $CONFIG, $_SESSION, $OUTPUT;

 //Basically this sends a request to dopasswdpop.html and change the password for the IMAP account
 //this is different from cPanel 10 which uses dowebmailpasswd.cgi instead

 $cpaneluser = $_SESSION['username'];
 $cpanelpass = $curpasswd;
 $data=explode('@', $_SESSION['username']);
 $domain=$data[1];
 $uname=$data[0];

 // First do a check if curl_init exists:
 if (function_exists("curl_init")) {
  $authstr = "$cpaneluser:$cpanelpass";
  $postfields="email=$uname&domain=$domain&password=$newpasswd";

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $domain.":2095/webmail/x3/mail/dopasswdpop.html");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_USERPWD, $authstr);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);


  $cbsreturn = curl_exec($ch);
//  echo "Result: " . $cbsreturn; // Returns all the html from cPanel, uncomment to view (debugging)

  if ((strpos($cbsreturn, "successfully modified")) and (!strpos($cbsreturn, "result in failure"))) {
//We update the password for the current session
$_SESSION['password'] = encrypt_passwd($newpasswd);
   curl_close($ch);
   return true;
  } else {
   curl_close($ch);
   return false;
  }
 }
}


function rcmail_passwd_form($attrib){
 global $CONFIG, $OUTPUT;

 list($form_start, $form_end) = get_form_tags($attrib, 'save-passwd');
 unset($attrib['form']);

 if (!$attrib['id'])
  $attrib['id'] = 'rcmSavepassword';

 // allow the following attributes to be added to the tag
 $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));

 // return the complete edit form as table
 $out = "$form_start\n\n";

 $a_show_cols = array('curpasswd'  => array('type' => 'text'), 'newpasswd'  => array('type' => 'text'), 'confpasswd'  => array('type' => 'text'));

 // show current password field
 $field_id = 'curpasswd';
 $input_curpasswd = new passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 'size' => 30));

 $out .= sprintf("
\n", $field_id, rep_specialchars_output(rcube_label('curpasswd')), $input_curpasswd->show($CONFIG['curpasswd']));

 // show new password selection
 $field_id = 'newpasswd';
 $input_newpasswd = new passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 'size' => 30));

 $out .= sprintf("\n", $field_id, rep_specialchars_output(rcube_label('newpasswd')), $input_newpasswd->show($CONFIG['newpasswd']));

 // show confirm password selection
 $field_id = 'confpasswd';
 $input_confpasswd = new passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 'size' => 30));

 $out .= sprintf("\n", $field_id, rep_specialchars_output(rcube_label('confpasswd')), $input_confpasswd->show($CONFIG['confpasswd']));

 $out .= "\n
%s
%s
%s
$form_end";

 return $out;
}

// Handle user request
if ($_action=='save-passwd'){

 if (!isset($_POST['_curpasswd']))
  $OUTPUT->show_message('errorsaving', 'error');
 else if (!isset($_POST['_newpasswd']))
  $OUTPUT->show_message('errorsaving', 'error');
 else if (rcmail_save_passwd(get_input_value('_curpasswd', RCUBE_INPUT_POST), get_input_value('_newpasswd', RCUBE_INPUT_POST))){
  $OUTPUT->show_message('successfullysaved', 'confirmation');
 } else
  $OUTPUT->show_message('errorsaving', 'error');

 // overwrite action variable
 rcmail_overwrite_action('passwd');

}

// add some labels to client
rcube_add_label('nocurrentpassword');
rcube_add_label('nopassword');
rcube_add_label('passwordinconsistency');
parse_template('passwd');
?>

# -------------------------------------------------------------------------------------------------------------

# In file /skins/default/includes/settingstabs.html

# Insert after Line 2


# -------------------------------------------------------------------------------------------------------------

# Add File /skins/default/templates/passwd.html that contains

[/url]
[/url]

<roundcube:object name="pagetitle" />

























# -------------------------------------------------------------------------------------------------------------
#
# In File index.php
#
# Insert after line that reads:  include_once('program/steps/settings/func.inc'); (about line 343)

 if (($_action=='passwd') or ($_action=='save-passwd'))
  include('program/steps/settings/passwd.inc');

David

Offline Rudy

  • Jr. Member
  • **
  • Posts: 17
Re: advanced Adressbook
« Reply #27 on: October 08, 2007, 03:03:51 AM »
Works like a charm. Thanks a lot! Is there any way to implement multiple E-Mail addresses for one contact in this plugin/mod?

Offline dloendorf

  • Jr. Member
  • **
  • Posts: 16
Re: advanced Adressbook
« Reply #28 on: October 08, 2007, 08:46:01 AM »
Of course, the short answer is Yes - But...

I am leaving for Europe a week from today, so will probably not have a chance to look into adding that function. Come mid-January, when I return, if someone else has not implemented it, I will be happy to make an attempt.

David

Offline Rudy

  • Jr. Member
  • **
  • Posts: 17
Re: advanced Adressbook
« Reply #29 on: October 08, 2007, 03:23:09 PM »
I just found a little typo in your instructions: :)

Code: [Select]
# Replace Line 46 with
 $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', 'global_contact', 'firm', 'position', 'p_tel', 'p_fax', 'p_mob', 'p_address', 'w_tel', 'w_fax', 'w_mob', 'g_adresse', 'notice');

Last line, there it should say "w_address" instead of "g_adresse".