From 0c02ca4c12d4a400af76f620d405ebc7dc1f8cb1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 14 Oct 2014 23:19:49 -0500 Subject: [PATCH] Improve code style in Tour plugin - refs #7279 --- plugin/tour/ajax/save.ajax.php | 11 ++++++----- plugin/tour/ajax/steps.ajax.php | 8 +++----- plugin/tour/config.php | 2 -- plugin/tour/index.php | 6 ++---- plugin/tour/install.php | 4 +--- plugin/tour/lang/english.php | 2 -- plugin/tour/lang/spanish.php | 2 -- plugin/tour/plugin.php | 2 -- plugin/tour/readme.txt | 2 +- plugin/tour/src/tour_plugin.class.php | 14 +++++--------- plugin/tour/uninstall.php | 4 +--- 11 files changed, 19 insertions(+), 38 deletions(-) diff --git a/plugin/tour/ajax/save.ajax.php b/plugin/tour/ajax/save.ajax.php index 33dec1bf6a..fcee058159 100644 --- a/plugin/tour/ajax/save.ajax.php +++ b/plugin/tour/ajax/save.ajax.php @@ -1,14 +1,15 @@ * @package chamilo.plugin.tour */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/main/inc/global.inc.php'; -require_once dirname((__DIR__)) . '/config.php'; +/** + * Init + */ +require_once __DIR__ . '/../../../main/inc/global.inc.php'; +require_once __DIR__ . '/../config.php'; if (!api_is_anonymous()) { $currentPageClass = isset($_POST['page_class']) ? $_POST['page_class'] : ''; @@ -19,4 +20,4 @@ if (!api_is_anonymous()) { $tourPlugin = Tour::create(); $tourPlugin->saveCompletedTour($currentPageClass, $userId); } -} \ No newline at end of file +} diff --git a/plugin/tour/ajax/steps.ajax.php b/plugin/tour/ajax/steps.ajax.php index 09080aee14..5be9d870a0 100644 --- a/plugin/tour/ajax/steps.ajax.php +++ b/plugin/tour/ajax/steps.ajax.php @@ -1,13 +1,11 @@ * @package chamilo.plugin.tour */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/main/inc/global.inc.php'; +require_once __DIR__.'/../../../main/inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; require_once api_get_path(PLUGIN_PATH) . 'tour/src/tour_plugin.class.php'; @@ -16,7 +14,7 @@ if (!api_is_anonymous()) { $tourPlugin = Tour::create(); - $json = $tourPlugin->getTourCofig(); + $json = $tourPlugin->getTourConfig(); $currentPageSteps = array(); @@ -36,4 +34,4 @@ if (!api_is_anonymous()) { if (!empty($currentPageSteps)) { echo json_encode($currentPageSteps); } -} \ No newline at end of file +} diff --git a/plugin/tour/config.php b/plugin/tour/config.php index 8935755ab7..73544d88c2 100644 --- a/plugin/tour/config.php +++ b/plugin/tour/config.php @@ -1,7 +1,5 @@ diff --git a/plugin/tour/index.php b/plugin/tour/index.php index 497f010ef0..65a133c729 100644 --- a/plugin/tour/index.php +++ b/plugin/tour/index.php @@ -1,13 +1,11 @@ * @package chamilo.plugin.tour */ -require_once dirname(__FILE__) . '/config.php'; +require_once __DIR__ . '/config.php'; $pluginPath = api_get_path(PLUGIN_PATH) . 'tour/'; $pluginWebPath = api_get_path(WEB_PLUGIN_PATH) . 'tour/'; @@ -15,7 +13,7 @@ $pluginWebPath = api_get_path(WEB_PLUGIN_PATH) . 'tour/'; $userId = api_get_user_id(); $tourPlugin = Tour::create(); -$config = $tourPlugin->getTourCofig(); +$config = $tourPlugin->getTourConfig(); $showTour = $tourPlugin->get('show_tour') === 'true'; if ($showTour) { diff --git a/plugin/tour/install.php b/plugin/tour/install.php index 7ddb02e98d..31ef15b6da 100644 --- a/plugin/tour/install.php +++ b/plugin/tour/install.php @@ -1,12 +1,10 @@ * @package chamilo.plugin.tour */ -require_once dirname(__FILE__) . '/config.php'; +require_once __DIR__ . '/config.php'; Tour::create()->install(); diff --git a/plugin/tour/lang/english.php b/plugin/tour/lang/english.php index 1644568649..efc9d403e3 100644 --- a/plugin/tour/lang/english.php +++ b/plugin/tour/lang/english.php @@ -1,7 +1,5 @@ diff --git a/plugin/tour/lang/spanish.php b/plugin/tour/lang/spanish.php index a5a6336a3c..d15180c36e 100644 --- a/plugin/tour/lang/spanish.php +++ b/plugin/tour/lang/spanish.php @@ -1,7 +1,5 @@ diff --git a/plugin/tour/plugin.php b/plugin/tour/plugin.php index 7e8eceac11..bc8a5b2165 100644 --- a/plugin/tour/plugin.php +++ b/plugin/tour/plugin.php @@ -1,7 +1,5 @@ diff --git a/plugin/tour/readme.txt b/plugin/tour/readme.txt index b9da6e5e21..c2cdf80d4e 100644 --- a/plugin/tour/readme.txt +++ b/plugin/tour/readme.txt @@ -2,7 +2,7 @@

Shows people how to use your Chamilo LMS

Set the blocks for the tour

Edit the plugin/tour/config/tour.json file adding the page classes and steps

-

To set the steps in a page, add a object like this:

+

To set the steps in a page, add an object like this:

 {
     "pageClass": "page unique class selector",
diff --git a/plugin/tour/src/tour_plugin.class.php b/plugin/tour/src/tour_plugin.class.php
index 9e9fca13a8..eb2dcd1c35 100644
--- a/plugin/tour/src/tour_plugin.class.php
+++ b/plugin/tour/src/tour_plugin.class.php
@@ -1,16 +1,12 @@
 
  * @package chamilo.plugin.tour
  */
 class Tour extends Plugin
 {
-
     /**
      * Class constructor
      */
@@ -98,10 +94,10 @@ class Tour extends Plugin
         $checkResult = Database::select('count(1) as qty', $pluginTourLogTable, array(
                     'where' => array(
                         "page_class = '?' AND " => $currentPageClass,
-                        "user_id = ?" => $userId
+                        "user_id = ?" => intval($userId)
                     )), 'first');
 
-        if ($checkResult != false) {
+        if ($checkResult !== false) {
             if ($checkResult['qty'] > 0) {
                 return false;
             }
@@ -122,7 +118,7 @@ class Tour extends Plugin
 
         Database::insert($pluginTourLogTable, array(
             'page_class' => $currentPageClass,
-            'user_id' => $userId,
+            'user_id' => intval($userId),
             'visualization_datetime' => api_get_utc_datetime()
         ));
     }
@@ -131,7 +127,7 @@ class Tour extends Plugin
      * Get the configuration to show the tour in pages
      * @return array The config data
      */
-    public function getTourCofig()
+    public function getTourConfig()
     {
         $pluginPath = api_get_path(PLUGIN_PATH) . 'tour/';
 
diff --git a/plugin/tour/uninstall.php b/plugin/tour/uninstall.php
index 0c63b59c6b..0806c2cf6a 100644
--- a/plugin/tour/uninstall.php
+++ b/plugin/tour/uninstall.php
@@ -1,12 +1,10 @@
 
  * @package chamilo.plugin.tour
  */
-require_once dirname(__FILE__) . '/config.php';
+require_once __DIR__ . '/config.php';
 
 Tour::create()->uninstall();