|
Moodle
2.2.1
http://www.collinsharper.com
|
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 delete_xml_file 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 'confirmdeletexmlfile' => 'tool_xmldb', 00045 'yes' => '', 00046 'no' => '' 00047 )); 00048 } 00049 00055 function invoke() { 00056 parent::invoke(); 00057 00058 $result = true; 00059 00060 // Set own core attributes 00061 $this->does_generate = ACTION_GENERATE_HTML; 00062 00063 // These are always here 00064 global $CFG, $XMLDB; 00065 00066 // Do the job, setting result as needed 00067 00068 // Get the dir containing the file 00069 $dirpath = required_param('dir', PARAM_CLEAN); 00070 $dirpath = $CFG->dirroot . $dirpath; 00071 00072 $confirmed = optional_param('confirmed', false, PARAM_BOOL); 00073 00074 // If not confirmed, show confirmation box 00075 if (!$confirmed) { 00076 $o = '<table width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">'; 00077 $o.= ' <tr><td class="generalboxcontent">'; 00078 $o.= ' <p class="centerpara">' . $this->str['confirmdeletexmlfile'] . '<br /><br />' . $dirpath . '/install.php</p>'; 00079 $o.= ' <table class="boxaligncenter" cellpadding="20"><tr><td>'; 00080 $o.= ' <div class="singlebutton">'; 00081 $o.= ' <form action="index.php?action=delete_xml_file&sesskey=' . sesskey() . '&confirmed=yes&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&postaction=main_view#lastused" method="post"><fieldset class="invisiblefieldset">'; 00082 $o.= ' <input type="submit" value="'. $this->str['yes'] .'" /></fieldset></form></div>'; 00083 $o.= ' </td><td>'; 00084 $o.= ' <div class="singlebutton">'; 00085 $o.= ' <form action="index.php?action=main_view#lastused" method="post"><fieldset class="invisiblefieldset">'; 00086 $o.= ' <input type="submit" value="'. $this->str['no'] .'" /></fieldset></form></div>'; 00087 $o.= ' </td></tr>'; 00088 $o.= ' </table>'; 00089 $o.= ' </td></tr>'; 00090 $o.= '</table>'; 00091 00092 $this->output = $o; 00093 } else { 00094 // Get the original dir and delete the xml file 00095 if (!empty($XMLDB->dbdirs)) { 00096 if (isset($XMLDB->dbdirs[$dirpath])) { 00097 $dbdir =& $XMLDB->dbdirs[$dirpath]; 00098 if ($dbdir) { 00099 @unlink($dirpath . '/install.xml'); 00100 } 00101 } 00102 } 00103 } 00104 00105 // Launch postaction if exists (leave this here!) 00106 if ($this->getPostAction() && $result) { 00107 return $this->launch($this->getPostAction()); 00108 } 00109 00110 // Return ok if arrived here 00111 return $result; 00112 } 00113 } 00114