.

StatusAnyCommand Class Reference
[Status]

Implementation of delegated command to set status. More...

Inheritance diagram for StatusAnyCommand:
CommandChain CommandBase ICommand IAction ISerializable

List of all members.

Public Member Functions

  get_description ()
  Returns a description of this command.
  get_name ()
  Returns title of command.
  get_params ()
  Returns params.

Protected Member Functions

  do_can_execute ($user)
  Returns true, if changing status is allowed.
  do_can_execute_status ($user, IStatusHolder $inst, $new_status)
  Check if command can be executed.
  do_execute ()
  Change status.

Detailed Description

Implementation of delegated command to set status.

Expects new status as param.

Specialized status commands should derive from this class

Author:
Gerd Riesselmann

Definition at line 12 of file status.any.cmd.php.


Member Function Documentation

StatusAnyCommand::do_can_execute ( user  )  [protected]

Returns true, if changing status is allowed.

Validates $user and than calls template method do_can_execute_status()

Reimplemented from CommandChain.

Definition at line 18 of file status.any.cmd.php.

00018                                                  {
00019                 $ret = false;
00020                 $inst = $this->get_instance();
00021                 if ($inst instanceof IStatusHolder) {
00022                         $new_status = $this->get_params();
00023                         $ret = ($inst->get_status() != $new_status);
00024                         // Note that functions below are not be called, if $ret becomes false   
00025                         $ret = $ret && parent::do_can_execute($user);
00026                         $ret = $ret && $this->do_can_execute_status($user, $inst, $new_status);
00027                 }
00028                 return $ret;
00029         }
StatusAnyCommand::do_can_execute_status ( user,
IStatusHolder inst,
new_status  
) [protected]

Check if command can be executed.

Parameters:
mixed  $user
IStatusHolder  $inst
mixed  $new_status
Returns:
bool

Definition at line 39 of file status.any.cmd.php.

00039                                                                                           {
00040                 return true;
00041         }
StatusAnyCommand::do_execute (  )  [protected]

Change status.

Returns:
Status

Reimplemented from CommandChain.

Definition at line 48 of file status.any.cmd.php.

00048                                         {
00049                 $ret = new Status();
00050                 Load::commands('generics/setstatus');
00051                 $this->append(new SetstatusCommand($this->get_instance(), $this->get_params()));
00052                 $this->set_result($this->get_instance());
00053                 return $ret;
00054         }
StatusAnyCommand::get_description (  ) 

Returns a description of this command.

Reimplemented from CommandBase.

Definition at line 79 of file status.any.cmd.php.

00079                                           {
00080                 $text = 'Change to ' . Cast::string($this->get_params());
00081                 $transmods = array('app', 'status');
00082                 $inst = $this->get_instance();
00083                 if ($inst instanceof IDataObject) {
00084                         array_unshift($transmods, $inst->get_table_name());
00085                 }
00086                 return tr(
00087                         $text, 
00088                         $transmods
00089                 );      
00090         } 
StatusAnyCommand::get_name (  ) 

Returns title of command.

Reimplemented from CommandBase.

Definition at line 72 of file status.any.cmd.php.

00072                                    {
00073                 return 'status';
00074         }
StatusAnyCommand::get_params (  ) 

Returns params.

Returns:
mixed

Reimplemented from CommandBase.

Definition at line 61 of file status.any.cmd.php.

00061                                      {
00062                 $ret = parent::get_params();
00063                 if (is_array($ret)) {
00064                         $ret = Arr::get_item($ret, 0, '');
00065                 }
00066                 return $ret;
00067         }       

The documentation for this class was generated from the following file: