[nag] task completion

Paul Cooper pgc@ucecom.com
10 Dec 2001 16:56:55 -0500


---------------------- multipart/mixed attachment
On Sun, 2001-12-09 at 03:40, Jon Parise wrote:
> On Thu, Dec 06, 2001 at 11:40:00AM -0500, Paul Cooper wrote:
[snip]
> > As it stands it's not great - I haven't yet got round to adding the 
> > compeletion status to the task list, so there's no way to see open / 
> > closed tasks yet in the list (yet). Also now that I think about it could 
> > be more useful to be a percentage rather than a boolean, e.g. Open, 20%, 
> > 40%, 60%, 80%, Closed.
>  
> I cleaned up your patch a little bit and committed it.  Thanks
> for the contribution.

Thanks. I've completed this task now. Attached is a diff to add a status
column and sort to the task list and a phpdoc cleanup.

Paul 

> -- 
> Jon Parise (jon@csh.rit.edu)  .  Information Technology (2001)
> http://www.csh.rit.edu/~jon/  :  Computer Science House Member
> 
> -- 
> Nag mailing list: http://horde.org/nag/
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: nag-unsubscribe@lists.horde.org


---------------------- multipart/mixed attachment
? diff.u
Index: lib/Nag.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /repository/nag/lib/Nag.php,v
retrieving revision 1.32
diff -u -r1.32 Nag.php
--- lib/Nag.php	9 Dec 2001 07:30:58 -0000	1.32
+++ lib/Nag.php	10 Dec 2001 16:43:30 -0000
@@ -64,6 +64,7 @@
=20
         /* Sort the task list. */
         $sort_functions =3D array(
+	    SORT_COMPLETION =3D> 'ByCompletion',
             SORT_PRIORITY =3D> 'ByPriority',
             SORT_NAME =3D> 'ByName',
             SORT_ADDED =3D> 'ByAdded',
@@ -362,7 +363,7 @@
     /**
      * Returns the string representation of the given completion status.
      *
-     * @param int $completed    The priority value.
+     * @param int $completed    The completion value.
      *
      * @return string       The string representation of $completed.
      */
@@ -391,6 +392,21 @@
     if ($a['priority'] =3D=3D $b['priority']) return 0;
     return ($a['priority'] > $b['priority']) ? -1 : 1;
 }
+
+/**
+ * Comparison function for sorting tasks by Completion status.
+ *
+ * @param array $a  Task one.
+ * @param array $b  Task two.
+ *
+ * @return integer  1 if task one is greater, -1 if task two is greater; 0=
 if they are equal.
+ */
+function _sortByCompletion($a, $b)
+{
+    if ($a['completed'] =3D=3D $b['completed']) return 0;
+    return ($a['completed'] > $b['completed']) ? -1 : 1;
+}
+
=20
 /**
  * Comparison function for reverse sorting tasks by priority.
Index: lib/constants.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /repository/nag/lib/constants.php,v
retrieving revision 1.1
diff -u -r1.1 constants.php
--- lib/constants.php	21 Oct 2001 20:16:24 -0000	1.1
+++ lib/constants.php	10 Dec 2001 16:43:30 -0000
@@ -13,6 +13,8 @@
 /** @const SORT_ADDED Sort by creation date.      */ define('SORT_ADDED', =
1);
 /** @const SORT_DUE Sort by due date.             */ define('SORT_DUE', 2)=
;
 /** @const SORT_PRIORITY Sort by priority.        */ define('SORT_PRIORITY=
', 3);
+/** @const SORT_COMPLETION Sort by priority.        */ define('SORT_COMPLE=
TION', 4);
+
 /** @const SORT_ASCEND Sort in ascending order.   */ define('SORT_ASCEND',=
 0);
 /** @const SORT_DESCEND Sort in descending order. */ define('SORT_DESCEND'=
, 1);
=20
Index: templates/list/task_headers.inc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /repository/nag/templates/list/task_headers.inc,v
retrieving revision 1.8
diff -u -r1.8 task_headers.inc
--- templates/list/task_headers.inc	9 Dec 2001 07:10:50 -0000	1.8
+++ templates/list/task_headers.inc	10 Dec 2001 16:43:35 -0000
@@ -9,9 +9,13 @@
         <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_PRIORITY), _("Sort by Priority"), 'widget') . _("Priority") ?></a>
     </th>
     <td width=3D"0%">&nbsp;</td>
-    <th class=3D"<?=3D ($prefs->getValue('sortby') =3D=3D SORT_NAME) ? 'se=
lected' : 'item' ?>" width=3D"60%" align=3D"left" nowrap=3D"nowrap">
+    <th class=3D"<?=3D ($prefs->getValue('sortby') =3D=3D SORT_NAME) ? 'se=
lected' : 'item' ?>" width=3D"50%" align=3D"left" nowrap=3D"nowrap">
         <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_NAME . '&sortdir=3D' . abs(1 - $prefs->getValue('sortdir'))), _("Sort Dir=
ection"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.gif' :=
 'up.gif', 'alt=3D"' . _("Sort Direction") .  '"') ?></a>
         <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_NAME), _("Sort by Name"), 'widget') . _("Name") ?></a>
+    </th>
+    <th class=3D"<?=3D ($prefs->getValue('sortby') =3D=3D SORT_NAME) ? 'se=
lected' : 'item' ?>" width=3D"10%" align=3D"left" nowrap=3D"nowrap">
+        <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_COMPLETION . '&sortdir=3D' . abs(1 - $prefs->getValue('sortdir'))), _("So=
rt Direction"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.=
gif' : 'up.gif', 'alt=3D"' . _("Sort Direction") .  '"') ?></a>
+        <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_COMPLETION), _("Sort by Completion Status"), 'widget') . _("Status") ?></=
a>
     </th>
     <th class=3D"<?=3D ($prefs->getValue('sortby') =3D=3D SORT_ADDED) ? 's=
elected' : 'item' ?>" width=3D"15%" align=3D"left" nowrap=3D"nowrap">
         <?=3D Horde::link(Horde::applicationUrl('list.php?sortby=3D' . SOR=
T_ADDED . '&sortdir=3D' . abs(1 - $prefs->getValue('sortdir'))), _("Sort Di=
rection"), 'widget') . Horde::img($prefs->getValue('sortdir') ? 'down.gif' =
: 'up.gif', 'alt=3D"' . _("Sort Direction") .  '"') ?></a>
Index: templates/list/task_summaries.inc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /repository/nag/templates/list/task_summaries.inc,v
retrieving revision 1.10
diff -u -r1.10 task_summaries.inc
--- templates/list/task_summaries.inc	1 Sep 2001 16:40:15 -0000	1.10
+++ templates/list/task_summaries.inc	10 Dec 2001 16:43:35 -0000
@@ -9,6 +9,9 @@
     <td nowrap=3D"nowrap">
         <?=3D Horde::link("view.php?task=3D$task_id", _("View Task Details=
")) ?><?=3D htmlspecialchars($task['name']) ?></a>
     </td>
+    <td nowrap=3D"nowrap">
+        <?=3D htmlspecialchars(Nag::formatCompletion($task['completed'])) =
?></a>
+    </td>
     <td nowrap=3D"nowrap"><?=3D strftime($conf['list']['date_format'], $ta=
sk['added']); ?></td>
     <td nowrap=3D"nowrap">
 <?php

---------------------- multipart/mixed attachment--