Added settings list to function call that otherwise removes all settings - refs #7051

1.9.x
Yannick Warnier 11 years ago
parent 554d8b5b71
commit 29f8530649
  1. 18
      main/inc/lib/plugin.class.php
  2. 7
      plugin/bbb/lib/bbb_plugin.class.php
  3. 2
      plugin/olpc_peru_filter/lib/olpc_peru_filter_plugin.class.php
  4. 2
      plugin/openmeetings/lib/openmeetings_plugin.class.php

@ -332,7 +332,8 @@ class Plugin
$sql = "SELECT value FROM $t_course WHERE c_id = $course_id AND variable = '$variable' ";
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$sql_course = "INSERT INTO $t_course (c_id, variable, value, category, subkey, type) VALUES ($course_id, '$variable','$value', 'plugins', '$plugin_name', '$type')";
$sql_course = "INSERT INTO $t_course (c_id, variable, value, category, subkey, type)
VALUES ($course_id, '$variable','$value', 'plugins', '$plugin_name', '$type')";
$r = Database::query($sql_course);
}
}
@ -361,9 +362,10 @@ class Plugin
* Delete the fields added to the course settings page and the link to the
* tool on the course's homepage
* @param int The integer course ID
* @param arrat The list of settings to delete
* @return void
*/
public function uninstall_course_fields($course_id)
public function uninstall_course_fields($course_id, $settings = null)
{
$course_id = intval($course_id);
if (empty($course_id)) {
@ -374,8 +376,11 @@ class Plugin
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
if (!empty($this->course_settings)) {
foreach ($this->course_settings as $setting) {
// The settings array has to be passed from the uninstall method in the
// plugin's class, otherwise it is too risky for other plugins: using
// $this->course_settings here seems to glob all settings from all plugins
if (!empty($settings)) {
foreach ($settings as $setting) {
$variable = Database::escape_string($setting['name']);
if (!empty($setting['group'])) {
$variable = Database::escape_string($setting['group']);
@ -408,16 +413,17 @@ class Plugin
/**
* Uninstall the plugin settings fields from all courses
* @param array The list of all settings that have to be deleted
* @return void
*/
public function uninstall_course_fields_in_all_courses()
public function uninstall_course_fields_in_all_courses($settings = array())
{
// Update existing courses to add conference settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code FROM $t_courses ORDER BY id";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$this->uninstall_course_fields($row['id']);
$this->uninstall_course_fields($row['id'], $settings);
}
}

@ -22,7 +22,7 @@ class BBBPlugin extends Plugin
}
protected function __construct() {
parent::__construct('2.0', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
parent::__construct('2.1', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
}
function install() {
@ -38,7 +38,8 @@ class BBBPlugin extends Plugin
created_at VARCHAR(255) NOT NULL,
closed_at VARCHAR(255) NOT NULL,
calendar_id INT DEFAULT 0,
welcome_msg VARCHAR(255) NOT NULL DEFAULT '')";
welcome_msg VARCHAR(255) NOT NULL DEFAULT '',
session_id INT unsigned DEFAULT 0)";
Database::query($sql);
//Installing course settings
@ -77,6 +78,6 @@ class BBBPlugin extends Plugin
Database::query($sql);
//Deleting course settings
$this->uninstall_course_fields_in_all_courses();
$this->uninstall_course_fields_in_all_courses($this->course_settings);
}
}

@ -51,7 +51,7 @@ class OLPC_Peru_FilterPlugin extends Plugin
function uninstall() {
//Deleting course settings
$this->uninstall_course_fields_in_all_courses();
$this->uninstall_course_fields_in_all_courses($this->course_settings);
}
/**
* Caller for the install_course_fields() function

@ -86,6 +86,6 @@ class OpenMeetingsPlugin extends Plugin
Database::query($sql);
//Deleting course settings
$this->uninstall_course_fields_in_all_courses();
$this->uninstall_course_fields_in_all_courses($this->course_settings);
}
}

Loading…
Cancel
Save