Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
global_navigation_for_ajax Class Reference

The global navigation class used especially for AJAX requests. More...

Inheritance diagram for global_navigation_for_ajax:
global_navigation navigation_node renderable

Public Member Functions

 __construct ($page, $branchtype, $id)
 Constructs the navigation for use in an AJAX request.
 
 __wakeup ()
 Resets the page specific information on this node if it is being unserialised.
 
 action ()
 Get the action url for this navigation node.
 
 action_link_actions ()
 Return an array consisting of the actions for the action link.
 
 actionattributes ()
 Return an array consisting of the additional attributes for the action url.
 
 add ($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null)
 Adds a navigation node as a child of this node.
 
 add_class ($class)
 Adds a CSS class to this node.
 
 add_course (stdClass $course, $forcegeneric=false, $coursetype=self::COURSE_OTHER)
 Adds the given course to the navigation structure.
 
 add_course_essentials ($coursenode, stdClass $course)
 Adds essential course nodes to the navigation for the given course.
 
 add_front_page_course_essentials (navigation_node $coursenode, stdClass $course)
 This generates the structure of the course that won't be generated when the modules and sections are added.
 
 add_node (navigation_node $childnode, $beforekey=null)
 Adds a navigation node as a child of this one, given a $node object created using the create function.
 
 build_flat_navigation_list (flat_navigation $nodes, $showdivider=false, $label='')
 Walk the tree building up a list of all the flat navigation nodes.
 
 check_if_active ($strength=URL_MATCH_EXACT)
 Checks if this node is the active node.
 
 clear_cache ()
 Clears the navigation cache.
 
 contains_active_node ()
 Checks if this node or any of its children contain the active node.
 
 extend_for_user ($user)
 Extends the navigation for the given user.
 
 find ($key, $type)
 Searches this nodes children and their children to find a navigation node with the matching key and type.
 
 find_active_node ()
 Finds the active node.
 
 find_all_of_type ($type)
 Finds all nodes of a given type (recursive)
 
 find_expandable (array &$expandable)
 Finds all nodes that are expandable by AJAX.
 
 force_open ()
 Forces this node to be open and at the same time forces open all parents until the root node.
 
 get ($key, $type=null)
 Attempts to get the navigation with the given key from this nodes children.
 
 get_children_key_list ()
 Return a list of all the keys of all the child nodes.
 
 get_content ($shorttext=false)
 Gets the content for this node.
 
 get_css_type ()
 Gets the CSS class to add to this node to describe its type.
 
 get_expandable ()
 Returns an array of expandable nodes.
 
 get_extending_users ()
 Returns all of the users the navigation is being extended for.
 
 get_siblings ()
 Get a list of sibling navigation nodes at the same level as this one.
 
 get_tabs_array (array $inactive=array(), $return=false)
 Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page.
 
 get_title ()
 Gets the title to use for this node.
 
 has_action ()
 Used to easily determine if this link in the breadcrumbs has a valid action/url.
 
 has_children ()
 Checks if this node has or could have any children.
 
 has_internal_action ()
 Used to easily determine if the action is an internal link.
 
 has_siblings ()
 True if this nav node has siblings in the tree.
 
 hide (array $typestohide=null)
 Hides the node and any children it has.
 
 initialise ()
 Initialise the navigation given the type and id for the branch to expand.
 
 is_action_link ()
 Check whether the node's action is of type action_link.
 
 is_hidden ()
 Used to easily determine if this link in the breadcrumbs is hidden.
 
 is_short_branch ()
 To better balance the admin tree, we want to group all the short top branches together.
 
 load_generic_course_sections (stdClass $course, navigation_node $coursenode)
 Generically loads the course sections into the course's navigation.
 
 make_active ()
 Marks this node as active and forces it open.
 
 make_inactive ()
 Marks a node as inactive and recusised back to the base of the tree doing the same to all parents.
 
 remove ()
 Removes this node.
 
 remove_class ($class)
 Removes a CSS class from this node.
 
 search_for_active_node ($strength=URL_MATCH_BASE)
 Searches all children for the best matching active node.
 
 set_expansion_limit ($type)
 Sets an expansion limit for the navigation.
 
 set_force_into_more_menu (bool $forceintomoremenu=false)
 Sets whether the node and its children should be added into a "more" menu whenever possible.
 
 set_parent (navigation_node $parent)
 Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well.
 
 set_show_in_secondary_navigation (bool $show=true)
 Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.
 
 set_userid_for_parent_checks ($userid)
 Mutator to set userid to allow parent to see child's profile page navigation.
 
 title (?string $title=null)
 Sets the title for this node and forces Moodle to utilise it.
 
 trim_if_empty ()
 Removes this node if it is empty.
 

Static Public Member Functions

static create ($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null)
 Creates a navigation node, ready to add it as a child using add_node function.
 
static module_extends_navigation ($modname)
 This method simply checks to see if a given module can extend the navigation.
 
static override_active_url (moodle_url $url, $loadadmintree=false)
 This sets the URL that the URL of new nodes get compared to when locating the active node.
 
static require_admin_tree ()
 Use when page is linked from the admin tree, if not used navigation could not find the page using current URL because the tree is not fully loaded.
 

Public Attributes

moodle_url action_link null $action = null
 An action for the node (link)
 
navigation_node_collection $children = array()
 An array of child nodes.
 
array $classes = array()
 An array of CSS classes for the node.
 
bool $collapse = false
 If set to true the node will be collapsed by default.
 
bool $display = true
 If set to false the node will not be displayed.
 
bool $forceintomoremenu = false
 If set to true this node will be forced into a "more" menu whenever possible.
 
bool $forceopen = false
 If set to true the node will be expanded by default.
 
bool $forcetitle = false
 If set to true a title will be added to the action no matter what.
 
bool $haschildren
 node that have children.
 
string $helpbutton = null
 A string that can be used to build a help button.
 
bool $hidden = false
 If set to true the node will be dimmed.
 
bool $hideicon = false
 Override to not display the icon even if one is provided.
 
pix_icon $icon = null
 The path to an icon to use for this node.
 
int $id = null
 Parameter to aid the coder in tracking [optional].
 
mixed $includesectionnum = false
 If set to an int, that section will be included even if it has no activities.
 
bool $isactive = false
 If set to true the node will be recognised as active.
 
bool $isexpandable = false
 Set to true if we KNOW that this node can be expanded.
 
string int $key = null
 The identifier for the node, used to retrieve the node.
 
bool $mainnavonly = false
 If set to true the the navigation bar should ignore this node.
 
string $moremenuid
 unique identifier.
 
int $nodetype = self::NODETYPE_LEAF
 See NODETYPE_* constants defined for this class.
 
navigation_node $parent = null
 A reference to the node parent, you should never set this directly you should always call set_parent.
 
bool $preceedwithhr = false
 If set to true then an HR will be printed before the node.
 
bool $requiresajaxloading = false
 does the node need to be loaded via ajax
 
string $shorttext = null
 Short text to use if requested [optional].
 
bool $showchildreninsubmenu = false
 If set to true the children of this node will be displayed within a submenu when applicable.
 
bool $showinflatnavigation = false
 If set to true this node will be added to the "flat" navigation.
 
bool $showinsecondarynavigation = true
 If set to true this node will be displayed in the "secondary" navigation when applicable.
 
string $tab
 tab element ID.
 
string lang_string $text = null
 The text to use for the node.
 
string $title = null
 The title attribute for an action if one is defined.
 
int $type = self::TYPE_UNKNOWN
 See TYPE_* constants defined for this class.
 
const COURSE_CURRENT = 2
 var int Course the current user is currently viewing
 
const COURSE_INDEX_PAGE = 'courseindexpage'
 var string The course index page navigation node
 
const COURSE_MY = 1
 var int Course the current user is enrolled in but not viewing
 
const COURSE_OTHER = 0
 var int Course the current user is not enrolled in
 
const LOAD_ALL_CATEGORIES = -1
 Used when loading categories to load all categories.
 
const LOAD_ROOT_CATEGORIES = 0
 Used when loading categories to load all top level categories [parent = 0].
 
int const NODETYPE_BRANCH = 1
 Used to identify this node a branch, happens with children 1.
 
int const NODETYPE_LEAF = 0
 Used to identify this node a leaf (default) 0.
 
int const TYPE_ACTIVITY = 40
 Activity node type, e.g.
 
int const TYPE_CATEGORY = 10
 Category node type 10.
 
int const TYPE_CONTAINER = 90
 Setting node type, used for containers of no importance 90.
 
int const TYPE_COURSE = 20
 Course node type 20.
 
int const TYPE_CUSTOM = 60
 A custom node type, default when adding without specifing type 60.
 
const TYPE_MY_CATEGORY = 11
 var int Category displayed in MyHome navigation node
 
int const TYPE_RESOURCE = 50
 Resource node type, e.g.
 
int const TYPE_ROOTNODE = 0
 System node type 0.
 
int const TYPE_SECTION = 30
 Course Structure node type 30.
 
int const TYPE_SETTING = 70
 Setting node type, used only within settings nav 70.
 
int const TYPE_SITE_ADMIN = 71
 site admin branch node type, used only within settings nav 71
 
int const TYPE_SYSTEM = 1
 System node type 1.
 
null const TYPE_UNKNOWN = null
 Unknown node type null.
 
int const TYPE_USER = 80
 Setting node type, used only within settings nav 80.
 

Static Public Attributes

static bool $autofindactive = true
 toogles auto matching of active node
 

Protected Member Functions

 add_category (stdClass $category, navigation_node $parent, $nodetype=self::TYPE_CATEGORY)
 Adds a structured category to the navigation in the correct order/place.
 
 add_context_locking_node (\navigation_node $node, context $context)
 Add the menu item to handle locking and unlocking of a conext.
 
 can_add_more_courses_to_category ($category)
 Returns true if more courses can be added to the provided category.
 
 can_expand_course ($course)
 Checks if a user can expand a course in the navigation.
 
 current_user_is_parent_role ()
 Returns true if the current user is a parent of the user being currently viewed.
 
 generate_sections_and_activities (stdClass $course)
 Generates an array of sections and an array of activities for the given course.
 
 get_expand_course_cache ()
 Returns a cache instance to use for the expand course cache.
 
 is_category_fully_loaded ($categoryid)
 Returns true if the category has already been loaded as have any child categories.
 
 load_activity ($cm, stdClass $course, navigation_node $activity)
 Loads the navigation structure for the given activity into the activities node.
 
 load_all_categories ($categoryid=self::LOAD_ROOT_CATEGORIES, $showbasecategories=false)
 Loads all categories (top level or if an id is specified for that category)
 
moodle_database load_all_courses ($categoryids=null)
 Loads the courses in Moodle into the navigation.
 
moodle_database load_category ($categoryid, $nodetype=self::TYPE_CATEGORY)
 Loads a single category into the AJAX navigation.
 
 load_course (stdClass $course)
 Loads the given course into the navigation.
 
 load_course_sections (stdClass $course, navigation_node $coursenode, $sectionnum=null, $cm=null)
 Loads all of the courses section into the navigation.
 
 load_courses_enrolled ()
 They've expanded the 'my courses' branch.
 
 load_courses_other ()
 They've expanded the general 'courses' branch.
 
 load_for_user ($user=null, $forceforcontext=false)
 Loads user specific information into the navigation in the appropriate place.
 
 load_local_plugin_navigation ()
 This function gives local plugins an opportunity to modify navigation.
 
 load_section_activities (navigation_node $sectionnode, $sectionnumber, array $activities, $course=null)
 Loads all of the activities for a section into the navigation structure.
 
 load_stealth_activity (navigation_node $coursenode, $modinfo)
 Loads a stealth module from unavailable section.
 
 show_categories ($ismycourse=false)
 Returns true if courses should be shown within categories on the navigation.
 
 show_my_categories ()
 Returns true if we should show categories in the My Courses branch.
 

Protected Attributes

array $addedcategories = array()
 An array of category ids that are included in the navigation.
 
array $addedcourses = array()
 An array of course ids that are present in the navigation.
 
bool $allcategoriesloaded = false
 
int $branchtype
 used for determining what type of navigation_node\TYPE_* is being used
 
navigation_cache $cache
 
cache_session $cacheexpandcourse = null
 A cache that stores information on expanded courses.
 
array $expandable = array()
 Holds an array of expandable nodes.
 
int $expansionlimit = 0
 expansion limit
 
array $extendforuser = array()
 An array of stdClasses for users that the navigation is extended for.
 
bool $initialised = false
 switch to let us know if the navigation object is initialised
 
int $instanceid
 the instance id
 
array $mycourses = array()
 An array of course information.
 
array $namedtypes
 
moodle_page $page
 The Moodle page this navigation object belongs to.
 
navigation_node[] $rootnodes = array()
 An array for containing root navigation nodes.
 
bool $showcategories = null
 A switch for whether courses should be shown within categories on the navigation.
 
bool $showemptysections = true
 A switch for whether to show empty sections in the navigation.
 
null var $showmycategories = null
 bool A switch for whether or not to show categories in the my courses branch.
 
int $useridtouseforparentchecks = 0
 userid to allow parent to see child's profile page navigation
 

Static Protected Attributes

static moodle_url $fullmeurl = null
 
static bool $loadadmintree = false
 should we load full admin tree or rely on AJAX for performance reasons
 

Detailed Description

The global navigation class used especially for AJAX requests.

The primary methods that are used in the global navigation class have been overriden to ensure that only the relevant branch is generated at the root of the tree. This can be done because AJAX is only used when the backwards structure for the requested branch exists. This has been done only because it shortens the amounts of information that is generated which of course will speed up the response time.. because no one likes laggy AJAX.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

global_navigation_for_ajax::__construct ( $page,
$branchtype,
$id )

Constructs the navigation for use in an AJAX request.

Parameters
moodle_page$pagemoodle_page object
int$branchtype
int$id

Member Function Documentation

◆ action()

navigation_node::action ( )
inherited

Get the action url for this navigation node.

Called from templates.

Since
Moodle 3.2

◆ action_link_actions()

navigation_node::action_link_actions ( )
inherited

Return an array consisting of the actions for the action link.

Return values
arrayFormatted array to parse in a template

◆ actionattributes()

navigation_node::actionattributes ( )
inherited

Return an array consisting of the additional attributes for the action url.

Return values
arrayFormatted array to parse in a template

◆ add()

navigation_node::add ( $text,
$action = null,
$type = self::TYPE_CUSTOM,
$shorttext = null,
$key = null,
pix_icon $icon = null )
inherited

Adds a navigation node as a child of this node.

Parameters
string$text
moodle_url | action_link | string$action
int$type
string$shorttext
string | int$key
pix_icon$icon
Return values
navigation_node

Reimplemented in navbar, and settings_navigation.

◆ add_category()

global_navigation::add_category ( stdClass $category,
navigation_node $parent,
$nodetype = self::TYPE_CATEGORY )
protectedinherited

Adds a structured category to the navigation in the correct order/place.

Parameters
stdClass$categorycategory to be added in navigation.
navigation_node$parentparent navigation node
int$nodetypetype of node, if category is under MyHome then it's TYPE_MY_CATEGORY
Return values
void.

◆ add_class()

navigation_node::add_class ( $class)
inherited

Adds a CSS class to this node.

Parameters
string$class
Return values
bool

◆ add_context_locking_node()

navigation_node::add_context_locking_node ( \navigation_node $node,
context $context )
protectedinherited

Add the menu item to handle locking and unlocking of a conext.

Parameters
navigation_node$nodeNode to add
context$contextThe context to be locked

◆ add_course()

global_navigation::add_course ( stdClass $course,
$forcegeneric = false,
$coursetype = self::COURSE_OTHER )
inherited

Adds the given course to the navigation structure.

Parameters
stdClass$course
bool$forcegeneric
bool$ismycourse
Return values
navigation_node

◆ add_course_essentials()

global_navigation::add_course_essentials ( $coursenode,
stdClass $course )
inherited

Adds essential course nodes to the navigation for the given course.

This method adds nodes such as reports, blogs and participants

Parameters
navigation_node$coursenode
stdClass$course
Return values
boolreturns true on successful addition of a node.

◆ add_front_page_course_essentials()

global_navigation::add_front_page_course_essentials ( navigation_node $coursenode,
stdClass $course )
inherited

This generates the structure of the course that won't be generated when the modules and sections are added.

Things such as the reports branch, the participants branch, blogs... get added to the course node by this method.

Parameters
navigation_node$coursenode
stdClass$course
Return values
boolTrue for successfull generation

◆ add_node()

navigation_node::add_node ( navigation_node $childnode,
$beforekey = null )
inherited

