[prev in list] [next in list] [prev in thread] [next in thread] 

List:       imp
Subject:    [horde] Re: horde_prefs - categories and category_colors
From:       Craig White <craigwhite () azapple ! com>
Date:       2005-02-27 2:27:18
Message-ID: 1109471238.20049.59.camel () lin-workstation ! azapple ! com
[Download RAW message or body]

On Sat, 2005-02-26 at 16:15 -0700, Craig White wrote:
> I am not understanding what is getting written to the horde_prefs
> table...
> 
----
I still don't understand some of the values in this field as discussed
BUT

- I think that I have made a significant breakthrough in setting
preferences.

- This process would be EASILY repeatable for many modules and default
preferences if not most of them...

I am keying on the first name in the Horde Setup -> Admins 
(* Which users should be treated as administrators (root, super-user) by
Horde?)

I make all users 'categories' and 'category colors' derived from
whatever 'Administrator' had set up.

by setting 'hook = true'; in horde/config/prefs.php for 
// categories
$_prefs['categories'] = array(

// category colors
$_prefs['category_colors'] = array(

and then adding to horde/config/hooks.php

if (!function_exists('_prefs_hook_category_colors')) {

   function _prefs_hook_category_colors($user = null)
   {

     $def_value = 'category_colors';

     require_once 'DB.php';
     global $conf;
     $def_user = $conf['auth']['admins'][0];
     $search_params = array($def_user, $def_value);
     $search_string = 'SELECT * FROM horde_prefs WHERE pref_uid = ? \
AND pref_scope = "horde" AND pref_name = ?';
     $db =& DB::connect($conf['sql'], true);
     $res =& $db->query($search_string, $search_params);
     while ($res->fetchInto($row)) {
     $name = $row[3];
     }
     $db->disconnect();
     return $name;
   }
}

if (!function_exists('_prefs_hook_categories')) {

   function _prefs_hook_categories($user = null)
   {

     $def_value = 'categories';

     require_once 'DB.php';
     global $conf;
     $def_user = $conf['auth']['admins'][0];
     $search_params = array($def_user, $def_value);
     $search_string = 'SELECT * FROM horde_prefs WHERE pref_uid = ? \
AND pref_scope = "horde" AND pref_name = ?';
     $db =& DB::connect($conf['sql'], true);
     $res =& $db->query($search_string, $search_params);
     while ($res->fetchInto($row)) {
     $name = $row[3];
     }
     $db->disconnect();
     return $name;
   }
}

----
I have a few thoughts...

1 - this only considers sql preferences backend. Probably wouldn't be
hard to modify for ldap preferences backend. Each 'hook' would require
only that you change 3 entries on the first 5 lines.

2 - this might be worthy of a 'tab' in Horde Setup for 'Default User'
settings which could activate a bunch of 'preset' hooks for commonly
considered default preferences and checkbox activation. Jan asked if I
wanted to offer a patch for this type of logic and this is the path that
I am thinking unless this is objectionable.

3 - If '2' were a logical concept to persue, it would also make sense
for a button alongside the checkbox that did something like
'DELETE FROM horde_prefs WHERE pref_uid != "Administrator" AND pref_name
= $PREFERENCE' so all user preferences were cleared and upon next login
or usage. (of course, this is SQL lingo and LDAP would need to be
accomodated) 

Craig

-- 
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@lists.horde.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic