Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
question_edit_contexts Class Reference

Tracks all the contexts related to the one where we are currently editing questions, and provides helper methods to check permissions. More...

Public Member Functions

 __construct (context $thiscontext)
 Constructor. More...
 
 all ()
 
 have_cap ($cap)
 Has at least one parent context got the cap $cap? More...
 
 have_one_cap ($caps)
 Has at least one parent context got one of the caps $caps? More...
 
 have_one_edit_tab_cap ($tabname)
 Has at least one parent context got one of the caps for actions on $tabname. More...
 
 having_add_and_use ()
 
 having_cap ($cap)
 
 having_one_cap ($caps)
 
 having_one_edit_tab_cap ($tabname)
 
 lowest ()
 
 require_cap ($cap)
 Throw error if at least one parent context hasn't got the cap $cap. More...
 
 require_one_cap ($caps)
 Throw error if at least one parent context hasn't got one of the caps $caps. More...
 
 require_one_edit_tab_cap ($tabname)
 Throw error if at least one parent context hasn't got one of the caps $caps. More...
 

Static Public Attributes

static $caps
 

Protected Attributes

 $allcontexts
 

Detailed Description

Tracks all the contexts related to the one where we are currently editing questions, and provides helper methods to check permissions.

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

Constructor & Destructor Documentation

◆ __construct()

question_edit_contexts::__construct ( context  $thiscontext)

Constructor.

Parameters
contextthe current context.

Member Function Documentation

◆ all()

question_edit_contexts::all ( )
Return values
context[]all parent contexts

◆ have_cap()

question_edit_contexts::have_cap (   $cap)

Has at least one parent context got the cap $cap?

Parameters
string$capcapability
Return values
boolean

◆ have_one_cap()

question_edit_contexts::have_one_cap (   $caps)

Has at least one parent context got one of the caps $caps?

Parameters
array$capscapability
Return values
boolean

◆ have_one_edit_tab_cap()

question_edit_contexts::have_one_edit_tab_cap (   $tabname)

Has at least one parent context got one of the caps for actions on $tabname.

Parameters
string$tabnameedit tab name
Return values
boolean

◆ having_add_and_use()

question_edit_contexts::having_add_and_use ( )
Return values
context[]those contexts where a user can add a question and then use it.

◆ having_cap()

question_edit_contexts::having_cap (   $cap)
Parameters
string$capcapability
Return values
context[]parent contexts having capability, zero based index

◆ having_one_cap()

question_edit_contexts::having_one_cap (   $caps)
Parameters
array$capscapabilities
Return values
context[]parent contexts having at least one of $caps, zero based index

◆ having_one_edit_tab_cap()

question_edit_contexts::having_one_edit_tab_cap (   $tabname)
Parameters
string$tabnameedit tab name
Return values
context[]parent contexts having at least one of $caps, zero based index

◆ lowest()

question_edit_contexts::lowest ( )
Return values
contextlowest context which must be either the module or course context

◆ require_cap()

question_edit_contexts::require_cap (   $cap)

Throw error if at least one parent context hasn't got the cap $cap.

Parameters
string$capcapability

◆ require_one_cap()

question_edit_contexts::require_one_cap (   $caps)

Throw error if at least one parent context hasn't got one of the caps $caps.

Parameters
array$capscapabilities

◆ require_one_edit_tab_cap()

question_edit_contexts::require_one_edit_tab_cap (   $tabname)

Throw error if at least one parent context hasn't got one of the caps $caps.

Parameters
string$tabnameedit tab name

Member Data Documentation

◆ $caps

question_edit_contexts::$caps
static
Initial value:
= array(
'editq' => array('moodle/question:add',
'moodle/question:editmine',
'moodle/question:editall',
'moodle/question:viewmine',
'moodle/question:viewall',
'moodle/question:usemine',
'moodle/question:useall',
'moodle/question:movemine',
'moodle/question:moveall'),
'questions'=>array('moodle/question:add',
'moodle/question:editmine',
'moodle/question:editall',
'moodle/question:viewmine',
'moodle/question:viewall',
'moodle/question:movemine',
'moodle/question:moveall'),
'categories'=>array('moodle/question:managecategory'),
'import'=>array('moodle/question:add'),
'export'=>array('moodle/question:viewall', 'moodle/question:viewmine'))

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