#886 realname, lastlogin, lastfail fields added for users.
This commit is contained in:
parent
bf52970576
commit
36c1074779
5 changed files with 72 additions and 24 deletions
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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
|
* authentication/authorization class
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.12 $
|
* @version $Revision: 1.13 $
|
||||||
* @see Subjects
|
* @see Subjects
|
||||||
* @see GreenBox
|
* @see GreenBox
|
||||||
*/
|
*/
|
||||||
|
@ -77,7 +77,10 @@ class Alib extends Subjects{
|
||||||
*/
|
*/
|
||||||
function login($login, $pass)
|
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();
|
$sessid = $this->_createSessid();
|
||||||
if(PEAR::isError($sessid)) return $sessid;
|
if(PEAR::isError($sessid)) return $sessid;
|
||||||
$userid = $this->getSubjId($login);
|
$userid = $this->getSubjId($login);
|
||||||
|
@ -89,6 +92,7 @@ class Alib extends Subjects{
|
||||||
$this->login = $login;
|
$this->login = $login;
|
||||||
$this->userid = $userid;
|
$this->userid = $userid;
|
||||||
$this->sessid = $sessid;
|
$this->sessid = $sessid;
|
||||||
|
$this->setTimeStamp($login, FALSE);
|
||||||
return $sessid;
|
return $sessid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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)
|
* (allow adding users to groups or groups to groups)
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.8 $
|
||||||
* @see ObjClasses
|
* @see ObjClasses
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
|
@ -67,9 +67,10 @@ class Subjects extends ObjClasses{
|
||||||
*
|
*
|
||||||
* @param login string
|
* @param login string
|
||||||
* @param pass string, optional
|
* @param pass string, optional
|
||||||
|
* @param realname string, optional
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function addSubj($login, $pass=NULL)
|
function addSubj($login, $pass=NULL, $realname='')
|
||||||
{
|
{
|
||||||
if(!$login) return $this->dbc->raiseError(
|
if(!$login) return $this->dbc->raiseError(
|
||||||
get_class($this)."::addSubj: empty login"
|
get_class($this)."::addSubj: empty login"
|
||||||
|
@ -77,9 +78,10 @@ class Subjects extends ObjClasses{
|
||||||
$id = $this->dbc->nextId("{$this->subjTable}_id_seq");
|
$id = $this->dbc->nextId("{$this->subjTable}_id_seq");
|
||||||
if(PEAR::isError($id)) return $id;
|
if(PEAR::isError($id)) return $id;
|
||||||
$r = $this->dbc->query("
|
$r = $this->dbc->query("
|
||||||
INSERT INTO {$this->subjTable} (id, login, pass, type)
|
INSERT INTO {$this->subjTable} (id, login, pass, type, realname)
|
||||||
VALUES ($id, '$login', ".
|
VALUES ($id, '$login', ".
|
||||||
(is_null($pass) ? "'!', 'G'" : "'".md5($pass)."', 'U'").")
|
(is_null($pass) ? "'!', 'G'" : "'".md5($pass)."', 'U'").",
|
||||||
|
'$realname')
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
return $id;
|
return $id;
|
||||||
|
@ -123,6 +125,24 @@ class Subjects extends ObjClasses{
|
||||||
return (is_null($id) ? FALSE : $id);
|
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
|
* Change user password
|
||||||
*
|
*
|
||||||
|
@ -531,7 +551,10 @@ class Subjects extends ObjClasses{
|
||||||
id int not null PRIMARY KEY,
|
id int not null PRIMARY KEY,
|
||||||
login varchar(255) not null default'',
|
login varchar(255) not null default'',
|
||||||
pass 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
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->subjTable}_id_idx
|
||||||
ON {$this->subjTable} (id)");
|
ON {$this->subjTable} (id)");
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.48 $
|
* @version $Revision: 1.49 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
@ -890,11 +890,12 @@ class BasicStor extends Alib{
|
||||||
*
|
*
|
||||||
* @param login string
|
* @param login string
|
||||||
* @param pass string OPT
|
* @param pass string OPT
|
||||||
|
* @param realname string OPT
|
||||||
* @return int/err
|
* @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->dbc->isError($uid)) return $uid;
|
||||||
if($this->isGroup($uid) === FALSE){
|
if($this->isGroup($uid) === FALSE){
|
||||||
$fid = $this->bsCreateFolder($this->storId, $login);
|
$fid = $this->bsCreateFolder($this->storId, $login);
|
||||||
|
@ -919,14 +920,17 @@ class BasicStor extends Alib{
|
||||||
return $uid;
|
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 login string
|
||||||
* @param uid int OPT
|
|
||||||
* @return boolean/err
|
* @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);
|
$res = parent::removeSubj($login);
|
||||||
if($this->dbc->isError($res)) return $res;
|
if($this->dbc->isError($res)) return $res;
|
||||||
$id = $this->getObjId($login, $this->storId);
|
$id = $this->getObjId($login, $this->storId);
|
||||||
|
@ -1403,15 +1407,20 @@ class BasicStor extends Alib{
|
||||||
$this->storId, $this->config["TrashName"]);
|
$this->storId, $this->config["TrashName"]);
|
||||||
if($this->dbc->isError($tfid)) return $tfid;
|
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']){
|
if(!$this->config['isArchive']){
|
||||||
$stPrefGr = parent::addSubj($this->config['StationPrefsGr']);
|
$stPrefGr = parent::addSubj($this->config['StationPrefsGr']);
|
||||||
|
if($this->dbc->isError($stPrefGr)) return $stPrefGr;
|
||||||
$this->addSubj2Gr('root', $this->config['StationPrefsGr']);
|
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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>dsn<dd> datasource setting
|
||||||
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
||||||
* <dt>authCookieName <dd>secret token cookie name
|
* <dt>authCookieName <dd>secret token cookie name
|
||||||
|
* <dt>AdminsGr <dd>name of admin group
|
||||||
* <dt>StationPrefsGr <dd>name of station preferences group
|
* <dt>StationPrefsGr <dd>name of station preferences group
|
||||||
* <dt>AllGr <dd>name of 'all users' group
|
* <dt>AllGr <dd>name of 'all users' group
|
||||||
* <dt>TrashName <dd>name of trash folder (subfolder of the storageRoot)
|
* <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>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
|
||||||
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
|
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
|
||||||
* for login to archive
|
* for login to archive
|
||||||
|
* <dt>sysSubjs<dd>system users/groups - cannot be deleted
|
||||||
* </dl>
|
* </dl>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,6 +80,7 @@ $config = array(
|
||||||
|
|
||||||
/* ================================================ storage configuration */
|
/* ================================================ storage configuration */
|
||||||
'authCookieName'=> 'lssid',
|
'authCookieName'=> 'lssid',
|
||||||
|
'AdminsGr' => 'Admins',
|
||||||
'StationPrefsGr'=> 'StationPrefs',
|
'StationPrefsGr'=> 'StationPrefs',
|
||||||
'AllGr' => 'All',
|
'AllGr' => 'All',
|
||||||
'TrashName' => 'trash_',
|
'TrashName' => 'trash_',
|
||||||
|
@ -136,6 +139,9 @@ $config = array(
|
||||||
'RootNode' => 'RootNode',
|
'RootNode' => 'RootNode',
|
||||||
'tmpRootPass' => 'q',
|
'tmpRootPass' => 'q',
|
||||||
);
|
);
|
||||||
|
$config['sysSubjs'] = array(
|
||||||
|
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||||
|
);
|
||||||
|
|
||||||
// see if a ~/.livesupport/storageServer.conf.php exists, and
|
// see if a ~/.livesupport/storageServer.conf.php exists, and
|
||||||
// overwrite the settings from there if any
|
// overwrite the settings from there if any
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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>dsn<dd> datasource setting
|
||||||
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
||||||
* <dt>authCookieName <dd>secret token cookie name
|
* <dt>authCookieName <dd>secret token cookie name
|
||||||
|
* <dt>AdminsGr <dd>name of admin group
|
||||||
* <dt>StationPrefsGr <dd>name of station preferences group
|
* <dt>StationPrefsGr <dd>name of station preferences group
|
||||||
* <dt>AllGr <dd>name of 'all users' group
|
* <dt>AllGr <dd>name of 'all users' group
|
||||||
* <dt>TrashName <dd>name of trash folder (subfolder of the storageRoot)
|
* <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>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
|
||||||
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
|
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
|
||||||
* for login to archive
|
* for login to archive
|
||||||
|
* <dt>sysSubjs<dd>system users/groups - cannot be deleted
|
||||||
* </dl>
|
* </dl>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,6 +80,7 @@ $config = array(
|
||||||
|
|
||||||
/* ================================================ storage configuration */
|
/* ================================================ storage configuration */
|
||||||
'authCookieName'=> 'lssid',
|
'authCookieName'=> 'lssid',
|
||||||
|
'AdminsGr' => 'Admins',
|
||||||
'StationPrefsGr'=> 'StationPrefs',
|
'StationPrefsGr'=> 'StationPrefs',
|
||||||
'AllGr' => 'All',
|
'AllGr' => 'All',
|
||||||
'TrashName' => 'trash_',
|
'TrashName' => 'trash_',
|
||||||
|
@ -136,4 +139,7 @@ $config = array(
|
||||||
'RootNode' => 'RootNode',
|
'RootNode' => 'RootNode',
|
||||||
'tmpRootPass' => 'q',
|
'tmpRootPass' => 'q',
|
||||||
);
|
);
|
||||||
|
$config['sysSubjs'] = array(
|
||||||
|
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue