本文整理汇总了PHP中Perms::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Perms::filter方法的具体用法?PHP Perms::filter怎么用?PHP Perms::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Perms
的用法示例。
在下文中一共展示了Perms::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableTransitions
function getAvailableTransitions( $object, $type = null )
{
$states = $this->getCurrentStates($object, $type);
$transitions = $this->getTransitionsFromStates($states);
$transitions = Perms::filter(
array('type' => 'transition'),
'object',
$transitions,
array('object' => 'transitionId'),
'trigger_transition'
);
foreach ( $transitions as & $tr ) {
$object = new Transition($tr['from'], $tr['to']);
$object->setStates($states);
foreach ( $tr['guards'] as $guard ) {
call_user_func_array(array($object, 'addGuard' ), $guard);
}
$tr['enabled'] = $object->isReady();
$tr['explain'] = $object->explain();
}
return $transitions;
}
示例2: list_templates
/**
* @param $section
* @param $offset
* @param $maxRecords
* @param $sort_mode
* @param $find
* @return array
*/
public function list_templates($section, $offset, $maxRecords, $sort_mode, $find)
{
$bindvars = array($section);
if ($find) {
$findesc = '%' . $find . '%';
$mid = " and (`content` like ?)";
$bindvars[] = $findesc;
} else {
$mid = "";
}
$query = "select `name` ,`created`,tcts.`templateId` from `tiki_content_templates` tct, `tiki_content_templates_sections` tcts ";
$query .= " where tcts.`templateId`=tct.`templateId` and `section`=? {$mid} order by " . $this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_content_templates` tct, `tiki_content_templates_sections` tcts ";
$query_cant .= "where tcts.`templateId`=tct.`templateId` and `section`=? {$mid}";
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
while ($res = $result->fetchRow()) {
$query2 = "select `section` from `tiki_content_templates_sections` where `templateId`=?";
$result2 = $this->query($query2, array((int) $res["templateId"]));
$sections = array();
while ($res2 = $result2->fetchRow()) {
$sections[] = $res2["section"];
}
$res["sections"] = $sections;
$ret[] = $res;
}
// filter out according to perms
$ret = Perms::filter(array('type' => 'template'), 'object', $ret, array('object' => 'templateId'), 'use_content_templates');
$cant = count($ret);
$retval = array();
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
示例3: get_past
function get_past($offset, $max, $ofUser = '')
{
$conditions = 'tpr.`amount` <= tpr.`amount_paid` AND tpr.`cancel_date` IS NULL';
if ($ofUser) {
$conditions .= " AND uu.`login` = '{$ofUser}'";
}
$count = 'SELECT COUNT(*) FROM `tiki_payment_requests` tpr LEFT JOIN `users_users` uu ON (uu.`userId` = tpr.`userId`) WHERE ' . $conditions;
$data = 'SELECT tpr.*, uu.`login` as `user`, tp.`type`, tp.`payment_date`,' . ' tp.`details` as `payment_detail`, uup.`login` as `payer`' . ' FROM `tiki_payment_requests` tpr' . ' LEFT JOIN `users_users` uu ON (uu.`userId` = tpr.`userId`)' . ' LEFT JOIN `tiki_payment_received` tp ON (tp.`paymentRequestId`=tpr.`paymentRequestId`)' . ' LEFT JOIN `users_users` uup ON (uup.`userId` = tp.`userId`) WHERE ' . $conditions;
$all = $this->fetchAll($data, array(), $max, $offset);
return array('cant' => $this->getOne($count), 'data' => Perms::filter(array('type' => 'payment'), 'object', $all, array('object' => 'paymentRequestId'), 'payment_view'));
}
示例4: list_surveys
/**
* @param $offset
* @param $maxRecords
* @param $sort_mode
* @param $find
* @return array
*/
public function list_surveys($offset, $maxRecords, $sort_mode, $find, $perm = 'take_survey')
{
$conditions = array();
if ($find) {
$conditions['search'] = $this->surveysTable->expr('(`name` like ? or `description` like ?)', array("%{$find}%", "%{$find}%"));
}
$surveys = $this->surveysTable->fetchAll($this->surveysTable->all(), $conditions, $maxRecords, $offset, $this->surveysTable->sortMode($sort_mode));
$surveys = Perms::filter(array('type' => 'survey'), 'object', $surveys, array('object' => 'surveyId'), $perm);
foreach ($surveys as &$survey) {
$survey['questions'] = $this->questionsTable->fetchOne($this->questionsTable->count(), array('surveyId' => $survey['surveyId']));
}
$retval["data"] = $surveys;
$retval["cant"] = count($surveys);
return $retval;
}
示例5: list_all_blog_posts
/**
* list_all_blog_posts Returns all the posts filtered by $date and $find
*
* @param int $offset
* @param int $maxRecords
* @param string $sort_mode
* @param string $find
* @param string $date
* @access public
* @return void
*/
function list_all_blog_posts($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $date = '')
{
if ($find) {
$findesc = '%' . $find . '%';
$mid = " where (`data` like ?) ";
$bindvars = array($findesc);
} else {
$mid = "";
$bindvars = array();
}
if ($date) {
$bindvars[] = $date;
if ($mid) {
$mid .= " and `created`<=? ";
} else {
$mid .= " where `created`<=? ";
}
}
$query = "select * from `tiki_blog_posts` {$mid} order by " . $this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_blog_posts` {$mid}";
$result = $this->fetchAll($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
$result = Perms::filter(array('type' => 'blog'), 'object', $result, array('object' => 'blogId'), array('read_blog', 'blog_view_ref'));
foreach ($result as $res) {
$query2 = "select `title` from `tiki_blogs` where `blogId`=?";
$title = $this->getOne($query2, array($res["blogId"]));
$res["blogtitle"] = $title;
$ret[] = $res;
}
$retval = array();
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
示例6: list_pages
/**
* @param int $offset
* @param $maxRecords
* @param string $sort_mode
* @param string $find
* @param string $initial
* @param bool $exact_match
* @param bool $onlyName
* @param bool $forListPages
* @param bool $only_orphan_pages
* @param string $filter
* @param bool $onlyCant
* @param string $ref
* @return array
*/
function list_pages($offset = 0, $maxRecords = -1, $sort_mode = 'pageName_desc', $find = '', $initial = '', $exact_match = true, $onlyName = false, $forListPages = false, $only_orphan_pages = false, $filter = '', $onlyCant = false, $ref = '')
{
global $prefs, $tiki_p_wiki_view_ratings;
$loadCategories = isset($prefs['wiki_list_categories']) && $prefs['wiki_list_categories'] == 'y' || isset($prefs['wiki_list_categories_path']) && $prefs['wiki_list_categories_path'] == 'y';
$loadCategories = $loadCategories && $forListPages;
$join_tables = '';
$join_bindvars = array();
$old_sort_mode = '';
if ($sort_mode == 'size_desc') {
$sort_mode = 'page_size_desc';
}
if ($sort_mode == 'size_asc') {
$sort_mode = 'page_size_asc';
}
$select = '';
// If sort mode is versions, links or backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil
$need_everything = false;
if (in_array($sort_mode, array('versions_desc', 'versions_asc', 'links_asc', 'links_desc', 'backlinks_asc', 'backlinks_desc'))) {
$old_sort_mode = $sort_mode;
$sort_mode = 'user_desc';
$need_everything = true;
}
if (is_array($find)) {
// you can use an array of pages
$mid = " where LOWER(`pageName`) IN (" . implode(',', array_fill(0, count($find), 'LOWER(?)')) . ")";
$bindvars = $find;
} elseif (is_string($find) && !empty($find)) {
// or a string
if (!$exact_match && $find) {
$find = preg_replace("/([^\\s]+)/", "%\\1%", $find);
$f = preg_split("/[\\s]+/", $find, -1, PREG_SPLIT_NO_EMPTY);
if (empty($f)) {
//look for space...
$mid = " where LOWER(`pageName`) like LOWER('%{$find}%')";
} else {
$findop = $forListPages ? ' AND' : ' OR';
$mid = " where LOWER(`pageName`) like " . implode($findop . ' LOWER(`pageName`) like ', array_fill(0, count($f), 'LOWER(?)'));
$bindvars = $f;
}
} else {
$mid = " where LOWER(`pageName`) like LOWER(?) ";
$bindvars = array($find);
}
} else {
$bindvars = array();
$mid = '';
}
$categlib = TikiLib::lib('categ');
$category_jails = $categlib->get_jail();
if (!isset($filter['andCategId']) && !isset($filter['categId']) && empty($filter['noCateg']) && !empty($category_jails)) {
$filter['categId'] = $category_jails;
}
// If language is set to '', assume that no language filtering should be done.
if (isset($filter['lang']) && $filter['lang'] == '') {
unset($filter['lang']);
}
$distinct = '';
if (!empty($filter)) {
$tmp_mid = array();
foreach ($filter as $type => $val) {
if ($type == 'andCategId') {
$categories = $categlib->get_jailed((array) $val);
$join_tables .= " inner join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) ";
$join_bindvars[] = 'wiki page';
foreach ($categories as $i => $categId) {
$join_tables .= " inner join `tiki_category_objects` as tc{$i} on (tc{$i}.`catObjectId`=tob.`objectId` and tc{$i}.`categId` =?) ";
$join_bindvars[] = $categId;
}
} elseif ($type == 'categId') {
$categories = $categlib->get_jailed((array) $val);
$categories[] = -1;
$cat_count = count($categories);
$join_tables .= " inner join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) inner join `tiki_category_objects` as tc on (tc.`catObjectId`=tob.`objectId` and tc.`categId` IN(" . implode(', ', array_fill(0, $cat_count, '?')) . ")) ";
if ($cat_count > 1) {
$distinct = ' DISTINCT ';
}
$join_bindvars = array_merge(array('wiki page'), $categories);
} elseif ($type == 'noCateg') {
$join_tables .= ' left join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) left join `tiki_categorized_objects` as tcdo on (tcdo.`catObjectId`=tob.`objectId`) left join `tiki_category_objects` as tco on (tcdo.`catObjectId`=tco.`catObjectId`)';
$join_bindvars[] = 'wiki page';
$tmp_mid[] = '(tco.`categId` is null)';
} elseif ($type == 'notCategId') {
foreach ($val as $v) {
$tmp_mid[] = '(tp.`pageName` NOT IN(SELECT itemId FROM tiki_objects INNER JOIN tiki_category_objects ON catObjectId = objectId WHERE type = "wiki page" AND categId = ?))';
$bindvars[] = $v;
//.........这里部分代码省略.........
示例7: tra
$smarty->assign('exportEOL', $_REQUEST['exportEOL']);
$smarty->assign('exportQuote', $_REQUEST['exportQuote']);
$smarty->assign('bookAutoTax', $_REQUEST['bookAutoTax']);
}
break;
case 'close' :
if (!$globalperms->acct_create_book) {
$smarty->assign('msg', tra("You do not have permissions to close this book") . ": feature_accounting");
$smarty->display("error.tpl");
die;
}
$accountinglib->closeBook($_REQUEST['bookId']);
break;
case 'view' :
break;
default ://list
}
$books=$accountinglib->listBooks();
$filtered = Perms::filter(
array( 'type' => 'accounting book'),
'object',
$books,
array( 'object' => 'bookName' ),
'acct_view'
);
$smarty->assign('books', $books);
$smarty->assign('canCreate', $globalperms->acct_create_book);
ask_ticket('accounting');
$smarty->assign('mid', 'tiki-accounting_books.tpl');
$smarty->display("tiki.tpl");
示例8: hasOnlyPrivateBacklinks
function hasOnlyPrivateBacklinks($fileId)
{
$objects = $this->getFileBacklinks($fileId);
if (empty($objects)) {
return false;
}
foreach ($objects as $object) {
$pobjects[$object['type']][] = $object;
}
include_once 'lib/objectlib.php';
$map = ObjectLib::map_object_type_to_permission();
foreach ($pobjects as $type => $list) {
if ($type == 'blog post') {
$this->parentObjects($list, 'tiki_blog_posts', 'postId', 'blogId');
$f = Perms::filter(array('type' => 'blog'), 'object', $list, array('object' => 'blogId'), str_replace('tiki_p_', '', $map['blog']));
} elseif (strstr($type, 'comment')) {
$this->parentObjects($list, 'tiki_comments', 'threadId', 'object');
$t = str_replace(' comment', '', $type);
$f = Perms::filter(array('type' => $t), 'object', $list, array('object' => 'object'), str_replace('tiki_p_', '', $map[$t]));
} elseif ($type == 'forum post') {
$this->parentObjects($list, 'tiki_comments', 'threadId', 'object');
$f = Perms::filter(array('type' => 'forum'), 'object', $list, array('object' => 'object'), str_replace('tiki_p_', '', $map['forum']));
} elseif ($type == 'trackeritem') {
$this->parentObjects($list, 'tiki_tracker_items', 'itemId', 'trackerId');
$f = Perms::filter(array('type' => 'tracker'), 'object', $list, array('object' => 'trackerId'), str_replace('tiki_p_', '', $map['tracker']));
//NEED to check item perm
} else {
$f = Perms::filter(array('type' => $type), 'object', $list, array('object' => 'itemId'), str_replace('tiki_p_', '', $map[$type]));
}
$debug = 0;
if (!empty($debug)) {
echo "<br />FILE{$fileId}";
if (!empty($f)) {
echo 'OK-';
} else {
echo 'NO-';
}
foreach ($list as $l) {
echo $l['type'] . ': ' . $l['itemId'] . '(' . $l['href'] . ')' . ',';
}
}
if (!empty($f)) {
return false;
}
}
return true;
}
示例9: array
$page_ref_id = $_REQUEST['page_ref_id'];
} else {
// else check if page is the head of a structure
$page_ref_id = $structlib->get_struct_ref_if_head($_REQUEST['page']);
}
//If a structure page isnt going to be displayed
if (empty($page_ref_id)) {
//Check to see if its a member of any structures
if (isset($_REQUEST['structure']) && !empty($_REQUEST['structure'])) {
$struct = $_REQUEST['structure'];
} else {
$struct = '';
}
//Get the structures this page is a member of
$structs = $structlib->get_page_structures($_REQUEST['page'], $struct);
$structs_with_perm = Perms::filter(array('type' => 'wiki page'), 'object', $structs, array('object' => 'permName'), 'view');
//If page is only member of one structure, display if requested
$single_struct = count($structs_with_perm) == 1;
if ((!empty($struct) || $prefs['feature_wiki_open_as_structure'] == 'y') && $single_struct) {
$page_ref_id = $structs_with_perm[0]['req_page_ref_id'];
$_REQUEST['page_ref_id'] = $page_ref_id;
}
}
} elseif (!empty($_REQUEST['page_ref_id'])) {
$smarty->assign('msg', tra('This feature is disabled') . ': feature_wiki_structure');
$smarty->display('error.tpl');
die;
}
if (!empty($page_ref_id)) {
$page_info = $structlib->s_get_page_info($page_ref_id);
$info = null;
示例10: filter_categ_items
function filter_categ_items($ret)
{
// FIXME: this is an approximation - the perm should be function of the status
$categlib = TikiLib::lib('categ');
if (!empty($ret[0]['itemId']) && $categlib->is_categorized('trackeritem', $ret[0]['itemId'])) {
return Perms::filter(array('type' => 'trackeritem'), 'object', $ret, array('object' => 'itemId'), 'view_trackers');
} else {
return $ret;
}
}
示例11: list_perspectives
function list_perspectives($offset = 0, $maxRecords = -1)
{
$db = TikiDb::get();
$list = $db->fetchAll("SELECT perspectiveId, name FROM tiki_perspectives", array(), $maxRecords, $offset);
$list = Perms::filter(array('type' => 'perspective'), 'object', $list, array('object' => 'perspectiveId'), 'perspective_view');
foreach ($list as &$info) {
$perms = Perms::get(array('type' => 'perspective', 'object' => $info['perspectiveId']));
$this->write_permissions($info, $perms);
}
return $list;
}
示例12: str_replace
$cats = $categlib->get_default_categories();
}
if ($cat_type == 'wiki page' || $cat_type == 'blog' || $cat_type == 'image gallery' || $cat_type == 'mypage') {
$ext = $cat_type == 'wiki page' ? 'wiki' : str_replace(' ', '_', $cat_type);
$pref = 'feature_' . $ext . '_mandatory_category';
if ($prefs[$pref] > 0) {
$categories = $categlib->getCategories(array('identifier' => $prefs[$pref], 'type' => 'descendants'));
} else {
$categories = $categlib->getCategories();
}
$smarty->assign('mandatory_category', $prefs[$pref]);
} else {
$categories = $categlib->getCategories();
}
$can = $catobjperms->modify_object_categories;
$categories = Perms::filter(array('type' => 'category'), 'object', $categories, array('object' => 'categId'), array('view_category'));
foreach ($categories as &$category) {
$catperms = Perms::get(array('type' => 'category', 'object' => $category['categId']));
if (in_array($category["categId"], $cats)) {
$category["incat"] = 'y';
$category['canchange'] = !$cat_object_exists || $can && $catperms->remove_object;
} else {
$category["incat"] = 'n';
$category['canchange'] = $can && $catperms->add_object;
}
// allow to preselect categories when creating a new article
// like this: /tiki-edit_article.php?cat_categories[]=1&cat_categorize=on
if (!$cat_object_exists && isset($_REQUEST["cat_categories"]) && isset($_REQUEST["cat_categorize"]) && $_REQUEST["cat_categorize"] == 'on') {
if (in_array($category["categId"], $_REQUEST["cat_categories"])) {
$category["incat"] = 'y';
} else {
示例13: testContextBuilding
function testContextBuilding()
{
$perms = new Perms();
$perms->setResolverFactories(array($mock = $this->getMock('Perms_ResolverFactory')));
Perms::set($perms);
$mock->expects($this->once())->method('getResolver')->with($this->equalTo(array('type' => 'wiki page', 'object' => 'Hello World', 'creator' => 'admin')))->will($this->returnValue(null));
$mock->expects($this->once())->method('bulk');
$data = array(array('pageId' => 1, 'pageName' => 'Hello World', 'content' => 'Hello World', 'creator' => 'admin'));
Perms::filter(array('type' => 'wiki page'), 'object', $data, array('object' => 'pageName', 'creator' => 'creator'), 'view');
}
示例14: forums_ranking_last_posts
/**
* @param $limit
* @param bool $toponly
* @param string $forumId
* @return mixed
*/
function forums_ranking_last_posts($limit, $toponly = false, $forumId = '')
{
global $user;
$commentslib = TikiLib::lib('comments');
$offset = 0;
$count = 0;
$ret = array();
$result = $commentslib->get_all_comments('forum', 0, $limit, 'commentDate_desc', '', '', '', $toponly, $forumId);
$result['data'] = Perms::filter(array('type' => 'forum'), 'object', $result['data'], array('object' => 'object'), 'forum_read');
foreach ($result['data'] as $res) {
$aux['name'] = $res['title'];
$aux['title'] = $res['parentTitle'];
$tmp = $res['parentId'];
if ($tmp == 0) {
$tmp = $res['threadId'];
}
$aux['href'] = $res['href'];
$aux['hits'] = $this->get_long_datetime($res['commentDate']);
$tmp = $res['parentId'];
if ($tmp == 0) {
$tmp = $res['threadId'];
}
$aux['date'] = $res['commentDate'];
$aux['user'] = $res['userName'];
$ret[] = $aux;
}
$retval["data"] = $ret;
$retval["title"] = tra("Forums last posts");
$retval["y"] = tra("Topic date");
$retval["type"] = "date";
return $retval;
}
示例15: array
$smarty->assign('daysnames', $daysnames);
$smarty->assign('daysnames_abr', $daysnames_abr);
$smarty->assign('monthnames', $monthnames);
$smarty->assign('edit', false);
$smarty->assign('recurrent', '');
$hour_minmax = '';
$recurrence = array('id' => '', 'weekly' => '', 'weekday' => '', 'monthly' => '', 'dayOfMonth' => '', 'yearly' => '', 'dateOfYear_day' => '', 'dateOfYear_month' => '', 'startPeriod' => '', 'nbRecurrences' => '', 'endPeriod' => '');
$smarty->assign('recurrence', $recurrence);
$caladd = array();
$rawcals = $calendarlib->list_calendars();
if ($rawcals['cant'] == 0 && $tiki_p_admin_calendar == 'y') {
$smarty->assign('msg', tra('You need to <a href="tiki-admin_calendars.php?cookietab=2">create a calendar</a>'));
$smarty->display("error.tpl");
die;
}
$rawcals['data'] = Perms::filter(array('type' => 'calendar'), 'object', $rawcals['data'], array('object' => 'calendarId'), 'view_calendar');
foreach ($rawcals["data"] as $cal_data) {
$cal_id = $cal_data['calendarId'];
$calperms = Perms::get(array('type' => 'calendar', 'object' => $cal_id));
if ($cal_data["personal"] == "y") {
if ($user) {
$cal_data["tiki_p_view_calendar"] = 'y';
$cal_data["tiki_p_view_events"] = 'y';
$cal_data["tiki_p_add_events"] = 'y';
$cal_data["tiki_p_change_events"] = 'y';
} else {
$cal_data["tiki_p_view_calendar"] = 'n';
$cal_data["tiki_p_view_events"] = 'y';
$cal_data["tiki_p_add_events"] = 'n';
$cal_data["tiki_p_change_events"] = 'n';
}