/** * Comment wall initialisation. */ function commentwall_init() { global $CFG, $db, $function, $metatags, $template; // Add meta tags $metatags .= "<script type=\"text/javascript\" src=\"{$CFG->wwwroot}mod/commentwall/commentwall.js\"><!-- commentwall js --></script>"; // Define some templates templates_add_context('commentwallobject', 'mod/commentwall/template'); templates_add_context('commentwallfooter', 'mod/commentwall/footer'); templates_add_context('css', 'mod/commentwall/css'); // Set up the database $tables = $db->Metatables(); if (!in_array($CFG->prefix . "commentwall", $tables)) { if (file_exists($CFG->dirroot . "mod/commentwall/{$CFG->dbtype}.sql")) { modify_database($CFG->dirroot . "mod/commentwall/{$CFG->dbtype}.sql"); //reload system header_redirect($CFG->wwwroot); } else { error("Error: Your database ({$CFG->dbtype}) is not yet fully supported by the Elgg commentwall. See the mod/commentwall directory."); } print_continue($CFG->wwwroot); exit; } // Add configuration options $function['userdetails:edit:details'][] = $CFG->dirroot . "mod/commentwall/lib/commentwall_settings.php"; }
function generic_comments_init() { global $CFG, $db, $function, $metatags, $template; $metatags .= "<script type=\"text/javascript\" src=\"{$CFG->wwwroot}mod/generic_comments/generic_comments.js\"><!-- generic_comments js --></script>"; // create the generic_comments and generic watchlist table $tables = $db->Metatables(); if (!in_array($CFG->prefix . "comments", $tables) || !in_array($CFG->prefix . "watchlist", $tables)) { if (file_exists($CFG->dirroot . "mod/generic_comments/{$CFG->dbtype}.sql")) { modify_database($CFG->dirroot . "mod/generic_comments/{$CFG->dbtype}.sql"); //reload system header_redirect($CFG->wwwroot); } else { error("Error: Your database ({$CFG->dbtype}) is not yet fully supported by the Elgg generic comments. See the mod/generic_comments directory."); } print_continue("index.php"); exit; } $function['comments:init'][] = $CFG->dirroot . "mod/generic_comments/comments_actions.php"; $function['permissions:check'][] = $CFG->dirroot . "mod/generic_comments/permissions_check.php"; // Add annotation support display_set_display_annotation_function("file::file", "generic_comments_displayobjectannotations"); display_set_display_annotation_function("mediastream::media", "generic_comments_displayobjectannotations"); // Register file river hook (if there) if (function_exists('river_save_event')) { river_register_friendlyname_hook('file::file', 'generic_comments_get_friendly_name'); } templates_add_context('embeddedcomments', 'mod/generic_comments/comments'); templates_add_context('embeddedcomment', 'mod/generic_comments/comment'); templates_add_context('css', 'mod/generic_comments/css', true, false); }
function apply($discussion, $all, $selected, $formdata) { global $COURSE, $USER, $CFG; // Begin with standard text $a = (object) array('name' => fullname($USER, true)); $allhtml = "<head>"; foreach ($CFG->stylesheets as $stylesheet) { $allhtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n"; } $allhtml .= "</head>\n<body id='forumng-email'>\n"; $preface = get_string('forward_preface', 'forumng', $a); $allhtml .= $preface; $alltext = format_text_email($preface, FORMAT_HTML); // Include intro if specified if (!preg_match('~^(<br[^>]*>|<p>|</p>|\\s)*$~', $formdata->message)) { $alltext .= "\n" . forum_cron::EMAIL_DIVIDER . "\n"; $allhtml .= '<hr size="1" noshade="noshade" />'; // Add intro $message = trusttext_strip(stripslashes($formdata->message)); $allhtml .= format_text($message, $formdata->format); $alltext .= format_text_email($message, $formdata->format); } // Get list of all post ids in discussion order $alltext .= "\n" . forum_cron::EMAIL_DIVIDER . "\n"; $allhtml .= '<hr size="1" noshade="noshade" />'; $poststext = ''; $postshtml = ''; $discussion->build_selected_posts_email($selected, $poststext, $postshtml); $alltext .= $poststext; $allhtml .= $postshtml . '</body>'; $emails = preg_split('~[; ]+~', $formdata->email); $subject = stripslashes($formdata->subject); foreach ($emails as $email) { $fakeuser = (object) array('email' => $email, 'mailformat' => 1, 'id' => 0); $from = $USER; $from->maildisplay = 999; // Nasty hack required for OU moodle if (!email_to_user($fakeuser, $from, $subject, $alltext, $allhtml)) { print_error('error_forwardemail', 'forumng', $formdata->email); } } // Log that it was sent $discussion->log('forward discussion', $formdata->email); if (!empty($formdata->ccme)) { if (!email_to_user($USER, $from, $subject, $alltext, $allhtml)) { print_error('error_forwardemail', 'forumng', $USER->email); } } $discussion->print_subpage_header($this->get_page_name()); print_box(get_string('forward_done', 'forumng')); print_continue('../../discuss.php?' . $discussion->get_link_params(forum::PARAM_PLAIN)); print_footer($COURSE); }
/** * * Enter description here ... * @param unknown_type $blended * @param $USER $user */ function search_quiz_attempts_regs($blended, $user) { global $DB; //print_object($USER); $quiz_attempts = null; // $quiz_attempts = get_records($table='quiz_attempts', $field='userid', $value=$user->id,'timefinish DESC'); $quiz_attempts = $DB->get_records('quiz_attempts', array('userid' => 'timefinish DESC')); if ($quiz_attempts == null) { echo "<center>"; echo 'No se han encontrado cuestionarios evaluados para este usuario.'; echo "</center>"; $continue = "../../course/view.php?id={$blended->course}"; print_continue($continue); //debugging('No se han encontrado cuestionarios evaluados para este usuario.'); } return $quiz_attempts; }
function csverror($message, $link = '') { global $CFG, $SESSION; print_header(get_string('error')); echo '<br />'; $message = clean_text($message); print_simple_box('<span style="font-family:monospace;color:#000000;">' . $message . '</span>', 'center', '', '#FFBBBB', 5, 'errorbox'); if (!$link) { if (!empty($SESSION->fromurl)) { $link = $SESSION->fromurl; unset($SESSION->fromurl); } else { $link = $CFG->wwwroot . '/'; } } print_continue($link); print_footer(); die; }
function widget_init() { global $CFG, $function, $db, $METATABLES; $function['init'][] = $CFG->dirroot . "mod/widget/init.php"; // Initialise the 'allcontent' widget array - i.e., widgets where Javascript is allowed if (!isset($CFG->widgets->allcontent)) { $CFG->widgets->allcontent = array(); } // register the widgets that this module provides $CFG->widgets->list[] = array('name' => gettext("Text box"), 'description' => gettext("Displays the text of your choice."), 'type' => "widget::text"); if (!in_array($CFG->prefix . "widget_data", $METATABLES) || !in_array($CFG->prefix . "widgets", $METATABLES)) { if (file_exists($CFG->dirroot . "mod/widget/{$CFG->dbtype}.sql")) { modify_database($CFG->dirroot . "mod/widget/{$CFG->dbtype}.sql"); //reload system header_redirect($CFG->wwwroot); } else { error("Error: Your database ({$CFG->dbtype}) is not yet fully supported by the Elgg widgets. See the mod/widget directory."); } print_continue("index.php"); exit; } // Delete users listen_for_event("user", "delete", "widget_user_delete"); }
$search = optional_param('search', '', PARAM_RAW); $replace = optional_param('replace', '', PARAM_RAW); ################################################################### admin_externalpage_print_header(); print_heading('Search and replace text throughout the whole database'); if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form print_simple_box_start('center'); echo '<div align="center">'; echo '<form action="replace.php" method="post">'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; echo 'Search whole database for: <input type="text" name="search" /><br />'; echo 'Replace with this string: <input type="text" name="replace" /><br />'; echo '<input type="submit" value="Yes, do it now" /><br />'; echo '</form>'; echo '</div>'; print_simple_box_end(); admin_externalpage_print_footer(); die; } print_simple_box_start('center'); if (!db_replace($search, $replace)) { error('An error has occured during this process'); } print_simple_box_end(); /// Rebuild course cache which might be incorrect now notify('Rebuilding course cache...'); rebuild_course_cache(); notify('...finished'); print_continue('index.php'); admin_externalpage_print_footer();
function upgrade_blocks_plugins($continueto) { global $CFG, $db; $blocktitles = array(); $invalidblocks = array(); $validblocks = array(); $notices = array(); //Count the number of blocks in db $blockcount = count_records('block'); //If there isn't records. This is the first install, so I remember it if ($blockcount == 0) { $first_install = true; } else { $first_install = false; } $site = get_site(); if (!($blocks = get_list_of_plugins('blocks', 'db'))) { error('No blocks installed!'); } include_once $CFG->dirroot . '/blocks/moodleblock.class.php'; if (!class_exists('block_base')) { error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php'); } foreach ($blocks as $blockname) { if ($blockname == 'NEWBLOCK') { // Someone has unzipped the template, ignore it continue; } if (!block_is_compatible($blockname)) { // This is an old-style block //$notices[] = 'Block '. $blockname .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.'; $invalidblocks[] = $blockname; continue; } $fullblock = $CFG->dirroot . '/blocks/' . $blockname; if (is_readable($fullblock . '/block_' . $blockname . '.php')) { include_once $fullblock . '/block_' . $blockname . '.php'; } else { $notices[] = 'Block ' . $blockname . ': ' . $fullblock . '/block_' . $blockname . '.php was not readable'; continue; } $oldupgrade = false; $newupgrade = false; if (@is_dir($fullblock . '/db/')) { if (@is_readable($fullblock . '/db/' . $CFG->dbtype . '.php')) { include_once $fullblock . '/db/' . $CFG->dbtype . '.php'; // defines old upgrading function $oldupgrade = true; } if (@is_readable($fullblock . '/db/upgrade.php')) { include_once $fullblock . '/db/upgrade.php'; // defines new upgrading function $newupgrade = true; } } $classname = 'block_' . $blockname; if (!class_exists($classname)) { $notices[] = 'Block ' . $blockname . ': ' . $classname . ' not implemented'; continue; } // Here is the place to see if the block implements a constructor (old style), // an init() function (new style) or nothing at all (error time). $constructor = get_class_constructor($classname); if (empty($constructor)) { // No constructor $notices[] = 'Block ' . $blockname . ': class does not have a constructor'; $invalidblocks[] = $blockname; continue; } $block = new stdClass(); // This may be used to update the db below $blockobj = new $classname(); // This is what we 'll be testing // Inherits from block_base? if (!is_subclass_of($blockobj, 'block_base')) { $notices[] = 'Block ' . $blockname . ': class does not inherit from block_base'; continue; } // OK, it's as we all hoped. For further tests, the object will do them itself. if (!$blockobj->_self_test()) { $notices[] = 'Block ' . $blockname . ': self test failed'; continue; } $block->version = $blockobj->get_version(); if (!isset($block->version)) { $notices[] = 'Block ' . $blockname . ': has no version support. It must be updated by a programmer.'; continue; } $block->name = $blockname; // The name MUST match the directory $blocktitle = $blockobj->get_title(); if ($currblock = get_record('block', 'name', $block->name)) { if ($currblock->version == $block->version) { // do nothing } else { if ($currblock->version < $block->version) { if (empty($updated_blocks)) { $strblocksetup = get_string('blocksetup'); print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); } $updated_blocks = true; upgrade_log_start(); print_heading('New version of ' . $blocktitle . ' (' . $block->name . ') exists'); @set_time_limit(0); // To allow slow databases to complete the long SQL /// Run de old and new upgrade functions for the module $oldupgrade_function = $block->name . '_upgrade'; $newupgrade_function = 'xmldb_block_' . $block->name . '_upgrade'; /// First, the old function if exists $oldupgrade_status = true; if ($oldupgrade && function_exists($oldupgrade_function)) { $db->debug = true; $oldupgrade_status = $oldupgrade_function($currblock->version, $block); } else { if ($oldupgrade) { notify('Upgrade function ' . $oldupgrade_function . ' was not available in ' . $fullblock . '/db/' . $CFG->dbtype . '.php'); } } /// Then, the new function if exists and the old one was ok $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) { $db->debug = true; $newupgrade_status = $newupgrade_function($currblock->version, $block); } else { if ($newupgrade) { notify('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullblock . '/db/upgrade.php'); } } $db->debug = false; /// Now analyze upgrade results if ($oldupgrade_status && $newupgrade_status) { // No upgrading failed // Set the block cron on upgrade $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0; // OK so far, now update the block record $block->id = $currblock->id; if (!update_record('block', $block)) { error('Could not update block ' . $block->name . ' record in block table!'); } $component = 'block/' . $block->name; if (!update_capabilities($component)) { error('Could not update ' . $block->name . ' capabilities!'); } events_update_definition($component); notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess'); } else { notify('Upgrading block ' . $block->name . ' from ' . $currblock->version . ' to ' . $block->version . ' FAILED!'); } echo '<hr />'; } else { upgrade_log_start(); error('Version mismatch: block ' . $block->name . ' can\'t downgrade ' . $currblock->version . ' -> ' . $block->version . '!'); } } } else { // block not installed yet, so install it // If it allows multiples, start with it enabled if ($blockobj->instance_allow_multiple()) { $block->multiple = 1; } // Set the block cron on install $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0; // [pj] Normally this would be inline in the if, but we need to // check for NULL (necessary for 4.0.5 <= PHP < 4.2.0) $conflictblock = array_search($blocktitle, $blocktitles); if ($conflictblock !== false && $conflictblock !== NULL) { // Duplicate block titles are not allowed, they confuse people // AND PHP's associative arrays ;) error('<strong>Naming conflict</strong>: block <strong>' . $block->name . '</strong> has the same title with an existing block, <strong>' . $conflictblock . '</strong>!'); } if (empty($updated_blocks)) { $strblocksetup = get_string('blocksetup'); print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); } $updated_blocks = true; upgrade_log_start(); print_heading($block->name); $db->debug = true; @set_time_limit(0); // To allow slow databases to complete the long SQL /// Both old .sql files and new install.xml are supported /// but we priorize install.xml (XMLDB) if present $status = false; if (file_exists($fullblock . '/db/install.xml')) { $status = install_from_xmldb_file($fullblock . '/db/install.xml'); //New method } else { if (file_exists($fullblock . '/db/' . $CFG->dbtype . '.sql')) { $status = modify_database($fullblock . '/db/' . $CFG->dbtype . '.sql'); //Old method } else { $status = true; } } $db->debug = false; if ($status) { if ($block->id = insert_record('block', $block)) { $blockobj->after_install(); $component = 'block/' . $block->name; if (!update_capabilities($component)) { notify('Could not set up ' . $block->name . ' capabilities!'); } events_update_definition($component); notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess'); echo '<hr />'; } else { error($block->name . ' block could not be added to the block list!'); } } else { error('Block ' . $block->name . ' tables could NOT be set up successfully!'); } } $blocktitles[$block->name] = $blocktitle; } if (!empty($notices)) { upgrade_log_start(); foreach ($notices as $notice) { notify($notice); } } // Finally, if we are in the first_install of BLOCKS (this means that we are // upgrading from Moodle < 1.3), put blocks in all existing courses. if ($first_install) { upgrade_log_start(); //Iterate over each course if ($courses = get_records('course')) { foreach ($courses as $course) { $page = page_create_object(PAGE_COURSE_VIEW, $course->id); blocks_repopulate_page($page); } } } if (!empty($CFG->siteblocksadded)) { /// This is a once-off hack to make a proper upgrade upgrade_log_start(); $page = page_create_object(PAGE_COURSE_VIEW, SITEID); blocks_repopulate_page($page); delete_records('config', 'name', 'siteblocksadded'); } upgrade_log_finish(); if (!empty($updated_blocks)) { print_continue($continueto); print_footer('none'); die; } }
theme_setup($choose); admin_externalpage_print_header(); print_heading(get_string("themesaved")); if (file_exists("{$choose}/README.html")) { print_simple_box_start("center"); readfile("{$choose}/README.html"); print_simple_box_end(); } else { if (file_exists("{$choose}/README.txt")) { print_simple_box_start("center"); $file = file("{$choose}/README.txt"); echo format_text(implode('', $file), FORMAT_MOODLE); print_simple_box_end(); } } print_continue("{$CFG->wwwroot}/"); admin_externalpage_print_footer(); exit; } else { error("Could not set the theme!"); } } admin_externalpage_print_header('themeselector'); print_heading($strthemes); $themes = get_list_of_plugins("theme"); $sesskey = !empty($USER->id) ? $USER->sesskey : ''; echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">\n"; if (!$USER->screenreader) { echo "\t<tr class=\"generaltableheader\">\n\t\t<th scope=\"col\">{$strtheme}</th>\n"; echo "\t\t<th scope=\"col\">{$strinfo}</th>\n\t</tr>\n"; }
function delete_file() { global $CFG; $file = required_param('file', PARAM_FILE); $userid = required_param('userid', PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_BOOL); $mode = optional_param('mode', '', PARAM_ALPHA); $offset = optional_param('offset', 0, PARAM_INT); require_login($this->course->id, false, $this->cm); if (empty($mode)) { $urlreturn = 'view.php'; $optionsreturn = array('id' => $this->cm->id); $returnurl = 'view.php?id=' . $this->cm->id; } else { $urlreturn = 'submissions.php'; $optionsreturn = array('id' => $this->cm->id, 'offset' => $offset, 'mode' => $mode, 'userid' => $userid); $returnurl = "submissions.php?id={$this->cm->id}&offset={$offset}&mode={$mode}&userid={$userid}"; } if (!($submission = $this->get_submission($userid)) or !$this->can_delete_files($submission)) { // can not delete $this->view_header(get_string('delete')); notify(get_string('cannotdeletefiles', 'assignment')); print_continue($returnurl); $this->view_footer(); die; } $dir = $this->file_area_name($userid); if (!data_submitted('nomatch') or !$confirm or !confirm_sesskey()) { $optionsyes = array('id' => $this->cm->id, 'file' => $file, 'userid' => $userid, 'confirm' => 1, 'sesskey' => sesskey(), 'mode' => $mode, 'offset' => $offset, 'sesskey' => sesskey()); if (empty($mode)) { $this->view_header(get_string('delete')); } else { print_header(get_string('delete')); } print_heading(get_string('delete')); notice_yesno(get_string('confirmdeletefile', 'assignment', $file), 'delete.php', $urlreturn, $optionsyes, $optionsreturn, 'post', 'get'); if (empty($mode)) { $this->view_footer(); } else { print_footer('none'); } die; } $filepath = $CFG->dataroot . '/' . $dir . '/' . $file; if (file_exists($filepath)) { if (@unlink($filepath)) { $updated = new object(); $updated->id = $submission->id; $updated->timemodified = time(); if (update_record('assignment_submissions', $updated)) { add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id); $submission = $this->get_submission($userid); $this->update_grade($submission); } redirect($returnurl); } } // print delete error if (empty($mode)) { $this->view_header(get_string('delete')); } else { print_header(get_string('delete')); } notify(get_string('deletefilefailed', 'assignment')); print_continue($returnurl); if (empty($mode)) { $this->view_footer(); } else { print_footer('none'); } die; }
if ($PermissionGranted) { $dbentry = new stdClass(); $dbentry->id = $entry->id; $dbentry->glossaryid = $mainglossary->id; $dbentry->sourceglossaryid = $glossary->id; if (!update_record('glossary_entries', $dbentry)) { error('Could not export the entry to the main glossary'); } else { print_simple_box_start('center', '60%'); echo '<p align="center"><font size="3">' . $entryexported . '</font></p></font>'; print_continue('view.php?id=' . $cm->id . '&mode=entry&hook=' . $entry->id); print_simple_box_end(); print_footer(); redirect('view.php?id=' . $cm->id . '&mode=entry&hook=' . $entry->id); die; } } else { print_simple_box_start('center', '60%', '#FFBBBB'); echo '<p align="center"><font size="3">' . $entryalreadyexist . '</font></p></font>'; echo '<p align="center">'; print_continue('view.php?id=' . $cm->id . '&mode=entry&hook=' . $entry->id); print_simple_box_end(); } } } else { print_simple_box_start('center', '60%', '#FFBBBB'); notice('A weird error was found while trying to export this entry. Operation cancelled.'); print_continue('view.php?id=' . $cm->id . '&mode=entry&hook=' . $entry->id); print_simple_box_end(); } print_footer();
function wiki_export_html(&$WS) { global $CFG; check_dir_exists("{$CFG->dataroot}/temp", true); check_dir_exists("{$CFG->dataroot}/temp/html", true); check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}", true); check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}", true); //export contents wiki_export_html_content($WS); //export attached files $flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}"); if ($flist != null) { foreach ($flist as $fil) { $from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}/{$fil}"; $to_file = "{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments/{$fil}"; copy($from_file, $to_file); } } //zip file name $times = time(); $name = $WS->dfwiki->name . '-' . $times . '.zip'; $cleanzipname = clean_filename($name); //List of files and directories $filelist = list_directories_and_files("{$CFG->dataroot}/temp/html"); //Convert them to full paths $files = array(); if ($filelist != null) { foreach ($filelist as $file) { $files[] = "{$CFG->dataroot}/temp/html/{$file}"; } } check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml", true); $destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml/{$cleanzipname}"; $status = zip_files($files, $destination); //delete the folder created in temp $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/html"); if ($filelist2 != null) { $del = delete_dir_contents("{$CFG->dataroot}/temp/html"); } //show it all to be albe to download the file $prop = null; $prop->class = "textcenter"; wiki_div_start($prop); wiki_size_text(get_string("exporthtmlcorrectly", "wiki"), 2); wiki_div_end(); $prop = null; $prop->border = "0"; $prop->class = "boxaligncenter"; $prop->classtd = "nwikileftnow"; wiki_table_start($prop); $wdir = '/exportedhtml'; $fileurl = "{$wdir}/{$cleanzipname}"; $ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}"; $icon = mimeinfo("icon", $cleanzipname); link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640); echo "\n" . ' '; link_to_popup_window($ffurl, "display", htmlspecialchars($cleanzipname), 480, 640); $prop = null; $prop->class = "nwikileftnow"; wiki_change_row($prop); echo ' '; wiki_table_end(); $prop = null; $prop->border = "0"; $prop->class = "boxaligncenter"; $prop->classtd = "nwikileftnow"; wiki_table_start($prop); $prop = null; $prop->id = "form"; $prop->method = "post"; $prop->action = '../xml/index.php?id=' . $WS->dfwiki->course . '&wdir=/exportedhtml'; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "dfform[viewexported]"; $prop->value = get_string('viewexported', 'wiki'); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); wiki_change_column(); print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}"); wiki_table_end(); }
/** * given an import code, commits all entries in buffer tables * (grade_import_value and grade_import_newitem) * If this function is called, we assume that all data collected * up to this point is fine and we can go ahead and commit * @param int courseid - id of the course * @param string importcode - import batch identifier * @param feedback print feedback and continue button * @return bool success */ function grade_import_commit($courseid, $importcode, $importfeedback = true, $verbose = true) { global $CFG, $USER, $DB; $commitstart = time(); // start time in case we need to roll back $newitemids = array(); // array to hold new grade_item ids from grade_import_newitem table, mapping array /// first select distinct new grade_items with this batch $params = array($importcode, $USER->id); if ($newitems = $DB->get_records_sql("SELECT *\n FROM {grade_import_newitem}\n WHERE importcode = ? AND importer=?", $params)) { // instances of the new grade_items created, cached // in case grade_update fails, so that we can remove them $instances = array(); $failed = false; foreach ($newitems as $newitem) { // get all grades with this item if ($grades = $DB->get_records('grade_import_values', array('newgradeitem' => $newitem->id))) { /// create a new grade item for this - must use false as second param! /// TODO: we need some bounds here too $gradeitem = new grade_item(array('courseid' => $courseid, 'itemtype' => 'manual', 'itemname' => $newitem->itemname), false); $gradeitem->insert('import'); $instances[] = $gradeitem; // insert each individual grade to this new grade item foreach ($grades as $grade) { if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback, FORMAT_MOODLE)) { $failed = true; break 2; } } } } if ($failed) { foreach ($instances as $instance) { $gradeitem->delete('import'); } import_cleanup($importcode); return false; } } /// then find all existing items if ($gradeitems = $DB->get_records_sql("SELECT DISTINCT (itemid)\n FROM {grade_import_values}\n WHERE importcode = ? AND importer=? AND itemid > 0", array($importcode, $USER->id))) { $modifieditems = array(); foreach ($gradeitems as $itemid => $notused) { if (!($gradeitem = new grade_item(array('id' => $itemid)))) { // not supposed to happen, but just in case import_cleanup($importcode); return false; } // get all grades with this item if ($grades = $DB->get_records('grade_import_values', array('itemid' => $itemid))) { // make the grades array for update_grade foreach ($grades as $grade) { if (!$importfeedback) { $grade->feedback = false; // ignore it } if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback)) { $failed = 1; break 2; } } //$itemdetails -> idnumber = $gradeitem->idnumber; $modifieditems[] = $itemid; } if (!empty($failed)) { import_cleanup($importcode); return false; } } } if ($verbose) { notify(get_string('importsuccess', 'grades'), 'notifysuccess'); $unenrolledusers = get_unenrolled_users_in_import($importcode, $courseid); if ($unenrolledusers) { $list = "<ul>\n"; foreach ($unenrolledusers as $u) { $u->fullname = fullname($u); $list .= '<li>' . get_string('usergrade', 'grades', $u) . '</li>'; } $list .= "</ul>\n"; notify(get_string('unenrolledusersinimport', 'grades', $list), 'notifysuccess'); } print_continue($CFG->wwwroot . '/grade/index.php?id=' . $courseid); } // clean up import_cleanup($importcode); return true; }
/** * Get a single record as an object using the specified SQL statement * * A LIMIT is normally added to only look for 1 record * If debugging is OFF only the first record is returned even if there is * more than one matching record! * * @uses $CFG * @uses $db * @param string $sql The SQL string you wish to be executed. * @param array $values If using placeholder ?s in the $sql, pass values here. * @return Found record as object. False if not found or error */ function get_record_sql($sql, $values = null, $expectmultiple = false, $nolimit = false) { global $db, $CFG; if (isset($CFG->debug) && $CFG->debug > 7 && !$expectmultiple) { // Debugging mode - don't use limit $limit = ''; } else { if ($nolimit) { $limit = ''; } else { $limit = ' LIMIT 1'; // Workaround - limit to one record } } if (defined('ELGG_PERFDB')) { global $PERF; $PERF->dbqueries++; } $rs = false; if (!empty($values) && is_array($values) && count($values) > 0) { $stmt = $db->Prepare($sql . $limit); $rs = $db->Execute($stmt, $values); } else { $rs = $db->Execute($sql . $limit); } if (!$rs) { if (isset($CFG->debug) and $CFG->debug > 7) { // Debugging mode - print checks notify($db->ErrorMsg() . '<br /><br />' . $sql . $limit); } if (!empty($CFG->dblogerror)) { $debug = debug_backtrace(); foreach ($debug as $d) { if (strpos($d['file'], 'datalib') === false) { error_log("SQL " . $db->ErrorMsg() . " in {$d['file']} on line {$d['line']}. STATEMENT: {$sql}{$limit}"); break; } } } return false; } if (!($recordcount = $rs->RecordCount())) { return false; // Found no records } if ($recordcount == 1) { // Found one record return (object) $rs->fields; } else { // Error: found more than one record notify('Error: Turn off debugging to hide this error.'); notify($sql . $limit); if ($records = $rs->GetAssoc(true)) { notify('Found more than one record in get_record_sql !'); print_object($records); } else { notify('Very strange error in get_record_sql !'); print_object($rs); } print_continue("{$CFG->wwwroot}/{$CFG->admin}/config.php"); } }
} if (!$qformat->exportpostprocess()) { // In case anything needs to be done after error($txt->exporterror, "{$CFG->wwwroot}/question/export.php?courseid={$course->id}&category={$category->id}"); } echo "<hr />"; // link to download the finished file $file_ext = $qformat->export_file_extension(); if ($CFG->slasharguments) { $efile = "{$CFG->wwwroot}/file.php/" . $qformat->question_get_export_dir() . "/{$exportfilename}" . $file_ext . "?forcedownload=1"; } else { $efile = "{$CFG->wwwroot}/file.php?file=/" . $qformat->question_get_export_dir() . "/{$exportfilename}" . $file_ext . "&forcedownload=1"; } echo "<p><div class=\"boxaligncenter\"><a href=\"{$efile}\">{$txt->download}</a></div></p>"; echo "<p><div class=\"boxaligncenter\"><font size=\"-1\">{$txt->downloadextra}</font></div></p>"; print_continue("edit.php?courseid={$course->id}"); print_footer($course); exit; } /// Display upload form // get valid formats to generate dropdown list $fileformatnames = get_import_export_formats('export'); // get filename if (empty($exportfilename)) { $exportfilename = default_export_filename($course, $category); } print_heading_with_help($txt->exportquestions, 'export', 'quiz'); print_box_start('generalbox boxwidthnormal boxaligncenter'); ?> <form enctype="multipart/form-data" method="post" action="export.php">
echo '</tr>'; if ($catsincl) { echo '<tr>'; echo '<td width="50%" align="right">'; echo get_string("importedcategories", "glossary"); echo ':</td>'; echo '<td width="50%">'; echo $importedcats; echo '</td>'; echo '</tr>'; } echo '</table><hr />'; // rejected entries if ($rejections) { echo '<table class="glossaryimportexport">'; echo '<tr><td align="center" colspan="2" width="100%"><strong>' . get_string("rejectionrpt", "glossary") . '</strong></tr>'; echo $rejections; echo '</table><hr />'; } /// Print continue button, based on results if ($importedentries) { print_continue('view.php?id=' . $id); } else { print_continue('import.php?id=' . $id); } print_box_end(); } else { notice(get_string('errorparsingxml', 'glossary')); } /// Finish the page print_footer($course);
} //get the completeds $feedbackcompleteds = get_records_select('feedback_completed', 'feedback=' . $feedback->id . ' AND userid=0', 'timemodified'); /// Print the page header if ($course->category) { $navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->"; } $strfeedbacks = get_string("modulenameplural", "feedback"); $strfeedback = get_string("modulename", "feedback"); print_header("{$course->shortname}: {$feedback->name}", "{$course->fullname}", "{$navigation} <a href=\"index.php?id={$course->id}\">{$strfeedbacks}</a> -> {$feedback->name}", "", "", true, update_module_button($cm->id, $course->id, $strfeedback), navmenu($course, $cm)); /// Print the main part of the page /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// print_heading($feedback->name); print_continue('view.php?id=' . $id); //Liste mit anonym ausgefuellten Feedbacks anzeigen print_simple_box_start("center"); ?> <script type="text/javascript"> function go2delete(form) { form.action = "<?php echo $CFG->wwwroot; ?> /mod/feedback/delete_completed.php"; form.submit(); } </script> <div align="center">
/** * Print a message and exit. * * @uses $CFG * @param string $message ? * @param string $link ? * @todo Finish documenting this function */ function notice($message, $link = '', $course = NULL) { global $CFG, $SITE, $THEME, $COURSE, $PAGE; $message = clean_text($message); // In case nasties are in here if (CLI_SCRIPT) { // notices in cron should be mtrace'd. mtrace($message); die; } if (!$PAGE->headerprinted) { //header not yet printed print_header(get_string('notice')); } else { print_container_end_all(false, $THEME->open_header_containers); } print_box($message, 'generalbox', 'notice'); print_continue($link); if (empty($course)) { print_footer($COURSE); } else { print_footer($course); } exit; }
print_box($stroutofattempts, 'center'); } elseif ($key == $preferences['newemailkey']) { $olduser = clone $user; cancel_email_update($user->id); $user->email = $preferences['newemail']; // Detect duplicate before saving if (get_record('user', 'email', addslashes($user->email))) { $stremailnowexists = get_string('auth_emailnowexists', 'auth'); print_box($stremailnowexists, 'center'); print_continue("{$CFG->wwwroot}/user/view.php?id={$user->id}"); } else { // update user email if (!set_field('user', 'email', addslashes($user->email), 'id', $user->id)) { error('Error updating user record'); } else { $authplugin = get_auth_plugin($user->auth); $authplugin->user_update($olduser, $user); events_trigger('user_updated', $user); $a->email = $user->email; $stremailupdatesuccess = get_string('auth_emailupdatesuccess', 'auth', $a); print_box($stremailupdatesuccess, 'center'); print_continue("{$CFG->wwwroot}/user/view.php?id={$user->id}"); } } } else { $preferences['newemailattemptsleft']--; set_user_preference('newemailattemptsleft', $preferences['newemailattemptsleft'], $user->id); $strinvalidkey = get_string('auth_invalidnewemailkey', 'auth'); print_box($strinvalidkey, 'center'); } print_footer('none');
if ($cron == 1) { mtrace("<p>Su cuestionario sera generado mas tarde</a></p>"); $continue = "{$CFG->wwwroot}/mod/blended/edit_paperquiz.php?a={$a}"; print_continue($continue); // Finish the page print_footer($course); } else { // Generate every job matching this data. (This makes a grouping of attempts) $job->quiz = $quiz->id; $job->userid = $USER->id; $job->blended = $blended->id; $job->timestamp = $timestamp; list($numattempts, $pdfFile) = generateJobs($job); if ($numattempts > 0) { $tex = new object(); $tex->href = "{$CFG->wwwroot}/files/index.php?id={$course->id}&wdir=%2F{$pdfFile->inCourseFolderRelativePath}"; $tex->hrefText = $pdfFile->inCourseFolderRelativePath; $tex->directLinkhref = "{$CFG->wwwroot}/file.php/{$pdfFile->RelativePath}?forcedownload=1"; $tex->directLinkText = $pdfFile->Name; echo get_string("PDFgeneratedMessage", "blended", $tex); } else { echo "<p>No PDF file generated.</p>"; } $continue = "{$CFG->wwwroot}/mod/blended/edit_paperquiz.php?a={$a}"; print_continue($continue); // Finish the page echo "<center>"; helpbutton($page = 'generateQuizesPDF', get_string('pagehelp', 'blended'), $module = 'blended', $image = true, $linktext = true, $text = '', $return = false, $imagetext = ''); echo "</center>"; print_footer($course); }
print_header($site->fullname . ':Error', $site->fullname . ': Error 404', 'Error 404 - File not Found', ''); print_simple_box('<p align="center">' . get_string('pagenotexist', 'error') . '<br />' . s($requesturi) . '</p>', 'center'); if (isloggedin()) { ?> <center> <p><?php echo get_string('pleasereport', 'error'); ?> <p><form action="<?php echo $CFG->wwwroot; ?> /error/index.php" method="post"> <textarea rows="3" cols="50" name="text" id="text"></textarea><br /> <input type="hidden" name="referer" value="<?php p($httpreferer); ?> "> <input type="hidden" name="requested" value="<?php p($requesturi); ?> "> <input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?> "> </form> <?php } else { print_continue($CFG->wwwroot); } print_footer();
/** * @param string $errorstr passed by reference, if silent is true, * errorstr will be populated and this function will return false rather than calling error() or notify() * @param boolean $noredirect (optional) if this is passed, this function will not print continue, or * redirect to the next step in the restore process, instead will return $backup_unique_code */ function restore_precheck($id, $file, &$errorstr, $noredirect = false) { global $CFG, $SESSION; //Prepend dataroot to variable to have the absolute path $file = $CFG->dataroot . "/" . $file; if (!defined('RESTORE_SILENTLY')) { //Start the main table echo "<table cellpadding=\"5\">"; echo "<tr><td>"; //Start the mail ul echo "<ul>"; } //Check the file exists if (!is_file($file)) { if (!defined('RESTORE_SILENTLY')) { error("File not exists ({$file})"); } else { $errorstr = "File not exists ({$file})"; return false; } } //Check the file name ends with .zip if (!substr($file, -4) == ".zip") { if (!defined('RESTORE_SILENTLY')) { error("File has an incorrect extension"); } else { $errorstr = 'File has an incorrect extension'; return false; } } //Now calculate the unique_code for this restore $backup_unique_code = time(); //Now check and create the backup dir (if it doesn't exist) if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("creatingtemporarystructures") . '</li>'; } $status = check_and_create_backup_dir($backup_unique_code); //Empty dir if ($status) { $status = clear_backup_dir($backup_unique_code); } //Now delete old data and directories under dataroot/temp/backup if ($status) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("deletingolddata") . '</li>'; } $status = backup_delete_old_data(); } //Now copy he zip file to dataroot/temp/backup/backup_unique_code if ($status) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("copyingzipfile") . '</li>'; } if (!($status = backup_copy_file($file, $CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/" . basename($file)))) { if (!defined('RESTORE_SILENTLY')) { notify("Error copying backup file. Invalid name or bad perms."); } else { $errorstr = "Error copying backup file. Invalid name or bad perms"; return false; } } } //Now unzip the file if ($status) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("unzippingbackup") . '</li>'; } if (!($status = restore_unzip($CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/" . basename($file)))) { if (!defined('RESTORE_SILENTLY')) { notify("Error unzipping backup file. Invalid zip file."); } else { $errorstr = "Error unzipping backup file. Invalid zip file."; return false; } } } // If experimental option is enabled (enableimsccimport) // check for Common Cartridge packages and convert to Moodle format if ($status && isset($CFG->enableimsccimport) && $CFG->enableimsccimport == 1) { require_once $CFG->dirroot . '/backup/cc/restore_cc.php'; if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string('checkingforimscc', 'imscc') . '</li>'; } $status = cc_convert($CFG->dataroot . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . $backup_unique_code); } //Check for Blackboard backups and convert if ($status) { require_once "{$CFG->dirroot}/backup/bb/restore_bb.php"; if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("checkingforbbexport") . '</li>'; } $status = blackboard_convert($CFG->dataroot . "/temp/backup/" . $backup_unique_code); } //Now check for the moodle.xml file if ($status) { $xml_file = $CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/moodle.xml"; if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("checkingbackup") . '</li>'; } if (!($status = restore_check_moodle_file($xml_file))) { if (!is_file($xml_file)) { $errorstr = 'Error checking backup file. moodle.xml not found at root level of zip file.'; } else { $errorstr = 'Error checking backup file. moodle.xml is incorrect or corrupted.'; } if (!defined('RESTORE_SILENTLY')) { notify($errorstr); } else { return false; } } } $info = ""; $course_header = ""; //Now read the info tag (all) if ($status) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("readinginfofrombackup") . '</li>'; } //Reading info from file $info = restore_read_xml_info($xml_file); //Reading course_header from file $course_header = restore_read_xml_course_header($xml_file); if (!is_object($course_header)) { // ensure we fail if there is no course header $course_header = false; } } if (!defined('RESTORE_SILENTLY')) { //End the main ul echo "</ul>\n"; //End the main table echo "</td></tr>"; echo "</table>"; } //We compare Moodle's versions if ($status && $CFG->version < $info->backup_moodle_version) { $message = new object(); $message->serverversion = $CFG->version; $message->serverrelease = $CFG->release; $message->backupversion = $info->backup_moodle_version; $message->backuprelease = $info->backup_moodle_release; print_simple_box(get_string('noticenewerbackup', '', $message), "center", "70%", '', "20", "noticebox"); } //Now we print in other table, the backup and the course it contains info if ($info and $course_header and $status) { //First, the course info if (!defined('RESTORE_SILENTLY')) { $status = restore_print_course_header($course_header); } //Now, the backup info if ($status) { if (!defined('RESTORE_SILENTLY')) { $status = restore_print_info($info); } } } //Save course header and info into php session if ($status) { $SESSION->info = $info; $SESSION->course_header = $course_header; } //Finally, a little form to continue //with some hidden fields if ($status) { if (!defined('RESTORE_SILENTLY')) { echo "<br /><div style='text-align:center'>"; $hidden["backup_unique_code"] = $backup_unique_code; $hidden["launch"] = "form"; $hidden["file"] = $file; $hidden["id"] = $id; print_single_button("restore.php", $hidden, get_string("continue"), "post"); echo "</div>"; } else { if (empty($noredirect)) { print_continue($CFG->wwwroot . '/backup/restore.php?backup_unique_code=' . $backup_unique_code . '&launch=form&file=' . $file . '&id=' . $id . '&sesskey=' . sesskey()); print_footer(); die; } else { return $backup_unique_code; } } } if (!$status) { if (!defined('RESTORE_SILENTLY')) { error("An error has ocurred"); } else { $errorstr = "An error has occured"; // helpful! :P return false; } } return true; }
} require_login($course->id, false, $cm); if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { print_error('cannotviewassignment', 'assignment'); } if ($assignment->assignmenttype != 'upload') { print_error('invalidtype', 'assignment'); } $assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course); $returnurl = "../../submissions.php?id={$assignmentinstance->cm->id}&userid={$userid}&offset={$offset}&mode=single"; if ($submission = $assignmentinstance->get_submission($user->id) and !empty($submission->data1)) { print_header(fullname($user, true) . ': ' . $assignment->name); print_heading(get_string('notes', 'assignment') . ' - ' . fullname($user, true)); print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%'); if ($mode != 'single') { close_window_button(); } else { print_continue($returnurl); } print_footer('none'); } else { print_header(fullname($user, true) . ': ' . $assignment->name); print_heading(get_string('notes', 'assignment') . ' - ' . fullname($user, true)); print_simple_box(get_string('notesempty', 'assignment'), 'center', '100%'); if ($mode != 'single') { close_window_button(); } else { print_continue($returnurl); } print_footer('none'); }
/** * This function checks to see whether local database customisations are up-to-date * by comparing $CFG->local_version to the variable $local_version defined in * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade' * in a file called 'local/db/upgrade.php', and if it's there calls it with the * appropiate $oldversion parameter. Then it updates $CFG->local_version. * On success it prints a continue link. On failure it prints an error. * * @uses $CFG * @uses $db to do something really evil with the debug setting that should probably be eliminated. TODO! * @param string $continueto a URL passed to print_continue() if the local upgrades succeed. */ function upgrade_local_dbs($continueto) { global $CFG, $db; $path = '/local'; $pat = 'local'; $status = true; $changed = false; $firstloop = true; while (is_dir($CFG->dirroot . $path)) { // if we don't have code version or a db upgrade file, check lower if (!file_exists($CFG->dirroot . "{$path}/version.php") || !file_exists($CFG->dirroot . "{$path}/db/upgrade.php")) { $path .= '/local'; $pat .= 'local'; continue; } require_once $CFG->dirroot . "{$path}/version.php"; // Get code versions $cfgvarname = "{$pat}_version"; if (empty($CFG->{$cfgvarname})) { // normally we'd install, but just replay all the upgrades. $CFG->{$cfgvarname} = 0; } $localversionvar = "{$pat}_version"; // echo "($localversionvar) ".$$localversionvar." > ($cfgvarname) ".$CFG->{$cfgvarname}."<br/>"; if (${$localversionvar} > $CFG->{$cfgvarname}) { // something upgrades! upgrade_log_start(); /// Capabilities /// do this first *instead of* last , so that the installer has the chance to locally assign caps if (!update_capabilities($pat)) { error('Could not set up the capabilities for ' . $pat . '!'); } if ($firstloop) { $strdatabaseupgrades = get_string('databaseupgrades'); print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript()); $firstloop = false; } $changed = true; require_once $CFG->dirroot . "{$path}/db/upgrade.php"; $db->debug = true; $upgradefunc = "xmldb_{$pat}_upgrade"; if ($upgradefunc($CFG->{$cfgvarname})) { $db->debug = false; if (set_config($localversionvar, ${$localversionvar})) { notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databaseupgradelocal', '', $path . ' >> ' . ${$localversionvar}), 'notifysuccess'); } else { $status = false; error('Upgrade of local database customisations failed in $path! (Could not update version in config table)'); } } else { $db->debug = false; error("Upgrade failed! See {$path}/version.php"); } if (!events_update_definition($pat)) { error('Could not set up the events definitions for ' . $pat . '!'); } upgrade_log_finish(); } else { if (${$localversionvar} < $CFG->{$cfgvarname}) { notify("WARNING!!! The local version you are using in {$path} is OLDER than the version that made these databases!"); } } $path .= '/local'; $pat .= 'local'; } if ($changed) { print_continue($continueto); print_footer('none'); exit; } }
print_heading(get_string("gradinggrade", "workshop") . " " . get_string("analysis", "workshop")); print_table($table); echo '</td></tr>'; if ($workshop->showleaguetable and time() > $workshop->assessmentend) { workshop_print_league_table($workshop); if ($workshop->anonymous) { echo "<p>" . get_string("namesnotshowntostudents", "workshop", $course->students) . "</p>\n"; } } echo '</table>'; } elseif ($action == 'showdescription') { workshop_print_assignment_info($workshop); print_box(format_text($workshop->description, $workshop->format), 'generalbox', 'intro'); if (isset($_SERVER["HTTP_REFERER"])) { print_continue(htmlentities($_SERVER["HTTP_REFERER"])); } else { print_continue("{$CFG->wwwroot}/course/view.php?id={$cm->id}"); } } elseif ($action == 'allsubmissions') { require_capability('mod/workshop:manage', $context); if ($submissions = get_records('workshop_submissions', 'workshopid', $workshop->id)) { foreach ($submissions as $submission) { $user = get_record('user', 'id', $submission->userid); print_heading('"' . $submission->title . '" ' . get_string('by', 'workshop') . ' ' . fullname($user)); workshop_print_submission($workshop, $submission); } } } else { error("Fatal Error: Unknown Action: " . $action . "\n"); } print_footer($course);
$newassessment = workshop_copy_assessment($assessment, $newsubmission, true); // set the resubmission flag so student can be emailed/told about // this assessment set_field("workshop_assessments", "resubmission", 1, "id", $newassessment->id); } } else { // a hot assessment, was not used, just dump it delete_records("workshop_assessments", "id", $assessment->id); } } } add_to_log($course->id, "workshop", "resubmit", "view.php?id={$cm->id}", "{$workshop->id}", "{$cm->id}"); } // do something about the attachments, if there are any if ($workshop->nattachments) { require_once $CFG->dirroot . '/lib/uploadlib.php'; $um = new upload_manager(null, false, false, $course, false, $workshop->maxbytes); if ($um->preprocess_files()) { $dir = workshop_file_area_name($workshop, $newsubmission); if ($um->save_files($dir)) { print_heading(get_string("uploadsuccess", "workshop")); } // um will take care of printing errors. } } if (!$workshop->nattachments) { print_heading(get_string("submitted", "workshop") . " " . get_string("ok")); } add_to_log($course->id, "workshop", "submit", "view.php?id={$cm->id}", "{$workshop->id}", "{$cm->id}"); print_continue("view.php?id={$cm->id}"); print_footer($course);
/** * Get a single record as an object using an SQL statement * * The SQL statement should normally only return one record. In debug mode * you will get a warning if more record is returned (unless you * set $expectmultiple to true). In non-debug mode, it just returns * the first record. * * @uses $CFG * @uses $db * @param string $sql The SQL string you wish to be executed, should normally only return one record. * @param bool $expectmultiple If the SQL cannot be written to conveniently return just one record, * set this to true to hide the debug message. * @param bool $nolimit sometimes appending ' LIMIT 1' to the SQL causes an error. Set this to true * to stop your SQL being modified. This argument should probably be deprecated. * @return Found record as object. False if not found or error */ function get_record_sql($sql, $expectmultiple = false, $nolimit = false) { global $CFG; /// Default situation $limitfrom = 0; /// Number of records to skip $limitnum = 1; /// Number of records to retrieve /// Only a few uses of the 2nd and 3rd parameter have been found /// I think that we should avoid to use them completely, one /// record is one record, and everything else should return error. /// So the proposal is to change all the uses, (4-5 inside Moodle /// Core), drop them from the definition and delete the next two /// "if" sentences. (eloy, 2006-08-19) if ($nolimit) { $limitfrom = 0; $limitnum = 0; } else { if ($expectmultiple) { $limitfrom = 0; $limitnum = 1; } else { if (debugging('', DEBUG_DEVELOPER)) { // Debugging mode - don't use a limit of 1, but do change the SQL, because sometimes that // causes errors, and in non-debug mode you don't see the error message and it is // impossible to know what's wrong. $limitfrom = 0; $limitnum = 100; } } } if (!($rs = get_recordset_sql($sql, $limitfrom, $limitnum))) { return false; } $recordcount = $rs->RecordCount(); if ($recordcount == 0) { // Found no records return false; } else { if ($recordcount == 1) { // Found one record /// DIRTY HACK to retrieve all the ' ' (1 space) fields converted back /// to '' (empty string) for Oracle. It's the only way to work with /// all those NOT NULL DEFAULT '' fields until we definitively delete them if ($CFG->dbfamily == 'oracle') { array_walk($rs->fields, 'onespace2empty'); } /// End of DIRTY HACK return (object) $rs->fields; } else { // Error: found more than one record notify('Error: Turn off debugging to hide this error.'); notify($sql . '(with limits ' . $limitfrom . ', ' . $limitnum . ')'); if ($records = $rs->GetAssoc(true)) { notify('Found more than one record in get_record_sql !'); print_object($records); } else { notify('Very strange error in get_record_sql !'); print_object($rs); } print_continue("{$CFG->wwwroot}/{$CFG->admin}/config.php"); } } }
$navlinks = array(); $navlinks[] = array('name' => $stradministration, 'link' => "{$CFG->wwwroot}/{$CFG->admin}/index.php", 'type' => 'misc'); $navlinks[] = array('name' => $strcourserestore, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); if (!$file) { print_header("{$site->shortname}: {$strcourserestore}", $site->fullname, $navigation); print_heading(get_string("nofilesselected")); print_continue("{$CFG->wwwroot}/{$CFG->admin}/index.php"); print_footer(); exit; } //If cancel has been selected, inform and end if ($cancel) { print_header("{$site->shortname}: {$strcourserestore}", $site->fullname, $navigation); print_heading(get_string("restorecancelled")); print_continue("{$CFG->wwwroot}/course/view.php?id=" . $id); print_footer(); exit; } //We are here, so me have a file. //Get and check course if (!($course = get_record("course", "id", $id))) { error("Course ID was incorrect (can't find it)"); } //Print header if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { $navlinks[] = array('name' => basename($file), 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("{$site->shortname}: {$strcourserestore}", $site->fullname, $navigation); } else { $navlinks = array();
echo '<form name="frm" action="' . $CFG->wwwroot . '/course/view.php?id=' . $courseid . '" method="post" onsubmit=" ">'; } else { if ($course->id == SITEID) { echo '<form name="frm" action="' . $CFG->wwwroot . '" method="post" onsubmit=" ">'; } else { echo '<form name="frm" action="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '" method="post" onsubmit=" ">'; } } echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; echo '<input type="hidden" name="courseid" value="' . $courseid . '" />'; echo '<button type="submit">' . get_string('cancel') . '</button>'; echo '</form>'; echo '</div>'; $SESSION->feedback->is_started = true; // print_simple_box_end(); print_box_end(); } } } else { // print_simple_box_start('center'); print_box_start('generalbox boxaligncenter'); echo '<h2><font color="red">' . get_string('this_feedback_is_already_submitted', 'feedback') . '</font></h2>'; print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id); // print_simple_box_end(); print_box_end(); } /// Finish the page /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// print_footer($course);
continue; } } if (!($files = get_directory_list("{$CFG->dirroot}/lang/en_utf8/docs", "CVS"))) { error("Could not find English language docs files!"); } foreach ($files as $filekey => $file) { // check all the docs files. if (!file_exists("{$langdir}/docs/{$file}")) { notify(get_string("filemissing", "", "{$langdir}/docs/{$file}"), 'notifyproblem'); $somethingfound = true; continue; } } if (!empty($somethingfound)) { print_continue("lang.php"); } else { notice(get_string("languagegood"), "lang.php"); } } else { if ($mode == 'compare') { if (!file_exists($langbase)) { if (!lang_make_directory($langbase)) { error('ERROR: Could not create base lang directory ' . $langbase); } else { echo '<div class="notifysuccess">Created directory ' . $langbase . '</div>' . "<br />\n"; } } if (!$uselocal && !file_exists($langdir)) { if (!lang_make_directory($langdir)) { error('ERROR: Could not create directory ' . $langdir);