当前位置: 首页>>代码示例>>PHP>>正文


PHP LeftAndMain::canView方法代码示例

本文整理汇总了PHP中LeftAndMain::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP LeftAndMain::canView方法的具体用法?PHP LeftAndMain::canView怎么用?PHP LeftAndMain::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LeftAndMain的用法示例。


在下文中一共展示了LeftAndMain::canView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canView

 /**
  * Relax the access permissions, so anyone who has access to any CMS subsite can access this controller.
  */
 public function canView($member = null)
 {
     if (parent::canView()) {
         return true;
     }
     if (Subsite::all_accessible_sites()->count() > 0) {
         return true;
     }
     return false;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:13,代码来源:SubsiteXHRController.php

示例2: canView

	/**
	 * Does the parent permission checks, but also
	 * makes sure that instantiatable subclasses of
	 * {@link Report} exist. By default, the CMS doesn't
	 * include any Reports, so there's no point in showing
	 *
	 * @param Member $member
	 * @return boolean
	 */
	function canView($member = null) {
		if(!$member && $member !== FALSE) $member = Member::currentUser();

		if(!parent::canView($member)) return false;

		$hasViewableSubclasses = false;
		foreach($this->Reports() as $report) {
			if($report->canView($member)) return true;
		}

		return false;
	}
开发者ID:redema,项目名称:silverstripe-cms,代码行数:21,代码来源:ReportAdmin.php

示例3: canView

 function canView()
 {
     if (self::$trusted_envs && !in_array(Director::get_environment_type(), self::$trusted_envs)) {
         return false;
     }
     if (self::$trusted_ips && !in_array($_SERVER['REMOTE_ADDR'], self::$trusted_ips)) {
         return false;
     }
     if (!self::$activated) {
         return false;
     }
     return parent::canView();
 }
开发者ID:alapini,项目名称:silverstripe-dbplumber,代码行数:13,代码来源:DatabaseBrowser.php

示例4: canView

 /**
  * Does the parent permission checks, but also
  * makes sure that instantiatable subclasses of
  * {@link Report} exist. By default, the CMS doesn't
  * include any Reports, so there's no point in showing
  *
  * @param Member $member
  * @return boolean
  */
 public function canView($member = null)
 {
     if (!$member && $member !== FALSE) {
         $member = Member::currentUser();
     }
     if (!parent::canView($member)) {
         return false;
     }
     if ($this->reportObject) {
         return $this->reportObject->canView($member);
     }
     foreach ($this->Reports() as $report) {
         if ($report->canView($member)) {
             return true;
         }
     }
     return false;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:27,代码来源:ReportAdmin.php

示例5: canView

	/**
	 * Does the parent permission checks, but also
	 * makes sure that instantiatable subclasses of
	 * {@link Report} exist. By default, the CMS doesn't
	 * include any Reports, so there's no point in showing
	 * 
	 * @param Member $member
	 * @return boolean
	 */
	function canView($member = null) {
		if(!$member && $member !== FALSE) {
			$member = Member::currentUser();
		}
		
		if(!parent::canView($member)) return false;
		
		$hasViewableSubclasses = false;
		$subClasses = array_values(ClassInfo::subclassesFor('SSReport'));
		foreach($subClasses as $subclass) {
			// Remove abstract classes and LeftAndMain
			$classReflection = new ReflectionClass($subclass);
			if($classReflection->isInstantiable() && $subclass != 'SSReport') {
				if(singleton($subclass)->canView()) $hasViewableSubclasses = true;
			}			
		}
		
		return $hasViewableSubclasses;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:28,代码来源:ReportAdmin.php

示例6: testAlternateAccessCheck

 function testAlternateAccessCheck()
 {
     $admin = $this->objFromFixture("Member", "admin");
     $this->loginAs($admin);
     $ids = array();
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     $subsite2 = $this->objFromFixture('Subsite', 'domaintest2');
     $subsite3 = $this->objFromFixture('Subsite', 'domaintest3');
     $ids[] = $subsite1->ID;
     $ids[] = $subsite2->ID;
     $ids[] = $subsite3->ID;
     $ids[] = 0;
     foreach ($ids as $id) {
         Subsite::changeSubsite($id);
         //switch to main site (subsite ID zero)
         $left = new LeftAndMain();
         $this->assertTrue($left->canView(), "Admin user can view subsites LeftAndMain with id = '{$id}'");
         $this->assertEquals($id, Subsite::currentSubsiteID(), "The current subsite has not been changed in the process of checking permissions for admin user.");
     }
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:20,代码来源:LeftAndMainSubsitesTest.php

示例7: testAccessChecksDontChangeCurrentSubsite

 function testAccessChecksDontChangeCurrentSubsite()
 {
     $admin = $this->objFromFixture("Member", "admin");
     $this->loginAs($admin);
     $ids = array();
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     $subsite2 = $this->objFromFixture('Subsite', 'domaintest2');
     $subsite3 = $this->objFromFixture('Subsite', 'domaintest3');
     $ids[] = $subsite1->ID;
     $ids[] = $subsite2->ID;
     $ids[] = $subsite3->ID;
     $ids[] = 0;
     // Enable session-based subsite tracking.
     Subsite::$use_session_subsiteid = true;
     foreach ($ids as $id) {
         Subsite::changeSubsite($id);
         $this->assertEquals($id, Subsite::currentSubsiteID());
         $left = new LeftAndMain();
         $this->assertTrue($left->canView(), "Admin user can view subsites LeftAndMain with id = '{$id}'");
         $this->assertEquals($id, Subsite::currentSubsiteID(), "The current subsite has not been changed in the process of checking permissions for admin user.");
     }
 }
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:22,代码来源:LeftAndMainSubsitesTest.php

示例8: canView

 /**
  * @param null $member
  * @return bool|int
  */
 public function canView($member = null)
 {
     if (!$member && $member !== false) {
         $member = Member::currentUser();
     }
     $codes = array();
     $extraCodes = $this->stat('required_permission_codes');
     if ($extraCodes !== false) {
         // allow explicit FALSE to disable subclass check
         if ($extraCodes) {
             $codes = array_merge($codes, (array) $extraCodes);
         } else {
             $codes[] = "CMS_ACCESS_{$this->class}";
         }
     }
     foreach ($codes as $code) {
         if (!Permission::checkMember($member, $code)) {
             return false;
         }
     }
     return parent::canView($member);
 }
开发者ID:littlegiant,项目名称:silverstripe-singlepageadmin,代码行数:26,代码来源:SinglePageAdmin.php


注:本文中的LeftAndMain::canView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。