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


PHP JUser::getAuthorisedCategories方法代码示例

本文整理汇总了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');
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:18,代码来源:JUserTestGetAuthorisedCategories.php

示例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'));
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:13,代码来源:AbstractAdminController.php


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