Source for file users.php

Documentation is available at users.php

  1. <?php
  2. /**
  3. * Edit/create/delete users, their project associations and permissions
  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/users.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** User object */
  19. require_once 'inc/bb/user.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 users, their project associations and permissions
  27. * @package    Bumblebee
  28. * @subpackage Actions
  29. */
  30. class ActionUsers 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 ActionUsers($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('users')."'>".T_('Return to user list')."</a>";
  58.   }
  59.  
  60.   function select($deleted=false) {
  61.     $select = new AnchorTableList(T_('Users'), T_('Select which user to view'));
  62.     $select->deleted = $deleted;
  63.     $select->connectDB('users', array('id', 'name', 'username'));
  64.     $select->list->prepend(array('-1', T_('Create new user')));
  65.     $select->list->append(array('showdeleted', T_('Show deleted users')));
  66.     $select->hrefbase = makeURL('users', array('id'=>'__id__'));
  67.     $select->setFormat('id', '%s', array('name'), ' %s', array('username'));
  68.     echo $select->display();
  69.   }
  70.  
  71.   function edit() {
  72.     $user = new User($this->auth, $this->PD['id']);
  73.     $user->update($this->PD);
  74.     #$project->fields['defaultclass']->invalid = 1;
  75.     $user->checkValid();
  76.     echo $this->reportAction($user->sync(),
  77.           array(
  78.               STATUS_OK =>   ($this->PD['id'] < 0 ? T_('User created') : T_('User updated')),
  79.               STATUS_ERR =>  T_('User could not be changed:').' '.$user->errorMessage
  80.           )
  81.         );
  82.     echo $user->display();
  83.     if ($user->id < 0) {
  84.       $submit = T_('Create new user');
  85.       $delete = '0';
  86.     } else {
  87.       $submit = T_('Update entry');
  88.       $delete = $user->isDeleted ? T_('Undelete entry') : T_('Delete entry');
  89.     }
  90.     echo "<input type='submit' name='submit' value='$submit' />";
  91.     if ($delete) echo "<input type='submit' name='delete' value='$delete' />";
  92.   }
  93.  
  94.   function delete() {
  95.     $user = new User($this->auth, $this->PD['id']);
  96.     echo $this->reportAction($user->delete(),
  97.               array(
  98.                   STATUS_OK =>   $user->isDeleted ? T_('User undeleted') : T_('User deleted'),
  99.                   STATUS_ERR =>  T_('User could not be deleted:').'<br/><br/>'.$user->errorMessage
  100.               )
  101.             );
  102.   }
  103. }
  104.  
  105. ?>

Documentation generated on Tue, 06 Mar 2007 10:02:09 +0000 by phpDocumentor 1.3.0