/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_XML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the file parameter $file = required_param('file', PARAM_PATH); $file = $CFG->dirroot . stripslashes_safe($file); /// File must be under $CFG->wwwroot and /// under one db directory (simple protection) if (substr($file, 0, strlen($CFG->dirroot)) == $CFG->dirroot && substr(dirname($file), -2, 2) == 'db') { /// Everything is ok. Load the file to memory $this->output = file_get_contents($file); } else { /// Switch to HTML and error $this->does_generate = ACTION_GENERATE_HTML; $this->errormsg = 'File not viewable (' . $file . ')'; $result = false; } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting $result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dir if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { /// Set some defaults $dbdir->xml_exists = false; $dbdir->xml_writeable = false; $dbdir->xml_loaded = false; ///Only if the directory exists if (!$dbdir->path_exists) { return false; } $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml'); ///Set the XML DTD and schema $xmldb_file->setDTD($CFG->dirroot . '/lib/xmldb/xmldb.dtd'); $xmldb_file->setSchema($CFG->dirroot . '/lib/xmldb/xmldb.xsd'); /// Set dbdir as necessary if ($xmldb_file->fileExists()) { $dbdir->xml_exists = true; } if ($xmldb_file->fileWriteable()) { $dbdir->xml_writeable = true; } /// Load the XML contents to structure $loaded = $xmldb_file->loadXMLStructure(); if ($loaded && $xmldb_file->isLoaded()) { $dbdir->xml_loaded = true; $dbdir->filemtime = filemtime($dbdir->path . '/install.xml'); } $dbdir->xml_file = $xmldb_file; } else { $this->errormsg = 'Wrong directory (' . $dirpath . ')'; $result = false; } } else { $this->errormsg = 'XMLDB structure not found'; $result = false; } /// Launch postaction if exists if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_XML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the file parameter $select = required_param('select', PARAM_ALPHA); //original/edited /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dir if ($select == 'original') { if (!empty($XMLDB->dbdirs)) { $base =& $XMLDB->dbdirs[$dirpath]; } } else { if ($select == 'edited') { if (!empty($XMLDB->editeddirs)) { $base =& $XMLDB->editeddirs[$dirpath]; } } else { $this->errormsg = 'Cannot access to ' . $select . ' info'; $result = false; } } if ($base) { /// Only if the directory exists and it has been loaded if (!$base->path_exists || !$base->xml_loaded) { $this->errormsg = 'Directory ' . $dirpath . ' not loaded'; return false; } } else { $this->errormsg = 'Problem handling ' . $select . ' files'; return false; } /// Get the structure if ($result) { if (!($structure =& $base->xml_file->getStructure())) { $this->errormsg = 'Error retrieving ' . $select . ' structure'; $result = false; } } if ($result) { /// Everything is ok. Generate the XML output $this->output = $structure->xmlOutput(); } else { /// Switch to HTML and error $this->does_generate = ACTION_GENERATE_HTML; } /// Return ok if arrived here return $result; }
function print_feedback_label($item) { ?> <td colspan="2"> <?php echo stripslashes_safe($item->presentation); ?> </td> <?php }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $confirmed = optional_param('confirmed', false, PARAM_BOOL); /// If not confirmed, show confirmation box if (!$confirmed) { $o = '<table width="60" class="generalbox boxaligncenter" border="0" cellpadding="5" cellspacing="0" id="notice">'; $o .= ' <tr><td class="generalboxcontent">'; $o .= ' <p class="centerpara">' . $this->str['confirmrevertchanges'] . '<br /><br />' . $dirpath . '</p>'; $o .= ' <table class="boxaligncenter" cellpadding="20"><tr><td>'; $o .= ' <div class="singlebutton">'; $o .= ' <form action="index.php?action=revert_changes&sesskey=' . sesskey() . '&confirmed=yes&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&postaction=main_view#lastused" method="post"><fieldset class="invisiblefieldset">'; $o .= ' <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>'; $o .= ' </td><td>'; $o .= ' <div class="singlebutton">'; $o .= ' <form action="index.php?action=main_view#lastused" method="post"><fieldset class="invisiblefieldset">'; $o .= ' <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>'; $o .= ' </td></tr>'; $o .= ' </table>'; $o .= ' </td></tr>'; $o .= '</table>'; $this->output = $o; } else { /// Get the original dir and delete some elements if (!empty($XMLDB->dbdirs)) { if (isset($XMLDB->dbdirs[$dirpath])) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { unset($dbdir->xml_changed); } } } /// Get the edited dir and delete it completely if (!empty($XMLDB->editeddirs)) { if (isset($XMLDB->editeddirs[$dirpath])) { unset($XMLDB->editeddirs[$dirpath]); } } } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE $statementparam = required_param('statement', PARAM_CLEAN); $basesentenceparam = optional_param('basesentence', NULL, PARAM_CLEAN); $statement =& $structure->getStatement($statementparam); $sentences =& $statement->getSentences(); $sentence = NULL; /// If some sentence has been specified, create the new one /// based on it if (!empty($basesentenceparam)) { $sentence = $sentences[$basesentenceparam]; } /// Else, try to create the new one based in the last if (empty($sentence) && !empty($sentences)) { $sentence = end($sentences); } /// Else, create one sentence by hand if (empty($sentence)) { $sentence = "(list, of, fields) VALUES ('list', 'of', 'values')"; } /// Add the sentence to the statement $statement->addSentence($sentence); /// We have one new sentence, so the statement and the structure has changed $statement->setChanged(true); $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
function get_content() { global $WS, $CFG; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); // If we are out of a dfwiki activity or in a different // dfwiki format course and we want to create a block: if (empty($WS->dfwiki)) { $this->content->text = get_string('block_warning', 'wiki'); return $this->content; } $this->content->items = array(); $this->content->icons = array(); /* $this->content->footer = '<br />' . helpbutton('search', $this->title, 'wiki', true, false, '', true) . get_string('search');*/ // $this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki') . // helpbutton ('search', get_string('block_search', 'wiki'), 'wiki', true, false, '', true); // Converts reserved chars for html to prevent chars misreading $pagetemp = stripslashes_safe($WS->page); $formurl = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . $WS->pageaction . '/' . urlencode($pagetemp); $formalturl = $CFG->wwwroot . '/mod/wiki/part/search/index.php?id=' . $WS->cm->id . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . $WS->pageaction . '/' . urlencode($pagetemp); //reurl script ?> <script language="JavaScript" type="text/javascript"> function wiki_search_block_reulr (val) { wiki_form = document.getElementById ('wiki_search_block_form'); if (val) { wiki_form.action = '<?php echo $formalturl; ?> '; } else { wiki_form.action = '<?php echo $formurl; ?> '; } } </script> <?php // mount the form $form = '<form id="wiki_search_block_form"method="post" action="' . $formurl . '">' . '<div><input type="hidden" name="dfsetup" value="5" />' . '<input type="text" name="dfformfield" /><br />'; // if this block is in a course it must submit info to /mod/wiki/view.php if ($this->instance->pagetype != 'mod-wiki-view') { $form .= '<input type="hidden" name="dfformmain" value="ch" />' . '<input type="submit" name="dfformbut" value="' . get_string('search') . '" /><br /></div></form>'; } else { $form .= '<input id="wiki_search_block_check" type="checkbox" name="dfformmain" value="ch" ' . 'onClick="wiki_search_block_reulr (this.checked);"/>' . get_string('detailed', 'wiki') . '<input type="submit" name="dfformbut" value="' . get_string('search') . '" /><br /></div></form>'; } $form .= $this->get_results(); $this->content->text = $form; return $this->content; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the edited dir if (!empty($XMLDB->editeddirs)) { if (isset($XMLDB->editeddirs[$dirpath])) { $editeddir =& $XMLDB->editeddirs[$dirpath]; } } /// Copy the edited dir over the original one if (!empty($XMLDB->dbdirs)) { if (isset($XMLDB->dbdirs[$dirpath])) { $XMLDB->dbdirs[$dirpath] = unserialize(serialize($editeddir)); $dbdir =& $XMLDB->dbdirs[$dirpath]; } } /// Chech for perms if (!is_writeable($dirpath . '/install.xml')) { $this->errormsg = $this->str['filenotwriteable'] . '(' . $dirpath . '/install.xml)'; return false; } /// Save the original dir $result = $dbdir->xml_file->saveXMLFile(); if ($result) { /// Delete the edited dir unset($XMLDB->editeddirs[$dirpath]); /// Unload de originaldir unset($XMLDB->dbdirs[$dirpath]->xml_file); unset($XMLDB->dbdirs[$dirpath]->xml_loaded); unset($XMLDB->dbdirs[$dirpath]->xml_changed); unset($XMLDB->dbdirs[$dirpath]->xml_exists); unset($XMLDB->dbdirs[$dirpath]->xml_writeable); } else { $this->errormsg = 'Error saving XML file (' . $dirpath . ')'; return false; } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE $tableparam = required_param('table', PARAM_CLEAN); $table =& $structure->getTable($tableparam); /// If the changeme field exists, just get it and continue $changeme_exists = false; if ($fields =& $table->getFields()) { if ($field =& $table->getField('changeme')) { $changeme_exists = true; } } if (!$changeme_exists) { /// Lets create the field $field = new XMLDBField('changeme'); $field->setComment('Default comment for the field, please edit me'); $table->addField($field); /// We have one new field, so the structure has changed $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get parameters $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $statementparam = strtolower(required_param('statement', PARAM_CLEAN)); $name = trim(strtolower(required_param('name', PARAM_CLEAN))); $comment = required_param('comment', PARAM_CLEAN); $comment = stripslashes_safe($comment); $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); $statement =& $structure->getStatement($statementparam); $errors = array(); /// To store all the errors found /// If there is one name change, do it, changing the prev and next /// atributes of the adjacent tables if ($statementparam != $name) { $statement->setName($name); if ($statement->getPrevious()) { $prev =& $structure->getStatement($statement->getPrevious()); $prev->setNext($name); $prev->setChanged(true); } if ($statement->getNext()) { $next =& $structure->getStatement($statement->getNext()); $next->setPrevious($name); $next->setChanged(true); } } /// Set comment $statement->setComment($comment); /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) { global $CFG; static $htmleditorused = false; $answers =& $question->options->answers; $readonly = empty($options->readonly) ? '' : 'disabled="disabled"'; // Only use the rich text editor for the first essay question on a page. $usehtmleditor = can_use_html_editor() && !$htmleditorused; $formatoptions = new stdClass(); $formatoptions->noclean = true; $formatoptions->para = false; $inputname = $question->name_prefix; $stranswer = get_string("answer", "quiz") . ': '; /// set question text and media $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course); $image = get_question_image($question); // feedback handling $feedback = ''; if ($options->feedback && !empty($answers)) { foreach ($answers as $answer) { $feedback = format_text($answer->feedback, '', $formatoptions, $cmoptions->course); } } // get response value if (isset($state->responses[''])) { $value = stripslashes_safe($state->responses['']); } else { $value = ""; } // answer if (empty($options->readonly)) { // the student needs to type in their answer so print out a text editor $answer = print_textarea($usehtmleditor, 18, 80, 630, 400, $inputname, $value, $cmoptions->course, true); } else { // it is read only, so just format the students answer and output it $safeformatoptions = new stdClass(); $safeformatoptions->para = false; $answer = format_text($value, FORMAT_MOODLE, $safeformatoptions, $cmoptions->course); $answer = '<div class="answerreview">' . $answer . '</div>'; } include "{$CFG->dirroot}/question/type/essay/display.html"; if ($usehtmleditor && empty($options->readonly)) { use_html_editor($inputname); $htmleditorused = true; } }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $file = $dirpath . '/install.xml'; /// Some variables $xmlpath = dirname(str_replace($CFG->dirroot . '/', '', $file)); $xmlversion = userdate(time(), '%Y%m%d', 99, false); $xmlcomment = 'XMLDB file for Moodle ' . dirname($xmlpath); $xmltable = strtolower(basename(dirname($xmlpath))); /// Initial contents $c = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n"; $c .= ' <XMLDB PATH="' . $xmlpath . '" VERSION="' . $xmlversion . '" COMMENT="' . $xmlcomment . '">' . "\n"; $c .= ' <TABLES>' . "\n"; $c .= ' <TABLE NAME="' . $xmltable . '" COMMENT="Default comment for ' . $xmltable . ', please edit me">' . "\n"; $c .= ' <FIELDS>' . "\n"; $c .= ' <FIELD NAME="id" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" SEQUENCE="true" />' . "\n"; $c .= ' </FIELDS>' . "\n"; $c .= ' <KEYS>' . "\n"; $c .= ' <KEY NAME="primary" TYPE="primary" FIELDS="id" />' . "\n"; $c .= ' </KEYS>' . "\n"; $c .= ' </TABLE>' . "\n"; $c .= ' </TABLES>' . "\n"; $c .= ' </XMLDB>'; if (!file_put_contents($file, $c)) { $errormsg = 'Error creando fichero ' . $file; $result = false; } /// Launch postaction if exists if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the original dir and delete some elements if (!empty($XMLDB->dbdirs)) { if (isset($XMLDB->dbdirs[$dirpath])) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { unset($dbdir->xml_file); unset($dbdir->xml_loaded); unset($dbdir->xml_changed); unset($dbdir->xml_exists); unset($dbdir->xml_writeable); } } } /// Get the edited dir and delete it completely if (!empty($XMLDB->editeddirs)) { if (isset($XMLDB->editeddirs[$dirpath])) { unset($XMLDB->editeddirs[$dirpath]); } } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention error('Wrong action call'); } /// Get parameters $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $comment = required_param('comment', PARAM_CLEAN); $comment = stripslashes_safe($comment); /// Set comment and recalculate hash $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); $structure->setComment($comment); $structure->calculateHash(true); /// If the hash has changed from the original one, change the version /// and mark the structure as changed $origdir =& $XMLDB->dbdirs[$dirpath]; $origstructure =& $origdir->xml_file->getStructure(); if ($structure->getHash() != $origstructure->getHash()) { $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
$feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted); } } } else { $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid); } /// Print the main part of the page /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// print_heading(format_text($feedback->name)); if (isset($savereturn) && $savereturn == 'saved') { if ($feedback->page_after_submit) { // print_simple_box_start('center', '75%'); print_box_start('generalbox boxaligncenter boxwidthwide'); echo format_text(stripslashes_safe($feedback->page_after_submit)); // print_simple_box_end(); print_box_end(); } else { echo '<p align="center"><b><font color="green">' . get_string('entries_saved', 'feedback') . '</font></b></p>'; if (intval($feedback->publish_stats) == 1) { echo '<p align="center"><a href="analysis.php?id=' . $id . '&courseid=' . $courseid . '">'; echo get_string('completed_feedbacks', 'feedback') . '</a>'; echo '</p>'; } } if ($feedback->site_after_submit) { print_continue(feedback_encode_target_url($feedback->site_after_submit)); } else { if ($courseid) { print_continue($CFG->wwwroot . '/course/view.php?id=' . $courseid);
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes //$this->does_generate = ACTION_NONE; $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting $result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dir if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { /// Only if the directory exists and it has been loaded if (!$dbdir->path_exists || !$dbdir->xml_loaded) { return false; } /// Check if the in-memory object exists and create it if (empty($XMLDB->editeddirs)) { $XMLDB->editeddirs = array(); } /// Check if the dir exists and copy it from dbdirs if (!isset($XMLDB->editeddirs[$dirpath])) { $XMLDB->editeddirs[$dirpath] = unserialize(serialize($dbdir)); } /// Get it $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); /// Add the main form $o = '<form id="form" action="index.php" method="post">'; $o .= '<div>'; $o .= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />'; $o .= ' <input type="hidden" name ="action" value="edit_xml_file_save" />'; $o .= ' <input type="hidden" name ="postaction" value="edit_xml_file" />'; $o .= ' <input type="hidden" name ="path" value="' . s($structure->getPath()) . '" />'; $o .= ' <input type="hidden" name ="version" value="' . s($structure->getVersion()) . '" />'; $o .= ' <table id="formelements" class="boxaligncenter">'; $o .= ' <tr valign="top"><td>Path:</td><td>' . s($structure->getPath()) . '</td></tr>'; $o .= ' <tr valign="top"><td>Version:</td><td>' . s($structure->getVersion()) . '</td></tr>'; $o .= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td><textarea name="comment" rows="3" cols="80" id="comment">' . $structure->getComment() . '</textarea></td></tr>'; $o .= ' <tr><td> </td><td><input type="submit" value="' . $this->str['change'] . '" /></td></tr>'; $o .= ' </table>'; $o .= '</div></form>'; /// Calculate the buttons $b = ' <p class="centerpara buttons">'; /// The view original XML button $b .= ' <a href="index.php?action=view_structure_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&select=original">[' . $this->str['vieworiginal'] . ']</a>'; /// The view edited XML button if ($structure->hasChanged()) { $b .= ' <a href="index.php?action=view_structure_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&select=edited">[' . $this->str['viewedited'] . ']</a>'; } else { $b .= ' [' . $this->str['viewedited'] . ']'; } /// The new table button $b .= ' <a href="index.php?action=new_table&postaction=edit_table&table=changeme&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newtable'] . ']</a>'; /// The new from MySQL button if ($CFG->dbfamily == 'mysql') { $b .= ' <a href="index.php?action=new_table_from_mysql&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newtablefrommysql'] . ']</a>'; } else { $b .= ' [' . $this->str['newtablefrommysql'] . ']'; } /// The new statement button $b .= ' <a href="index.php?action=new_statement&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newstatement'] . ']</a>'; /// The back to main menu button $b .= ' <a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>'; $b .= '</p>'; $b .= ' <p class="centerpara buttons">'; /// The view sql code button $b .= '<a href="index.php?action=view_structure_sql&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['viewsqlcode'] . ']</a>'; /// The view php code button $b .= ' <a href="index.php?action=view_structure_php&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['viewphpcode'] . ']</a>'; $b .= '</p>'; $o .= $b; /// Join all the reserved words into one big array /// Calculate list of available SQL generators $plugins = get_list_of_plugins('lib/xmldb/classes/generators'); $reserved_words = array(); foreach ($plugins as $plugin) { $classname = 'XMLDB' . $plugin; $generator = new $classname(); $reserved_words = array_merge($reserved_words, $generator->getReservedWords()); } sort($reserved_words); $reserved_words = array_unique($reserved_words); /// Add the tables list $tables =& $structure->getTables(); if ($tables) { $o .= '<h3 class="main">' . $this->str['tables'] . '</h3>'; $o .= '<table id="listtables" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($tables as $table) { /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button $b .= '<a href="index.php?action=edit_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>'; $b .= '</td><td class="button cell">'; /// The up button if ($table->getPrevious()) { $b .= '<a href="index.php?action=move_updown_table&direction=up&table=' . $table->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= '</td><td class="button cell">'; /// The down button if ($table->getNext()) { $b .= '<a href="index.php?action=move_updown_table&direction=down&table=' . $table->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= '</td><td class="button cell">'; /// The delete button (if we have more than one and it isn't used) if (count($tables) > 1 && !$structure->getTableUses($table->getName())) { ///!$structure->getTableUses($table->getName())) { $b .= '<a href="index.php?action=delete_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>'; } else { $b .= '[' . $this->str['delete'] . ']'; } /// Detect if the table name is a reserved word if (in_array($table->getName(), $reserved_words)) { $b .= ' <a href="index.php?action=view_reserved_words"><span class="error">' . $this->str['reserved'] . '</span></a>'; } $b .= '</td>'; /// Print table row $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_table_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&table=' . $table->getName() . '&select=edited">' . $table->getName() . '</a>' . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; } ///Add the statements list $statements =& $structure->getStatements(); if ($statements) { $o .= '<h3 class="main">' . $this->str['statements'] . '</h3>'; $o .= '<table id="liststatements" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($statements as $statement) { /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button $b .= '<a href="index.php?action=edit_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>'; $b .= '</td><td class="button cell">'; /// The up button if ($statement->getPrevious()) { $b .= '<a href="index.php?action=move_updown_statement&direction=up&statement=' . $statement->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= '</td><td class="button cell">'; /// The down button if ($statement->getNext()) { $b .= '<a href="index.php?action=move_updown_statement&direction=down&statement=' . $statement->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= '</td><td class="button cell">'; /// The delete button $b .= '<a href="index.php?action=delete_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>'; $b .= '</td>'; /// Print statement row $o .= '<tr class="r' . $row . '"><td class="statement cell"><a href="index.php?action=view_statement_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&statement=' . $statement->getName() . '&select=edited">' . $statement->getName() . '</a>' . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; } ///Add the back to main $this->output = $o; } } /// Launch postaction if exists (leave this unmodified) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB, $db; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE $tableparam = optional_param('table', NULL, PARAM_CLEAN); $typeparam = optional_param('type', NULL, PARAM_CLEAN); /// If no table or type, show form if (!$tableparam || !$typeparam) { /// No postaction here $this->postaction = NULL; /// Get list of tables $dbtables = $db->MetaTables('TABLES'); $selecttables = array(); foreach ($dbtables as $dbtable) { $dbtable = str_replace($CFG->prefix, '', $dbtable); $selecttables[$dbtable] = $dbtable; } /// Get list of statement types $typeoptions = array(XMLDB_STATEMENT_INSERT => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_INSERT), XMLDB_STATEMENT_UPDATE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_UPDATE), XMLDB_STATEMENT_DELETE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_DELETE), XMLDB_STATEMENT_CUSTOM => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_CUSTOM)); if (!$selecttables) { $this->errormsg = 'No tables available to create statements'; return false; } /// Now build the form $o = '<form id="form" action="index.php" method="post">'; $o .= '<div>'; $o .= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />'; $o .= ' <input type="hidden" name ="action" value="new_statement" />'; $o .= ' <input type="hidden" name ="postaction" value="edit_statement" />'; $o .= ' <input type="hidden" name ="sesskey" value="' . sesskey() . '" />'; $o .= ' <table id="formelements" class="boxaligncenter" cellpadding="5">'; $o .= ' <tr><td><label for="type" accesskey="t">' . $this->str['statementtype'] . ' </label>' . choose_from_menu($typeoptions, 'type', '', 'choose', '', 0, true) . '<label for="table" accesskey="a">' . $this->str['statementtable'] . ' </label>' . choose_from_menu($selecttables, 'table', '', 'choose', '', 0, true) . '</td></tr>'; $o .= ' <tr><td colspan="2" align="center"><input type="submit" value="' . $this->str['create'] . '" /></td></tr>'; $o .= ' <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>'; $o .= ' </table>'; $o .= '</div></form>'; $this->output = $o; /// If table, retrofit information and, if everything works, /// go to the table edit action } else { /// Get some params (table is mandatory here) $tableparam = required_param('table', PARAM_CLEAN); $typeparam = required_param('type', PARAM_CLEAN); /// Only insert is allowed :-/ if ($typeparam != XMLDB_STATEMENT_INSERT) { $this->errormsg = 'Only insert of records is supported'; return false; } /// Calculate the name of the statement $typename = XMLDBStatement::getXMLDBStatementName($typeparam); $name = trim(strtolower($typename . ' ' . $tableparam)); /// Check that this Statement hasn't been created before if ($structure->getStatement($name)) { $this->errormsg = 'The statement "' . $name . '" already exists, please use it to add more sentences'; return false; } /// Create one new XMLDBStatement $statement = new XMLDBStatement($name); $statement->setType($typeparam); $statement->setTable($tableparam); $statement->setComment('Initial ' . $typename . ' of records on table ' . $tableparam); /// Finally, add the whole retroffited table to the structure /// in the place specified $structure->addStatement($statement); } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $statementparam = required_param('statement', PARAM_CLEAN); $sentenceparam = required_param('sentence', PARAM_INT); $confirmed = optional_param('confirmed', false, PARAM_BOOL); /// If not confirmed, show confirmation box if (!$confirmed) { $o = '<table width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">'; $o .= ' <tr><td class="generalboxcontent">'; $o .= ' <p class="centerpara">' . $this->str['confirmdeletesentence'] . '</p>'; $o .= ' <table class="boxaligncenter" cellpadding="20"><tr><td>'; $o .= ' <div class="singlebutton">'; $o .= ' <form action="index.php?action=delete_sentence&confirmed=yes&postaction=edit_statement&sentence=' . $sentenceparam . '&statement=' . urlencode($statementparam) . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">'; $o .= ' <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>'; $o .= ' </td><td>'; $o .= ' <div class="singlebutton">'; $o .= ' <form action="index.php?action=edit_statement&statement=' . urlencode($statementparam) . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">'; $o .= ' <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>'; $o .= ' </td></tr>'; $o .= ' </table>'; $o .= ' </td></tr>'; $o .= '</table>'; $this->output = $o; } else { /// Get the edited dir if (!empty($XMLDB->editeddirs)) { if (isset($XMLDB->editeddirs[$dirpath])) { $dbdir =& $XMLDB->dbdirs[$dirpath]; $editeddir =& $XMLDB->editeddirs[$dirpath]; if ($editeddir) { $structure =& $editeddir->xml_file->getStructure(); $statements =& $structure->getStatements(); $statement =& $structure->getStatement($statementparam); $sentences =& $statement->getSentences(); /// Remove the sentence unset($sentences[$sentenceparam]); /// The statement has changed $statement->setChanged(true); /// Recalculate the hash $structure->calculateHash(true); /// If the hash has changed from the original one, change the version /// and mark the structure as changed $origstructure =& $dbdir->xml_file->getStructure(); if ($structure->getHash() != $origstructure->getHash()) { $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); } } } } } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE $prev = NULL; $next = NULL; $tableparam = required_param('table', PARAM_CLEAN); $indexparam = required_param('index', PARAM_CLEAN); $direction = required_param('direction', PARAM_ALPHA); $tables =& $structure->getTables(); $table =& $structure->getTable($tableparam); $indexes =& $table->getIndexes(); if ($direction == 'down') { $index =& $table->getIndex($indexparam); $swap =& $table->getIndex($index->getNext()); } else { $swap =& $table->getIndex($indexparam); $index =& $table->getIndex($swap->getPrevious()); } /// Change the index before the pair if ($index->getPrevious()) { $prev =& $table->getIndex($index->getPrevious()); $prev->setNext($swap->getName()); $swap->setPrevious($prev->getName()); $prev->setChanged(true); } else { $swap->setPrevious(NULL); } /// Change the field after the pair if ($swap->getNext()) { $next =& $table->getIndex($swap->getNext()); $next->setPrevious($index->getName()); $index->setNext($next->getName()); $next->setChanged(true); } else { $index->setNext(NULL); } /// Swap the indexes $index->setPrevious($swap->getName()); $swap->setNext($index->getName()); /// Mark indexes as changed $index->setChanged(true); $swap->setChanged(true); /// Table has changed $table->setChanged(true); /// Reorder the indexes $table->orderIndexes($indexes); /// Recalculate the hash $structure->calculateHash(true); /// If the hash has changed from the original one, change the version /// and mark the structure as changed $origstructure =& $dbdir->xml_file->getStructure(); if ($structure->getHash() != $origstructure->getHash()) { $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
function scorm_get_tracks($scoid, $userid, $attempt = '') { /// Gets all tracks of specified sco and user global $CFG; if (empty($attempt)) { if ($scormid = get_field('scorm_scoes', 'scorm', 'id', $scoid)) { $attempt = scorm_get_last_attempt($scormid, $userid); } else { $attempt = 1; } } $attemptsql = ' AND attempt=' . $attempt; if ($tracks = get_records_select('scorm_scoes_track', "userid={$userid} AND scoid={$scoid}" . $attemptsql, 'element ASC')) { $usertrack->userid = $userid; $usertrack->scoid = $scoid; // Defined in order to unify scorm1.2 and scorm2004 $usertrack->score_raw = ''; $usertrack->status = ''; $usertrack->total_time = '00:00:00'; $usertrack->session_time = '00:00:00'; $usertrack->timemodified = 0; foreach ($tracks as $track) { $element = $track->element; $track->value = stripslashes_safe($track->value); $usertrack->{$element} = $track->value; switch ($element) { case 'x.start.time': $usertrack->x_start_time = $track->value; break; case 'cmi.core.lesson_status': case 'cmi.completion_status': if ($track->value == 'not attempted') { $track->value = 'notattempted'; } $usertrack->status = $track->value; break; case 'cmi.core.score.raw': case 'cmi.score.raw': $usertrack->score_raw = sprintf('%0d', $track->value); break; case 'cmi.core.session_time': case 'cmi.session_time': $usertrack->session_time = $track->value; break; case 'cmi.core.total_time': case 'cmi.total_time': $usertrack->total_time = $track->value; break; } if (isset($track->timemodified) && $track->timemodified > $usertrack->timemodified) { $usertrack->timemodified = $track->timemodified; } } if (is_array($usertrack)) { ksort($usertrack); } return $usertrack; } else { return false; } }
function feedback_excelprint_detailed_head(&$worksheet, $items, $rowOffset) { global $fstring, $feedback; if (!$items) { return; } $colOffset = 0; $worksheet->setFormat('<l><f><ru2>'); $worksheet->write_string($rowOffset, $colOffset, $fstring->idnumber); $colOffset++; $worksheet->write_string($rowOffset, $colOffset, $fstring->username); $colOffset++; $worksheet->write_string($rowOffset, $colOffset, $fstring->fullname); $colOffset++; foreach ($items as $item) { $worksheet->setFormat('<l><f><ru2>'); $worksheet->write_string($rowOffset, $colOffset, stripslashes_safe($item->name)); $colOffset++; } $worksheet->setFormat('<l><f><ru2>'); $worksheet->write_string($rowOffset, $colOffset, $fstring->courseid); $colOffset++; $worksheet->setFormat('<l><f><ru2>'); $worksheet->write_string($rowOffset, $colOffset, $fstring->course); $colOffset++; return $rowOffset + 1; }
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false) { $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right'; //get the range $range_from_to = explode('|', $item->presentation); //get the min-value $range_from = isset($range_from_to[0]) ? intval($range_from_to[0]) : 0; //get the max-value $range_to = isset($range_from_to[1]) ? intval($range_from_to[1]) : 0; if ($highlightrequire and !$this->check_value($value, $item)) { $highlight = 'bgcolor="#FFAAAA" class="missingrequire"'; } else { $highlight = ''; } $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : ''; ?> <td <?php echo $highlight; ?> valign="top" align="<?php echo $align; ?> "> <?php echo format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false); switch (true) { case $range_from === 0 and $range_to > 0: echo ' (' . get_string('maximal', 'feedback') . ': ' . $range_to . ')'; break; case $range_from > 0 and $range_to === 0: echo ' (' . get_string('minimal', 'feedback') . ': ' . $range_from . ')'; break; case $range_from === 0 and $range_to === 0: break; default: echo ' (' . $range_from . '-' . $range_to . ')'; break; } ?> </td> <td valign="top" align="<?php echo $align; ?> "> <?php if ($readonly) { // print_simple_box_start($align); print_box_start('generalbox boxalign' . $align); echo $value ? $value : ' '; // print_simple_box_end(); print_box_end(); } else { ?> <input type="text" name="<?php echo $item->typ . '_' . $item->id; ?> " size="10" maxlength="10" value="<?php echo $value ? $value : ''; ?> " /> <?php } ?> </td> <?php }
/** * This function will iterate over $clobs and $blobs array, executing the needed * UpdateClob() and UpdateBlob() ADOdb function calls to store LOBs contents properly * Records to be updated are always searched by PK (id always!) * * Used by Orace CLOBS and BLOBS and MSSQL IMAGES * * This function is private and must not be used outside dmllib at all * * @param $table string the table where the record is going to be inserted/updated (without prefix) * @param $sqlcondition mixed value defining the records to be LOB-updated. It it's a number, must point * to the PK og the table (id field), else it's processed as one harcoded SQL condition (WHERE clause) * @param $clobs array of clobs to be updated * @param $blobs array of blobs to be updated */ function db_update_lobs($table, $sqlcondition, &$clobs, &$blobs) { global $CFG, $db; $status = true; /// Initial configuration, based on DB switch ($CFG->dbfamily) { case 'oracle': $clobdbtype = 'CLOB'; //Name of clobs for this DB $blobdbtype = 'BLOB'; //Name of blobs for this DB break; case 'mssql': $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under mssql flavours we don't process CLOBS) $blobdbtype = 'IMAGE'; //Name of blobs for this DB break; case 'postgres': $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under postgres flavours we don't process CLOBS) $blobdbtype = 'BYTEA'; //Name of blobs for this DB break; default: return; //Other DB doesn't need this two step to happen, prevent continue } /// Calculate the update sql condition if (is_numeric($sqlcondition)) { /// If passing a number, it's the PK of the table (id) $sqlcondition = 'id=' . $sqlcondition; } else { /// Else, it's a formal standard SQL condition, we try to delete the WHERE in case it exists $sqlcondition = trim(preg_replace('/^WHERE/is', '', trim($sqlcondition))); } /// Update all the clobs if ($clobs) { foreach ($clobs as $key => $value) { if (defined('MDL_PERFDB')) { global $PERF; $PERF->dbqueries++; } /// Count the extra updates in PERF /// Oracle CLOBs doesn't like quoted strings (are inserted via prepared statemets) if ($CFG->dbfamily == 'oracle') { $value = stripslashes_safe($value); } if (!$db->UpdateClob($CFG->prefix . $table, $key, $value, $sqlcondition)) { $status = false; $statement = "UpdateClob('{$CFG->prefix}{$table}', '{$key}', '" . substr($value, 0, 100) . "...', '{$sqlcondition}')"; debugging($db->ErrorMsg() . "<br /><br />" . s($statement)); if (!empty($CFG->dblogerror)) { $debug = array_shift(debug_backtrace()); error_log("SQL " . $db->ErrorMsg() . " in {$debug['file']} on line {$debug['line']}. STATEMENT: {$statement}"); } } } } /// Update all the blobs if ($blobs) { foreach ($blobs as $key => $value) { if (defined('MDL_PERFDB')) { global $PERF; $PERF->dbqueries++; } /// Count the extra updates in PERF /// Oracle, MSSQL and PostgreSQL BLOBs doesn't like quoted strings (are inserted via prepared statemets) if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql' || $CFG->dbfamily == 'postgres') { $value = stripslashes_safe($value); } if (!$db->UpdateBlob($CFG->prefix . $table, $key, $value, $sqlcondition)) { $status = false; $statement = "UpdateBlob('{$CFG->prefix}{$table}', '{$key}', '" . substr($value, 0, 100) . "...', '{$sqlcondition}')"; debugging($db->ErrorMsg() . "<br /><br />" . s($statement)); if (!empty($CFG->dblogerror)) { $debug = array_shift(debug_backtrace()); error_log("SQL " . $db->ErrorMsg() . " in {$debug['file']} on line {$debug['line']}. STATEMENT: {$statement}"); } } } } return $status; }
/** * Print a message in a standard themed box. * This old function used to implement boxes using tables. Now it uses a DIV, but the old * parameters remain. If possible, $align, $width and $color should not be defined at all. * Preferably just use print_box() in weblib.php * * @param string $align, alignment of the box, not the text (default center, left, right). * @param string $width, width of the box, including units %, for example '100%'. * @param string $color, background colour of the box, for example '#eee'. * @param int $padding, padding in pixels, specified without units. * @param string $class, space-separated class names. * @param string $id, space-separated id names. * @param boolean $return, return as string or just print it */ function print_simple_box($message, $align = '', $width = '', $color = '', $padding = 5, $class = 'generalbox', $id = '', $return = false) { $output = ''; $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true); $output .= stripslashes_safe($message); $output .= print_simple_box_end(true); if ($return) { return $output; } else { echo $output; } }
function excelprint_detailed_head(&$worksheet, $items, $rowOffset) { if (!$items) { return; } $colOffset = 0; foreach ($items as $item) { $worksheet->setFormat('<l><f><ru2>'); $worksheet->write_string($rowOffset, $colOffset, stripslashes_safe($item->name)); $colOffset++; } return $rowOffset + 1; }
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false) { $info = $this->get_info($item); $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right'; $presentation = explode(FEEDBACK_MULTICHOICE_LINE_SEP, stripslashes_safe($info->presentation)); //test if required and no value is set so we have to mark this item //we have to differ check and the other subtypes if ($info->subtype == 'c') { if (is_array($value)) { $values = $value; } else { $values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value); } if ($highlightrequire and $item->required and $values[0] == '') { $highlight = 'bgcolor="#FFAAAA" class="missingrequire"'; } else { $highlight = ''; } $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : ''; echo '<td ' . $highlight . ' valign="top" align="' . $align . '">' . format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false) . '</td>'; echo '<td valign="top" align="' . $align . '">'; } else { if ($highlightrequire and $item->required and intval($value) <= 0) { $highlight = 'bgcolor="#FFAAAA" class="missingrequire"'; } else { $highlight = ''; } $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : ''; ?> <td <?php echo $highlight; ?> valign="top" align="<?php echo $align; ?> "><?php echo format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false); ?> </td> <td valign="top" align="<?php echo $align; ?> "> <?php } $index = 1; $checked = ''; if ($readonly) { if ($info->subtype == 'c') { print_box_start('generalbox boxalign' . $align); foreach ($presentation as $pres) { foreach ($values as $val) { if ($val == $index) { echo text_to_html($pres . '<br />', true, false, false); break; } } $index++; } // print_simple_box_end(); print_box_end(); } else { foreach ($presentation as $pres) { if ($value == $index) { // print_simple_box_start($align); print_box_start('generalbox boxalign' . $align); echo text_to_html($pres, true, false, false); // print_simple_box_end(); print_box_end(); break; } $index++; } } } else { //print the "not_selected" item on radiobuttons if ($info->subtype == 'r') { ?> <table><tr> <td valign="top" align="<?php echo $align; ?> "><input type="radio" name="<?php echo $item->typ . '_' . $item->id; ?> " id="<?php echo $item->typ . '_' . $item->id . '_xxx'; ?> " value="" <?php echo $value ? '' : 'checked="checked"'; ?> /> </td> <td align="<?php echo $align; ?> "> <label for="<?php echo $item->typ . '_' . $item->id . '_xxx'; ?> "><?php print_string('not_selected', 'feedback'); ?> </label> </td> </tr></table> <?php } if ($info->subtype != 'd') { if ($info->horizontal) { echo '<table><tr>'; } } switch ($info->subtype) { case 'r': $this->print_item_radio($presentation, $item, $value, $info, $align); break; case 'c': $this->print_item_check($presentation, $item, $value, $info, $align); break; case 'd': $this->print_item_dropdown($presentation, $item, $value, $info, $align); break; } if ($info->subtype != 'd') { if ($info->horizontal) { echo '</tr></table>'; } } /* if($item->required == 1) { echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />'; } */ } ?> </td> <?php }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention error('Wrong action call'); } /// Get parameters $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); $tableparam = strtolower(required_param('table', PARAM_PATH)); $name = substr(trim(strtolower(required_param('name', PARAM_PATH))), 0, 28); $comment = required_param('comment', PARAM_CLEAN); $comment = stripslashes_safe($comment); $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); $table =& $structure->getTable($tableparam); $errors = array(); /// To store all the errors found /// Perform some checks /// Check empty name if (empty($name)) { $errors[] = $this->str['tablenameempty']; } /// Check incorrect name if ($name == 'changeme') { $errors[] = $this->str['incorrecttablename']; } /// Check duplicatename if ($tableparam != $name && $structure->getTable($name)) { $errors[] = $this->str['duplicatetablename']; } if (!empty($errors)) { $temptable = new XMLDBTable($name); /// Prepare the output $site = get_site(); $navlinks = array(); $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("{$site->shortname}: XMLDB", "{$site->fullname}", $navigation); notice('<p>' . implode(', ', $errors) . '</p> <p>' . $temptable->readableInfo(), 'index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); die; /// re-die :-P } /// If there is one name change, do it, changing the prev and next /// atributes of the adjacent tables if ($tableparam != $name) { $table->setName($name); if ($table->getPrevious()) { $prev =& $structure->getTable($table->getPrevious()); $prev->setNext($name); $prev->setChanged(true); } if ($table->getNext()) { $next =& $structure->getTable($table->getNext()); $next->setPrevious($name); $next->setChanged(true); } } /// Set comment $table->setComment($comment); /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
function print_feedback_radio($item, $value = false, $readonly = false) { $presentation = explode("|", stripslashes_safe($item->presentation)); $requiredmark = $item->required == 1 ? '<font color="red">*</font>' : ''; ?> <td valign="top" align="left"><?php echo text_to_html(stripslashes_safe($item->name) . $requiredmark, true, false, false); ?> </td> <td valign="top" align="left"> <?php $index = 1; $checked = ''; if ($readonly) { foreach ($presentation as $radio) { if ($value == $index) { print_simple_box_start('left'); echo text_to_html($radio, true, false, false); print_simple_box_end(); break; } $index++; } } else { foreach ($presentation as $radio) { if ($value == $index) { $checked = 'checked="checked"'; } else { $checked = ''; } ?> <table><tr> <td valign="top"><input type="radio" name="<?php echo $item->typ . '_' . $item->id; ?> " value="<?php echo $index; ?> " <?php echo $checked; ?> /> </td><td><?php echo text_to_html($radio, true, false, false); ?> </td></tr></table> <?php $index++; } /* if($item->required == 1) { echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />'; } */ } ?> </td> <?php }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE /// Get parameters $tableparam = required_param('table', PARAM_PATH); if (!($table =& $structure->getTable($tableparam))) { $this->errormsg = 'Wrong table specified: ' . $tableparam; return false; } $generatorparam = optional_param('generator', null, PARAM_ALPHANUM); if (empty($generatorparam)) { $generatorparam = $CFG->dbtype; } /// Calculate list of available SQL generators $plugins = get_list_of_plugins('lib/xmldb/classes/generators'); $generators = array(); foreach ($plugins as $plugin) { $generators[$plugin] = $plugin; } /// Check we have the selected generator if (!in_array($generatorparam, $generators)) { $generatorparam = reset($generators); } /// The back to edit table button $b = ' <p class="centerpara buttons">'; $b .= '<a href="index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>'; $b .= '</p>'; $o = $b; $o .= ' <table id="formelements" class="boxaligncenter" cellpadding="5">'; $o .= ' <tr><td align="center">' . $this->str['selectdb']; /// Show the popup of generators $url = 'index.php?action=view_table_sql&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&generator='; $o .= popup_form($url, $generators, 'selectgenerator', $generatorparam, '', '', '', true); $o .= ' </td></tr>'; $o .= ' <tr><td><textarea cols="80" rows="32">'; /// Get an array of statements if ($starr = $table->getCreateTableSQL($generatorparam, $CFG->prefix)) { $sqltext = ''; foreach ($starr as $st) { $sqltext .= s($st) . "\n\n"; } $sqltext = trim($sqltext); $o .= $sqltext; } $o .= '</textarea></td></tr>'; $o .= ' </table>'; $this->output = $o; /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }