Nag
in package
Nag Base Class.
See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.
Tags
Table of Contents
- DAV_ACCOUNT = 3
- CalDAV principal.
- DAV_CALDAV = 2
- CalDAV task list.
- DAV_WEBDAV = 1
- WebDAV task list.
- ITIP_CANCEL = 2
- ITIP_REQUEST = 1
- iTip requests
- ITIP_UPDATE = 3
- RANGE_THISANDFUTURE = 'THISANDFUTURE'
- RESPONSE_ACCEPTED = 2
- RESPONSE_DECLINED = 3
- RESPONSE_NONE = 1
- Status codes
- SORT_ASCEND = 0
- Sort in ascending order.
- SORT_ASSIGNEE = 'assignee'
- Sort by assignee.
- SORT_COMPLETION = 'completed'
- Sort by completion.
- SORT_DESCEND = 1
- Sort in descending order.
- SORT_DUE = 'due'
- Sort by due date.
- SORT_ESTIMATE = 'estimate'
- Sort by estimate.
- SORT_NAME = 'name'
- Sort by task name.
- SORT_OWNER = 'tasklist'
- Sort by owner.
- SORT_PRIORITY = 'priority'
- Sort by priority.
- SORT_START = 'start'
- Sort by start date.
- VIEW_ALL = 1
- All tasks
- VIEW_COMPLETE = 2
- Complete tasks
- VIEW_FUTURE = 3
- Future tasks
- VIEW_FUTURE_INCOMPLETE = 4
- Future and incompleted tasks
- VIEW_INCOMPLETE = 0
- Incomplete tasks
- _rsortByAssignee() : int
- Comparison function for reverse sorting tasks by assignee.
- _rsortByCompletion() : int
- Comparison function for reverse sorting tasks by completion status.
- _rsortByDue() : int
- Comparison function for reverse sorting tasks by due date.
- _rsortByEstimate() : int
- Comparison function for reverse sorting tasks by name.
- _rsortByName() : int
- Comparison function for reverse sorting tasks by name.
- _rsortByOwner() : int
- Comparison function for reverse sorting tasks by owner.
- _rsortByPriority() : int
- Comparison function for reverse sorting tasks by priority.
- _rsortByStart() : int
- Comparison function for reverse sorting tasks by start date.
- _sortByAssignee() : int
- Comparison function for sorting tasks by assignee.
- _sortByCompletion() : int
- Comparison function for sorting tasks by completion status.
- _sortByDue() : int
- Comparison function for sorting tasks by due date.
- _sortByEstimate() : int
- Comparison function for sorting tasks by assignee.
- _sortByName() : int
- Comparison function for sorting tasks by name.
- _sortByOwner() : int
- Comparison function for sorting tasks by owner.
- _sortByPriority() : int
- Comparison function for sorting tasks by priority.
- _sortByStart() : int
- Comparison function for sorting tasks by start date.
- addTasklist() : Horde_Share
- Creates a new share.
- buildCheckboxWidget() : string
- Builds the HTML for a checkbox widget.
- buildMimeMessage() : Horde_Mime_Part
- Builds the body MIME part of a multipart message.
- buildPriorityWidget() : string
- Builds the HTML for a priority selection widget.
- countTasks() : int
- Returns the number of taks in task lists that the current user owns.
- createTasksFromText() : array<string|int, mixed>
- Imports one or more tasks parsed from a string.
- deleteTasklist() : mixed
- Deletes a task list.
- formatAlarm() : string
- Returns the string matching the given alarm value.
- formatAssignee() : string
- Returns the full name and a compose to message an assignee.
- formatCompletion() : string
- Returns the string representation of the given completion status.
- formatDate() : string
- Formats the given Unix-style date string.
- formatOrganizer() : string
- Returns formatted string representing a task organizer.
- formatPriority() : string
- Returns a colored representation of a priority.
- getDefaultTasklist() : string
- Returns the default tasklist for the current user at the specified permissions level.
- getImagePart() : Horde_Mime_Part
- Returns a MIME part for an image to be embedded into a HTML document.
- getLabel() : string
- Returns the label to be used for a task list.
- getSyncLists() : array<string|int, mixed>
- Returns the tasklists that should be used for syncing.
- getTask() : Nag_Task
- Returns a single task.
- getUrl() : string
- Returns a DAV URL to be used for a task list.
- getUserEmail() : mixed
- getUserName() : string
- Returns the real name, if available, of a user.
- hasPermission() : bool
- Returns whether the current user has certain permissions on a tasklist.
- initialize() : mixed
- Initial app setup code.
- listAlarms() : array<string|int, mixed>
- Returns all the alarms active right on $date.
- listTasklists() : array<string|int, mixed>
- Lists all task lists a user has access to.
- listTasks() : Nag_Task
- Retrieves the current user's task list from storage.
- parseDate() : Horde_Date
- Parses a complete date-time string into a Horde_Date object.
- randomColor() : string
- Returns a random CSS color.
- responseFromICal() : string
- Maps an iCalendar attendee response string to the corresponding Nag value.
- secondsToString() : string
- sendITipNotifications() : mixed
- Sends out iTip task notification to the assignee.
- sendNotification() : mixed
- Sends email notifications that a task has been added, edited, or deleted to users that want such notifications.
- status() : mixed
- Trigger notifications.
- updateTasklist() : mixed
- Updates an existing share.
- _getOwner() : string
- Returns the owner of a task.
- _notificationPref() : bool
- Returns whether a user wants email notifications for a tasklist.
Constants
DAV_ACCOUNT
CalDAV principal.
public
mixed
DAV_ACCOUNT
= 3
DAV_CALDAV
CalDAV task list.
public
mixed
DAV_CALDAV
= 2
DAV_WEBDAV
WebDAV task list.
public
mixed
DAV_WEBDAV
= 1
ITIP_CANCEL
public
mixed
ITIP_CANCEL
= 2
ITIP_REQUEST
iTip requests
public
mixed
ITIP_REQUEST
= 1
ITIP_UPDATE
public
mixed
ITIP_UPDATE
= 3
RANGE_THISANDFUTURE
public
mixed
RANGE_THISANDFUTURE
= 'THISANDFUTURE'
RESPONSE_ACCEPTED
public
mixed
RESPONSE_ACCEPTED
= 2
RESPONSE_DECLINED
public
mixed
RESPONSE_DECLINED
= 3
RESPONSE_NONE
Status codes
public
mixed
RESPONSE_NONE
= 1
SORT_ASCEND
Sort in ascending order.
public
mixed
SORT_ASCEND
= 0
SORT_ASSIGNEE
Sort by assignee.
public
mixed
SORT_ASSIGNEE
= 'assignee'
SORT_COMPLETION
Sort by completion.
public
mixed
SORT_COMPLETION
= 'completed'
SORT_DESCEND
Sort in descending order.
public
mixed
SORT_DESCEND
= 1
SORT_DUE
Sort by due date.
public
mixed
SORT_DUE
= 'due'
SORT_ESTIMATE
Sort by estimate.
public
mixed
SORT_ESTIMATE
= 'estimate'
SORT_NAME
Sort by task name.
public
mixed
SORT_NAME
= 'name'
SORT_OWNER
Sort by owner.
public
mixed
SORT_OWNER
= 'tasklist'
SORT_PRIORITY
Sort by priority.
public
mixed
SORT_PRIORITY
= 'priority'
SORT_START
Sort by start date.
public
mixed
SORT_START
= 'start'
VIEW_ALL
All tasks
public
mixed
VIEW_ALL
= 1
VIEW_COMPLETE
Complete tasks
public
mixed
VIEW_COMPLETE
= 2
VIEW_FUTURE
Future tasks
public
mixed
VIEW_FUTURE
= 3
VIEW_FUTURE_INCOMPLETE
Future and incompleted tasks
public
mixed
VIEW_FUTURE_INCOMPLETE
= 4
VIEW_INCOMPLETE
Incomplete tasks
public
mixed
VIEW_INCOMPLETE
= 0
Methods
_rsortByAssignee()
Comparison function for reverse sorting tasks by assignee.
public
static _rsortByAssignee(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByCompletion()
Comparison function for reverse sorting tasks by completion status.
public
static _rsortByCompletion(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByDue()
Comparison function for reverse sorting tasks by due date.
public
static _rsortByDue(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater, 0 if they are equal.
_rsortByEstimate()
Comparison function for reverse sorting tasks by name.
public
static _rsortByEstimate(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByName()
Comparison function for reverse sorting tasks by name.
public
static _rsortByName(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByOwner()
Comparison function for reverse sorting tasks by owner.
public
static _rsortByOwner(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByPriority()
Comparison function for reverse sorting tasks by priority.
public
static _rsortByPriority(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater; 0 if they are equal.
_rsortByStart()
Comparison function for reverse sorting tasks by start date.
public
static _rsortByStart(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —-1 if task one is greater, 1 if task two is greater, 0 if they are equal.
_sortByAssignee()
Comparison function for sorting tasks by assignee.
public
static _sortByAssignee(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByCompletion()
Comparison function for sorting tasks by completion status.
public
static _sortByCompletion(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByDue()
Comparison function for sorting tasks by due date.
public
static _sortByDue(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByEstimate()
Comparison function for sorting tasks by assignee.
public
static _sortByEstimate(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByName()
Comparison function for sorting tasks by name.
public
static _sortByName(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByOwner()
Comparison function for sorting tasks by owner.
public
static _sortByOwner(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByPriority()
Comparison function for sorting tasks by priority.
public
static _sortByPriority(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
_sortByStart()
Comparison function for sorting tasks by start date.
public
static _sortByStart(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
Task one.
- $b : array<string|int, mixed>
-
Task two.
Return values
int —1 if task one is greater, -1 if task two is greater; 0 if they are equal.
addTasklist()
Creates a new share.
public
static addTasklist(array<string|int, mixed> $info[, bool $display = true ]) : Horde_Share
Parameters
- $info : array<string|int, mixed>
-
Hash with tasklist information.
- $display : bool = true
-
Add the new tasklist to display_tasklists
Return values
Horde_Share —The new share.
buildCheckboxWidget()
Builds the HTML for a checkbox widget.
public
static buildCheckboxWidget(string $name, int $checked) : string
Parameters
- $name : string
-
The name of the widget.
- $checked : int
-
The default checkbox state.
Return values
string —HTML for a checkbox representing the completion state.
buildMimeMessage()
Builds the body MIME part of a multipart message.
public
static buildMimeMessage(Horde_View $view, string $template, Horde_Mime_Part $image) : Horde_Mime_Part
Parameters
- $view : Horde_View
-
A view to render the HTML and plain text templates for the messate.
- $template : string
-
The template base name for the view.
- $image : Horde_Mime_Part
-
The MIME part of a related image.
Return values
Horde_Mime_Part —A multipart/alternative MIME part.
buildPriorityWidget()
Builds the HTML for a priority selection widget.
public
static buildPriorityWidget(string $name[, int $selected = -1 ]) : string
Parameters
- $name : string
-
The name of the widget.
- $selected : int = -1
-
The default selected priority.
Return values
string —The HTML
countTasks()
Returns the number of taks in task lists that the current user owns.
public
static countTasks() : int
Return values
int —The number of tasks that the user owns.
createTasksFromText()
Imports one or more tasks parsed from a string.
public
static createTasksFromText(string $text[, string $tasklist = null ]) : array<string|int, mixed>
Parameters
- $text : string
-
The text to parse into
- $tasklist : string = null
-
The tasklist into which the task will be imported. If 'null', the user's default tasklist will be used.
Return values
array<string|int, mixed> —The UIDs of all tasks that were added.
deleteTasklist()
Deletes a task list.
public
static deleteTasklist(Horde_Share_Object $tasklist) : mixed
Parameters
- $tasklist : Horde_Share_Object
-
The task list to delete.
Tags
Return values
mixed —formatAlarm()
Returns the string matching the given alarm value.
public
static formatAlarm(int $value) : string
Parameters
- $value : int
-
The alarm value in minutes.
Return values
string —The formatted alarm string.
formatAssignee()
Returns the full name and a compose to message an assignee.
public
static formatAssignee(string $assignee[, bool $link = false ]) : string
Parameters
- $assignee : string
-
The assignee's user name.
- $link : bool = false
-
Whether to link to an email compose screen.
Return values
string —The formatted assignee name.
formatCompletion()
Returns the string representation of the given completion status.
public
static formatCompletion(int $completed) : string
Parameters
- $completed : int
-
The completion value.
Return values
string —The HTML representation of $completed.
formatDate()
Formats the given Unix-style date string.
public
static formatDate([string $unixdate = '' ][, bool $hours = true ]) : string
Parameters
- $unixdate : string = ''
-
The Unix-style date value to format.
- $hours : bool = true
-
Whether to add hours.
Return values
string —The formatted due date string.
formatOrganizer()
Returns formatted string representing a task organizer.
public
static formatOrganizer(string $organizer[, bool $link = false ]) : string
Parameters
- $organizer : string
-
The organinzer, as an email or mailto: format.
- $link : bool = false
-
Whether to link to an email compose screen.
Return values
string —The formatted organizer name.
formatPriority()
Returns a colored representation of a priority.
public
static formatPriority(int $priority) : string
Parameters
- $priority : int
-
The priority level.
Return values
string —The HTML representation of $priority.
getDefaultTasklist()
Returns the default tasklist for the current user at the specified permissions level.
public
static getDefaultTasklist([int $permission = Horde_Perms::SHOW ]) : string
Parameters
- $permission : int = Horde_Perms::SHOW
-
Horde_Perms constant for permission level required.
Return values
string —The default tasklist or null if none.
getImagePart()
Returns a MIME part for an image to be embedded into a HTML document.
public
static getImagePart(string $file) : Horde_Mime_Part
Parameters
- $file : string
-
An image file name.
Return values
Horde_Mime_Part —A MIME part representing the image.
getLabel()
Returns the label to be used for a task list.
public
static getLabel(mixed $tasklist) : string
Attaches the owner name of shared task lists if necessary.
Parameters
- $tasklist : mixed
Return values
string —The task list's label.
getSyncLists()
Returns the tasklists that should be used for syncing.
public
static getSyncLists() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of task list ids
getTask()
Returns a single task.
public
static getTask(string $tasklist, string $task) : Nag_Task
Parameters
- $tasklist : string
-
A tasklist.
- $task : string
-
A task id.
Return values
Nag_Task —The task hash.
getUrl()
Returns a DAV URL to be used for a task list.
public
static getUrl(int $type, mixed $tasklist) : string
Parameters
- $type : int
-
A Nag::DAV_* constant.
- $tasklist : mixed
Tags
Return values
string —The task list's URL.
getUserEmail()
public
static getUserEmail(mixed $user) : mixed
Parameters
- $user : mixed
Return values
mixed —getUserName()
Returns the real name, if available, of a user.
public
static getUserName(string $uid) : string
Parameters
- $uid : string
-
The userid of the user to retrieve
Return values
string —The fullname of the user.
hasPermission()
Returns whether the current user has certain permissions on a tasklist.
public
static hasPermission(string $tasklist, int $perm) : bool
Parameters
- $tasklist : string
-
A tasklist id.
- $perm : int
-
A Horde_Perms permission mask.
Return values
bool —True if the current user has the requested permissions.
initialize()
Initial app setup code.
public
static initialize() : mixed
Return values
mixed —listAlarms()
Returns all the alarms active right on $date.
public
static listAlarms(int $date[, array<string|int, mixed> $tasklists = null ]) : array<string|int, mixed>
Parameters
- $date : int
-
The unix epoch time to check for alarms.
- $tasklists : array<string|int, mixed> = null
-
An array of tasklists
Return values
array<string|int, mixed> —An array of Nag_Task objects with alarms active on $date.
listTasklists()
Lists all task lists a user has access to.
public
static listTasklists([bool $owneronly = false ][, int $permission = Horde_Perms::SHOW ][, bool $smart = true ]) : array<string|int, mixed>
Parameters
- $owneronly : bool = false
-
Only return task lists that this user owns? Defaults to false.
- $permission : int = Horde_Perms::SHOW
-
The permission to filter task lists by.
- $smart : bool = true
-
Include SmartLists in the results.
Return values
array<string|int, mixed> —The task lists.
listTasks()
Retrieves the current user's task list from storage.
public
static listTasks([arary $options = array() ]) : Nag_Task
This function will also sort the resulting list, if requested.
Parameters
- $options : arary = array()
-
Options array:
- altsortby: (string) The secondary sort field. Same values as sortdir. DEFAULT: altsortby pref is used.
- completed: (integer) Which task to retrieve. A Nag::VIEW_* constant. DEFAULT: show_completed pref is used.
- external: (boolean) Whether to include tasks from other applications too. DEFAULT: true.
- include_history: (boolean) Autoload created/modified data from Horde_History. DEFAULT: true (Automatically load history data).
- include_tags: (boolean) Autoload all tags. DEFAULT: false (Tags are lazy loaded as needed.)
- sortby: (string) A Nag::SORT_* constant for the field to sort by. DEFAULT: sortby pref is used.
- sortdir: (string) Direction of sort. NAG::SORT_ASCEND or NAG::SORT_DESCEND. DEFAULT: sortdir pref is used.
- tasklists: (array) An array of tasklists to include. DEFAULT: Use $GLOBALS['display_tasklists'];
Return values
Nag_Task —A list of the requested tasks.
parseDate()
Parses a complete date-time string into a Horde_Date object.
public
static parseDate(string $date[, bool $withtime = true ]) : Horde_Date
Parameters
- $date : string
-
The date-time string to parse.
- $withtime : bool = true
-
Whether time is included in the string.
Tags
Return values
Horde_Date —The parsed date.
randomColor()
Returns a random CSS color.
public
static randomColor() : string
Return values
string —A random CSS color string.
responseFromICal()
Maps an iCalendar attendee response string to the corresponding Nag value.
public
static responseFromICal(string $response) : string
Parameters
- $response : string
-
The attendee response.
Return values
string —The Nag response value.
secondsToString()
public
static secondsToString(int $seconds) : string
Parameters
- $seconds : int
Return values
string —sendITipNotifications()
Sends out iTip task notification to the assignee.
public
static sendITipNotifications(Nag_Task $task, Horde_Notification_Handler $notification, int $action[, Horde_Date $instance = null ][, string $range = null ]) : mixed
Can be used to send task invitations, updates, and cancellations.
Parameters
- $task : Nag_Task
-
The task in question.
- $notification : Horde_Notification_Handler
-
A notification object used to show result status.
- $action : int
-
The type of notification to send. One of the Nag::ITIP_* values.
- $instance : Horde_Date = null
-
If cancelling a single instance of a recurring task, the date of this instance.
- $range : string = null
-
The range parameter if this is a recurring event. Possible values are self::RANGE_THISANDFUTURE
Return values
mixed —sendNotification()
Sends email notifications that a task has been added, edited, or deleted to users that want such notifications.
public
static sendNotification(string $action, Nag_Task $task[, Nag_Task $old_task = null ]) : mixed
Parameters
- $action : string
-
The event action. One of "add", "edit", or "delete".
- $task : Nag_Task
-
The changed task.
- $old_task : Nag_Task = null
-
The original task if $action is "edit".
Tags
Return values
mixed —status()
Trigger notifications.
public
static status() : mixed
Return values
mixed —updateTasklist()
Updates an existing share.
public
static updateTasklist(Horde_Share_Object $tasklist, array<string|int, mixed> $info) : mixed
Parameters
- $tasklist : Horde_Share_Object
-
The share to update.
- $info : array<string|int, mixed>
-
Hash with task list information.
Tags
Return values
mixed —_getOwner()
Returns the owner of a task.
protected
static _getOwner(Nag_Task $task) : string
Parameters
- $task : Nag_Task
-
A task.
Return values
string —The task's owner.
_notificationPref()
Returns whether a user wants email notifications for a tasklist.
protected
static _notificationPref(string $user, string $mode[, string $tasklist = null ]) : bool
Parameters
- $user : string
-
A user name.
- $mode : string
-
The check "mode". If "owner", the method checks if the user wants notifications only for tasklists he owns. If "read", the method checks if the user wants notifications for all tasklists he has read access to, or only for shown tasklists and the specified tasklist is currently shown.
- $tasklist : string = null
-
The name of the tasklist if mode is "read".
Tags
Return values
bool —True if the user wants notifications for the tasklist.