/**
  *
  */
 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;
 }
Example #2
1
/**
 * 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);
    }
}
Example #3
0
 /**
  * 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';
         }
     }
 }
 /**
  * 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>";
 }
Example #5
0
 /**
  * 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;
 }
 /**
  * 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);
 }
 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();
 }
 /**
  * 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';
             }
         }
     }
 }
 /**
  * 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));
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
    /**
     * 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().
                    "&amp;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;
    }
Example #12
0
 /**
  * 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();
     }
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
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;
    }
}
 /**
  * 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);
     }
 }
Example #16
0
        /**
     * The standard tags (typically performance information and validation links,
     * if we are in developer debug mode) that should be output in the footer area
     * of the page. Designed to be called in theme layout.php files.
     * @return string HTML fragment.
     */
    public function standard_footer_html() {
        global $CFG;

        // This function is normally called from a layout.php file in {@link header()}
        // but some of the content won't be known until later, so we return a placeholder
        // for now. This will be replaced with the real content in {@link footer()}.
        $output = self::PERFORMANCE_INFO_TOKEN;
        // Moodle 2.1 uses a magic accessor for $this->page->devicetypeinuse so we need to
        // check for the existence of the function that uses as
        // isset($this->page->devicetypeinuse) returns false
        if (function_exists('get_user_device_type')?($this->page->devicetypeinuse=='legacy'):$this->page->legacythemeinuse) {
            // The legacy theme is in use print the notification
            $output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse'));
        }
       // if (!empty($CFG->debugpageinfo)) {
       //     $output .= '<div class="performanceinfo">This page is: ' . $this->page->debug_summary() . '</div>';
       // }
        if (debugging(null, DEBUG_DEVELOPER)) {  // Only in developer mode
            $output .= '<div class="purgecaches"><a href="'.$CFG->wwwroot.'/admin/purgecaches.php?confirm=1&amp;sesskey='.sesskey().'">'.get_string('purgecaches', 'admin').'</a></div>';
        }
        if (!empty($CFG->debugvalidators)) {
            $output .= '<div class="validators"><ul>
              <li><a href="http://validator.w3.org/check?verbose=1&amp;ss=1&amp;uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li>
              <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&amp;url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li>
              <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&amp;warnp2n3e=1&amp;url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li>
            </ul></div>';
        }
        return $output;
    }
 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;
     $url = clone $baseurl;
     if (!$isstealth && has_capability('moodle/course:sectionvisibility', $coursecontext)) {
         if ($section->visible) {
             // Show the hide/show eye.
             $this->title = get_string('hidefromothers', 'format_' . $course->format);
             $url->param('hide', $section->section);
             $this->url = $url;
             $this->class .= ' snap-hide';
         } else {
             $this->title = get_string('showfromothers', 'format_' . $course->format);
             $url->param('show', $section->section);
             $this->url = $url;
             $this->class .= ' snap-show';
         }
     }
 }
 /**
  * Define this form - called from the parent constructor.
  */
 public function definition()
 {
     global $CFG;
     global $USER;
     global $DB;
     $deletebuturl = $CFG->wwwroot . "/blocks/eexcess/delete_interests_from_db.php";
     $tablename = "block_eexcess_interests";
     $mform =& $this->_form;
     $cats = $DB->get_records($tablename, array("userid" => $USER->id));
     foreach ($cats as $cat) {
         $tags = explode(",", $cat->interests);
         $listr = "";
         foreach ($tags as $tag) {
             $listr .= "<li>{$tag}</li>";
         }
         $catid = $cat->id;
         if ($cat->active > 0) {
             $checked = "checked=\"true\"";
             $activeclass = "active-cat";
         } else {
             $checked = "";
             $activeclass = "inactive-cat";
         }
         $sesskey = sesskey();
         $html = "<div data-catid=\"{$catid}\" data-sesskey=\"{$sesskey}\"class=\"int-category {$activeclass} \">";
         $html .= "<a data-catid=\"{$catid}\" href=\"{$deletebuturl}\" class=\"delete_interests\">x</a>";
         $html .= "<span><h4>{$cat->title}</h4></span><label>Use -</label>";
         $html .= "<input type=\"checkbox\" {$checked} value=\"1\" class=\"active\"/><ul >{$listr}</ul></div>";
         $mform->addElement('html', $html);
     }
     $mform->addElement('html', '<input type="hidden" id="interest_json" name="interest_json">');
     $buttitle = get_string('interests_tags', 'block_eexcess');
     $mform->addElement('html', '<button type="button" id="id_area_for_tags" class="area_for_tags">' . $buttitle . '</button>');
     $this->add_action_buttons(true, get_string('savechanges'));
 }
