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) {
}
$this->open_folder($content->visiblename);
-
+
unset($entries);
-
+
$entries = array_keys($content->children);
-
+
foreach ($entries as $entry) {
$this->build_tree($content->children[$entry]);
}
function get_content() {
global $CFG, $ADMIN;
-
+
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
// 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";
$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";
$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";
$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";
* 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);
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.
*
*/
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
*
* @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;
}
/**
* 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) {
}
+ /**
+ * Is this category hidden in admin tree block?
+ *
+ * @return bool True if hidden
+ */
+ function is_hidden() {
+ return $this->hidden;
+ }
}
/**
*/
var $req_capability;
+ /**
+ * @var bool hidden in admin tree block.
+ */
+ var $hidden;
+
/**
* Constructor for adding an external page into the 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;
} else {
$this->req_capability = array($req_capability);
}
+ $this->hidden = $hidden;
}
/**
return false;
}
+ /**
+ * Is this external page hidden in admin tree block?
+ *
+ * @return bool True if hidden
+ */
+ function is_hidden() {
+ return $this->hidden;
+ }
+
}
/**
*/
var $req_capability;
+ /**
+ * @var bool hidden in admin tree block.
+ */
+ var $hidden;
+
// see admin_category
function path($name, $path = array()) {
if ($name == $this->name) {
}
// 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;
} 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
return $return;
}
+ /**
+ * Is this settigns page hidden in admin tree block?
+ *
+ * @return bool True if hidden
+ */
+ function is_hidden() {
+ return $this->hidden;
+ }
+
}