Moodle  2.2.1
http://www.collinsharper.com
context Class Reference
Inheritance diagram for context:

Public Member Functions

 __set ($name, $value)
 __get ($name)
 __isset ($name)
 __unset ($name)
 update_moved (context $newparent)
 reset_paths ($rebuild=true)
 delete_content ()
 delete ()
 get_context_name ($withprefix=true, $short=false)
 get_url ()
 get_capabilities ()
 get_child_contexts ()
 get_parent_contexts ($includeself=false)
 get_parent_context_ids ($includeself=false)
 get_parent_context ()
 get_course_context ($strict=true)
 reload_if_dirty ()
 mark_dirty ()

Static Public Member Functions

static instance_by_id ($id, $strictness=MUST_EXIST)

Protected Member Functions

 __construct (stdClass $record)

Static Protected Member Functions

static reset_caches ()
static cache_add (context $context)
static cache_remove (context $context)
static cache_get ($contextlevel, $instance)
static cache_get_by_id ($id)
static preload_from_record (stdClass $rec)
static create_instance_from_record (stdClass $record)
static merge_context_temp_table ()
static insert_context_record ($contextlevel, $instanceid, $parentpath)
static get_cleanup_sql ()
static build_paths ($force)
static create_level_instances ()

Protected Attributes

 $_id
 $_contextlevel
 $_instanceid
 $_path
 $_depth

Static Protected Attributes

static $cache_count = 0
static $cache_preloaded = array()
static $systemcontext = null

Detailed Description

Definition at line 4490 of file accesslib.php.


Constructor & Destructor Documentation

__construct ( stdClass $  record) [protected]

Constructor is protected so that devs are forced to use context_xxx::instance() or context::instance_by_id().

Parameters:
stdClass$record

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, and context_system.

Definition at line 4706 of file accesslib.php.


Member Function Documentation

__get ( name)

Magic method getter, redirects to read only values.

Parameters:
string$name
Returns:
mixed

Definition at line 4658 of file accesslib.php.

Here is the call graph for this function:

__isset ( name)

Full support for isset on our magic read only properties.

Parameters:
$name
Returns:
bool

Definition at line 4677 of file accesslib.php.

__set ( name,
value 
)

Magic setter method, we do not want anybody to modify properties from the outside

Parameters:
string$name
mixed

Definition at line 4649 of file accesslib.php.

Here is the call graph for this function:

__unset ( name)

ALl properties are read only, sorry.

Parameters:
string$name

Definition at line 4694 of file accesslib.php.

Here is the call graph for this function:

static build_paths ( force) [static, protected]

Rebuild context paths and depths at context level.

Parameters:
$force
Returns:
void

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, and context_system.

Definition at line 5130 of file accesslib.php.

Here is the caller graph for this function:

static cache_add ( context context) [static, protected]

Adds a context to the cache. If the cache is full, discards a batch of older entries.

Parameters:
context$contextNew context to add
Returns:
void

Definition at line 4537 of file accesslib.php.

Here is the caller graph for this function:

static cache_get ( contextlevel,
instance 
) [static, protected]

Gets a context from the cache.

Parameters:
int$contextlevelContext level
int$instanceInstance ID
Returns:
context|bool Context or false if not in cache

Definition at line 4596 of file accesslib.php.

Here is the caller graph for this function:

static cache_get_by_id ( id) [static, protected]

Gets a context from the cache based on its id.

Parameters:
int$idContext ID
Returns:
context|bool Context or false if not in cache

Definition at line 4610 of file accesslib.php.

Here is the caller graph for this function:

static cache_remove ( context context) [static, protected]

Removes a context from the cache.

Parameters:
context$contextContext object to remove
Returns:
void

Definition at line 4573 of file accesslib.php.

Here is the caller graph for this function:

static create_instance_from_record ( stdClass $  record) [static, protected]

This function is also used to work around 'protected' keyword problems in context_helper.

Parameters:
stdClass$record
Returns:
context instance

Definition at line 4720 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static create_level_instances ( ) [static, protected]

Create missing context instances at given level

Returns:
void

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, and context_system.

Definition at line 5140 of file accesslib.php.

Here is the caller graph for this function:

delete ( )

Delete the context content and the context record itself

Definition at line 4927 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Delete all data linked to content, do not delete the context record itself

Definition at line 4894 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_capabilities ( ) [abstract]

Returns array of relevant context capability records.

Returns:
array

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, context_system, and context_helper.

Here is the caller graph for this function:

Recursive function which, given a context, find all its children context ids.

For course category contexts it will return immediate children and all subcategory contexts. It will NOT recurse into courses or subcategories categories. If you want to do that, call it on the returned courses/categories.

