Browse Source

Fix parameters, add int casting.

jmontoyaa 8 years ago
parent
commit
d0d332a667
1 changed files with 15 additions and 10 deletions
  1. 15 10
      plugin/buycourses/src/buy_course_plugin.class.php

+ 15 - 10
plugin/buycourses/src/buy_course_plugin.class.php

@@ -1895,26 +1895,31 @@ class BuyCoursesPlugin extends Plugin
      * @return array
      */
     public function getServiceSale(
-        $id = null,
-        $buyerId = null,
-        $status = null,
-        $nodeType = null,
-        $nodeId = null,
+        $id = 0,
+        $buyerId = 0,
+        $status = 0,
+        $nodeType = 0,
+        $nodeId = 0,
         $hot = false
     ) {
         $servicesTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SERVICES);
         $servicesSaleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SERVICES_SALE);
 
         $conditions = null;
-        $showData = "all";
-        $groupBy = "";
-
-        if ($id) {
+        $showData = 'all';
+        $groupBy = '';
+        $id = (int) $id;
+        $buyerId = (int) $buyerId;
+        $status = (int) $status;
+        $nodeType = (int) $nodeType;
+        $nodeId = (int) $nodeId;
+
+        if (!empty($id)) {
             $conditions = ['WHERE' => ['ss.id = ?' => $id]];
             $showData = "first";
         }
 
-        if ($buyerId) {
+        if (!empty($buyerId)) {
             $conditions = ['WHERE' => ['ss.buyer_id = ?' => $buyerId], 'ORDER' => 'id ASC'];
         }