Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
bc4cc476
Commit
bc4cc476
authored
May 09, 2011
by
Francois Marier
Committed by
Gerrit Code Review
May 09, 2011
Browse files
Merge "Replace links with forms for enabling/disabling plugins (bug #714967)"
parents
bb0f7101
d4be7807
Changes
5
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/extensions/pluginconfig.php
View file @
bc4cc476
...
...
@@ -40,11 +40,6 @@ define('SECTION_PLUGINNAME', $pluginname);
define
(
'SECTION_PAGE'
,
'pluginconfig'
);
safe_require
(
$plugintype
,
$pluginname
);
if
(
$sesskey
=
param_alphanum
(
'sesskey'
,
''
))
{
if
(
$sesskey
!=
$USER
->
get
(
'sesskey'
))
{
throw
new
UserException
(
'Invalid sesskey'
);
}
}
$enable
=
param_integer
(
'enable'
,
0
);
$disable
=
param_integer
(
'disable'
,
0
);
...
...
@@ -53,23 +48,8 @@ if ($disable && !call_static_method(generate_class_name($plugintype, $pluginname
}
if
(
$enable
||
$disable
)
{
if
(
$plugintype
==
'blocktype'
)
{
if
(
strpos
(
$pluginname
,
'/'
)
!==
false
)
{
list
(
$artefact
,
$pluginname
)
=
split
(
'/'
,
$pluginname
);
// Don't enable blocktypes unless the artefact plugin that provides them is also enabled
if
(
$enable
&&
!
get_field
(
'artefact_installed'
,
'active'
,
'name'
,
$artefact
))
{
$SESSION
->
add_error_msg
(
get_string
(
'pluginnotenabled'
,
'mahara'
,
$artefact
));
redirect
(
'/admin/extensions/plugins.php'
);
}
}
}
else
if
(
$plugintype
==
'artefact'
&&
$disable
)
{
// Disable all the artefact's blocktypes too
set_field
(
'blocktype_installed'
,
'active'
,
0
,
'artefactplugin'
,
$pluginname
);
}
set_field
(
$plugintype
.
'_installed'
,
'active'
,
$enable
,
'name'
,
$pluginname
);
$SESSION
->
add_ok_msg
(
get_string
(
'plugin'
.
((
$enable
)
?
'enabled'
:
'disabled'
)));
redirect
(
'/admin/extensions/plugins.php'
);
require_once
(
get_config
(
'libroot'
)
.
'upgrade.php'
);
activate_plugin_form
(
$plugintype
,
get_record
(
$plugintype
.
'_installed'
,
'name'
,
$pluginname
));
}
if
(
$plugintype
==
'artefact'
)
{
...
...
htdocs/admin/extensions/plugins.php
View file @
bc4cc476
...
...
@@ -66,6 +66,9 @@ foreach (array_keys($plugins) as $plugin) {
'active'
=>
$i
->
active
,
'disableable'
=>
call_static_method
(
generate_class_name
(
$plugin
,
$key
),
'can_be_disabled'
),
);
if
(
$plugins
[
$plugin
][
'installed'
][
$key
][
'disableable'
])
{
$plugins
[
$plugin
][
'installed'
][
$key
][
'activateform'
]
=
activate_plugin_form
(
$plugin
,
$i
);
}
if
(
$plugin
==
'artefact'
)
{
$plugins
[
$plugin
][
'installed'
][
$key
][
'types'
]
=
array
();
safe_require
(
'artefact'
,
$key
);
...
...
htdocs/lib/upgrade.php
View file @
bc4cc476
...
...
@@ -1072,3 +1072,47 @@ function set_antispam_defaults() {
set_config
(
'spamhaus'
,
0
);
set_config
(
'surbl'
,
0
);
}
function
activate_plugin_form
(
$plugintype
,
$plugin
)
{
return
pieform
(
array
(
'name'
=>
'activate_'
.
$plugintype
.
'_'
.
$plugin
->
name
,
'renderer'
=>
'oneline'
,
'elementclasses'
=>
false
,
'successcallback'
=>
'activate_plugin_submit'
,
'class'
=>
'oneline inline'
,
'jsform'
=>
false
,
'action'
=>
get_config
(
'wwwroot'
)
.
'admin/extensions/pluginconfig.php'
,
'elements'
=>
array
(
'plugintype'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$plugintype
),
'pluginname'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$plugin
->
name
),
'disable'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$plugin
->
active
),
'enable'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
1
-
$plugin
->
active
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'class'
=>
'linkbtn'
,
'value'
=>
$plugin
->
active
?
get_string
(
'hide'
)
:
get_string
(
'show'
)
),
),
));
}
function
activate_plugin_submit
(
Pieform
$form
,
$values
)
{
global
$SESSION
;
if
(
$values
[
'plugintype'
]
==
'blocktype'
)
{
if
(
strpos
(
$values
[
'pluginname'
],
'/'
)
!==
false
)
{
list
(
$artefact
,
$values
[
'pluginname'
])
=
split
(
'/'
,
$values
[
'pluginname'
]);
// Don't enable blocktypes unless the artefact plugin that provides them is also enabled
if
(
$values
[
'enable'
]
&&
!
get_field
(
'artefact_installed'
,
'active'
,
'name'
,
$artefact
))
{
$SESSION
->
add_error_msg
(
get_string
(
'pluginnotenabled'
,
'mahara'
,
$artefact
));
redirect
(
'/admin/extensions/plugins.php'
);
}
}
}
else
if
(
$values
[
'plugintype'
]
==
'artefact'
&&
$values
[
'disable'
])
{
// Disable all the artefact's blocktypes too
set_field
(
'blocktype_installed'
,
'active'
,
0
,
'artefactplugin'
,
$values
[
'pluginname'
]);
}
set_field
(
$values
[
'plugintype'
]
.
'_installed'
,
'active'
,
$values
[
'enable'
],
'name'
,
$values
[
'pluginname'
]);
$SESSION
->
add_ok_msg
(
get_string
(
'plugin'
.
((
$values
[
'enable'
])
?
'enabled'
:
'disabled'
)));
redirect
(
'/admin/extensions/plugins.php'
);
}
htdocs/theme/raw/static/style/style.css
View file @
bc4cc476
...
...
@@ -112,6 +112,7 @@ p {
.nowrap
{
white-space
:
nowrap
;
}
form
.oneline.inline
div
,
.inline
{
display
:
inline
;
}
...
...
@@ -537,6 +538,9 @@ span.btn a.icon, a span.icon {
border
:
0
;
cursor
:
pointer
;
color
:
#0000ee
;
background
:
none
;
padding
:
0
;
font-size
:
100%
;
}
/* bolding some buttons */
#editgroup
#editgroup_submit
,
...
...
htdocs/theme/raw/templates/admin/extensions/plugins.tpl
View file @
bc4cc476
...
...
@@ -14,11 +14,7 @@
{
foreach
from
=
$installed
key
=
'plugin'
item
=
'data'
}
<li
id=
"
{
$plugintype
}
.
{
$plugin
}
"
>
{
$plugin
}
{
if
$data.disableable
}
{
if
$data.active
}
[
<a
href=
"pluginconfig.php?plugintype=
{
$plugintype
}
&pluginname=
{
$plugin
}
&disable=1&sesskey=
{
$SESSKEY
}
"
>
{
str
tag
=
'hide'
}
</a>
{
else
}
[
<a
href=
"pluginconfig.php?plugintype=
{
$plugintype
}
&pluginname=
{
$plugin
}
&enable=1&sesskey=
{
$SESSKEY
}
"
>
{
str
tag
=
'show'
}
</a>
{/
if
}
[
{
$data.activateform
|
safe
}
{/
if
}
{
if
$data.config
}
{
if
!
$data.disableable
}
[
{
else
}
|
{/
if
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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