Miscellaneous fixes for MDL-11543
- added button to edit current category - removed old mini-forms to do the same - tidied up various things and CSS as well
This commit is contained in:
+22
-37
@@ -122,7 +122,7 @@
|
||||
|
||||
/// Print button to turn editing off
|
||||
if ($adminediting) {
|
||||
echo '<div class="categoryediting button" align="right">'.update_category_button($category->id).'</div>';
|
||||
echo '<div class="categoryediting button">'.update_category_button($category->id).'</div>';
|
||||
}
|
||||
|
||||
/// Print link to roles
|
||||
@@ -143,9 +143,8 @@
|
||||
echo '</div>';
|
||||
|
||||
/// Print current category description
|
||||
if ($category->description) {
|
||||
if (!$creatorediting && $category->description) {
|
||||
print_box_start();
|
||||
print_heading(get_string('description'));
|
||||
echo $category->description;
|
||||
print_box_end();
|
||||
}
|
||||
@@ -237,6 +236,24 @@
|
||||
|
||||
} // End of editing stuff
|
||||
|
||||
|
||||
if ($creatorediting) {
|
||||
echo '<div class="buttons">';
|
||||
if (has_capability('moodle/category:update', $context)) { // Print button to update this category
|
||||
unset($options);
|
||||
$options['id'] = $category->id;
|
||||
print_single_button('editcategory.php', $options, get_string('editcategorythis'), 'get');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/category:create', $context)) { // Print button for creating new categories
|
||||
unset($options);
|
||||
$options['categoryadd'] = 1;
|
||||
$options['id'] = $id;
|
||||
print_single_button('editcategory.php', $options, get_string('addsubcategory'), 'get');
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// Print out all the sub-categories
|
||||
if ($subcategories = get_records("course_categories", "parent", $category->id, "sortorder ASC")) {
|
||||
$firstentry = true;
|
||||
@@ -260,15 +277,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Print button for creating new categories
|
||||
if (has_capability('moodle/category:create', $context) && $creatorediting) {
|
||||
unset($options);
|
||||
$options['categoryadd'] = 1;
|
||||
$options['id'] = $id;
|
||||
echo '<div class="buttons">';
|
||||
print_single_button('editcategory.php', $options, get_string('addsubcategory'), 'get');
|
||||
echo '<br /></div>';
|
||||
}
|
||||
|
||||
/// Print out all the courses
|
||||
unset($course); // To avoid unwanted language effects later
|
||||
@@ -464,6 +472,7 @@
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
echo '<div class="buttons">';
|
||||
if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name
|
||||
unset($options);
|
||||
$options['id'] = $category->id;
|
||||
@@ -476,33 +485,9 @@
|
||||
unset($options);
|
||||
$options['category'] = $category->id;
|
||||
print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
|
||||
echo '<br />';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
if (has_capability('moodle/category:update', $context)) { /// Print form to rename the category
|
||||
$strrename= get_string('rename');
|
||||
echo '<form id="renameform" action="category.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="text" size="30" name="rename" value="'.htmlspecialchars($category->name).'" alt="'.$strrename.'" />';
|
||||
echo '<input type="submit" value="'.$strrename.'" />';
|
||||
echo '</div></form>';
|
||||
echo '<br />';
|
||||
|
||||
if (!empty($CFG->allowcategorythemes)) {
|
||||
$choices = array();
|
||||
$choices[''] = get_string('default');
|
||||
$choices += get_list_of_themes();
|
||||
|
||||
echo '<form id="themeform" action="category.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
choose_from_menu($choices, 'categorytheme', $category->theme);
|
||||
echo '<input type="submit" value="'.get_string('setcategorytheme').'" />';
|
||||
echo '</div></form>';
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print_course_search();
|
||||
|
||||
@@ -290,7 +290,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
}
|
||||
|
||||
if (!update_record('course_categories', $category)) {
|
||||
notice( "Could not update the category '$category->name' ");
|
||||
error( "Could not update the category '$category->name' ");
|
||||
} else {
|
||||
if ($category->parent == 0) {
|
||||
$redirect_link = 'index.php?categoryedit=on';
|
||||
@@ -298,11 +298,11 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
$redirect_link = 'category.php?id='.$category->id.'&categoryedit=on';
|
||||
}
|
||||
fix_course_sortorder();
|
||||
redirect($redirect_link, get_string('categoryupdated', null, $category->name));
|
||||
redirect($redirect_link);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notice("You do not have the permission to update this category.");
|
||||
error("You do not have the permission to update this category.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class editcategory_form extends moodleform {
|
||||
$mform->addRule('name', get_string('required'), 'required', null);
|
||||
$mform->addElement('htmleditor', 'description', get_string('description'));
|
||||
$mform->setType('description', PARAM_RAW);
|
||||
if (!empty($CFG->allowcoursethemes)) {
|
||||
if (!empty($CFG->allowcategorythemes)) {
|
||||
$themes=array();
|
||||
$themes[''] = get_string('forceno');
|
||||
$themes += get_list_of_themes();
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
$USER->timeaccess = $SESSION->oldtimeaccess;
|
||||
unset($SESSION->oldtimeaccess);
|
||||
}
|
||||
if (isset($SESSION->grade_last_report)) { // Restore grade defaults if any
|
||||
$USER->grade_last_report = $SESSION->grade_last_report;
|
||||
unset($SESSION->grade_last_report);
|
||||
}
|
||||
|
||||
if ($return and isset($_SERVER["HTTP_REFERER"])) { // That's all we wanted to do, so let's go back
|
||||
redirect($_SERVER["HTTP_REFERER"]);
|
||||
@@ -73,6 +77,9 @@
|
||||
if (isset($USER->timeaccess)) {
|
||||
$SESSION->oldtimeaccess = $USER->timeaccess;
|
||||
}
|
||||
if (isset($USER->grade_last_report)) {
|
||||
$SESSION->grade_last_report = $USER->grade_last_report;
|
||||
}
|
||||
|
||||
/// Login as this user and return to course home page.
|
||||
|
||||
|
||||
@@ -405,6 +405,7 @@ $string['edhelpfontlist'] = 'Define the fonts used on editors dropdown menu.';
|
||||
$string['edhelpfontsize'] = 'The default font-size sets the size of a font. <br />Valid values are for example: medium, large, smaller, larger, 10pt, 11px.';
|
||||
$string['edit'] = 'Edit $a';
|
||||
$string['editcategorysettings'] = 'Edit category settings';
|
||||
$string['editcategorythis'] = 'Edit this category';
|
||||
$string['editcoursesettings'] = 'Edit course settings';
|
||||
$string['editfiles'] = 'Edit files';
|
||||
$string['editgroupprofile'] = 'Edit group profile';
|
||||
|
||||
@@ -1922,6 +1922,15 @@ body#course-category .addcategory {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
body#course-category .buttons .singlebutton {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
body#course-category .buttons {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
body#course-index #middle-column .editcourse {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
|
||||
Reference in New Issue
Block a user