Source for file instrumentclass.php

Documentation is available at instrumentclass.php

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

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