Example #19
0
 function definition()
 {
     global $DB, $CFG, $COURSE;
     $mform =& $this->_form;
     $mform->addElement('textarea', 'querysql', get_string('querysql', 'block_configurable_reports'), 'rows="35" cols="80"');
     $mform->addRule('querysql', get_string('required'), 'required', null, 'client');
     $mform->setType('querysql', PARAM_RAW);
     $mform->addElement('hidden', 'courseid', $COURSE->id);
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
     $mform->addElement('static', 'note', '', get_string('listofsqlreports', 'block_configurable_reports'));
     if ($userandrepo = get_config('block_configurable_reports', 'sharedsqlrepository')) {
         $c = new curl();
         $res = $c->get("https://api.github.com/repos/{$userandrepo}/contents/");
         $res = json_decode($res);
         if (is_array($res)) {
             $reportcategories = array(get_string('choose'));
             foreach ($res as $item) {
                 if ($item->type == 'dir') {
                     $reportcategories[$item->path] = $item->path;
                 }
             }
             $mform->addElement('select', 'reportcategories', get_string('reportcategories', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportcategories(this,"' . sesskey() . '")'));
             $mform->addElement('select', 'reportsincategory', get_string('reportsincategory', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportsincategory(this,"' . sesskey() . '")'));
             $mform->addElement('textarea', 'remotequerysql', get_string('remotequerysql', 'block_configurable_reports'), 'rows="15" cols="90"');
         }
     }
     //$this->add_action_buttons();
 }
Example #20
0
    /**
     * Display the listing of registered on hub
     */
    public function registeredonhublisting($hubs) {
        global $CFG;
        $table = new html_table();
        $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
        $table->size = array('80%', '20%');

        foreach ($hubs as $hub) {
            if ($hub->huburl == HUB_MOODLEORGHUBURL) {
                $hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
            }
            $hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
            $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));

            $unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
                            array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
                                'unregistration' => 1));
            $unregisterbutton = new single_button($unregisterhuburl,
                            get_string('unregister', 'hub'));
            $unregisterbutton->class = 'centeredbutton';
            $unregisterbuttonhtml = $this->output->render($unregisterbutton);

            //add button cells
            $cells = array($hublinkcell, $unregisterbuttonhtml);
            $row = new html_table_row($cells);
            $table->data[] = $row;
        }

        return html_writer::table($table);
    }
 public function earlier_user_menu()
 {
     global $USER, $CFG, $OUTPUT;
     if ($CFG->branch > "27") {
         return '';
     }
     $uname = fullname($USER, true);
     $dlink = new moodle_url("/my");
     $plink = new moodle_url("/user/profile.php", array("id" => $USER->id));
     $lo = new moodle_url('/login/logout.php', array('sesskey' => sesskey()));
     $content = '<li class="dropdown no-divider">
     <a class="dropdown-toggle"
     data-toggle="dropdown"
     href="#">
     ' . $uname . '
     <i class="fa fa-chevron-down"></i><span class="caretup"></span>
     </a>
     <ul class="dropdown-menu">
     <li><a href="' . $dlink . '">Dashboard</a></li>
     <li><a href="' . $plink . '">Profile</a></li>
     <li><a href="' . $lo . '">Logout</a></li>
     </ul>
     </li>';
     return $content;
 }
 public function definition()
 {
     global $USER, $cm;
     if (is_array($locations = praxe_get_available_locations($USER->id, praxe_record::getData('isced'), praxe_record::getData('studyfield'))) && count($locations)) {
         //$mform =& $this->_form;
         $this->content_before_form .= get_string('assigntolocation_text_forstudents', 'praxe');
         $form = '<form class="mform" action="' . praxe_get_base_url() . '" method="post">';
         $form .= '<input type="hidden" name="post_form" value="assignlocation" />';
         $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
         $table = new stdClass();
         $table->head = array('', get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe'));
         $table->align = array('center', 'left', 'center', 'center');
         foreach ($locations as $loc) {
             $row = array('<input id="praxe_loc_' . $loc->id . '" type="radio" name="location" value="' . $loc->id . '" />');
             $sch = "<a href=\"" . praxe_get_base_url(array('viewaction' => 'viewschool', 'schoolid' => $loc->school)) . "\" title=\"" . get_string('school_detail', 'praxe') . "\">" . s($loc->name) . "</a>";
             $sch .= "<div class=\"praxe_detail\">" . s($loc->street) . ', ' . s($loc->city) . "</div>";
             $row[] = $sch;
             $row[] = s($loc->subject);
             if (!is_null($loc->teacherid)) {
                 $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname));
                 $row[] = praxe_get_user_fullname($teacher);
             } else {
                 $row[] = '';
             }
             $table->data[] = $row;
             //$row .= '<label for="praxe_loc_'.$loc->id.'">'.$text.'</label>';
             //$form .= "<div class=\"tr\">$row</div>";
         }
         $form .= html_writer::table($table, true);
         $form .= '<div class="fitem center" style="margin: 10px 0;">' . '<input type="submit" id="id_submitbutton" value="Submit" name="submitbutton" /> ' . '<input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="Cancel" name="cancel" />' . '</div>';
         $form .= '</form>';
         $this->content .= "<div>{$form}</div>";
         //$mform->addElement('header', null, get_string('locations', 'praxe'));
         /*
         			$options = array();
         $radioarray = array();
         foreach($locations as $loc) {
         	//print_object($loc);
         	$link = "<a target='_blank' href='view.php?id=$cm->id&amp;praxeaction=viewschool&amp;schoolid=$loc->school' title='".get_string('school_detail','praxe')."'>".get_string('school_detail','praxe')."</a>";
         	$text = s($loc->name) . "($link) - " . s($loc->subject);
         	$text .= "<br>".s($loc->street).', '.s($loc->zip).'&nbsp;&nbsp;'.s($loc->city);
         	if(!is_null($loc->teacherid)) {
         		$teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname));
         		$text .= " (".praxe_get_user_fullname($teacher).")";
         	}
         	$radioarray[] = $mform->createElement('radio', 'location', null, $text, $loc->id, array('class'=>'radio location'));
         }
         $mform->addGroup($radioarray, 'location', get_string('locations','praxe').':', '<hr>', false);
         $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'client');
         $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'server');
         //$mform->addElement('select', 'location', get_string('chooselocation', 'praxe'), $options, array('size' => count($options) > 15 ? '15' : count($options)+1));
         $mform->addElement('hidden', 'post_form', 'assigntolocation');
         */
         //$this->add_action_buttons(true, get_string('submit'));
     } else {
         $this->content_before_form .= get_string('nolocationsavailable', 'praxe');
     }
 }
