Memo categories and the summary screen

Brian Keifer <[email protected]> Fri, 27 Dec 2002 23:49:37 -0500
Newsgroups gmane.comp.horde.mnemo
Message-ID <[email protected]>
Hi, List.

Mnemo poked me in the eye this morning and said it (he?  she?) felt left out. 
Attached are the necessary files to give Mnemo the ability to limit what
categories of memos are shown on the Horde summary screen.  The attached
showsummaryselect.inc file is new and goes in mnemo/templates/prefs/.

Credit where credit is due:  the code itself is straight from Chuck's commit of
John Morrissey's Nag patch earlier this week.  Thanks, John!

-Brian


-- 
Mnemo mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
mnemo_summary_categories.diff (text/diff, 2.6 KB)
Index: prefs.php
===================================================================
RCS file: /usr/home/cvs/horde/mnemo/prefs.php,v
retrieving revision 1.9
diff -u -r1.9 prefs.php
--- prefs.php	18 Dec 2002 22:54:36 -0000	1.9
+++ prefs.php	28 Dec 2002 04:23:43 -0000
@@ -71,6 +71,15 @@
     }
 }
 
+function handle_showsummaryselect($updated)
+{
+    global $prefs;
+
+    $summary_categories = Horde::getFormData('summary_categories');
+    $prefs->setValue('summary_categories', $summary_categories);
+    return true;
+}
+
 define('MNEMO_BASE', dirname(__FILE__));
 require_once MNEMO_BASE . '/lib/base.php';
 require_once HORDE_BASE . '/lib/PrefsUI.php';
Index: config/prefs.php.dist
===================================================================
RCS file: /usr/home/cvs/horde/mnemo/config/prefs.php.dist,v
retrieving revision 1.9
diff -u -r1.9 prefs.php.dist
--- config/prefs.php.dist	1 Dec 2002 02:34:50 -0000	1.9
+++ config/prefs.php.dist	28 Dec 2002 03:56:12 -0000
@@ -14,7 +14,7 @@
     'column' => _("Other Options"),
     'label' => _("Display Options"),
     'desc' => _("Change your note sorting and display options."),
-    'members' => array('sortby', 'sortdir', 'summary_show_colors'));
+    'members' => array('sortby', 'sortdir', 'summary_show_colors', 'showsummaryselect'));
 
 $prefGroups['share'] = array(
     'column' => _("Other Options"),
@@ -100,6 +100,14 @@
     'value' => 0,
     'locked' => false,
     'shared' => true,
+    'type' => 'implicit');
+
+$_prefs['showsummaryselect'] = array('type' => 'special');
+
+$_prefs['summary_categories'] = array(
+    'value' => '',
+    'locked' => false,
+    'shared' => false,
     'type' => 'implicit');
 
 // Link to the notepad management
Index: lib/api.php
===================================================================
RCS file: /usr/home/cvs/horde/mnemo/lib/api.php,v
retrieving revision 1.11
diff -u -r1.11 api.php
--- lib/api.php	12 Nov 2002 17:20:09 -0000	1.11
+++ lib/api.php	28 Dec 2002 04:20:48 -0000
@@ -81,8 +81,19 @@
 
     $colors = Mnemo::categoryColors();
 
-    $memos = _mnemo_list();
-    foreach ($memos as $id => $memo) {
+    $summaryCategories = explode(';', $prefs->getValue('summary_categories'));
+    $categories = array();
+    if ($summaryCategories != array('')) {
+        foreach ($summaryCategories as $summaryColumn) {
+            list($categories[],) = explode(',', $summaryColumn);
+        }
+    }
+
+    foreach (_mnemo_list() as $id => $memo) {
+        if (!in_array($memo['category'], $categories)) {
+            continue;
+        }
+
         $html .= '  <tr>';
 
         if ($prefs->getValue('summary_show_colors')) {
showsummaryselect.inc (application/octet-stream, 4.6 KB) - not displayed