Skip to content

Commit

Permalink
MDL-22388 Added some checks to kill these scripts dead with an unequi…
Browse files Browse the repository at this point in the history
…vocal notice unless included properly from a Moodle script.
  • Loading branch information
moodler committed May 13, 2010
1 parent f60d078 commit bfebaf6
Show file tree
Hide file tree
Showing 99 changed files with 415 additions and 23 deletions.
4 changes: 4 additions & 0 deletions admin/dbtransfer/database_export_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class database_export_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions admin/dbtransfer/database_transfer_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class database_transfer_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions admin/mnet/profileform.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir . '/formslib.php');

/**
Expand Down
4 changes: 4 additions & 0 deletions admin/mnet/services_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir . '/formslib.php');

class mnet_services_form extends moodleform {
Expand Down
39 changes: 22 additions & 17 deletions admin/uploadpicture_form.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
<?php
require_once $CFG->libdir.'/formslib.php';

class admin_uploadpicture_form extends moodleform {
function definition (){
global $CFG, $USER;
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

$mform =& $this->_form;
require_once $CFG->libdir.'/formslib.php';

$this->set_upload_manager(new upload_manager('userpicturesfile', false, false, null, false, 0, true, true, false));
class admin_uploadpicture_form extends moodleform {
function definition (){
global $CFG, $USER;

$mform->addElement('header', 'settingsheader', get_string('upload'));
$mform =& $this->_form;

$mform->addElement('file', 'userpicturesfile', get_string('file'), 'size="40"');
$mform->addRule('userpicturesfile', null, 'required');
$this->set_upload_manager(new upload_manager('userpicturesfile', false, false, null, false, 0, true, true, false));

$choices =& $this->_customdata;
$mform->addElement('select', 'userfield', get_string('uploadpicture_userfield', 'admin'), $choices);
$mform->setType('userfield', PARAM_INT);
$mform->addElement('header', 'settingsheader', get_string('upload'));

$choices = array( 0 => get_string('no'), 1 => get_string('yes') );
$mform->addElement('select', 'overwritepicture', get_string('uploadpicture_overwrite', 'admin'), $choices);
$mform->setType('overwritepicture', PARAM_INT);
$mform->addElement('file', 'userpicturesfile', get_string('file'), 'size="40"');
$mform->addRule('userpicturesfile', null, 'required');

$this->add_action_buttons(false, get_string('uploadpictures', 'admin'));
}
$choices =& $this->_customdata;
$mform->addElement('select', 'userfield', get_string('uploadpicture_userfield', 'admin'), $choices);
$mform->setType('userfield', PARAM_INT);

$choices = array( 0 => get_string('no'), 1 => get_string('yes') );
$mform->addElement('select', 'overwritepicture', get_string('uploadpicture_overwrite', 'admin'), $choices);
$mform->setType('overwritepicture', PARAM_INT);

$this->add_action_buttons(false, get_string('uploadpictures', 'admin'));
}
}

5 changes: 5 additions & 0 deletions admin/uploaduser_form.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class admin_uploaduser_form1 extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions admin/user/user_message_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class user_message_form extends moodleform {
Expand Down
1 change: 1 addition & 0 deletions blocks/blog_recent/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

class block_blog_recent_edit_form extends block_edit_form {
protected function specific_definition($mform) {
// Fields for editing HTML block title and contents.
Expand Down
2 changes: 1 addition & 1 deletion blocks/blog_tags/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ protected function specific_definition($mform) {
$mform->addElement('select', 'config_sort', get_string('tagsort', 'blog'), $sort);
$mform->setDefault('config_sort', BLOGDEFAULTSORT);
}
}
}
4 changes: 4 additions & 0 deletions blocks/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir . '/formslib.php');

/**
Expand Down
4 changes: 4 additions & 0 deletions blog/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class blog_edit_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions blog/external_blog_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class blog_edit_external_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions blog/preferences_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class blog_preferences_form extends moodleform {
Expand Down
6 changes: 5 additions & 1 deletion calendar/event_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
/**
* Always include formslib
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->dirroot.'/lib/formslib.php');

/**
Expand Down Expand Up @@ -175,4 +179,4 @@ function validation($data, $files) {
return $errors;
}

}
}
6 changes: 5 additions & 1 deletion cohort/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->dirroot . '/lib/formslib.php');

class cohort_edit_form extends moodleform {
Expand Down Expand Up @@ -101,4 +105,4 @@ protected function get_category_options($currentcontextid) {
return $options;
}
}


4 changes: 4 additions & 0 deletions course/completion_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
// //
///////////////////////////////////////////////////////////////////////////

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class course_completion_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/delete_category_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/questionlib.php');

Expand Down
4 changes: 4 additions & 0 deletions course/edit_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class course_edit_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/editcategory_form.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class editcategory_form extends moodleform {

Expand Down
4 changes: 4 additions & 0 deletions course/editsection_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class editsection_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/import/activities/import_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class course_import_activities_form_1 extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/import/groups/import_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class course_import_groups_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/recent_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* @package course
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class recent_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions course/request_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
* @package course
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

/**
Expand Down
4 changes: 4 additions & 0 deletions course/reset_form.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class course_reset_form extends moodleform {
Expand Down
5 changes: 5 additions & 0 deletions enrol/authorize/config_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}


if (!isset($frm->enrol_cost)) $frm->enrol_cost = '5';
if (!isset($frm->enrol_currency)) $frm->enrol_currency = 'USD';
if (!isset($frm->enrol_mailstudents)) $frm->enrol_mailstudents = '';
Expand Down
4 changes: 4 additions & 0 deletions enrol/authorize/enrol_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

class enrol_authorize_form extends moodleform
Expand Down
4 changes: 4 additions & 0 deletions filter/local_settings_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
*//** */
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir . '/formslib.php');

abstract class filter_local_settings_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions grade/edit/letter/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class edit_letter_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions grade/edit/outcome/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class edit_outcome_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions grade/edit/outcome/import_outcomes_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->dirroot.'/lib/formslib.php');

class import_outcomes_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions grade/edit/scale/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once $CFG->libdir.'/formslib.php';

class edit_scale_form extends moodleform {
Expand Down
4 changes: 4 additions & 0 deletions grade/edit/settings/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

require_once($CFG->libdir.'/formslib.php');

/**
Expand Down
Loading

0 comments on commit bfebaf6

Please sign in to comment.