本文整理汇总了PHP中Subsite::disable_subsite_filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Subsite::disable_subsite_filter方法的具体用法?PHP Subsite::disable_subsite_filter怎么用?PHP Subsite::disable_subsite_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subsite
的用法示例。
在下文中一共展示了Subsite::disable_subsite_filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: objFromFixture
/**
* Avoid subsites filtering on fixture fetching.
*/
function objFromFixture($class, $id)
{
Subsite::disable_subsite_filter(true);
$obj = parent::objFromFixture($class, $id);
Subsite::disable_subsite_filter(false);
return $obj;
}
示例2: run
public function run($request)
{
$groups = Group::get();
echo 'Pass ?drop=1 to drop groups without members<br/>';
echo 'Want more dropping? Pass ?permission=1 to also drop groups without permissions even if they have members<br/>';
echo 'Pass ?merge=1 to merge groups with the same code<br/>';
echo 'Want to merge across subsites ? Pass ?subsite=1 to disable subsite filters<br/>';
echo '<hr/>';
$merge = $request->getVar('merge');
$drop = $request->getVar('drop');
$dropNoPermission = $request->getVar('permission');
$subsite = $request->getVar('subsite');
if (class_exists('Subsite') && $subsite) {
Subsite::$disable_subsite_filter = true;
}
if ($drop) {
DB::alteration_message("Dropping groups with no members");
if ($dropNoPermission) {
DB::alteration_message("Also dropping groups with no permissions");
}
foreach ($groups as $group) {
if (!$group->Members()->count()) {
DB::alteration_message("Removing group {$group->ID} because it has no members", "deleted");
$group->delete();
}
if ($dropNoPermission) {
$c = $group->Permissions()->count();
if (!$c) {
DB::alteration_message("Removing group {$group->ID} because it has no permissions", "deleted");
$group->delete();
}
}
}
}
if ($merge) {
DB::alteration_message("Merging groups with duplicated codes");
$index = array();
/* @var $group Group */
foreach ($groups as $group) {
DB::alteration_message("Found group " . $group->Code);
if (!isset($index[$group->Code])) {
$index[$group->Code] = $group;
DB::alteration_message("First instance of group, do not merge");
continue;
}
$mergeGroup = $index[$group->Code];
DB::alteration_message('Merge group ' . $group->ID . ' with ' . $mergeGroup->ID, 'repaired');
$i = 0;
foreach ($group->Members() as $m) {
$i++;
$mergeGroup->Members()->add($m);
}
DB::alteration_message('Added ' . $i . ' members to group', 'created');
DB::alteration_message("Group " . $group->ID . ' was deleted', 'deleted');
$group->delete();
}
}
DB::alteration_message('All done!');
}
示例3: process
/**
* To process this job, we need to get the next page whose ID is the next greater than the last
* processed. This way we don't need to remember a bunch of data about what we've processed
*/
public function process()
{
if (ClassInfo::exists('Subsite')) {
Subsite::disable_subsite_filter();
}
$class = $this->reindexType;
$pages = $class::get();
$pages = $pages->filter(array('ID:GreaterThan' => $this->lastIndexedID));
$pages = $pages->limit(Config::inst()->get(__CLASS__, 'at_a_time'));
$pages = $pages->sort('ID ASC');
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
if (!$pages || !$pages->count()) {
$this->isComplete = true;
return;
}
$mode = Versioned::get_reading_mode();
Versioned::reading_stage('Stage');
// index away
$service = singleton('SolrSearchService');
$live = array();
$stage = array();
$all = array();
foreach ($pages as $page) {
// Make sure the current page is not orphaned.
if ($page->ParentID > 0) {
$parent = $page->getParent();
if (is_null($parent) || $parent === false) {
continue;
}
}
// Appropriately index the current page, taking versioning into account.
if ($page->hasExtension('Versioned')) {
$stage[] = $page;
$base = $page->baseTable();
$idField = '"' . $base . '_Live"."ID"';
$livePage = Versioned::get_one_by_stage($page->ClassName, 'Live', $idField . ' = ' . $page->ID);
if ($livePage) {
$live[] = $livePage;
}
} else {
$all[] = $page;
}
$this->lastIndexedID = $page->ID;
}
if (count($all)) {
$service->indexMultiple($all);
}
if (count($stage)) {
$service->indexMultiple($stage, 'Stage');
}
if (count($live)) {
$service->indexMultiple($live, 'Live');
}
Versioned::set_reading_mode($mode);
$this->lastIndexedID = $page->ID;
$this->currentStep += $pages->count();
}
示例4: getQuery
function getQuery()
{
$oldState = Subsite::$disable_subsite_filter;
Subsite::$disable_subsite_filter = true;
$return = parent::getQuery();
Subsite::$disable_subsite_filter = $oldState;
return $return;
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:8,代码来源:SubsiteAgnosticTableListField.php
示例5: done
/**
* @param array $compatibility
*/
public static function done(array $compatibility)
{
if (class_exists("Subsite")) {
Subsite::$disable_subsite_filter = $compatibility[self::SUBSITES];
}
if (class_exists("Translatable")) {
Translatable::enable_locale_filter($compatibility[self::TRANSLATABLE]);
}
}
示例6: getItem
protected function getItem()
{
if (ClassInfo::exists('Subsite')) {
Subsite::disable_subsite_filter(true);
}
$item = DataObject::get_by_id($this->itemType, $this->itemID);
if (ClassInfo::exists('Subsite')) {
Subsite::disable_subsite_filter(false);
}
return $item;
}
示例7: Items
function Items()
{
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = true;
}
$items = parent::Items();
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
return $items;
}
示例8: getAllLivePages
/**
*
* @return DataList
*/
protected function getAllLivePages($subsiteID = 0)
{
ini_set('memory_limit', '200M');
$oldMode = Versioned::get_reading_mode();
if (class_exists('Subsite')) {
Subsite::disable_subsite_filter(true);
}
Versioned::reading_stage('Live');
$pages = DataObject::get("SiteTree");
Versioned::set_reading_mode($oldMode);
if (class_exists('Subsite')) {
return $pages->filter(array('SubsiteID' => $subsiteID));
}
return $pages;
}
示例9: testVirtualPageFromAnotherSubsite
function testVirtualPageFromAnotherSubsite()
{
Subsite::$write_hostmap = false;
$subsite = $this->objFromFixture('Subsite_Template', 'subsite2');
Subsite::changeSubsite($subsite->ID);
Subsite::$disable_subsite_filter = false;
$linky = $this->objFromFixture('SiteTree', 'linky');
$svp = new SubsitesVirtualPage();
$svp->CopyContentFromID = $linky->ID;
$svp->SubsiteID = $subsite->ID;
$svp->URLSegment = 'linky';
$svp->write();
$this->assertEquals($svp->SubsiteID, $subsite->ID);
$this->assertEquals($svp->Title, $linky->Title);
}
示例10: updateLinks
/**
* Rewrite links to the $old file to now point to the $new file.
*
* @uses SiteTree->rewriteFileURL()
*
* @param String $old File path relative to the webroot
* @param String $new File path relative to the webroot
*/
function updateLinks($old, $new)
{
if (class_exists('Subsite')) {
Subsite::disable_subsite_filter(true);
}
$pages = $this->owner->BackLinkTracking();
$summary = "";
if ($pages) {
foreach ($pages as $page) {
$page->rewriteFileURL($old, $new);
}
}
if (class_exists('Subsite')) {
Subsite::disable_subsite_filter(false);
}
}
示例11: loadFixtures
public function loadFixtures()
{
if (ClassInfo::exists('Subsite')) {
$currentSubsite = Subsite::currentSubsiteID();
}
foreach (self::$preload_fixtures as $desc) {
$fixtureFile = $desc['file'];
if (file_exists(Director::baseFolder() . '/' . $fixtureFile)) {
$siteID = null;
if (isset($desc['subsite'])) {
$site = DataObject::get_one('Subsite', '"Title" = \'' . Convert::raw2sql($desc['subsite']) . '\'');
if ($site && $site->ID) {
$siteID = $site->ID;
}
if (!$siteID) {
// no site, so just skip this file load
continue;
}
}
// need to disable the filter when running dev/build so that it actually searches
// within the relevant subsite, not the 'current' one.
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = true;
}
$filter = $desc['filter'] . ($siteID ? ' AND "SubsiteID"=' . $siteID : '');
$existing = DataObject::get_one($desc['type'], $filter);
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
if (!$existing) {
if ($siteID) {
Subsite::changeSubsite($siteID);
}
$fixture = new YamlFixture($fixtureFile);
$fixture->saveIntoDatabase();
DB::alteration_message('YAML bootstrap loaded from ' . $fixtureFile, 'created');
}
}
}
if (ClassInfo::exists('Subsite')) {
Subsite::changeSubsite($currentSubsite);
}
}
示例12: run
public function run($request)
{
set_time_limit(0);
increase_memory_limit_to();
Subsite::$disable_subsite_filter = true;
$mainConfig = SiteConfig::current_site_config();
$mainConfig->compileStyles();
DB::alteration_message("Compile styles for main site");
$subsites = Subsite::get();
foreach ($subsites as $subsite) {
$subsiteConfig = SiteConfig::get()->filter('SubsiteID', $subsite->ID)->first();
if (!$subsiteConfig) {
DB::alteration_message("No config for subsite " . $subsite->ID, "error");
continue;
}
$subsiteConfig->compileStyles();
DB::alteration_message("Compile styles for subsite " . $subsite->ID);
}
DB::alteration_message("All done");
}
示例13: init
public function init()
{
if (!Controller::has_curr()) {
return;
}
/* @var $ctrl Controller */
$ctrl = Controller::curr();
/* @ var $req SS_HTTPRequest */
$req = $ctrl->getRequest();
// Otherwise it will get excluded if it does not have access to all subsites...
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = true;
}
$base = AdminRootController::config()->url_base;
$defaultPanel = AdminRootController::config()->default_panel;
$currentSegment = $req->getURL();
// We will fail if we are redirected to a panel without the proper permission
if (($currentSegment == $base || $currentSegment == $base . '/pages') && $defaultPanel == 'CMSPagesController' && !Permission::check('CMS_ACCESS_CMSMain')) {
// Instead, let's redirect to something we can access
if (Permission::check('CMS_ACCESS')) {
$member = Member::currentUser();
$permissions = Permission::permissions_for_member($member->ID);
foreach ($permissions as $permission) {
if (strpos($permission, 'CMS_ACCESS_') === 0) {
$class = str_replace('CMS_ACCESS_', '', $permission);
$segment = Config::inst()->get($class, 'url_segment');
$url = Director::absoluteBaseURL() . $base . '/' . $segment;
header('Location:' . $url);
exit;
}
}
}
}
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
}
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-devtoolkit,代码行数:37,代码来源:DevToolkitLeftAndMainExtension.php
示例14: getPermissionsDescription
/**
* Builds a comma separated list of human-readbale permissions for a given Member.
*
* @return string
*/
public function getPermissionsDescription()
{
if (class_exists('Subsite')) {
Subsite::disable_subsite_filter(true);
}
$permissionsUsr = Permission::permissions_for_member($this->owner->ID);
$permissionsSrc = Permission::get_codes(true);
sort($permissionsUsr);
$permissionNames = array();
foreach ($permissionsUsr as $code) {
$code = strtoupper($code);
foreach ($permissionsSrc as $k => $v) {
if (isset($v[$code])) {
$name = empty($v[$code]['name']) ? _t('MemberReportExtension.UNKNOWN', 'Unknown') : $v[$code]['name'];
$permissionNames[] = $name;
}
}
}
$result = $permissionNames ? implode(', ', $permissionNames) : _t('MemberReportExtension.NOPERMISSIONS', 'No Permissions');
if (class_exists('Subsite')) {
Subsite::disable_subsite_filter(false);
}
return $result;
}
示例15: augmentSyncLinkTracking
public function augmentSyncLinkTracking()
{
// Set LinkTracking appropriately
$links = HTTP::getLinksIn($this->owner->Content);
$linkedPages = array();
if ($links) {
foreach ($links as $link) {
if (substr($link, 0, strlen('http://')) == 'http://') {
$withoutHttp = substr($link, strlen('http://'));
if (strpos($withoutHttp, '/') && strpos($withoutHttp, '/') < strlen($withoutHttp)) {
$domain = substr($withoutHttp, 0, strpos($withoutHttp, '/'));
$rest = substr($withoutHttp, strpos($withoutHttp, '/') + 1);
$subsiteID = Subsite::getSubsiteIDForDomain($domain);
if ($subsiteID == 0) {
continue;
}
// We have no idea what the domain for the main site is, so cant track links to it
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
Subsite::disable_subsite_filter(true);
$candidatePage = DataObject::get_one("SiteTree", "\"URLSegment\" = '" . Convert::raw2sql(urldecode($rest)) . "' AND \"SubsiteID\" = " . $subsiteID, false);
Subsite::disable_subsite_filter($origDisableSubsiteFilter);
if ($candidatePage) {
$linkedPages[] = $candidatePage->ID;
} else {
$this->owner->HasBrokenLink = true;
}
}
}
}
}
$this->owner->CrossSubsiteLinkTracking()->setByIDList($linkedPages);
}