Minor - flint fixes

pull/3388/head
Julio Montoya 5 years ago
parent 2e24eba9be
commit bba8022c79
  1. 6
      main/inc/lib/plugin.class.php
  2. 1
      plugin/buycourses/src/buy_course_plugin.class.php
  3. 12
      plugin/mindmap/ajax/mindmap.ajax.php
  4. 1
      plugin/mindmap/edit-mindmap/index.php
  5. 5
      plugin/mindmap/inc/action.switch.php
  6. 5
      plugin/mindmap/inc/edit.form.php
  7. 4
      plugin/mindmap/install.php
  8. 12
      plugin/mindmap/list.php
  9. 11
      plugin/mindmap/mindmap_plugin.class.php
  10. 1
      plugin/whispeakauth/WhispeakAuthPlugin.php

@ -858,6 +858,7 @@ class Plugin
* Returns true if the plugin is installed, false otherwise. * Returns true if the plugin is installed, false otherwise.
* *
* @param bool $checkEnabled Also check if enabled (instead of only installed) * @param bool $checkEnabled Also check if enabled (instead of only installed)
*
* @return bool True if plugin is installed/enabled, false otherwise * @return bool True if plugin is installed/enabled, false otherwise
*/ */
public function isEnabled($checkEnabled = false) public function isEnabled($checkEnabled = false)
@ -880,8 +881,8 @@ class Plugin
[ [
"variable = ? AND subkey = ? AND category = 'Plugins' " => [ "variable = ? AND subkey = ? AND category = 'Plugins' " => [
$this->get_name().'_tool_enable', $this->get_name().'_tool_enable',
$this->get_name() $this->get_name(),
] ],
] ]
); );
if (is_array($enabled) && isset($enabled['selected_value']) && $enabled['selected_value'] == 'false') { if (is_array($enabled) && isset($enabled['selected_value']) && $enabled['selected_value'] == 'false') {
@ -890,6 +891,7 @@ class Plugin
return false; return false;
} }
} }
return true; return true;
} }

@ -108,6 +108,7 @@ class BuyCoursesPlugin extends Plugin
* Check if plugin is enabled. * Check if plugin is enabled.
* *
* @param bool $checkEnabled Check if, additionnally to being installed, the plugin is enabled * @param bool $checkEnabled Check if, additionnally to being installed, the plugin is enabled
*
* @return bool * @return bool
*/ */
public function isEnabled($checkEnabled = false) public function isEnabled($checkEnabled = false)

@ -1,7 +1,9 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Process the saving of the mindmap updates (when clicking the logo to get out) * Process the saving of the mindmap updates (when clicking the logo to get out).
*/ */
if (isset($_GET['id'])) { if (isset($_GET['id'])) {
if (isset($_POST['datamap'])) { if (isset($_POST['datamap'])) {
@ -23,31 +25,29 @@ if (isset($_GET['id'])) {
} }
if ($dataMap != '') { if ($dataMap != '') {
$user = api_get_user_info(); $user = api_get_user_info();
$table = 'plugin_mindmap'; $table = 'plugin_mindmap';
$params = [ $params = [
'mindmap_data' => $dataMap 'mindmap_data' => $dataMap,
]; ];
$whereConditions = [ $whereConditions = [
'id = ?' => $idMM, 'id = ?' => $idMM,
'AND (user_id = ?' => $user['id'], 'AND (user_id = ?' => $user['id'],
'OR is_shared = 1)' 'OR is_shared = 1)',
]; ];
$isAdmin = api_is_platform_admin(); $isAdmin = api_is_platform_admin();
if ($user['status'] == SESSIONADMIN || $user['status'] == PLATFORM_ADMIN || $isAdmin) { if ($user['status'] == SESSIONADMIN || $user['status'] == PLATFORM_ADMIN || $isAdmin) {
$whereConditions = [ $whereConditions = [
'id = ?' => $idMM 'id = ?' => $idMM,
]; ];
} }
$resultUp = Database::update($table, $params, $whereConditions); $resultUp = Database::update($table, $params, $whereConditions);
echo 'OK'; echo 'OK';
} else { } else {
echo 'KO'; echo 'KO';
} }

@ -42,7 +42,6 @@
} }
echo 'titleMM = "'.$titleMM.'";'; echo 'titleMM = "'.$titleMM.'";';
} }
} }
?> ?>
</script> </script>

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
$varString = api_get_self(); $varString = api_get_self();
@ -18,7 +19,7 @@ switch ($action) {
'is_shared' => (empty($values['is_shared']) ? 0 : (int) $values['is_shared']), 'is_shared' => (empty($values['is_shared']) ? 0 : (int) $values['is_shared']),
'c_id' => $cid, 'c_id' => $cid,
'url_id' => $urlId, 'url_id' => $urlId,
'session_id' => $sessionId 'session_id' => $sessionId,
]; ];
$result = Database::insert($plugin->table, $params); $result = Database::insert($plugin->table, $params);
@ -39,7 +40,7 @@ switch ($action) {
'title' => $values['title'], 'title' => $values['title'],
'description' => $values['description'], 'description' => $values['description'],
'is_public' => $values['is_public'], 'is_public' => $values['is_public'],
'is_shared' => $values['is_shared'] 'is_shared' => $values['is_shared'],
]; ];
Database::update($plugin->table, $params, ['id = ?' => $id]); Database::update($plugin->table, $params, ['id = ?' => $id]);
Display::addFlash(Display::return_message(get_lang('Updated'))); Display::addFlash(Display::return_message(get_lang('Updated')));

@ -1,7 +1,7 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Generate the form to add/edit a mindmap record * Generate the form to add/edit a mindmap record.
*/ */
$form = new FormValidator( $form = new FormValidator(
'dictionary', 'dictionary',
@ -10,7 +10,6 @@ $form = new FormValidator(
); );
if ($action == 'add' || $action == 'edit') { if ($action == 'add' || $action == 'edit') {
$form->addText('title', get_lang('Title'), true); $form->addText('title', get_lang('Title'), true);
$form->addText('description', get_lang('Description'), false); $form->addText('description', get_lang('Description'), false);
@ -20,9 +19,7 @@ if ($action == 'add' || $action == 'edit') {
$form->addElement('hidden', 'mindmap_type', 'mind'); $form->addElement('hidden', 'mindmap_type', 'mind');
$form->addButtonSave(get_lang('Save')); $form->addButtonSave(get_lang('Save'));
} else { } else {
$ht = '<p style="text-align:center;" ><img alt="'.htmlentities(get_lang('Save')).'" src="img/mindmap128.png" /></p>'; $ht = '<p style="text-align:center;" ><img alt="'.htmlentities(get_lang('Save')).'" src="img/mindmap128.png" /></p>';
$form->addElement('static', '', '', $ht); $form->addElement('static', '', '', $ht);
} }

@ -1,9 +1,9 @@
<?php <?php
/* For license terms, see /license.txt */ /* For license terms, see /license.txt */
require_once(__DIR__.'/mindmap_plugin.class.php'); require_once __DIR__.'/mindmap_plugin.class.php';
if(!api_is_platform_admin()){ if (!api_is_platform_admin()) {
die('You must have admin permissions to install plugins'); die('You must have admin permissions to install plugins');
} }

@ -39,18 +39,18 @@ if (!$plugin->isEnabled(true)) {
api_not_allowed(true); api_not_allowed(true);
exit; exit;
} else { } else {
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
$cid = 0; $cid = 0;
if (!empty($_GET['cidReq'])) { if (!empty($_GET['cidReq'])) {
$cid = api_get_course_int_id($_GET['cidReq']); $cid = api_get_course_int_id($_GET['cidReq']);
} else { } else {
$cid = isset($_GET['cid']) ? (int)$_GET['cid'] : 0; $cid = isset($_GET['cid']) ? (int) $_GET['cid'] : 0;
} }
if (!empty($_GET['id_session'])) { if (!empty($_GET['id_session'])) {
$sessionId = (int)$_GET['id_session']; $sessionId = (int) $_GET['id_session'];
} else { } else {
$sessionId = isset($_GET['sid']) ? (int)$_GET['sid'] : 0; $sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
} }
if ($cid == 0) { if ($cid == 0) {
@ -90,7 +90,7 @@ if (!$plugin->isEnabled(true)) {
} }
} }
// Show create/edit form // Show create/edit form
include('inc/edit.form.php'); include 'inc/edit.form.php';
$htmlHeadXtra[] = '<script src="resources/js/jquery.dataTables.min.js?v='.$version.'" language="javascript"></script>'; $htmlHeadXtra[] = '<script src="resources/js/jquery.dataTables.min.js?v='.$version.'" language="javascript"></script>';
@ -114,7 +114,7 @@ if (!$plugin->isEnabled(true)) {
// Process actions (add/edit/delete) // Process actions (add/edit/delete)
// Also exit and redirect to list if action successful // Also exit and redirect to list if action successful
include('inc/action.switch.php'); include 'inc/action.switch.php';
} }
$addButton = Display::url( $addButton = Display::url(

@ -3,7 +3,7 @@
/** /**
* Class MindmapPlugin * Class MindmapPlugin
* This class defines the course plugin "MindMap", storing its data in the plugin_mindmap table * This class defines the course plugin "MindMap", storing its data in the plugin_mindmap table.
*/ */
class MindmapPlugin extends Plugin class MindmapPlugin extends Plugin
{ {
@ -22,21 +22,22 @@ class MindmapPlugin extends Plugin
'tool_enable' => 'boolean', 'tool_enable' => 'boolean',
] ]
); );
} }
/** /**
* Create instance of a Mindmap plugin object * Create instance of a Mindmap plugin object.
*
* @return MindmapPlugin|null * @return MindmapPlugin|null
*/ */
public static function create() public static function create()
{ {
static $result = null; static $result = null;
return $result ? $result : $result = new self(); return $result ? $result : $result = new self();
} }
/** /**
* Install the table structure * Install the table structure.
*/ */
public function install() public function install()
{ {
@ -78,7 +79,7 @@ class MindmapPlugin extends Plugin
} }
// Deleting course settings and course home icons // Deleting course settings and course home icons
$this->uninstall_course_fields_in_all_courses(); $this->uninstall_course_fields_in_all_courses();
error_log('dropping c_tool');
$p2 = api_get_path(SYS_PATH).'main/img/icons/64/mindmap.png'; $p2 = api_get_path(SYS_PATH).'main/img/icons/64/mindmap.png';
if (file_exists($p2) && is_writable($p2)) { if (file_exists($p2) && is_writable($p2)) {
unlink($p2); unlink($p2);

@ -408,6 +408,7 @@ class WhispeakAuthPlugin extends Plugin implements HookPluginInterface
* Check if the WhispeakAuth plugin is installed and enabled. * Check if the WhispeakAuth plugin is installed and enabled.
* *
* @param bool $checkEnabled Check if, additionnally to being installed, the plugin is enabled * @param bool $checkEnabled Check if, additionnally to being installed, the plugin is enabled
*
* @return bool * @return bool
*/ */
public function isEnabled($checkEnabled = false) public function isEnabled($checkEnabled = false)

Loading…
Cancel
Save