idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
30,700
public static function override_active_url ( moodle_url $ url , $ loadadmintree = false ) { self :: $ fullmeurl = new moodle_url ( $ url ) ; if ( $ loadadmintree ) { self :: $ loadadmintree = true ; } }
This sets the URL that the URL of new nodes get compared to when locating the active node .
30,701
public function add ( $ text , $ action = null , $ type = self :: TYPE_CUSTOM , $ shorttext = null , $ key = null , pix_icon $ icon = null ) { $ childnode = self :: create ( $ text , $ action , $ type , $ shorttext , $ key , $ icon ) ; return $ this -> add_node ( $ childnode ) ; }
Adds a navigation node as a child of this node .
30,702
public function build_flat_navigation_list ( flat_navigation $ nodes , $ showdivider = false , $ label = '' ) { if ( $ this -> showinflatnavigation ) { $ indent = 0 ; if ( $ this -> type == self :: TYPE_COURSE || $ this -> key === self :: COURSE_INDEX_PAGE ) { $ indent = 1 ; } $ flat = new flat_navigation_node ( $ this...
Walk the tree building up a list of all the flat navigation nodes .
30,703
public function has_children ( ) { return ( $ this -> nodetype === navigation_node :: NODETYPE_BRANCH || $ this -> children -> count ( ) > 0 || $ this -> isexpandable ) ; }
Checks if this node has or could have any children
30,704
public function make_active ( ) { $ this -> isactive = true ; $ this -> add_class ( 'active_tree_node' ) ; $ this -> force_open ( ) ; if ( $ this -> parent !== null ) { $ this -> parent -> make_inactive ( ) ; } }
Marks this node as active and forces it open .
30,705
public function make_inactive ( ) { $ this -> isactive = false ; $ this -> remove_class ( 'active_tree_node' ) ; if ( $ this -> parent !== null ) { $ this -> parent -> make_inactive ( ) ; } }
Marks a node as inactive and recusised back to the base of the tree doing the same to all parents .
30,706
public function force_open ( ) { $ this -> forceopen = true ; if ( $ this -> parent !== null ) { $ this -> parent -> force_open ( ) ; } }
Forces this node to be open and at the same time forces open all parents until the root node .
30,707
public function remove_class ( $ class ) { if ( in_array ( $ class , $ this -> classes ) ) { $ key = array_search ( $ class , $ this -> classes ) ; if ( $ key !== false ) { unset ( $ this -> classes [ $ key ] ) ; return true ; } } return false ; }
Removes a CSS class from this node .
30,708
public function contains_active_node ( ) { if ( $ this -> isactive ) { return true ; } else { foreach ( $ this -> children as $ child ) { if ( $ child -> isactive || $ child -> contains_active_node ( ) ) { return true ; } } } return false ; }
Checks if this node or any of its children contain the active node .
30,709
public function is_short_branch ( ) { $ limit = 8 ; if ( $ this -> children -> count ( ) >= $ limit ) { return false ; } foreach ( $ this -> children as $ child ) { if ( $ child -> has_children ( ) ) { return false ; } } return true ; }
To better balance the admin tree we want to group all the short top branches together .
30,710
public function find_active_node ( ) { if ( $ this -> isactive ) { return $ this ; } else { foreach ( $ this -> children as & $ child ) { $ outcome = $ child -> find_active_node ( ) ; if ( $ outcome !== false ) { return $ outcome ; } } } return false ; }
Finds the active node .
30,711
public function search_for_active_node ( ) { if ( $ this -> check_if_active ( URL_MATCH_BASE ) ) { return $ this ; } else { foreach ( $ this -> children as & $ child ) { $ outcome = $ child -> search_for_active_node ( ) ; if ( $ outcome !== false ) { return $ outcome ; } } } return false ; }
Searches all children for the best matching active node
30,712
public function get_content ( $ shorttext = false ) { if ( $ shorttext && $ this -> shorttext !== null ) { return format_string ( $ this -> shorttext ) ; } else { return format_string ( $ this -> text ) ; } }
Gets the content for this node .
30,713
public function get_css_type ( ) { if ( array_key_exists ( $ this -> type , $ this -> namedtypes ) ) { return 'type_' . $ this -> namedtypes [ $ this -> type ] ; } return 'type_unknown' ; }
Gets the CSS class to add to this node to describe its type
30,714
public function find_expandable ( array & $ expandable ) { foreach ( $ this -> children as & $ child ) { if ( $ child -> display && $ child -> has_children ( ) && $ child -> children -> count ( ) == 0 ) { $ child -> id = 'expandable_branch_' . $ child -> type . '_' . clean_param ( $ child -> key , PARAM_ALPHANUMEXT ) ;...
Finds all nodes that are expandable by AJAX
30,715
public function get_tabs_array ( array $ inactive = array ( ) , $ return = false ) { $ tabs = array ( ) ; $ rows = array ( ) ; $ selected = null ; $ activated = array ( ) ; foreach ( $ this -> children as $ node ) { $ tabs [ ] = new tabobject ( $ node -> key , $ node -> action , $ node -> get_content ( ) , $ node -> ge...
Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page .
30,716
public function set_parent ( navigation_node $ parent ) { $ this -> parent = $ parent ; if ( $ this -> isactive ) { $ this -> parent -> force_open ( ) ; $ this -> parent -> make_inactive ( ) ; } }
Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well .
30,717
public function hide ( array $ typestohide = null ) { if ( $ typestohide === null || in_array ( $ this -> type , $ typestohide ) ) { $ this -> display = false ; if ( $ this -> has_children ( ) ) { foreach ( $ this -> children as $ child ) { $ child -> hide ( $ typestohide ) ; } } } }
Hides the node and any children it has .
30,718
public function action ( ) { if ( $ this -> action instanceof moodle_url ) { return $ this -> action ; } else if ( $ this -> action instanceof action_link ) { return $ this -> action -> url ; } return $ this -> action ; }
Get the action url for this navigation node . Called from templates .
30,719
protected function add_context_locking_node ( \ navigation_node $ node , \ context $ context ) { global $ CFG ; if ( ! empty ( $ CFG -> contextlocking ) && has_capability ( 'moodle/site:managecontextlocks' , $ context ) ) { $ parentcontext = $ context -> get_parent_context ( ) ; if ( empty ( $ parentcontext ) || ! $ pa...
Add the menu item to handle locking and unlocking of a conext .
30,720
public function add ( navigation_node $ node , $ beforekey = null ) { global $ CFG ; $ key = $ node -> key ; $ type = $ node -> type ; if ( ! array_key_exists ( $ type , $ this -> orderedcollection ) ) { $ this -> orderedcollection [ $ type ] = array ( ) ; } if ( $ CFG -> debug && array_key_exists ( $ key , $ this -> o...
Adds a navigation node to the collection
30,721
public function get_key_list ( ) { $ keys = array ( ) ; foreach ( $ this -> collection as $ node ) { $ keys [ ] = $ node -> key ; } return $ keys ; }
Return a list of all the keys of all the nodes .
30,722
public function get ( $ key , $ type = null ) { if ( $ type !== null ) { if ( ! empty ( $ this -> orderedcollection [ $ type ] [ $ key ] ) ) { return $ this -> orderedcollection [ $ type ] [ $ key ] ; } } else { foreach ( $ this -> collection as $ node ) { if ( $ node -> key === $ key ) { return $ node ; } } } return f...
Fetches a node from this collection .
30,723
public function find ( $ key , $ type = null ) { if ( $ type !== null && array_key_exists ( $ type , $ this -> orderedcollection ) && array_key_exists ( $ key , $ this -> orderedcollection [ $ type ] ) ) { return $ this -> orderedcollection [ $ type ] [ $ key ] ; } else { $ nodes = $ this -> getIterator ( ) ; foreach (...
Searches for a node with matching key and type .
30,724
public function type ( $ type ) { if ( ! array_key_exists ( $ type , $ this -> orderedcollection ) ) { $ this -> orderedcollection [ $ type ] = array ( ) ; } return $ this -> orderedcollection [ $ type ] ; }
Fetches all nodes of a given type from this collection
30,725
public function remove ( $ key , $ type = null ) { $ child = $ this -> get ( $ key , $ type ) ; if ( $ child !== false ) { foreach ( $ this -> collection as $ colkey => $ node ) { if ( $ node -> key === $ key && ( is_null ( $ type ) || $ node -> type == $ type ) ) { unset ( $ this -> collection [ $ colkey ] ) ; $ this ...
Removes the node with the given key and type from the collection
30,726
protected function current_user_is_parent_role ( ) { global $ USER , $ DB ; if ( $ this -> useridtouseforparentchecks && $ this -> useridtouseforparentchecks != $ USER -> id ) { $ usercontext = context_user :: instance ( $ this -> useridtouseforparentchecks , MUST_EXIST ) ; if ( ! has_capability ( 'moodle/user:viewdeta...
Returns true if the current user is a parent of the user being currently viewed .
30,727
protected function show_categories ( $ ismycourse = false ) { global $ CFG , $ DB ; if ( $ ismycourse ) { return $ this -> show_my_categories ( ) ; } if ( $ this -> showcategories === null ) { $ show = false ; if ( $ this -> page -> context -> contextlevel == CONTEXT_COURSECAT ) { $ show = true ; } else if ( ! empty ( ...
Returns true if courses should be shown within categories on the navigation .
30,728
protected function show_my_categories ( ) { global $ CFG ; if ( $ this -> showmycategories === null ) { $ this -> showmycategories = ! empty ( $ CFG -> navshowmycoursecategories ) && ! core_course_category :: is_simple_site ( ) ; } return $ this -> showmycategories ; }
Returns true if we should show categories in the My Courses branch .
30,729
protected function can_add_more_courses_to_category ( $ category ) { global $ CFG ; $ limit = 20 ; if ( ! empty ( $ CFG -> navcourselimit ) ) { $ limit = ( int ) $ CFG -> navcourselimit ; } if ( is_numeric ( $ category ) ) { if ( ! array_key_exists ( $ category , $ this -> addedcategories ) ) { return true ; } $ course...
Returns true if more courses can be added to the provided category .
30,730
protected function load_course ( stdClass $ course ) { global $ SITE ; if ( $ course -> id == $ SITE -> id ) { return $ this -> rootnodes [ 'site' ] ; } else if ( array_key_exists ( $ course -> id , $ this -> addedcourses ) ) { return $ this -> addedcourses [ $ course -> id ] ; } else { return $ this -> add_course ( $ ...
Loads the given course into the navigation
30,731
protected function load_course_sections ( stdClass $ course , navigation_node $ coursenode , $ sectionnum = null , $ cm = null ) { global $ CFG , $ SITE ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; if ( isset ( $ cm -> sectionnum ) ) { $ sectionnum = $ cm -> sectionnum ; } if ( $ sectionnum !== null ) { $ ...
Loads all of the courses section into the navigation .
30,732
protected function generate_sections_and_activities ( stdClass $ course ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; $ modinfo = get_fast_modinfo ( $ course ) ; $ sections = $ modinfo -> get_section_info_all ( ) ; $ courseformatoptions = course_get_format ( $ course ) -> get_format_options...
Generates an array of sections and an array of activities for the given course .
30,733
public function load_generic_course_sections ( stdClass $ course , navigation_node $ coursenode ) { global $ CFG , $ DB , $ USER , $ SITE ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; list ( $ sections , $ activities ) = $ this -> generate_sections_and_activities ( $ course ) ; $ navigationsections = array ...
Generically loads the course sections into the course s navigation .
30,734
protected function load_section_activities ( navigation_node $ sectionnode , $ sectionnumber , array $ activities , $ course = null ) { global $ CFG , $ SITE ; static $ legacyonclickcounter = 0 ; $ activitynodes = array ( ) ; if ( empty ( $ activities ) ) { return $ activitynodes ; } if ( ! is_object ( $ course ) ) { $...
Loads all of the activities for a section into the navigation structure .
30,735
protected function load_stealth_activity ( navigation_node $ coursenode , $ modinfo ) { if ( empty ( $ modinfo -> cms [ $ this -> page -> cm -> id ] ) ) { return null ; } $ cm = $ modinfo -> cms [ $ this -> page -> cm -> id ] ; if ( $ cm -> icon ) { $ icon = new pix_icon ( $ cm -> icon , get_string ( 'modulename' , $ c...
Loads a stealth module from unavailable section
30,736
protected function load_activity ( $ cm , stdClass $ course , navigation_node $ activity ) { global $ CFG , $ DB ; if ( ! ( $ cm instanceof cm_info ) ) { $ modinfo = get_fast_modinfo ( $ course ) ; $ cm = $ modinfo -> get_cm ( $ cm -> id ) ; } $ activity -> nodetype = navigation_node :: NODETYPE_LEAF ; $ activity -> ma...
Loads the navigation structure for the given activity into the activities node .
30,737
public static function module_extends_navigation ( $ modname ) { global $ CFG ; static $ extendingmodules = array ( ) ; if ( ! array_key_exists ( $ modname , $ extendingmodules ) ) { $ extendingmodules [ $ modname ] = false ; $ file = $ CFG -> dirroot . '/mod/' . $ modname . '/lib.php' ; if ( file_exists ( $ file ) ) {...
This method simply checks to see if a given module can extend the navigation .
30,738
protected function get_expand_course_cache ( ) { if ( $ this -> cacheexpandcourse === null ) { $ this -> cacheexpandcourse = cache :: make ( 'core' , 'navigation_expandcourse' ) ; } return $ this -> cacheexpandcourse ; }
Returns a cache instance to use for the expand course cache .
30,739
protected function can_expand_course ( $ course ) { $ cache = $ this -> get_expand_course_cache ( ) ; $ canexpand = $ cache -> get ( $ course -> id ) ; if ( $ canexpand === false ) { $ canexpand = isloggedin ( ) && can_access_course ( $ course , null , '' , true ) ; $ canexpand = ( int ) $ canexpand ; $ cache -> set ( ...
Checks if a user can expand a course in the navigation .
30,740
protected function is_category_fully_loaded ( $ categoryid ) { return ( array_key_exists ( $ categoryid , $ this -> addedcategories ) && ( $ this -> allcategoriesloaded || $ this -> addedcategories [ $ categoryid ] -> children -> count ( ) > 0 ) ) ; }
Returns true if the category has already been loaded as have any child categories
30,741
public function set_expansion_limit ( $ type ) { global $ SITE ; $ nodes = $ this -> find_all_of_type ( $ type ) ; $ typestohide = array ( self :: TYPE_CATEGORY , self :: TYPE_COURSE , self :: TYPE_SECTION , self :: TYPE_ACTIVITY ) ; foreach ( $ nodes as $ node ) { if ( $ type == self :: TYPE_COURSE && $ node -> key ==...
Sets an expansion limit for the navigation
30,742
public function get ( $ key , $ type = null ) { if ( ! $ this -> initialised ) { $ this -> initialise ( ) ; } return parent :: get ( $ key , $ type ) ; }
Attempts to get the navigation with the given key from this nodes children .
30,743
public function find ( $ key , $ type ) { if ( ! $ this -> initialised ) { $ this -> initialise ( ) ; } if ( $ type == self :: TYPE_ROOTNODE && array_key_exists ( $ key , $ this -> rootnodes ) ) { return $ this -> rootnodes [ $ key ] ; } return parent :: find ( $ key , $ type ) ; }
Searches this nodes children and their children to find a navigation node with the matching key and type .
30,744
public function has_items ( ) { if ( $ this -> duringinstall ) { return false ; } else if ( $ this -> hasitems !== false ) { return true ; } if ( count ( $ this -> children ) > 0 || count ( $ this -> prependchildren ) > 0 ) { $ outcome = true ; } else if ( ! $ this -> ignoreactive ) { $ this -> page -> navigation -> in...
Quick check to see if the navbar will have items in .
30,745
public function get ( $ key , $ type = null ) { foreach ( $ this -> children as & $ child ) { if ( $ child -> key === $ key && ( $ type == null || $ type == $ child -> type ) ) { return $ child ; } } foreach ( $ this -> prependchildren as & $ child ) { if ( $ child -> key === $ key && ( $ type == null || $ type == $ ch...
Gets a navigation node
30,746
private function get_course_categories ( ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; $ categories = array ( ) ; $ cap = 'moodle/category:viewhiddencategories' ; $ showcategories = ! core_course_category :: is_simple_site ( ) ; if ( $ showcategories ) { foreach ( $ this -> page -> categori...
Get the list of categories leading to this course .
30,747
public function get_collectionlabel ( ) { if ( ! empty ( $ this -> collectionlabel ) ) { return $ this -> collectionlabel ; } if ( $ this -> parent && ( $ this -> parent instanceof flat_navigation_node || $ this -> parent instanceof flat_navigation ) ) { return $ this -> parent -> get_collectionlabel ( ) ; } debugging ...
Getter get the label for this flat_navigation node or it s parent if it doesn t have one .
30,748
public function isactive ( ) { global $ PAGE ; if ( $ this -> is_section ( ) ) { $ active = $ PAGE -> navigation -> find_active_node ( ) ; while ( $ active = $ active -> parent ) { if ( $ active -> key == $ this -> key && $ active -> type == $ this -> type ) { return true ; } } } return $ this -> isactive ; }
In flat navigation - sections are active if we are looking at activities in the section .
30,749
public function set_showdivider ( $ val , $ label = '' ) { $ this -> showdivider = $ val ; if ( $ this -> showdivider && empty ( $ label ) ) { debugging ( 'Navigation region requires a label' , DEBUG_DEVELOPER ) ; } else { $ this -> set_collectionlabel ( $ label ) ; } }
Setter for showdivider
30,750
public function add ( navigation_node $ node , $ beforekey = null ) { $ result = parent :: add ( $ node , $ beforekey ) ; if ( empty ( $ this -> collectionlabel ) ) { if ( $ node instanceof flat_navigation_node ) { $ this -> set_collectionlabel ( $ node -> get_collectionlabel ( ) ) ; } } return $ result ; }
Override the parent so we can set a label for this collection if it has not been set yet .
30,751
public function add ( $ text , $ url = null , $ type = null , $ shorttext = null , $ key = null , pix_icon $ icon = null ) { $ node = parent :: add ( $ text , $ url , $ type , $ shorttext , $ key , $ icon ) ; $ node -> add_class ( 'root_node' ) ; return $ node ; }
Override the parent function so that we can add preceeding hr s and set a root node class against all first level element
30,752
public function prepend ( $ text , $ url = null , $ type = null , $ shorttext = null , $ key = null , pix_icon $ icon = null ) { $ children = $ this -> children ; $ childrenclass = get_class ( $ children ) ; $ this -> children = new $ childrenclass ; $ node = $ this -> add ( $ text , $ url , $ type , $ shorttext , $ ke...
This function allows the user to add something to the start of the settings navigation which means it will be at the top of the settings navigation block
30,753
protected function is_admin_tree_needed ( ) { if ( self :: $ loadadmintree ) { return true ; } if ( $ this -> page -> pagelayout === 'admin' or strpos ( $ this -> page -> pagetype , 'admin-' ) === 0 ) { if ( $ this -> page -> context -> contextlevel != CONTEXT_SYSTEM ) { return false ; } return true ; } return false ; ...
Does this page require loading of full admin tree or is it enough rely on AJAX?
30,754
protected function scan_for_active_node ( navigation_node $ node ) { if ( ! $ node -> check_if_active ( ) && $ node -> children -> count ( ) > 0 ) { foreach ( $ node -> children as & $ child ) { $ this -> scan_for_active_node ( $ child ) ; } } }
This function recursivily scans nodes until it finds the active node or there are no more nodes .
30,755
protected function get_by_path ( array $ path ) { $ node = $ this -> get ( array_shift ( $ path ) ) ; foreach ( $ path as $ key ) { $ node -> get ( $ key ) ; } return $ node ; }
Gets a navigation node given an array of keys that represent the path to the desired node .
30,756
protected function load_user_settings ( $ courseid = SITEID ) { global $ USER , $ CFG ; if ( isguestuser ( ) || ! isloggedin ( ) ) { return false ; } $ navusers = $ this -> page -> navigation -> get_extending_users ( ) ; if ( count ( $ this -> userstoextendfor ) > 0 || count ( $ navusers ) > 0 ) { $ usernode = null ; f...
Loads the user settings block of the settings nav
30,757
public function extend_for_user ( $ userid ) { global $ CFG ; if ( ! in_array ( $ userid , $ this -> userstoextendfor ) ) { $ this -> userstoextendfor [ ] = $ userid ; if ( $ this -> initialised ) { $ this -> generate_user_settings ( $ this -> page -> course -> id , $ userid , 'userviewingsettings' ) ; $ children = arr...
Extends the settings navigation for the given user .
30,758
protected function load_block_settings ( ) { global $ CFG ; $ blocknode = $ this -> add ( $ this -> context -> get_context_name ( ) , null , self :: TYPE_SETTING , null , 'blocksettings' ) ; $ blocknode -> force_open ( ) ; if ( get_assignable_roles ( $ this -> context , ROLENAME_ORIGINAL ) ) { $ assignurl = new moodle_...
Loads block specific settings in the navigation
30,759
public function can_view_user_preferences ( $ userid ) { if ( is_siteadmin ( ) ) { return true ; } $ preferencenode = $ this -> find ( 'userviewingsettings' . $ userid , null ) ; if ( $ preferencenode && $ preferencenode -> has_children ( ) ) { foreach ( $ preferencenode -> children as $ childnode ) { if ( $ childnode ...
Checks to see if there are child nodes available in the specific user s preference node . If so then they have the appropriate permissions view this user s preferences .
30,760
public function initialise ( ) { if ( $ this -> initialised || during_initial_install ( ) ) { return false ; } $ this -> context = $ this -> page -> context ; $ this -> load_administration_settings ( ) ; $ this -> load_local_plugin_settings ( ) ; $ this -> initialised = true ; }
Initialise the site admin navigation .
30,761
public function set_expandable ( $ expandable ) { foreach ( $ expandable as $ node ) { $ this -> expandable [ $ node [ 'key' ] . ':' . $ node [ 'type' ] ] = $ node ; } }
Set the expandable items in the array so that we have enough information to attach AJAX events
30,762
protected function ensure_session_cache_initialised ( ) { global $ SESSION ; if ( empty ( $ this -> session ) ) { if ( ! isset ( $ SESSION -> navcache ) ) { $ SESSION -> navcache = new stdClass ; } if ( ! isset ( $ SESSION -> navcache -> { $ this -> area } ) ) { $ SESSION -> navcache -> { $ this -> area } = array ( ) ;...
Used to set up the cache within the SESSION .
30,763
public function cached ( $ key ) { global $ USER ; $ this -> ensure_session_cache_initialised ( ) ; if ( ! array_key_exists ( $ key , $ this -> session ) || ! is_array ( $ this -> session [ $ key ] ) || $ this -> session [ $ key ] [ self :: CACHEUSERID ] != $ USER -> id || $ this -> session [ $ key ] [ self :: CACHETIM...
Check the existence of the identifier in the cache
30,764
public function compare ( $ key , $ value , $ serialise = true ) { if ( $ this -> cached ( $ key ) ) { if ( $ serialise ) { $ value = serialize ( $ value ) ; } if ( $ this -> session [ $ key ] [ self :: CACHEVALUE ] === $ value ) { return true ; } } return false ; }
Compare something to it s equivilant in the cache
30,765
protected function garbage_collection ( ) { if ( empty ( $ this -> session ) ) { return true ; } foreach ( $ this -> session as $ key => $ cachedinfo ) { if ( is_array ( $ cachedinfo ) && $ cachedinfo [ self :: CACHETIME ] < $ this -> timeout ) { unset ( $ this -> session [ $ key ] ) ; } } }
Checks all cache entries and removes any that have expired good ole cleanup
30,766
public static function destroy_volatile_caches ( ) { global $ SESSION ; if ( is_array ( self :: $ volatilecaches ) && count ( self :: $ volatilecaches ) > 0 ) { foreach ( self :: $ volatilecaches as $ area ) { $ SESSION -> navcache -> { $ area } = array ( ) ; } } else { $ SESSION -> navcache = new stdClass ; } }
Destroys all caches marked as volatile
30,767
public static function get_forums_by_courses ( $ courseids = array ( ) ) { global $ CFG ; require_once ( $ CFG -> dirroot . "/mod/forum/lib.php" ) ; $ params = self :: validate_parameters ( self :: get_forums_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ courses = array ( ) ; if ( empty ( $ par...
Returns a list of forums in a provided list of courses if no list is provided all forums that the user can view will be returned .
30,768
public static function get_forums_by_courses_returns ( ) { return new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Forum id' ) , 'course' => new external_value ( PARAM_INT , 'Course id' ) , 'type' => new external_value ( PARAM_TEXT , 'The forum type' ) ...
Describes the get_forum return value .
30,769
public static function get_discussion_posts ( int $ discussionid , ? string $ sortby , ? string $ sortdirection ) { global $ USER ; $ params = self :: validate_parameters ( self :: get_discussion_posts_parameters ( ) , [ 'discussionid' => $ discussionid , 'sortby' => $ sortby , 'sortdirection' => $ sortdirection , ] ) ...
Get the forum posts in the specified discussion .
30,770
public static function get_discussion_posts_parameters ( ) { return new external_function_parameters ( [ 'discussionid' => new external_value ( PARAM_INT , 'The ID of the discussion from which to fetch posts.' , VALUE_REQUIRED ) , 'sortby' => new external_value ( PARAM_ALPHA , 'Sort by this element: id, created or modi...
Describe the post parameters .
30,771
public static function get_discussion_posts_returns ( ) { return new external_single_structure ( [ 'posts' => new external_multiple_structure ( \ mod_forum \ local \ exporters \ post :: get_read_structure ( ) ) , 'ratinginfo' => \ core_rating \ external \ util :: external_ratings_structure ( ) , 'warnings' => new exter...
Describe the post return format .
30,772
public static function get_forum_discussion_posts_parameters ( ) { return new external_function_parameters ( array ( 'discussionid' => new external_value ( PARAM_INT , 'discussion ID' , VALUE_REQUIRED ) , 'sortby' => new external_value ( PARAM_ALPHA , 'sort by this element: id, created or modified' , VALUE_DEFAULT , 'c...
Describes the parameters for get_forum_discussion_posts .
30,773
public static function get_forum_discussion_posts_returns ( ) { return new external_single_structure ( array ( 'posts' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Post id' ) , 'discussion' => new external_value ( PARAM_INT , 'Discussion id' ) , ...
Describes the get_forum_discussion_posts return value .
30,774
public static function get_forum_discussions_paginated_parameters ( ) { return new external_function_parameters ( array ( 'forumid' => new external_value ( PARAM_INT , 'forum instance id' , VALUE_REQUIRED ) , 'sortby' => new external_value ( PARAM_ALPHA , 'sort by this element: id, timemodified, timestart or timeend' ,...
Describes the parameters for get_forum_discussions_paginated .
30,775
public static function get_forum_discussions_paginated_returns ( ) { return new external_single_structure ( array ( 'discussions' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Post id' ) , 'name' => new external_value ( PARAM_TEXT , 'Discussion na...
Describes the get_forum_discussions_paginated return value .
30,776
public static function get_forum_discussions_parameters ( ) { return new external_function_parameters ( array ( 'forumid' => new external_value ( PARAM_INT , 'forum instance id' , VALUE_REQUIRED ) , 'sortorder' => new external_value ( PARAM_INT , 'sort by this element: numreplies, , created or timemodified' , VALUE_DEF...
Describes the parameters for get_forum_discussions .
30,777
public static function view_forum_discussion ( $ discussionid ) { global $ DB , $ CFG , $ USER ; require_once ( $ CFG -> dirroot . "/mod/forum/lib.php" ) ; $ params = self :: validate_parameters ( self :: view_forum_discussion_parameters ( ) , array ( 'discussionid' => $ discussionid ) ) ; $ warnings = array ( ) ; $ di...
Trigger the discussion viewed event .
30,778
public static function toggle_favourite_state ( $ discussionid , $ targetstate ) { global $ DB , $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: toggle_favourite_state_parameters ( ) , [ 'discussionid' => $ discussionid , 'targetstate' => $ targetstate ] ) ; $ vaultfactory = mod_forum \ local \ conta...
Toggle the favouriting value for the discussion provided
30,779
public static function get_forum_access_information ( $ forumid ) { global $ DB ; $ params = self :: validate_parameters ( self :: get_forum_access_information_parameters ( ) , array ( 'forumid' => $ forumid ) ) ; $ forum = $ DB -> get_record ( 'forum' , array ( 'id' => $ params [ 'forumid' ] ) , '*' , MUST_EXIST ) ; $...
Return access information for a given forum .
30,780
public static function get_forum_access_information_returns ( ) { $ structure = array ( 'warnings' => new external_warnings ( ) ) ; $ capabilities = load_capability_def ( 'mod_forum' ) ; foreach ( $ capabilities as $ capname => $ capdata ) { $ field = 'can' . str_replace ( 'mod/forum:' , '' , $ capname ) ; $ structure ...
Describes the get_forum_access_information return value .
30,781
public static function set_subscription_state ( $ forumid , $ discussionid , $ targetstate ) { global $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: set_subscription_state_parameters ( ) , [ 'forumid' => $ forumid , 'discussionid' => $ discussionid , 'targetstate' => $ targetstate ] ) ; $ vaultfacto...
Set the subscription state .
30,782
public static function set_lock_state ( $ forumid , $ discussionid , $ targetstate ) { global $ DB , $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: set_lock_state_parameters ( ) , [ 'forumid' => $ forumid , 'discussionid' => $ discussionid , 'targetstate' => $ targetstate ] ) ; $ vaultfactory = mod_...
Set the lock state .
30,783
public static function set_pin_state ( $ discussionid , $ targetstate ) { global $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: set_pin_state_parameters ( ) , [ 'discussionid' => $ discussionid , 'targetstate' => $ targetstate , ] ) ; $ vaultfactory = mod_forum \ local \ container :: get_vault_facto...
Set the pin state .
30,784
protected final function definition ( ) { $ form = $ this -> _form ; $ store = $ this -> _customdata [ 'store' ] ; $ plugin = $ this -> _customdata [ 'plugin' ] ; $ locks = $ this -> _customdata [ 'locks' ] ; $ form -> addElement ( 'hidden' , 'plugin' , $ plugin ) ; $ form -> setType ( 'plugin' , PARAM_PLUGIN ) ; $ for...
The definition of the add instance form
30,785
public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( ! array_key_exists ( 'name' , $ errors ) ) { if ( ! preg_match ( '#^[a-zA-Z0-9\-_ ]+$#' , $ data [ 'name' ] ) ) { $ errors [ 'name' ] = get_string ( 'storenameinvalid' , 'cache' ) ; } else if ( empty ( $ this -...
Validates the add instance form data
30,786
public function set_data ( $ data ) { if ( ! isset ( $ data [ 'sharing' ] ) ) { $ data [ 'sharing' ] = cache_administration_helper :: get_definition_sharing_options ( cache_definition :: SHARING_DEFAULT ) ; } parent :: set_data ( $ data ) ; }
Sets the data for this form .
30,787
public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( count ( $ errors ) === 0 && ! isset ( $ data [ 'sharing' ] ) ) { $ errors [ 'sharing' ] = get_string ( 'sharingrequired' , 'cache' ) ; } return $ errors ; }
Validates this form
30,788
final public function definition ( ) { $ plugin = $ this -> _customdata [ 'lock' ] ; $ this -> _form -> addElement ( 'hidden' , 'action' , 'newlockinstance' ) ; $ this -> _form -> setType ( 'action' , PARAM_ALPHANUMEXT ) ; $ this -> _form -> addElement ( 'hidden' , 'lock' , $ plugin ) ; $ this -> _form -> setType ( 'lo...
Defines this form .
30,789
final public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( ! isset ( $ errors [ 'name' ] ) ) { $ config = cache_config :: instance ( ) ; if ( in_array ( $ data [ 'name' ] , array_keys ( $ config -> get_locks ( ) ) ) ) { $ errors [ 'name' ] = get_string ( 'locknam...
Validates this form .
30,790
public function get_readable_fullname ( ) { global $ CFG ; $ fpath = array ( ) ; for ( $ parent = $ this ; $ parent && $ parent -> get_parent ( ) ; $ parent = $ parent -> get_parent ( ) ) { array_unshift ( $ fpath , $ parent -> get_visible_name ( ) ) ; } if ( $ this -> lf -> get_component ( ) == 'user' && $ this -> lf ...
Returns the localised human - readable name of the file together with virtual path
30,791
public function is_empty_area ( ) { if ( $ this -> lf -> get_filepath ( ) === '/' and $ this -> lf -> get_filename ( ) === '.' ) { $ fs = get_file_storage ( ) ; return $ fs -> is_area_empty ( $ this -> lf -> get_contextid ( ) , $ this -> lf -> get_component ( ) , $ this -> lf -> get_filearea ( ) , $ this -> lf -> get_i...
Whether or not this is an empty area
30,792
public function get_parent ( ) { if ( $ this -> lf -> get_filepath ( ) === '/' and $ this -> lf -> is_directory ( ) ) { if ( $ this -> areaonly ) { return null ; } else if ( $ this -> itemidused ) { return $ this -> browser -> get_file_info ( $ this -> context , $ this -> lf -> get_component ( ) , $ this -> lf -> get_f...
Returns parent file_info instance
30,793
public function create_directory ( $ newdirname , $ userid = NULL ) { if ( ! $ this -> is_writable ( ) or ! $ this -> lf -> is_directory ( ) ) { return null ; } $ newdirname = clean_param ( $ newdirname , PARAM_FILE ) ; if ( $ newdirname === '' ) { return null ; } $ filepath = $ this -> lf -> get_filepath ( ) . '/' . $...
Create new directory may throw exception - make sure params are valid .
30,794
public function create_file_from_string ( $ newfilename , $ content , $ userid = NULL ) { if ( ! $ this -> is_writable ( ) or ! $ this -> lf -> is_directory ( ) ) { return null ; } $ newfilename = clean_param ( $ newfilename , PARAM_FILE ) ; if ( $ newfilename === '' ) { return null ; } $ fs = get_file_storage ( ) ; $ ...
Create new file from string - make sure params are valid .
30,795
public function delete ( ) { if ( ! $ this -> is_writable ( ) ) { return false ; } if ( $ this -> is_directory ( ) ) { $ filepath = $ this -> lf -> get_filepath ( ) ; $ fs = get_file_storage ( ) ; $ storedfiles = $ fs -> get_area_files ( $ this -> context -> id , $ this -> get_component ( ) , $ this -> lf -> get_filear...
Delete file make sure file is deletable first .
30,796
protected function get_legacy_eventdata ( ) { $ eventdata = new \ stdClass ( ) ; $ eventdata -> modulename = $ this -> other [ 'modulename' ] ; $ eventdata -> cmid = $ this -> objectid ; $ eventdata -> courseid = $ this -> courseid ; $ eventdata -> userid = $ this -> userid ; return $ eventdata ; }
Legacy event data .
30,797
public function execute ( ) { global $ DB ; $ started = time ( ) ; $ backupid = $ this -> get_custom_data ( ) -> backupid ; $ backuprecordid = $ DB -> get_field ( 'backup_controllers' , 'id' , array ( 'backupid' => $ backupid ) , MUST_EXIST ) ; mtrace ( 'Processing asynchronous backup for backup: ' . $ backupid ) ; $ b...
Run the adhoc task and preform the backup .
30,798
public function idArithmetic ( $ action , array $ options = array ( ) ) { return $ this -> _idArithmetic ( $ this -> id , $ action , array_merge ( array ( 'count' => 1 ) , $ options ) ) ; }
Performs MIME ID arithmetic .
30,799
public function isChild ( $ id ) { $ base = ( substr ( $ this -> id , - 2 ) == '.0' ) ? substr ( $ this -> id , 0 , - 1 ) : rtrim ( $ this -> id , '.' ) . '.' ; return ( ( ( $ base == 0 ) && ( $ id != 0 ) ) || ( strpos ( strval ( $ id ) , strval ( $ base ) ) === 0 ) ) ; }
Determines if a given MIME ID lives underneath a base ID .