Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00032 class edit_xml_file_save extends XMLDBAction {
00033 
00037     function init() {
00038         parent::init();
00039 
00040         // Set own custom attributes
00041 
00042         // Get needed strings
00043         $this->loadStrings(array(
00044             // 'key' => 'module',
00045         ));
00046     }
00047 
00053     function invoke() {
00054         parent::invoke();
00055 
00056         $result = true;
00057 
00058         // Set own core attributes
00059         $this->does_generate = ACTION_NONE;
00060         //$this->does_generate = ACTION_GENERATE_HTML;
00061 
00062         // These are always here
00063         global $CFG, $XMLDB;
00064 
00065         // Do the job, setting result as needed
00066 
00067         if (!data_submitted()) { // Basic prevention
00068             print_error('wrongcall', 'error');
00069         }
00070 
00071         // Get parameters
00072         $dirpath = required_param('dir', PARAM_PATH);
00073         $dirpath = $CFG->dirroot . $dirpath;
00074 
00075         $comment = required_param('comment', PARAM_CLEAN);
00076         $comment = $comment;
00077 
00078         // Set comment and recalculate hash
00079         $editeddir =& $XMLDB->editeddirs[$dirpath];
00080         $structure =& $editeddir->xml_file->getStructure();
00081         $structure->setComment($comment);
00082         $structure->calculateHash(true);
00083 
00084 
00085         // If the hash has changed from the original one, change the version
00086         // and mark the structure as changed
00087         $origdir =& $XMLDB->dbdirs[$dirpath];
00088         $origstructure =& $origdir->xml_file->getStructure();
00089         if ($structure->getHash() != $origstructure->getHash()) {
00090             $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
00091             $structure->setChanged(true);
00092         }
00093 
00094         // Launch postaction if exists (leave this here!)
00095         if ($this->getPostAction() && $result) {
00096             return $this->launch($this->getPostAction());
00097         }
00098 
00099         // Return ok if arrived here
00100         return $result;
00101     }
00102 }
00103 
 All Data Structures Namespaces Files Functions Variables Enumerations