diff --git a/documentation/changelog.html b/documentation/changelog.html
index 4b34e87cfb..d9758b4080 100755
--- a/documentation/changelog.html
+++ b/documentation/changelog.html
@@ -34,6 +34,7 @@
The documents tool and the learn path tool can display vectorial images
An optional "Course (training) validation" feature has been implemented. When it is activated, teachers loose ability to create coursers. Teachers fill course requests instead. Then, after approval, the requested courses are created by the platform administrator. (Feature # 2099)
A new UI option "Fill with exemplary content" have been added to the forms about training/course creation. Now teachers and platform administrators are able to choose whether exemplary content should be put or not in the trainings/courses they are going to create. When a training/course is not created directly by a user, then the platform setting "Example material on training creation" is taken into account. (Feature # 539)
+ Added install/uninstall script possibilities for plugins (BT#1752)
Debugging
diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php
index a1150a2b02..4715a4365f 100755
--- a/main/admin/settings.lib.php
+++ b/main/admin/settings.lib.php
@@ -43,7 +43,6 @@ function handle_plugins() {
$user_id = api_get_user_id();
$category = $_GET['category'];
event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, $time, $user_id);
-
Display :: display_confirmation_message(get_lang('SettingsStored'));
}
@@ -91,6 +90,8 @@ function handle_plugins() {
echo get_lang('Header');
echo '| ';
echo get_lang('Footer');
+ echo ' | ';
+ echo get_lang('CourseTool');
echo ' | ';
echo '';
@@ -137,6 +138,7 @@ function handle_plugins() {
display_plugin_cell('mycourses_menu', $plugin_info, $testplugin, $usedplugins);
display_plugin_cell('header', $plugin_info, $testplugin, $usedplugins);
display_plugin_cell('footer', $plugin_info, $testplugin, $usedplugins);
+ display_plugin_cell('course_tool_plugin', $plugin_info, $testplugin, $usedplugins);
echo '';
}
}
@@ -398,20 +400,45 @@ function store_plugins() {
$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
global $_configuration;
+ // Get a list of all current 'Plugins' settings
+ $installed_plugins = api_get_settings('Plugins','list',$_configuration['access_url']);
+ $shortlist_installed = array();
+ foreach ($installed_plugins as $plugin) {
+ $shortlist_installed[] = $plugin['subkey'];
+ }
+ $shortlist_installed = array_flip(array_flip($shortlist_installed));
// Step 1 : We remove all the plugins.
//$sql = "DELETE FROM $table_settings_current WHERE category='Plugins'";
//Database::query($sql);
$r = api_delete_category_settings('Plugins', $_configuration['access_url']);
-
+ $shortlist_required = array();
// Step 2: Looping through all the post values we only store these which are really a valid plugin location.
foreach ($_POST as $form_name => $formvalue) {
$form_name_elements = explode('-', $form_name);
if (is_valid_plugin_location($form_name_elements[1])) {
+ $shortlist_required[] = $form_name_elements[0];
//$sql = "INSERT into $table_settings_current (variable,category,selected_value) VALUES ('".$form_name_elements['1']."','Plugins','".$form_name_elements['0']."')";
//Database::query($sql);
api_add_setting($form_name_elements['0'], $form_name_elements['1'], $form_name_elements['0'], null, 'Plugins', $form_name_elements['0'], null, null, null, $_configuration['access_url'], 1);
+ // check if there is an install procedure
+ $pluginpath = api_get_path(SYS_PLUGIN_PATH).$form_name_elements[0].'/install.php';
+ if (is_file($pluginpath) && is_readable($pluginpath)) {
+ //execute the install procedure
+ include $pluginpath;
+ }
}
}
+ foreach ($shortlist_installed as $plugin) {
+ // if one plugin was really deleted, execute the uninstall script
+ if (!in_array($plugin,$shortlist_required)) {
+ // check if there is an install procedure
+ $pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin.'/uninstall.php';
+ if (is_file($pluginpath) && is_readable($pluginpath)) {
+ //execute the install procedure
+ include $pluginpath;
+ }
+ }
+ }
}
/**
@@ -419,7 +446,7 @@ function store_plugins() {
* @author Patrick Cool , Ghent University
*/
function is_valid_plugin_location($location) {
- static $valid_locations = array('loginpage_main', 'loginpage_menu', 'campushomepage_main', 'campushomepage_menu', 'mycourses_main', 'mycourses_menu', 'header', 'footer');
+ static $valid_locations = array('loginpage_main', 'loginpage_menu', 'campushomepage_main', 'campushomepage_menu', 'mycourses_main', 'mycourses_menu', 'header', 'footer', 'course_tool_plugin');
return in_array($location, $valid_locations);
}
diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php
index 8a93f3ea6a..971e59590a 100755
--- a/main/inc/lib/add_course.lib.inc.php
+++ b/main/inc/lib/add_course.lib.inc.php
@@ -2053,6 +2053,7 @@ function fill_Db_course($course_db_name, $course_repository, $language, $default
}
global $_configuration, $_user;
+ $cdb = $course_db_name; //save it for plugins, later on
$course_db_name = $_configuration['table_prefix'].$course_db_name.$_configuration['db_glue'];
@@ -2392,6 +2393,22 @@ function fill_Db_course($course_db_name, $course_repository, $language, $default
Database::query("INSERT INTO `$TABLEFORUMPOSTS` VALUES (1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
}
+
+ // PLUGINS - if an installed plugin has a course_install.php file, execute it
+ $installed_plugins = api_get_settings('Plugins','list',$_configuration['access_url']);
+ $shortlist_installed = array();
+ foreach ($installed_plugins as $plugin) {
+ $shortlist_installed[] = $plugin['subkey'];
+ }
+ $shortlist_installed = array_flip(array_flip($shortlist_installed));
+ foreach ($shortlist_installed as $plugin) {
+ $pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin.'/course_install.php';
+ if (is_file($pluginpath) && is_readable($pluginpath)) {
+ //execute the install procedure
+ include $pluginpath;
+ }
+ }
+ //end of installed plugins alterations
$language_interface = $language_interface_tmp;