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
mahara
mahara
Commits
cafb3bbe
Commit
cafb3bbe
authored
Oct 25, 2006
by
Penny Leach
Browse files
upgrade_plugin now handles event subscriptions
parent
007f1d41
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/mahara.php
View file @
cafb3bbe
...
@@ -229,20 +229,19 @@ function upgrade_plugin($upgrade) {
...
@@ -229,20 +229,19 @@ function upgrade_plugin($upgrade) {
if
(
$crons
=
call_static_method
(
$pcname
,
'get_cron'
))
{
if
(
$crons
=
call_static_method
(
$pcname
,
'get_cron'
))
{
foreach
(
$crons
as
$cron
)
{
foreach
(
$crons
as
$cron
)
{
$cron
=
(
object
)
$cron
;
$cron
=
(
object
)
$cron
;
// @todo maybe these steps should break stuff rather than just complaining.
if
(
empty
(
$cron
->
callfunction
))
{
if
(
empty
(
$cron
->
function
))
{
$db
->
RollbackTrans
();
log_warn
(
"cron for
$pcname
didn't supply function name"
);
throw
new
InstallationException
(
"cron for
$pcname
didn't supply function name"
);
continue
;
}
}
if
(
!
is_callable
(
array
(
$pcname
,
$cron
->
function
)))
{
if
(
!
is_callable
(
array
(
$pcname
,
$cron
->
call
function
)))
{
log_warn
(
"cron
$cron->function
for
$pcname
existed but wasn't callable"
);
$db
->
RollbackTrans
(
);
continue
;
throw
new
InstallationException
(
"cron
$cron->callfunction
for
$pcname
supplied but wasn't callable"
)
;
}
}
$new
=
false
;
$new
=
false
;
if
(
!
empty
(
$upgrade
->
install
))
{
if
(
!
empty
(
$upgrade
->
install
))
{
$new
=
true
;
$new
=
true
;
}
}
else
if
(
!
record_exists
(
'cron_'
.
$plugintype
,
'plugin'
,
$pluginname
,
'function'
,
$cron
->
function
))
{
else
if
(
!
record_exists
(
'cron_'
.
$plugintype
,
'plugin'
,
$pluginname
,
'function'
,
$cron
->
call
function
))
{
$new
=
true
;
$new
=
true
;
}
}
$cron
->
plugin
=
$pluginname
;
$cron
->
plugin
=
$pluginname
;
...
@@ -255,10 +254,37 @@ function upgrade_plugin($upgrade) {
...
@@ -255,10 +254,37 @@ function upgrade_plugin($upgrade) {
}
}
}
}
$events
=
call_static_method
(
$pcname
,
'get_event_subscriptions'
);
if
(
$events
=
call_static_method
(
$pcname
,
'get_event_subscriptions'
))
{
// @todo save event subscriptions
foreach
(
$events
as
$event
)
{
$event
=
(
object
)
$event
;
call_static_method
(
$pcname
,
'postinst'
);
if
(
!
record_exists
(
'event'
,
'name'
,
$event
->
event
))
{
$db
->
RollbackTrans
();
throw
new
InstallationException
(
"event
$event->event
for
$pcname
doesn't exist!"
);
}
if
(
empty
(
$event
->
callfunction
))
{
$db
->
RollbackTrans
();
throw
new
InstallationException
(
"event
$event->event
for
$pcname
didn't supply function name"
);
}
if
(
!
is_callable
(
array
(
$pcname
,
$event
->
callfunction
)))
{
$db
->
RollbackTrans
();
throw
new
InstallationException
(
"event
$event->event
with function
$event->callfunction
for
$pcname
supplied but wasn't callable"
);
}
$exists
=
false
;
if
(
empty
(
$upgrade
->
install
))
{
$exists
=
record_exists
(
'event_subscription_'
.
$plugintype
,
'plugin'
,
$pluginname
,
'event'
,
$event
->
event
());
}
$event
->
plugin
=
$pluginname
;
if
(
empty
(
$exists
))
{
insert_record
(
'event_subscription_'
.
$plugintype
,
$event
);
}
else
{
update_record
(
'event_subscription_'
.
$plugintype
,
$event
,
array
(
'id'
,
$exists
->
id
));
}
}
}
call_static_method
(
$pcname
,
'postinst'
);
if
(
$db
->
HasFailedTrans
())
{
if
(
$db
->
HasFailedTrans
())
{
$status
=
false
;
$status
=
false
;
...
@@ -813,4 +839,6 @@ class Plugin {
...
@@ -813,4 +839,6 @@ class Plugin {
}
}
}
}
class
InstallationException
extends
Exception
{}
?>
?>
Write
Preview
Supports
Markdown
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