Source for file actionaction.php
Documentation is available at actionaction.php
* Base class inherited by all actions from the action-triage
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* path (bumblebee root)/inc/actions/actionaction.php
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
/** status codes for success/failure of database actions */
require_once 'inc/statuscodes.php';
* Base class inherited by all actions from the action-triage
* An Action is a single operation requested by the user. What action is to be performed
* is determined by the action-triage mechanism in the class ActionFactory.
* Since http is a stateless protocol, what seems like just one activity
* (e.g. "edit a booking") actually includes multiple http requests
* ("show the user the current values" and "sync changes to disk"). Additionally,
* the one application suite will have many different things to do (e.g. edit/create
* users, edit/create foobar objects). There are two approaches to this multiple
* functions problem: have many .php files that are called directly by the user
* for each function (i.e. links to user.php and foobar.php) but then you can end up
* with a lot of repeated code in each file to control the page layout, load themes,
* control login etc. Alternatively, you can use just the one index.php and include
* an extra control variable in each link that decides what the script should do this time.
* In either case, it is convenient to have a standard "action" object that can be created
* by some ActionFactory which then obeys a standard "action" interface to then
* be used by the internals of the application.
* $action = new ActionFactory($params);
* Unparsed path data from the CGI call
* Parsed input data (combined PATH data and POST data)
* Permit normal HTML output
* Allows previous output (from the HTML template) to be flushed or suppress it so
* The action should be read-only; no data should be changed
* Default status messages that are returned to the user.
* Turn on debugging messages from the Action* classes
* Variable assignment only in this constructor, the child class would normally:
* - use parent's constructor
* @param BumblebeeAuth $auth Authorisation object
* @param array $pdata extra state data from the call path
* Actually perform the action that this Action* class is to perform
* this is an abstract class and this function <b>must</b> be overridden
* Parse the input data sources
/* foreach ($_POST as $k => $v) {
if (isset
($this->PD['id']) &&
$this->PD['id'] ==
'showdeleted') {
$this->PD['showdeleted'] =
true;
/* if (isset($this->PDATA[1]) && $this->PDATA[1] !== '') {
if ($this->PDATA[1] != 'showdeleted') {
$this->PD['id'] = $this->PDATA[1];
$this->PD['showdeleted'] = true;
#$PD['defaultclass'] = 12;
* Reports to the user whether an action was successful
* @param integer $status success or otherwise of action
* @param array $messages (optional) messages to be reported, indexed by $status
* $status codes as per file statuscodes.php
//$this->log('ActionStatus: '.$status);
if (isset
($messages[$status])) {
$message .=
$messages[$status];
foreach ($messages as $code =>
$msg) {
$message =
T_('Unknown status code. Error:').
' '.
$status;
$t =
'<div class="'.
($status & STATUS_OK ?
'msgsuccess' :
'msgerror').
'">'
* Select which item to edit for this action
* @param boolean $deleted (optional) show deleted items
function select($deleted=
false) {
* Delete the selected item
* Generic logging function for use by all Action classes
* The higher the value of $priority, the less likely the message is to
* be output. The normal range for priority is [1-10] with messages with
* ($priority <= $this->DEBUG) being displayed.
* @param string $message the message to be logged to the browser
* @param integer $priority (optional) the priority level of the message
function log ($message, $priority=
10) {
if ($priority <=
$this->DEBUG) {
echo
$message.
"<br />\n";
* Display a message to the user explaining that the requested action cannot be
* performed as the object is "readonly".
* This is designed to be used with the magic token verification system that requires
* that the form that is submitted by the user contains some additional secret data that
* was provided by the installation. This is designed to prevent attacks through getting
* users to visit specially crafted URLs or to submit malicious forms.
* @param string $message message to show to the user explaining that the action cannot be processed
* @see http://www.debian-administration.org/articles/465
printf('<div class="error">%s</div>',
T_('The requested objects are read-only as I can\'t verify the validity of the form you submitted.')
* Cleanse the input data of all fields except for the specifed whitelisted fields
* Removes all user-submitted data fields from the $ActionAction::PD array except for
* the fields that are explicitly whitelisted in the function call.
* @param mixed $fields single field name or list of fields to whitelist
if (! is_array($fields)) $fields =
array($fields);
foreach ($fields as $f) {
$this->PD[$f] =
$data[$f];
Documentation generated on Tue, 06 Mar 2007 10:00:27 +0000 by phpDocumentor 1.3.0