PHP Class Nag, horde

See the enclosed file COPYING for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.
Author: Jon Parise ([email protected])
Author: Chuck Hagenbuch ([email protected])
Author: Jan Schneider ([email protected])
显示文件 Open project: horde/horde Class Usage Examples

Public Methods

Method Description
_rsortByAssignee ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by assignee.
_rsortByCompletion ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by completion status.
_rsortByDue ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by due date.
_rsortByEstimate ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by name.
_rsortByName ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by name.
_rsortByOwner ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by owner.
_rsortByPriority ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by priority.
_rsortByStart ( array $a, array $b ) : integer Comparison function for reverse sorting tasks by start date.
_sortByAssignee ( array $a, array $b ) : integer Comparison function for sorting tasks by assignee.
_sortByCompletion ( array $a, array $b ) : integer Comparison function for sorting tasks by completion status.
_sortByDue ( array $a, array $b ) : integer Comparison function for sorting tasks by due date.
_sortByEstimate ( array $a, array $b ) : integer Comparison function for sorting tasks by assignee.
_sortByName ( array $a, array $b ) : integer Comparison function for sorting tasks by name.
_sortByOwner ( array $a, array $b ) : integer Comparison function for sorting tasks by owner.
_sortByPriority ( array $a, array $b ) : integer Comparison function for sorting tasks by priority.
_sortByStart ( array $a, array $b ) : integer Comparison function for sorting tasks by start date.
addTasklist ( array $info, boolean $display = true ) : Horde_Share Creates a new share.
buildCheckboxWidget ( string $name, integer $checked ) : string Builds the HTML for a checkbox widget.
buildMimeMessage ( Horde_View $view, string $template, Horde_Mime_Part $image ) : Horde_Mime_Part Builds the body MIME part of a multipart message.
buildPriorityWidget ( string $name, integer $selected ) : string Builds the HTML for a priority selection widget.
countTasks ( ) : integer Returns the number of taks in task lists that the current user owns.
createTasksFromText ( string $text, string $tasklist = null ) : array Imports one or more tasks parsed from a string.
deleteTasklist ( Horde_Share_Object $tasklist ) Deletes a task list.
formatAlarm ( integer $value ) : string Returns the string matching the given alarm value.
formatAssignee ( string $assignee, boolean $link = false ) : string Returns the full name and a compose to message an assignee.
formatCompletion ( integer $completed ) : string Returns the string representation of the given completion status.
formatDate ( string $unixdate = '', boolean $hours = true ) : string Formats the given Unix-style date string.
formatOrganizer ( string $organizer, boolean $link = false ) : string Returns formatted string representing a task organizer.
formatPriority ( integer $priority ) : string Returns a colored representation of a priority.
getDefaultTasklist ( integer $permission = Horde_Perms::SHOW ) : string Returns the default tasklist for the current user at the specified permissions level.
getImagePart ( string $file ) : Horde_Mime_Part Returns a MIME part for an image to be embedded into a HTML document.
getLabel ( $tasklist ) : string Returns the label to be used for a task list.
getSyncLists ( ) : array Returns the tasklists that should be used for syncing.
getTask ( string $tasklist, string $task ) : Nag_Task Returns a single task.
getUrl ( integer $type, $tasklist ) : string Returns a DAV URL to be used for a task list.
getUserEmail ( $user )
getUserName ( string $uid ) : string Returns the real name, if available, of a user.
hasPermission ( string $tasklist, integer $perm ) : boolean Returns whether the current user has certain permissions on a tasklist.
initialize ( ) Initial app setup code.
listAlarms ( integer $date, array $tasklists = null ) : array Returns all the alarms active right on $date.
listTasklists ( boolean $owneronly = false, integer $permission = Horde_Perms::SHOW, boolean $smart = true ) : array Lists all task lists a user has access to.
listTasks ( array $options = [] ) : Nag_Task Retrieves the current user's task list from storage.
parseDate ( string $date, boolean $withtime = true ) : Horde_Date Parses a complete date-time string into a Horde_Date object.
randomColor ( ) : string Returns a random CSS color.
responseFromICal ( string $response ) : string Maps an iCalendar attendee response string to the corresponding Nag value.
secondsToString ( integer $seconds ) : string
sendITipNotifications ( Nag_Task $task, Horde_Notification_Handler $notification, integer $action, Horde_Date $instance = null, string $range = null ) Sends out iTip task notification to the assignee.
sendNotification ( string $action, Nag_Task $task, Nag_Task $old_task = null ) Sends email notifications that a task has been added, edited, or deleted to users that want such notifications.
status ( ) Trigger notifications.
updateTasklist ( Horde_Share_Object $tasklist, array $info ) Updates an existing share.

Protected Methods

Method Description
_getOwner ( Nag_Task $task ) : string Returns the owner of a task.
_notificationPref ( string $user, string $mode, string $tasklist = null ) : boolean Returns whether a user wants email notifications for a tasklist.

Method Details

_getOwner() protected static method

Returns the owner of a task.
protected static _getOwner ( Nag_Task $task ) : string
$task Nag_Task A task.
return string The task's owner.

_notificationPref() protected static method

Returns whether a user wants email notifications for a tasklist.
protected static _notificationPref ( string $user, string $mode, string $tasklist = null ) : boolean
$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 The name of the tasklist if mode is "read".
return boolean True if the user wants notifications for the tasklist.

_rsortByAssignee() public static method

Comparison function for reverse sorting tasks by assignee.
public static _rsortByAssignee ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByCompletion() public static method

Comparison function for reverse sorting tasks by completion status.
public static _rsortByCompletion ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByDue() public static method

Comparison function for reverse sorting tasks by due date.
public static _rsortByDue ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater, 0 if they are equal.

_rsortByEstimate() public static method

Comparison function for reverse sorting tasks by name.
public static _rsortByEstimate ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByName() public static method

Comparison function for reverse sorting tasks by name.
public static _rsortByName ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByOwner() public static method

Comparison function for reverse sorting tasks by owner.
public static _rsortByOwner ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByPriority() public static method

Comparison function for reverse sorting tasks by priority.
public static _rsortByPriority ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater; 0 if they are equal.

_rsortByStart() public static method

Comparison function for reverse sorting tasks by start date.
public static _rsortByStart ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer -1 if task one is greater, 1 if task two is greater, 0 if they are equal.

_sortByAssignee() public static method

Comparison function for sorting tasks by assignee.
public static _sortByAssignee ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByCompletion() public static method

Comparison function for sorting tasks by completion status.
public static _sortByCompletion ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByDue() public static method

Comparison function for sorting tasks by due date.
public static _sortByDue ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByEstimate() public static method

Comparison function for sorting tasks by assignee.
public static _sortByEstimate ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByName() public static method

Comparison function for sorting tasks by name.
public static _sortByName ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByOwner() public static method

Comparison function for sorting tasks by owner.
public static _sortByOwner ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByPriority() public static method

Comparison function for sorting tasks by priority.
public static _sortByPriority ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

_sortByStart() public static method

Comparison function for sorting tasks by start date.
public static _sortByStart ( array $a, array $b ) : integer
$a array Task one.
$b array Task two.
return integer 1 if task one is greater, -1 if task two is greater; 0 if they are equal.

addTasklist() public static method

Creates a new share.
public static addTasklist ( array $info, boolean $display = true ) : Horde_Share
$info array Hash with tasklist information.
$display boolean Add the new tasklist to display_tasklists
return Horde_Share The new share.

buildCheckboxWidget() public static method

Builds the HTML for a checkbox widget.
public static buildCheckboxWidget ( string $name, integer $checked ) : string
$name string The name of the widget.
$checked integer The default checkbox state.
return string HTML for a checkbox representing the completion state.

buildMimeMessage() public static method

Builds the body MIME part of a multipart message.
public static buildMimeMessage ( Horde_View $view, string $template, Horde_Mime_Part $image ) : Horde_Mime_Part
$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 Horde_Mime_Part A multipart/alternative MIME part.

buildPriorityWidget() public static method

Builds the HTML for a priority selection widget.
public static buildPriorityWidget ( string $name, integer $selected ) : string
$name string The name of the widget.
$selected integer The default selected priority.
return string The HTML

countTasks() public static method

Returns the number of taks in task lists that the current user owns.
public static countTasks ( ) : integer
return integer The number of tasks that the user owns.

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.

deleteTasklist() public static method

Deletes a task list.
public static deleteTasklist ( Horde_Share_Object $tasklist )
$tasklist Horde_Share_Object The task list to delete.

formatAlarm() public static method

Returns the string matching the given alarm value.
public static formatAlarm ( integer $value ) : string
$value integer The alarm value in minutes.
return string The formatted alarm string.

formatAssignee() public static method

Returns the full name and a compose to message an assignee.
public static formatAssignee ( string $assignee, boolean $link = false ) : string
$assignee string The assignee's user name.
$link boolean Whether to link to an email compose screen.
return string The formatted assignee name.

formatCompletion() public static method

Returns the string representation of the given completion status.
public static formatCompletion ( integer $completed ) : string
$completed integer The completion value.
return string The HTML representation of $completed.

formatDate() public static method

Formats the given Unix-style date string.
public static formatDate ( string $unixdate = '', boolean $hours = true ) : string
$unixdate string The Unix-style date value to format.
$hours boolean Whether to add hours.
return string The formatted due date string.

formatOrganizer() public static method

Returns formatted string representing a task organizer.
public static formatOrganizer ( string $organizer, boolean $link = false ) : string
$organizer string The organinzer, as an email or mailto: format.
$link boolean Whether to link to an email compose screen.
return string The formatted organizer name.

formatPriority() public static method

Returns a colored representation of a priority.
public static formatPriority ( integer $priority ) : string
$priority integer The priority level.
return string The HTML representation of $priority.

getDefaultTasklist() public static method

Returns the default tasklist for the current user at the specified permissions level.
public static getDefaultTasklist ( integer $permission = Horde_Perms::SHOW ) : string
$permission integer Horde_Perms constant for permission level required.
return string The default tasklist or null if none.

getImagePart() public static method

Returns a MIME part for an image to be embedded into a HTML document.
public static getImagePart ( string $file ) : Horde_Mime_Part
$file string An image file name.
return Horde_Mime_Part A MIME part representing the image.

getLabel() public static method

Attaches the owner name of shared task lists if necessary.
public static getLabel ( $tasklist ) : string
return string The task list's label.

getSyncLists() public static method

Returns the tasklists that should be used for syncing.
public static getSyncLists ( ) : array
return array An array of task list ids

getTask() public static method

Returns a single task.
public static getTask ( string $tasklist, string $task ) : Nag_Task
$tasklist string A tasklist.
$task string A task id.
return Nag_Task The task hash.

getUrl() public static method

Returns a DAV URL to be used for a task list.
public static getUrl ( integer $type, $tasklist ) : string
$type integer A Nag::DAV_* constant.
return string The task list's URL.

getUserEmail() public static method

public static getUserEmail ( $user )

getUserName() public static method

Returns the real name, if available, of a user.
public static getUserName ( string $uid ) : string
$uid string The userid of the user to retrieve
return string The fullname of the user.

hasPermission() public static method

Returns whether the current user has certain permissions on a tasklist.
public static hasPermission ( string $tasklist, integer $perm ) : boolean
$tasklist string A tasklist id.
$perm integer A Horde_Perms permission mask.
return boolean True if the current user has the requested permissions.

initialize() public static method

Initial app setup code.
public static initialize ( )

listAlarms() public static method

Returns all the alarms active right on $date.
public static listAlarms ( integer $date, array $tasklists = null ) : array
$date integer The unix epoch time to check for alarms.
$tasklists array An array of tasklists
return array An array of Nag_Task objects with alarms active on $date.

listTasklists() public static method

Lists all task lists a user has access to.
public static listTasklists ( boolean $owneronly = false, integer $permission = Horde_Perms::SHOW, boolean $smart = true ) : array
$owneronly boolean Only return task lists that this user owns? Defaults to false.
$permission integer The permission to filter task lists by.
$smart boolean Include SmartLists in the results.
return array The task lists.

listTasks() public static method

This function will also sort the resulting list, if requested.
public static listTasks ( array $options = [] ) : Nag_Task
$options 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 Nag_Task A list of the requested tasks.

parseDate() public static method

Parses a complete date-time string into a Horde_Date object.
public static parseDate ( string $date, boolean $withtime = true ) : Horde_Date
$date string The date-time string to parse.
$withtime boolean Whether time is included in the string.
return Horde_Date The parsed date.

randomColor() public static method

Returns a random CSS color.
public static randomColor ( ) : string
return string A random CSS color string.

responseFromICal() public static method

Maps an iCalendar attendee response string to the corresponding Nag value.
public static responseFromICal ( string $response ) : string
$response string The attendee response.
return string The Nag response value.

secondsToString() public static method

public static secondsToString ( integer $seconds ) : string
$seconds integer
return string

sendITipNotifications() public static method

Can be used to send task invitations, updates, and cancellations.
public static sendITipNotifications ( Nag_Task $task, Horde_Notification_Handler $notification, integer $action, Horde_Date $instance = null, string $range = null )
$task Nag_Task The task in question.
$notification Horde_Notification_Handler A notification object used to show result status.
$action integer The type of notification to send. One of the Nag::ITIP_* values.
$instance Horde_Date If cancelling a single instance of a recurring task, the date of this instance.
$range string The range parameter if this is a recurring event. Possible values are self::RANGE_THISANDFUTURE

sendNotification() public static method

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 )
$action string The event action. One of "add", "edit", or "delete".
$task Nag_Task The changed task.
$old_task Nag_Task The original task if $action is "edit".

status() public static method

Trigger notifications.
public static status ( )

updateTasklist() public static method

Updates an existing share.
public static updateTasklist ( Horde_Share_Object $tasklist, array $info )
$tasklist Horde_Share_Object The share to update.
$info array Hash with task list information.