本文整理汇总了PHP中Perms类的典型用法代码示例。如果您正苦于以下问题:PHP Perms类的具体用法?PHP Perms怎么用?PHP Perms使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Perms类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleSave
function handleSave($value, $oldValue)
{
global $prefs, $user;
$tikilib = TikiLib::lib('tiki');
$trackerId = $this->getConfiguration('trackerId');
$file_name = $this->getConfiguration('file_name');
$file_size = $this->getConfiguration('file_size');
$file_type = $this->getConfiguration('file_type');
$perms = Perms::get('tracker', $trackerId);
if ($perms->attach_trackers && $file_name) {
if ($prefs['t_use_db'] == 'n') {
$fhash = md5($file_name . $tikilib->now);
if (file_put_contents($prefs['t_use_dir'] . $fhash, $value) === false) {
$smarty = TikiLib::lib('smarty');
$smarty->assign('msg', tra('Cannot write to this file:') . $fhash);
$smarty->display("error.tpl");
die;
}
$value = '';
} else {
$fhash = 0;
}
$trklib = TikiLib::lib('trk');
$value = $trklib->replace_item_attachment($oldValue, $file_name, $file_type, $file_size, $value, '', $user, $fhash, '', '', $trackerId, $this->getItemId(), '', false);
}
return array('value' => $value);
}
示例2: perms
public function perms()
{
if ($this->requiresPermission('manage roles', $this->name)) {
Fabriq::title('Admin | Manage permissions');
FabriqModules::add_css('roles', 'roles');
$perms = new Perms();
$perms->getAll();
$modules = new Modules();
$modules->getEnabled();
$roles = FabriqModules::new_model('roles', 'Roles');
$roles->getRoles();
$modulePerms = FabriqModules::new_model('roles', 'ModulePerms');
$modulePerms->getAll();
$permissions = array();
foreach ($perms as $perm) {
$permissions[$perm->id] = array();
foreach ($roles as $role) {
if (isset($modulePerms->perms[$perm->id][$role->id])) {
$permissions[$perm->id][$role->id] = 1;
} else {
$permissions[$perm->id][$role->id] = 0;
}
}
}
if (isset($_POST['submit'])) {
foreach ($perms as $perm) {
foreach ($roles as $role) {
if (isset($_POST['permission'][$perm->id][$role->id])) {
$permissions[$perm->id][$role->id] = 1;
// add to database if it's not already set
if (!isset($modulePerms->perms[$perm->id][$role->id])) {
$p = FabriqModules::new_model('roles', 'ModulePerms');
$p->permission = $perm->id;
$p->role = $role->id;
$p->id = $p->create();
$modulePerms->perms[$perm->id][$role->id] = $modulePerms->count();
$modulePerms->add($p);
}
} else {
$permissions[$perm->id][$role->id] = 0;
// remove from database if it is already set
if (isset($modulePerms->perms[$perm->id][$role->id])) {
$p = FabriqModules::new_model('roles', 'ModulePerms');
$p->find($modulePerms[$modulePerms->perms[$perm->id][$role->id]]->id);
$p->destroy();
$modulePerms->remove($modulePerms->perms[$perm->id][$role->id]);
$modulePerms->reindex();
}
}
}
}
Messaging::message('Permissions have been updated.', 'success');
}
FabriqModules::set_var($this->name, 'perms', $perms);
FabriqModules::set_var($this->name, 'modules', $modules);
FabriqModules::set_var($this->name, 'roles', $roles);
FabriqModules::set_var($this->name, 'permissions', $permissions);
}
}
示例3: setUp
function setUp()
{
$perms = new Perms();
$perms->setCheckSequence(array($this->globalAlternate = new Perms_Check_Alternate('admin'), new Perms_Check_Direct()));
$perms->setResolverFactories(array(new Perms_ResolverFactory_StaticFactory('global', new Perms_Resolver_Static(array('Anonymous' => array('tiki_p_view'), 'Registered' => array('tiki_p_view', 'tiki_p_topic_read'))))));
$index = new Search_Index_Memory();
$indexer = new Search_Indexer($index);
$this->indexer = $indexer;
$this->index = $index;
$this->perms = $perms;
}
示例4: module_contributors
function module_contributors($mod_reference, $module_params)
{
global $smarty, $userlib, $wikilib, $tikilib, $headerlib;
$currentObject = current_object();
if ($currentObject['type'] == 'wiki page') {
$objectperms = Perms::get(array('type' => 'wiki page', 'object' => $currentObject['object']));
if ($objectperms->view) {
$contributors = $wikilib->get_contributors($currentObject['object']);
$contributors_details = array();
$headerlib->add_css('div.contributors div br {clear: both;}'); // Avoid avatar conflicts with lines below
foreach ($contributors as $contributor) {
$details = array('login' => $contributor);
$details['realName'] = $userlib->get_user_preference($contributor, 'realName');
$country = $tikilib->get_user_preference($contributor, 'country');
if (!is_null($country) && $country != 'Other') {
$details['country'] = $country;
}
$email_isPublic = $tikilib->get_user_preference($contributor, 'email is public');
if ($email_isPublic != 'n') {
include_once ('lib/userprefs/scrambleEmail.php');
$details['email'] = $userlib->get_user_email($contributor);
$details['scrambledEmail'] = scrambleEmail($details['email'], $email_isPublic);
}
$details['homePage'] = $tikilib->get_user_preference($contributor, 'homePage');
$details['avatar'] = $tikilib->get_user_avatar($contributor);
$contributors_details[] = $details;
}
$smarty->assign_by_ref('contributors_details', $contributors_details);
$hiddenContributors = count($contributors_details) - 5;
if ($hiddenContributors > 0) {
$smarty->assign('hiddenContributors', $hiddenContributors);
}
}
}
}
示例5: 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;
}
示例6: smarty_function_permission_link
/**
* Generates a link to the object permission screen, and verifies if there are
* active permissions to render the link differently as required.
*
* Important parameters: type and id, for the target object - otherwise global
* permType, if different from type
* title, the name of the object
*
* Almost mandatory: mode, display style of the button
* glyph: simple fa (Font Awesome)
* icon: classic tiki icon
* link: plain text link (label)
* text: glyph + label
* button: button with label
* button_link: button with label (btn-link)
*
* Occasional: label, alter the displayed text from default
group, parameter to objectpermissions
textFilter, parameter to objectpermissions
showDisabled, parameter to objectpermissions
addclass: add classes separated by spaces
*/
function smarty_function_permission_link($params, $smarty)
{
$params = new JitFilter($params);
$type = $params->type->text();
$id = $params->id->text();
$objectlib = TikiLib::lib('object');
if (isset($params['type'], $params['id'])) {
$arguments = ['objectType' => $type, 'objectId' => $id, 'permType' => $type, 'objectName' => $params->title->text() ?: $objectlib->get_title($type, $id)];
} else {
$arguments = [];
}
if ($params->permType->text()) {
$arguments['permType'] = $params->permType->text();
}
if ($params->textFilter->text()) {
$arguments['textFilter'] = $params->textFilter->text();
}
if ($params->group->groupname()) {
$arguments['group'] = $params->group->groupname();
}
if ($params->showDisabled->word() == 'y') {
$arguments['show_disabled_features'] = 'y';
}
if (!empty($arguments)) {
$link = 'tiki-objectpermissions.php?' . http_build_query($arguments, '', '&');
} else {
$link = 'tiki-objectpermissions.php';
}
$perms = Perms::get($type, $id);
$source = $perms->getResolver()->from();
return $smarty->fetch('permission_link.tpl', ['permission_link' => ['url' => $link, 'active' => $source == 'object', 'mode' => $params->mode->word() ?: 'glyph', 'label' => $params->label->text() ?: tr('Permissions'), 'count' => $params->count->int(), 'type' => $type, 'addclass' => $params->addclass->text()]]);
}
示例7: checkObject
public static function checkObject($perm, $type, $object)
{
$perms = Perms::get($type, $object);
if (!$perms->{$perm}) {
throw new self(tr('Permission denied'));
}
}
示例8: wikiplugin_bigbluebutton
function wikiplugin_bigbluebutton($data, $params)
{
try {
global $smarty, $prefs, $user;
$bigbluebuttonlib = TikiLib::lib('bigbluebutton');
$meeting = $params['name'];
// Meeting is more descriptive than name, but parameter name was already decided.
$smarty->assign('bbb_meeting', $meeting);
$smarty->assign('bbb_image', parse_url($prefs['bigbluebutton_server_location'], PHP_URL_SCHEME) . '://' . parse_url($prefs['bigbluebutton_server_location'], PHP_URL_HOST) . '/images/bbb_logo.png');
$perms = Perms::get('bigbluebutton', $meeting);
$params = array_merge(array('prefix' => ''), $params);
// This is incomplete, will only apply if the dynamic feature is enabled. To be completed.
$params['configuration'] = array('presentation' => array('active' => false));
$smarty->assign('bbb_params', Tiki_Security::get()->encode($params));
if (!$bigbluebuttonlib->roomExists($meeting)) {
if (!isset($_POST['bbb']) || $_POST['bbb'] != $meeting || !$perms->bigbluebutton_create) {
$smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl');
}
}
if ($perms->bigbluebutton_join) {
$smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting));
if ($perms->bigbluebutton_view_rec) {
$smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
}
return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl');
} elseif ($perms->bigbluebutton_view_rec) {
# Case for anonymous users with the perm to view recordings but not to join meetings
$smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl');
}
} catch (Exception $e) {
return WikiParser_PluginOutput::internalError(tr('BigBlueButton misconfigured or unaccessible.'));
}
}
示例9: setUp
function setUp()
{
if (!Perms::get()->admin) {
throw new Services_Exception(tr('Permission Denied'), 403);
}
$this->lib = TikiLib::lib('activity');
}
示例10: wikiplugin_transclude
function wikiplugin_transclude( $data, $params )
{
if ( ! isset( $params['page'] ) ) {
return WikiParser_PluginOutput::argumentError(array( 'page' ));
}
$page = $params['page'];
unset($params['page']);
global $tikilib;
if ( ! Perms::get('wiki page', $page)->view ) {
return WikiParser_PluginOutput::error(tra('Permission Denied'), tra('Attempt to include a page that cannot be viewed.'));
}
if ( $info = $tikilib->get_page_info($page) ) {
$parts = preg_split('/%%%text%%%/', $info['data']);
$data = $tikilib->parse_data($data);
$pass = $parts[0] . $data . $parts[1];
return preg_replace_callback(
'/%%%([A-z0-9]+)%%%/',
array( new WikiPlugin_Transclude_Replacer($params), 'callback' ),
$pass
);
} else {
return WikiParser_PluginOutput::error(tr('Page not found'), tr('Page named "%0" does not exist at this time.', $page));
}
}
示例11: module_menupage
/**
* @param $mod_reference
* @param $module_params
*/
function module_menupage($mod_reference, $module_params)
{
if (!empty($module_params['pagemenu'])) {
$wikilib = TikiLib::lib('wiki');
$menulib = TikiLib::lib('menu');
$smarty = TikiLib::lib('smarty');
$pagemenu = $module_params['pagemenu'];
if (!empty($module_params['use_namespace'])) {
$pagemenu = $wikilib->include_default_namespace($pagemenu);
}
$perms = Perms::get(array('object' => $pagemenu, 'type' => 'wiki page'));
if ($perms->view) {
$content = $wikilib->get_parse($pagemenu, $dummy, true);
} else {
$content = '<label class="error">' . tra("You are not logged in") . '</label>';
}
if (!empty($content) && !empty($module_params['menu_type']) && in_array($module_params['menu_type'], array('horiz', 'vert'))) {
$class = 'cssmenu_' . $module_params['menu_type'];
$content = preg_replace_callback('/<(ul|ol|li)([^>]*)>/Umi', function ($matches) use($class) {
if ($matches[1] == 'li') {
$class = 'menuSection';
}
return "<{$matches[1]} class=\"{$class}\" {$matches[2]}>";
}, $content);
$content = $menulib->clean_menu_html($content);
}
$smarty->assign('tpl_module_title', $wikilib->get_without_namespace($pagemenu));
$smarty->assign_by_ref('contentmenu', $content);
}
}
示例12: list_quizzes
/**
* @param $offset
* @param $maxRecords
* @param string $sort_mode
* @param null $find
* @return array
*/
public function list_quizzes($offset, $maxRecords, $sort_mode = 'name_desc', $find = null)
{
$quizzes = $this->table('tiki_quizzes');
$conditions = array();
if (!empty($find)) {
$findesc = '%' . $find . '%';
$conditions['search'] = $quizzes->expr('(`name` like ? or `description` like ?)', array($findesc, $findesc));
}
$result = $quizzes->fetchColumn('quizId', $conditions);
$res = $ret = $retids = array();
$n = 0;
//FIXME Perm:filter ?
foreach ($result as $res) {
$objperm = Perms::get('quizzes', $res);
if ($objperm->take_quiz) {
if ($maxRecords == -1 || $n >= $offset && $n < $offset + $maxRecords) {
$retids[] = $res;
}
$n++;
}
}
if ($n > 0) {
$result = $quizzes->fetchAll($quizzes->all(), array('quizId' => $quizzes->in($retids)), -1, -1, $quizzes->expr($this->convertSortMode($sort_mode)));
$questions = $this->table('tiki_quiz_questions');
$results = $this->table('tiki_quiz_results');
foreach ($result as $res) {
$res['questions'] = $questions->fetchCount(array('quizId' => (int) $res['quizId']));
$res['results'] = $results->fetchCount(array('quizId' => (int) $res['quizId']));
$ret[] = $res;
}
}
return array('data' => $ret, 'cant' => $n);
}
示例13: module_last_category_objects
function module_last_category_objects($mod_reference, $module_params)
{
global $smarty;
if (!isset($module_params['type'])) {
$module_params['type'] = 'wiki page';
}
if ($module_params['type'] == '*') {
$module_params['type'] = '';
}
global $categlib;
require_once ('lib/categories/categlib.php');
$last = $categlib->last_category_objects($module_params['id'], $mod_reference['rows'], $module_params['type']);
$categperms = Perms::get(array('type' => 'category', 'object' => $module_params['id']));
$jail = $categlib->get_jail();
$smarty->assign(
'mod_can_view',
$categperms->view_category && (empty($jail) || in_array($module_params['id'], $jail))
);
if (!is_array($last) or !is_array($last['data'])) {
$last['data'][]['name'] = tra('no object here yet');
}
$smarty->assign('last', $last['data']);
$smarty->assign('type', $module_params['type']);
$smarty->assign('maxlen', isset($module_params['maxlen']) ? $module_params['maxlen'] : 0);
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Clearing tracker...</info>');
$trackerId = $input->getArgument('trackerId');
$tracker = \Tracker_Definition::get($trackerId);
if (!$tracker) {
throw new \Exception('Tracker Clear: Tracker not found');
}
$perms = \Perms::get('tracker', $trackerId);
if (!$perms->admin_trackers) {
throw new \Exception('Tracker Clear: Admin permission required');
}
$confirm = $input->getOption('confirm');
$utilities = new \Services_Tracker_Utilities();
if ($confirm) {
$utilities->clearTracker($trackerId);
$output->writeln('<info>Tracker clear done</info>');
} else {
$name = $tracker->getConfiguration('name');
$output->writeln("<info>Use the --confirm option to proceed with the clear operation.</info>");
$output->writeln("<info> There is NO undo and no notifications will be sent.</info>");
$output->writeln("<info> All items in tracker #{$trackerId} \"{$name}\" will be deleted.</info>");
}
return 0;
}
示例15: module_freetags_current
function module_freetags_current($mod_reference, $module_params)
{
global $user, $page, $smarty;
global $freetaglib;
include_once 'lib/freetag/freetaglib.php';
$objectperms = Perms::get(array('type' => 'wiki page', 'object' => $page));
if (! empty($page) && $objectperms->view) {
if ($objectperms->edit && $objectperms->freetags_tag) {
if (isset($_POST['mod_add_tags'])) {
$freetaglib->tag_object($user, $page, 'wiki page', $_POST['tags']);
header("Location: {$_SERVER['REQUEST_URI']}");
exit;
}
$smarty->assign('addFreetags', "y");
$canTag = true;
} else {
$canTag = false;
}
$smarty->assign('tpl_module_title', tra('Freetags'));
$currenttags = $freetaglib->get_tags_on_object($page, 'wiki page');
if (count($currenttags['data']) || $canTag) {
$smarty->assign('modFreetagsCurrent', $currenttags);
}
}
}