[kronolith] Two config questions

Michael J Rubinsky mrubinsk at horde.org
Tue Dec 6 05:11:10 UTC 2011


Quoting cjdl01 <cjdl01 at brokensolstice.com>:

> Quoting Michael J Rubinsky <mrubinsk at horde.org>:
>
>> Quoting cjdl01 <cjdl01 at brokensolstice.com>:
>>
>>> (just for a refersher) I'm trying to make is so that my konolith,  
>>> when inviting attendees, parses ALL of the address books to which  
>>> I have access.  Right now, it only does my private, default  
>>> address book.  I use only the localsql backend.  (Incidentally, I  
>>> have the same exact issue with IMP, the auto complete only checks  
>>> my private default address book.)
>>>
>>> So I have a horde/kronolith/config/prefs.local.php with that has  
>>> this, and only this in it:
>>>
>>> <?php
>>> $_prefs['search_sources']['locked'] = true;
>>> $_prefs['search_sources']['hook'] = true;
>>> $_prefs['search_fields']['locked'] = true;
>>> $_prefs['search_fields']['hook'] = true;
>>> =================================================================
>>>
>>>
>>>
>>> I use the localsql backend exclusively, so I have a  
>>> horde/turba/config/backends.local.php that consists of this:
>>>
>>> <?php
>>> /**
>>>
>>> /**
>>> $cfgSources['localsql'] = array(
>>>   'disabled' => false,
>>>   'title' => _("Shared Address Books"),
>>>   'type' => 'sql',
>>>   'params' => array(
>>>       'table' => 'turba_objects'
>>>   ),
>>>   'map' => array(
>>>       '__key' => 'object_id',
>>>       '__owner' => 'owner_id',
>>>       '__type' => 'object_type',
>>>       '__members' => 'object_members',
>>>       '__uid' => 'object_uid',
>>>       'firstname' => 'object_firstname',
>>>       'lastname' => 'object_lastname',
>>>       'middlenames' => 'object_middlenames',
>>>       'namePrefix' => 'object_nameprefix',
>>>       'nameSuffix' => 'object_namesuffix',
>>>       'name' => array('fields' => array('namePrefix', 'firstname',
>>>                                         'middlenames', 'lastname',
>>>                                         'nameSuffix'),
>>>                       'format' => '%s %s %s %s %s',
>>>                       'parse' => array(
>>>                           array('fields' => array('firstname',  
>>> 'middlenames',
>>>                                                   'lastname'),
>>>                                 'format' => '%s %s %s'),
>>>                           array('fields' => array('firstname', 'lastname'),
>>>                                 'format' => '%s %s'))),
>>>       'alias' => 'object_alias',
>>>       'birthday' => 'object_bday',
>>>       'anniversary' => 'object_anniversary',
>>>       'spouse' => 'object_spouse',
>>>       'photo' => 'object_photo',
>>>       'phototype' => 'object_phototype',
>>>       'homeStreet' => 'object_homestreet',
>>>       'homePOBox' => 'object_homepob',
>>>       'homeCity' => 'object_homecity',
>>>       'homeProvince' => 'object_homeprovince',
>>>       'homePostalCode' => 'object_homepostalcode',
>>>       'homeCountry' => 'object_homecountry',
>>>       'homeAddress' => array('fields' => array('homeStreet', 'homeCity',
>>>                                                'homeProvince',
>>>                                                'homePostalCode'),
>>>                              'format' => "%s \n %s, %s  %s"),
>>>       'workStreet' => 'object_workstreet',
>>>       'workPOBox' => 'object_workpob',
>>>       'workCity' => 'object_workcity',
>>>       'workProvince' => 'object_workprovince',
>>>       'workPostalCode' => 'object_workpostalcode',
>>>       'workCountry' => 'object_workcountry',
>>>       'workAddress' => array('fields' => array('workStreet', 'workCity',
>>>                                                'workProvince',
>>>                                                'workPostalCode'),
>>>                              'format' => "%s \n %s, %s  %s"),
>>>       'department' => 'object_department',
>>>       'timezone' => 'object_tz',
>>>       'email' => 'object_email',
>>>       'homePhone' => 'object_homephone',
>>>       'homeFax' => 'object_homefax',
>>>       'workPhone' => 'object_workphone',
>>>       'cellPhone' => 'object_cellphone',
>>>       'assistPhone' => 'object_assistantphone',
>>>       'fax' => 'object_fax',
>>>       'pager' => 'object_pager',
>>>       'title' => 'object_title',
>>>       'role' => 'object_role',
>>>       'company' => 'object_company',
>>>       'logo' => 'object_logo',
>>>       'logotype' => 'object_logotype',
>>>       'category' => 'object_category',
>>>       'notes' => 'object_notes',
>>>       'website' => 'object_url',
>>>       'freebusyUrl' => 'object_freebusyurl',
>>>       'pgpPublicKey' => 'object_pgppublickey',
>>>       'smimePublicKey' => 'object_smimepublickey',
>>>       'imaddress' => 'object_imaddress',
>>>       'imaddress2' => 'object_imaddress2',
>>>       'imaddress3' => 'object_imaddress3'
>>>   ),
>>>   'tabs' => array(
>>>       _("Personal") => array('firstname', 'lastname', 'middlenames',
>>>                              'namePrefix', 'nameSuffix', 'name', 'alias',
>>>                              'birthday', 'spouse', 'anniversary', 'photo'),
>>>       _("Location") => array('homeStreet', 'homePOBox', 'homeCity',
>>>                              'homeProvince', 'homePostalCode',  
>>> 'homeCountry',
>>>                              'homeAddress', 'workStreet', 'workPOBox',
>>>                              'workCity', 'workProvince', 'workPostalCode',
>>>                              'workCountry', 'workAddress', 'timezone'),
>>>       _("Communications") => array('email', 'homePhone', 'workPhone',
>>>                                    'assistPhone', 'homeFax',
>>>                                    'cellPhone', 'fax', 'pager',  
>>> 'imaddress',
>>>                                    'imaddress2', 'imaddress3'),
>>>       _("Organization") => array('title', 'role', 'company',  
>>> 'department', 'logo'),
>>>       _("Other") => array('category', 'notes', 'website', 'freebusyUrl',
>>>                           'pgpPublicKey', 'smimePublicKey'),
>>>   ),
>>>   'search' => array(
>>>       'name',
>>>       'email'
>>>   ),
>>>   'strict' => array(
>>>       'object_id',
>>>       'owner_id',
>>>       'object_type',
>>>   ),
>>>   'export' => true,
>>>   'browse' => true,
>>>   'use_shares' => true,
>>>   'list_name_field' => 'lastname',
>>>   'alternative_name' => 'company',
>>> );
>>>
>>> /**
>>> $cfgSources['prefs'] = array(
>>>   'disabled' => true,
>>>   'title' => _("Private Address Book"),
>>>   'type' => 'prefs',
>>>   'params' => array(
>>>       'name' => 'prefs',
>>>       'charset' => 'UTF-8'
>>>   ),
>>>   'map' => array(
>>>       '__key' => 'id',
>>>       '__type' => '_type',
>>>       '__members' => '_members',
>>>       '__uid' => 'uid',
>>>       'name' => 'name',
>>>       'email' => 'mail',
>>>       'alias' => 'alias'
>>>   ),
>>>   'search' => array(
>>>       'name',
>>>       'email',
>>>       'alias'
>>>   ),
>>>   'strict' => array(
>>>       'id',
>>>       '_type',
>>>   ),
>>>   'export' => true,
>>>   'browse' => true,
>>> );
>>>
>>> /**
>>> $cfgSources['favourites'] = array(
>>>   'disabled' => false,
>>>   'title' => _("Favourite Recipients"),
>>>   'type' => 'favourites',
>>>   'params' => array(
>>>       'limit' => 10
>>>   ),
>>>   'map' => array(
>>>       '__key' => 'email',
>>>       'name' => 'email',
>>>       'email' => 'email'
>>>   ),
>>>   'search' => array(
>>>       'name',
>>>       'email'
>>>   ),
>>>   'strict' => array(
>>>       'id',
>>>   ),
>>>   'export' => true,
>>>   'browse' => true,
>>> );
>>>
>>>
>>> if (!empty($GLOBALS['conf']['imsp']['enabled'])) {
>>>   $_imsp_auth_user = $GLOBALS['prefs']->getValue('imsp_auth_user');
>>>   $_imsp_auth_pass = $GLOBALS['prefs']->getValue('imsp_auth_pass');
>>>   if (!strlen($_imsp_auth_user)) {
>>>       $_imsp_auth_user = $GLOBALS['registry']->getAuth('bare');
>>>       $_imsp_auth_pass =  
>>> $GLOBALS['registry']->getAuthCredential('password');
>>>   }
>>>   $cfgSources['imsp'] = array(
>>>       'disabled' => true,
>>>       'title' => _("IMSP"),
>>>       'type' => 'imsp',
>>>       'params' => array(
>>>           'server'  => $GLOBALS['conf']['imsp']['server'],
>>>           'port'    => $GLOBALS['conf']['imsp']['port'],
>>>           'auth_method' => $GLOBALS['conf']['imsp']['auth_method'],
>>>           'socket'  => isset($GLOBALS['conf']['imsp']['socket']) ?
>>>                        $GLOBALS['conf']['imsp']['socket'] .  
>>> $_imsp_auth_user . '.sck' :
>>>                        '',
>>>           'command' => isset($GLOBALS['conf']['imsp']['command']) ?
>>>                        $GLOBALS['conf']['imsp']['command'] : '' ,
>>>           'auth_mechanism' =>  
>>> isset($GLOBALS['conf']['imsp']['auth_mechanism']) ?
>>>                                
>>> $GLOBALS['conf']['imsp']['auth_mechanism'] : '',
>>>           'username' => $_imsp_auth_user,
>>>           'password' => $_imsp_auth_pass,
>>>           'name' => $_imsp_auth_user,
>>>           'group_id_field' => 'group',
>>>           'group_id_value' => 'group',
>>>           'contact_ownership' => false,
>>>           'my_rights' => '',
>>>           ),
>>>       'map' => array(
>>>           '__key' => 'name',
>>>           '__type' => '__type',
>>>           '__members' => '__members',
>>>           '__owner' => '__owner',
>>>           '__uid' => '__uid',
>>>           'name' => 'fullname',
>>>           'email' => 'email',
>>>           'alias' => 'alias',
>>>           'company' => 'company',
>>>           'notes' => 'notes',
>>>           'workPhone' => 'phone-work',
>>>           'fax' => 'fax',
>>>           'homePhone' => 'phone-home',
>>>           'cellPhone' => 'cellphone',
>>>           'freebusyUrl' => 'freebusyUrl'
>>>           ),
>>>       'search' => array(
>>>           'name',
>>>           'email',
>>>           'alias',
>>>           'company',
>>>           'homePhone'
>>>           ),
>>>       'strict' => array(),
>>>       'export' => true,
>>>       'browse' => true,
>>>       'use_shares' => false,
>>>       );
>>>
>>>   /**
>>>    if (empty($cfgSources['imsp']['use_shares']) &&  
>>> !empty($cfgSources['imsp']['enabled'])) {
>>>        try {
>>>           $result =  
>>> Horde_Core_Imsp_Utils::getAllBooks($cfgSources['imsp']);
>>>           $resultCount = count($result);
>>>           for ($i = 0; $i < $resultCount; ++$i) {
>>>               $dup = false;
>>>               foreach ($cfgSources as $key => $thisSource) {
>>>                   if (($thisSource['type'] == 'imsp') &&
>>>                       ($thisSource['params']['name'] ==  
>>> $result[$i]['params']['name'])) {
>>>
>>>                       $dup = true;
>>>                       $acl = $result[$i]['params']['my_rights'];
>>>                       $cfgSources[$key]['params']['my_rights'] = $acl;
>>>                       break;
>>>                   }
>>>               }
>>>               if (!$dup) {
>>>                   $cfgSources[$result[$i]['params']['name']] = $result[$i];
>>>               }
>>>           }
>>>       } catch (Horde_Imsp_Exception $e) {
>>>           $GLOBALS['notification']->push($e->getMessage());
>>>       }
>>>    }
>>> }
>>> /* End IMSP sources. */
>>> =====================================================================================
>>>
>>>
>>>
>>>
>>> My horde/kronolith/config/hooks.php has this and only this in it:
>>>
>>> <?php
>>> class Kronolith_Hooks
>>> {
>>>   /**
>>>    * Adds user-defined AJAX action handlers.
>>>    *
>>>    * @param string $action         The AJAX action.
>>>    * @param Horde_Variables $vars  The URL parameters.
>>>    *
>>>    * @return mixed  The data to send to the browser (will be JSON encoded).
>>>    * @throws Horde_Exception
>>>    */
>>>    public function ajaxaction($action, $vars)
>>>    {
>>>       switch ($action) {
>>>       case 'Foo':
>>>           return 'bar';
>>>       }
>>>
>>>       throw new Horde_Exception('Unknown action');
>>>    }
>>>
>>> }
>>> ============================================================================================
>>>
>>>
>>>
>>> It still does not work.  What am I missing here?
>>
>>
>> What about the hook for the search_soruces value? You configured a  
>> hook, but I don't see it in the information you posted above.
>>
>> -- 
>> mike
>
> I was directed not to do that earlier in this thread... (not by you,  
> of course ;) )
>
> So, I think I know what you mean, but I'm not sure I got the syntax  
> right.  I put this in my horde/kronolith/config/prefs.local.php:
>
> $_prefs['search_sources'] = array(
>     'value' => 'localsql'
> );
>
> I also tried this:
>
> $_prefs['search_sources'] = array(
>     'value' => json_encode(array('localsql'))
> );
>
> Neither is working, so this must be wrong. Can you give me an  
> example of how this works?

localsql won't work if you are using shares (which Turba does out of  
the box), since each address book/share has it's own unique id. If you  
want to pre-populate and lock this preference you need to use a hook.  
There is *no* way to know at configuration time what the value of this  
prefs should be for every user. I've not tried to do this personally  
though, so there very well may be a reason why the prefs hook can't  
determine the correct values. You said you tried a hook earlier but  
were told not to? What was the reason, and what was your hook?

If you don't want to pre-populate or lock this preference for a  
specific reason, then you should just use the prefs UI to add all of  
your address books to this pref.

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org


More information about the kronolith mailing list