mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
it is now possible to hide parts of admin tree - not used yet, but it will be soon used for those hidden unsupported scripts in admin/ directory
This commit is contained in:
parent
7253d30810
commit
a8a66c96ab
@ -57,16 +57,16 @@ class block_admin_tree extends block_base {
|
||||
function build_tree (&$content) {
|
||||
global $CFG;
|
||||
if (is_a($content, 'admin_settingpage')) {
|
||||
if ($content->check_access()) {
|
||||
if ($content->check_access() and !$content->is_hidden()) {
|
||||
$this->create_item($content->visiblename,$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_tree/item.gif');
|
||||
}
|
||||
} else if (is_a($content, 'admin_externalpage')) {
|
||||
if ($content->check_access()) {
|
||||
if ($content->check_access() and !$content->is_hidden()) {
|
||||
$this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_tree/item.gif');
|
||||
}
|
||||
} else if (is_a($content, 'admin_category')) {
|
||||
if ($content->check_access()) {
|
||||
|
||||
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->pathtosection[count($this->pathtosection) - 1] == $content->name) {
|
||||
@ -75,11 +75,11 @@ class block_admin_tree extends block_base {
|
||||
}
|
||||
|
||||
$this->open_folder($content->visiblename);
|
||||
|
||||
|
||||
unset($entries);
|
||||
|
||||
|
||||
$entries = array_keys($content->children);
|
||||
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$this->build_tree($content->children[$entry]);
|
||||
}
|
||||
@ -92,7 +92,7 @@ class block_admin_tree extends block_base {
|
||||
function get_content() {
|
||||
|
||||
global $CFG, $ADMIN;
|
||||
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
$adminroot = admin_get_root();
|
||||
|
||||
@ -107,17 +107,17 @@ class block_admin_tree extends block_base {
|
||||
|
||||
// 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".)
|
||||
|
||||
|
||||
unset($entries);
|
||||
|
||||
|
||||
$entries = array_keys($adminroot->children);
|
||||
|
||||
asort($entries);
|
||||
|
||||
|
||||
asort($entries);
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$this->build_tree($adminroot->children[$entry]);
|
||||
}
|
||||
|
||||
|
||||
if ($this->tempcontent !== '') {
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '<script type="text/javascript">' . "\n\n";
|
||||
@ -131,7 +131,7 @@ class block_admin_tree extends block_base {
|
||||
$this->content->text .= ' }' . "\n";
|
||||
$this->content->text .= ' return null;' . "\n";
|
||||
$this->content->text .= '}' . "\n";
|
||||
|
||||
|
||||
$this->content->text .= 'function toggle(spanid) {' . "\n";
|
||||
$this->content->text .= ' if (getspan(spanid).innerHTML == "") {' . "\n";
|
||||
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
|
||||
@ -155,13 +155,13 @@ class block_admin_tree extends block_base {
|
||||
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
|
||||
$this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
|
||||
$this->content->text .= '}' . "\n";
|
||||
|
||||
|
||||
$this->content->text .= 'function expandall() {' . "\n";
|
||||
$this->content->text .= ' for (i = 1; i <= vh_numspans; i++) {' . "\n";
|
||||
$this->content->text .= ' expand("vh_span" + String(i));' . "\n";
|
||||
$this->content->text .= ' }' . "\n";
|
||||
$this->content->text .= '}' . "\n";
|
||||
|
||||
|
||||
$this->content->text .= 'function collapseall() {' . "\n";
|
||||
$this->content->text .= ' for (i = vh_numspans; i > 0; i--) {' . "\n";
|
||||
$this->content->text .= ' collapse("vh_span" + String(i));' . "\n";
|
||||
@ -170,9 +170,9 @@ class block_admin_tree extends block_base {
|
||||
|
||||
$this->content->text .= '</script>' . "\n";
|
||||
$this->content->text .= '<div align="left">' . "\n";
|
||||
|
||||
|
||||
$this->content->text .= $this->tempcontent;
|
||||
|
||||
|
||||
$this->content->text .= '</div>' . "\n";
|
||||
$this->content->text .= '<script type="text/javascript">' . "\n";
|
||||
$this->content->text .= 'collapseall();' . "\n";
|
||||
|
@ -741,7 +741,7 @@ class part_of_admin_tree {
|
||||
* Removes named part_of_admin_tree.
|
||||
*
|
||||
* @param string $name The internal name of the part_of_admin_tree we want to remove.
|
||||
* @return boolean success.
|
||||
* @return bool success.
|
||||
*/
|
||||
function prune($name) {
|
||||
trigger_error('Admin class does not implement method <strong>prune()</strong>', E_USER_WARNING);
|
||||
@ -765,6 +765,16 @@ class part_of_admin_tree {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mostly usefull for removing of some parts of the tree in admin tree block.
|
||||
*
|
||||
* @return True is hidden from normal list view
|
||||
*/
|
||||
function is_hidden() {
|
||||
trigger_error('Admin class does not implement method <strong>is_hidden()</strong>', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the path to $name in the admin tree.
|
||||
*
|
||||
@ -847,6 +857,11 @@ class admin_category extends parentable_part_of_admin_tree {
|
||||
*/
|
||||
var $visiblename;
|
||||
|
||||
/**
|
||||
* @var bool Should this category be hidden in admin tree block?
|
||||
*/
|
||||
var $hidden;
|
||||
|
||||
// constructor for an empty admin category
|
||||
// $name is the internal name of the category. it MUST be unique in the entire hierarchy
|
||||
// $visiblename is the displayed name of the category. use a get_string for this
|
||||
@ -856,12 +871,14 @@ class admin_category extends parentable_part_of_admin_tree {
|
||||
*
|
||||
* @param string $name The internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
|
||||
* @param string $visiblename The displayed named for this category. Usually obtained through get_string()
|
||||
* @param bool $hidden hide category in admin tree block
|
||||
* @return mixed Returns the new object.
|
||||
*/
|
||||
function admin_category($name, $visiblename) {
|
||||
function admin_category($name, $visiblename, $hidden = false) {
|
||||
$this->children = array();
|
||||
$this->name = $name;
|
||||
$this->visiblename = $visiblename;
|
||||
$this->hidden = $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -914,7 +931,7 @@ class admin_category extends parentable_part_of_admin_tree {
|
||||
* Removes part_of_admin_tree object with internal name $name.
|
||||
*
|
||||
* @param string $name The internal name of the object we want to remove.
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function prune($name) {
|
||||
|
||||
@ -994,6 +1011,14 @@ class admin_category extends parentable_part_of_admin_tree {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this category hidden in admin tree block?
|
||||
*
|
||||
* @return bool True if hidden
|
||||
*/
|
||||
function is_hidden() {
|
||||
return $this->hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1026,6 +1051,11 @@ class admin_externalpage extends part_of_admin_tree {
|
||||
*/
|
||||
var $req_capability;
|
||||
|
||||
/**
|
||||
* @var bool hidden in admin tree block.
|
||||
*/
|
||||
var $hidden;
|
||||
|
||||
/**
|
||||
* Constructor for adding an external page into the admin tree.
|
||||
*
|
||||
@ -1034,7 +1064,7 @@ class admin_externalpage extends part_of_admin_tree {
|
||||
* @param string $url The external URL that we should link to when someone requests this external page.
|
||||
* @param mixed $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'.
|
||||
*/
|
||||
function admin_externalpage($name, $visiblename, $url, $req_capability = 'moodle/site:config') {
|
||||
function admin_externalpage($name, $visiblename, $url, $req_capability = 'moodle/site:config', $hidden=false) {
|
||||
$this->name = $name;
|
||||
$this->visiblename = $visiblename;
|
||||
$this->url = $url;
|
||||
@ -1043,6 +1073,7 @@ class admin_externalpage extends part_of_admin_tree {
|
||||
} else {
|
||||
$this->req_capability = array($req_capability);
|
||||
}
|
||||
$this->hidden = $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1096,6 +1127,15 @@ class admin_externalpage extends part_of_admin_tree {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this external page hidden in admin tree block?
|
||||
*
|
||||
* @return bool True if hidden
|
||||
*/
|
||||
function is_hidden() {
|
||||
return $this->hidden;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1125,6 +1165,11 @@ class admin_settingpage extends part_of_admin_tree {
|
||||
*/
|
||||
var $req_capability;
|
||||
|
||||
/**
|
||||
* @var bool hidden in admin tree block.
|
||||
*/
|
||||
var $hidden;
|
||||
|
||||
// see admin_category
|
||||
function path($name, $path = array()) {
|
||||
if ($name == $this->name) {
|
||||
@ -1146,7 +1191,7 @@ class admin_settingpage extends part_of_admin_tree {
|
||||
}
|
||||
|
||||
// see admin_externalpage
|
||||
function admin_settingpage($name, $visiblename, $req_capability = 'moodle/site:config') {
|
||||
function admin_settingpage($name, $visiblename, $req_capability = 'moodle/site:config', $hidden=false) {
|
||||
global $CFG;
|
||||
$this->settings = new stdClass();
|
||||
$this->name = $name;
|
||||
@ -1156,6 +1201,7 @@ class admin_settingpage extends part_of_admin_tree {
|
||||
} else {
|
||||
$this->req_capability = array($req_capability);
|
||||
}
|
||||
$this->hidden = false;
|
||||
}
|
||||
|
||||
// not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
|
||||
@ -1211,6 +1257,15 @@ class admin_settingpage extends part_of_admin_tree {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this settigns page hidden in admin tree block?
|
||||
*
|
||||
* @return bool True if hidden
|
||||
*/
|
||||
function is_hidden() {
|
||||
return $this->hidden;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user