Gitlab CSE Unil
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
moodle-assignfeedback_editpdfplus
Commits
e9ff33d2
Commit
e9ff33d2
authored
Apr 20, 2018
by
M. Chardon
Browse files
optimisation recherche de barre d'outil à exporter
parent
f455eee4
Changes
2
Hide whitespace changes
Inline
Side-by-side
classes/admin_editor.php
View file @
e9ff33d2
...
...
@@ -242,6 +242,18 @@ class admin_editor {
return
$tools
;
}
/**
* Get all diferent contexts id
* @global type $DB
* @param Integer $axisid axis' id
* @return array<\assignfeedback_editpdfplus\tool> the toolbar, order by order_tool
*/
public
static
function
get_all_different_contexts
()
{
global
$DB
;
$records
=
$DB
->
get_records_sql
(
"SELECT DISTINCT(contextid) FROM `mdl_assignfeedback_editpp_axis`"
);
return
$records
;
}
/**
* Update a tool
* @global type $DB
...
...
locallib_admin.php
View file @
e9ff33d2
...
...
@@ -36,6 +36,7 @@ class assign_feedback_editpdfplus_admin {
/** @var stdClass $course current course */
private
$course
=
null
;
/** @var stdClass $context current context */
private
$context
=
null
;
...
...
@@ -200,7 +201,7 @@ class assign_feedback_editpdfplus_admin {
$html
.
=
$renderer
->
render_assignfeedback_editpdfplus_widget_admin_toolform
(
$data
);
return
$html
;
}
/**
* Create a admin widget for rendering the editor.
*
...
...
@@ -216,18 +217,28 @@ class assign_feedback_editpdfplus_admin {
$typetools
=
page_editor
::
get_typetools
(
null
);
$axis
=
page_editor
::
get_axis
(
array
(
$this
->
context
->
id
));
$toolbars
=
$this
->
prepareToolbar
(
$axis
,
$tools
);
// get all accessibled toolbars
$courses
=
get_courses
();
$contextListToCheck
=
array
();
foreach
(
$courses
as
$course
)
{
$contextid
=
context_course
::
instance
(
$course
->
id
);
$coursecontextsTmp
=
array_filter
(
explode
(
'/'
,
$contextid
->
path
),
'strlen'
);
foreach
(
$coursecontextsTmp
as
$value
)
{
if
(
$value
!=
$this
->
context
->
id
&&
!
in_array
(
$value
,
$contextListToCheck
))
{
$contextListToCheck
[]
=
$value
;
}
$contextsIdAxes
=
admin_editor
::
get_all_different_contexts
();
foreach
(
$contextsIdAxes
as
$contextTmp
)
{
$contextObj
=
context
::
instance_by_id
(
$contextTmp
->
contextid
);
//$contextObj = context_system::instance_by_id($contextTmp->contextid, IGNORE_MISSING);
if
(
$contextObj
/* && has_capability('assignfeedback/editpdfplus:use', $contextObj) */
&&
has_capability
(
'assignfeedback/editpdfplus:managetools'
,
$contextObj
,
null
,
false
)
&&
$contextTmp
->
contextid
!=
$this
->
context
->
id
)
{
$contextListToCheck
[]
=
$contextTmp
->
contextid
;
}
}
/* $courses = get_courses();
$contextListToCheck = array();
foreach ($courses as $course) {
$contextid = context_course::instance($course->id);
$coursecontextsTmp = array_filter(explode('/', $contextid->path), 'strlen');
foreach ($coursecontextsTmp as $value) {
if ($value != $this->context->id && !in_array($value, $contextListToCheck)) {
$contextListToCheck[] = $value;
}
}
} */
$axisDispo
=
array
();
$toolDispo
=
page_editor
::
get_tools
(
$contextListToCheck
);
foreach
(
$contextListToCheck
as
$value
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment