Documentation : actions/actions.php
- Class Actions - The database abstraction layer for actions
- Accept() - Accept an action
- Are_allowed() - Check if new actions can be added
- Delete() - Delete one action
- Delete_for_anchor() - Delete all actions for a given anchor
- Duplicate_for_anchor() - Duplicate all actions for a given anchor
- Get() - Get one action by id
- Get_next_url() - Get id of next action
- Get_previous_url() - Get id of previous action
- Get_url() - Build a reference to an action
- List_by_date() - List newest actions
- List_by_date_for_anchor() - List newest on-going actions for one anchor
- List_by_date_for_author() - List newest actions for one author
- List_completed_for_anchor() - List newest completed actions for one anchor
- List_rejected_for_anchor() - List newest rejected actions for one anchor
- List_selected() - List selected actions
- Post() - Post a new action or an updated action
- Setup() - Create or alter tables for actions
- Stat() - Get some statistics
- Stat_for_anchor() - Get some statistics for one anchor
Class Actions - The database abstraction layer for actions
Actions are like post-it notes, or reminders. They are a very straightforward way of managing short-lived and task-oriented items of information.The life cycle of an action is quite simple. An action is created, then closed. An action record is created when some community member is tasked to do something. Like for paper reminders, you can create actions for yourself or for others. Then actions can be either rejected or completed by the person to which they have been assigned.
While being really simplistic, this implementation of actions is quite enough to support following patterns of workflow:
Every action record has following attributes:
- an anchor - usually, some user profile
- a title and a description
- an optional target designation - usually, the URL of another page
- a status that can be: 'on-going', 'completed' or 'rejected'
- dates of creation and last modification are recorded as well
This script is a reference file of this system.
Licence : GNU Lesser General Public License
Auteurs :
- Bernard Paques bernard.paques@bigfoot.com
- Florent
- Christophe Battarel christophe.battarel@altairis.fr
accept() - Accept an action
function accept($id, $status = 'on-going')
- $id - int the id of the item to accept
- $status = 'on-going' - string the new status
- 'on-going' - the action has been started
- 'completed' - nothing more to do
- 'rejected' - the task has been cancelled for some reason
The name of the surfer and the modification date is recorded as well.
Voir aussi :
are_allowed() - Check if new actions can be added
function are_allowed($anchor=NULL, $item=NULL)
- $anchor=NULL - object an instance of the Anchor interface, if any
- $item=NULL - array a set of item attributes, if any
- returns TRUE or FALSE
The function prevents the creation of new actions when:
- the global parameter 'users_without_submission' has been set to 'Y'
- provided item has been locked
- item has some option 'no_actions' that prevents new actions
- the anchor has some option 'no_actions' that prevents new actions
Then the function allows for new actions when:
- surfer has been authenticated as a valid member
Then, ultimately, the default is not allow for the creation of new actions.
delete() - Delete one action
function delete($id)
- $id - int the id of the action to delete
- returns boolean TRUE on success, FALSE otherwise
Voir aussi :
delete_for_anchor() - Delete all actions for a given anchor
function delete_for_anchor($anchor)
- $anchor - string the anchor to check
Voir aussi :
duplicate_for_anchor() - Duplicate all actions for a given anchor
function duplicate_for_anchor($anchor_from, $anchor_to)
- $anchor_from - string the source anchor
- $anchor_to - string the target anchor
- returns int the number of duplicated records
Voir aussi :
get() - Get one action by id
function &get($id)
- $id - int the id of the action
- returns the resulting $item array, with at least keys: 'id', 'title', etc.
get_next_url() - Get id of next action
function get_next_url($item, $anchor, $order='date')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- returns some text
Voir aussi :
get_previous_url() - Get id of previous action
function get_previous_url($item, $anchor, $order='date')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- returns some text
Voir aussi :
get_url() - Build a reference to an action
function get_url($id, $action='view', $name=NULL)
- $id - int the id of the action to handle
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- $name=NULL - string additional data, such as page name, if any
- returns string a normalized reference
with_friendly_urls' and on action,
following results can be observed:
- view - actions/view.php?id=123 or actions/view.php/123 or action-123
- other - actions/edit.php?id=123 or actions/edit.php/123 or action-edit/123
Voir aussi :
list_by_date() - List newest actions
function &list_by_date($offset=0, $count=10, $variant='full')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='full' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
list_by_date_for_anchor() - List newest on-going actions for one anchor
function &list_by_date_for_anchor($anchor, $offset=0, $count=20, $variant=NULL)
- $anchor - string the anchor (e.g., 'user:123')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=20 - int the number of items to display
- $variant=NULL - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
list_by_date_for_author() - List newest actions for one author
function &list_by_date_for_author($author_id, $offset=0, $count=20, $variant='date')
- $author_id - int the id of the author of the action
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=20 - int the number of items to display
- $variant='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
include_once 'actions/actions.php';
$items = actions::list_by_date_for_author(0, COMPACT_LIST_SIZE, '', 12);
$context['text'] .= Skin::build_list($items, 'compact');
list_completed_for_anchor() - List newest completed actions for one anchor
function &list_completed_for_anchor($anchor, $offset=0, $count=20, $variant=NULL)
- $anchor - string the anchor (e.g., 'user:123')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=20 - int the number of items to display
- $variant=NULL - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
list_rejected_for_anchor() - List newest rejected actions for one anchor
function &list_rejected_for_anchor($anchor, $offset=0, $count=20, $variant=NULL)
- $anchor - string the anchor (e.g., 'user:123')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=20 - int the number of items to display
- $variant=NULL - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
list_selected() - List selected actions
function &list_selected(&$result, $layout='compact')
- &$result - resource result of database query
- $layout='compact' - string 'full', etc or object, i.e., an instance of Layout_Interface
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
- 'compact' - to build short lists in boxes and sidebars (this is the default)
- 'no_anchor' - to build detailed lists in an anchor page
- 'full' - include anchor information
post() - Post a new action or an updated action
function post($fields)
- $fields - array an array of fields
- returns the id of the new action, or FALSE on error
setup() - Create or alter tables for actions
function setup()
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $min_date, $max_date) array
stat_for_anchor() - Get some statistics for one anchor
function &stat_for_anchor($anchor)
- $anchor - the selected anchor (e.g., 'article:12')
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi :