Source for file instruments.php

Documentation is available at instruments.php

  1. <?php
  2. /**
  3. * Edit/create/delete instruments
  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/instruments.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** instrument object */
  19. require_once 'inc/bb/instrument.php';
  20. /** list of choices */
  21. require_once 'inc/formslib/anchortablelist.php';
  22. /** parent object */
  23. require_once 'inc/actions/actionaction.php';
  24.  
  25. /**
  26. * Edit/create/delete instruments
  27. @package    Bumblebee
  28. @subpackage Actions
  29. */
  30. class ActionInstruments extends ActionAction {
  31.  
  32.   /**
  33.   * Initialising the class
  34.   *
  35.   * @param  BumblebeeAuth $auth  Authorisation object
  36.   * @param  array $pdata   extra state data from the call path
  37.   * @return void nothing
  38.   */
  39.   function ActionInstruments($auth$pdata{
  40.     parent::ActionAction($auth$pdata);
  41.     $this->mungeInputData();
  42.   }
  43.  
  44.   function go({
  45.     if (isset($this->PD['id'])) {
  46.       $this->select(issetSet($this->PD'showdeleted'false));
  47.     elseif (isset($this->PD['delete'])) {
  48.       if ($this->readOnly{
  49.         $this->readOnlyError();
  50.       else {
  51.         $this->delete();
  52.       }
  53.     else {
  54.       if ($this->readOnly$this->_dataCleanse('id');
  55.       $this->edit();
  56.     }
  57.     echo "<br /><br /><a href='".makeURL('instruments')."'>".T_('Return to instruments list')."</a>";
  58.   }
  59.  
  60.   function select($deleted=false{
  61.     $select new AnchorTableList('Instrument'T_('Select which instrument to view'));
  62.     $select->deleted $deleted;
  63.     $select->connectDB('instruments'array('id''name''longname'));
  64.     $select->list->prepend(array('-1'T_('Create new instrument')));
  65.     $select->list->append(array('showdeleted'T_('Show deleted instruments')));
  66.     $select->hrefbase makeURL('instruments'array('id'=>'__id__'));
  67.     $select->setFormat('id''%s'array('name')' %30.30s'array('longname'));
  68.     #echo $groupselect->list->text_dump();
  69.     echo $select->display();
  70.   }
  71.  
  72.   function edit({
  73.     $instrument new Instrument($this->PD['id']);
  74.     $instrument->update($this->PD);
  75.     $instrument->checkValid();
  76.     echo $this->reportAction($instrument->sync(),
  77.           array(
  78.               STATUS_OK =>   ($this->PD['id'T_('Instrument created')
  79.                                                   : T_('Instrument updated')),
  80.               STATUS_ERR =>  T_('Instrument could not be changed:').' '.$instrument->errorMessage
  81.           )
  82.         );
  83.     echo $instrument->display();
  84.     if ($instrument->id 0{
  85.       $submit T_('Create new instrument');
  86.       $delete '0';
  87.     else {
  88.       $submit T_('Update entry');
  89.       $delete $instrument->isDeleted T_('Undelete entry'T_('Delete entry');
  90.     }
  91.     #$submit = ($PD['id'] < 0 ? "Create new" : "Update entry");
  92.     echo "<input type='submitname='submitvalue='$submit' />";
  93.     if ($deleteecho "<input type='submitname='deletevalue='$delete' />";
  94.   }
  95.  
  96.   function delete()   {
  97.     $instrument new Instrument($this->PD['id']);
  98.     echo $this->reportAction($instrument->delete(),
  99.               array(
  100.                   STATUS_OK =>   $instrument->isDeleted T_('Instrument undeleted')
  101.                                                         : T_('Instrument deleted'),
  102.                   STATUS_ERR =>  T_('Instrument could not be deleted:')
  103.                                  .'<br/><br/>'.$instrument->errorMessage
  104.               )
  105.             );
  106.   }
  107. }
  108. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:41 +0000 by phpDocumentor 1.3.0