Commit 47f0a3dd authored by Daniel Neis Araujo's avatar Daniel Neis Araujo

excluindo cursos em destaque

parent ac978278
......@@ -138,4 +138,9 @@ class block_featuredcourses extends block_base {
ORDER BY sortorder';
return $DB->get_records_sql($sql);
}
static function delete_featuredcourse($courseid) {
global $DB;
return $DB->delete_records('block_featuredcourses', array('courseid' => $courseid));
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* deletes a featured course
*
* @package block_featuredcourses
* @author Daniel Neis
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
require_once("../../config.php");
require_once($CFG->dirroot.'/blocks/featuredcourses/delete_featuredcourse_form.php');
$courseid = required_param('courseid', PARAM_INT);
$PAGE->set_url('/blocks/featuredcourses/delete_featuredcourse.php', array('courseid'=>$courseid));
$context = context_system::instance();
$PAGE->set_context($context);
require_login();
require_capability('block/featuredcourses:addinstance', $context);
$mform = new block_featuredcourses_delete_featuredcourse_form();
$newformdata = array('courseid'=>$courseid,
'confirmdelete'=>'1');
$mform->set_data($newformdata);
$formdata = $mform->get_data();
if ($mform->is_cancelled()) {
redirect($CFG->wwwroot.'/blocks/featuredcourses/featuredcourses.php');
}
if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) {
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
require_once($CFG->dirroot.'/blocks/featuredcourses/block_featuredcourses.php');
block_featuredcourses::delete_featuredcourse($formdata->courseid);
redirect($CFG->wwwroot.'/blocks/featuredcourses/featuredcourses.php');
}
$title = get_string('delete_featuredcourse', 'block_featuredcourses');
$PAGE->navbar->add($title);
$PAGE->set_heading($title);
$PAGE->set_title($title);
echo $OUTPUT->header(),
$OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal'),
html_writer::tag('p', get_string('confirmdelete', 'block_featuredcourses'), array('class' => 'bold'));
$mform->display();
echo $OUTPUT->box_end(),
$OUTPUT->footer();
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* prints the form to confirm delete a featured course
*
* @package block_featuredcourses
* @author Daniel Neis
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
//It must be included from a Moodle page
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.');
}
require_once($CFG->libdir.'/formslib.php');
class block_featuredcourses_delete_featuredcourse_form extends moodleform {
public function definition() {
$mform =& $this->_form;
// hidden elements
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$mform->addElement('hidden', 'confirmdelete');
$mform->setType('confirmdelete', PARAM_INT);
$this->add_action_buttons(true, get_string('yes'));
}
}
......@@ -13,6 +13,7 @@ class featuredcourses_form extends moodleform {
* Form definition.
*/
function definition() {
global $CFG;
$mform = $this->_form;
$availablecourses = $this->_customdata['availablecourses']; // this contains the data of this form
......@@ -35,6 +36,8 @@ class featuredcourses_form extends moodleform {
$mform->setType('featured['.$c->id.'][sortorder]', PARAM_INT);
$mform->setDefault('featured['.$c->id.'][sortorder]', $c->sortorder);
$mform->addElement('static', 'link', get_string('deletelink', 'block_featuredcourses', $CFG->wwwroot.'/blocks/featuredcourses/delete_featuredcourse.php?courseid='.$c->id));
}
// Add a new featured course
......
......@@ -37,3 +37,6 @@ $string['doadd'] = 'Check to add new featured course';
$string['missingcourseid'] = 'You must select a course.';
$string['sortorder'] = 'Sort order';
$string['missingsortorder'] = 'You must set a sort order.';
$string['deletelink'] = '<a href="{$a}">Delete</a>';
$string['delete_featuredcourse'] = 'Delete Featured Course';
$string['confirmdelete'] = 'Are you sure you want to delete this course from the list of featured courses?';
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment