本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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.");
}
}
示例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.");
}
}
示例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);
}