#886 realname, lastlogin, lastfail fields added for users.

This commit is contained in:
tomas 2005-04-29 00:54:20 +00:00
parent bf52970576
commit 36c1074779
5 changed files with 72 additions and 24 deletions

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/alib.php,v $
------------------------------------------------------------------------------*/
@ -40,7 +40,7 @@ define('ALIBERR_NOTEXISTS', 31);
* authentication/authorization class
*
* @author $Author: tomas $
* @version $Revision: 1.12 $
* @version $Revision: 1.13 $
* @see Subjects
* @see GreenBox
*/
@ -77,7 +77,10 @@ class Alib extends Subjects{
*/
function login($login, $pass)
{
if(FALSE === $this->authenticate($login, $pass)) return FALSE;
if(FALSE === $this->authenticate($login, $pass)){
$this->setTimeStamp($login, TRUE);
return FALSE;
}
$sessid = $this->_createSessid();
if(PEAR::isError($sessid)) return $sessid;
$userid = $this->getSubjId($login);
@ -89,6 +92,7 @@ class Alib extends Subjects{
$this->login = $login;
$this->userid = $userid;
$this->sessid = $sessid;
$this->setTimeStamp($login, FALSE);
return $sessid;
}

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/subj.php,v $
------------------------------------------------------------------------------*/
@ -39,7 +39,7 @@ define('ALIBERR_BADSMEMB', 21);
* (allow adding users to groups or groups to groups)
*
* @author $Author: tomas $
* @version $Revision: 1.7 $
* @version $Revision: 1.8 $
* @see ObjClasses
* @see Alib
*/
@ -67,9 +67,10 @@ class Subjects extends ObjClasses{
*
* @param login string
* @param pass string, optional
* @param realname string, optional
* @return int/err
*/
function addSubj($login, $pass=NULL)
function addSubj($login, $pass=NULL, $realname='')
{
if(!$login) return $this->dbc->raiseError(
get_class($this)."::addSubj: empty login"
@ -77,9 +78,10 @@ class Subjects extends ObjClasses{
$id = $this->dbc->nextId("{$this->subjTable}_id_seq");
if(PEAR::isError($id)) return $id;
$r = $this->dbc->query("
INSERT INTO {$this->subjTable} (id, login, pass, type)
INSERT INTO {$this->subjTable} (id, login, pass, type, realname)
VALUES ($id, '$login', ".
(is_null($pass) ? "'!', 'G'" : "'".md5($pass)."', 'U'").")
(is_null($pass) ? "'!', 'G'" : "'".md5($pass)."', 'U'").",
'$realname')
");
if(PEAR::isError($r)) return $r;
return $id;
@ -123,6 +125,24 @@ class Subjects extends ObjClasses{
return (is_null($id) ? FALSE : $id);
}
/**
* Set lastlogin or lastfail timestamp
*
* @param login string
* @param failed boolean, true=> set lastfail, false=> set lastlogin
* @return boolean/int/err
*/
function setTimeStamp($login, $failed=FALSE)
{
$fld = ($failed ? 'lastfail' : 'lastlogin');
$r = $this->dbc->query("
UPDATE {$this->subjTable} SET $fld=now()
WHERE login='$login'
");
if(PEAR::isError($r)) return $r;
return TRUE;
}
/**
* Change user password
*
@ -531,7 +551,10 @@ class Subjects extends ObjClasses{
id int not null PRIMARY KEY,
login varchar(255) not null default'',
pass varchar(255) not null default'',
type char(1) not null default 'U'
type char(1) not null default 'U',
realname varchar(255) not null default'',
lastlogin timestamp,
lastfail timestamp
)");
$this->dbc->query("CREATE UNIQUE INDEX {$this->subjTable}_id_idx
ON {$this->subjTable} (id)");

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.48 $
Version : $Revision: 1.49 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/
@ -53,7 +53,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module
*
* @author $Author: tomas $
* @version $Revision: 1.48 $
* @version $Revision: 1.49 $
* @see Alib
*/
class BasicStor extends Alib{
@ -890,11 +890,12 @@ class BasicStor extends Alib{
*
* @param login string
* @param pass string OPT
* @param realname string OPT
* @return int/err
*/
function addSubj($login, $pass=NULL)
function addSubj($login, $pass=NULL, $realname='')
{
$uid = parent::addSubj($login, $pass);
$uid = parent::addSubj($login, $pass, $realname);
if($this->dbc->isError($uid)) return $uid;
if($this->isGroup($uid) === FALSE){
$fid = $this->bsCreateFolder($this->storId, $login);
@ -919,14 +920,17 @@ class BasicStor extends Alib{
return $uid;
}
/**
* Remove user by login or by uid and his home folder
* Remove user by login and remove also his home folder
*
* @param login string
* @param uid int OPT
* @return boolean/err
*/
function removeSubj($login, $uid=NULL)
function removeSubj($login)
{
if(FALSE !== array_search($login, $this->config['sysSubjs'])){
return $this->dbc->raiseError(
"BasicStor::removeSubj: cannot remove system user/group");
}
$res = parent::removeSubj($login);
if($this->dbc->isError($res)) return $res;
$id = $this->getObjId($login, $this->storId);
@ -1403,15 +1407,20 @@ class BasicStor extends Alib{
$this->storId, $this->config["TrashName"]);
if($this->dbc->isError($tfid)) return $tfid;
}
$allid = parent::addSubj($this->config['AllGr']);
if($this->dbc->isError($allid)) return $allid;
$r = $this->addSubj2Gr('root', $this->config['AllGr']);
$r = $res = parent::addPerm($allid, 'read', $this->rootId, 'A');
$admid = parent::addSubj($this->config['AdminsGr']);
if($this->dbc->isError($admid)) return $admid;
$r = $this->addSubj2Gr('root', $this->config['AdminsGr']);
if($this->dbc->isError($r)) return $r;
$res = parent::addPerm($admid, '_all', $this->rootId, 'A');
if($this->dbc->isError($res)) return $res;
if(!$this->config['isArchive']){
$stPrefGr = parent::addSubj($this->config['StationPrefsGr']);
if($this->dbc->isError($stPrefGr)) return $stPrefGr;
$this->addSubj2Gr('root', $this->config['StationPrefsGr']);
$allid = $stPrefGr = parent::addSubj($this->config['AllGr']);
if($this->dbc->isError($allid)) return $allid;
$r = $this->addSubj2Gr('root', $this->config['AllGr']);
if($this->dbc->isError($r)) return $r;
$r = $res = parent::addPerm($allid, 'read', $this->rootId, 'A');
if($this->dbc->isError($r)) return $r;
}
}

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.20 $
Version : $Revision: 1.21 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $
------------------------------------------------------------------------------*/
@ -42,6 +42,7 @@ define('LS_VERSION', '0.9');
* <dt>dsn<dd> datasource setting
* <dt>tblNamePrefix <dd>prefix for table names in the database
* <dt>authCookieName <dd>secret token cookie name
* <dt>AdminsGr <dd>name of admin group
* <dt>StationPrefsGr <dd>name of station preferences group
* <dt>AllGr <dd>name of 'all users' group
* <dt>TrashName <dd>name of trash folder (subfolder of the storageRoot)
@ -60,6 +61,7 @@ define('LS_VERSION', '0.9');
* <dt>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
* for login to archive
* <dt>sysSubjs<dd>system users/groups - cannot be deleted
* </dl>
*/
@ -78,6 +80,7 @@ $config = array(
/* ================================================ storage configuration */
'authCookieName'=> 'lssid',
'AdminsGr' => 'Admins',
'StationPrefsGr'=> 'StationPrefs',
'AllGr' => 'All',
'TrashName' => 'trash_',
@ -136,6 +139,9 @@ $config = array(
'RootNode' => 'RootNode',
'tmpRootPass' => 'q',
);
$config['sysSubjs'] = array(
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
);
// see if a ~/.livesupport/storageServer.conf.php exists, and
// overwrite the settings from there if any

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php.template,v $
------------------------------------------------------------------------------*/
@ -42,6 +42,7 @@ define('LS_VERSION', '0.9');
* <dt>dsn<dd> datasource setting
* <dt>tblNamePrefix <dd>prefix for table names in the database
* <dt>authCookieName <dd>secret token cookie name
* <dt>AdminsGr <dd>name of admin group
* <dt>StationPrefsGr <dd>name of station preferences group
* <dt>AllGr <dd>name of 'all users' group
* <dt>TrashName <dd>name of trash folder (subfolder of the storageRoot)
@ -60,6 +61,7 @@ define('LS_VERSION', '0.9');
* <dt>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
* for login to archive
* <dt>sysSubjs<dd>system users/groups - cannot be deleted
* </dl>
*/
@ -78,6 +80,7 @@ $config = array(
/* ================================================ storage configuration */
'authCookieName'=> 'lssid',
'AdminsGr' => 'Admins',
'StationPrefsGr'=> 'StationPrefs',
'AllGr' => 'All',
'TrashName' => 'trash_',
@ -136,4 +139,7 @@ $config = array(
'RootNode' => 'RootNode',
'tmpRootPass' => 'q',
);
$config['sysSubjs'] = array(
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
);
?>