本文整理汇总了PHP中Perms::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Perms::get方法的具体用法?PHP Perms::get怎么用?PHP Perms::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Perms
的用法示例。
在下文中一共展示了Perms::get方法的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: 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);
}
}
}
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$confirm = $input->getOption('confirm');
$perms = \Perms::get();
if (!$perms->admin_file_galleries) {
throw new \Exception('Tracker Clear: Admin permission required');
}
if ($confirm) {
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
$output->writeln('<info>Deleting old filegal files...</info>');
}
\TikiLib::lib('filegal')->deleteOldFiles();
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
$output->writeln('<info>Deleting old filegal files done</info>');
}
} else {
$query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
$now = time();
$files = \TikiDb::get()->query($query, array($now));
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
if ($files->numrows) {
$output->writeln("<comment>Files to delete:</comment>");
foreach ($files->result as $file) {
$old = ceil(abs($now - $file['lastModif']) / 86400);
$days = $old > 1 ? 'days' : 'day';
$deleteAfter = \TikiLib::lib('tiki')->get_short_datetime($file['deleteAfter']);
$output->writeln("<info> \"{$file['name']}\" is {$old} {$days} old in gallery #{$file['galleryId']} (id #{$file['fileId']} deleteAfter {$deleteAfter})</info>");
}
} else {
$output->writeln("<comment>No files to delete</comment>");
}
}
}
}
示例4: 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;
}
示例5: 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);
}
}
示例6: 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.'));
}
}
示例7: 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);
}
示例8: 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));
}
}
示例9: 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);
}
}
}
示例10: 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);
}
示例11: setUp
function setUp()
{
if (!Perms::get()->admin) {
throw new Services_Exception(tr('Permission Denied'), 403);
}
$this->lib = TikiLib::lib('activity');
}
示例12: triggerTransition
/**
* @param $transitionId
* @param $object
* @param null $type
* @return bool
*/
function triggerTransition($transitionId, $object, $type = null)
{
// Make sure the transition exists
if (!($transition = $this->getTransition($transitionId))) {
return false;
}
// Make sure the user can use it
$perms = Perms::get(array('type' => 'transition', 'object' => $transitionId));
if (!$perms->trigger_transition) {
return false;
}
// Verify that the states are consistent
$states = $this->getCurrentStates($object, $type);
$tr = new Tiki_Transition($transition['from'], $transition['to']);
$tr->setStates($states);
foreach ($transition['guards'] as $guard) {
call_user_func_array(array($tr, 'addGuard'), $guard);
}
if (!$tr->isReady()) {
return false;
}
$this->addState($transition['to'], $object, $type);
if (!$transition['preserve']) {
$this->removeState($transition['from'], $object, $type);
}
return true;
}
示例13: checkObject
public static function checkObject($perm, $type, $object)
{
$perms = Perms::get($type, $object);
if (!$perms->{$perm}) {
throw new self(tr('Permission denied'));
}
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Importing tracker...');
$lib = \TikiLib::lib('tabular');
$info = $lib->getInfo($input->getArgument('tabularId'));
$perms = \Perms::get('tabular', $info['tabularId']);
if (!$info || !$perms->tabular_import) {
throw new \Exception('Tracker Import: Tabular Format not found');
}
$fileName = $input->getArgument('filename');
if (!file_exists($fileName)) {
throw new \Exception('Tracker Import: File not found');
}
// from \Services_Tracker_TabularController::getSchema TODO refactor?
$tracker = \Tracker_Definition::get($info['trackerId']);
if (!$tracker) {
throw new \Exception('Tracker Import: Tracker not found');
}
$schema = new \Tracker\Tabular\Schema($tracker);
$schema->loadFormatDescriptor($info['format_descriptor']);
$schema->loadFilterDescriptor($info['filter_descriptor']);
$schema->validate();
if (!$schema->getPrimaryKey()) {
throw new \Exception(tr('Primary Key required'));
}
// this will throw exceptions and not return if there's a problem
$source = new \Tracker\Tabular\Source\CsvSource($schema, $fileName);
$writer = new \Tracker\Tabular\Writer\TrackerWriter();
$writer->write($source);
$output->writeln('Import done');
return 0;
}
示例15: 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()]]);
}