PATCH: Show whups tickets on nag task list.
"Jason M. Felice" <[email protected]> Tue, 3 Jun 2003 16:27:59 -0400
| Newsgroups | gmane.comp.horde.nag |
|---|---|
| Message-ID | <[email protected]> |
The attached patch adds logic to Nag::listTasks() to check for applications with registered 'getListAsTypes' and 'listAs' apis that support a type called 'taskHash'. Any app supporting this will be queried for tasks to display on the task list. And this patch implements those two apis for whups. This patch also implements the listAs API for nag itself. -- Nag mailing list Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
nag-show-tickets.patch
(text/plain, 10.3 KB)
Index: nag/list.php
===================================================================
RCS file: /repository/nag/list.php,v
retrieving revision 1.53
diff -u -u -r1.53 list.php
--- nag/list.php 23 May 2003 03:56:10 -0000 1.53
+++ nag/list.php 3 Jun 2003 20:05:05 -0000
@@ -95,11 +95,6 @@
} else {
$style = 'text' . $task['priority'];
}
- $viewurl = Horde::addParameter('view.php', 'task=' . $task['task_id']);
- $viewurl = Horde::addParameter($viewurl, 'tasklist=' . $task['tasklist_id']);
-
- $taskurl = Horde::addParameter('task.php', 'task=' . $task['task_id']);
- $taskurl = Horde::addParameter($taskurl, 'tasklist=' . $task['tasklist_id']);
$share = $GLOBALS['nag_shares']->getShare($task['tasklist_id']);
$owner = $task['tasklist_id'];
Index: nag/lib/Nag.php
===================================================================
RCS file: /repository/nag/lib/Nag.php,v
retrieving revision 1.74
diff -u -u -r1.74 Nag.php
--- nag/lib/Nag.php 1 Jun 2003 01:38:47 -0000 1.74
+++ nag/lib/Nag.php 3 Jun 2003 20:05:05 -0000
@@ -91,7 +91,7 @@
function listTasks($sortby = NAG_SORT_PRIORITY,
$sortdir = NAG_SORT_ASCEND)
{
- global $prefs, $conf;
+ global $prefs, $conf, $registry;
$tasks = array();
/* Sorting criteria for the task list. */
@@ -112,24 +112,51 @@
/* Retrieve the task list for storage. */
$newtasks = $storage->listTasks();
+ foreach ($newtasks as $taskID => $task) {
+ $url = Horde::addParameter('view.php', 'task=' . $task['task_id']);
+ $url = Horde::addParameter($url, 'tasklist=' . $task['tasklist_id']);
+ $newtasks[$taskID]['view_link'] = Horde::applicationUrl($url);
- /* Filter complete/incomplete tasks if the user doesn't
- * want them shown. */
- if ($prefs->getValue('show_completed') == 0) {
- foreach ($newtasks as $taskID => $task) {
- if (!empty($task['completed'])) {
- unset($newtasks[$taskID]);
- }
- }
- } elseif ($prefs->getValue('show_completed') == 2) {
- foreach ($newtasks as $taskID => $task) {
- if (empty($task['completed'])) {
- unset($newtasks[$taskID]);
- }
- }
+ $url = Horde::addParameter('task.php', 'task=' . $task['task_id']);
+ $url = Horde::addParameter($url, 'tasklist=' . $task['tasklist_id']);
+ $newtasks[$taskID]['complete_link'] = Horde::applicationUrl(Horde::addParameter($url, 'actionID=' . NAG_COMPLETE_TASKS));
+ $newtasks[$taskID]['edit_link'] = Horde::applicationUrl(Horde::addParameter($url, 'actionID=' . NAG_MODIFY_TASK));
+ $newtasks[$taskID]['delete_link'] = Horde::applicationUrl(Horde::addParameter($url, 'actionID=' . NAG_DELETE_TASKS));
}
$tasks = array_merge($tasks, $newtasks);
+ }
+
+ // We look for registered apis that support listAs(taskHash).
+ $apps = $registry->listApps();
+ foreach ($apps as $app) {
+ if ($app == 'nag')
+ continue;
+ if ($registry->hasMethod('getListAsTypes', $app)) {
+ $listAsTypes = $registry->callByPackage($app, 'getListAsTypes');
+ if (in_array('taskHash',$listAsTypes)) {
+ $newtasks = $registry->callByPackage($app, 'listAs', array('taskHash'));
+ $tasks = array_merge($tasks, $newtasks);
+ }
+ }
+ }
+
+ /* Filter complete/incomplete tasks if the user doesn't
+ * want them shown. */
+ switch ($prefs->getValue('show_completed')) {
+ case 0:
+ foreach ($tasks as $taskID => $task) {
+ if (!empty($task['completed']))
+ unset($tasks[$taskID]);
+ }
+ break;
+
+ case 2:
+ foreach ($tasks as $taskID => $task) {
+ if (empty($task['completed']))
+ unset($tasks[$taskID]);
+ }
+ break;
}
// Sort the array if we have a sort function defined for this
Index: nag/lib/api.php
===================================================================
RCS file: /repository/nag/lib/api.php,v
retrieving revision 1.44
diff -u -u -r1.44 api.php
--- nag/lib/api.php 22 Apr 2003 03:29:57 -0000 1.44
+++ nag/lib/api.php 3 Jun 2003 20:05:05 -0000
@@ -62,6 +62,13 @@
'args' => array('categoryID', 'tasklist'),
'type' => 'string');
+$_services['getListAsTypes'] = array(
+ 'args' => array(),
+ 'type' => 'array');
+
+$_services['listAs'] = array(
+ 'args' => array('type'),
+ 'type' => 'array');
function _nag_linkParameters()
{
@@ -185,4 +192,15 @@
} else {
return _("Task not found.");
}
+}
+
+function _nag_getListAsTypes ()
+{
+ return array('taskHash');
+}
+
+function _nag_listAs ($type)
+{
+ require_once dirname(__FILE__) . '/base.php';
+ return Nag::listTasks();
}
Index: nag/templates/list/task_summaries.inc
===================================================================
RCS file: /repository/nag/templates/list/task_summaries.inc,v
retrieving revision 1.31
diff -u -u -r1.31 task_summaries.inc
--- nag/templates/list/task_summaries.inc 7 May 2003 15:14:21 -0000 1.31
+++ nag/templates/list/task_summaries.inc 3 Jun 2003 20:05:05 -0000
@@ -1,16 +1,16 @@
<tr class="<?php echo $style ?>" onmouseover="javascript:style.backgroundColor='<?php echo $css['.' . $style . '-hi']['background-color'] ?>'" onmouseout="javascript:style.backgroundColor='<?php echo $css['.' . $style]['background-color'] ?>'">
<td nowrap="nowrap">
<?php if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), _PERMS_DELETE)): ?>
- <?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($taskurl, 'actionID=' . NAG_DELETE_TASKS)), _("Delete Task"), 'widget') ?>
+ <?php echo Horde::link($task['delete_link'], _("Delete Task"), 'widget') ?>
<?php echo Horde::img('delete.gif', _("Delete Task")) ?>
</a>
<?php endif; ?>
<?php if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), _PERMS_EDIT) && empty($task['completed'])): ?>
- <?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($taskurl, 'actionID=' . NAG_MODIFY_TASK)), _("Edit Task"), 'widget') ?>
+ <?php echo Horde::link($task['edit_link'], _("Edit Task"), 'widget') ?>
<?php echo Horde::img('edit.gif', _("Edit Task")) ?>
</a>
- <?php echo Horde::link(Horde::applicationUrl(Horde::addParameter($taskurl, 'actionID=' . NAG_COMPLETE_TASKS)), _("Complete Task"), 'widget') ?>
+ <?php echo Horde::link($task['complete_link'], _("Complete Task"), 'widget') ?>
<?php echo Horde::img('complete.gif', _("Complete Task")) ?>
</a>
<?php endif; ?>
@@ -19,7 +19,7 @@
<td align="center" nowrap="nowrap"><?php echo htmlspecialchars(Nag::formatCompletion($task['completed'])) ?></a></td>
<td align="center" nowrap="nowrap"><?php echo $owner ?></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 !empty($task['name']) ? htmlspecialchars($task['name']) : _("[none]") ?></a></td>
+ <td nowrap="nowrap"><?php echo Horde::link($task['view_link'], _("View Task Details"), '', '', '', $task['desc']) ?><?php echo !empty($task['name']) ? htmlspecialchars($task['name']) : _("[none]") ?></a></td>
<td nowrap="nowrap">
<?php if ($task['due'] > 0): ?>
<?php if (empty($task['completed']) && $task['due'] < time()) { echo '<span class="overdue">' . strftime($conf['list']['date_format'], $task['due']) . '</span>';
Index: whups/lib/api.php
===================================================================
RCS file: /repository/whups/lib/api.php,v
retrieving revision 1.41
diff -u -u -r1.41 api.php
--- whups/lib/api.php 5 Apr 2003 02:41:33 -0000 1.41
+++ whups/lib/api.php 3 Jun 2003 20:05:05 -0000
@@ -69,6 +69,13 @@
'args' => array(),
'type' => 'array');
+$_services['getListAsTypes'] = array(
+ 'args' => array(),
+ 'type' => 'array');
+
+$_services['listAs'] = array(
+ 'args' => array('type'),
+ 'type' => 'array');
function _whups_block($type, $params)
{
@@ -504,4 +511,53 @@
} else {
return $ticket;
}
+}
+
+function _whups_getListAsTypes ()
+{
+ return array('taskHash');
+}
+
+function _whups_listAs ($type)
+{
+ if ($type != 'taskHash')
+ return array();
+
+ require_once dirname(__FILE__) . '/base.php';
+ global $whups;
+ $info = array('owner' => Auth::getAuth(),
+ 'nores' => true);
+ $tickets = &$whups->getTicketsByProperties($info);
+ if (is_a($tickets, 'PEAR_Error')) {
+ return $tickets;
+ }
+ $result = array();
+ foreach ($tickets as $ticket) {
+ $base = Horde::addParameter('details.php', 'id='.$ticket['id']);
+ $view_link = Horde::applicationUrl($base);
+
+ $delete_link = Horde::addParameter($base, 'action=dt');
+ $delete_link = Horde::applicationUrl($delete_link);
+
+ $complete_link = Horde::addParameter($base, 'action=ss');
+ $complete_link = Horde::applicationUrl($complete_link);
+
+ $result['whups/'.$ticket['id']] = array(
+ 'task_id' => $ticket['id'],
+ 'priority' => $ticket['_priority_name'],
+ 'tasklist_id' => $ticket['user_id_owner'],
+ 'completed' => !empty($ticket['_date_resolved']),
+ 'name' => $ticket['_module_name'] . ' ' .
+ $ticket['id'] . ' - ' . $ticket['summary'],
+ 'desc' => null,
+ 'due' => null,
+ 'category' => null,
+ 'view_link' => $view_link,
+ 'delete_link' => $delete_link,
+ 'edit_link' => $view_link,
+ 'complete_link' => $complete_link,
+ );
+
+ }
+ return $result;
}