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
de22acac
Commit
de22acac
authored
Oct 25, 2006
by
Penny Leach
Browse files
base class for plugins now used in upgrade_plugin
(cron/postinst/events). fixed a few todos too.
parent
691e51a8
Changes
1
Show whitespace changes
Inline
Side-by-side
htdocs/lib/mahara.php
View file @
de22acac
...
...
@@ -187,7 +187,6 @@ function upgrade_plugin($upgrade) {
$db
->
StartTrans
();
if
(
!
empty
(
$upgrade
->
install
))
{
// @todo add to installed_artefacts
if
(
is_readable
(
$location
.
'install.xml'
))
{
$status
=
install_from_xmldb_file
(
$location
.
'install.xml'
);
}
...
...
@@ -196,13 +195,15 @@ function upgrade_plugin($upgrade) {
}
}
else
{
if
(
is_readable
(
$location
.
'upgrade.php'
))
{
require_once
(
$location
.
'upgrade.php'
);
// @todo check file exists first - reasonable for it not to have
// db tables at all. should still insert version number and cron etc
$function
=
'xmldb_'
.
$plugintype
.
'_'
.
$pluginname
.
'_upgrade'
;
$status
=
$function
(
$upgrade
->
from
);
}
else
{
$status
=
true
;
}
}
if
(
!
$status
||
$db
->
HasFailedTrans
())
{
$db
->
CompleteTrans
();
throw
new
DatalibException
(
"Failed to upgrade
$upgrade->name
"
);
...
...
@@ -221,7 +222,17 @@ function upgrade_plugin($upgrade) {
update_record
(
$installtable
,
$installed
,
'name'
);
}
// @todo here is where plugins register events and set their crons up
// postinst stuff...
safe_require
(
$plugintype
,
$pluginname
,
'lib.php'
);
$pcname
=
'Plugin'
.
ucfirst
(
$plugintype
)
.
ucfirst
(
$pluginname
);
$crons
=
call_static_method
(
$pcname
,
'get_cron'
);
// @todo save cronjobs.
$events
=
call_static_method
(
$pcname
,
'get_event_subscriptions'
);
// @todo save event subscriptions
call_static_method
(
$pcname
,
'postinst'
);
if
(
$db
->
HasFailedTrans
())
{
$status
=
false
;
...
...
@@ -758,4 +769,23 @@ function xmldb_dbg($message) {
}
define
(
'DEBUG_DEVELOPER'
,
'whocares'
);
/**
* Base class for all plugintypes.
* @abstract
*/
abstract
class
Plugin
{
public
static
function
get_cron
()
{
return
array
();
}
public
static
function
get_event_subscriptions
()
{
return
array
();
}
public
static
function
postinst
()
{
return
true
;
}
}
?>
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