Source for file user.php
Documentation is available at user.php
* User object (extends dbo), with extra customisations for other links
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
require_once 'inc/bb/configreader.php';
require_once 'inc/formslib/dbrow.php';
require_once 'inc/formslib/idfield.php';
require_once 'inc/formslib/textfield.php';
require_once 'inc/formslib/radiolist.php';
require_once 'inc/formslib/checkbox.php';
require_once 'inc/formslib/bitmask.php';
require_once 'inc/formslib/passwdfield.php';
require_once 'inc/formslib/droplist.php';
require_once 'inc/formslib/joindata.php';
* User object (extends dbo), with extra customisations for other links
* @todo //TODO: Editing method for new permissions model
function User($auth, $id, $passwdOnly=
false) {
$this->DBRow('users', $id);
$attrs =
array('size' =>
'48');
$f->requiredTwoStage =
1;
$f->isValidTest =
'is_valid_username';
$f->isValidTest =
'is_empty_string';
$f->required =
! $passwdOnly;
$f->isValidTest =
'is_empty_string';
$f->required =
! $passwdOnly;
$f->isValidTest =
'is_empty_string';
if (! $conf->value('auth', 'permissionsModel', false)) {
$f =
new CheckBox('isadmin', T_('System Administrator'));
$f =
new Bitmask('permissions', T_('System permissions'), T_('Grant these system-wide permissions to the user'), T_('Grant'));
$f->showHideButtons =
true;
// association of user with an authentication method
$f =
new RadioList('auth_method', T_('User authentication method'));
$f->setValuesArray($this->_authList, 'id', 'iv');
$f->setFormat('id', '%s', array('iv'));
$f->hidden =
$passwdOnly;
$password =
new PasswdField('passwd', T_('Password (for local login)'));
$password->setAttr(array('size' =>
24));
//$password->isValidTest = 'is_nonempty_string';
$password->suppressValidation =
0;
//$f->list->append(array('local','Local login: '), $password);
//repeat the password field so that we can check that the user entered
//what they thought they did
$password_veri =
new PasswdField('passwd_veri', T_('Please re-enter password'));
$password_veri->setAttr(array('size' =>
24));
$password_veri->suppressValidation =
0;
$password_veri->editable =
1;
$password_veri->sqlHidden =
true;
// association of users to projects
'projects', T_('Project membership'));
$projectfield =
new DropList('projectid', T_('Project'));
$projectfield->connectDB('projects', array('id', 'name', 'longname'));
$projectfield->prepend(array('0',T_('(none)'), T_('no selection')));
$projectfield->setDefault(0);
$projectfield->setFormat('id', '%s', array('name'), ' (%25.25s)', array('longname'));
$f->addElement($projectfield);
$f->joinSetup('projectid', array('minspare' =>
2));
// association of users with instrumental permissions
'instruments', T_('Instrument permissions'));
$instrfield =
new DropList('instrid', T_('Instrument'));
$instrfield->connectDB('instruments', array('id', 'name', 'longname'));
$instrfield->prepend(array('0', T_('(none)'), T_('no selection')));
$instrfield->setDefault(0);
$instrfield->setFormat('id', '%s', array('name'), ' (%25.25s)', array('longname'));
$f->addElement($instrfield);
$subscribeAnnounce =
new CheckBox('announce', T_('Subscribe: announce'));
$subscribeAnnounce->defaultValue =
1;
$f->addElement($subscribeAnnounce);
$unbookAnnounce =
new CheckBox('unbook', T_('Subscribe: unbook'));
$f->addElement($unbookAnnounce);
if (! $conf->value('auth', 'permissionsModel', false)) {
$instradmin =
new CheckBox('isadmin', T_('Instrument admin'));
$f->addElement($instradmin);
$bm =
new Bitmask('permissions', T_('Instrument permissions'), T_('Grant these instrument permissions to the user'), T_('Grant'));
$bm->showHideButtons =
true;
//Add these fields in once we need this functinality
$hasPriority = new CheckBox('haspriority', 'Booking priority');
$f->addElement($hasPriority);
$bookPoints = new TextField('points', 'Booking points');
$f->addElement($bookPoints);
$bookPointsRecharge = new TextField('pointsrecharge', 'Booking points recharge');
$f->addElement($bookPointsRecharge);
$f->joinSetup('instrid', array('minspare' =>
2));
&&
$conf->value('auth', 'useLocal')?
true:
false;
foreach ($conf->getSection('auth') as $key =>
$val) {
if (strpos($key, 'use') ===
0 &&
$val) {
$this->_magicPassList[$method] =
$conf->value('auth', $method.
'PassToken');
//now edit the passwd/auth fields
if ($this->fields['passwd']->value ==
$passtok) {
$this->fields['passwd']->crypt_method =
'';
//echo $this->fields['passwd']->value;
//monkey the passwd/auth fields
//echo $this->_authMethod. '-';
//preDump($this->fields['passwd']);
//echo $this->fields['passwd']->value;
//echo $this->fields['auth_method']->changed.'/'.$this->fields['passwd']->value;
$this->fields['passwd']->value =
'';
if ($this->fields['auth_method']->changed ||
$this->fields['passwd']->changed) {
$this->fields['passwd']->value !=
$this->fields['passwd_veri']->value) {
$this->fields['passwd']->isValid =
0;
$this->fields['passwd']->changed =
1;
$this->fields['passwd_veri']->isValid =
0;
$this->fields['passwd_veri']->changed =
0;
$this->errorMessage .=
T_('The supplied passwords did not match. Please retry.').
'<br/>';
/*&& $this->fields['passwd']->value != ''*/
$this->log('User::sync(): indulging in password munging, '.
$this->_authMethod);
$this->fields['passwd']->crypt_method =
'';
$this->fields['passwd']->changed =
1;
&&
$this->fields['username']->value !=
'') {
$this->fields['passwd']->changed =
1;
$this->fields['passwd']->isValid =
0;
$this->errorMessage .=
T_('password must be set for local login.').
'<br/>';
Documentation generated on Tue, 06 Mar 2007 10:02:08 +0000 by phpDocumentor 1.3.0