本文整理汇总了PHP中stripslashes_safe函数的典型用法代码示例。如果您正苦于以下问题:PHP stripslashes_safe函数的具体用法?PHP stripslashes_safe怎么用?PHP stripslashes_safe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stripslashes_safe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoke
/**
* 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;
}
示例2: invoke
/**
* 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;
}
示例3: invoke
/**
* 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;
}
示例4: invoke
/**
* 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;
}
示例5: print_feedback_label
function print_feedback_label($item)
{
?>
<td colspan="2">
<?php
echo stripslashes_safe($item->presentation);
?>
</td>
<?php
}
示例6: invoke
/**
* 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;
}
示例7: invoke
/**
* 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;
}
示例8: get_content
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;
}
示例9: invoke
/**
* 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;
}
示例10: invoke
/**
* 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;
}
示例11: invoke
/**
* 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;
}
示例12: print_question_formulation_and_controls
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;
}
}
示例13: invoke
/**
* 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;
}
示例14: invoke
/**
* 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;
}
示例15: invoke
/**
* 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;
}