Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

(no description)

File Size: 222 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

question_edit_contexts:: (13 methods):
  __construct()
  all()
  lowest()
  having_cap()
  having_one_cap()
  having_one_edit_tab_cap()
  having_add_and_use()
  have_cap()
  have_one_cap()
  have_one_edit_tab_cap()
  require_cap()
  require_one_cap()
  require_one_edit_tab_cap()


Class: question_edit_contexts  - X-Ref

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

__construct(\context $thiscontext)   X-Ref
Constructor

param: \context $thiscontext the current context.

all()   X-Ref
Get all the contexts.

return: \context[] all parent contexts

lowest()   X-Ref
Get the lowest context.

return: \context lowest context which must be either the module or course context

having_cap($cap)   X-Ref
Get the contexts having cap.

return: \context[] parent contexts having capability, zero based index
param: string $cap capability

having_one_cap($caps)   X-Ref
Get the contexts having at least one cap.

return: \context[] parent contexts having at least one of $caps, zero based index
param: array $caps capabilities

having_one_edit_tab_cap($tabname)   X-Ref
Context having at least one cap.

return: \context[] parent contexts having at least one of $caps, zero based index
param: string $tabname edit tab name

having_add_and_use()   X-Ref
Contexts for adding question and also using it.

return: \context[] those contexts where a user can add a question and then use it.

have_cap($cap)   X-Ref
Has at least one parent context got the cap $cap?

return: boolean
param: string $cap capability

have_one_cap($caps)   X-Ref
Has at least one parent context got one of the caps $caps?

return: boolean
param: array $caps capability

have_one_edit_tab_cap($tabname)   X-Ref
Has at least one parent context got one of the caps for actions on $tabname

return: boolean
param: string $tabname edit tab name

require_cap($cap)   X-Ref
Throw error if at least one parent context hasn't got the cap $cap

param: string $cap capability

require_one_cap($caps)   X-Ref
Throw error if at least one parent context hasn't got one of the caps $caps

param: array $caps capabilities

require_one_edit_tab_cap($tabname)   X-Ref
Throw error if at least one parent context hasn't got one of the caps $caps

param: string $tabname edit tab name