[nag] task complion

Jon Parise jon@horde.org
Sun, 9 Dec 2001 03:40:30 -0500


On Thu, Dec 06, 2001 at 11:40:00AM -0500, Paul Cooper wrote:

> I've been playing with nag, and I decided to add an extra field - 
> 
> task_completed  smallint default 0
> 
> which I use to indicate whether a task is completed or not (you were 
> guessing right :) See the attached diff(s) - which style is preferred 
> round here -u or -c?
> 
> 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.

-- 
Jon Parise (jon@csh.rit.edu)  .  Information Technology (2001)
http://www.csh.rit.edu/~jon/  :  Computer Science House Member


>From jon@horde.org Date: Sat,  8 Dec 2001 23:40:42 -0800 (PST)
Return-Path: <jon@csh.rit.edu>
Mailing-List: contact nag-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list nag@lists.horde.org
Received: (qmail 13180 invoked from network); 9 Dec 2001 08:50:16 -0000
Received: from mcp.csh.rit.edu (129.21.60.9)
  by clark.horde.org with SMTP; 9 Dec 2001 08:50:16 -0000
Received: from fury.csh.rit.edu (fury.csh.rit.edu [129.21.60.5])
	by mcp.csh.rit.edu (Postfix) with ESMTP id 46A091FE
	for <nag@lists.horde.org>; Sun,  9 Dec 2001 03:50:15 -0500 (EST)
Received: by fury.csh.rit.edu (Postfix, from userid 37404)
	id 5621E2E079; Sun,  9 Dec 2001 03:50:10 -0500 (EST)
Date: Sun, 9 Dec 2001 03:50:10 -0500
From: Jon Parise <jon@horde.org>
To: nag@lists.horde.org
Message-ID: <20011209035009.C11916@csh.rit.edu>
Mail-Followup-To: nag@lists.horde.org
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="tThc/1wpZn/ma/RB"
Content-Disposition: inline
User-Agent: Mutt/1.3.12i
Subject: [[cvs] cvs commit: nag task.php nag/docs CHANGES nag_tasks.sql nag/lib Storage.php nag/lib/Storage sql.php nag/templates/task task.inc nag/templates/view headers.inc (fwd)]

--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

FYI -

-- 
Jon Parise (jon@csh.rit.edu)  .  Information Technology (2001)
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

--tThc/1wpZn/ma/RB
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <cvs-return-4014-jon=csh.rit.edu@lists.horde.org>
Delivered-To: jon@csh.rit.edu
Received: from clark.horde.org (clark.horde.org [199.175.137.150])
	by mcp.csh.rit.edu (Postfix) with SMTP id F08A41FE
	for <jon@csh.rit.edu>; Sun,  9 Dec 2001 03:49:39 -0500 (EST)
Received: (qmail 13090 invoked by alias); 9 Dec 2001 08:49:38 -0000
Mailing-List: contact cvs-help@lists.horde.org; run by ezmlm
Precedence: bulk
List-Post: <mailto:cvs@lists.horde.org>
List-Help: <mailto:cvs-help@lists.horde.org>
List-Unsubscribe: <mailto:cvs-unsubscribe@lists.horde.org>
List-Subscribe: <mailto:cvs-subscribe@lists.horde.org>
Reply-To: dev@lists.horde.org
Delivered-To: mailing list cvs@lists.horde.org
Received: (qmail 13079 invoked from network); 9 Dec 2001 08:49:38 -0000
To: cvs@lists.horde.org
From: "Jon Parise" <jon@horde.org>
X-Horde-CVS-Branch: HEAD
Message-Id: <20011209074042.687BF40D@arkady.horde.org>
Date: Sat,  8 Dec 2001 23:40:42 -0800 (PST)
Subject: [cvs] cvs commit: nag task.php nag/docs CHANGES nag_tasks.sql nag/lib
         Storage.php nag/lib/Storage sql.php nag/templates/task task.inc
         nag/templates/view headers.inc
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1

jon         2001/12/08 23:40:42 PST

  Modified files:
    .                    task.php 
    docs                 CHANGES nag_tasks.sql 
    lib                  Storage.php 
    lib/Storage          sql.php 
    templates/task       task.inc 
    templates/view       headers.inc 
  Log:
  Removing task dependencies.
  
  I'm not sure if anyone is actually using these, but they really shouldn't
  be in a simple task management application.
  
  Revision  Changes    Path
  1.40      +2 -1      nag/docs/CHANGES
  1.9       +1 -2      nag/docs/nag_tasks.sql
  1.20      +3 -6      nag/lib/Storage.php
  1.18      +4 -8      nag/lib/Storage/sql.php
  1.18      +2 -7      nag/task.php
  1.9       +1 -7      nag/templates/task/task.inc
  1.11      +3 -13     nag/templates/view/headers.inc

  Chora Links:
  http://cvs.horde.org/diff.php/nag/docs/CHANGES?r1=1.39&r2=1.40&ty=u
  http://cvs.horde.org/diff.php/nag/docs/nag_tasks.sql?r1=1.8&r2=1.9&ty=u
  http://cvs.horde.org/diff.php/nag/lib/Storage.php?r1=1.19&r2=1.20&ty=u
  http://cvs.horde.org/diff.php/nag/lib/Storage/sql.php?r1=1.17&r2=1.18&ty=u
  http://cvs.horde.org/diff.php/nag/task.php?r1=1.17&r2=1.18&ty=u
  http://cvs.horde.org/diff.php/nag/templates/task/task.inc?r1=1.8&r2=1.9&ty=u
  http://cvs.horde.org/diff.php/nag/templates/view/headers.inc?r1=1.10&r2=1.11&ty=u

-- 
To unsubscribe, mail: cvs-unsubscribe@lists.horde.org

--tThc/1wpZn/ma/RB--


>From pgc@ucecom.com Date: 10 Dec 2001 16:56:55 -0500
Return-Path: <pgc@ucecom.com>
Mailing-List: contact nag-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list nag@lists.horde.org
Received: (qmail 53180 invoked from network); 10 Dec 2001 16:52:45 -0000
Received: from unknown (HELO ucecom.com) (195.8.161.130)
  by clark.horde.org with SMTP; 10 Dec 2001 16:52:45 -0000
Received: from hankey.ucecom.com ([140.4.2.19]) by stan.ucecom.com
          (Netscape Messaging Server 3.6)  with ESMTP id AAA2385B;
          Tue, 11 Dec 2001 10:49:47 +0000
From: "Paul Cooper" <pgc@ucecom.com>
To: nag@lists.horde.org
Cc: dev@lists.horde.org
In-Reply-To: <20011209034029.B11916@csh.rit.edu>
References: <20011206114000.A28372@ucecom.com> 
	<20011209034029.B11916@csh.rit.edu>
Content-Type: multipart/mixed; boundary="=-gXOUINWrHyO9aucPKTD6"
X-Mailer: Evolution/1.0 (Preview Release)
Date: 10 Dec 2001 16:56:55 -0500
Message-Id: <1008021415.7143.10.camel@hankey.ucecom.com>
Mime-Version: 1.0
Subject: Re: [nag] task completion

--=-gXOUINWrHyO9aucPKTD6
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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


--=-gXOUINWrHyO9aucPKTD6
Content-Disposition: attachment; filename=diff.u
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ANSI_X3.4-1968

? 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

--=-gXOUINWrHyO9aucPKTD6--