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:
# First posted by Helga as
# http://roundcubeforum.net/forum/inde...sg3238#msg3238
# 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 ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Data</b></legend><table>\n\n";
$contact ="<td width=\"45%\" valign=\"top\">\n<fieldset width=\"45%\" class=\"title\"><legend><b>Contact</b></legend><table>\n\n";
$a_show_cols = array('name', 'firstname', 'surname', 'email', '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("<tr><td class=\"title\">%s</td><td>%s</td></tr>\n",
Q(rcube_label($col)),
$value);
}
$out .= "\n</table>";
# with these new lines
$title = Q(rcube_label($col));
if($col == "notice"){
$out2 = "<td colspan=\"3\" width=\"100%\" valign=\"top\"><fieldset width=\"100%\" class=\"title\"><legend><b>$title</b></legend><table>\n";
$out2 .= sprintf("<tr><td>%s</td></tr>\n", $value);
$out2 .= "</table></fieldset></td>\n\n";
}
elseif($col == "p_tel" | $col == "p_fax" | $col == "p_mob" | $col == "w_tel" | $col == "w_fax" | $col == "w_mob"){
if(!$value == ""){
$contact .= sprintf("<tr><td>%s</td><td>%s</td></tr>\n",$title, $value);
}
}
elseif($col == "p_address"){
$p_address = "<td width=\"45%\" valign=\"top\"><fieldset width=\"45%\" class=\"title\"><legend><b>$title</b></legend><table>\n";
$p_address .= sprintf("<tr><td>%s</td></tr>\n", $value);
$p_address .= "</table></fieldset></td>\n\n";
}
elseif($col == "w_address"){
$w_address = "<td width=\"45%\" valign=\"top\"><fieldset width=\"45%\" class=\"title\"><legend><b>$title</b></legend><table>\n";
$w_address .= sprintf("<tr><td>%s</td></tr>\n", $value);
$w_address .= "</table></fieldset></td>\n\n";
}
else{
if($col == "global_contact"){
if($value == 1)
$data .= sprintf("<tr><td>%s</td><td>%s</td></tr>\n",$title, 'Yes');
else
$data .= sprintf("<tr><td>%s</td><td>%s</td></tr>\n",$title, 'No');
} else if(!$value == "")
$data .= sprintf("<tr><td>%s</td><td>%s</td></tr>\n",$title, $value);
}
}
$data .= "</table></td>";
$contact .= "</table></td>";
$out .= "$data<td width=\"2%\">$contact\n\n";
$out .= "</tr><tr>";
$out .= "$p_address<td width=\"2%\">$w_address\n\n";
$out .= "</tr><tr>";
$out .= $out2;
$out .= "\n</tr></table>";
# -------------------------------------------------------------------------------------------------------------
#
# 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:
# Support password modification using CPanel 11
#
# Code written by Danny Herran <danny@ingeniarte.com>
# with small modification by David Loendorf <dloendorf@gmail.com>
# Original post is here http://roundcubeforum.net/forum/inde...sg3155#msg3155
# You can find original code at http://www.ingeniarte.com/rcpasswd.php
# 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
<?php
/*
-----------------------------------------------------------------------
| 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 <danny@ingeniarte.com |
-----------------------------------------------------------------------
$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 <table> 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<table" . $attrib_str . ">\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", $field_id, rep_specialchars_output(rcube_label('confpasswd')), $input_confpasswd->show($CONFIG['confpasswd']));
$out .= "\n</table>$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
<span id="settingstabpasswd" class="tablink"><roundcube:button command="passwd" type="link" label="password" title="changepasswd" class="tablink" /></span>
# -------------------------------------------------------------------------------------------------------------
# Add File /skins/default/templates/passwd.html that contains
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm...sitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<link rel="stylesheet" type="text/css" href="/settings.css" />
</head>
<body>
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
<roundcube:include file="/includes/settingstabs.html" />
<div id="userprefs-box">
<div id="userprefs-title"><roundcube:label name="changepasswd" /></div>
<div style="padding:15px">
<roundcube:object name="userpasswd">
<p><br /><roundcube:button command="save-passwd" type="input" class="button" label="save" /></p>
</div>
</div>
<roundcube:include file="/includes/settingscripts.html" />
</body>
</html>
# -------------------------------------------------------------------------------------------------------------
#
# 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