createTasksFromText() public static method

Imports one or more tasks parsed from a string.
public static createTasksFromText ( string $text, string $tasklist = null ) : array
$text string The text to parse into
$tasklist string The tasklist into which the task will be imported. If 'null', the user's default tasklist will be used.
return array The UIDs of all tasks that were added.
Example #1
0
File: Api.php Project: Gomez/horde
 /**
  * Imports one or more tasks parsed from a string.
  *
  * @param string $text      The text to parse into
  * @param string $tasklist  The tasklist into which the task will be
  *                          imported.  If 'null', the user's default
  *                          tasklist will be used.
  *
  * @return array  The UIDs of all tasks that were added.
  * @throws Horde_Exception_PermissionDenied
  */
 public function quickAdd($text, $tasklist = null)
 {
     if ($tasklist === null) {
         $tasklist = Nag::getDefaultTasklist(Horde_Perms::EDIT);
     } elseif (!Nag::hasPermission($tasklist, Horde_Perms::EDIT)) {
         throw new Horde_Exception_PermissionDenied();
     }
     return Nag::createTasksFromText($text, $tasklist);
 }
Example #2
0
<?php

require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('nag');
if ($quickText = Horde_Util::getPost('quickText')) {
    try {
        $result = Nag::createTasksFromText($quickText, Nag::getDefaultTasklist(Horde_Perms::EDIT));
    } catch (Nag_Exception $e) {
        $notification->push($e->getMessage());
    }
    if ($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');
    }
} else {
    $notification->push(_("No tasks have been added."), 'horde.warning');
}
Horde::url('list.php', true)->redirect();