Opened 10 years ago

Closed 6 years ago

#1442732 closed Feature Patches (fixed)

Global addressbook (per domain)

Reported by: nobody Owned by: nobody
Priority: 5 Milestone: later
Component: Addressbook Version: 0.1-beta
Severity: minor Keywords: addressbook

Description (last modified by thomasb)

Although I have already hacked it into .1 beta...

One of the biggest reasons I was unhappy with
SquirrelMail? was their lack of a globally available, on
a per domain basis level, address book.

I was easily able to integrate this into the beta
release of RoundCube and would hope to see it in the

Great program thus far though.

Change History (10)

comment:1 Changed 10 years ago by smueller72

Logged In: YES 

I am looking for this same type of functionality.  Care to
share your hack?  

Is this something that is planned to be included in an
upcoming release?  I would prefer to wait for the 'official'
release rather than hack.  

comment:2 Changed 10 years ago by nobody

Logged In: NO 

Supply a patch for your hack?

comment:3 Changed 10 years ago by nobody

Logged In: NO 

First off, added a column to the contacts table, user_domain
Then, when someone logs in, I use pregs to strip off the
domain name from the email address and add that to a
The files I had to change were:

***index.php around line 191:***
//see the else clause:
// log in to imap server
if (!empty($_SESSION['user_id']) && $_task=='mail')
  $conn = $IMAP->connect($_SESSION['imap_host'],
decrypt_passwd($_SESSION['password']), $_SESSION['imap_port
  if (!$conn)
    show_message('imaperror', 'error');
    $_SESSION['user_id'] = '';
  else {
    //  20060303 PS - Get the user's domain they typed in. 
For use with address book functionality.
    $parts = explode("@", $_SESSION['username']);
    $_SESSION['user_domain'] = $parts[1];

Then in the 3 address book folder's files I changed the
query that was called.  This query is called once or twice
in each of these 3 files.  My query is only slightly
different, it searches the user_domain col. I made in the
contacts table.
My query:
 $DB->query("SELECT * FROM ".get_table_name('contacts')."
              WHERE  contact_id=?
              AND    ( user_id=? OR
user_domain='{$_SESSION["user_domain"]}' )
              AND    del<>1",

The same query is made in the program/steps/mail/
Basically whenever you see the userid=?, just add the OR
clause I put in there.  Pretty basic really.

Sorry I didnt post it sooner.

comment:4 Changed 10 years ago by mrsticks1982

Logged In: YES 

OK, Ive logged in now.  I created this thread, and it's my
hack Ive posted.  

I neglected to go into a little more detail.

At the moment, since I havent started using roundcube
exclusively, I never actually coded the process whereby the
user's domain ACTUALLY gets inserted into the DB.  I just
logged in once, manually updated that user's DB entry to
include his domain in the user_domain col.

And at this point, the code of roundcube is written so that
you cant delete these domain global addresses.  This has to
do with the user_id being set to 0 in the contacts table and
the user_domain field filled in.

I think thats about it.


comment:5 Changed 10 years ago by thomasb

  • Description modified (diff)
  • Milestone 0.1-beta2 deleted
  • Severity changed from critical to minor
  • Version later deleted


comment:6 Changed 10 years ago by thomasb

  • Milestone set to later
  • Version set to 0.1-beta

comment:7 Changed 8 years ago by seansan

  • Keywords addressbook added
  • Milestone changed from later to 0.2-beta
  • Summary changed from Per Domain Global Contacts/Address Book to Global addressbook (per domain)
  • Type changed from Feature Requests to Patches

Review as part of update to AB in Milestone: 0.2-beta

comment:8 follow-up: Changed 7 years ago by thomasb

  • Milestone changed from 0.2-beta to 0.5-beta

comment:9 in reply to: ↑ 8 Changed 7 years ago by mdasberg

Fixed it for version 0.2-beta.

First off, added a column to the contacts table, user_domain varchar(255).

next we need to change some things.

Open program/include/rcube_contacts.php:

  • find the following: function list_records($cols=null, $subset=0) {
  • add:

global $RCMAIL;
$domain = $RCMAIL->user->get_user_domain();

  • find the following: AND (user_id=? OR global_contact = 1)".
  • replace with: AND (user_id=? OR (global_contact = 1 AND user_domain = '$domain'))".

Open program/include/rcube_user.php:

  • add:


  • Extracts the domain name from the user login. *
  • @return string Domain */

function get_user_domain()

return substr($this->datausername?, strpos($this->datausername?, '@') + 1);


thats about it.

Kind regards,


comment:10 Changed 6 years ago by alec

  • Component changed from Core functionality to Addressbook
  • Milestone changed from 0.5-beta to later
  • Resolution changed from None to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.