Source for file groups.php

Documentation is available at groups.php

  1. <?php
  2. /**
  3. * Interface for editing details of groups
  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/groups.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** Group object */
  19. require_once 'inc/bb/group.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. * Interface for editing details of groups
  27. *
  28. * @package    Bumblebee
  29. * @subpackage Actions
  30. */
  31. class ActionGroups 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 ActionGroups($auth, $pdata) {
  41.     parent::ActionAction($auth, $pdata);
  42.     $this->mungeInputData();
  43.   }
  44.  
  45.   function go() {
  46.     if (! isset($this->PD['id'])) {
  47.       $this->select(issetSet($this->PD, 'showdeleted', false));
  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('groups')."'>".T_('Return to group list')."</a>";
  59.   }
  60.  
  61.   function select($deleted=false) {
  62.     $select = new AnchorTableList(T_('Group'), T_('Select which group to view'));
  63.     $select->deleted = $deleted;
  64.     $select->connectDB('groups', array('id', 'name', 'longname'));
  65.     $select->list->prepend(array('-1', T_('Create new group')));
  66.     $select->list->append(array('showdeleted', T_('Show deleted groups')));
  67.     $select->hrefbase = makeURL('groups', array('id'=>'__id__'));
  68.     $select->setFormat('id', '%s', array('name'), ' %50.50s', array('longname'));
  69.     #echo $select->list->text_dump();
  70.     echo $select->display();
  71.   }
  72.  
  73.   function edit() {
  74.     $group = new Group($this->PD['id']);
  75.     $group->update($this->PD);
  76.     $group->checkValid();
  77.     echo $this->reportAction($group->sync(),
  78.           array(
  79.               STATUS_OK =>   ($this->PD['id'] < 0 ? T_('Group created') : T_('Group updated')),
  80.               STATUS_ERR =>  T_('Group could not be changed:').' '.$group->errorMessage
  81.           )
  82.         );
  83.     echo $group->display();
  84.     if ($group->id < 0) {
  85.       $submit = T_('Create new group');
  86.       $delete = '0';
  87.     } else {
  88.       $submit = T_('Update entry');
  89.       $delete = $group->isDeleted ? T_('Undelete entry') : T_('Delete entry');
  90.     }
  91.     #$submit = ($PD['id'] < 0 ? "Create new" : "Update entry");
  92.     echo "<input type='submit' name='submit' value='$submit' />";
  93.     if ($delete) echo "<input type='submit' name='delete' value='$delete' />";
  94.   }
  95.  
  96.   function delete() {
  97.     $group = new Group($this->PD['id']);
  98.     echo $this->reportAction($group->delete(),
  99.               array(
  100.                   STATUS_OK =>   $group->isDeleted ? T_('Group undeleted') : T_('Group deleted'),
  101.                   STATUS_ERR =>  T_('Group could not be deleted:').'<br/><br/>'.$group->errorMessage
  102.               )
  103.             );
  104.   }
  105. }
  106. ?>

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