From aaf133838cdcc87c329f5e330aa9905269ff840c Mon Sep 17 00:00:00 2001 From: Martin Dougiamas Date: Sun, 16 May 2010 16:19:27 +0000 Subject: [PATCH] old admin blocks MDL-22475 Goodbye admin and admin_tree. You were good to us. But now we have Settings. --- blocks/admin/block_admin.php | 225 ------------------ blocks/admin/db/upgrade.php | 41 ---- blocks/admin/lang/en/block_admin.php | 26 -- blocks/admin_tree/admintree.js | 75 ------ blocks/admin_tree/block_admin_tree.php | 170 ------------- .../admin_tree/lang/en/block_admin_tree.php | 26 -- blocks/admin_tree/styles.css | 5 - lib/adminlib.php | 2 - lib/db/upgrade.php | 10 + version.php | 2 +- 10 files changed, 11 insertions(+), 571 deletions(-) delete mode 100644 blocks/admin/block_admin.php delete mode 100644 blocks/admin/db/upgrade.php delete mode 100644 blocks/admin/lang/en/block_admin.php delete mode 100644 blocks/admin_tree/admintree.js delete mode 100644 blocks/admin_tree/block_admin_tree.php delete mode 100644 blocks/admin_tree/lang/en/block_admin_tree.php delete mode 100644 blocks/admin_tree/styles.css diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php deleted file mode 100644 index c616d1e87fa..00000000000 --- a/blocks/admin/block_admin.php +++ /dev/null @@ -1,225 +0,0 @@ -title = get_string('pluginname', 'block_admin'); - $this->version = 2007101509; - } - - function get_content() { - global $CFG, $USER, $DB, $OUTPUT; - - if ($this->content !== NULL) { - return $this->content; - } - - $this->content = new stdClass; - $this->content->items = array(); - $this->content->icons = array(); - $this->content->footer = ''; - - $course = $this->page->course; - - if (empty($CFG->loginhttps)) { - $securewwwroot = $CFG->wwwroot; - } else { - $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); - } - - $isenrolled = is_enrolled($this->page->context); - $isviewing = is_viewing($this->page->context); - - /// Course editing on/off - if ($course->id !== SITEID and has_capability('moodle/course:update', $this->page->context)) { - $this->content->icons[]=''; - if ($this->page->user_is_editing()) { - $this->content->items[]=''.get_string('turneditingoff').''; - } else { - $this->content->items[]=''.get_string('turneditingon').''; - } - - $this->content->items[]=''.get_string('settings').''; - $this->content->icons[]=''; - } - - /// Assign roles to the course - if ($course->id != SITEID) { - if (has_capability('moodle/role:assign', $this->page->context)) { - $this->content->items[]=''.get_string('assignroles', 'role').''; - $this->content->icons[]=''; - } else if (get_overridable_roles($this->page->context, ROLENAME_ORIGINAL)) { - $this->content->items[]=''.get_string('overridepermissions', 'role').''; - $this->content->icons[]=''; - } - } - - /// View course grades (or just your own grades, same link) - /// find all accessible reports - if ($course->id !== SITEID and ($isenrolled or $isviewing)) { - $reportavailable = false; - if (has_capability('moodle/grade:viewall', $this->page->context)) { - $reportavailable = true; - } else if (!empty($course->showgrades)) { - if ($reports = get_plugin_list('gradereport')) { // Get all installed reports - arsort($reports); // user is last, we want to test it first - foreach ($reports as $plugin => $plugindir) { - if (has_capability('gradereport/'.$plugin.':view', $this->page->context)) { - //stop when the first visible plugin is found - $reportavailable = true; - break; - } - } - } - } - - if ($reportavailable) { - $this->content->items[]=''.get_string('grades').''; - $this->content->icons[]=''; - } - } - - /// Course outcomes (to help give it more prominence because it's important) - if (!empty($CFG->enableoutcomes)) { - if ($course->id!==SITEID and has_capability('moodle/course:update', $this->page->context)) { - $this->content->items[]=''.get_string('outcomes', 'grades').''; - $this->content->icons[]=''; - } - } - - /// Manage metacourses - if ($course->metacourse) { - if (has_capability('moodle/course:managemetacourse', $this->page->context)) { - $strchildcourses = get_string('childcourses'); - $this->content->items[]=''.$strchildcourses.''; - $this->content->icons[]=''; - } else if (has_capability('moodle/role:assign', $this->page->context)) { - $strchildcourses = get_string('childcourses'); - $this->content->items[]=''.$strchildcourses.''; - $this->content->icons[]=''; - } - } - - - /// Manage groups in this course - if (($course->id!==SITEID) && ($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $this->page->context)) { - $strgroups = get_string('groups'); - $this->content->items[]=''.$strgroups.''; - $this->content->icons[]=''; - } - - /// Backup this course - if ($course->id!==SITEID and has_capability('moodle/backup:backupcourse', $this->page->context)) { - $this->content->items[]=''.get_string('backup').''; - $this->content->icons[]=''; - } - - /// Restore to this course - if ($course->id !== SITEID and has_capability('moodle/restore:restorecourse', $this->page->context)) { - $this->content->items[]=''.get_string('restore').''; - $this->content->icons[]=''; - } - - /// Import data from other courses - if ($course->id !== SITEID and has_capability('moodle/restore:restoretargetimport', $this->page->context)) { - $this->content->items[]=''.get_string('import').''; - $this->content->icons[]=''; - } - - /// Reset this course - if ($course->id!==SITEID and has_capability('moodle/course:reset', $this->page->context)) { - $this->content->items[]=''.get_string('reset').''; - $this->content->icons[]=''; - } - - /// View course reports - if ($course->id !== SITEID and has_capability('moodle/site:viewreports', $this->page->context)) { // basic capability for listing of reports - $this->content->items[]=''.get_string('reports').''; - $this->content->icons[]=''; - } - - /// Manage questions - if ($course->id !== SITEID){ - $questionlink = ''; - $questioncaps = array( - 'moodle/question:add', - 'moodle/question:editmine', - 'moodle/question:editall', - 'moodle/question:viewmine', - 'moodle/question:viewall', - 'moodle/question:movemine', - 'moodle/question:moveall'); - foreach ($questioncaps as $questioncap){ - if (has_capability($questioncap, $this->page->context)){ - $questionlink = 'edit.php'; - break; - } - } - if (!$questionlink && has_capability('moodle/question:managecategory', $this->page->context)) { - $questionlink = 'category.php'; - } - if ($questionlink) { - $this->content->items[]=''.get_string('questions', 'quiz').''; - $this->content->icons[]=''; - } - } - - /// Repository Instances - require_once($CFG->dirroot.'/repository/lib.php'); - $editabletypes = repository::get_editable_types($this->page->context); - if ($course->id !== SITEID && has_capability('moodle/course:update', $this->page->context) && !empty($editabletypes)) { - $this->content->items[]=''.get_string('repositories').''; - $this->content->icons[]=''; - } - - /// Manage files - if ($course->id !== SITEID and has_capability('moodle/course:managefiles', $this->page->context)) { - $this->content->items[]=''.get_string('files').''; - $this->content->icons[]=''; - } - - /// Authorize hooks - if ($course->enrol == 'authorize' || (empty($course->enrol) && $CFG->enrol == 'authorize') && ($course->id!==SITEID)) { - require_once($CFG->dirroot.'/enrol/authorize/const.php'); - $paymenturl = ''.get_string('payments').' '; - if (has_capability('enrol/authorize:managepayments', $this->page->context)) { - if ($cnt = $DB->count_records('enrol_authorize', array('status'=>AN_STATUS_AUTH, 'courseid'=>$course->id))) { - $paymenturl .= ''.get_string('paymentpending', 'moodle', $cnt).''; - } - } - $this->content->items[] = $paymenturl; - $this->content->icons[] = ''; - } - - /// Unenrol link - if (empty($course->metacourse) && ($course->id!==SITEID)) { - if ($isenrolled) { - if (has_capability('moodle/role:unassignself', $this->page->context, NULL, false) and get_user_roles($this->page->context, $USER->id, false)) { // Have some role - $this->content->items[]=''.get_string('unenrolme', '', format_string($course->shortname)).''; - $this->content->icons[]=''; - } - - } else if ($isviewing) { - // inspector, manager, etc. - do not show anything - } else { - // access because otherwise they would not get into this course at all - $this->content->items[]=''.get_string('enrolme', '', format_string($course->shortname)).''; - $this->content->icons[]=''; - } - } - - /// Link to the user own profile if they are enrolled - if ($isenrolled) { - $this->content->items[]=''.get_string('profile').''; - $this->content->icons[]=''; - } - - return $this->content; - } - - function applicable_formats() { - return array('course' => true); // Not needed on site - } -} - - diff --git a/blocks/admin/db/upgrade.php b/blocks/admin/db/upgrade.php deleted file mode 100644 index fe6782ca3ba..00000000000 --- a/blocks/admin/db/upgrade.php +++ /dev/null @@ -1,41 +0,0 @@ -get_manager(); - $result = true; - -/// And upgrade begins here. For each one, you'll need one -/// block of code similar to the next one. Please, delete -/// this comment lines once this file start handling proper -/// upgrade code. - -/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php -/// $result = result of database_manager methods -/// } - - return $result; -} - - diff --git a/blocks/admin/lang/en/block_admin.php b/blocks/admin/lang/en/block_admin.php deleted file mode 100644 index af9e7e452a6..00000000000 --- a/blocks/admin/lang/en/block_admin.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -/** - * Strings for component 'block_admin', language 'en', branch 'MOODLE_20_STABLE' - * - * @package block_admin - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['pluginname'] = 'Administration'; diff --git a/blocks/admin_tree/admintree.js b/blocks/admin_tree/admintree.js deleted file mode 100644 index b73304e2a46..00000000000 --- a/blocks/admin_tree/admintree.js +++ /dev/null @@ -1,75 +0,0 @@ -admin_tree = { - numdivs: null, - hiddennodes: null, - closedimg: null, - openimg: null, - closedalt: null, - openalt: null, - - init: function(numdivs, expandnodes, openimg, closedimg, openalt, closedalt) { - // Store the information we were passed in. - admin_tree.openimg = openimg; - admin_tree.closedimg = closedimg; - admin_tree.openalt = openalt; - admin_tree.closedalt = closedalt; - admin_tree.numdivs = numdivs; - - // Initialise the hiddennodes array. - admin_tree.hiddennodes = new Array(); - for (var i = 1; i <= admin_tree.numdivs; i++) { - admin_tree.hiddennodes[i] = null; - } - - // Collapse everything while adding the event handlers. - for (var i = admin_tree.numdivs; i > 0; i--) { - admin_tree.collapse(i); - var togglelink = document.getElementById("vh_div" + i + "indicator").parentNode; - togglelink.href = '#'; - YAHOO.util.Event.addListener(togglelink, 'click', admin_tree.toggle, i); - } - - // Re-expand the bits we want expanded. - for (var i = 0; i < expandnodes.length; i++) { - admin_tree.expand(expandnodes[i]); - } - }, - - toggle: function(e, i) { - if (admin_tree.hiddennodes[i] === null) { - admin_tree.collapse(i); - } else { - admin_tree.expand(i); - } - YAHOO.util.Event.preventDefault(e); - }, - - collapse: function(i) { - if (admin_tree.hiddennodes[i] !== null) { - return; - } - var obj = document.getElementById("vh_div" + i); - if (obj === null) { - return; - } - var nothing = document.createElement("span"); - nothing.setAttribute("id", "vh_div" + i); - admin_tree.hiddennodes[i] = obj; - obj.parentNode.replaceChild(nothing, obj); - var icon = document.getElementById("vh_div" + i + "indicator"); - icon.src = admin_tree.closedimg; - icon.alt = admin_tree.closedalt; - }, - - expand: function(i) { - if (admin_tree.hiddennodes[i] === null) { - return; - } - var nothing = document.getElementById("vh_div" + i); - var obj = admin_tree.hiddennodes[i]; - admin_tree.hiddennodes[i] = null; - nothing.parentNode.replaceChild(obj, nothing); - var icon = document.getElementById("vh_div" + i + "indicator"); - icon.src = admin_tree.openimg; - icon.alt = admin_tree.openalt; - } -}; diff --git a/blocks/admin_tree/block_admin_tree.php b/blocks/admin_tree/block_admin_tree.php deleted file mode 100644 index b779bca1085..00000000000 --- a/blocks/admin_tree/block_admin_tree.php +++ /dev/null @@ -1,170 +0,0 @@ -title = get_string('pluginname', 'block_admin_tree'); - $this->version = 2007101509; - $this->currentdepth = 0; - $this->divcounter = 1; - $this->tempcontent = ''; - } - - function applicable_formats() { - if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { - return array('site' => true, 'admin' => true, 'my' => true); - } else { - return array('site' => true, 'admin' => true); - } - } - - function preferred_width() { - return 210; - } - - function open_folder($visiblename) { - global $OUTPUT; - $strfolderopened = s(get_string('folderopened')); - - $this->tempcontent .= '
'; - $this->tempcontent .= ''.$strfolderopened.' '; - $this->tempcontent .= $visiblename.'
'."\n"; - $this->currentdepth++; - $this->divcounter++; - } - - function close_folder() { - $this->currentdepth--; - $this->tempcontent .= "
\n"; - } - - function create_item($visiblename,$link,$icon,$class) { - global $CFG; - $this->tempcontent .= '
'. - $visiblename.'
'."\n"; - } - - function build_tree (&$content) { - global $CFG, $OUTPUT; - if ($content instanceof admin_settingpage) { - // show hidden pages in tree if hidden page active - if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) { - $class = ($content->name == $this->section) ? 'link current' : 'link'; - if ($content->is_hidden()) { - $class .= ' hidden'; - } - $this->create_item($content->visiblename, $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section='.$content->name,$OUTPUT->pix_url('i/item'), $class); - } - } else if ($content instanceof admin_externalpage) { - // show hidden pages in tree if hidden page active - if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) { - $class = ($content->name == $this->section) ? 'link current' : 'link'; - if ($content->name === 'adminnotifications') { - if (admin_critical_warnings_present()) { - $class .= ' criticalnotification'; - } - } - if ($content->is_hidden()) { - $class .= ' hidden'; - } - $this->create_item($content->visiblename, $content->url, $OUTPUT->pix_url('i/item'), $class); - } - } else if ($content instanceof admin_category) { - if ($content->check_access() and !$content->is_hidden()) { - - // check if the category we're currently printing is a parent category for the current page; if it is, we - // make a note (in the javascript) that it has to be expanded after the page has loaded - if ($this->section != '' and $this->pathtosection[count($this->pathtosection) - 1] == $content->name) { - $this->expandnodes[] = $this->divcounter; - array_pop($this->pathtosection); - } - - $this->open_folder($content->visiblename); - - $entries = array_keys($content->children); - - foreach ($entries as $entry) { - $this->build_tree($content->children[$entry]); - } - - $this->close_folder(); - } - } - } - - function get_content() { - global $CFG, $OUTPUT, $COURSE; - - if ($this->content !== NULL) { - return $this->content; - } - - if (isguestuser() or !isloggedin()) { - // shortcut - these users can not change any settings - $this->content = ''; - return ''; - } - - if ($COURSE->shortname === '') { - // remove admin block if site not fully configured yet - $this->content = ''; - return ''; - } - - require_once($CFG->libdir.'/adminlib.php'); - $adminroot = admin_get_root(false, false); // settings not required - only pages - - $this->section = $this->page->url->param('section'); - if ($current = $adminroot->locate($this->section, true)) { - $this->pathtosection = $current->path; - array_pop($this->pathtosection); - } - - // we need to do this instead of $this->build_tree($adminroot) because the top-level folder - // is redundant (and ideally ignored). (the top-level folder is "administration".) - $entries = array_keys($adminroot->children); - asort($entries); - foreach ($entries as $entry) { - $this->build_tree($adminroot->children[$entry]); - } - - if ($this->tempcontent !== '') { - $this->page->requires->yui2_lib('event'); - $this->page->requires->js('/blocks/admin_tree/admintree.js'); - $this->page->requires->js_function_call('admin_tree.init', - array($this->divcounter - 1, $this->expandnodes, - $OUTPUT->pix_url('i/open'), $OUTPUT->pix_url('i/closed'), - get_string('folderopened'), get_string('folderclosed'))); - - $this->content = new object(); - $this->content->text = '
' . $this->tempcontent . "
\n"; - - // only do search if you have moodle/site:config - if (has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) ) { - $this->content->footer = - '
'. - '
'. - ''. - ''. - '
'. - '
'; - } else { - $this->content->footer = ''; - } - } else { - $this->content = new object(); - $this->content->text = ''; - } - - return $this->content; - } -} - diff --git a/blocks/admin_tree/lang/en/block_admin_tree.php b/blocks/admin_tree/lang/en/block_admin_tree.php deleted file mode 100644 index 1abe5d098f9..00000000000 --- a/blocks/admin_tree/lang/en/block_admin_tree.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -/** - * Strings for component 'block_admin_tree', language 'en', branch 'MOODLE_20_STABLE' - * - * @package block_admin_tree - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['pluginname'] = 'Site administration'; diff --git a/blocks/admin_tree/styles.css b/blocks/admin_tree/styles.css deleted file mode 100644 index 80221ef5060..00000000000 --- a/blocks/admin_tree/styles.css +++ /dev/null @@ -1,5 +0,0 @@ -.block_admin_tree .admintree {text-align:left;} -.block_admin_tree .admintree .depth1 {padding-left: 16px;} -.block_admin_tree .admintree .depth2 {padding-left: 32px;} -.block_admin_tree .admintree .depth3 {padding-left: 48px;} -.block_admin_tree .admintree .depth4 {padding-left: 64px;} \ No newline at end of file diff --git a/lib/adminlib.php b/lib/adminlib.php index 29c5f079dbe..fac99bfe326 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5842,9 +5842,7 @@ function print_plugin_tables() { 'workshop'); $plugins_standard['blocks'] = array('activity_modules', - 'admin', 'admin_bookmarks', - 'admin_tree', 'blog_menu', 'blog_recent', 'blog_tags', diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 7e943c073e3..7e2cee8b480 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4052,6 +4052,16 @@ AND EXISTS (SELECT 'x' } + if ($result && $oldversion < 2010051600) { + + /// Delete the blocks completely. All the contexts, instances etc were cleaned up above in 2009082800 + $DB->delete_records('block', array('name'=>'admin')); + $DB->delete_records('block', array('name'=>'admin_tree')); + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010051600); + } + return $result; } diff --git a/version.php b/version.php index 9250356baa7..b95e2a6fdb1 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2010051500; // YYYYMMDD = date of the last version bump + $version = 2010051600; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 Preview 1 (Build: 20100516)'; // Human-friendly version name