public function definition() { global $CFG; $strrequired = get_string('required'); //retrieve the publication $hub = new local_hub(); $course = $hub->get_course($this->_customdata['id']); $mform =& $this->_form; $mform->addElement('header', 'moodle', get_string('coursesettingsform', 'local_hub', $course->fullname)); $mform->addElement('hidden', 'id', $course->id); $mform->setType('id', PARAM_INT); $mform->addElement('checkbox', 'visible', get_string('coursevisibility', 'local_hub')); $mform->addHelpButton('visible', 'coursevisibility', 'local_hub'); $mform->setDefault('visible', $course->privacy); $mform->addElement('text', 'fullname', get_string('coursename', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('fullname', PARAM_TEXT); $mform->addHelpButton('fullname', 'coursename', 'local_hub'); $mform->setDefault('fullname', $course->fullname); $mform->addRule('fullname', $strrequired, 'required', null, 'client'); if (!empty($course->courseurl)) { $mform->addElement('text', 'courseurl', get_string('courseurl', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('courseurl', PARAM_URL); $mform->addHelpButton('courseurl', 'courseurl', 'local_hub'); $mform->setDefault('courseurl', $course->courseurl); $mform->addRule('courseurl', $strrequired, 'required', null, 'client'); } else { $mform->addElement('text', 'demourl', get_string('demourl', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('demourl', PARAM_URL); $mform->addHelpButton('demourl', 'demourl', 'local_hub'); $mform->setDefault('demourl', $course->demourl); } $mform->addElement('textarea', 'description', get_string('coursedesc', 'local_hub'), array('rows' => 10, 'cols' => 56, 'class' => 'coursesettingstextarea')); $mform->addHelpButton('description', 'coursedesc', 'local_hub'); $mform->addRule('description', $strrequired, 'required', null, 'client'); $mform->setDefault('description', $course->description); $languages = get_string_manager()->get_list_of_languages(); asort($languages, SORT_LOCALE_STRING); $mform->addElement('select', 'language', get_string('courselang', 'local_hub'), $languages); $mform->setDefault('language', $course->language); $mform->addHelpButton('language', 'courselang', 'local_hub'); $mform->addElement('text', 'publishername', get_string('publishername', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('publishername', PARAM_TEXT); $mform->setDefault('publishername', $course->publishername); $mform->addRule('publishername', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publishername', 'publishername', 'local_hub'); $mform->addElement('text', 'publisheremail', get_string('publisheremail', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('publisheremail', PARAM_EMAIL); $mform->setDefault('publisheremail', $course->publisheremail); $mform->addRule('publisheremail', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publisheremail', 'publisheremail', 'local_hub'); $mform->addElement('text', 'creatorname', get_string('creatorname', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->addRule('creatorname', $strrequired, 'required', null, 'client'); $mform->setType('creatorname', PARAM_TEXT); $mform->setDefault('creatorname', $course->creatorname); $mform->addHelpButton('creatorname', 'creatorname', 'local_hub'); $mform->addElement('text', 'contributornames', get_string('contributornames', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('contributornames', PARAM_TEXT); $mform->setDefault('contributornames', $course->contributornames); $mform->addHelpButton('contributornames', 'contributornames', 'local_hub'); $mform->addElement('text', 'coverage', get_string('tags', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('coverage', PARAM_TEXT); $mform->setDefault('coverage', $course->coverage); $mform->addHelpButton('coverage', 'tags', 'local_hub'); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('licence', 'local_hub'), $options); $mform->setDefault('licence', $course->licenceshortname); unset($options); $mform->addHelpButton('licence', 'licence', 'local_hub'); require_once $CFG->dirroot . "/course/publish/lib.php"; $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); //prepare data for the smartselect foreach ($options as $key => &$option) { $keylength = strlen($key); if ($keylength == 10) { $option = " " . $option; } else { if ($keylength == 12) { $option = " " . $option; } } } $options = array('none' => get_string('none', 'local_hub')) + $options; $mform->addElement('select', 'subject', get_string('subject', 'local_hub'), $options); unset($options); $mform->addHelpButton('subject', 'subject', 'local_hub'); $mform->setDefault('subject', $course->subject); $mform->addRule('subject', $strrequired, 'required', null, 'client'); $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact')); $options = array(); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'local_hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'local_hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'local_hub'); $mform->addElement('select', 'audience', get_string('audience', 'local_hub'), $options); $mform->setDefault('audience', $course->audience); unset($options); $mform->addHelpButton('audience', 'audience', 'local_hub'); $options = array(); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'local_hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'local_hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'local_hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'local_hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'local_hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'local_hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'local_hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'local_hub'), $options); $mform->setDefault('educationallevel', $course->educationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'local_hub'); //setdefault is currently not supported making this required field not usable MDL-20988 $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false); $mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions); $mform->setType('creatornotes', PARAM_CLEANHTML); $mform->addHelpButton('creatornotes', 'creatornotes', 'hub'); //set default value for creatornotes editor $data = new stdClass(); $data->creatornotes = array(); $data->creatornotes['text'] = $course->creatornotes; $data->creatornotes['format'] = $course->creatornotesformat; $this->set_data($data); //select screenshots to keep for ($screenshotnumber = 1; $screenshotnumber <= $course->screenshots; $screenshotnumber++) { $baseurl = new moodle_url($CFG->wwwroot . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE, 'screenshotnumber' => $screenshotnumber, 'alwaysreload' => time())); $screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname)); $coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => '')); $mform->addElement('checkbox', 'screenshot_' . $screenshotnumber, get_string('keepscreenshot', 'local_hub'), $coursescreenshot); $mform->addHelpButton('screenshot_' . $screenshotnumber, 'keepscreenshot', 'local_hub'); $mform->setDefault('screenshot_' . $screenshotnumber, 1); } $mform->addElement('filemanager', 'addscreenshots', get_string('addscreenshots', 'local_hub'), null, array('subdirs' => 0, 'maxbytes' => 1000000, 'maxfiles' => MAXSCREENSHOTSNUMBER)); $mform->addHelpButton('addscreenshots', 'addscreenshots', 'local_hub'); $this->add_action_buttons(false, get_string('update')); }
// // /////////////////////////////////////////////////////////////////////////// /** * On this page administrator can change site settings * @package localhub * @copyright 2010 Moodle Pty Ltd (http://moodle.com) * @author Jerome Mouneyrac * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require '../../../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->dirroot . '/local/hub/admin/forms.php'; admin_externalpage_setup('hubcoursesettings'); $id = optional_param('id', 0, PARAM_INT); $hub = new local_hub(); $course = $hub->get_course($id, MUST_EXIST); //define nav bar $PAGE->set_url('/local/hub/admin/coursesettings.php', array('id' => $id)); $PAGE->navbar->ignore_active(true); $PAGE->navbar->add(get_string('administrationsite')); $PAGE->navbar->add(get_string('hub', 'local_hub')); $PAGE->navbar->add(get_string('managecourses', 'local_hub'), new moodle_url('/local/hub/admin/managecourses.php', array('courseid' => $course->id, 'sesskey' => sesskey()))); $PAGE->navbar->add(get_string('coursesettings', 'local_hub'), new moodle_url('/local/hub/admin/coursesettings.php', array('id' => $id))); $coursesettingsform = new hub_course_settings_form('', array('id' => $id)); $fromform = $coursesettingsform->get_data(); //Save settings and redirect to search site page if (!empty($fromform) and confirm_sesskey()) { //update the course values $course->fullname = $fromform->fullname; $course->description = $fromform->description; $course->language = $fromform->language;
$xmlrpcnotification .= get_string('xmlrpcdisabled', 'local_hub'); echo $OUTPUT->notification($xmlrpcnotification); echo $OUTPUT->footer(); die; } $hub = new local_hub(); $renderer = $PAGE->get_renderer('local_hub'); /// BULK OPERATIONS $bulkoperation = optional_param('bulkselect', false, PARAM_ALPHANUM); $confirm = optional_param('confirm', false, PARAM_INTEGER); if (!empty($bulkoperation) and confirm_sesskey()) { //retrieve all ids for ($i = 1; $i <= HUB_COURSE_PER_PAGE; $i = $i + 1) { $selectedcourseid = optional_param('bulk-' . $i, false, PARAM_INTEGER); if (!empty($selectedcourseid)) { $bulkcourses[] = $hub->get_course($selectedcourseid); } } if (!$confirm) { echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('managecourses', 'local_hub'), 3, 'main'); echo $renderer->course_bulk_operation_confirmation($bulkcourses, $bulkoperation); echo $OUTPUT->footer(); die; } else { if ($bulkoperation == 'bulkdelete') { foreach ($bulkcourses as $bulkcourse) { $hub->delete_course($bulkcourse->id); } } else { foreach ($bulkcourses as $bulkcourse) {