Improve quick task adding.
authorJan Schneider <jan@horde.org>
Thu, 9 Dec 2010 15:02:41 +0000 (16:02 +0100)
committerJan Schneider <jan@horde.org>
Thu, 9 Dec 2010 15:02:41 +0000 (16:02 +0100)
nag/quick.php

index 03c6a5c..d7fd15b 100644 (file)
@@ -4,10 +4,15 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('nag');
 
 if ($quickText = Horde_Util::getPost('quickText')) {
-    $result = $registry->tasks->quickAdd($quickText);
-    if (!$result) {
-        throw new Nag_Exception($result);
+    $result = Nag::createTasksFromText($quickText, Nag::getDefaultTasklist(Horde_Perms::EDIT));
+    if (is_a($result, 'PEAR_Error')) {
+        $notification->push($result);
+    } elseif ($result) {
+        $notification->push(sprintf(ngettext("Added %d task", "Added %d tasks", count($result)), count($result)), 'horde.success');
+    } else {
+        $notification->push(_("No tasks have been added."), 'horde.warning');
     }
-    $notification->push(sprintf(ngettext("Added %d task", "Added %d tasks", count($result)), count($result)), 'horde.success');
-    Horde::url('list.php', true)->redirect();
+} else {
+    $notification->push(_("No tasks have been added."), 'horde.warning');
 }
+Horde::url('list.php', true)->redirect();