From 61ef86e8a55c2417aba0941d755ab5c4ab01c3f1 Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Tue, 8 Jun 2010 12:28:36 -0600 Subject: [PATCH] Nag: Add View/sort-by for Start Date Signed-off-by: Jan Schneider --- nag/config/prefs.php.dist | 3 ++ nag/lib/Nag.php | 57 +++++++++++++++++++++++++++++++++++ nag/lib/Task.php | 1 + nag/templates/list/task_headers.inc | 4 +++ nag/templates/list/task_summaries.inc | 4 +++ 5 files changed, 69 insertions(+) diff --git a/nag/config/prefs.php.dist b/nag/config/prefs.php.dist index b4362f8a7..341fc8d35 100644 --- a/nag/config/prefs.php.dist +++ b/nag/config/prefs.php.dist @@ -56,6 +56,7 @@ $_prefs['tasklist_columns'] = array( 'priority' => _("Priority"), 'assignee' => _("Assignee"), 'due' => _("Due Date"), + 'start' => _("Due Date"), 'estimate' => _("Estimated Time"), 'category' => _("Category") ), @@ -77,6 +78,7 @@ $_prefs['sortby'] = array( Nag::SORT_NAME => _("Task Name"), Nag::SORT_CATEGORY => _("Category"), Nag::SORT_DUE => _("Due Date"), + Nag::SORT_START => _("Start Date"), Nag::SORT_COMPLETION => _("Completed?"), Nag::SORT_ESTIMATE => _("Estimated Time"), Nag::SORT_ASSIGNEE => _("Assignee"), @@ -94,6 +96,7 @@ $_prefs['altsortby'] = array( Nag::SORT_NAME => _("Task Name"), Nag::SORT_CATEGORY => _("Category"), Nag::SORT_DUE => _("Due Date"), + Nag::SORT_START => _("Start Date"), Nag::SORT_COMPLETION => _("Completed?"), Nag::SORT_ESTIMATE => _("Estimated Time"), Nag::SORT_ASSIGNEE => _("Assignee"), diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index 463b4cdec..3c726783b 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -28,6 +28,11 @@ class Nag const SORT_DUE = 'due'; /** + * Sort by start date. + */ + const SORT_START = 'start'; + + /** * Sort by completion. */ const SORT_COMPLETION = 'completed'; @@ -1336,6 +1341,58 @@ class Nag } /** + * Comparison function for sorting tasks by start date. + * + * @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. + */ + public static function _sortByStart($a, $b) + { + if ($a->start == $b->start) { + return self::_sortByIdentity($a, $b); + } + + // Treat empty start dates as farthest into the future. + if ($a->start == 0) { + return 1; + } + if ($b->start == 0) { + return -1; + } + + return ($a->start > $b->start) ? 1 : -1; + } + + /** + * Comparison function for reverse sorting tasks by start date. + * + * @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. + */ + public static function _rsortByStart($a, $b) + { + if ($a->start == $b->start) { + return self::_sortByIdentity($b, $a); + } + + // Treat empty start dates as farthest into the future. + if ($a->start == 0) { + return -1; + } + if ($b->start == 0) { + return 1; + } + + return ($a->start < $b->start) ? 1 : -1; + } + + /** * Comparison function for sorting tasks by completion status. * * @param array $a Task one. diff --git a/nag/lib/Task.php b/nag/lib/Task.php index 66402becf..2a6a9a8ed 100644 --- a/nag/lib/Task.php +++ b/nag/lib/Task.php @@ -580,6 +580,7 @@ class Nag_Task { Nag::SORT_NAME => 'ByName', Nag::SORT_CATEGORY => 'ByCategory', Nag::SORT_DUE => 'ByDue', + Nag::SORT_START => 'ByStart', Nag::SORT_COMPLETION => 'ByCompletion', Nag::SORT_ASSIGNEE => 'ByAssignee', Nag::SORT_ESTIMATE => 'ByEstimate', diff --git a/nag/templates/list/task_headers.inc b/nag/templates/list/task_headers.inc index 93c440f04..51c7fa826 100644 --- a/nag/templates/list/task_headers.inc +++ b/nag/templates/list/task_headers.inc @@ -51,6 +51,10 @@ function doPrefsUpdate(column, sortDown) width="2%">   + + width="2%"> +   + width="10%">   diff --git a/nag/templates/list/task_summaries.inc b/nag/templates/list/task_summaries.inc index 95fa8189f..f3fdc8c8c 100644 --- a/nag/templates/list/task_summaries.inc +++ b/nag/templates/list/task_summaries.inc @@ -61,6 +61,10 @@ if ($share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { due ? strftime($dateFormat, $task->due) : ' ' ?> + + + start ? strftime($dateFormat, $task->start) : ' ' ?> + estimation()) ?> -- 2.11.0