- New API CreateAdministrator used by the setup wizard

SVN:code[4]
This commit is contained in:
Denis Flaven
2009-03-27 10:28:41 +00:00
parent 5bc46af9b6
commit 542ccb38e1
2 changed files with 22 additions and 3 deletions

View File

@@ -165,6 +165,19 @@ class UserRightsMatrix extends UserRightsAddOnAPI
UR_ACTION_BULK_DELETE => 'bulk delete',
);
// Installation: create the very first user
public function CreateAdministrator($sAdminUser, $sAdminPwd)
{
// Maybe we should check that no other user with userid == 0 exists
$oUser = new UserRightsMatrixUsers();
$oUser->Set('login', $sAdminUser);
$oUser->Set('password', $sAdminPwd);
$oUser->Set('userid', 1); // one is for root !
$oUser->DBInsert();
$this->Setup();
return true;
}
public function Setup()
{
// Users must be added manually
@@ -177,7 +190,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
{
foreach (self::$m_aActionCodes as $iActionCode => $sAction)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassGrant AS cg WHERE cg.class = '$sClass' AND cg.action = '$sAction' AND cg.userid = $iUserId"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassGrant AS cg WHERE (cg.class = '$sClass') AND (cg.action = '$sAction') AND (cg.userid = $iUserId)"));
if ($oSet->Count() < 1)
{
// Create a new entry
@@ -191,7 +204,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassStimulusGrant AS sg WHERE sg.class = '$sClass' AND sg.stimulus = '$sStimulusCode' AND sg.userid = $iUserId"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassStimulusGrant AS sg WHERE (sg.class = '$sClass') AND (sg.stimulus = '$sStimulusCode') AND (sg.userid = $iUserId)"));
if ($oSet->Count() < 1)
{
// Create a new entry
@@ -205,7 +218,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
foreach (MetaModel::GetAttributesList($sClass) as $sAttCode)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixAttributeGrant WHERE UserRightsMatrixAttributeGrant.class = '$sClass' AND UserRightsMatrixAttributeGrant.attcode = '$sAttCode' AND UserRightsMatrixAttributeGrant.userid = $iUserId"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixAttributeGrant WHERE (UserRightsMatrixAttributeGrant.class = '$sClass') AND (UserRightsMatrixAttributeGrant.attcode = '$sAttCode') AND (UserRightsMatrixAttributeGrant.userid = $iUserId)"));
if ($oSet->Count() < 1)
{
foreach (array('read', 'modify') as $sAction)

View File

@@ -16,6 +16,12 @@
class UserRightsNull extends UserRightsAddOnAPI
{
// Installation: create the very first user
public function CreateAdministrator($sAdminUser, $sAdminPwd)
{
return true;
}
public function Setup()
{
return true;