Home « Server software «
Documentation: decisions/decisions.php
Class Decisions - The database abstraction layer for decisions
Decisions are a way to record signatures added to pages. Information stored in a decision includes:- the decision itself, which can be a Yes, or a No
- identification of the person who has signed (typically, id and e-mail address of the surfer)
- the date of the decision
- identification of the signed page (typically, and anchor to some article)
- identification of the container of the signed page (typically, an anchor to some section)
- comment to the decision (optional)
At the moment YACS supports following decision types:
- yes - this is an approval
- no - this is a reject
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
delete() - Delete one decision
function delete($id)
- $id - the id of the decision to delete
- returns an error message, if any
Voir aussi:
delete_for_anchor() - Delete all decisions for a given anchor
function delete_for_anchor($anchor)
- $anchor - the anchor to check
- returns an error message, if any
Voir aussi:
get() - Get one decision by id
function &get($id)
- $id - int the id of the decision
- returns the resulting $item array, with at least keys: 'id', 'type', 'description', etc.
Voir aussi:
get_ballot() - Link to surfer ballot, if any
function get_ballot($anchor)
- $anchor - string the anchor of the vote
- returns either NULL, or the link of the ballot
get_img() - Get a
element
function get_img($type)
- $type - the type ('yes', etc.')
- returns a suitable HTML element
get_next_url() - Get id of next decision
function get_next_url($item, $anchor, $order='date', $capability='?')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- $capability='?' - string surfer actual capability ('?', 'M', or 'A')
- returns some text
Voir aussi:
get_options() - Get types as options of a <SELECT> field
function get_options($type)
- $type - string the current type
- returns the HTML to insert in the page
Voir aussi:
get_previous_url() - Get id of previous decision
function get_previous_url($item, $anchor, $order='date', $capability='?')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- $capability='?' - string surfer actual capability ('?', 'M', or 'A')
- returns some text
Voir aussi:
get_radio_buttons() - Get types as radio buttons
function get_radio_buttons($name, $type)
- $name - string the current type
- $type -
- returns the HTML to insert in the page
Voir aussi:
get_results_for_anchor() - Sum up all decisions for one anchor
function get_results_for_anchor($anchor)
- $anchor - the selected anchor (e.g., 'article:12')
- returns the resulting ($total_count, $yes_count, $no_count) array
get_title() - Get a default title from the type selected
function get_title($type)
- $type - the type ('suggestion', etc.')
- returns a suitable title
get_url() - Get the url to view a decision
function get_url($id, $action='view')
- $id - int the id of the decision to view, or an anchor reference
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- returns an anchor to the viewing script
decisions/view.php?id=512
'),
which may be not processed correctly by search engines.
If the parameter 'with_friendly_urls
' has been set to 'Y
' in the configuration panel,
this function will return an URL parsable by search engines (e.g. 'decisions/view.php/512
').Voir aussi:
list_by_date() - List newest decisions
function &list_by_date($offset=0, $count=10, $variant='date')
- $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='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
// side bar with the list of most recent decisions
include_once 'decisions/decisions.php';
$local['title_en'] = 'Most recent decisions';
$local['title_fr'] = 'décisions récents';
$title = i18n::user('title');
$items = Decisions::list_by_date(0, 10);
$text = Skin::build_list($items, 'compact');
$context['text'] .= Skin::build_box($title, $text, 'navigation');
You can also display the newest decision separately, using Decisions::get_newest() In this case, skip the very first decision in the list by using Decisions::list_by_date(1, 10)
Voir aussi:
list_by_date_for_anchor() - List newest decisions for one anchor
function &list_by_date_for_anchor($anchor, $offset=0, $count=20, $variant='no_anchor', $capability='?')
- $anchor - int the id of the anchor
- $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='no_anchor' - string the list variant, if any
- $capability='?' - string actual surfer capability ('?', 'M', or 'A')
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Example:
include_once 'decisions/decisions.php';
$items = Decisions::list_by_date_for_anchor('section:12', 0, 10);
$context['text'] .= Skin::build_list($items, 'compact');
Voir aussi:
- articles/fetch_as_msword.php
- articles/fetch_as_pdf.php
- articles/fetch_for_palm.php
- articles/print.php
- articles/view.php
- decisions/feed.php
list_by_date_for_author() - List newest decisions 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 decision
- $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)
list_selected() - List selected decisions
function &list_selected(&$result, $layout='compact', $capability='?')
- &$result - resource result of database query
- $layout='compact' - string 'full', etc or object, i.e., an instance of Layout_Interface
- $capability='?' - string '?' or 'A', to support editors and to impersonate associates, where applicable
- returns an array of $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
- 'search' - include anchor information
- 'feeds'
list_threads_by_date() - Thread newest decisions
function &list_threads_by_date($offset=0, $count=10, $variant='date')
- $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='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
post() - Post a new decision or an updated decision
function post($fields)
- $fields - array an array of fields
- returns the id of the new article, or FALSE on error
$context['error']
.Voir aussi:
search() - Search for some keywords in all decisions
function &search($pattern, $offset=0, $count=10, $variant='search')
- $pattern - the search string
- $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='search' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
setup() - Create tables for decisions
function setup()
Voir aussi:
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi:
stat_for_anchor() - Get some statistics for one anchor
function &stat_for_anchor($anchor, $capability='?')
- $anchor - the selected anchor (e.g., 'article:12')
- $capability='?' - string actual surfer capability ('?', 'M', or 'A')
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi:
stat_threads() - Get some statistics on threads
function &stat_threads()
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi: