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