Exemple #1
0
// security managers initialization (for current FA and 'global' for entire site)
if ($fusebox['mode'] == "development" || $oUser->isDev()) {
    $oSecurityManager = new SecurityManager($oDB, $oUser, $oFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_LOOSE, true);
    $ogSecurityManager = new SecurityManager($oDB, $oUser, $ogFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_LOOSE, true);
} else {
    if ($fusebox['globalSecurityMode'] == "STRICT") {
        $oSecurityManager = new SecurityManager($oDB, $oUser, $oFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_STRICT, false);
        $ogSecurityManager = new SecurityManager($oDB, $oUser, $ogFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_STRICT, false);
    } elseif ($fusebox['globalSecurityMode'] == "LOOSE") {
        $oSecurityManager = new SecurityManager($oDB, $oUser, $oFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_LOOSE, false);
        $ogSecurityManager = new SecurityManager($oDB, $oUser, $ogFuseaction, $fusebox['tableSecurity'], $fusebox['tableGroups'], $fusebox['tableUsersGroups'], $fusebox['defaultGroup'], SECURITYMODE_LOOSE, false);
    } else {
        _throw("FUncertainSecurityMode", "Security mode is uncertain");
    }
}
if (!$oSecurityManager->initialize() || !$ogSecurityManager->initialize()) {
    _throw("FNoSecurityTables", "There are no security tables \"{$fusebox['tableGroups']}\" and/or \"{$fusebox['tableSecurity']}\" present in DB");
}
// checking that default user group exists and add it if needed
if (!$oSecurityManager->checkGroup($fusebox['defaultGroup'])) {
    $tmpoGroup = new Group(0, $fusebox['defaultGroup']);
    if ($oSecurityManager->addGroup($tmpoGroup)) {
        unset($tmpoGroup);
    } else {
        _throw("FCannotAddDefaultGroup", "Cannot add default security group");
    }
}
// check if user is default user then make him belong to default group only
if ($defaultGroup = $oSecurityManager->getGroup($fusebox['defaultGroup'])) {
    if ($oUser->isDefaultUser()) {
        if (!$oSecurityManager->setUserGroups(array($defaultGroup))) {