Example #23
0
function rejudge_notice()
{
    global $assignment, $id;
    print_header(get_string('notice'));
    $message = get_string('rejudgeallnotice', 'assignment_onlinejudge', $assignment->name);
    $link = 'rejudge.php?id=' . $id . '&force=1';
    notice_okcancel($message, $link, array('sesskey' => sesskey()));
    print_footer('none');
}
 public function modify_items_link($courseid = 0)
 {
     global $COURSE;
     if ($courseid == 0) {
         $courseid = $COURSE->id;
     }
     $url = new moodle_url('/grade/edit/tree/index.php', array('sesskey' => sesskey(), 'showadvanced' => 1, 'id' => $courseid));
     return $this->notification(html_writer::tag('p', html_writer::link($url, '点击此处修改成绩设置')));
 }
Example #25
0
 /**
  * Column actions.
  *
  * @param  object $row
  * @return string
  */
 protected function col_actions($row)
 {
     global $OUTPUT;
     $action = new \confirm_action(get_string('areyousure'));
     $url = new moodle_url($this->baseurl);
     $url->params(array('removecohort' => $row->id, 'sesskey' => sesskey()));
     $actionlink = $OUTPUT->action_link($url, '', $action, null, new \pix_icon('t/delete', get_string('stopsyncingcohort', 'tool_lp')));
     return $actionlink;
 }
Example #26
0
function memorization_print_new_verse_box()
{
    global $CFG, $USER;
    print_box_start('add-verse-box generalbox box');
    print_heading(get_string('newverse', 'memorization'));
    $biblebooks = biblebooks_array();
    // create the book selector
    $biblebookoptions = '';
    foreach ($biblebooks as $booknumber => $bookofbible) {
        if ($booknumber == 0) {
            continue;
        }
        $biblebookoptions .= '<option value="' . $booknumber . '">' . $bookofbible . '</option>';
    }
    $startbookid = '<select name="startbookid">' . $biblebookoptions . '</select>';
    $endbookid = '<select name="endbookid">' . $biblebookoptions . '</select>';
    // create the chapter inputs
    $startchapter = '<input type="text" name="startchapter" size="5" />';
    $endchapter = '<input type="text" name="endchapter" size="5"/>';
    // create the verse inputs
    $startverse = '<input type="text" name="startverse" size="5"/>';
    $endverse = '<input type="text" name="endverse" size="5"/>';
    // create the version chooser
    $versions = get_records('memorization_version');
    if (!empty($versions)) {
        $versionselect = '<select name="versionid">';
        $lastversionid = get_field_sql("SELECT versionid FROM {$CFG->prefix}memorization_verse WHERE userid={$USER->id} ORDER BY id DESC");
        foreach ($versions as $versionid => $version) {
            $selected = $versionid == $lastversionid ? ' SELECTED="selected" ' : '';
            $versionselect .= '<option ' . $selected . ' value="' . $versionid . '">' . $version->value . '</option>';
        }
        $versionselect .= '</select>';
    }
    $currenturl = new moodle_url(qualified_me());
    echo '<form method="POST" action="addverse.php?' . $currenturl->get_query_string() . '">
          <input type="hidden" name="sesskey" value="' . sesskey() . '">
          <table>
            <tr>
              <td>' . get_string('fromverse', 'memorization') . '</td>
              <td>' . $startbookid . ' ' . $startchapter . ':' . $startverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('toverse', 'memorization') . '</td>
              <td>' . $endbookid . ' ' . $endchapter . ':' . $endverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('version', 'memorization') . '</td>
              <td>' . $versionselect . '</td>
            </tr>
          </table>
          <input type="submit">
          </form>';
    print_box_end();
}
Example #27
0
File: lib.php Project: dg711/moodle
 /**
  * Constructor of dropbox plugin.
  *
  * @inheritDocs
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = [])
 {
     $options['page'] = optional_param('p', 1, PARAM_INT);
     parent::__construct($repositoryid, $context, $options);
     $returnurl = new moodle_url('/repository/repository_callback.php', ['callback' => 'yes', 'repo_id' => $repositoryid, 'sesskey' => sesskey()]);
     // Create the dropbox API instance.
     $key = get_config('dropbox', 'dropbox_key');
     $secret = get_config('dropbox', 'dropbox_secret');
     $this->dropbox = new repository_dropbox\dropbox($key, $secret, $returnurl);
 }
Example #28
0
 /**
  * Renders the active method selector at the grading method management screen
  *
  * @param grading_manager $gradingman
  * @param moodle_url $targeturl
  * @return string
  */
 public function management_method_selector(grading_manager $manager, moodle_url $targeturl)
 {
     $method = $manager->get_active_method();
     $methods = $manager->get_available_methods(false);
     $methods['none'] = get_string('gradingmethodnone', 'core_grading');
     $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())), 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
     $selector->set_label(get_string('changeactivemethod', 'core_grading'));
     $selector->set_help_icon('gradingmethod', 'core_grading');
     return $this->output->render($selector);
 }
 /**
  * Prints the respective type icon
  *
  * @global object
  * @return string
  */
 function image()
 {
     global $OUTPUT;
     $params = array('d' => $this->data->id, 'fid' => $this->field->id, 'mode' => 'display', 'sesskey' => sesskey());
     $link = new moodle_url('/mod/data/field.php', $params);
     $str = '<a href="' . $link->out() . '">';
     $str .= '<img src="' . $OUTPUT->pix_url('linkedradiobutton', 'datafield_linkedradiobutton') . '" ';
     $str .= 'height="' . $this->iconheight . '" width="' . $this->iconwidth . '" alt="' . $this->type . '" title="' . $this->type . '" /></a>';
     return $str;
 }
 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
     $confirmed = optional_param('confirmed', false, PARAM_BOOL);
     /// If  not confirmed, show confirmation box
     if (!$confirmed) {
         $o = '<table width="60" class="generalbox boxaligncenter" border="0" cellpadding="5" cellspacing="0" id="notice">';
         $o .= '  <tr><td class="generalboxcontent">';
         $o .= '    <p class="centerpara">' . $this->str['confirmrevertchanges'] . '<br /><br />' . $dirpath . '</p>';
         $o .= '    <table class="boxaligncenter" cellpadding="20"><tr><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=revert_changes&amp;sesskey=' . sesskey() . '&amp;confirmed=yes&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;postaction=main_view#lastused" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>';
         $o .= '      </td><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=main_view#lastused" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>';
         $o .= '      </td></tr>';
         $o .= '    </table>';
         $o .= '  </td></tr>';
         $o .= '</table>';
         $this->output = $o;
     } else {
         /// Get the original dir and delete some elements
         if (!empty($XMLDB->dbdirs)) {
             if (isset($XMLDB->dbdirs[$dirpath])) {
                 $dbdir =& $XMLDB->dbdirs[$dirpath];
                 if ($dbdir) {
                     unset($dbdir->xml_changed);
                 }
             }
         }
         /// Get the edited dir and delete it completely
         if (!empty($XMLDB->editeddirs)) {
             if (isset($XMLDB->editeddirs[$dirpath])) {
                 unset($XMLDB->editeddirs[$dirpath]);
             }
         }
     }
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }