community block/publication MDL-23056 use required_param instead of optional_param when possible

This commit is contained in:
jerome mouneyrac 2010-11-09 02:35:36 +00:00
parent 54ab8769cd
commit 0d731457f7
5 changed files with 7 additions and 15 deletions

View File

@ -33,8 +33,7 @@ require_once($CFG->dirroot . '/blocks/community/forms.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
require_login();
$courseid = optional_param('courseid', $SITE->id, PARAM_INT); //if no courseid is given
$courseid = required_param('courseid', PARAM_INT); //if no courseid is given
$parentcourse = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $courseid);

View File

@ -39,9 +39,9 @@ require_once($CFG->libdir . '/filelib.php');
//retrieve initial page parameters
$id = optional_param('id', 0, PARAM_INT);
$hubcourseid = optional_param('hubcourseid', 0, PARAM_INT);
$huburl = optional_param('huburl', '', PARAM_URL);
$id = required_param('id', PARAM_INT);
$hubcourseid = required_param('hubcourseid', PARAM_INT);
$huburl = required_param('huburl', PARAM_URL);
$hubname = optional_param('hubname', '', PARAM_TEXT);
//some permissions and parameters checking
@ -51,9 +51,6 @@ if (!has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE
or !confirm_sesskey()) {
throw new moodle_exception('nopermission');
}
if (empty($huburl) or empty($hubcourseid)) {
throw new moodle_exception('missingparameter');
}
//page settings
$PAGE->set_url('/course/publish/backup.php');

View File

@ -29,7 +29,7 @@ require('../../config.php');
require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/lib.php');
require_once($CFG->dirroot.'/course/publish/forms.php');
$id = optional_param('id', 0, PARAM_INT);
$id = required_param('id', PARAM_INT);
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_login($course);

View File

@ -30,7 +30,7 @@ require('../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
require_once($CFG->dirroot . '/course/publish/lib.php');
$id = optional_param('id', 0, PARAM_INT);
$id = required_param('id', PARAM_INT);
$hubname = optional_param('hubname', 0, PARAM_TEXT);
$huburl = optional_param('huburl', 0, PARAM_URL);

View File

@ -38,11 +38,7 @@ require_once($CFG->libdir . '/filelib.php');
//check user access capability to this page
$id = optional_param('id', 0, PARAM_INT);
if (empty($id)) {
throw new moodle_exception('wrongurlformat', 'hub');
}
$id = required_param('id', PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_login($course);