本文整理汇总了PHP中TBGSettings::getDefaultScopeID方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGSettings::getDefaultScopeID方法的具体用法?PHP TBGSettings::getDefaultScopeID怎么用?PHP TBGSettings::getDefaultScopeID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGSettings
的用法示例。
在下文中一共展示了TBGSettings::getDefaultScopeID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearUserScopes
public function clearUserScopes($user_id)
{
$crit = $this->getCriteria();
$crit->addWhere(self::SCOPE, TBGSettings::getDefaultScopeID(), Criteria::DB_NOT_EQUALS);
$crit->addWhere(self::USER_ID, $user_id);
$this->doDelete($crit);
}
示例2: loadFixtures
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());
}
示例3: runUpdateUserScopes
public function runUpdateUserScopes(TBGRequest $request)
{
try {
if (!TBGContext::getScope()->isDefault()) {
throw new Exception('This operation is not allowed');
}
$user = TBGContext::factory()->TBGUser($request['user_id']);
if ($user instanceof TBGUser) {
$return_options = array('message' => $this->getI18n()->__("The user's scope access was successfully updated"));
$scopes = $request->getParameter('scopes', array());
if (count($scopes) && !(count($scopes) == 1 && array_key_exists(TBGSettings::getDefaultScopeID(), $scopes))) {
foreach ($user->getScopes() as $scope_id => $scope) {
if (!$scope->isDefault() && !array_key_exists($scope_id, $scopes)) {
$user->removeScope($scope_id);
}
}
foreach ($scopes as $scope_id => $scope) {
try {
$scope = new TBGScope((int) $scope_id);
if ($user->isMemberOfScope($scope)) {
continue;
}
$user->addScope($scope);
} catch (Exception $e) {
}
}
}
return $this->renderJSON($return_options);
}
} catch (Exception $e) {
$this->getResponse()->setHttpStatus(400);
return $this->renderJSON(array('error' => $this->getI18n()->__('This user could not be updated: %message', array('%message' => $e->getMessage()))));
}
$this->getResponse()->setHttpStatus(400);
return $this->renderJSON(array('error' => $this->getI18n()->__('This user could not be updated')));
}
示例4: _postSave
/**
* Performs post-save actions on user objects
*
* This includes firing off events for modules to listen to (e.g. so
* activation emails can be sent out), and setting up a default
* dashboard for the new user.
*
* @param boolean $is_new Whether this is a new object or not (automatically passed to the function from B2DB)
*/
protected function _postSave($is_new)
{
if ($is_new) {
// Set up a default dashboard for the user
TBGDashboardViewsTable::getTable()->setDefaultViews($this->getID(), TBGDashboardViewsTable::TYPE_USER);
$scope = TBGContext::factory()->TBGScope((int) TBGSettings::getDefaultScopeID());
$this->addScope($scope, false);
$this->confirmScope($scope->getID());
if (!TBGContext::getScope()->isDefault()) {
$scope = TBGContext::getScope();
$this->addScope($scope, false);
$this->confirmScope($scope->getID());
}
$event = TBGEvent::createNew('core', 'TBGUser::_postSave', $this);
$event->trigger();
}
if ($this->_group_id !== null) {
TBGUserScopesTable::getTable()->updateUserScopeGroup($this->getID(), TBGContext::getScope()->getID(), $this->_group_id);
}
}