Adds a navigation node as a child of this one, given a $node object created using the create function.

Parameters
navigation_node$childnodeNode to add
string$beforekey
Return values
navigation_nodeThe added node

◆ build_flat_navigation_list()

navigation_node::build_flat_navigation_list ( flat_navigation $nodes,
$showdivider = false,
$label = '' )
inherited

Walk the tree building up a list of all the flat navigation nodes.

Deprecated
since Moodle 4.0
Parameters
flat_navigation$nodesList of the found flat navigation nodes.
boolean$showdividerShow a divider before the first node.
string$labelA label for the collection of navigation links.

◆ can_add_more_courses_to_category()

global_navigation::can_add_more_courses_to_category ( $category)
protectedinherited

Returns true if more courses can be added to the provided category.

Parameters
int | navigation_node | stdClass$category
Return values
bool

◆ can_expand_course()

global_navigation::can_expand_course ( $course)
protectedinherited

Checks if a user can expand a course in the navigation.

We use a cache here because in order to be accurate we need to call can_access_course which is a costly function. Because this functionality is basic + non-essential and because we lack good event triggering this cache permits stale data. In the situation the user is granted access to a course after we've initialised this session cache the cache will be stale. It is brought up to date in only one of two ways.

  1. The user logs out and in again.
  2. The user browses to the course they've just being given access to.

Really all this controls is whether the node is shown as expandable or not. It is uber un-important.

Parameters
stdClass$course
Return values
bool

◆ check_if_active()

navigation_node::check_if_active ( $strength = URL_MATCH_EXACT)
inherited

Checks if this node is the active node.

This is determined by comparing the action for the node against the defined URL for the page. A match will see this node marked as active.

Parameters
int$strengthOne of URL_MATCH_EXACT, URL_MATCH_PARAMS, or URL_MATCH_BASE
Return values
bool

◆ contains_active_node()

navigation_node::contains_active_node ( )
inherited

Checks if this node or any of its children contain the active node.

Recursive.

Return values
bool

◆ create()

static navigation_node::create ( $text,
$action = null,
$type = self::TYPE_CUSTOM,
$shorttext = null,
$key = null,
pix_icon $icon = null )
staticinherited

Creates a navigation node, ready to add it as a child using add_node function.

(The created node needs to be added before you can use it.)

Parameters
string$text
moodle_url | action_link$action
int$type
string$shorttext
string | int$key
pix_icon$icon
Return values
navigation_node

◆ current_user_is_parent_role()

global_navigation::current_user_is_parent_role ( )
protectedinherited

Returns true if the current user is a parent of the user being currently viewed.

If the current user is not viewing another user, or if the current user does not hold any parent roles over the other user being viewed this function returns false. In order to set the user for whom we are checking against you must call set_userid_for_parent_checks()

Since
Moodle 2.4
Return values
bool

◆ extend_for_user()

global_navigation::extend_for_user ( $user)
inherited

Extends the navigation for the given user.

Parameters
stdClass$userA user from the database

◆ find()

global_navigation::find ( $key,
$type )
inherited

Searches this nodes children and their children to find a navigation node with the matching key and type.

This method is recursive and searches children so until either a node is found or there are no more nodes to search.

If you know that the node being searched for is a child of this node then use the global_navigation::get() method instead.

Note: If you are trying to set the active node navigation_node::override_active_url() may be of more use to you.

Parameters
string | int$keyThe key of the node you wish to receive.
int$typeOne of navigation_node\TYPE_*
Return values
navigation_node|false

Reimplemented from navigation_node.

◆ find_active_node()

navigation_node::find_active_node ( )
inherited

Finds the active node.

Searches this nodes children plus all of the children for the active node and returns it if found.

Recursive.

Return values
navigation_node|false

◆ find_all_of_type()

navigation_node::find_all_of_type ( $type)
inherited

Finds all nodes of a given type (recursive)

Parameters
int$typeOne of navigation_node\TYPE_*
Return values
array

◆ find_expandable()

navigation_node::find_expandable ( array & $expandable)
inherited

Finds all nodes that are expandable by AJAX.

Parameters
array$expandableAn array by reference to populate with expandable nodes.

◆ force_open()

navigation_node::force_open ( )
inherited

Forces this node to be open and at the same time forces open all parents until the root node.

Recursive.

◆ generate_sections_and_activities()

global_navigation::generate_sections_and_activities ( stdClass $course)
protectedinherited

Generates an array of sections and an array of activities for the given course.

This method uses the cache to improve performance and avoid the get_fast_modinfo call

Parameters
stdClass$course
Return values
arrayArray($sections, $activities)

◆ get()

global_navigation::get ( $key,
$type = null )
inherited

Attempts to get the navigation with the given key from this nodes children.

This function only looks at this nodes children, it does NOT look recursivily. If the node can't be found then false is returned.

If you need to search recursivily then use the global_navigation::find() method.

Note: If you are trying to set the active node navigation_node::override_active_url() may be of more use to you.

Parameters
string | int$keyThe key of the node you wish to receive.
int$typeOne of navigation_node\TYPE_*
Return values
navigation_node|false

Reimplemented from navigation_node.

◆ get_children_key_list()

navigation_node::get_children_key_list ( )
inherited

Return a list of all the keys of all the child nodes.

Return values
arraythe keys.

◆ get_content()

navigation_node::get_content ( $shorttext = false)
inherited

Gets the content for this node.

Parameters
bool$shorttextIf true shorttext is used rather than the normal text
Return values
string

◆ get_css_type()

navigation_node::get_css_type ( )
inherited

Gets the CSS class to add to this node to describe its type.

Return values
string

◆ get_expand_course_cache()

global_navigation::get_expand_course_cache ( )
protectedinherited

Returns a cache instance to use for the expand course cache.

Return values
cache_session

◆ get_expandable()

global_navigation_for_ajax::get_expandable ( )

Returns an array of expandable nodes.

Return values
array

◆ get_extending_users()

global_navigation::get_extending_users ( )
inherited

Returns all of the users the navigation is being extended for.

Return values
arrayAn array of extending users.

◆ get_siblings()

navigation_node::get_siblings ( )
inherited

Get a list of sibling navigation nodes at the same level as this one.

Return values
bool|arrayof navigation_node

◆ get_tabs_array()

navigation_node::get_tabs_array ( array $inactive = array(),
$return = false )
inherited

Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page.

call_user_func_array('print_tabs', $node->get_tabs_array());

Parameters
array$inactive
bool$return
Return values
arrayArray (tabs, selected, inactive, activated, return)

◆ get_title()

navigation_node::get_title ( )
inherited

Gets the title to use for this node.

Return values
string

◆ has_action()

navigation_node::has_action ( )
inherited

Used to easily determine if this link in the breadcrumbs has a valid action/url.

Return values
boolean

◆ has_children()

navigation_node::has_children ( )
inherited

Checks if this node has or could have any children.

Return values
boolReturns true if it has children or could have (by AJAX expansion)

◆ has_internal_action()

navigation_node::has_internal_action ( )
inherited

Used to easily determine if the action is an internal link.

Return values
bool

◆ has_siblings()

navigation_node::has_siblings ( )
inherited

True if this nav node has siblings in the tree.

Return values
bool

◆ hide()

navigation_node::hide ( array $typestohide = null)
inherited

Hides the node and any children it has.

Since
Moodle 2.5
Parameters
array$typestohideOptional. An array of node types that should be hidden. If null all nodes will be hidden. If an array is given then nodes will only be hidden if their type mtatches an element in the array. e.g. array(navigation_node\TYPE_COURSE) would hide only course nodes.

◆ initialise()

global_navigation_for_ajax::initialise ( )

Initialise the navigation given the type and id for the branch to expand.

Return values
arrayAn array of the expandable nodes

Reimplemented from global_navigation.

◆ is_action_link()

navigation_node::is_action_link ( )
inherited

Check whether the node's action is of type action_link.

Return values
bool

◆ is_category_fully_loaded()

global_navigation::is_category_fully_loaded ( $categoryid)
protectedinherited

Returns true if the category has already been loaded as have any child categories.

Parameters
int$categoryid
Return values
bool

◆ is_hidden()

navigation_node::is_hidden ( )
inherited

Used to easily determine if this link in the breadcrumbs is hidden.

Return values
boolean

◆ is_short_branch()

navigation_node::is_short_branch ( )
inherited

To better balance the admin tree, we want to group all the short top branches together.

This means < 8 nodes and no subtrees.

Return values
bool

◆ load_activity()

global_navigation::load_activity ( $cm,
stdClass $course,
navigation_node $activity )
protectedinherited

Loads the navigation structure for the given activity into the activities node.

This method utilises a callback within the modules lib.php file to load the content specific to activity given.

The callback is a method: {modulename}_extend_navigation() Examples:

Parameters
cm_info | stdClass$cm
stdClass$course
navigation_node$activity
Return values
bool

◆ load_all_categories()

global_navigation::load_all_categories ( $categoryid = self::LOAD_ROOT_CATEGORIES,
$showbasecategories = false )
protectedinherited

Loads all categories (top level or if an id is specified for that category)

Parameters
int$categoryidThe category id to load or null/0 to load all base level categories
bool$showbasecategoriesIf set to true all base level categories will be loaded as well as the requested category and any parent categories.
Return values
navigation_node|voidreturns a navigation node if a category has been loaded.

◆ load_all_courses()

moodle_database global_navigation::load_all_courses ( $categoryids = null)
protectedinherited

Loads the courses in Moodle into the navigation.

$DB

Parameters
string | array$categoryidsAn array containing categories to load courses for, OR null to load courses for all categories.
Return values
arrayAn array of navigation_nodes one for each course

◆ load_category()

moodle_database global_navigation_for_ajax::load_category ( $categoryid,
$nodetype = self::TYPE_CATEGORY )
protected

Loads a single category into the AJAX navigation.

This function is special in that it doesn't concern itself with the parent of the requested category or its siblings. This is because with the AJAX navigation we know exactly what is wanted and only need to request that.

$DB

Parameters
int$categoryidid of category to load in navigation.
int$nodetypetype of node, if category is under MyHome then it's TYPE_MY_CATEGORY
Return values
void.

◆ load_course()

global_navigation::load_course ( stdClass $course)
protectedinherited

Loads the given course into the navigation.

Parameters
stdClass$course
Return values
navigation_node

◆ load_course_sections()

global_navigation::load_course_sections ( stdClass $course,
navigation_node $coursenode,
$sectionnum = null,
$cm = null )
protectedinherited

Loads all of the courses section into the navigation.

This function calls method from current course format, see core_courseformat\base\extend_course_navigation() If course module ($cm) is specified but course format failed to create the node, the activity node is created anyway.

By default course formats call the method global_navigation\load_generic_course_sections()

Parameters
stdClass$courseDatabase record for the course
navigation_node$coursenodeThe course node within the navigation
null | int$sectionnumIf specified load the contents of section with this relative number
null | cm_info$cmIf specified make sure that activity node is created (either in containg section or by calling load_stealth_activity() )

◆ load_for_user()

global_navigation::load_for_user ( $user = null,
$forceforcontext = false )
protectedinherited

Loads user specific information into the navigation in the appropriate place.

If no user is provided the current user is assumed.

Parameters
stdClass$user
bool$forceforcontextprobably force something to be loaded somewhere (ask SamH if not sure what this means)
Return values
bool

◆ load_generic_course_sections()

global_navigation::load_generic_course_sections ( stdClass $course,
navigation_node $coursenode )
inherited

Generically loads the course sections into the course's navigation.

Parameters
stdClass$course
navigation_node$coursenode
Return values
arrayAn array of course section nodes

◆ load_section_activities()

global_navigation::load_section_activities ( navigation_node $sectionnode,
$sectionnumber,
array $activities,
$course = null )
protectedinherited

Loads all of the activities for a section into the navigation structure.

Parameters
navigation_node$sectionnode
int$sectionnumber
array$activitiesAn array of activites as returned by global_navigation::generate_sections_and_activities()
stdClass$courseThe course object the section and activities relate to.
Return values
arrayArray of activity nodes

◆ load_stealth_activity()

global_navigation::load_stealth_activity ( navigation_node $coursenode,
$modinfo )
protectedinherited

Loads a stealth module from unavailable section.

Parameters
navigation_node$coursenode
stdClass | course_modinfo$modinfo
Return values
navigation_nodeor null if not accessible

◆ make_active()

navigation_node::make_active ( )
inherited

Marks this node as active and forces it open.

Important: If you are here because you need to mark a node active to get the navigation to do what you want have you looked at navigation_node::override_active_url()? You can use it to specify a different URL to match the active navigation node on rather than having to locate and manually mark a node active.

◆ module_extends_navigation()

static global_navigation::module_extends_navigation ( $modname)
staticinherited

This method simply checks to see if a given module can extend the navigation.

Todo
(MDL-25290) A shared caching solution should be used to save details on what extends navigation.
Parameters
string$modname
Return values
bool

◆ override_active_url()

static navigation_node::override_active_url ( moodle_url $url,
$loadadmintree = false )
staticinherited

This sets the URL that the URL of new nodes get compared to when locating the active node.

The active node is the node that matches the URL set here. By default this is either $PAGE->url or if that hasn't been set $FULLME.

Parameters
moodle_url$urlThe url to use for the fullmeurl.
bool$loadadmintreeuse true if the URL point to administration tree

◆ remove()

navigation_node::remove ( )
inherited

Removes this node.

Return values
bool

◆ remove_class()

navigation_node::remove_class ( $class)
inherited

Removes a CSS class from this node.

Parameters
string$class
Return values
boolTrue if the class was successfully removed.

◆ search_for_active_node()

navigation_node::search_for_active_node ( $strength = URL_MATCH_BASE)
inherited

Searches all children for the best matching active node.

Parameters
int$strengthThe url match to be made.
Return values
navigation_node|false

◆ set_expansion_limit()

global_navigation::set_expansion_limit ( $type)
inherited

Sets an expansion limit for the navigation.

The expansion limit is used to prevent the display of content that has a type greater than the provided $type.

Can be used to ensure things such as activities or activity content don't get shown on the navigation. They are still generated in order to ensure the navbar still makes sense.

Parameters
int$typeOne of navigation_node\TYPE_*
Return values
booltrue when complete.

◆ set_force_into_more_menu()

navigation_node::set_force_into_more_menu ( bool $forceintomoremenu = false)
inherited

Sets whether the node and its children should be added into a "more" menu whenever possible.

Parameters
bool$forceintomoremenu

◆ set_parent()

navigation_node::set_parent ( navigation_node $parent)
inherited

Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well.

Parameters
navigation_node$parent

◆ set_show_in_secondary_navigation()

navigation_node::set_show_in_secondary_navigation ( bool $show = true)
inherited

Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.

Parameters
bool$show

◆ set_userid_for_parent_checks()

global_navigation::set_userid_for_parent_checks ( $userid)
inherited

Mutator to set userid to allow parent to see child's profile page navigation.

See MDL-25805 for initial issue. Linked to it is an issue explaining why this is a REALLY UGLY HACK thats not for you to use!

Parameters
int$useriduserid of profile page that parent wants to navigate around.

◆ show_categories()

global_navigation::show_categories ( $ismycourse = false)
protectedinherited

Returns true if courses should be shown within categories on the navigation.

Parameters
bool$ismycourseSet to true if you are calculating this for a course.
Return values
bool

◆ show_my_categories()

global_navigation::show_my_categories ( )
protectedinherited

Returns true if we should show categories in the My Courses branch.

Return values
bool

◆ title()

navigation_node::title ( ?string $title = null)
inherited

Sets the title for this node and forces Moodle to utilise it.

Note that this method is named identically to the public "title" property of the class, which unfortunately confuses our Mustache renderer, because it will see the method and try and call it without any arguments (hence must be nullable) before trying to access the public property

Parameters
string | null$title
Return values
string

Member Data Documentation

◆ $isexpandable

bool navigation_node::$isexpandable = false
inherited

Set to true if we KNOW that this node can be expanded.


◆ $namedtypes

array navigation_node::$namedtypes
protectedinherited
Initial value:
= array(0 => 'system', 10 => 'category', 20 => 'course', 30 => 'structure', 40 => 'activity',
50 => 'resource', 60 => 'custom', 70 => 'setting', 71 => 'siteadmin', 80 => 'user',
90 => 'container')

◆ TYPE_ACTIVITY

int const navigation_node::TYPE_ACTIVITY = 40
inherited

Activity node type, e.g.

Forum, Quiz 40

◆ TYPE_RESOURCE

int const navigation_node::TYPE_RESOURCE = 50
inherited

Resource node type, e.g.

Link to a file, or label 50


The documentation for this class was generated from the following file: