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


PHP Perms::mixedFilter方法代码示例

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


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

示例1: testFilterMixed

 function testFilterMixed()
 {
     $perms = new Perms();
     $perms->setResolverFactories(array($resolver = $this->getMock('Perms_ResolverFactory'), new Perms_ResolverFactory_StaticFactory('global', new Perms_Resolver_Default(true))));
     Perms::set($perms);
     $resolver->expects($this->any())->method('getResolver')->will($this->returnValue(null));
     $resolver->expects($this->exactly(3))->method('bulk')->will($this->returnValue(array()));
     $resolver->expects($this->at(0))->method('bulk')->will($this->returnValue(array()))->with($this->equalTo(array('type' => 'wiki page')), $this->equalTo('object'), $this->equalTo(array('A', 'B')));
     $resolver->expects($this->at(1))->method('bulk')->will($this->returnValue(array()))->with($this->equalTo(array('type' => 'category')), $this->equalTo('object'), $this->equalTo(array(10)));
     $data = array(array('type' => 'wiki page', 'object' => 'A', 'creator' => 'abc'), array('type' => 'wiki page', 'object' => 'B', 'creator' => 'abc'), array('type' => 'category', 'object' => 10), array('type' => 'forumPost', 'object' => 12, 'author' => 'author'));
     $out = Perms::mixedFilter(array(), 'type', 'object', $data, array('wiki page' => array('object' => 'object', 'type' => 'type', 'creator' => 'creator'), 'category' => array('object' => 'object', 'type' => 'type'), 'forumPost' => array('object' => 'object', 'type' => 'type', 'creator' => 'author')), array('wiki page' => 'view', 'category' => 'view_categories', 'forumPost' => 'forum_post'));
     $this->assertEquals($data, $out);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:13,代码来源:MixedTest.php

示例2: filter_object_list

 /**
  * @param array $result		object list
  * @param int $cant			size of list
  * @param int $offset		start of list
  * @param int $maxRecords	size of page - NB: -1 will check perms etc on every object and can be very slow
  * @return array
  */
 private function filter_object_list($result, $cant, $offset, $maxRecords)
 {
     global $user, $prefs;
     $permMap = TikiLib::lib('object')->map_object_type_to_permission();
     $groupList = $this->get_user_groups($user);
     // Filter based on permissions
     $contextMap = array('type' => 'type', 'object' => 'itemId');
     $contextMapMap = array_fill_keys(array_keys($permMap), $contextMap);
     if ($maxRecords == -1) {
         $requiredResult = $result;
     } else {
         $requiredResult = array_slice($result, $offset, $maxRecords);
     }
     $requiredResult = Perms::mixedFilter(array(), 'type', 'object', $requiredResult, $contextMapMap, $permMap);
     if ($maxRecords != -1) {
         // if filtered result is less than what's there look for more
         while (count($requiredResult) < $maxRecords && count($requiredResult) < $cant) {
             $nextResults = array_slice($result, $maxRecords, $maxRecords - count($requiredResult));
             $nextResults = Perms::mixedFilter(array(), 'type', 'object', $nextResults, $contextMapMap, $permMap);
             if (empty($nextResults)) {
                 break;
             }
             $requiredResult = array_merge($requiredResult, $nextResults);
         }
     } else {
         $cant = count($requiredResult);
     }
     $result = $requiredResult;
     $ret = array();
     $objs = array();
     foreach ($result as $res) {
         if (!in_array($res['catObjectId'] . '-' . $res['categId'], $objs)) {
             // same object and same category
             if (preg_match('/trackeritem/', $res['type']) && $res['description'] == '') {
                 $trklib = TikiLib::lib('trk');
                 $trackerId = preg_replace('/^.*trackerId=([0-9]+).*$/', '$1', $res['href']);
                 $res['name'] = $trklib->get_isMain_value($trackerId, $res['itemId']);
                 $filed = $trklib->get_field_id($trackerId, "description");
                 $res['description'] = $trklib->get_item_value($trackerId, $res['itemId'], $filed);
                 if (empty($res['description'])) {
                     $res['description'] = $this->getOne("select `name` from `tiki_trackers` where `trackerId`=?", array((int) $trackerId));
                 }
             }
             if ($prefs['feature_sefurl'] == 'y') {
                 $type = $res['type'] == 'wiki page' ? 'wiki' : $res['type'];
                 $res['sefurl'] = filter_out_sefurl($res['href'], $type);
             }
             if (empty($res['name'])) {
                 $res['name'] = '#' . $res['itemId'];
             }
             $ret[] = $res;
             $objs[] = $res['catObjectId'] . '-' . $res['categId'];
         }
     }
     return array("data" => $ret, "cant" => $cant);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:63,代码来源:categlib.php


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