本文整理汇总了PHP中sesskey函数的典型用法代码示例。如果您正苦于以下问题:PHP sesskey函数的具体用法?PHP sesskey怎么用?PHP sesskey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sesskey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_replacements
/**
*
*/
public function get_replacements(array $patterns, $entry = null, array $options = array())
{
global $CFG, $OUTPUT;
$replacements = parent::get_replacements($patterns, $entry, $options);
$view = $this->_view;
$df = $view->get_df();
$filter = $view->get_filter();
$baseurl = new moodle_url($view->get_baseurl());
$baseurl->param('sesskey', sesskey());
foreach ($patterns as $pattern) {
switch ($pattern) {
case '##exportall##':
$actionurl = new moodle_url($baseurl, array('pdfexportall' => true));
$label = html_writer::tag('span', get_string('exportall', 'dataformview_pdf'));
$replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportall'));
break;
case '##exportpage##':
$actionurl = new moodle_url($baseurl, array('pdfexportpage' => true));
$label = html_writer::tag('span', get_string('exportpage', 'dataformview_pdf'));
$replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportpage'));
break;
case '##pagebreak##':
$replacements[$pattern] = $view::PAGE_BREAK;
break;
}
}
return $replacements;
}
示例2: local_loginas_extends_settings_navigation
/**
* Adds module specific settings to the settings block.
*
* @param settings_navigation $settings The settings navigation object
* @param stdClass $context The node context
*/
function local_loginas_extends_settings_navigation(settings_navigation $settings, $context)
{
global $DB, $CFG, $PAGE, $USER;
// Course id and context.
$courseid = !empty($PAGE->course->id) ? $PAGE->course->id : SITEID;
$coursecontext = context_course::instance($courseid);
// Must have the loginas capability.
if (!has_capability('moodle/user:loginas', $coursecontext)) {
return;
}
// Set the settings category.
$loginas = $settings->add(get_string('loginas'));
// Login as list by admin setting.
if (is_siteadmin($USER)) {
// Admin settings page.
$url = new moodle_url('/admin/settings.php', array('section' => 'localsettingloginas'));
$loginas->add(get_string('settings'), $url, $settings::TYPE_SETTING);
// Users list.
$loginasusers = array();
// Since 2.6, use all the required fields.
$ufields = 'id, ' . get_all_user_name_fields(true);
// Get users by id.
if ($configuserids = get_config('local_loginas', 'loginasusers')) {
$userids = explode(',', $configuserids);
if ($users = $DB->get_records_list('user', 'id', $userids, '', $ufields)) {
$loginasusers = $users;
}
}
// Get users by username.
if ($configusernames = get_config('local_loginas', 'loginasusernames')) {
$usernames = explode(',', $configusernames);
if ($users = $DB->get_records_list('user', 'username', $usernames, '', $ufields)) {
$loginasusers = $loginasusers + $users;
}
}
// Add action links for specified users.
if ($loginasusers) {
$params = array('id' => $courseid, 'sesskey' => sesskey());
foreach ($loginasusers as $userid => $lauser) {
$url = new moodle_url('/course/loginas.php', $params);
$url->param('user', $userid);
$loginas->add(fullname($lauser, true), $url, $settings::TYPE_SETTING);
}
}
}
// Course users login as.
if (!($configcourseusers = get_config('local_loginas', 'courseusers'))) {
return;
}
$loggedinas = \core\session\manager::is_loggedinas();
if (!$loggedinas) {
// Ajax link.
$node = $loginas->add(get_string('courseusers', 'local_loginas'), 'javascript:void();', $settings::TYPE_SETTING);
$node->add_class('local_loginas_setting_link');
local_loginas_require_js($PAGE);
}
}
示例3: __construct
/**
* Constructor
*
* @param string|moodle_url $pageurl
*/
public function __construct($pageurl)
{
global $OUTPUT;
parent::__construct();
$this->attributes['class'] = 'generaltable tag-areas-table';
$this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag'));
$this->data = array();
$this->rowclasses = array();
$tagareas = core_tag_area::get_areas();
$tagcollections = core_tag_collection::get_collections_menu(true);
$tagcollectionsall = core_tag_collection::get_collections_menu();
foreach ($tagareas as $itemtype => $it) {
foreach ($it as $component => $record) {
$areaname = core_tag_area::display_name($record->component, $record->itemtype);
$baseurl = new moodle_url($pageurl, array('ta' => $record->id, 'sesskey' => sesskey()));
if ($record->enabled) {
$enableurl = new moodle_url($baseurl, array('action' => 'areadisable'));
$enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/hide', get_string('disable')));
} else {
$enableurl = new moodle_url($baseurl, array('action' => 'areaenable'));
$enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/show', get_string('enable')));
}
if ($record->enabled && empty($record->locked) && count($tagcollections) > 1) {
$changecollurl = new moodle_url($baseurl, array('action' => 'areasetcoll'));
$select = new single_select($changecollurl, 'areacollid', $tagcollections, $record->tagcollid, null);
$select->set_label(get_string('changetagcoll', 'core_tag', $areaname), array('class' => 'accesshide'));
$collectionselect = $OUTPUT->render($select);
} else {
$collectionselect = $tagcollectionsall[$record->tagcollid];
}
$this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect);
$this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
}
}
}
示例4: get_button
/**
* Convenience function for subclasses. Returns HTML code suitable to
* use for a button in this area.
* @param mod_forumng_discussion $discussion
* @param string $name Text of button
* @param string $script Name/path of .php script (relative to mod/forumng)
* @param bool $post If true, makes the button send a POST request
* @param array $options If included, passes these options as well as 'd'
* @param string $extrahtml If specified, adds this HTML at end of (just
* inside) the form
* @param bool $highlight If true, adds a highlight class to the form
* @param bool $selector If true, adds a selector class to the form (indicating that the
* JavaScript post selector should be used)
* @return string HTML code for button
*/
protected static function get_button($discussion, $name, $script, $post = false, $options = array(), $extrahtml = '', $highlight = false, $selector = false)
{
$method = $post ? 'post' : 'get';
$optionshtml = '';
$options['d'] = $discussion->get_id();
if ($discussion->get_forum()->is_shared()) {
$options['clone'] = $discussion->get_forum()->get_course_module_id();
}
if ($post) {
$options['sesskey'] = sesskey();
}
foreach ($options as $key => $value) {
$optionshtml .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
$class = '';
if ($highlight) {
$class = 'forumng-highlight';
}
if ($selector) {
$class .= ' forumng-selectorbutton';
}
if ($class !== '') {
$class = ' class="' . trim($class) . '"';
}
return "<form method='{$method}' action='{$script}' {$class}><div>" . "{$optionshtml}<input type='submit' value='{$name}' />" . "{$extrahtml}</div></form>";
}
示例5: export_for_template
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
global $CFG;
require_once $CFG->libdir . '/externallib.php';
$r = new stdClass();
$r->id = (int) $this->record->id;
$r->tagcollid = clean_param($this->record->tagcollid, PARAM_INT);
$r->rawname = clean_param($this->record->rawname, PARAM_TAG);
$r->name = clean_param($this->record->name, PARAM_TAG);
$format = clean_param($this->record->descriptionformat, PARAM_INT);
list($r->description, $r->descriptionformat) = external_format_text($this->record->description, $format, \context_system::instance()->id, 'core', 'tag', $r->id);
$r->flag = clean_param($this->record->flag, PARAM_INT);
if (isset($this->record->isstandard)) {
$r->isstandard = clean_param($this->record->isstandard, PARAM_INT) ? 1 : 0;
}
$r->official = $r->isstandard;
// For backwards compatibility.
$url = core_tag_tag::make_url($r->tagcollid, $r->rawname);
$r->viewurl = $url->out(false);
$manageurl = new moodle_url('/tag/manage.php', array('sesskey' => sesskey(), 'tagid' => $this->record->id));
$url = new moodle_url($manageurl);
$url->param('action', 'changetype');
$url->param('isstandard', $r->isstandard ? 0 : 1);
$r->changetypeurl = $url->out(false);
$url = new moodle_url($manageurl);
$url->param('action', $this->record->flag ? 'resetflag' : 'setflag');
$r->changeflagurl = $url->out(false);
return $r;
}
示例6: ilp_moodleform
/**
* This is identical to the overridden function except that it calls ilp_MoodleQuickForm instead
* of MoodleQuickForm
* @param <type> $action
* @param <type> $customdata
* @param <type> $method
* @param <type> $target
* @param <type> $attributes
* @param <type> $editable
*/
function ilp_moodleform($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true)
{
if (empty($action)) {
$action = strip_querystring(qualified_me());
}
$this->_formname = get_class($this);
// '_form' suffix kept in order to prevent collisions of form id and other element
$this->_customdata = $customdata;
$this->_form =& new ilp_MoodleQuickForm($this->_formname, $method, $action, $target, $attributes);
if (!$editable) {
$this->_form->hardFreeze();
}
//TODO find a way to emulate moodle 2 functionality in 1.9 and check if file manager
//$this->set_upload_manager(new upload_manager());
$this->definition();
$this->_form->addElement('hidden', 'sesskey', null);
// automatic sesskey protection
$this->_form->setType('sesskey', PARAM_RAW);
$this->_form->setDefault('sesskey', sesskey());
$this->_form->addElement('hidden', '_qf__' . $this->_formname, null);
// form submission marker
$this->_form->setType('_qf__' . $this->_formname, PARAM_RAW);
$this->_form->setDefault('_qf__' . $this->_formname, 1);
$this->_form->_setDefaultRuleMessages();
// we have to know all input types before processing submission ;-)
$this->_process_submission($method);
}
示例7: definition
public function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext'];
$attforsession = $this->_customdata['session'];
$attblock = $this->_customdata['attendance'];
$statuses = $attblock->get_statuses();
$mform->addElement('hidden', 'sessid', null);
$mform->setType('sessid', PARAM_INT);
$mform->setConstant('sessid', $attforsession->id);
$mform->addElement('hidden', 'sesskey', null);
$mform->setType('sesskey', PARAM_INT);
$mform->setConstant('sesskey', sesskey());
// Set a title as the date and time of the session.
$sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')) . ' ' . userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attendance'));
$mform->addElement('header', 'session', $sesstiontitle);
// If a session description is set display it.
if (!empty($attforsession->description)) {
$mform->addElement('html', $attforsession->description);
}
// Create radio buttons for setting the attendance status.
$radioarray = array();
foreach ($statuses as $status) {
$radioarray[] =& $mform->createElement('radio', 'status', '', $status->description, $status->id, array());
}
// Add the radio buttons as a control with the user's name in front.
$mform->addGroup($radioarray, 'statusarray', $USER->firstname . ' ' . $USER->lastname . ':', array(''), false);
$mform->addRule('statusarray', get_string('attendancenotset', 'attendance'), 'required', '', 'client', false, false);
$this->add_action_buttons();
}
示例8: __construct
/**
* course_action_section_highlight constructor.
* @param stdClass $course
* @param stdClass $section - Note this is the section we want to affect via the url param.
* @param bool $onsectionpage
*/
public function __construct($course, $section, $onsectionpage = false)
{
if ($onsectionpage) {
$baseurl = course_get_url($course, $section->section);
} else {
$baseurl = course_get_url($course);
}
$baseurl->param('sesskey', sesskey());
$coursecontext = context_course::instance($course->id);
$isstealth = isset($course->numsections) && $section->section > $course->numsections;
if ($course->format === 'topics') {
if (!$isstealth && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
$url = clone $baseurl;
$marker = optional_param('marker', '', PARAM_INT);
$marker = $marker === '' ? $course->marker : $marker;
// Note if the new target section is 0 then it means the requested action is to have no current section
// highlighted.
if ($marker == $section->section || $section->section === 0) {
// Show the lightbulb.
$this->title = get_string('markedthistopic');
$url->param('marker', 0);
$this->url = $url;
$this->class .= ' snap-marked';
} else {
$this->title = get_string('markthistopic');
$url->param('marker', $section->section);
$this->url = $url;
$this->class .= ' snap-marker';
}
}
}
}
示例9: section_edit_controls
/**
* Generate the edit controls of a section
*
* @param stdClass $course The course entry from DB
* @param stdClass $section The course_section entry from DB
* @param bool $onsectionpage true if being printed on a section page
* @return array of links with edit controls
*/
protected function section_edit_controls($course, $section, $onsectionpage = false)
{
global $PAGE;
if (!$PAGE->user_is_editing()) {
return array();
}
if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
return array();
}
if ($onsectionpage) {
$url = course_get_url($course, $section->section);
} else {
$url = course_get_url($course);
}
$url->param('sesskey', sesskey());
$controls = array();
if ($course->marker == $section->section) {
// Show the "light globe" on/off.
$url->param('marker', 0);
$controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 'class' => 'icon ', 'alt' => get_string('markedthistopic'))), array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight'));
} else {
$url->param('marker', $section->section);
$controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 'class' => 'icon', 'alt' => get_string('markthistopic'))), array('title' => get_string('markthistopic'), 'class' => 'editing_highlight'));
}
return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage));
}
示例10: subscriber_selection_form
/**
* This method is used to generate HTML for a subscriber selection form that
* uses two user_selector controls
*
* @param user_selector_base $existinguc
* @param user_selector_base $potentialuc
* @return string
*/
public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc)
{
$output = '';
$formattributes = array();
$formattributes['id'] = 'subscriberform';
$formattributes['action'] = '';
$formattributes['method'] = 'post';
$output .= html_writer::start_tag('form', $formattributes);
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
$existingcell = new html_table_cell();
$existingcell->text = $existinguc->display(true);
$existingcell->attributes['class'] = 'existing';
$actioncell = new html_table_cell();
$actioncell->text = html_writer::start_tag('div', array());
$actioncell->text .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'subscribe', 'value' => $this->page->theme->larrow . ' ' . get_string('add'), 'class' => 'actionbutton'));
$actioncell->text .= html_writer::empty_tag('br', array());
$actioncell->text .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'unsubscribe', 'value' => $this->page->theme->rarrow . ' ' . get_string('remove'), 'class' => 'actionbutton'));
$actioncell->text .= html_writer::end_tag('div', array());
$actioncell->attributes['class'] = 'actions';
$potentialcell = new html_table_cell();
$potentialcell->text = $potentialuc->display(true);
$potentialcell->attributes['class'] = 'potential';
$table = new html_table();
$table->attributes['class'] = 'subscribertable boxaligncenter';
$table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell)));
$output .= html_writer::table($table);
$output .= html_writer::end_tag('form');
return $output;
}
示例11: user_rss_token_box
/**
* Display user tokens with buttons to reset them
* @param object $tokens
* @param int $userid
* @return string html code
*/
public function user_rss_token_box($token) {
global $OUTPUT, $CFG;
// display strings
$stroperation = get_string('operation', 'webservice');
$strtoken = get_string('key', 'webservice');
$return = $OUTPUT->heading(get_string('rss'), 3, 'main', true);
$return .= $OUTPUT->box_start('generalbox webservicestokenui');
$return .= get_string('rsskeyshelp');
$table = new html_table();
$table->head = array($strtoken, $stroperation);
$table->align = array('left', 'center');
$table->width = '100%';
$table->data = array();
if (!empty($token)) {
$reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey().
"&action=resetrsstoken\">".get_string('reset')."</a>";
$table->data[] = array($token, $reset);
$return .= html_writer::table($table);
} else {
$return .= get_string('notoken', 'webservice');
}
$return .= $OUTPUT->box_end();
return $return;
}
示例12: config_form_criteria
/**
* Add appropriate form elements to the criteria form
*
* @param stdClass $data details of overall criterion
*/
public function config_form_criteria($data)
{
global $OUTPUT;
$prefix = 'criteria-' . $this->id;
if (count($data->criteria) > 2) {
echo $OUTPUT->box_start();
if (!empty($this->description)) {
$badge = new badge($this->badgeid);
echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
}
echo $OUTPUT->heading($this->get_title(), 2);
$agg = $data->get_aggregation_methods();
if (!$data->is_locked() && !$data->is_active()) {
$editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id));
$editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action'));
echo $OUTPUT->box($editaction, array('criteria-header'));
$url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey()));
echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null, null, array('aria-describedby' => 'overall'));
echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall'));
} else {
echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix');
}
echo $OUTPUT->box_end();
}
}
示例13: export_for_template
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
global $CFG;
require_once $CFG->libdir . '/externallib.php';
$r = new stdClass();
$r->id = (int) $this->record->id;
$r->rawname = clean_param($this->record->rawname, PARAM_TAG);
$r->name = clean_param($this->record->name, PARAM_TAG);
$format = clean_param($this->record->descriptionformat, PARAM_INT);
list($r->description, $r->descriptionformat) = external_format_text($this->record->description, $format, \context_system::instance()->id, 'core', 'tag', $r->id);
$r->flag = clean_param($this->record->flag, PARAM_INT);
if (isset($this->record->official)) {
$r->official = clean_param($this->record->official, PARAM_INT);
} else {
$r->official = $this->record->tagtype === 'official' ? 1 : 0;
}
$url = new moodle_url('/tag/index.php', array('id' => $this->record->id));
$r->viewurl = $url->out(false);
$manageurl = new moodle_url('/tag/manage.php', array('sesskey' => sesskey(), 'tagid' => $this->record->id));
$url = new moodle_url($manageurl);
$url->param('action', 'changetype');
$url->param('tagtype', $r->official ? 'default' : 'official');
$r->changetypeurl = $url->out(false);
$url = new moodle_url($manageurl);
$url->param('action', $this->record->flag ? 'resetflag' : 'setflag');
$r->changeflagurl = $url->out(false);
return $r;
}
示例14: prevent_double_paid
function prevent_double_paid($plugininstance)
{
global $CFG, $SESSION, $USER, $DB;
$plugin = enrol_get_plugin('authorize');
$sql = "SELECT id FROM {enrol_authorize} WHERE userid = ? AND courseid = ? AND instanceid = ?";
$params = array($USER->id, $plugininstance->courseid, $plugininstance->id);
if (!$plugin->get_config('an_test')) {
// Real mode
$sql .= ' AND status IN(?,?,?)';
$params[] = AN_STATUS_AUTH;
$params[] = AN_STATUS_UNDERREVIEW;
$params[] = AN_STATUS_APPROVEDREVIEW;
} else {
// Test mode
$sql .= ' AND status=?';
$params[] = AN_STATUS_NONE;
}
if ($recid = $DB->get_field_sql($sql, $params)) {
$a = new stdClass();
$a->orderid = $recid;
$a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$a->orderid}";
redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
return;
}
if (isset($SESSION->ccpaid)) {
unset($SESSION->ccpaid);
redirect($CFG->wwwroot . '/login/logout.php?sesskey=' . sesskey());
return;
}
}
示例15: definition
/**
* Defines the elements of the form used to mark a quiz submission.
*/
public function definition()
{
global $OUTPUT;
$mform =& $this->_form;
$mform->addElement('hidden', 'attemptid');
$mform->setType('attemptid', PARAM_INT);
$mform->addElement('hidden', 'questionid');
$mform->setType('questionid', PARAM_INT);
$mform->addElement('hidden', 'sesskey', sesskey());
$mform->setType('sesskey', PARAM_ALPHANUM);
$mform->addElement('static', 'picture', $OUTPUT->user_picture($this->_customdata->user), fullname($this->_customdata->user, true) . '<br/>' . userdate($this->_customdata->submission->timemodified) . $this->_customdata->lateness);
// Now come multiple (possibly) question comment fields.
// Use $attemptobj->get_questions($arrayofquestionis) for this.
foreach ($this->_customdata->questions as $questionid => $question) {
$mform->addElement('header', 'question' . $questionid, get_string('question', 'modulename'));
// Display question text.
// Display user's answer.
// Display comment form.
$mform->addElement('editor', 'comment[' . $questionid . ']', get_string('comment', 'quiz') . ':', null, $this->get_editor_options());
// Display grade selector.
$grademenu = make_grades_menu($question->grade);
$grademenu['-1'] = get_string('nograde');
// TODO broken!
$attributes = array();
$mform->addElement('select', 'grade[' . $questionid . ']', get_string('grade') . ':', $grademenu, $attributes);
// TODO set default to existing grade?
$mform->setDefault('grade[' . $questionid . ']', -1);
}
}