Ejemplo n.º 1
0
 public static function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $admin_group = new TBGGroup();
     $admin_group->setName('Administrators');
     $admin_group->setScope($scope);
     $admin_group->save();
     TBGSettings::saveSetting('admingroup', $admin_group->getID(), 'core', $scope_id);
     $user_group = new TBGGroup();
     $user_group->setName('Regular users');
     $user_group->setScope($scope);
     $user_group->save();
     TBGSettings::saveSetting('defaultgroup', $user_group->getID(), 'core', $scope_id);
     $guest_group = new TBGGroup();
     $guest_group->setName('Guests');
     $guest_group->setScope($scope);
     $guest_group->save();
     // Set up initial users, and their permissions
     if ($scope->isDefault()) {
         list($guestuser_id, $adminuser_id) = TBGUser::loadFixtures($scope, $admin_group, $user_group, $guest_group);
         TBGUserScopesTable::getTable()->addUserToScope($guestuser_id, $scope->getID(), $guest_group->getID(), true);
         TBGUserScopesTable::getTable()->addUserToScope($adminuser_id, $scope->getID(), $admin_group->getID(), true);
     } else {
         $default_scope_id = TBGSettings::getDefaultScopeID();
         $default_user_id = (int) TBGSettings::get(TBGSettings::SETTING_DEFAULT_USER_ID, 'core', $default_scope_id);
         TBGUserScopesTable::getTable()->addUserToScope($default_user_id, $scope->getID(), $user_group->getID(), true);
         TBGUserScopesTable::getTable()->addUserToScope(1, $scope->getID(), $admin_group->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_USER_ID, $default_user_id, 'core', $scope->getID());
     }
     TBGPermissionsTable::getTable()->loadFixtures($scope, $admin_group->getID(), $guest_group->getID());
 }
Ejemplo n.º 2
0
 public static function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $admin_group = new TBGGroup();
     $admin_group->setName('Administrators');
     $admin_group->setScope($scope);
     $admin_group->save();
     TBGSettings::saveSetting('admingroup', $admin_group->getID(), 'core', $scope_id);
     $user_group = new TBGGroup();
     $user_group->setName('Regular users');
     $user_group->setScope($scope);
     $user_group->save();
     TBGSettings::saveSetting('defaultgroup', $user_group->getID(), 'core', $scope_id);
     $guest_group = new TBGGroup();
     $guest_group->setName('Guests');
     $guest_group->setScope($scope);
     $guest_group->save();
     // Set up initial users, and their permissions
     TBGUser::loadFixtures($scope, $admin_group, $user_group, $guest_group);
     TBGPermissionsTable::getTable()->loadFixtures($scope, $admin_group->getID(), $guest_group->getID());
 }