Source for file actions.php

Documentation is available at actions.php

  1. <?php
  2. /**
  3. * List of all currently available actions
  4. *
  5. @author     Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Actions
  11. *
  12. *  path (bumblebee root)/inc/actions/actions.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. require_once 'inc/permissions.php';
  19.  
  20. /**
  21. * An available action
  22. *
  23. @package    Bumblebee
  24. @subpackage Actions
  25. */
  26. class ActionData {
  27.   /** @var string    name of the action in action= URL */
  28.   var $name;
  29.   /** @var string    title for the html page */
  30.   var $title;
  31.   /** @var string    name of the action for the menu */
  32.   var $menu;
  33.   /** @var string    name of the Action* class that should be instantiated */
  34.   var $action_class;
  35.   /** @var boolean   include the entry on the menu */
  36.   var $menu_visible;
  37.   /** @var integer   permissions required for this action */
  38.   var $permissions;
  39.   /** @var integer   menu order number (lowest numbers at top of menu) */
  40.   var $menu_order = NULL;
  41.   /** @var integer   name of the action that should follow next (defaults to $this->name) */
  42.   var $next_action;
  43.  
  44.   /**
  45.   *  Create a new ActionData object
  46.   *
  47.   * @param string $class          name of the class to be instantiated
  48.   * @param string $file          name of the php file to be included
  49.   * @param string $name 
  50.   * @param string $title 
  51.   * @param string $menu 
  52.   * @param integer $permissions    from permissions.php (default: BBROLE_NONE)
  53.   * @param integer $menu_order     use negative number for not shown on menu, default: use in order instantiated into ActionListing
  54.   * @param string $next_action 
  55.   */
  56.   function ActionData($class$file$name$title$menu$permissions=BBROLE_NONE,
  57.                       $menu_order=NULL$next_action=NULL{
  58.     $this->action_class = $class;
  59.     $this->name         = $name;
  60.     $this->file         $file;
  61.     $this->menu         = $menu;
  62.     $this->title        = $title;
  63.     $this->permissions  = $permissions;
  64.     $this->menu_order   = $menu_order;
  65.     $this->menu_visible = ($menu_order === NULL || $menu_order 0);
  66.     $this->next_action  = $next_action === NULL $name $next_action;
  67.   }
  68.  
  69.   function name({
  70.     return $this->name;
  71.   }
  72.  
  73.   function title({
  74.     return $this->title;
  75.   }
  76.  
  77.   function menu({
  78.     return $this->menu;
  79.   }
  80.   function permissions({
  81.     return $this->permissions;
  82.   }
  83.  
  84.   function menu_order({
  85.     return $this->menu_order;
  86.   }
  87.  
  88.   function menu_visible($permissions=-1{
  89.     return $this->menu_visible $permissions;
  90.   }
  91.  
  92.   function requires_admin({
  93.     return $this->permissions >= BBROLE_ADMIN_BASE;
  94.   }
  95.  
  96.   function next_action($action=NULL{
  97.     if ($action === NULL)
  98.       return $this->next_action;
  99.     return $this->next_action = $action;
  100.   }
  101.  
  102.   function action_class({
  103.     return $this->action_class;
  104.   }
  105.  
  106.   function include_file({
  107.     return $this->file;
  108.   }
  109.  
  110. }
  111.  
  112. /**
  113. * List of all currently available actions
  114. *
  115. * Create data structures that can describe both the action-word to be acted
  116. * on, as well as the title to be reflected in the HTML title tag.
  117. *
  118. @todo //TODO: this should be integrated with the Menu class
  119. @todo //TODO: document the fixed up version
  120. @package    Bumblebee
  121. @subpackage Actions
  122. */
  123. class ActionListing {
  124.   /** @var array  list of ActionData objects */
  125.   var $actions        = array();
  126.   /** @var string name of default action when none is explicitly specified in the URL */
  127.   var $default_action = 'view';
  128.  
  129.   function ActionListing({
  130.     $this->_populate();
  131.     $this->_initialise();
  132.   }
  133.  
  134.   /** @todo //TODO:: conditionally initialise these -- at least limit the number of extraneous T_() calls for non admin users */
  135.   function _populate({
  136.     $this->actions[new ActionData('ActionUnknown''unknownaction.php',
  137.         'unknown',    T_('Oops! I cannot do that!')T_('Unknown')BBROLE_NONE-1);
  138.     $this->actions[new ActionData('ActionUnknown''unknownaction.php',
  139.         'forbidden!'T_('No, you cannot do that')T_('Forbidden')BBROLE_NONE-1);
  140.     $this->actions[new ActionData('ActionOffline''offline.php',
  141.         'offline'T_('System Offline')T_('System Offline')BBROLE_NONE-1);
  142.  
  143.     $this->actions[new ActionData('ActionView''view.php',
  144.         'view',       T_('View list of instruments')T_('Main')BBROLE_NONE);
  145.     $this->actions[new ActionData('ActionCalendar''calendar.php',
  146.         'calendar',   T_('View instrument calendar')T_('Calendar')BBROLE_NONE-1);
  147.     $this->actions[new ActionData('ActionBook''book.php',
  148.         'book',       T_('View/edit instrument bookings')T_('Bookings')BBROLE_NONE-1);
  149.     $this->actions[new ActionData('ActionBookContact''bookcontact.php',
  150.         'bookcontact',T_('Requeset an instrument booking')T_('Request booking')BBROLE_NONE-1);
  151.     $this->actions[new ActionData('ActionPassword''password.php',
  152.         'passwd',     T_('Change password')T_('Change password'),    BBROLE_PASSWD);
  153.     $this->actions[new ActionData('ActionPrintLoginForm''login.php',
  154.         'login',      T_('Login')T_('Login')BBROLE_NONE-1'view');
  155.     $this->actions[new ActionData('ActionLogout''logout.php',
  156.         'logout',     T_('Logout')T_('Logout')BBROLE_LOGOUT);
  157.  
  158.     $this->actions[new ActionData('ActionGroups''groups.php',
  159.         'groups',     T_('Manage groups')T_('Edit groups')BBROLE_ADMIN_GROUPS);
  160.     $this->actions[new ActionData('ActionProjects''projects.php',
  161.         'projects',   T_('Manage projects')T_('Edit projects')BBROLE_ADMIN_PROJECTS);
  162.     $this->actions[new ActionData('ActionUsers''users.php',
  163.         'users',      T_('Manage users')T_('Edit users')BBROLE_ADMIN_USERS);
  164.     $this->actions[new ActionData('ActionInstruments''instruments.php',
  165.         'instruments'T_('Manage instruments')T_('Edit instruments')BBROLE_ADMIN_INSTRUMENTS);
  166.     $this->actions[new ActionData('ActionConsumables''consumables.php',
  167.         'consumables'T_('Manage consumables')T_('Edit consumables')BBROLE_ADMIN_CONSUMABLES);
  168.     $this->actions[new ActionData('ActionConsume''consume.php',
  169.         'consume',    T_('Record consumable usage')T_('Use consumable')BBROLE_ADMIN_CONSUME);
  170.     $this->actions[new ActionData('ActionMasquerade''masquerade.php',
  171.         'masquerade'T_('Masquerade as another user')T_('Masquerade')BBROLE_ADMIN_MASQ);
  172.     $this->actions[new ActionData('ActionCosts''costs.php',
  173.         'costs',      T_('Edit standard costs')T_('Edit costs')BBROLE_ADMIN_COSTS);
  174.     $this->actions[new ActionData('ActionSpecialCosts''specialcosts.php',
  175.         'specialcosts',    T_('Edit or create special charges')T_('Edit special costs')BBROLE_ADMIN_COSTS-1);
  176.     $this->actions[new ActionData('ActionUserClass''userclass.php',
  177.         'userclass',  T_('Edit or create user class')T_('Edit user class')BBROLE_ADMIN_COSTS-1);
  178.     $this->actions[new ActionData('ActionInstrumentClass''instrumentclass.php',
  179.         'instrumentclass'T_('Edit or create instrument class')T_('Edit instrument class')BBROLE_ADMIN_COSTS-1);
  180.     $this->actions[new ActionData('ActionDeletedBookings''deletedbookings.php',
  181.         'deletedbookings'T_('View deleted bookings')T_('Deleted bookings')BBROLE_ADMIN_DELETEDBOOKINGS);
  182.     $this->actions[new ActionData('ActionEmaillist''emaillist.php',
  183.         'emaillist',  T_('Email lists')T_('Email lists')BBROLE_ADMIN_EMAILLIST);
  184.     $this->actions[new ActionData('ActionExport''export.php',
  185.         'export',     T_('Export data')T_('Export data')BBROLE_ADMIN_EXPORT);
  186.     $this->actions[new ActionData('ActionBilling''billing.php',
  187.         'billing',    T_('Prepare billing summaries')T_('Billing reports')BBROLE_ADMIN_BILLING);
  188.     $this->actions[new ActionData('ActionBackupDB''backupdatabase.php',
  189.         'backupdb',   T_('Backup database')T_('Backup database')BBROLE_ADMIN_BACKUPDB);
  190.     $this->actions[new ActionData('ActionSettings''settings.php',
  191.         'settings',   T_('Configuration editor')T_('Configure system')BBROLE_ADMIN_CONFIG);
  192.  
  193.   }
  194.  
  195.   function _initialise({
  196.     $actions $this->actions;
  197.     $this->actions = array();
  198.     foreach ($actions as $action{
  199.       $this->actions[$action->name()$action;
  200.     }
  201.     $this->actions[''clone($this->actions[$this->default_action]);
  202.     $this->actions['']->menu_visible false;
  203.   }
  204.  
  205.   function action_exists($action{
  206.     return isset($this->actions[$action]);
  207.   }
  208.  
  209. //ActionListing
  210.  
  211. ?>

Documentation generated on Tue, 06 Mar 2007 10:00:30 +0000 by phpDocumentor 1.3.0