\Nag_Driver_Sql

Nag storage implementation for PHP's PEAR database abstraction layer.

The table structure can be created by the scripts/sql/nag.sql script.

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Summary

Methods
Properties
Constants
__construct()
listAlarms()
open()
add()
modify()
delete()
deleteAll()
retrieve()
getChildren()
get()
getByUID()
synchronize()
$tasks
No constants found
_add()
_modify()
_updateTags()
_addTags()
_getBy()
_addRecurrenceFields()
_move()
_delete()
_deleteAll()
_buildTask()
$_tasklist
$_params
$_errormsg
$_db
N/A
No private methods found
No private properties found
N/A

Properties

$tasks

$tasks : \Nag_Task

A Nag_Task instance holding the current task list.

Type

\Nag_Task

$_tasklist

$_tasklist : string

String containing the current tasklist.

Type

string

$_params

$_params : array

Hash containing connection parameters.

Type

array

$_errormsg

$_errormsg : string

An error message to throw when something is wrong.

Type

string

$_db

$_db : \Horde_Db_Adapter

Handle for the current database connection.

Type

\Horde_Db_Adapter

Methods

__construct()

__construct(string  $tasklist, array  $params = array()) : \Nag_Driver

Constructs a new SQL storage object.

Parameters

string $tasklist

The tasklist to load.

array $params

A hash containing connection parameters.

Returns

\Nag_Driver

listAlarms()

listAlarms(integer  $date) : array

Lists all alarms near $date.

Parameters

integer $date

The unix epoch time to check for alarms.

Throws

\Nag_Exception

Returns

array —

An array of tasks that have alarms that match.

open()

open(string  $tasklist) 

Sets the currently open tasklist.

Parameters

string $tasklist

The tasklist.

add()

add(array  $task) : array

Adds a task and handles notification.

Parameters

array $task

A hash with the following possible properties:

  • desc: (string) The description (long) of the task.
  • name: (string) The name (short) of the task.
  • actual: (OPTIONAL, float) The actual time spent on the task.
  • alarm: (OPTIONAL, integer) The alarm associated with the task.
  • assignee: (OPTIONAL, string) The assignee of the event.
  • completed: (OPTIONAL, integer) The completion state of the task.
  • completed_date: (OPTIONAL, integer) The task's completion date.
  • due: (OPTIONAL, integer) The due date of the task.
  • estimate: (OPTIONAL, float) The estimated time to complete the task.
  • methods: (OPTIONAL, array) The overridden alarm notification methods.
  • owner: (OPTIONAL, string) The owner of the event.
  • parent: (OPTIONAL, string) The parent task.
  • priority: (OPTIONAL, integer) The priority of the task.
  • private: (OPTIONAL, boolean) Whether the task is private.
  • recurrence: (OPTIONAL, Horde_Date_Recurrence|array) Recurrence information.
  • start: (OPTIONAL, integer) The start date of the task.
  • tags: (OPTIONAL, string) The comma delimited list of tags.
  • uid: (OPTIONAL, string) A Unique Identifier for the task.

Returns

array —

array(ID,UID) of new task

modify()

modify(string  $taskId, array  $properties) 

Modifies an existing task and handles notification.

Parameters

string $taskId

The task to modify.

array $properties

A hash with properties. @see add().

Throws

\Nag_Exception

delete()

delete(string  $taskId) 

Deletes a task and handles notification.

Parameters

string $taskId

The task to delete.

deleteAll()

deleteAll() 

Deletes all tasks for the current task list.

Throws

\Nag_Exception

retrieve()

retrieve(integer  $completed = \Nag::VIEW_ALL, boolean  $include_history = true) 

Retrieves tasks from the database.

Parameters

integer $completed

Which tasks to retrieve (1 = all tasks, 0 = incomplete tasks, 2 = complete tasks, 3 = future tasks, 4 = future and incomplete tasks).

boolean $include_history

Include created/changed data from Horde_History.

Throws

\Nag_Exception

getChildren()

getChildren(string  $parentId, boolean  $include_history = true) : array

Retrieves sub-tasks from the database.

Parameters

string $parentId

The parent id for the sub-tasks to retrieve.

boolean $include_history

Include created/modified info?

Throws

\Nag_Exception

Returns

array —

List of sub-tasks.

get()

get(  $taskIds) : \Nag_Task

Retrieves one or multiple tasks from the database.

Parameters

$taskIds

Throws

\Horde_Exception_NotFound
\Nag_Exception

Returns

\Nag_Task

A Nag_Task object.

getByUID()

getByUID(  $uids, array  $tasklists = null, boolean  $getall = true) : \Nag_Task

Retrieves one or multiple tasks from the database by UID.

Parameters

$uids
array $tasklists

An optional array of tasklists to search.

boolean $getall

If true, return all instances of the task, otherwise only one. Attempts to find the instance owned by the current user.

Throws

\Horde_Exception_NotFound
\Nag_Exception

Returns

\Nag_Task

A Nag_Task object.

synchronize()

synchronize(mixed  $token = false) 

Synchronize with the Kolab backend.

Parameters

mixed $token

A value indicating the last synchronization point, if available.

_add()

_add(array  $task) : string

Adds a task to the backend storage.

Parameters

array $task

A hash with the following possible properties:

  • actual: (float) The actual time spent on the task.
  • alarm: (integer) The alarm associated with the task.
  • assignee: (string) The assignee of the event.
  • completed: (integer) The completion state of the task.
  • desc: (string) The description (long) of the task.
  • due: (integer) The due date of the task.
  • estimate: (float) The estimated time to complete the task.
  • methods: (array) The overridden alarm notification methods.
  • name: (string) The name (short) of the task.
  • organizer: (string) The organizer/owner of the task.
  • owner: (string) The owner of the event.
  • parent: (string) The parent task.
  • priority: (integer) The priority of the task.
  • private: (boolean) Whether the task is private.
  • recurrence: (Horde_Date_Recurrence|array) Recurrence information.
  • start: (integer) The start date of the task.
  • tags: (array) The task tags.
  • uid: (string) A Unique Identifier for the task.

Throws

\Nag_Exception

Returns

string —

The Nag ID of the new task.

_modify()

_modify(string  $taskId, array  $task) 

Modifies an existing task.

Parameters

string $taskId

The task to modify.

array $task

Throws

\Nag_Exception

_updateTags()

_updateTags(array  $task) 

Helper function to update an existing event's tags to tagger storage.

Parameters

array $task

The task to update

_addTags()

_addTags(array  $task) 

Helper function to add tags from a newly created event to the tagger.

Parameters

array $task

The task to save tags to storage for.

_getBy()

_getBy(  $taskIds, string  $column, array  $tasklists = null) : \Nag_Task

Retrieves one or multiple tasks from the database.

Parameters

$taskIds
string $column

The column name to search for the ID.

array $tasklists

Throws

\Horde_Exception_NotFound
\Nag_Exception

Returns

\Nag_Task

A Nag_Task object.

_addRecurrenceFields()

_addRecurrenceFields(array  $values, array  $task) 

Adds recurrence information to the value hash for SQL INSERT/UPDATE queries.

Parameters

array $values

The fields to update.

array $task

The task information.

_move()

_move(string  $taskId, string  $newTasklist) 

Moves a task to a different tasklist.

Parameters

string $taskId

The task to move.

string $newTasklist

The new tasklist.

Throws

\Nag_Exception

_delete()

_delete(string  $taskId) 

Deletes a task from the backend.

Parameters

string $taskId

The task to delete.

Throws

\Nag_Exception

_deleteAll()

_deleteAll() : array

Deletes all tasks from the backend.

Throws

\Nag_Exception

Returns

array —

An array of uids that have been removed.

_buildTask()

_buildTask(array  $row, boolean  $include_history = true) : array

Return an array describing this task from the provided backend data.

Parameters

array $row

The backend data

boolean $include_history

Include history data.

Returns

array —

The task data.