2009-11-01 09:25:47 +00:00
|
|
|
<?php
|
2003-08-07 16:01:31 +00:00
|
|
|
// Displays the top level category or all courses
|
2005-01-18 11:08:58 +00:00
|
|
|
// In editing mode, allows the admin to edit a category,
|
2003-08-07 16:01:31 +00:00
|
|
|
// and rearrange courses
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2004-05-16 10:26:04 +00:00
|
|
|
require_once("../config.php");
|
|
|
|
require_once("lib.php");
|
2003-07-30 13:02:45 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // Category id
|
|
|
|
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
|
|
|
$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // how many per page
|
2006-08-25 04:06:41 +00:00
|
|
|
$categoryedit = optional_param('categoryedit', -1, PARAM_BOOL);
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$hide = optional_param('hide', 0, PARAM_INT);
|
|
|
|
$show = optional_param('show', 0, PARAM_INT);
|
|
|
|
$moveup = optional_param('moveup', 0, PARAM_INT);
|
|
|
|
$movedown = optional_param('movedown', 0, PARAM_INT);
|
|
|
|
$moveto = optional_param('moveto', 0, PARAM_INT);
|
|
|
|
$resort = optional_param('resort', 0, PARAM_BOOL);
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2009-11-01 09:10:09 +00:00
|
|
|
$site = get_site();
|
2009-11-01 09:25:47 +00:00
|
|
|
|
2008-02-20 06:07:50 +00:00
|
|
|
if (empty($id)) {
|
2008-05-07 06:02:51 +00:00
|
|
|
print_error("unknowcategory");
|
2008-02-20 06:07:50 +00:00
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2009-05-06 08:46:05 +00:00
|
|
|
$PAGE->set_category_by_id($id);
|
2009-07-28 03:12:04 +00:00
|
|
|
$urlparams = array('id' => $id);
|
|
|
|
if ($page) {
|
|
|
|
$urlparams['page'] = $page;
|
|
|
|
}
|
|
|
|
if ($perpage) {
|
|
|
|
$urlparams['perpage'] = $perpage;
|
|
|
|
}
|
|
|
|
$PAGE->set_url('course/category.php', $urlparams);
|
2009-05-06 08:46:05 +00:00
|
|
|
$context = $PAGE->context;
|
|
|
|
$category = $PAGE->category;
|
2004-05-16 10:26:04 +00:00
|
|
|
|
2009-07-28 03:12:04 +00:00
|
|
|
$canedit = can_edit_in_category($category->id);
|
|
|
|
if ($canedit) {
|
2006-08-25 04:06:41 +00:00
|
|
|
if ($categoryedit !== -1) {
|
2009-05-06 08:59:29 +00:00
|
|
|
$USER->editing = $categoryedit;
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2009-07-20 08:57:18 +00:00
|
|
|
require_login();
|
|
|
|
$editingon = $PAGE->user_is_editing();
|
2003-08-07 16:01:31 +00:00
|
|
|
} else {
|
2009-07-20 08:57:18 +00:00
|
|
|
if ($CFG->forcelogin) {
|
|
|
|
require_login();
|
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$editingon = false;
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2009-07-20 08:57:18 +00:00
|
|
|
if (!$category->visible) {
|
|
|
|
require_capability('moodle/category:viewhiddencategories', $context);
|
|
|
|
}
|
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
// Process any category actions.
|
|
|
|
if (has_capability('moodle/category:manage', $context)) {
|
2003-08-11 07:48:03 +00:00
|
|
|
/// Resort the category if requested
|
2006-03-07 19:36:13 +00:00
|
|
|
if ($resort and confirm_sesskey()) {
|
2004-11-17 06:57:28 +00:00
|
|
|
if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
2008-06-16 14:25:53 +00:00
|
|
|
$i = 1;
|
2004-05-30 00:33:45 +00:00
|
|
|
foreach ($courses as $course) {
|
2008-06-16 14:25:53 +00:00
|
|
|
$DB->set_field('course', 'sortorder', $category->sortorder+$i, array('id'=>$course->id));
|
|
|
|
$i++;
|
2004-05-30 00:33:45 +00:00
|
|
|
}
|
2008-06-16 14:25:53 +00:00
|
|
|
fix_course_sortorder(); // should not be needed
|
2004-05-30 00:33:45 +00:00
|
|
|
}
|
2003-08-11 07:48:03 +00:00
|
|
|
}
|
2003-08-11 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-04 14:23:49 +00:00
|
|
|
// Process any course actions.
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($editingon) {
|
2005-01-18 11:08:58 +00:00
|
|
|
/// Move a specified course to a new category
|
2008-06-09 16:53:30 +00:00
|
|
|
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
2007-04-13 05:40:11 +00:00
|
|
|
// user must have category update in both cats to perform this
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
require_capability('moodle/category:manage', $context);
|
|
|
|
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveto));
|
2007-08-17 11:18:58 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if (!$destcategory = $DB->get_record('course_categories', array('id' => $data->moveto))) {
|
|
|
|
print_error('cannotfindcategory', '', '', $data->moveto);
|
2003-08-09 16:53:30 +00:00
|
|
|
}
|
|
|
|
|
2007-08-17 11:18:58 +00:00
|
|
|
$courses = array();
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
foreach ($data as $key => $value) {
|
2005-09-01 04:48:22 +00:00
|
|
|
if (preg_match('/^c\d+$/', $key)) {
|
2009-10-05 07:44:45 +00:00
|
|
|
$courseid = substr($key, 1);
|
|
|
|
array_push($courses, $courseid);
|
|
|
|
|
|
|
|
// check this course's category
|
|
|
|
if ($movingcourse = $DB->get_record('course', array('id'=>$courseid))) {
|
|
|
|
if ($movingcourse->category != $id ) {
|
|
|
|
print_error('coursedoesnotbelongtocategory');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_error('cannotfindcourse');
|
|
|
|
}
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
}
|
2005-09-01 04:48:22 +00:00
|
|
|
move_courses($courses, $data->moveto);
|
2003-07-30 13:02:45 +00:00
|
|
|
}
|
|
|
|
|
2005-01-18 11:08:58 +00:00
|
|
|
/// Hide or show a course
|
2005-06-14 09:21:09 +00:00
|
|
|
if ((!empty($hide) or !empty($show)) and confirm_sesskey()) {
|
|
|
|
if (!empty($hide)) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$course = $DB->get_record('course', array('id' => $hide));
|
2003-08-07 16:01:31 +00:00
|
|
|
$visible = 0;
|
|
|
|
} else {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$course = $DB->get_record('course', array('id' => $show));
|
2003-08-07 16:01:31 +00:00
|
|
|
$visible = 1;
|
|
|
|
}
|
2009-10-05 07:44:45 +00:00
|
|
|
|
2003-08-07 16:01:31 +00:00
|
|
|
if ($course) {
|
2009-10-05 07:44:45 +00:00
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
require_capability('moodle/course:visibility', $coursecontext);
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if (!$DB->set_field('course', 'visible', $visible, array('id' => $course->id))) {
|
|
|
|
print_error('errorupdatingcoursevisibility');
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-07-30 13:02:45 +00:00
|
|
|
|
|
|
|
|
2003-08-07 16:01:31 +00:00
|
|
|
/// Move a course up or down
|
2005-06-14 09:21:09 +00:00
|
|
|
if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
require_capability('moodle/category:manage', $context);
|
2005-01-18 11:08:58 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
// Ensure the course order has continuous ordering
|
2008-06-16 14:25:53 +00:00
|
|
|
fix_course_sortorder();
|
|
|
|
$swapcourse = NULL;
|
2005-01-18 11:08:58 +00:00
|
|
|
|
2005-06-14 09:21:09 +00:00
|
|
|
if (!empty($moveup)) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($movecourse = $DB->get_record('course', array('id' => $moveup))) {
|
|
|
|
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder - 1));
|
2008-06-16 14:25:53 +00:00
|
|
|
}
|
2004-11-17 06:57:28 +00:00
|
|
|
} else {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($movecourse = $DB->get_record('course', array('id' => $movedown))) {
|
|
|
|
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder + 1));
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2003-07-30 13:02:45 +00:00
|
|
|
}
|
2008-06-16 14:25:53 +00:00
|
|
|
if ($swapcourse and $movecourse) {
|
2009-10-05 07:44:45 +00:00
|
|
|
// check course's category
|
|
|
|
if ($movecourse->category != $id) {
|
|
|
|
print_error('coursedoesnotbelongtocategory');
|
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$DB->set_field('course', 'sortorder', $swapcourse->sortorder, array('id' => $movecourse->id));
|
|
|
|
$DB->set_field('course', 'sortorder', $movecourse->sortorder, array('id' => $swapcourse->id));
|
2008-06-16 14:25:53 +00:00
|
|
|
}
|
2004-11-17 06:57:28 +00:00
|
|
|
}
|
2003-08-07 16:01:31 +00:00
|
|
|
|
|
|
|
} // End of editing stuff
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2009-07-04 14:23:49 +00:00
|
|
|
// Print headings
|
|
|
|
$numcategories = $DB->count_records('course_categories');
|
|
|
|
|
|
|
|
$stradministration = get_string('administration');
|
|
|
|
$strcategories = get_string('categories');
|
|
|
|
$strcategory = get_string('category');
|
|
|
|
$strcourses = get_string('courses');
|
|
|
|
|
2009-07-28 03:12:04 +00:00
|
|
|
if ($editingon && can_edit_in_category()) {
|
2009-07-04 14:23:49 +00:00
|
|
|
// Integrate into the admin tree only if the user can edit categories at the top level,
|
|
|
|
// otherwise the admin block does not appear to this user, and you get an error.
|
2009-07-28 03:12:04 +00:00
|
|
|
require_once($CFG->libdir . '/adminlib.php');
|
|
|
|
admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.php');
|
2009-08-04 09:33:43 +00:00
|
|
|
$PAGE->set_context($context); // Ensure that we are actually showing blocks etc for the cat context
|
2009-07-04 14:23:49 +00:00
|
|
|
admin_externalpage_print_header();
|
2009-11-01 09:25:47 +00:00
|
|
|
} else {
|
2009-09-03 08:47:24 +00:00
|
|
|
$PAGE->set_title("$site->shortname: $category->name");
|
|
|
|
$PAGE->set_heading("$site->fullname: $strcourses");
|
|
|
|
$PAGE->set_button(print_course_search('', true, 'navbar'));
|
2009-12-27 12:02:04 +00:00
|
|
|
$PAGE->set_pagelayout('coursecategory');
|
2009-09-03 08:47:24 +00:00
|
|
|
echo $OUTPUT->header();
|
2009-07-04 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Print link to roles
|
|
|
|
if (has_capability('moodle/role:assign', $context)) {
|
|
|
|
echo '<div class="rolelink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
|
|
|
|
$context->id.'">'.get_string('assignroles','role').'</a></div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the category selector
|
|
|
|
$displaylist = array();
|
|
|
|
$notused = array();
|
|
|
|
make_categories_list($displaylist, $notused);
|
|
|
|
|
|
|
|
echo '<div class="categorypicker">';
|
2009-08-10 08:38:45 +00:00
|
|
|
$select = html_select::make_popup_form('category.php', 'id', $displaylist, 'switchcategory', $category->id);
|
2009-08-08 09:31:01 +00:00
|
|
|
$select->set_label($strcategories.':');
|
2009-08-10 03:35:14 +00:00
|
|
|
$select->nothinglabel = false;
|
2009-08-08 09:31:01 +00:00
|
|
|
echo $OUTPUT->select($select);
|
2009-07-04 14:23:49 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
/// Print current category description
|
|
|
|
if (!$editingon && $category->description) {
|
2009-08-10 04:53:59 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2009-11-04 06:14:06 +00:00
|
|
|
$options = new stdClass;
|
|
|
|
$options->noclean = true;
|
|
|
|
$options->para = false;
|
|
|
|
if (!isset($category->descriptionformat)) {
|
|
|
|
$category->descriptionformat = FORMAT_MOODLE;
|
|
|
|
}
|
|
|
|
echo format_text($category->description, $category->descriptionformat, $options);
|
2009-08-10 04:53:59 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2009-07-04 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($editingon && has_capability('moodle/category:manage', $context)) {
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->container_start('buttons');
|
2007-10-10 04:05:46 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
// Print button to update this category
|
|
|
|
$options = array('id' => $category->id);
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('editcategorythis'), 'get'));
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
|
|
|
|
// Print button for creating new categories
|
|
|
|
$options = array('parent' => $category->id);
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('addsubcategory'), 'get'));
|
2007-10-10 04:05:46 +00:00
|
|
|
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->container_end();
|
2007-10-10 04:05:46 +00:00
|
|
|
}
|
|
|
|
|
2003-08-11 13:02:45 +00:00
|
|
|
/// Print out all the sub-categories
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($subcategories = $DB->get_records('course_categories', array('parent' => $category->id), 'sortorder ASC')) {
|
2004-03-20 12:21:08 +00:00
|
|
|
$firstentry = true;
|
2003-08-11 13:02:45 +00:00
|
|
|
foreach ($subcategories as $subcategory) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($subcategory->visible || has_capability('moodle/category:viewhiddencategories', $context)) {
|
2005-01-11 08:00:26 +00:00
|
|
|
$subcategorieswereshown = true;
|
2004-03-20 12:21:08 +00:00
|
|
|
if ($firstentry) {
|
2007-04-30 18:18:07 +00:00
|
|
|
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter">';
|
2006-12-13 03:03:43 +00:00
|
|
|
echo '<tr><th scope="col">'.get_string('subcategories').'</th></tr>';
|
2007-02-06 08:24:37 +00:00
|
|
|
echo '<tr><td style="white-space: nowrap">';
|
2004-03-20 12:21:08 +00:00
|
|
|
$firstentry = false;
|
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$catlinkcss = $subcategory->visible ? '' : ' class="dimmed" ';
|
2004-09-08 21:25:33 +00:00
|
|
|
echo '<a '.$catlinkcss.' href="category.php?id='.$subcategory->id.'">'.
|
2007-02-28 06:25:22 +00:00
|
|
|
format_string($subcategory->name).'</a><br />';
|
2004-03-20 12:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$firstentry) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '</td></tr></table>';
|
|
|
|
echo '<br />';
|
2003-08-11 13:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 11:08:58 +00:00
|
|
|
|
2003-08-07 16:01:31 +00:00
|
|
|
/// Print out all the courses
|
2005-01-18 11:08:58 +00:00
|
|
|
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible,c.guest,c.password',
|
|
|
|
$totalcount, $page*$perpage, $perpage);
|
2003-09-03 14:05:31 +00:00
|
|
|
$numcourses = count($courses);
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2003-09-10 17:36:15 +00:00
|
|
|
if (!$courses) {
|
2005-01-11 08:00:26 +00:00
|
|
|
if (empty($subcategorieswereshown)) {
|
2009-08-06 08:15:43 +00:00
|
|
|
echo $OUTPUT->heading(get_string("nocoursesyet"));
|
2005-01-11 08:00:26 +00:00
|
|
|
}
|
2003-07-30 13:02:45 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
|
2009-08-10 04:53:59 +00:00
|
|
|
echo $OUTPUT->box_start('courseboxes');
|
2007-02-14 04:56:26 +00:00
|
|
|
print_courses($category);
|
2009-08-10 04:53:59 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2005-01-18 11:08:58 +00:00
|
|
|
} else {
|
2009-08-07 00:27:42 +00:00
|
|
|
echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "category.php?id=$category->id&perpage=$perpage"));
|
2003-08-21 09:33:07 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$strcourses = get_string('courses');
|
|
|
|
$strselect = get_string('select');
|
|
|
|
$stredit = get_string('edit');
|
|
|
|
$strdelete = get_string('delete');
|
|
|
|
$strbackup = get_string('backup');
|
|
|
|
$strrestore = get_string('restore');
|
|
|
|
$strmoveup = get_string('moveup');
|
|
|
|
$strmovedown = get_string('movedown');
|
|
|
|
$strupdate = get_string('update');
|
|
|
|
$strhide = get_string('hide');
|
|
|
|
$strshow = get_string('show');
|
|
|
|
$strsummary = get_string('summary');
|
|
|
|
$strsettings = get_string('settings');
|
|
|
|
$strassignteachers = get_string('assignteachers');
|
|
|
|
$strallowguests = get_string('allowguests');
|
|
|
|
$strrequireskey = get_string('requireskey');
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2003-08-07 16:01:31 +00:00
|
|
|
|
2007-04-26 08:49:21 +00:00
|
|
|
echo '<form id="movecourses" action="category.php" method="post"><div>';
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
2007-04-26 08:49:21 +00:00
|
|
|
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter"><tr>';
|
|
|
|
echo '<th class="header" scope="col">'.$strcourses.'</th>';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($editingon) {
|
2007-04-26 08:49:21 +00:00
|
|
|
echo '<th class="header" scope="col">'.$stredit.'</th>';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '<th class="header" scope="col">'.$strselect.'</th>';
|
2003-08-11 05:38:28 +00:00
|
|
|
} else {
|
2007-04-26 08:49:21 +00:00
|
|
|
echo '<th class="header" scope="col"> </th>';
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '</tr>';
|
2003-08-07 16:01:31 +00:00
|
|
|
|
2003-07-30 13:02:45 +00:00
|
|
|
|
|
|
|
$count = 0;
|
2003-08-09 16:53:30 +00:00
|
|
|
$abletomovecourses = false; // for now
|
2003-07-30 13:02:45 +00:00
|
|
|
|
2005-11-10 22:08:35 +00:00
|
|
|
// Checking if we are at the first or at the last page, to allow courses to
|
|
|
|
// be moved up and down beyond the paging border
|
|
|
|
if ($totalcount > $perpage) {
|
|
|
|
$atfirstpage = ($page == 0);
|
2007-08-30 06:01:57 +00:00
|
|
|
if ($perpage > 0) {
|
|
|
|
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));
|
|
|
|
} else {
|
|
|
|
$atlastpage = true;
|
|
|
|
}
|
2005-11-10 22:08:35 +00:00
|
|
|
} else {
|
|
|
|
$atfirstpage = true;
|
|
|
|
$atlastpage = true;
|
|
|
|
}
|
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$spacer = '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
2004-02-21 03:26:04 +00:00
|
|
|
foreach ($courses as $acourse) {
|
2007-09-19 07:08:24 +00:00
|
|
|
if (isset($acourse->context)) {
|
|
|
|
$coursecontext = $acourse->context;
|
|
|
|
} else {
|
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id);
|
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2003-07-30 13:02:45 +00:00
|
|
|
$count++;
|
2005-11-10 22:08:35 +00:00
|
|
|
$up = ($count > 1 || !$atfirstpage);
|
|
|
|
$down = ($count < $numcourses || !$atlastpage);
|
2003-07-30 13:02:45 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$linkcss = $acourse->visible ? '' : ' class="dimmed" ';
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '<tr>';
|
2007-02-28 06:25:22 +00:00
|
|
|
echo '<td><a '.$linkcss.' href="view.php?id='.$acourse->id.'">'. format_string($acourse->fullname) .'</a></td>';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if ($editingon) {
|
|
|
|
echo '<td>';
|
2006-11-21 03:26:31 +00:00
|
|
|
if (has_capability('moodle/course:update', $coursecontext)) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '<a title="'.$strsettings.'" href="'.$CFG->wwwroot.'/course/edit.php?id='.$acourse->id.'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="'.$stredit.'" /></a> ';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
|
|
|
// role assignment link
|
|
|
|
if (has_capability('moodle/role:assign', $coursecontext)) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '<a title="'.get_string('assignroles', 'role').'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$coursecontext->id.'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('i/roles') . '" class="iconsmall" alt="'.get_string('assignroles', 'role').'" /></a> ';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
2007-08-17 11:18:58 +00:00
|
|
|
}
|
|
|
|
|
2007-02-16 08:46:55 +00:00
|
|
|
if (can_delete_course($acourse->id)) {
|
2006-11-09 06:22:10 +00:00
|
|
|
echo '<a title="'.$strdelete.'" href="delete.php?id='.$acourse->id.'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="'.$strdelete.'" /></a> ';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
2006-11-09 06:22:10 +00:00
|
|
|
}
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2007-03-14 04:31:04 +00:00
|
|
|
// MDL-8885, users with no capability to view hidden courses, should not be able to lock themselves out
|
|
|
|
if (has_capability('moodle/course:visibility', $coursecontext) && has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
2006-11-09 06:22:10 +00:00
|
|
|
if (!empty($acourse->visible)) {
|
|
|
|
echo '<a title="'.$strhide.'" href="category.php?id='.$category->id.'&page='.$page.
|
2009-01-02 10:36:25 +00:00
|
|
|
'&perpage='.$perpage.'&hide='.$acourse->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/hide') . '" class="iconsmall" alt="'.$strhide.'" /></a> ';
|
2006-11-09 06:22:10 +00:00
|
|
|
} else {
|
|
|
|
echo '<a title="'.$strshow.'" href="category.php?id='.$category->id.'&page='.$page.
|
2009-01-02 10:36:25 +00:00
|
|
|
'&perpage='.$perpage.'&show='.$acourse->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a> ';
|
2006-08-08 05:13:06 +00:00
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
2006-11-09 06:22:10 +00:00
|
|
|
}
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2006-11-21 03:26:31 +00:00
|
|
|
if (has_capability('moodle/site:backup', $coursecontext)) {
|
2006-11-09 06:22:10 +00:00
|
|
|
echo '<a title="'.$strbackup.'" href="../backup/backup.php?id='.$acourse->id.'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/backup') . '" class="iconsmall" alt="'.$strbackup.'" /></a> ';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
2006-11-09 06:22:10 +00:00
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2006-11-21 03:26:31 +00:00
|
|
|
if (has_capability('moodle/site:restore', $coursecontext)) {
|
2006-11-09 06:22:10 +00:00
|
|
|
echo '<a title="'.$strrestore.'" href="../files/index.php?id='.$acourse->id.
|
|
|
|
'&wdir=/backupdata">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/restore') . '" class="iconsmall" alt="'.$strrestore.'" /></a> ';
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer;
|
2006-11-09 06:22:10 +00:00
|
|
|
}
|
2005-01-18 11:08:58 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if (has_capability('moodle/category:manage', $context)) {
|
2003-08-07 16:01:31 +00:00
|
|
|
if ($up) {
|
2004-11-17 06:57:28 +00:00
|
|
|
echo '<a title="'.$strmoveup.'" href="category.php?id='.$category->id.'&page='.$page.
|
2009-01-02 10:36:25 +00:00
|
|
|
'&perpage='.$perpage.'&moveup='.$acourse->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="iconsmall" alt="'.$strmoveup.'" /></a> ';
|
2003-08-15 10:11:22 +00:00
|
|
|
} else {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo $spacer;
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2005-01-18 11:08:58 +00:00
|
|
|
|
2003-08-07 16:01:31 +00:00
|
|
|
if ($down) {
|
2004-11-17 06:57:28 +00:00
|
|
|
echo '<a title="'.$strmovedown.'" href="category.php?id='.$category->id.'&page='.$page.
|
2009-01-02 10:36:25 +00:00
|
|
|
'&perpage='.$perpage.'&movedown='.$acourse->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="iconsmall" alt="'.$strmovedown.'" /></a> ';
|
2003-08-15 10:11:22 +00:00
|
|
|
} else {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo $spacer;
|
2003-08-07 16:01:31 +00:00
|
|
|
}
|
2003-08-09 16:53:30 +00:00
|
|
|
$abletomovecourses = true;
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
} else {
|
|
|
|
echo $spacer, $spacer;
|
2003-08-11 05:38:28 +00:00
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '</td>';
|
2006-11-09 06:22:10 +00:00
|
|
|
echo '<td align="center">';
|
|
|
|
echo '<input type="checkbox" name="c'.$acourse->id.'" />';
|
2007-08-17 11:18:58 +00:00
|
|
|
echo '</td>';
|
2003-08-11 05:38:28 +00:00
|
|
|
} else {
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '<td align="right">';
|
2004-12-15 13:33:40 +00:00
|
|
|
if (!empty($acourse->guest)) {
|
2007-01-08 09:14:05 +00:00
|
|
|
echo '<a href="view.php?id='.$acourse->id.'"><img title="'.
|
2007-03-01 14:47:52 +00:00
|
|
|
$strallowguests.'" class="icon" src="'.
|
2009-12-16 21:50:45 +00:00
|
|
|
$OUTPUT->pix_url('i/guest') . '" alt="'.$strallowguests.'" /></a>';
|
2003-08-11 05:38:28 +00:00
|
|
|
}
|
2004-12-15 13:33:40 +00:00
|
|
|
if (!empty($acourse->password)) {
|
2007-01-08 09:14:05 +00:00
|
|
|
echo '<a href="view.php?id='.$acourse->id.'"><img title="'.
|
2007-03-01 14:47:52 +00:00
|
|
|
$strrequireskey.'" class="icon" src="'.
|
2009-12-16 21:50:45 +00:00
|
|
|
$OUTPUT->pix_url('i/key') . '" alt="'.$strrequireskey.'" /></a>';
|
2003-09-03 14:05:31 +00:00
|
|
|
}
|
2004-12-15 13:33:40 +00:00
|
|
|
if (!empty($acourse->summary)) {
|
2009-12-16 21:50:45 +00:00
|
|
|
$link = html_link::make("/course/info.php?id=$acourse->id", '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />');
|
2009-08-20 13:14:52 +00:00
|
|
|
$link->add_action(new popup_action('click', $link->url, 'courseinfo'));
|
|
|
|
$link->title = $strsummary;
|
2009-11-01 09:25:47 +00:00
|
|
|
echo $OUTPUT->link($link);
|
2003-08-11 05:38:28 +00:00
|
|
|
}
|
|
|
|
echo "</td>";
|
2003-07-30 13:02:45 +00:00
|
|
|
}
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
2003-08-09 16:53:30 +00:00
|
|
|
|
|
|
|
if ($abletomovecourses) {
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
$movetocategories = array();
|
|
|
|
$notused = array();
|
|
|
|
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
|
|
|
|
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '<tr><td colspan="3" align="right">';
|
2009-08-10 08:38:45 +00:00
|
|
|
$select = new html_select();
|
2009-08-04 02:05:32 +00:00
|
|
|
$select->options = $movetocategories;
|
|
|
|
$select->name = 'moveto';
|
|
|
|
$select->selectedvalue = $category->id;
|
|
|
|
$select->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
|
|
|
|
echo $OUTPUT->select($select);
|
2004-09-08 21:25:33 +00:00
|
|
|
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '</td></tr>';
|
2003-08-09 16:53:30 +00:00
|
|
|
}
|
2005-01-18 11:08:58 +00:00
|
|
|
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '</table>';
|
2007-04-26 08:49:21 +00:00
|
|
|
echo '</div></form>';
|
2005-04-22 07:52:21 +00:00
|
|
|
echo '<br />';
|
2003-07-30 13:02:45 +00:00
|
|
|
}
|
2007-08-17 11:18:58 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '<div class="buttons">';
|
|
|
|
if (has_capability('moodle/category:manage', $context) and $numcourses > 1) {
|
|
|
|
/// Print button to re-sort courses by name
|
2003-08-11 05:24:48 +00:00
|
|
|
unset($options);
|
2005-04-22 07:52:21 +00:00
|
|
|
$options['id'] = $category->id;
|
|
|
|
$options['resort'] = 'name';
|
2009-01-20 23:53:34 +00:00
|
|
|
$options['sesskey'] = sesskey();
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button('category.php', $options, get_string('resortcoursesbyname'), 'get'));
|
2003-08-22 12:15:35 +00:00
|
|
|
}
|
2003-08-11 05:24:48 +00:00
|
|
|
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
if (has_capability('moodle/course:create', $context)) {
|
|
|
|
/// Print button to create a new course
|
2003-08-09 16:53:30 +00:00
|
|
|
unset($options);
|
2005-04-22 07:52:21 +00:00
|
|
|
$options['category'] = $category->id;
|
2009-08-20 08:40:19 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button('edit.php', $options, get_string('addnewcourse'), 'get'));
|
2003-08-22 12:15:35 +00:00
|
|
|
}
|
2008-12-05 08:56:54 +00:00
|
|
|
|
|
|
|
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) {
|
|
|
|
print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
|
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.
* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.
Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.
Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
|
|
|
echo '</div>';
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2006-09-20 20:31:09 +00:00
|
|
|
print_course_search();
|
2007-08-17 11:18:58 +00:00
|
|
|
|
2009-08-06 14:10:33 +00:00
|
|
|
echo $OUTPUT->footer();
|
2003-07-30 13:02:45 +00:00
|
|
|
|