task completion action in nag

Paul Cooper pgc@ucecom.com
Mon, 10 Dec 2001 21:31:00 -0500


---------------------- multipart/mixed attachment
Here's a patch that adds a 'Set Task Completed' action in nag.

Paul

-- 
-----------------------------------------------------------------
Paul Cooper                             |  Tel: 0121 331 7858
Senior Programmer and Database Engineer |  Fax: 0121 331 7859
UCEcom                                  |  mailto:pgc@ucecom.com
University of Central England           |  http://www.ucecom.com
Birmingham, B4 7DX                      |
-----------------------------------------------------------------

---------------------- multipart/mixed attachment
? diff
? lib/Nag.php.diff
Index: list.php
===================================================================
RCS file: /repository/nag/list.php,v
retrieving revision 1.22
diff -u -r1.22 list.php
--- list.php	10 Dec 2001 16:49:00 -0000	1.22
+++ list.php	10 Dec 2001 21:20:30 -0000
@@ -62,6 +62,29 @@
      break;
      
  case NAG_COMPLETE_TASKS:
+     $items = Horde::getFormData('items');
+     $completed = intval(Horde::getFormData('completed'));
+     if (isset($items) && (count($items) > 0) && $completed == 1) {
+         foreach ($items as $task_id) {
+             if (isset($tasks[$task_id])) {
+                 $storage->modifyTask($task_id, 'completed', $completed);
+                 $tasks[$task_id]['completed'] = $completed;
+             }
+         }
+         
+         if ($storage->store() === STORAGE_OK) {
+             if (count($items) == 1) {
+                 $message = sprintf(_("Changed 1 task to completion status %d."), $completed);
+             } elseif (count($items) > 1) {
+                 $message = sprintf(_("Changed %d tasks to completion status %d."), count($items), $completed);
+             } else {
+                 $message = _("No tasks were changed.");
+             }
+             Horde::raiseMessage($message, HORDE_SUCCESS);
+         } else {
+             Horde::raiseMessage(_("There was a problem setting task completion status."), HORDE_ERROR);
+         }
+     }
      break;
      
  case NAG_SET_PRIORITY:
Index: templates/list/actions.inc
===================================================================
RCS file: /repository/nag/templates/list/actions.inc,v
retrieving revision 1.6
diff -u -r1.6 actions.inc
--- templates/list/actions.inc	10 Dec 2001 16:42:31 -0000	1.6
+++ templates/list/actions.inc	10 Dec 2001 21:20:51 -0000
@@ -6,6 +6,7 @@
             <option selected="selected"><?= _("Choose Action:") ?></option>
             <option value="<?= NAG_DELETE_TASKS ?>"><?= _("Delete Tasks") ?></option>
             <option value="<?= NAG_SET_PRIORITY ?>"><?= _("Set Task Priority") ?></option>
+            <option value="<?= NAG_COMPLETE_TASKS ?>"><?= _("Set Task Completed") ?></option>
         </select>
         <?php if ($conf['user']['online_help'] && $browser->hasFeature('javascript')) echo Help::link('nag', 'list-actions') ?>
     </td>
Index: templates/list/header.inc
===================================================================
RCS file: /repository/nag/templates/list/header.inc,v
retrieving revision 1.5
diff -u -r1.5 header.inc
--- templates/list/header.inc	10 Dec 2001 16:42:31 -0000	1.5
+++ templates/list/header.inc	10 Dec 2001 21:20:51 -0000
@@ -1,6 +1,7 @@
 <form method="post" name="list" enctype="multipart/form-data" action="<?= Horde::selfURL() ?>">
 <input type="hidden" name="actionID" value="" />
 <input type="hidden" name="priority" value="" />
+<input type="hidden" name="completed" value="" />
 <table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
 <tr>
     <td class="header" align="center">
Index: templates/list/javascript.inc
===================================================================
RCS file: /repository/nag/templates/list/javascript.inc,v
retrieving revision 1.2
diff -u -r1.2 javascript.inc
--- templates/list/javascript.inc	10 Dec 2001 16:42:31 -0000	1.2
+++ templates/list/javascript.inc	10 Dec 2001 21:20:51 -0000
@@ -33,6 +33,10 @@
                 return false;
             }
         }
+
+        if (document.list.actionID.value == <?= NAG_COMPLETE_TASKS ?>) {
+	     document.list.completed.value = 1;
+        }
         
         document.list.submit();
     }

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