[kronolith] Default external calendar

Gerard Breiner gerard.breiner at ias.u-psud.fr
Fri Apr 6 14:16:02 UTC 2012


Le 06/04/2012 15:58, Gerard Breiner a écrit :
> Le 06/04/2012 15:04, Jan Schneider a écrit :
>>
>> Zitat von Gerard Breiner <gerard.breiner at ias.u-psud.fr>:
>>
>>> Le 06/04/2012 13:40, Jan Schneider a écrit :
>>>>
>>>> Zitat von Gerard Breiner <gerard.breiner at ias.u-psud.fr>:
>>>>
>>>>> Le 19/03/2012 16:41, Gerard Breiner a écrit :
>>>>>> Le 19/03/2012 09:36, Jan Schneider a écrit :
>>>>>>>
>>>>>>> Zitat von gerard breiner <gerard.breiner at ias.u-psud.fr>:
>>>>>>>
>>>>>>>> gerard breiner <gerard.breiner at ias.u-psud.fr> a écrit :
>>>>>>>>
>>>>>>>>> Jan Schneider <jan at horde.org> a écrit :
>>>>>>>>>
>>>>>>>>>> Zitat von gerard breiner <gerard.breiner at ias.u-psud.fr>:
>>>>>>>>>>
>>>>>>>>>>> Jan Schneider <jan at horde.org> a écrit :
>>>>>>>>>>>
>>>>>>>>>>>> Zitat von Gerard Breiner <gerard.breiner at ias.u-psud.fr>:
>>>>>>>>>>>>
>>>>>>>>>>>>> Le 14/02/2012 15:37, Jan Schneider a écrit :
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Zitat von Martin Hochreiter <linuxbox at wavenet.at>:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> You cannot simply replace strings in the value copied 
>>>>>>>>>>>>>>>> from the database, because it is a serialized hash. 
>>>>>>>>>>>>>>>> Using $registry in prefs.local.php is not a good idea 
>>>>>>>>>>>>>>>> either.
>>>>>>>>>>>>>>>> Instead you should create a preference hook that builds 
>>>>>>>>>>>>>>>> the hash, and return it serialized.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> what a pitty :)  ... ok, thank you I will create a hook 
>>>>>>>>>>>>>>> for that (new world for me...)
>>>>>>>>>>>>>>> What should I use instead of the $registry variable to 
>>>>>>>>>>>>>>> get the credentials - or is it ok
>>>>>>>>>>>>>>> to use it in the hooks?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The prefs_init hook already gets the user name passed.
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Hello ,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I'm working on this too... So I followed the above Jan's 
>>>>>>>>>>>>> advice  and as well as read the very good doc 
>>>>>>>>>>>>> /horde/config/hooks.php.dist (many thanks for all the 
>>>>>>>>>>>>> work). The result is that I managed to create the remote 
>>>>>>>>>>>>> calendar by working with prefs and hooks.local.php.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is what I've done :
>>>>>>>>>>>>> kronolit/config/prefs.local.php
>>>>>>>>>>>>>
>>>>>>>>>>>>> [CODE]
>>>>>>>>>>>>> // remote calendars
>>>>>>>>>>>>> $_prefs['remote_cals'] = array(
>>>>>>>>>>>>> 'value' => '',
>>>>>>>>>>>>> 'hook' => 'true',
>>>>>>>>>>>>> 'locked' => 'false'
>>>>>>>>>>>>> );
>>>>>>>>>>>>> [/CODE]
>>>>>>>>>>>>>
>>>>>>>>>>>>> [CODE]
>>>>>>>>>>>>> kronolith/config/hooks.local.phpclass Kronolith_Hooks
>>>>>>>>>>>>> {
>>>>>>>>>>>>> public function prefs_init($prefs, $value, $username, 
>>>>>>>>>>>>> $scope_ob)
>>>>>>>>>>>>> {
>>>>>>>>>>>>>  switch ($prefs) {
>>>>>>>>>>>>>       case 'remote_cals':
>>>>>>>>>>>>>            $no_serialize = array(array('name'=>'Calendar',
>>>>>>>>>>>>>                                        
>>>>>>>>>>>>> 'url'=>'https://myurl/caldav.php/' .$username. '/agenda',
>>>>>>>>>>>>>                                        'user'=> $username
>>>>>>>>>>>>>  //                                    'password' => 
>>>>>>>>>>>>> $password
>>>>>>>>>>>>>                                  )
>>>>>>>>>>>>>                           );
>>>>>>>>>>>>>          $value = serialize($no_serialize);
>>>>>>>>>>>>>          return $value;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> [/CODE]
>>>>>>>>>>>>>
>>>>>>>>>>>>> Nevertheless at this time I don't know how to catch the 
>>>>>>>>>>>>> password... If Jan look at this again I would appreciate a 
>>>>>>>>>>>>> little more hints about this last issue.
>>>>>>>>>>>>
>>>>>>>>>>>> Try $GLOBALS['registry']->getAuthCredential('password')
>>>>>>>>>>>>
>>>>>>>>>>>> Jan.
>>>>>>>>>>>>
>>>>>>>>>>>> -- 
>>>>>>>>>>>> The Horde Project
>>>>>>>>>>>> http://www.horde.org/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> -- 
>>>>>>>>>>>> Kronolith mailing list
>>>>>>>>>>>> Frequently Asked Questions: http://horde.org/faq/
>>>>>>>>>>>> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
>>>>>>>>>>>
>>>>>>>>>>> Many thanks Jan for this advice... This command give the 
>>>>>>>>>>> password without encodage (I tried it in admin/phpshell.php 
>>>>>>>>>>> ). Nevertheless  it seems that username and password are 
>>>>>>>>>>> expecting as something like : 
>>>>>>>>>>> s:4:"user";s:12:"PYnhqb8tbok=";s:8:"password";s:15:"PQ7F+FGnp7t="; 
>>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>>> Sorry?
>>>>>>>>>>
>>>>>>>>>> -- 
>>>>>>>>>> The Horde Project
>>>>>>>>>> http://www.horde.org/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> -- 
>>>>>>>>>> Kronolith mailing list
>>>>>>>>>> Frequently Asked Questions: http://horde.org/faq/
>>>>>>>>>> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
>>>>>>>>>
>>>>>>>>> Probably misunderstanding from me... So followed your idea for 
>>>>>>>>> catching the password, here is what is my code now :
>>>>>>>>>
>>>>>>>>> kronolith/config/hooks.local.php
>>>>>>>>>
>>>>>>>>> [CODE]
>>>>>>>>> class Kronolith_Hooks
>>>>>>>>> {
>>>>>>>>>  public function prefs_init($prefs, $value, $username, $scope_ob)
>>>>>>>>>  {
>>>>>>>>>    switch ($prefs) {
>>>>>>>>>        case 'remote_cals':
>>>>>>>>>            $no_serialize = array(array('name'=>'Calendar',
>>>>>>>>>                                        
>>>>>>>>> 'url'=>'https://calendar.ias.u-psud.fr/caldav.php/' 
>>>>>>>>> .$username. '/calendar',
>>>>>>>>>                                        'user'=> $username,
>>>>>>>>>                                        'password' => 
>>>>>>>>> $GLOBALS['registry']->getAuthCredential('password')
>>>>>>>>>                                      )
>>>>>>>>>                                 );
>>>>>>>>>            $value = serialize($no_serialize);
>>>>>>>>>            return $value;
>>>>>>>>>      }
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> [/CODE]
>>>>>>>>>
>>>>>>>>> The remote calendar show up in the kronolith's interface but 
>>>>>>>>> credentials are still requested despite the user and password 
>>>>>>>>> in hooks.local.php.
>>>>>>>>>
>>>>>>>>> Best regards
>>>>>>>>>
>>>>>>>>> Gerard Breiner
>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>>> Kronolith mailing list
>>>>>>>>> Frequently Asked Questions: http://horde.org/faq/
>>>>>>>>> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
>>>>>>>>
>>>>>>>> Hello
>>>>>>>> Just for tests I added a few lines in the above code so that to 
>>>>>>>> save the $value variable in a file. We can see that each keys 
>>>>>>>> has respectively their values and the password is do catching.
>>>>>>>>
>>>>>>>> a:1:{i:0;a:4:{s:4:"name";s:10:"MyCalendar";s:3:"url";s:59:"https://davicalserver/caldav.php/gbreiner/calendar";s:4:"user";s:8:"gbreiner";s:8:"password";s:7:"1testpass2";}} 
>>>>>>>> Having said When I click on agenda (kronolith) and then click 
>>>>>>>> on "MyCalendar" I get the message (color red) saying that login 
>>>>>>>> and password are requested.
>>>>>>>> So I read again the docs into which it is said : "This hook is 
>>>>>>>> ONLY executed on login and preferences are cached during a 
>>>>>>>> user's session". So I'm wondering why I have to put again login 
>>>>>>>> and password in the form of "MyCalendar".
>>>>>>>>
>>>>>>>> I'm wondering where am I wrong....
>>>>>>>
>>>>>>> User name and password need to be encrypted with the user's 
>>>>>>> password and base64 encoded. See 
>>>>>>> Kronolith::subscribeRemoteCalendar(). Or even better: *use* 
>>>>>>> subscribeRemoteCalendar().
>>>>>>>
>>>>>>> Jan.
>>>>>>>
>>>>>> Many thanks Jan!  Works very fine now .....
>>>>>> The code is now :
>>>>>>
>>>>>> kronolith/config/hooks.local.php
>>>>>>
>>>>>> [CODE]
>>>>>> namespace Kronolith\subscribeRemoteCalendar;
>>>>>> use Kronolith\subscribeRemoteCalendar;
>>>>>> class Kronolith_Hooks
>>>>>> {
>>>>>>   public function prefs_init($prefs, $value, $username, $scope_ob)
>>>>>>   {
>>>>>>       switch ($prefs) {
>>>>>>            case 'remote_cals':
>>>>>>                  $password = 
>>>>>> $GLOBALS['registry']->getAuthCredential('password');
>>>>>>                  $info = array(array('name'=>'MyCalendar',
>>>>>>                                             
>>>>>> 'url'=>'https://calendar.ias.u-psud.fr/caldav.php/' .$username. 
>>>>>> '/calendar',
>>>>>>                                             'user'=> $user,
>>>>>>                                             'password' => $password
>>>>>>                                       )
>>>>>>                                );
>>>>>>              $value =  subscribeRemoteCalendar($info);
>>>>>>               return $value;
>>>>>>       }
>>
>>>>>>  }
>>>>>> }
>>>>>> [/CODE]
>>>>>>
>>>>>> kronolith/config/prefs.local.php
>>>>>>
>>>>>> [CODE]
>>>>>> $_prefs['remote_cals'] = array(
>>>>>>   'value' => '',
>>>>>>   'hook' => 'true'
>>>>>> );
>>>>>>
>>>>>> Best regards.
>>>>>>
>>>>>> Gérard Breiner
>>>>>> [/CODE]
>>>>>>
>>>>>>
>>>>> Hello Jan and alls,
>>>>>
>>>>> I come back again about this subject because  what I believed was 
>>>>> working doesn't longer works... I have to recognized that the use 
>>>>> of namespace and *use* keywords are new for me. So for doing 
>>>>> "simple" I use $value = Kronolith::subscribeRemoteCalendar($info); 
>>>>> . Nevertheless, it seems that $value is empty.
>>>>
>>>> Yes. The method doesn't return anything. It does exactly what the 
>>>> method name says. It subscribes a remote calendar.
>>>>
>>>>> Kronolith is 3.016.
>>>>>
>>>>> Here is the kronolith/config/hooks.php :
>>>>>
>>>>> [CODE]
>>>>> class Kronolith_Hooks
>>>>> {
>>>>>    public function prefs_init($prefs, $value, $username, $scope_ob)
>>>>>    {
>>>>> $user = $username;
>>>>>        switch ($prefs) {
>>>>>             case 'remote_cals':
>>>>>                   $password = 
>>>>> $GLOBALS['registry']->getAuthCredential('password');
>>>>>                   $info = array(array('name' => $username,
>>>>>                                       'url' => 
>>>>> 'https://calendar.ias.u-psud.fr/caldav.php/' .$username. '/calendar',
>>>>>                                       'user' => $user,
>>>>>                                       'password' => $password
>>>>>                                      )
>>>>>                                 );
>>>>>               $value = subscribeRemoteCalendar($info);
>>>>>               return $value;
>>>>>        }
>>>>>   }
>>>>>
>>>>> [/CODE]
>>>>>
>>>>> And the prefs['remote-cals'] in kronolith/config/prefs.local.php
>>>>>
>>>>> [CODE]
>>>>> // remote calendars
>>>>> $_prefs['remote_cals'] = array(
>>>>>    'value' => '',
>>>>>    'hook' => 'true'
>>>>> );
>>>>> [/CODE]
>>>>>
>>>>> And the horde.log about kronolith :
>>>>>
>>>>> [LOG]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Load config 
>>>>> file (conf.php; app: kronolith) [pid 28322 on line 865 of "/ww     
>>>>>                                            
>>>>> w/horde4/pear/php/Horde.php"]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Load config 
>>>>> file (hooks.php; app: kronolith) [pid 28322 on line 865 of "/w     
>>>>>                                            
>>>>> ww/horde4/pear/php/Horde.php"]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0002s)
>>>>>        SELECT DISTINCT s.* FROM kronolith_shares s LEFT JOIN
>>>>>          kronolith_shares_users u ON u.share_id = s.share_id LEFT 
>>>>> JOIN
>>>>>          kronolith_shares_groups g ON g.share_id = s.share_id WHERE
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0001s)
>>>>>        SELECT share_id, user_uid, perm FROM kronolith_shares_users 
>>>>> WHERE
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0001s)
>>>>>        SELECT share_id, group_uid, perm FROM 
>>>>> kronolith_shares_groups WHERE
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Horde_Prefs: 
>>>>> Storing preference value (display_remote_cals) [pid 28322 on       
>>>>>                                           line 200 of 
>>>>> "/www/horde4/pear/php/Horde/Prefs.php"]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Horde_Prefs: 
>>>>> Storing preference value (holiday_drivers) [pid 28322 on line      
>>>>>                                            200 of 
>>>>> "/www/horde4/pear/php/Horde/Prefs.php"]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Horde_Prefs: 
>>>>> Storing preference value (display_external_cals) [pid 28322 o      
>>>>>                                           n line 200 of 
>>>>> "/www/horde4/pear/php/Horde/Prefs.php"]
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0001s)
>>>>>        SELECT DISTINCT s.* FROM kronolith_shares s LEFT JOIN
>>>>>          kronolith_shares_users u ON u.share_id = s.share_id LEFT 
>>>>> JOIN
>>>>>          kronolith_shares_groups g ON g.share_id = s.share_id WHERE
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0001s)
>>>>>        SELECT share_id, user_uid, perm FROM kronolith_shares_users 
>>>>> WHERE
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] SQL  (0,0006s)
>>>>> 2012-04-06T11:40:53+02:00 DEBUG: HORDE4 [kronolith] Max memory 
>>>>> usage: 35913728 bytes [pid 28322 on line 476 of "/www/horde4/pe    
>>>>>                                             
>>>>> ar/php/Horde/Registry.php"]
>>>>> [/LOG]
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Best regards.
>>>>>
>>>>> Gérard Breiner
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> kronolith mailing list
>>>>> Frequently Asked Questions: http://wiki.horde.org/FAQ
>>>>> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
>>>>
>>> So, how I can see the subscribe is performed whereas "Remote 
>>> Calendars" doesn't show up anything ?
>>> It doesn't work since I've removed the one I  had created via the 
>>> hook and changed the name of the remote calendar in the hook by 
>>> $username.
>>
>> Either don't call this method from a preference hook, or take a look 
>> at the code of that method and use it inside the preference hook.
>>
>>>  (I recently upgrade by pear, so horde is now 4.0.14 and kronolith 
>>> is 3.0.16). I also migrate again the database horde3 to horde4 to 
>>> assume that all is "right". Nevertheless there is certainly 
>>> something I missed but after working several days on this issue I 
>>> have to recognize I need help. If you could give me some others 
>>> hints for tracking this that would be friendly.
>>>
>>> Many thanks.
>>>
>>> Best regards.
>>>
>>> Gérard Breiner
>>> -- 
>>> kronolith mailing list
>>> Frequently Asked Questions: http://wiki.horde.org/FAQ
>>> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
>>
> Thanks Jan,
> I'd already  look at the code of this method but maybe not enough. It 
> seems that I should a little more  look at  'display_remote_calendars'.
>
> Best regards
>
> Gérard Breiner
>
An idea that comes in my mind... If I don't put 'name' and 'url' in the 
hook I should have to rise an exception  according the code of 
subscribeRemoteCalendar but I do not get the message "You must specify a 
name and a URL." So I'm  wondering if the methode is indeed executed....

[CODE]
if (!(strlen($info['name']) && strlen($info['url']))) {
             throw new Kronolith_Exception(_("You must specify a name 
and a URL."));
         }
[/CODE]


Gérard Breiner




More information about the kronolith mailing list