Distinction between shared task lists
Brian Keifer <[email protected]>
| Newsgroups | gmane.comp.horde.nag |
|---|---|
| Message-ID | <[email protected]> |
Hi, list. I'm getting ready to roll out a horde mini-intranet for our little group of sysadmins. One of the things that Nag is missing is the ability to see multiple users' task lists but also have some way to identify what tasks belong to which user. A couple of hours and a few cans of Mountain Dew(tm) later, I give you the attached diff. It adds several features to Nag: 1) A preference to show/hide the username of each task's owner in the summary view. See it in action at: http://valinor.net/ss/tasks_username_patch1.png 2) A preference to group task lists by username. If this is enabled, the tasks are grouped by username and then sorted by whatever your default sort criteria is. For example, sorting by priority used to give you: Sue - 1 - Buy more Dew Joe - 2 - Fix the window Sue - 3 - Feed the badgers Tom - 4 - Mop the floor Sue - 5 - Paint the fence With this pref enabled, it would be more like this: Sue - 1 - Buy more Dew Sue - 3 - Feed the badgers Sue - 5 - Paint the fence Joe - 2 - Fix the window Tom - 4 - Mop the floor 3) In Nag's task list, an extra column has been added that displays the username. The obligatory screenshot is at: http://valinor.net/ss/tasks_username_patch2.png Take a look at the patch and kick the tires. Commit it if you like, hack it to bits if you don't. =) -Brian -- Nag mailing list Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQA9yeaQ55GV4qHJVdYRAj93AJ0T0DUhlu72eLAE5Orin4/HJQpVVQCdHeev xat6kZiXHi7yFcDhTjDrV3o= =T+sR -----END PGP SIGNATURE-----
nag_usernames.diff
(application/octet-stream, 8.6 KB)
Index: config/prefs.php.dist
===================================================================
RCS file: /repository/nag/config/prefs.php.dist,v
retrieving revision 1.17
diff -u -r1.17 prefs.php.dist
--- config/prefs.php.dist 29 Sep 2002 03:18:27 -0000 1.17
+++ config/prefs.php.dist 7 Nov 2002 03:53:10 -0000
@@ -14,7 +14,7 @@
'column' => _("Other Options"),
'label' => _("Display Options"),
'desc' => _("Change your task sorting and display options."),
- 'members' => array('sortby', 'sortdir', 'summary_show_priorities', 'summary_show_due', 'show_completed'));
+ 'members' => array('group_by_username', 'sortby', 'sortdir', 'summary_show_priorities', 'summary_show_due', 'show_completed', 'summary_show_usernames'));
$prefGroups['share'] = array(
'column' => _("Other Options"),
@@ -37,6 +37,14 @@
'type' => 'select',
'desc' => _("Select your preferred language:"));
+// group tasks by username?
+$_prefs['group_by_username'] = array(
+ 'value' => 1,
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'checkbox',
+ 'desc' => _("Group tasks by username?"));
+
// user preferred sorting column
$_prefs['sortby'] = array(
'value' => NAG_SORT_PRIORITY,
@@ -86,6 +94,15 @@
'shared' => false,
'type' => 'checkbox',
'desc' => _("Show due dates in the summary view?"));
+
+// show task list name in summary?
+$_prefs['summary_show_usernames'] = array(
+ 'value' => 1,
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'checkbox',
+ 'desc' => _("Show usernames in the summary view?"));
+
// user task categories
$_prefs['task_categories'] = array(
Index: lib/Nag.php
===================================================================
RCS file: /repository/nag/lib/Nag.php,v
retrieving revision 1.55
diff -u -r1.55 Nag.php
--- lib/Nag.php 1 Nov 2002 15:50:04 -0000 1.55
+++ lib/Nag.php 7 Nov 2002 03:53:11 -0000
@@ -42,6 +42,15 @@
global $prefs, $conf;
$tasks = array();
+ /* Sorting criteria for the task list. */
+ $sort_functions = array(
+ NAG_SORT_PRIORITY => 'ByPriority',
+ NAG_SORT_NAME => 'ByName',
+ NAG_SORT_CATEGORY => 'ByCategory',
+ NAG_SORT_DUE => 'ByDue',
+ NAG_SORT_COMPLETION => 'ByCompletion'
+ );
+
foreach ($GLOBALS['display_tasklists'] as $tasklist) {
/* Create a Nag storage instance. */
$storage = &Nag_Driver::singleton($conf['storage']['driver'], $tasklist,
@@ -66,23 +75,21 @@
}
}
}
+
+ if ($prefs->getValue('group_by_username')) {
+ $prefix = ($sortdir == NAG_SORT_DESCEND) ? '_rsort' : '_sort';
+ uasort($newtasks, $prefix . $sort_functions[$sortby]);
+ }
$tasks = array_merge($tasks, $newtasks);
}
- /* Sort the task list. */
- $sort_functions = array(
- NAG_SORT_PRIORITY => 'ByPriority',
- NAG_SORT_NAME => 'ByName',
- NAG_SORT_CATEGORY => 'ByCategory',
- NAG_SORT_DUE => 'ByDue',
- NAG_SORT_COMPLETION => 'ByCompletion'
- );
-
- /* Sort the array if we have a sort function defined for this field. */
- if (array_key_exists($sortby, $sort_functions)) {
- $prefix = ($sortdir == NAG_SORT_DESCEND) ? '_rsort' : '_sort';
- uasort($tasks, $prefix . $sort_functions[$sortby]);
+ /* Sort the array if we have a sort function defined for this field and haven't done so already. */
+ if (!$prefs->getValue('group_by_username')) {
+ if (array_key_exists($sortby, $sort_functions)) {
+ $prefix = ($sortdir == NAG_SORT_DESCEND) ? '_rsort' : '_sort';
+ uasort($tasks, $prefix . $sort_functions[$sortby]);
+ }
}
return $tasks;
Index: lib/api.php
===================================================================
RCS file: /repository/nag/lib/api.php,v
retrieving revision 1.26
diff -u -r1.26 api.php
--- lib/api.php 15 Oct 2002 17:10:28 -0000 1.26
+++ lib/api.php 7 Nov 2002 03:53:11 -0000
@@ -88,7 +88,14 @@
$html .= '<td class="text">';
$viewurl = Horde::addParameter('view.php', 'task=' . $task['task_id']);
$viewurl = Horde::addParameter($viewurl, 'tasklist=' . $task['tasklist_id']);
- $row = Horde::link(Horde::applicationUrl($viewurl), $task['name']) . htmlspecialchars($task['name']) . '</a>';
+ $row = Horde::link(Horde::applicationUrl($viewurl), $task['name']);
+
+ if ($prefs->getValue('summary_show_usernames')) {
+ $row .= $task['tasklist_id'] . ' - ';
+ }
+
+ $row .= htmlspecialchars($task['name']) . '</a>';
+
if (!empty($task['completed'])) {
$closed_begin = '<strike>';
$closed_end = '</strike>';
Index: lib/constants.php
===================================================================
RCS file: /repository/nag/lib/constants.php,v
retrieving revision 1.6
diff -u -r1.6 constants.php
--- lib/constants.php 15 Aug 2002 18:49:56 -0000 1.6
+++ lib/constants.php 7 Nov 2002 03:53:11 -0000
@@ -19,6 +19,7 @@
/** @const NAG_SORT_DUE Sort by due date. */ define('NAG_SORT_DUE', 2);
/** @const NAG_SORT_COMPLETION Sort by completion. */ define('NAG_SORT_COMPLETION', 3);
/** @const NAG_SORT_CATEGORY Sort by category. */ define('NAG_SORT_CATEGORY', 4);
+/** @const NAG_SORT_USERNAME Sort by username. */ define('NAG_SORT_USERNAME', 5);
/** @const NAG_SORT_ASCEND Sort in ascending order. */ define('NAG_SORT_ASCEND', 0);
/** @const NAG_SORT_DESCEND Sort in descending order. */ define('NAG_SORT_DESCEND', 1);
Index: templates/list/task_headers.inc
===================================================================
RCS file: /repository/nag/templates/list/task_headers.inc,v
retrieving revision 1.15
diff -u -r1.15 task_headers.inc
--- templates/list/task_headers.inc 20 Sep 2002 15:57:34 -0000 1.15
+++ templates/list/task_headers.inc 7 Nov 2002 03:53:11 -0000
@@ -12,6 +12,10 @@
<?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($sortbyurl, 'sortby=' . NAG_SORT_COMPLETION)), _("Sort Direction"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.gif' : 'up.gif', _("Sort Direction")) ?></a>
<?php echo Horde::link(Horde::applicationUrl(Horde::addParameter('list.php', 'sortby=' . NAG_SORT_COMPLETION)), _("Sort by Completion Status"), 'widget') . Horde::img('complete.gif', _("Completed?")) ?></a>
</th>
+ <th class="<?php echo ($prefs->getValue('sortby') == NAG_SORT_USERNAME) ? 'selected' : 'item' ?>" width="2%" align="left" nowrap="nowrap">
+ <?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($sortbyurl, 'sortby=' . NAG_SORT_USERNAME)), _("Sort Direction"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.gif' : 'up.gif', _("Sort Direction")) ?></a>
+ <?php echo Horde::link(Horde::applicationUrl(Horde::addParameter('list.php', 'sortby=' . NAG_SORT_USERNAME)), _("Sort by User Name"), 'widget') . _('Username') ?></a>
+ </th>
<th class="<?php echo ($prefs->getValue('sortby') == NAG_SORT_PRIORITY) ? 'selected' : 'item' ?>" width="2%" align="left" nowrap="nowrap">
<?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($sortbyurl, 'sortby=' . NAG_SORT_PRIORITY)), _("Sort Direction"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.gif' : 'up.gif', _("Sort Direction")) ?></a>
<?php echo Horde::link(Horde::applicationUrl(Horde::addParameter('list.php', 'sortby=' . NAG_SORT_PRIORITY)), _("Sort by Priority"), 'widget') . _("Pri") ?></a>
Index: templates/list/task_summaries.inc
===================================================================
RCS file: /repository/nag/templates/list/task_summaries.inc,v
retrieving revision 1.22
diff -u -r1.22 task_summaries.inc
--- templates/list/task_summaries.inc 22 Sep 2002 04:06:57 -0000 1.22
+++ templates/list/task_summaries.inc 7 Nov 2002 03:53:11 -0000
@@ -14,6 +14,7 @@
</td>
<td align="center" nowrap="nowrap"><?php echo htmlspecialchars(Nag::formatCompletion($task['completed'])) ?></a></td>
+ <td align="center"><?php echo $task['tasklist_id'] ?></td>
<td align="center"><?php echo $task['priority'] ?></td>
<td nowrap="nowrap"><?php echo Horde::link(Horde::applicationUrl($viewurl), _("View Task Details"), '', '', '', $task['desc']) ?><?php echo htmlspecialchars($task['name']) ?></a></td>
<td nowrap="nowrap">