本文整理汇总了PHP中JUser::getAuthorisedCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::getAuthorisedCategories方法的具体用法?PHP JUser::getAuthorisedCategories怎么用?PHP JUser::getAuthorisedCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::getAuthorisedCategories方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAuthorisedCategories
public function testGetAuthorisedCategories()
{
$user = new JUser(44);
$notAllowed = array(22, 34, 64, 65, 66, 67, 75);
$allowed = $user->getAuthorisedCategories('com_content', 'core.create');
$this->assertEquals(array(), array_intersect($allowed, $notAllowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 not allowed in these categories');
$this->assertEquals(19, count($allowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 allowed create for 19 categories');
$user = new JUser(45);
$notAllowed = array(22, 34, 64, 65, 66, 67, 75, 23, 68, 69, 70, 71);
$allowed = $user->getAuthorisedCategories('com_content', 'core.create');
$this->assertEquals(array(), array_intersect($allowed, $notAllowed), 'Line: ' . __LINE__ . ' User 45 in Groups 5,6 not allowed in these categories');
$this->assertEquals(14, count($allowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 allowed create for 14 categories');
$user = new JUser(46);
$this->assertThat($user->getAuthorisedCategories('com_content', 'core.create'), $this->equalTo(array(67)), 'Line: ' . __LINE__ . ' User 46 in Group 2 only has create for category 67');
$user = new JUser(42);
$allowed = $user->getAuthorisedCategories('com_content', 'core.create');
$this->assertEquals(26, count($allowed), 'Line: ' . __LINE__ . ' User 42 should be allowed all categories');
}
示例2: allowAdd
/**
* Method to check if you can add a new record.
*
* Extended classes can override this if necessary.
*
* @param array $data An array of input data.
*
* @return boolean
*/
protected function allowAdd($data = array())
{
return $this->user->authorise('core.create', $this->option) || count($this->user->getAuthorisedCategories($this->option, 'core.create'));
}