Re: default category

Brian Keifer <[email protected]> Wed, 12 Mar 2003 19:29:31 -0500
Newsgroups gmane.comp.horde.nag
Message-ID <[email protected]>
Attached is a patch against HEAD that allows users to select a default task
category.  If this one works out, I'll whip up a quick adaptation for mnemo,
too.  categoryselect.inc is a new file, and lives in nag/templates/prefs.

-Brian

-- 
When all else fails, there's always delusion.
--Conan O'Brien


-- 
Nag mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
nag_default_category.diff (text/diff, 2.5 KB)
Index: prefs.php
===================================================================
RCS file: /usr/home/cvs/horde/nag/prefs.php,v
retrieving revision 1.25
diff -u -r1.25 prefs.php
--- prefs.php	3 Jan 2003 12:44:45 -0000	1.25
+++ prefs.php	12 Mar 2003 19:09:20 -0000
@@ -45,6 +45,21 @@
     return false;
 }
 
+function handle_categoryselect($updated)
+{
+    global $prefs;
+
+    $default_task_category = Horde::getFormData('default_task_category');
+    if (!is_null($default_task_category)) {
+        $categories = Nag::listCategories();
+        if (is_array($categories) && isset($categories[$default_task_category])) {
+            $prefs->setValue('default_task_category', $default_task_category);
+            $updated = true;
+        }
+    }
+    return $updated;
+}
+
 function handle_tasklistselect($updated)
 {
     global $prefs;
Index: task.php
===================================================================
RCS file: /usr/home/cvs/horde/nag/task.php,v
retrieving revision 1.39
diff -u -r1.39 task.php
--- task.php	25 Feb 2003 21:51:31 -0000	1.39
+++ task.php	13 Mar 2003 00:16:54 -0000
@@ -29,7 +29,11 @@
     $task_desc = '';
     $task_priority = 3;
     $task_completed = 0;
-    $task_category = 0;
+
+    if (($task_category = $prefs->getValue('default_task_category')) == null) {
+        $task_category = 0;
+    }
+
     $task_alarm = 0;
     $alarm_value = 15;
     $alarm_unit = 'min';  
Index: config/prefs.php.dist
===================================================================
RCS file: /usr/home/cvs/horde/nag/config/prefs.php.dist,v
retrieving revision 1.25
diff -u -r1.25 prefs.php.dist
--- config/prefs.php.dist	4 Mar 2003 20:47:13 -0000	1.25
+++ config/prefs.php.dist	13 Mar 2003 00:26:34 -0000
@@ -41,7 +41,7 @@
     'column'  => _("Other Options"),
     'label'   => _("Category Management"),
     'desc'    => _("Allows categories to be added/removed/renamed."),
-    'members' => array('category_management'));
+    'members' => array('category_management', 'categoryselect'));
 
 
 // user language
@@ -133,6 +133,16 @@
     'shared' => false,
     'type' => 'special',
     'desc' => _("Category Management"));
+
+// default category selection widget
+$_prefs['categoryselect'] = array('type' => 'special');
+
+// default category selection
+$_prefs['default_task_category'] = array(
+    'value' => 0,
+    'locked' => false,
+    'shared' => true,
+    'type' => 'implicit');
 
 // default tasklist selection widget
 $_prefs['tasklistselect'] = array('type' => 'special');
categoryselect.inc (application/octet-stream, 596 B) - not displayed