/** * 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&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&ss=1&uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li> </ul></div>'; } return $output; }
/** * Overriding the normal constructor in order to use * our extended version of MoodleQuickForm, which * will enable this form to use slides * @param string $action Form destination * @param array $customdata Custom data for pre-populating form fields * @param string $method Method of form submission - GET or POST * @param string $target Form's target * @param array $attributes HTML form attributes * @param boolean $editable Whether the form can be edited * @version 2013050801 * @since 2011101901 */ public function __construct($action = null, array $customdata = array(), $method = 'post', $target = '', array $attributes = array(), $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 MoodleQuickFormWithSlides($this->_formname, $method, $action, $target, $attributes); if (!$editable) { $this->_form->hardFreeze(); } $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(); // Moodle 2.5 and above have auto-collapsing forms. Not appropriate here! // (Using method_exists() so that 2.0-2.4 and 2.5+ can share the same code base) if (method_exists($this->_form, 'setDisableShortforms')) { $this->_form->setDisableShortforms(true); } // we have to know all input types before processing submission ;-) $this->_process_submission($method); }
/** * 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); }
/** * Construct the unassigned datatable. * * @param string $uniqid A unique ID to assign to the datatable object. * @return deepsight_datatable The datatable object. */ protected function construct_unassigned_table($uniqid = null) { global $DB; $classid = $this->required_param('id', PARAM_INT); $endpoint = qualified_me() . '&action=deepsight_response&tabletype=unassigned&id=' . $classid; $table = new deepsight_datatable_enrolments($DB, 'unassigned', $endpoint, $uniqid, $classid); return $table; }
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(); }
/** * Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and * (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions * in favour of the usual print_header(), print_header_simple(), print_heading() etc. * !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at * the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN). * * @param int $courseid * @param string $active_type The type of the current page (report, settings, import, export, scales, outcomes, letters) * @param string $active_plugin The plugin of the current page (grader, fullview etc...) * @param string $heading The heading of the page. Tries to guess if none is given * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function * @param string $bodytags Additional attributes that will be added to the <body> tag * @param string $buttons Additional buttons to display on the page * * @return string HTML code or nothing if $return == false */ function print_grade_page_head_local($courseid, $active_type, $active_plugin = null, $heading = false, $return = false, $bodytags = '', $buttons = false, $extracss = array()) { global $CFG, $COURSE; $strgrades = get_string('grades'); $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); // Determine the string of the active plugin $stractive_plugin = $active_plugin ? $plugin_info['strings']['active_plugin_str'] : $heading; $stractive_type = $plugin_info['strings'][$active_type]; $navlinks = array(); $first_link = ''; if ($active_type == 'settings' && $active_plugin != 'coursesettings') { $first_link = $plugin_info['report'][$active_plugin]['link']; } elseif ($active_type != 'report') { $first_link = $CFG->wwwroot . '/grade/index.php?id=' . $COURSE->id; } if ($active_type == 'preferences') { $CFG->stylesheets[] = $CFG->wwwroot . '/grade/report/styles.css'; } foreach ($extracss as $css_url) { $CFG->stylesheets[] = $css_url; } $navlinks[] = array('name' => $strgrades, 'link' => $first_link, 'type' => 'misc'); $active_type_link = ''; if (!empty($plugin_info[$active_type]['link']) && $plugin_info[$active_type]['link'] != qualified_me()) { $active_type_link = $plugin_info[$active_type]['link']; } if (!empty($plugin_info[$active_type]['parent']['link'])) { $active_type_link = $plugin_info[$active_type]['parent']['link']; $navlinks[] = array('name' => $stractive_type, 'link' => $active_type_link, 'type' => 'misc'); } if (empty($plugin_info[$active_type]['id'])) { $navlinks[] = array('name' => $stractive_type, 'link' => $active_type_link, 'type' => 'misc'); } $navlinks[] = array('name' => $stractive_plugin, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); $title = ': ' . $stractive_plugin; if (empty($plugin_info[$active_type]['id']) || !empty($plugin_info[$active_type]['parent'])) { $title = ': ' . $stractive_type . ': ' . $stractive_plugin; } $returnval = print_header_simple($strgrades . ': ' . $stractive_type, $title, $navigation, '', $bodytags, true, $buttons, navmenu($COURSE), false, '', $return); // Guess heading if not given explicitly if (!$heading) { $heading = $stractive_plugin; } if ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN) { $returnval .= print_grade_plugin_selector($plugin_info, $return); } $returnval .= print_heading($heading); if ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS) { $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return); } if ($return) { return $returnval; } }
function instance_config_print() { global $CFG; /// set up the numberoftags select field $numberoftags = array(); for ($i = 1; $i <= 200; $i++) { $numberoftags[$i] = $i; } if (is_file($CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html')) { print_simple_box_start('center', '', '', 5, 'blockconfigglobal'); include $CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html'; print_simple_box_end(); } else { notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me())); } }
public function print_badge_table_actions($badge, $context) { $actions = ""; if (has_capability('moodle/badges:configuredetails', $context)) { // Activate/deactivate badge. if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) { $url = new moodle_url(qualified_me()); $url->param('activate', $badge->id); $url->param('sesskey', sesskey()); $actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " "; } else { $url = new moodle_url(qualified_me()); $url->param('lock', $badge->id); $url->param('sesskey', sesskey()); $actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " "; } } // Award badge manually. if ($badge->has_manual_award_criteria() && has_capability('moodle/badges:awardbadge', $context) && $badge->is_active()) { $url = new moodle_url('/badges/award.php', array('id' => $badge->id)); $actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " "; } // Edit badge. if (has_capability('moodle/badges:configuredetails', $context)) { $url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'details')); $actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " "; } // Duplicate badge. if (has_capability('moodle/badges:createbadge', $context)) { $url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey())); $actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " "; } // Delete badge. if (has_capability('moodle/badges:deletebadge', $context)) { $url = new moodle_url(qualified_me()); $url->param('delete', $badge->id); $actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " "; } return $actions; }
public function test_qualified_me() { global $PAGE, $FULLME, $CFG; $this->resetAfterTest(); $PAGE = new moodle_page(); $FULLME = $CFG->wwwroot . '/course/view.php?id=1&xx=yy'; $this->assertSame($FULLME, qualified_me()); $PAGE->set_url('/course/view.php', array('id' => 1)); $this->assertSame($CFG->wwwroot . '/course/view.php?id=1', qualified_me()); }
/** * The constructor function calls the abstract function definition() and it will then * process and clean and attempt to validate incoming data. * * It will call your custom validate method to validate data and will also check any rules * you have specified in definition using addRule * * The name of the form (id attribute of the form) is automatically generated depending on * the name you gave the class extending moodleform. You should call your class something * like * * @param mixed $action the action attribute for the form. If empty defaults to auto detect the * current url. If a moodle_url object then outputs params as hidden variables. * @param array $customdata if your form defintion method needs access to data such as $course * $cm, etc. to construct the form definition then pass it in this array. You can * use globals for somethings. * @param string $method if you set this to anything other than 'post' then _GET and _POST will * be merged and used as incoming data to the form. * @param string $target target frame for form submission. You will rarely use this. Don't use * it if you don't need to as the target attribute is deprecated in xhtml * strict. * @param mixed $attributes you can pass a string of html attributes here or an array. * @param bool $editable * @return object moodleform */ function moodleform($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true) { if (empty($action)) { $action = strip_querystring(qualified_me()); } // Assign custom data first, so that get_form_identifier can use it. $this->_customdata = $customdata; $this->_formname = $this->get_form_identifier(); $this->_form = new MoodleQuickForm($this->_formname, $method, $action, $target, $attributes); if (!$editable) { $this->_form->hardFreeze(); } $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); }
/** * Shows config form & errors * * @param object $frm * @access public */ function config_form($frm) { global $CFG; $mconfig = get_config('enrol/authorize'); if (!check_openssl_loaded()) { notify('PHP must be compiled with SSL support (--with-openssl)'); } if (empty($CFG->loginhttps) and substr($CFG->wwwroot, 0, 5) !== 'https') { $a = new stdClass(); $a->url = "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=httpsecurity"; notify(get_string('adminconfighttps', 'enrol_authorize', $a)); return; // notice breaks the form and xhtml later } elseif (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836 $wwwsroot = qualified_me(); $wwwsroot = str_replace('http:', 'https:', $wwwsroot); $a = new stdClass(); $a->url = $wwwsroot; notify(get_string('adminconfighttpsgo', 'enrol_authorize', $a)); return; // notice breaks the form and xhtml later } if (!empty($frm->an_review)) { $captureday = intval($frm->an_capture_day); $emailexpired = intval($frm->an_emailexpired); if ($captureday > 0 || $emailexpired > 0) { $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules'); if (time() - intval($lastcron) > 3600 * 24) { notify(get_string('admincronsetup', 'enrol_authorize')); } } } if ($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) { $a = new stdClass(); $a->count = $count; $a->url = $CFG->wwwroot . "/enrol/authorize/index.php?status=" . AN_STATUS_AUTH; notify(get_string('adminpendingorders', 'enrol_authorize', $a)); } if (data_submitted()) { if (empty($mconfig->an_login)) { notify("an_login required"); } if (empty($mconfig->an_tran_key) && empty($mconfig->an_password)) { notify("an_tran_key or an_password required"); } } include $CFG->dirroot . '/enrol/authorize/config_form.php'; }
/** * Private method. Used by printPass/Fail/Skip/Error. */ function _paintPassFail($passorfail, $message, $stacktrace = null, $debuginfo = null) { global $CFG, $OUTPUT; echo $OUTPUT->box_start($passorfail . ' generalbox '); $url = $this->_htmlEntities($this->_stripParameterFromUrl(qualified_me(), 'path')); echo '<b class="', $passorfail, '">', $this->get_string($passorfail), '</b>: '; $breadcrumb = $this->getTestList(); array_shift($breadcrumb); $file = array_shift($breadcrumb); $pathbits = preg_split('/\\/|\\\\/', substr($file, strlen($CFG->dirroot) + 1)); $file = array_pop($pathbits); $folder = ''; foreach ($pathbits as $pathbit) { $folder .= $pathbit . '/'; echo "<a href=\"{$url}path={$folder}\" title=\"{$this->strrunonlyfolder}\">{$pathbit}</a>/"; } echo "<a href=\"{$url}path={$folder}{$file}\" title=\"{$this->strrunonlyfile}\">{$file}</a>"; echo $this->strseparator, implode($this->strseparator, $breadcrumb); echo '<br />', $this->_htmlEntities($message), "\n\n"; if (!empty($debuginfo)) { print_object('Debug info:'); print_object($debuginfo); } if ($stacktrace) { $dotsadded = false; $interestinglines = 0; $filteredstacktrace = array(); foreach ($stacktrace as $frame) { if (empty($frame['file']) || strpos($frame['file'], 'simpletestlib') === false && strpos($frame['file'], 'simpletestcoveragelib') === false && strpos($frame['file'], 'tool/unittest') === false) { $filteredstacktrace[] = $frame; $interestinglines += 1; $dotsadded = false; } else { if (!$dotsadded) { $filteredstacktrace[] = array('line' => '...', 'file' => '...'); $dotsadded = true; } } } if ($interestinglines > 1 || $passorfail == 'exception' && $interestinglines > 0) { echo '<div class="notifytiny">' . format_backtrace($filteredstacktrace) . "</div>\n\n"; } } echo $OUTPUT->box_end(); flush(); }
/** * Will get called before the login page is shownr. Ff NTLM SSO * is enabled, and the user is in the right network, we'll redirect * to the magic NTLM page for SSO... * */ function loginpage_hook() { global $CFG, $SESSION; // HTTPS is potentially required //httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php if (($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST' && get_local_referer() != strip_querystring(qualified_me())) && !empty($this->config->ntlmsso_enabled) && !empty($this->config->ntlmsso_subnet) && empty($_GET['authldap_skipntlmsso']) && (isguestuser() || !isloggedin()) && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) { // First, let's remember where we were trying to get to before we got here if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = null; $referer = get_local_referer(false); if ($referer && $referer != $CFG->wwwroot && $referer != $CFG->wwwroot . '/' && $referer != $CFG->httpswwwroot . '/login/' && $referer != $CFG->httpswwwroot . '/login/index.php') { $SESSION->wantsurl = $referer; } } // Now start the whole NTLM machinery. if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESATTEMPT || $this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { if (core_useragent::is_ie()) { $sesskey = sesskey(); redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey=' . $sesskey); } else { if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1'); } } } redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_attempt.php'); } // No NTLM SSO, Use the normal login page instead. // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login // page insists on redirecting us to that page after user validation. If // we clicked on the redirect link at the ntlmsso_finish.php page (instead // of waiting for the redirection to happen) then we have a 'Referer:' header // we don't want to use at all. As we can't get rid of it, just point // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there). if (empty($SESSION->wantsurl) && get_local_referer() == $CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php') { $SESSION->wantsurl = $CFG->wwwroot; } }
public function get_baseurl() { $getcopy = $_GET; unset($getcopy['blogpage']); if (!empty($getcopy)) { $first = false; $querystring = ''; foreach ($getcopy as $var => $val) { if (!$first) { $first = true; $querystring .= "?{$var}={$val}"; } else { $querystring .= '&' . $var . '=' . $val; $hasparam = true; } } } else { $querystring = '?'; } return strip_querystring(qualified_me()) . $querystring; }
function instance_config_print() { global $CFG, $DB; if (!isset($this->config)) { // ... teacher has not yet configured the block, let's put some default values here to explain things $this->config->title = get_string('blockname', 'block_glossary_random'); $this->config->refresh = 0; $this->config->showconcept = 1; $this->config->cache = get_string('notyetconfigured', 'block_glossary_random'); $this->config->addentry = get_string('addentry', 'block_glossary_random'); $this->config->viewglossary = get_string('viewglossary', 'block_glossary_random'); $this->config->invisible = get_string('invisible', 'block_glossary_random'); } // select glossaries to put in dropdown box ... $glossaries = $DB->get_records_menu('glossary', array('course' => $this->course->id), 'name', 'id,name'); //format menu texts to avoid html and to filter multilang values if (!empty($glossaries)) { foreach ($glossaries as $key => $value) { $glossaries[$key] = strip_tags(format_string($value, true)); } } // and select quotetypes to put in dropdown box $type[0] = get_string('random', 'block_glossary_random'); $type[1] = get_string('lastmodified', 'block_glossary_random'); $type[2] = get_string('nextone', 'block_glossary_random'); $this->config->nexttime = usergetmidnight(time()) + DAYSECS * $this->config->refresh; // display the form if (is_file($CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html')) { print_simple_box_start('center', '', '', 5, 'blockconfigglobal'); include $CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html'; print_simple_box_end(); } else { notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me())); } return true; }
function get_baseurl($filtertype, $filterselect) { $getcopy = $_GET; unset($getcopy['blogpage']); $strippedurl = strip_querystring(qualified_me()); if (!empty($getcopy)) { $first = false; $querystring = ''; foreach ($getcopy as $var => $val) { if (!$first) { $first = true; if ($var != 'filterselect' && $var != 'filtertype') { $querystring .= '?' . $var . '=' . $val; $hasparam = true; } else { $querystring .= '?'; } } else { if ($var != 'filterselect' && $var != 'filtertype') { $querystring .= '&' . $var . '=' . $val; $hasparam = true; } } } if (isset($hasparam)) { $querystring .= '&'; } else { $querystring = '?'; } } else { $querystring = '?'; } return strip_querystring(qualified_me()) . $querystring . 'filtertype=' . $filtertype . '&filterselect=' . $filterselect . '&'; }
/** * 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, $SCRIPT; // 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; if ($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 pageinfo">This page is: ' . $this->page->debug_summary() . '</div>'; } if (debugging(null, DEBUG_DEVELOPER) and has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { // Only in developer mode // Add link to profiling report if necessary if (function_exists('profiling_is_running') && profiling_is_running()) { $txt = get_string('profiledscript', 'admin'); $title = get_string('profiledscriptview', 'admin'); $url = $CFG->wwwroot . '/admin/report/profiling/index.php?script=' . urlencode($SCRIPT); $link = '<a title="' . $title . '" href="' . $url . '">' . $txt . '</a>'; $output .= '<div class="profilingfooter">' . $link . '</div>'; } $output .= '<div class="purgecaches"><a href="' . $CFG->wwwroot . '/admin/purgecaches.php?confirm=1&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&ss=1&uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li> </ul></div>'; } if (!empty($CFG->additionalhtmlfooter)) { $output .= "\n" . $CFG->additionalhtmlfooter; } return $output; }
function displaydir($wdir, $files) { // $wdir == / or /a or /a/b/c/d etc @ini_set('memory_limit', '1024M'); global $courseid, $DB, $OUTPUT; global $USER, $CFG, $COURSE; global $choose; global $deptstr, $userstr; require_once $CFG->dirroot . '/blocks/morsle/constants.php'; $course = $COURSE; $user = $USER; // Get the sort parameter if there is one $sort = optional_param('sort', 1, PARAM_INT); $dirlist = array(); $filelist = array(); $dirhref = array(); $filehref = array(); $courseid = $course->id; $coursecontext = context_course::instance($COURSE->id); // separate all the files list into directories and files foreach ($files as $name => $file) { if (is_folder($file)) { $dirlist[$name] = $file; } else { $filelist[$name] = $file; } } // setup variables and strings $strname = get_string("name", 'block_morsle'); $strsize = get_string("size"); $strmodified = get_string("modified"); $straction = get_string("action"); $strmakeafolder = get_string("morslemakecollection", 'block_morsle'); $struploadafile = get_string("uploadafile"); $strselectall = get_string("selectall"); $strselectnone = get_string("deselectall"); $strwithchosenfiles = get_string("withchosenfiles"); $strmovetoanotherfolder = get_string("movetoanotherfolder"); $strlinktocourse = get_string("linktocourse", 'block_morsle'); $strmovefilestohere = get_string("movefilestohere"); $strdeletefromcollection = get_string("deletefromcollection", 'block_morsle'); $strcreateziparchive = get_string("createziparchive"); $strrename = get_string("rename"); $stredit = get_string("edit"); $strunzip = get_string("unzip"); $strlist = get_string("list"); $strrestore = get_string("restore"); $strchoose = get_string("choose"); $strfolder = get_string("folder"); $strfile = get_string("file"); $strdownload = get_string("strdownload", 'block_morsle'); $struploadthisfile = get_string("uploadthisfile"); $struploadandlinkthisfile = get_string("uploadandlinkthisfile", 'block_morsle'); $filesize = 'Varies as to type of document'; $strmaxsize = get_string("maxsize", "", $filesize); $strcancel = get_string("cancel"); $strmodified = get_string("strmodified", 'block_morsle'); //CLAMP #289 set color and background-color to transparent //Kevin Wiliarty 2011-03-08 $padrename = get_string("rename"); $padedit = $padunzip = $padlist = $padrestore = $padchoose = $padfolder = $padfile = $padlink = ''; $attsArr = array($padedit => $stredit, $padunzip => $strunzip, $padlist => $strlist, $padrestore => $strrestore, $padchoose => $strchoose, $padfolder => $strfolder, $padfile => $strfile, $padlink => $strlinktocourse); foreach ($attsArr as $key => $value) { $key = html_writer::div($value . ' ', '', array('style' => 'color:transparent; background-color:transparent; display:inline;')); } /* $padedit = html_writer::div($stredit . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padunzip = html_writer::div($strunzip . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padlist = html_writer::div($strlist . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padrestore = html_writer::div($strrestore . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padchoose = html_writer::div($strchoose . ' ','', array('style'=>'color: transparent; background-color:transparent; display:inline')); $padfolder = html_writer::div($strfolder . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline;')); $padfile = html_writer::div($strfile . ' ','', array('style'=>'color:transparent; background-color; transparent; display:inline;')); $padlink = html_writer::div($strlinktocourse . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline;')); */ $gdocsstr = 'Google-Docs-Storage-for-'; // Set sort arguments so that clicking on a column that is already sorted reverses the sort order $sortvalues = array(1, 2, 3); foreach ($sortvalues as &$sortvalue) { if ($sortvalue == $sort) { $sortvalue = -$sortvalue; } } $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); // beginning of with selected files portion echo html_writer::start_tag('table', array('border' => '0', 'cellspacing' => '2', 'cellpadding' => '2', 'style' => 'min-width: 900px; margin-left:auto; margin-right:auto', 'class' => 'files')); if ($wdir !== '') { echo html_writer::start_tag('tr'); //html_writer::table($table); if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) { echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'center')); // move files to other folder form echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'paste')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); echo html_writer::tag('input', '', array('align' => 'center', 'type' => 'submit', 'value' => $strmovefilestohere)); //echo "<span> --> <b>$wdir</b></span><br />"; echo html_writer::start_span() . '-->' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::end_tag('br'); echo html_writer::end_tag('td'); echo html_writer::start_tag('td'); echo html_writer::end_tag('form'); // cancel moving form echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'style' => 'color:red; margin-left:10px')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); } else { if (has_capability('moodle/course:update', $coursecontext) || strpos($wdir, '-write')) { echo html_writer::start_tag('tr', array('style' => 'background-color: #ffddbb;')); echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'left', 'style' => 'background-color:#ffddbb; padding-left:5px;')); // file upload form // TODO: what if we're in the user or departmental dir? echo html_writer::start_tag('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => 'morslefiles.php')); echo html_writer::start_span() . ' ' . $struploadafile . ' (' . $strmaxsize . ') ' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::tag('br', ''); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'upload')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); if (!isset($coursebytes)) { $coursebytes = 0; } if (!isset($modbytes)) { $modbytes = 0; } $maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursebytes, $modbytes); $str = html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => $maxbytes)) . "\n"; $name = 'userfile'; $str .= html_writer::tag('input', '', array('type' => 'file', 'size' => '50', 'name' => $name, 'alt' => $name, 'style' => 'margin-left: 5px;')) . html_writer::end_tag('br') . "\n"; echo $str; echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'save', 'value' => $struploadthisfile, 'style' => 'color:green; padding-left:5px;')); echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'savelink', 'value' => $struploadandlinkthisfile, 'style' => 'color:blue; padding-left:5px;')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); // cancel button div only if not in root morsle directory echo html_writer::start_tag('tr'); echo html_writer::tag('td', '', array('colspan' => '2', 'style' => 'background-color:#ffddbb;')); echo html_writer::start_tag('td', array('style' => 'background-color:#ffddbb; padding-left:5px;', 'colspan' => '1', 'align' => 'right')); echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'align' => 'left', 'style' => 'color:red;')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); echo html_writer::end_tag('tr'); echo html_writer::start_tag('tr'); echo html_writer::start_tag('tr') . html_writer::tag('td', '<br>', array('colspace' => '4')) . html_writer::end_tag('tr'); echo html_writer::start_tag('td', array('style' => 'max-width:50px; white-space:nowrap;', 'colspan' => '2', 'align' => 'left')); //dummy form - alignment only echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset')); echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectall, 'onclick' => 'checkall();', 'style' => 'color:green;')); echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectnone, 'onclick' => 'checknone();', 'style' => 'color:red;')); echo html_writer::end_tag('fieldset'); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::start_tag('td', array('align' => 'center', 'colspan' => '2')); // makedir form // TODO: program to allow this in user and departmental directory if (strpos($wdir, $deptstr) === false && strpos($wdir, $userstr) === false) { // not a user or departmental folder echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'makedir')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strmakeafolder)); echo html_writer::end_tag('form'); } echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); } } } echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'post', 'id' => 'dirform')); echo html_writer::start_div(); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::start_tag('tr'); echo html_writer::start_tag('th', array('class' => 'header', 'scope' => 'col', 'style' => 'max-width:40px;')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); // $options = array ("delete" => "$strdeletefromcollection"); // only editing teachers can link items to course page if (has_capability('moodle/course:update', $coursecontext)) { $options['link'] = "{$strlinktocourse}"; } if (!empty($filelist) || !empty($dirlist)) { // echo html_writer::tag('label', "$strwithchosenfiles...", array('for'=>'formactionid')); // echo html_writer::select($options, "$strwithchosenfiles...", '', array(1 => "$strwithchosenfiles...")); echo html_writer::start_div('', array('id' => 'noscriptgo', 'style' => 'display:inline;')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => get_string('go'))); echo html_writer::script('document.getElementById("noscriptgo").style.display="none"'); echo html_writer::end_div(); } echo html_writer::end_tag('th'); echo html_writer::start_tag('th', array('style' => 'padding-right:120px;', 'class' => 'header name', 'scope' => 'col')) . html_writer::link(qualified_me(), $strname, array('&sort' => '{' . $sortvalues[0] . '}')) . html_writer::end_tag('th'); echo html_writer::start_tag('th', array('class' => 'header date', 'scope' => 'col')) . html_writer::link(qualified_me(), $strmodified, array('&sort' => '{' . $sortvalues[2] . '}')) . html_writer::end_tag('th'); echo html_writer::tag('th', $straction, array('class' => 'header commands', 'scope' => 'col')); echo html_writer::end_tag('tr') . "\n"; // Sort parameter indicates column to sort by, and parity gives the direction switch ($sort) { case 1: $sortcmp = 'return strcasecmp($a[0],$b[0]);'; break; case -1: $sortcmp = 'return strcasecmp($b[0],$a[0]);'; break; case 2: $sortcmp = 'return ($a[1] - $b[1]);'; break; case -2: $sortcmp = 'return ($b[1] - $a[1]);'; break; case 3: $sortcmp = 'return ($a[2] - $b[2]);'; break; case -3: $sortcmp = 'return ($b[2] - $a[2]);'; break; } // Create a 2D array of directories and sort $dirdetails = array(); foreach ($dirlist as $name => $dir) { $dirdetails[$name] = new stdClass(); $dirdetails[$name]->updated = docdate($dir); $dirdetails[$name]->link = $dir->alternateLink; // usort($dirdetails, create_function('$a,$b', $sortcmp)); } // TODO: change to handle cross-listed courses // TODO: this needs to change if we eliminate morsle table if ($wdir === '') { $shortname = is_number(substr($course->shortname, 0, 5)) ? substr($course->shortname, 6) : $course->shortname; // SPLIT INTO DEPARTMENTAL CODES $dept = explode("-", $shortname); $deptpart = defined($dept[0]) ? CONSTANT($dept[0]) : null; $deptstr = $deptpart . $deptstr; $deptaccount = strtolower($deptstr); // only show the user collection if we're in the base folder $dirdetails[$userstr] = new stdClass(); $dirdetails[$userstr]->updated = date('Y-m-d'); $dirdetails[$userstr]->link = 'https://drive.google.com'; // always include departmental directory if exists // check to see if we even have a departmental account for this department but don't show the departmental collection if we're already in it indicated by $wdir if ($is_morsle_dept = $DB->get_record('morsle_active', array('shortname' => $deptaccount)) && has_capability('moodle/course:update', $coursecontext)) { $dirdetails[$deptstr] = new stdClass(); $dirdetails[$deptstr]->updated = date('Y-m-d'); } } // Create a 2D array of files and sort $filedetails = array(); $filetitles = array(); foreach ($filelist as $name => $file) { $filedetails[$name] = new stdClass(); $filedetails[$name]->updated = docdate($file); $filedetails[$name]->link = $file->alternateLink; // $row = array($filename, $filedate); // array_push($filedetails, $row); // usort($filedetails, create_function('$a,$b', $sortcmp)); } // TODO: fix this hack so we're back to being able to sort // ksort($filedetails); // sets the locked in sorting to name // need this in order to look up the link for the file based on doc title (key) /* if (sizeof($filelist) > 0) { $filevalues = array_values($filelist); $filelist = array_combine($filetitles, $filevalues); } */ // $count = 0; // $countdir = 0; $edittext = $padchoose . $padedit . $padunzip . $padlist . $padrestore; if ($wdir !== '') { $pathparts = explode('/', $wdir); array_pop($pathparts); $wdir = implode('/', $pathparts); echo "<tr class=\"folder\">"; print_cell(); print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '&choose=' . $choose . '&name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" /> ' . get_string('parentfolder') . '</a>', 'name'); // print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid='.$courseid.'&wdir='.$wdir.'/&choose='.$choose.'"> '.get_string('parentfolder').'</a>', 'parent'); echo "</tr>"; } if (!empty($dirdetails)) { foreach ($dirdetails as $name => $dir) { echo html_writer::start_tag('tr', array('class' => 'folder')); $filedate = $dir->updated; $filesafe = rawurlencode($name); $filename = $name; $fileurl = $dir->link; // $countdir++; // TODO: fix the parent directory if ($name == '..') { // $fileurl = rawurlencode(dirname($wdir)); print_cell(); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '/' . $fileurl . '&choose=' . $choose . '"><img src="' . $OUTPUT->pix_url('f/parent.gif') . '" class="icon" alt="" /> ' . get_string('parentfolder') . '</a>', 'name'); print_cell(); print_cell(); print_cell(); /* } else if ($name === $userstr) { // if departmental account or user collection // TODO: need to determine what $wdir is if we're coming in from one of the course subcollections // don't know where this fits in $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell(); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '&choose=' . $choose .'&name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" /> '. $name .'</a>', 'name'); // print_cell('left', '<a style="padding-left:0px" href="' . $fileurl . '" target="_blank"><img src="'. $OUTPUT->pix_url("f/folder") .'" class="icon" alt="" /> '. $filename .'</a>'); print_cell("right", $filedate, 'date'); // print_cell(); print_cell(); // print_cell(); } else if ($name === $deptstr){ // TODO: need to determine what $wdir is if we're coming in from one of the course subcollections $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell("center", "<input type=\"checkbox\" name=\"dir$countdir\" value=\"$filename\" />", 'checkbox'); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $branchdir . '&choose=' . $choose . '&name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" /> '. $name .'</a>', 'name'); print_cell("right", $filedate, 'date'); // print_cell(); if (has_capability('moodle/course:update', $coursecontext)) { print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&wdir=$branchdir&file=$filename&action=link&type=dir&choose=$choose\">$strlinktocourse</a>", 'commands'); } // print_cell(); */ } else { // not a user or departmental folder print_cell(); // print_cell("center", "<input type=\"checkbox\" name=\"$name\" value=\"$filename\" />", 'checkbox'); // print_cell("left", "<a href=\"morslefiles.php?courseid=$courseid&wdir=$wdir/$filesafe&choose=$choose\"><img src=\"$OUTPUT->pix_url('f/folder')\" class=\"icon\" alt=\"$strfolder\" /> ".$filename."</a>", 'name'); $branchdir = "{$wdir}/{$filesafe}"; // $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $branchdir . '&choose=' . $choose . '&name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" /> ' . $filename . '</a>', 'name'); print_cell("right", $filedate, 'date'); // print_cell(); if (has_capability('moodle/course:update', $coursecontext)) { print_cell("left", "{$edittext}<a href=\"morslefiles.php?courseid={$courseid}&wdir={$branchdir}&file={$filename}&action=link&type=dir&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); // print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&wdir=$wdir&file=$filename&action=link&type=dir&choose=$choose\">$strlinktocourse</a>", 'commands'); } } echo html_writer::end_tag('tr'); } } $iconchoices = array('excel' => 'download/spreadsheets', 'powerpoint' => 'download/presentations', 'word' => 'download/documents', 'pdf' => 'application/pdf'); if (!empty($filedetails)) { foreach ($filedetails as $name => $file) { if (isset($filelist[$name]->exportLinks)) { $links = array(); $links = array_values($filelist[$name]->exportLinks); $exportlink = $links[0]; } else { $exportlink = $filelist[$name]->alternateLink; } // positively identify the correct icon regardless of filename extension $icon = $filelist[$name]->iconLink; $filename = $name; $fileurl = $file->link; $embedlink = $filelist[$name]->embedLink; $embedsafe = rawurlencode($embedlink); $fileurlsafe = rawurlencode($fileurl); $filedate = $file->updated; $fileid = $filelist[$name]->id; $selectfile = trim($fileurl, "/"); // echo html_writer::start_tag('td', array('class'=>'file')); // echo html_writer::end_tag('td'); print_cell("center", "<input type=\"checkbox\" name=\"file\" value=\"{$filename}\" />", 'checkbox'); //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 // echo html_writer::start_tag('td', array('align'=>'left','style'=>'white-space:nowrap; padding-left:0px;','class'=>'name')); print_cell('left', '<a href="' . $fileurl . '" class="morslefile" target="_blank"> <img src="' . $icon . '" class="icon" alt="' . $strfile . '" /> ' . $filename . '</a>', 'name'); // $echovar = '<a href="' . $fileurl . '" target="_blank"> // <img src="' . $OUTPUT->pix_url("f/$icon") . '" class="icon" alt="' . $strfile . '" /> ' . htmlspecialchars($filename) . '</a>'; // echo $echovar; //html_writer::link(qualified_me(), $strname, array('&sort'=>'{'.$sortvalues[0].'}')) //$echovar = html_writer::tag('a', $fileurl, array('target'=>'_blank')) . html_writer::img($OUTPUT->pix_url("f/$icon"), $strfile, array('class'=>'icon')) . ' '.htmlspecialchars($filename) . html_writer::end_tag('a'); //echo $echovar; // echo html_writer::end_tag('td'); print_cell("right", $filedate, 'date'); if (has_capability('moodle/course:update', $coursecontext)) { if (strpos($wdir, $gdocsstr) === 1) { print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&wdir={$wdir}/{$fileid}&file={$filename}&name={$filename}&filelink={$fileurl}&action=link&type=file&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); } else { print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&wdir={$wdir}&file={$filename}&action=link&type=file&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); } // print_cell('left', '  <a title="' . $name . '" href="embeddoc.php?courseid=$courseid&embedlink=' . $embedsafe . '&name=' . $filename . '"> Embed </a>','embed'); } // print_cell('left', '  <a title="' . strip_tags($strdownload) . ': ' . $name . '" href="' .$CFG->wwwroot // . '/blocks/morsle/docs_export.php?exportlink=' . s($exportlink) . '&shortname=' . $course->shortname . '&title=' . $filename . '" target="_blank"> Download </a>','commands'); print_cell(); print_cell('left', '  <a title="' . $name . '" href="' . s($exportlink) . '" target="_blank"> Download </a>', 'commands'); //print_cell('left', '  <a title="' . $name . '" href="embeddoc.php?"' . s($embedlink) . '" target="_blank"> Embed in a Page resource </a>','commands'); echo html_writer::end_tag('tr'); } } echo html_writer::end_div(); echo html_writer::end_tag('form'); echo html_writer::end_tag('table'); }
// Trim whitespace off search query $query = urldecode(trim($query)); // Clean query to remove xss vulnerabilities // urlencoded parameters will be missed by standard optional_param cleaning, so need to double-check after decoding // e.g. a urlencoded <script> in the query will appear to optional_param as %3Cscript%3E and be ignored $query = clean_param($query, PARAM_TEXT); // This url $data = array( 'search' => true, 'query' => urlencode($query), 'searchtype' => $searchtype, 'page' => $page ); $thisurl = new moodle_url(strip_querystring(qualified_me()), array_merge($data, $this->urlparams)); // Extra form data $formdata = array( 'hidden' => $this->urlparams, 'query' => $query, 'searchtype' => $searchtype ); // Generate SQL // Search SQL information $search_info = new stdClass(); $search_info->id = 'id'; $search_info->fullname = 'fullname'; $search_info->sql = null;
function definition() { global $CFG, $USER, $DB, $COURSE, $OUTPUT; $mform =& $this->_form; // Don't forget the underscore! //add_enrolled_users($this->context); $mform->addElement('header', 'general', get_string('manageworkers', 'block_timetracker')); $mform->addHelpButton('general', 'manageworkers', 'block_timetracker'); $stractive = get_string('active', 'block_timetracker'); $strfirstname = get_string('firstname', 'block_timetracker'); $strlastname = get_string('lastname', 'block_timetracker'); $stremail = get_string('email', 'block_timetracker'); $me = new moodle_url(qualified_me()); $me->params(array('reload' => true)); $canview = false; if (has_capability('block/timetracker:viewonly', $this->context)) { $canview = true; } $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } if ($canmanage) { $reloadaction = $OUTPUT->action_icon($me, new pix_icon('refresh', 'Refresh worker list', 'block_timetracker')); $mform->addElement('html', $reloadaction . ' ' . $OUTPUT->action_link($me, 'Refresh worker list')); } $mform->addElement('html', '<table align="center" border="1" cellspacing="10px" ' . 'cellpadding="5px" width="75%">'); $mform->addElement('html', '<tr> <td style="font-weight: bold">' . $stractive . '</td> <td style="font-weight: bold">Worker name</td> <td style="font-weight: bold">' . $stremail . '</td> <td style="font-weight: bold; text-align: center">' . get_string('action') . '</td> </tr>'); if (!($workers = $DB->get_records('block_timetracker_workerinfo', array('courseid' => $COURSE->id), 'lastname ASC, firstname ASC'))) { $mform->addElement('html', '<tr><td colspan="4" style="text-align: center">No workers registered' . '</td></tr></table>'); } else { $canactivate = false; if (has_capability('block/timetracker:activateworkers', $this->context)) { $canactivate = true; } foreach ($workers as $worker) { $mform->addElement('html', '<tr><td>'); if ($worker->active) { if ($canactivate) { $mform->addElement('advcheckbox', 'activeid[' . $worker->id . ']', '', null, array('checked="checked"', 'group' => 1)); } else { $mform->addElement('advcheckbox', 'activeid[' . $worker->id . ']', '', null, array('checked="checked"', 'disabled="disabled"', 'group' => 1)); } } else { if ($canactivate) { $mform->addElement('advcheckbox', 'activeid[' . $worker->id . ']', '', null, array('group' => 1)); } else { $mform->addElement('advcheckbox', 'activeid[' . $worker->id . ']', '', null, array('disabled="disabled"', 'group' => 1)); } } $row = '</td>'; $row .= '<td>' . $worker->lastname . ', ' . $worker->firstname . '</td>'; $row .= '<td>' . $worker->email . '</td>'; $baseurl = $CFG->wwwroot . '/blocks/timetracker'; $urlparams['id'] = $COURSE->id; $urlparams['userid'] = $worker->id; $urlparams['sesskey'] = sesskey(); $deleteurl = new moodle_url($baseurl . '/deleteworker.php', $urlparams); $deleteicon = new pix_icon('user_delete', get_string('delete'), 'block_timetracker'); $deleteaction = $OUTPUT->action_icon($deleteurl, $deleteicon, new confirm_action('Are you sure you want to delete this worker and all this worker\'s' . ' work units?')); //don't need anymore unset($urlparams['sesskey']); $editurl = new moodle_url($baseurl . '/updateworkerinfo.php', $urlparams); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('user_edit', get_string('edit'), 'block_timetracker')); $reportsurl = new moodle_url($baseurl . '/reports.php', $urlparams); $reportsaction = $OUTPUT->action_icon($reportsurl, new pix_icon('report', 'Reports', 'block_timetracker')); $adduniturl = new moodle_url($baseurl . '/addunit.php', $urlparams); $addunitaction = $OUTPUT->action_icon($adduniturl, new pix_icon('clock_add', get_string('addentry', 'block_timetracker'), 'block_timetracker')); $timesheetsurl = new moodle_url($baseurl . '/viewtimesheets.php', $urlparams); $timesheetaction = $OUTPUT->action_icon($timesheetsurl, new pix_icon('date', 'View signed timesheets', 'block_timetracker')); $row .= '<td style="text-align: center">'; if ($canmanage) { $row .= $editaction . ' ' . $addunitaction . ' ' . $reportsaction . $timesheetaction; } else { $row .= $editaction . ' ' . $reportsaction . ' ' . $timesheetaction; //$row .= ' '; } $row .= '</td>'; $row .= '</tr>'; $mform->addElement('html', $row); $mform->addElement('hidden', 'workerid[' . $worker->id . ']', $worker->id); } if ($canactivate) { $this->add_checkbox_controller(1, null, null, 1); } $mform->addElement('html', '</table>'); $mform->addElement('hidden', 'id', $COURSE->id); if ($canmanage) { $this->add_action_buttons(false, 'Save Activation Changes'); } } }
/** * Must be called after table is defined. Use methods above first. Cannot * use functions below till after calling this method. * @return type? */ function setup() { global $SESSION, $CFG; if (empty($this->columns) || empty($this->uniqueid)) { return false; } if (!isset($SESSION->flextable)) { $SESSION->flextable = array(); } if (!isset($SESSION->flextable[$this->uniqueid])) { $SESSION->flextable[$this->uniqueid] = new stdClass(); $SESSION->flextable[$this->uniqueid]->uniqueid = $this->uniqueid; $SESSION->flextable[$this->uniqueid]->collapse = array(); $SESSION->flextable[$this->uniqueid]->sortby = array(); $SESSION->flextable[$this->uniqueid]->i_first = ''; $SESSION->flextable[$this->uniqueid]->i_last = ''; } $this->sess =& $SESSION->flextable[$this->uniqueid]; if (!empty($_GET[$this->request[ILP_TABLE_VAR_SHOW]]) && isset($this->columns[$_GET[$this->request[ILP_TABLE_VAR_SHOW]]])) { // Show this column $this->sess->collapse[$_GET[$this->request[ILP_TABLE_VAR_SHOW]]] = false; } else { if (!empty($_GET[$this->request[ILP_TABLE_VAR_HIDE]]) && isset($this->columns[$_GET[$this->request[ILP_TABLE_VAR_HIDE]]])) { // Hide this column $this->sess->collapse[$_GET[$this->request[ILP_TABLE_VAR_HIDE]]] = true; if (array_key_exists($_GET[$this->request[ILP_TABLE_VAR_HIDE]], $this->sess->sortby)) { unset($this->sess->sortby[$_GET[$this->request[ILP_TABLE_VAR_HIDE]]]); } } } // Now, update the column attributes for collapsed columns foreach (array_keys($this->columns) as $column) { if (!empty($this->sess->collapse[$column])) { $this->column_style[$column]['width'] = '10px'; } } if (!empty($_GET[$this->request[ILP_TABLE_VAR_SORT]]) && $this->is_sortable($_GET[$this->request[ILP_TABLE_VAR_SORT]]) && (isset($this->columns[$_GET[$this->request[ILP_TABLE_VAR_SORT]]]) || ($_GET[$this->request[ILP_TABLE_VAR_SORT]] == 'firstname' || $_GET[$this->request[ILP_TABLE_VAR_SORT]] == 'lastname') && isset($this->columns['fullname']))) { if (empty($this->sess->collapse[$_GET[$this->request[ILP_TABLE_VAR_SORT]]])) { if (array_key_exists($_GET[$this->request[ILP_TABLE_VAR_SORT]], $this->sess->sortby)) { // This key already exists somewhere. Change its sortorder and bring it to the top. $sortorder = $this->sess->sortby[$_GET[$this->request[ILP_TABLE_VAR_SORT]]] == SORT_ASC ? SORT_DESC : SORT_ASC; unset($this->sess->sortby[$_GET[$this->request[ILP_TABLE_VAR_SORT]]]); $this->sess->sortby = array_merge(array($_GET[$this->request[ILP_TABLE_VAR_SORT]] => $sortorder), $this->sess->sortby); } else { // Key doesn't exist, so just add it to the beginning of the array, ascending order $this->sess->sortby = array_merge(array($_GET[$this->request[ILP_TABLE_VAR_SORT]] => SORT_ASC), $this->sess->sortby); } // Finally, make sure that no more than $this->maxsortkeys are present into the array if (!empty($this->maxsortkeys) && ($sortkeys = count($this->sess->sortby)) > $this->maxsortkeys) { while ($sortkeys-- > $this->maxsortkeys) { array_pop($this->sess->sortby); } } } } // If we didn't sort just now, then use the default sort order if one is defined and the column exists if (empty($this->sess->sortby) && !empty($this->sort_default_column)) { $this->sess->sortby = array($this->sort_default_column => $this->sort_default_order == SORT_DESC ? SORT_DESC : SORT_ASC); } if (isset($_GET[$this->request[ILP_TABLE_VAR_ILAST]])) { if (empty($_GET[$this->request[ILP_TABLE_VAR_ILAST]]) || is_numeric(strpos(get_string('alphabet'), $_GET[$this->request[ILP_TABLE_VAR_ILAST]]))) { $this->sess->i_last = $_GET[$this->request[ILP_TABLE_VAR_ILAST]]; } } if (isset($_GET[$this->request[ILP_TABLE_VAR_IFIRST]])) { if (empty($_GET[$this->request[ILP_TABLE_VAR_IFIRST]]) || is_numeric(strpos(get_string('alphabet'), $_GET[$this->request[ILP_TABLE_VAR_IFIRST]]))) { $this->sess->i_first = $_GET[$this->request[ILP_TABLE_VAR_IFIRST]]; } } if (empty($this->baseurl)) { $getcopy = $_GET; unset($getcopy[$this->request[ILP_TABLE_VAR_SHOW]]); unset($getcopy[$this->request[ILP_TABLE_VAR_HIDE]]); unset($getcopy[$this->request[ILP_TABLE_VAR_SORT]]); unset($getcopy[$this->request[ILP_TABLE_VAR_IFIRST]]); unset($getcopy[$this->request[ILP_TABLE_VAR_ILAST]]); unset($getcopy[$this->request[ILP_TABLE_VAR_PAGE]]); $strippedurl = strip_querystring(qualified_me()); if (!empty($getcopy)) { $first = false; $querystring = ''; foreach ($getcopy as $var => $val) { if (!$first) { $first = true; $querystring .= '?' . $var . '=' . $val; } else { $querystring .= '&' . $var . '=' . $val; } } $this->reseturl = $strippedurl . $querystring; $querystring .= '&'; } else { $this->reseturl = $strippedurl; $querystring = '?'; } $this->baseurl = strip_querystring(qualified_me()) . $querystring; } // If it's "the first time" we 've been here, forget the previous initials filters if (qualified_me() == $this->reseturl) { $this->sess->i_first = ''; $this->sess->i_last = ''; } $this->currpage = optional_param($this->request[ILP_TABLE_VAR_PAGE], 0, PARAM_INT); $this->setup = true; /// Always introduce the "flexible" class for the table if not specified /// No attributes, add flexible class if (empty($this->attributes)) { $this->attributes['class'] = 'flexible'; /// No classes, add flexible class } else { if (!isset($this->attributes['class'])) { $this->attributes['class'] = 'flexible'; /// No flexible class in passed classes, add flexible class } else { if (!in_array('flexible', explode(' ', $this->attributes['class']))) { $this->attributes['class'] = trim('flexible ' . $this->attributes['class']); } } } }
/** * Create grade item for given quiz * * @param object $quiz object with extra cmidnumber * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook * @return int 0 if ok, error code otherwise */ function quiz_grade_item_update($quiz, $grades = NULL) { global $CFG; if (!function_exists('grade_update')) { //workaround for buggy PHP versions require_once $CFG->libdir . '/gradelib.php'; } if (array_key_exists('cmidnumber', $quiz)) { //it may not be always present $params = array('itemname' => $quiz->name, 'idnumber' => $quiz->cmidnumber); } else { $params = array('itemname' => $quiz->name); } if ($quiz->grade > 0) { $params['gradetype'] = GRADE_TYPE_VALUE; $params['grademax'] = $quiz->grade; $params['grademin'] = 0; } else { $params['gradetype'] = GRADE_TYPE_NONE; } /* description by TJ: 1/ If the quiz is set to not show scores while the quiz is still open, and is set to show scores after the quiz is closed, then create the grade_item with a show-after date that is the quiz close date. 2/ If the quiz is set to not show scores at either of those times, create the grade_item as hidden. 3/ If the quiz is set to show scores, create the grade_item visible. */ if (!($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED) and !($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN)) { $params['hidden'] = 1; } else { if ($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED and !($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN)) { if ($quiz->timeclose) { $params['hidden'] = $quiz->timeclose; } else { $params['hidden'] = 1; } } else { // a) both open and closed enabled // b) open enabled, closed disabled - we can not "hide after", grades are kept visible even after closing $params['hidden'] = 0; } } if ($grades === 'reset') { $params['reset'] = true; $grades = NULL; } $gradebook_grades = grade_get_grades($quiz->course, 'mod', 'quiz', $quiz->id); if (!empty($gradebook_grades->items)) { $grade_item = $gradebook_grades->items[0]; if ($grade_item->locked) { $confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT); if (!$confirm_regrade) { $message = get_string('gradeitemislocked', 'grades'); $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id . '&mode=overview'; $regrade_link = qualified_me() . '&confirm_regrade=1'; print_box_start('generalbox', 'notice'); echo '<p>' . $message . '</p>'; echo '<div class="buttons">'; print_single_button($regrade_link, null, get_string('regradeanyway', 'grades'), 'post', $CFG->framename); print_single_button($back_link, null, get_string('cancel'), 'post', $CFG->framename); echo '</div>'; print_box_end(); return GRADE_UPDATE_ITEM_LOCKED; } } } return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0, $grades, $params); }
/** * Prints inputs required for bulk edit checkbox persistence. * @param array $ids An array of IDs to note as checked. * @param int $classid The ID of the class the IDs belong to. * @param string $page The page type they're checked on. (ex. stu) * @param string $target The page section they're checked on. (ex. bulkedit) */ function print_ids_for_checkbox_selection($ids, $classid, $page, $target) { $baseurl = get_pm_url()->out_omit_querystring() . '?&id=' . $classid . '&s=' . $page . '&target=' . $target; echo '<input type="hidden" id="baseurl" value="' . $baseurl . '" /> '; echo '<input type="hidden" id="selfurl" value="' . qualified_me() . '" /> '; $result = implode(',', $ids); echo '<input type="hidden" id="persist_ids_this_page" value="' . $result . '" /> '; }
/** * 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, $SCRIPT; if (during_initial_install()) { // Debugging info can not work before install is finished, // in any case we do not want any links during installation! return ''; } // This function is normally called from a layout.php file in {@link core_renderer::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 core_renderer::footer()}. $output = $this->unique_performance_info_token; if ($this->page->devicetypeinuse == 'legacy') { // The legacy theme is in use print the notification $output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse')); } // Get links to switch device types (only shown for users not on a default device) $output .= $this->theme_switch_links(); if (!empty($CFG->debugpageinfo)) { $output .= '<div class="performanceinfo pageinfo">This page is: ' . $this->page->debug_summary() . '</div>'; } if (debugging(null, DEBUG_DEVELOPER) and has_capability('moodle/site:config', context_system::instance())) { // Only in developer mode // Add link to profiling report if necessary if (function_exists('profiling_is_running') && profiling_is_running()) { $txt = get_string('profiledscript', 'admin'); $title = get_string('profiledscriptview', 'admin'); $url = $CFG->wwwroot . '/admin/tool/profiling/index.php?script=' . urlencode($SCRIPT); $link= '<a title="' . $title . '" href="' . $url . '">' . $txt . '</a>'; $output .= '<div class="profilingfooter">' . $link . '</div>'; } $purgeurl = new moodle_url('/admin/purgecaches.php', array('confirm' => 1, 'sesskey' => sesskey(), 'returnurl' => $this->page->url->out_as_local_url(false))); $output .= '<div class="purgecaches">' . html_writer::link($purgeurl, get_string('purgecaches', 'admin')) . '</div>'; } if (!empty($CFG->debugvalidators)) { // NOTE: this is not a nice hack, $PAGE->url is not always accurate and $FULLME neither, it is not a bug if it fails. --skodak $output .= '<div class="validators"><ul> <li><a href="http://validator.w3.org/check?verbose=1&ss=1&uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li> <li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li> </ul></div>'; } return $output; }
notice(get_string('noviewdiscussionspermission', 'forum')); } /// find out current groups mode groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/forum/view.php?id=' . $cm->id); $currentgroup = groups_get_activity_group($cm); $groupmode = groups_get_activity_groupmode($cm); /// Okay, we can show the discussions. Log the forum view. if ($cm->id) { add_to_log($course->id, "forum", "view forum", "view.php?id=$cm->id", "$forum->id", $cm->id); } else { add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id"); } $SESSION->fromdiscussion = qualified_me(); // Return here if we post or set subscription etc /// Print settings and things across the top // If it's a simple single discussion forum, we need to print the display // mode control. if ($forum->type == 'single') { $discussion = NULL; $discussions = $DB->get_records('forum_discussions', array('forum'=>$forum->id), 'timemodified ASC'); if (!empty($discussions)) { $discussion = array_pop($discussions); } if ($discussion) { if ($mode) { set_user_preference("forum_displaymode", $mode);
/** * Default behavior: print the config_instance.html file * You don't need to override this if you're satisfied with the above * * @deprecated since Moodle 2.0. * @return boolean whether anything was done. Blocks should use edit_form.php. */ function instance_config_print() { global $CFG, $DB, $OUTPUT; // Default behavior: print the config_instance.html file // You don't need to override this if you're satisfied with the above if (!$this->instance_allow_multiple() && !$this->instance_allow_config()) { return false; } if (is_file($CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html')) { echo $OUTPUT->box_start('generalbox boxaligncenter blockconfiginstance'); include $CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html'; echo $OUTPUT->box_end(); } else { notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me())); } return true; }
$options = choice_prepare_options($choice, $USER, $cm, $allresponses); $renderer = $PAGE->get_renderer('mod_choice'); echo $renderer->display_options($options, $cm->id, $choice->display, $choice->allowmultiple); $choiceformshown = true; } else { $choiceformshown = false; } if (!$choiceformshown) { $sitecontext = context_system::instance(); if (isguestuser()) { // Guest account echo $OUTPUT->confirm(get_string('noguestchoose', 'choice') . '<br /><br />' . get_string('liketologin'), get_login_url(), new moodle_url('/course/view.php', array('id' => $course->id))); } else { if (!is_enrolled($context)) { // Only people enrolled can make a choice $SESSION->wantsurl = qualified_me(); $SESSION->enrolcancel = get_local_referer(false); $coursecontext = context_course::instance($course->id); $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); echo $OUTPUT->box_start('generalbox', 'notice'); echo '<p align="center">' . get_string('notenrolledchoose', 'choice') . '</p>'; echo $OUTPUT->container_start('continuebutton'); echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id' => $course->id)), get_string('enrolme', 'core_enrol', $courseshortname)); echo $OUTPUT->container_end(); echo $OUTPUT->box_end(); } } } // print the results at the bottom of the screen if (choice_can_view_results($choice, $current, $choiceopen)) { if (!empty($choice->showunanswered)) {
$CFG->tbl_uebsprach = "otmp_UebersetzerSprachen"; $CFG->tbl_programm = "otmp_Programm"; $CFG->tbl_kategorie = "otmp_Kategorie"; $CFG->tbl_adresse = "otmp_Adresse"; $CFG->tbl_optionen = "otmp_Optionen"; $CFG->tbl_auftrag = "otmp_Auftrag"; $CFG->tbl_text = "otmp_Text"; $CFG->tbl_konto = "otmp_Konto"; $CFG->tbl_systemkonto = "otmp_SystemKonto"; $CFG->tbl_bankkonto = "otmp_BankKonto"; $CFG->tbl_filetype = "otmp_Filetype"; $CFG->tbl_prgHasType = "otmp_PrgHasType"; /* define database error handling behavior, since we are in development stages * we will turn on all the debugging messages to help us troubleshoot */ $DB_DEBUG = true; $DB_DIE_ON_FAIL = true; /* load up standard libraries */ require "{$CFG->libdir}/stdlib.php"; require "{$CFG->libdir}/dblib.php"; require "{$CFG->libdir}/otmplib.php"; require "{$CFG->libdir}/sql.php"; /* setup some global variables */ $ME = qualified_me(); /* start up the sessions, to keep things clean and manageable we will just * use one array called SESSION to store our persistent variables */ /* session_save_path($CFG->sspath); */ session_start(); session_register("session"); /* connect to the database */ db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass); set_magic_quotes_runtime(0);
/** * Default exception handler, uncaught exceptions are equivalent to error() in 1.9 and earlier * * @param Exception $ex * @return void -does not return. Terminates execution! */ function default_exception_handler($ex) { global $CFG, $DB, $OUTPUT, $USER, $FULLME, $SESSION, $PAGE; // detect active db transactions, rollback and log as error abort_all_db_transactions(); if ($ex instanceof required_capability_exception && !CLI_SCRIPT && !AJAX_SCRIPT && !empty($CFG->autologinguests) && !empty($USER->autologinguest)) { $SESSION->wantsurl = qualified_me(); redirect(get_login_url()); } $info = get_exception_info($ex); if (debugging('', DEBUG_MINIMAL)) { $logerrmsg = "Default exception handler: " . $info->message . ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true); error_log($logerrmsg); } if (is_early_init($info->backtrace)) { echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode); } else { try { if ($DB) { // If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish $DB->set_debug(0); } echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo); } catch (Exception $out_ex) { // default exception handler MUST not throw any exceptions!! // the problem here is we do not know if page already started or not, we only know that somebody messed up in outputlib or theme // so we just print at least something instead of "Exception thrown without a stack frame in Unknown on line 0":-( if (CLI_SCRIPT or AJAX_SCRIPT) { // just ignore the error and send something back using the safest method echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode); } else { echo bootstrap_renderer::early_error_content($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo); $outinfo = get_exception_info($out_ex); echo bootstrap_renderer::early_error_content($outinfo->message, $outinfo->moreinfourl, $outinfo->link, $outinfo->backtrace, $outinfo->debuginfo); } } } exit(1); // General error code }
/** * This function checks that the current user is logged in and has the * required privileges * * This function checks that the current user is logged in, and optionally * whether they are allowed to be in a particular course and view a particular * course module. * If they are not logged in, then it redirects them to the site login unless * $autologinguest is set and {@link $CFG}->autologinguests is set to 1 in which * case they are automatically logged in as guests. * If $courseid is given and the user is not enrolled in that course then the * user is redirected to the course enrolment page. * If $cm is given and the course module is hidden and the user is not a teacher * in the course then the user is redirected to the course home page. * * When $cm parameter specified, this function sets page layout to 'module'. * You need to change it manually later if some other layout needed. * * @package core_access * @category access * * @param mixed $courseorid id of the course or course object * @param bool $autologinguest default true * @param object $cm course module object * @param bool $setwantsurltome Define if we want to set $SESSION->wantsurl, defaults to * true. Used to avoid (=false) some scripts (file.php...) to set that variable, * in order to keep redirects working properly. MDL-14495 * @param bool $preventredirect set to true in scripts that can not redirect (CLI, rss feeds, etc.), throws exceptions * @return mixed Void, exit, and die depending on path * @throws coding_exception * @throws require_login_exception */ function require_login($courseorid = null, $autologinguest = true, $cm = null, $setwantsurltome = true, $preventredirect = false) { global $CFG, $SESSION, $USER, $PAGE, $SITE, $DB, $OUTPUT; // Must not redirect when byteserving already started. if (!empty($_SERVER['HTTP_RANGE'])) { $preventredirect = true; } if (AJAX_SCRIPT) { // We cannot redirect for AJAX scripts either. $preventredirect = true; } // Setup global $COURSE, themes, language and locale. if (!empty($courseorid)) { if (is_object($courseorid)) { $course = $courseorid; } else { if ($courseorid == SITEID) { $course = clone $SITE; } else { $course = $DB->get_record('course', array('id' => $courseorid), '*', MUST_EXIST); } } if ($cm) { if ($cm->course != $course->id) { throw new coding_exception('course and cm parameters in require_login() call do not match!!'); } // Make sure we have a $cm from get_fast_modinfo as this contains activity access details. if (!$cm instanceof cm_info) { // Note: nearly all pages call get_fast_modinfo anyway and it does not make any // db queries so this is not really a performance concern, however it is obviously // better if you use get_fast_modinfo to get the cm before calling this. $modinfo = get_fast_modinfo($course); $cm = $modinfo->get_cm($cm->id); } } } else { // Do not touch global $COURSE via $PAGE->set_course(), // the reasons is we need to be able to call require_login() at any time!! $course = $SITE; if ($cm) { throw new coding_exception('cm parameter in require_login() requires valid course parameter!'); } } // If this is an AJAX request and $setwantsurltome is true then we need to override it and set it to false. // Otherwise the AJAX request URL will be set to $SESSION->wantsurl and events such as self enrolment in the future // risk leading the user back to the AJAX request URL. if ($setwantsurltome && defined('AJAX_SCRIPT') && AJAX_SCRIPT) { $setwantsurltome = false; } // Redirect to the login page if session has expired, only with dbsessions enabled (MDL-35029) to maintain current behaviour. if ((!isloggedin() or isguestuser()) && !empty($SESSION->has_timed_out) && !empty($CFG->dbsessions)) { if ($preventredirect) { throw new require_login_session_timeout_exception(); } else { if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } redirect(get_login_url()); } } // If the user is not even logged in yet then make sure they are. if (!isloggedin()) { if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests)) { if (!($guest = get_complete_user_data('id', $CFG->siteguest))) { // Misconfigured site guest, just redirect to login page. redirect(get_login_url()); exit; // Never reached. } $lang = isset($SESSION->lang) ? $SESSION->lang : $CFG->lang; complete_user_login($guest); $USER->autologinguest = true; $SESSION->lang = $lang; } else { // NOTE: $USER->site check was obsoleted by session test cookie, $USER->confirmed test is in login/index.php. if ($preventredirect) { throw new require_login_exception('You are not logged in'); } if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } $referer = get_local_referer(false); if (!empty($referer)) { $SESSION->fromurl = $referer; } // Give auth plugins an opportunity to authenticate or redirect to an external login page $authsequence = get_enabled_auth_plugins(true); // auths, in sequence foreach ($authsequence as $authname) { $authplugin = get_auth_plugin($authname); $authplugin->pre_loginpage_hook(); if (isloggedin()) { break; } } // If we're still not logged in then go to the login page if (!isloggedin()) { redirect(get_login_url()); exit; // Never reached. } } } // Loginas as redirection if needed. if ($course->id != SITEID and \core\session\manager::is_loggedinas()) { if ($USER->loginascontext->contextlevel == CONTEXT_COURSE) { if ($USER->loginascontext->instanceid != $course->id) { print_error('loginasonecourse', '', $CFG->wwwroot . '/course/view.php?id=' . $USER->loginascontext->instanceid); } } } // Check whether the user should be changing password (but only if it is REALLY them). if (get_user_preferences('auth_forcepasswordchange') && !\core\session\manager::is_loggedinas()) { $userauth = get_auth_plugin($USER->auth); if ($userauth->can_change_password() and !$preventredirect) { if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } if ($changeurl = $userauth->change_password_url()) { // Use plugin custom url. redirect($changeurl); } else { // Use moodle internal method. if (empty($CFG->loginhttps)) { redirect($CFG->wwwroot . '/login/change_password.php'); } else { $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot); redirect($wwwroot . '/login/change_password.php'); } } } else { if ($userauth->can_change_password()) { throw new moodle_exception('forcepasswordchangenotice'); } else { throw new moodle_exception('nopasswordchangeforced', 'auth'); } } } // Check that the user account is properly set up. If we can't redirect to // edit their profile, perform just the lax check. It will allow them to // use filepicker on the profile edit page. if ($preventredirect) { $usernotfullysetup = user_not_fully_set_up($USER, false); } else { $usernotfullysetup = user_not_fully_set_up($USER, true); } if ($usernotfullysetup) { if ($preventredirect) { throw new moodle_exception('usernotfullysetup'); } if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } redirect($CFG->wwwroot . '/user/edit.php?id=' . $USER->id . '&course=' . SITEID); } // Make sure the USER has a sesskey set up. Used for CSRF protection. sesskey(); // Do not bother admins with any formalities. if (is_siteadmin()) { // Set the global $COURSE. if ($cm) { $PAGE->set_cm($cm, $course); $PAGE->set_pagelayout('incourse'); } else { if (!empty($courseorid)) { $PAGE->set_course($course); } } // Set accesstime or the user will appear offline which messes up messaging. user_accesstime_log($course->id); return; } // Check that the user has agreed to a site policy if there is one - do not test in case of admins. if (!$USER->policyagreed and !is_siteadmin()) { if (!empty($CFG->sitepolicy) and !isguestuser()) { if ($preventredirect) { throw new moodle_exception('sitepolicynotagreed', 'error', '', $CFG->sitepolicy); } if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } redirect($CFG->wwwroot . '/user/policy.php'); } else { if (!empty($CFG->sitepolicyguest) and isguestuser()) { if ($preventredirect) { throw new moodle_exception('sitepolicynotagreed', 'error', '', $CFG->sitepolicyguest); } if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } redirect($CFG->wwwroot . '/user/policy.php'); } } } // Fetch the system context, the course context, and prefetch its child contexts. $sysctx = context_system::instance(); $coursecontext = context_course::instance($course->id, MUST_EXIST); if ($cm) { $cmcontext = context_module::instance($cm->id, MUST_EXIST); } else { $cmcontext = null; } // If the site is currently under maintenance, then print a message. if (!empty($CFG->maintenance_enabled) and !has_capability('moodle/site:maintenanceaccess', $sysctx)) { if ($preventredirect) { throw new require_login_exception('Maintenance in progress'); } $PAGE->set_context(null); print_maintenance_message(); } // Make sure the course itself is not hidden. if ($course->id == SITEID) { // Frontpage can not be hidden. } else { if (is_role_switched($course->id)) { // When switching roles ignore the hidden flag - user had to be in course to do the switch. } else { if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) { // Originally there was also test of parent category visibility, BUT is was very slow in complex queries // involving "my courses" now it is also possible to simply hide all courses user is not enrolled in :-). if ($preventredirect) { throw new require_login_exception('Course is hidden'); } $PAGE->set_context(null); // We need to override the navigation URL as the course won't have been added to the navigation and thus // the navigation will mess up when trying to find it. navigation_node::override_active_url(new moodle_url('/')); notice(get_string('coursehidden'), $CFG->wwwroot . '/'); } } } // Is the user enrolled? if ($course->id == SITEID) { // Everybody is enrolled on the frontpage. } else { if (\core\session\manager::is_loggedinas()) { // Make sure the REAL person can access this course first. $realuser = \core\session\manager::get_realuser(); if (!is_enrolled($coursecontext, $realuser->id, '', true) and !is_viewing($coursecontext, $realuser->id) and !is_siteadmin($realuser->id)) { if ($preventredirect) { throw new require_login_exception('Invalid course login-as access'); } $PAGE->set_context(null); echo $OUTPUT->header(); notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot . '/'); } } $access = false; if (is_role_switched($course->id)) { // Ok, user had to be inside this course before the switch. $access = true; } else { if (is_viewing($coursecontext, $USER)) { // Ok, no need to mess with enrol. $access = true; } else { if (isset($USER->enrol['enrolled'][$course->id])) { if ($USER->enrol['enrolled'][$course->id] > time()) { $access = true; if (isset($USER->enrol['tempguest'][$course->id])) { unset($USER->enrol['tempguest'][$course->id]); remove_temp_course_roles($coursecontext); } } else { // Expired. unset($USER->enrol['enrolled'][$course->id]); } } if (isset($USER->enrol['tempguest'][$course->id])) { if ($USER->enrol['tempguest'][$course->id] == 0) { $access = true; } else { if ($USER->enrol['tempguest'][$course->id] > time()) { $access = true; } else { // Expired. unset($USER->enrol['tempguest'][$course->id]); remove_temp_course_roles($coursecontext); } } } if (!$access) { // Cache not ok. $until = enrol_get_enrolment_end($coursecontext->instanceid, $USER->id); if ($until !== false) { // Active participants may always access, a timestamp in the future, 0 (always) or false. if ($until == 0) { $until = ENROL_MAX_TIMESTAMP; } $USER->enrol['enrolled'][$course->id] = $until; $access = true; } else { $params = array('courseid' => $course->id, 'status' => ENROL_INSTANCE_ENABLED); $instances = $DB->get_records('enrol', $params, 'sortorder, id ASC'); $enrols = enrol_get_plugins(true); // First ask all enabled enrol instances in course if they want to auto enrol user. foreach ($instances as $instance) { if (!isset($enrols[$instance->enrol])) { continue; } // Get a duration for the enrolment, a timestamp in the future, 0 (always) or false. $until = $enrols[$instance->enrol]->try_autoenrol($instance); if ($until !== false) { if ($until == 0) { $until = ENROL_MAX_TIMESTAMP; } $USER->enrol['enrolled'][$course->id] = $until; $access = true; break; } } // If not enrolled yet try to gain temporary guest access. if (!$access) { foreach ($instances as $instance) { if (!isset($enrols[$instance->enrol])) { continue; } // Get a duration for the guest access, a timestamp in the future or false. $until = $enrols[$instance->enrol]->try_guestaccess($instance); if ($until !== false and $until > time()) { $USER->enrol['tempguest'][$course->id] = $until; $access = true; break; } } } } } } } if (!$access) { if ($preventredirect) { throw new require_login_exception('Not enrolled'); } if ($setwantsurltome) { $SESSION->wantsurl = qualified_me(); } redirect($CFG->wwwroot . '/enrol/index.php?id=' . $course->id); } } // Check visibility of activity to current user; includes visible flag, conditional availability, etc. if ($cm && !$cm->uservisible) { if ($preventredirect) { throw new require_login_exception('Activity is hidden'); } if ($course->id != SITEID) { $url = new moodle_url('/course/view.php', array('id' => $course->id)); } else { $url = new moodle_url('/'); } redirect($url, get_string('activityiscurrentlyhidden')); } // Set the global $COURSE. if ($cm) { $PAGE->set_cm($cm, $course); $PAGE->set_pagelayout('incourse'); } else { if (!empty($courseorid)) { $PAGE->set_course($course); } } // Finally access granted, update lastaccess times. user_accesstime_log($course->id); }