When called for a course context, it will return the modules and blocks displayed in the course page and blocks displayed on the module pages.

If called on a user/course/module context it _will_ populate the cache with the appropriate contexts ;-)

Returns:
array Array of child records

Reimplemented in context_block, context_coursecat, and context_system.

Definition at line 5022 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_cleanup_sql ( ) [static, protected]

Returns sql necessary for purging of stale context instances.

Returns:
string cleanup SQL

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, and context_system.

Definition at line 5119 of file accesslib.php.

Here is the caller graph for this function:

get_context_name ( withprefix = true,
short = false 
)

Returns human readable context identifier.

Parameters:
boolean$withprefixwhether to prefix the name of the context with the type of context, e.g. User, Course, Forum, etc.
boolean$shortwhether to use the short name of the thing. Only applies to course contexts
Returns:
string the human readable context name.

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, and context_system.

Definition at line 4988 of file accesslib.php.

Here is the caller graph for this function:

get_course_context ( strict = true)

Is this context part of any course? If yes return course context.

Parameters:
bool$stricttrue means throw exception if not found, false means return false if not found
Returns:
course_context context of the enclosing course, null if not found or exception

Reimplemented in context_block, context_module, and context_course.

Definition at line 5105 of file accesslib.php.

Here is the caller graph for this function:

Returns parent context

Returns:
context

Definition at line 5086 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_parent_context_ids ( includeself = false)

Returns parent contexts of this context in reversed order, i.e. parent first, then grand parent, etc.

Parameters:
bool$includeselftre means include self too
Returns:
array of context ids

Definition at line 5067 of file accesslib.php.

Here is the caller graph for this function:

get_parent_contexts ( includeself = false)

Returns parent contexts of this context in reversed order, i.e. parent first, then grand parent, etc.

Parameters:
bool$includeselftre means include self too
Returns:
array of context instances

Definition at line 5046 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_url ( ) [abstract]

Returns the most relevant URL for this context.

Returns:
moodle_url

Reimplemented in context_block, context_module, context_course, context_coursecat, context_user, context_system, and context_helper.

Here is the caller graph for this function:

static insert_context_record ( contextlevel,
instanceid,
parentpath 
) [static, protected]

Utility method for context creation

Parameters:
int$contextlevel
int$instanceid
string$parentpath
Returns:
stdClass context record

Definition at line 4958 of file accesslib.php.

Here is the caller graph for this function:

static instance_by_id ( id,
strictness = MUST_EXIST 
) [static]

Get a context instance as an object, from a given context id.

Parameters:
int$idcontext id
int$strictnessIGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record found
Returns:
context|bool the context object or false if not found

Definition at line 4791 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Mark a context as dirty (with timestamp) so as to force reloading of the context.

Definition at line 5181 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static merge_context_temp_table ( ) [static, protected]

Copy prepared new contexts from temp table to context table, we do this in db specific way for perf reasons only.

Definition at line 4738 of file accesslib.php.

Here is the caller graph for this function:

static preload_from_record ( stdClass $  rec) [static, protected]

Preloads context information from db record and strips the cached info.

Parameters:
stdClass$rec
Returns:
void (modifies $rec)

Reimplemented in context_helper.

Definition at line 4624 of file accesslib.php.

Here is the call graph for this function:

Reset all cached permissions and definitions if the necessary.

Returns:
void

Definition at line 5148 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static reset_caches ( ) [static, protected]

Resets the cache to remove all data.

Reimplemented in context_helper.

Definition at line 4520 of file accesslib.php.

Here is the caller graph for this function:

reset_paths ( rebuild = true)

Remove all context path info and optionally rebuild it.

Parameters:
bool$rebuild
Returns:
void

Definition at line 4869 of file accesslib.php.

Here is the call graph for this function:

update_moved ( context newparent)

Update context info after moving context in the tree structure.

Parameters:
context$newparent
Returns:
void

Definition at line 4824 of file accesslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

$_contextlevel [protected]

Definition at line 4502 of file accesslib.php.

$_depth [protected]

Definition at line 4505 of file accesslib.php.

$_id [protected]

Definition at line 4501 of file accesslib.php.

$_instanceid [protected]

Definition at line 4503 of file accesslib.php.

$_path [protected]

Definition at line 4504 of file accesslib.php.

$cache_count = 0 [static, protected]

Definition at line 4511 of file accesslib.php.

$cache_preloaded = array() [static, protected]

Definition at line 4513 of file accesslib.php.

$systemcontext = null [static, protected]

Definition at line 4514 of file accesslib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations