[solved] Share user phonebook with its subusers

Hi Anton,

I want to give access to the phonebook contacts and/or groups of one user to its subusers. How do I configure that scenario?


you can use the same ACL on those users, and set the group to “share with members”, than the contacts will be visible.

just checked it, because i need the same functionality.
i am not able to prohibit the access to shared phonebooks (shared to members only) to groups based on ACL.
if i have an acl with access to feature_phonebook, the user with that acl has access to ALL shared groups and its members…
any ideas?

Hi Andre,

Thanks for your suggestion. I solved it some weeks ago but I did it in code. I changed the query in the phonebook.php file that retrieve the contacts and groups. If you need it here is it:

//Check if user is an ‘user’ or ‘subuser’ getting his parent_uid
if(($parent_uid = user_getparentbyuid($user_config[“uid”])) == FALSE){
$parent_uid = $user_config[“uid”];

            $fields = 'DISTINCT A.id AS pid, A.uid AS uid, A.name AS name, A.mobile AS mobile, A.email AS email, A.tags AS tags';
    $join = 'LEFT JOIN ' . _DB_PREF_ . '_featurePhonebook_group_contacts AS C ON A.id=C.pid ';
    $join .= 'LEFT JOIN ' . _DB_PREF_ . '_featurePhonebook_group AS B ON B.id=C.gpid';
    $conditions = array(
        '( A.uid' => $user_config['uid'] . "' OR B.id in ( 
            SELECT B.id AS id FROM " . _DB_PREF_ . "_featurePhonebook AS A 
            LEFT JOIN " . _DB_PREF_ . "_featurePhonebook_group_contacts AS C ON A.id=C.pid AND A.uid in (SELECT DISTINCT uid From " . _DB_PREF_ . "_tblUser WHERE parent_uid = '" . $user_config['uid'] . "' UNION Select '" . $parent_uid . "') 
                            LEFT JOIN " . _DB_PREF_ . "_featurePhonebook_group AS B ON B.id=C.gpid AND B.flag_sender='1' 
            )" . 
                    ") OR ( B.flag_sender='2' ) OR (B.flag_sender='0' AND A.uid='" . $user_config['uid'] . "') AND '1'='1"

great, thanks for the code, it works. maybe you can check in the code into github so it will survive an update?


please share the phonebook.php see if I can commit it, thx


phonebook.php (17.4 KB)
edit: duplicate file removed.

I see 2 files, which one is it ?


both files are the same…
removed one file.

its been a while and I just notice it, with this changes I can’t seem to search properly on phonebook anymore, can you guys check that

I have several groups and when I searched a group code it shown everyone, not just contacts on searched group

when I switched to the original code the search worked as expected:


Yes, I have to confirm this issue… can you quickly tell me the source code of the search part? then i will compare the statements of searching group code.