Code Duplication    Length = 9-13 lines in 5 locations

plugin/buycourses/src/buy_course_plugin.class.php 5 locations

@@ 859-868 (lines=10) @@
856
     * @param int $newStatus The new status
857
     * @return boolean
858
     */
859
    private function updateServiceSaleStatus($serviceSaleId, $newStatus = self::SERVICE_STATUS_PENDING)
860
    {
861
        $serviceSaleTable = Database::get_main_table(self::TABLE_SERVICES_NODE);
862
863
        return Database::update(
864
            $serviceSaleTable,
865
            ['status' => intval($newStatus)],
866
            ['id = ?' => intval($serviceSaleId)]
867
        );
868
    }
869
870
    /**
871
     * Complete sale process. Update sale status to completed
@@ 1408-1420 (lines=13) @@
1405
     * @param int $productType The type of product
1406
     * @return int The number of affected rows. Otherwise return false
1407
     */
1408
    public function updateItem(array $itemData, $productId, $productType)
1409
    {
1410
        $itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
1411
1412
        return Database::update(
1413
            $itemTable,
1414
            $itemData,
1415
            [
1416
                'product_id = ? AND ' => intval($productId),
1417
                'product_type' => $productType
1418
            ]
1419
        );
1420
    }
1421
1422
    /**
1423
     * Remove all beneficiaries for a item
@@ 1633-1643 (lines=11) @@
1630
     * @param int $status The status to set (-1 to cancel, 0 to pending, 1 to completed)
1631
     * @return array
1632
     */
1633
    public function setStatusPayouts($payoutId, $status)
1634
    {
1635
        $payoutsTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS);
1636
        
1637
        Database::update(
1638
            $payoutsTable,
1639
            ['status' => intval($status)],
1640
            ['id = ?' => intval($payoutId)]
1641
        );
1642
          
1643
    }
1644
    
1645
    /**
1646
     * Gets the stored platform commission params
@@ 1664-1672 (lines=9) @@
1661
     * @param int $params platform commission
1662
     * @return int The number of affected rows. Otherwise return false
1663
     */
1664
    public function updateCommission($params)
1665
    {
1666
        $commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
1667
1668
        return Database::update(
1669
            $commissionTable,
1670
            ['commission' => intval($params['commission'])]
1671
        );
1672
    }
1673
    
1674
    /**
1675
     * Register addicional service
@@ 2070-2079 (lines=10) @@
2067
     * @param string recurring profile Id
2068
     * @return Mixed
2069
     */
2070
    public function updateRecurringProfileId($serviceSaleId, $recurringProfileId)
2071
    {
2072
        $servicesSaleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SERVICES_NODE);
2073
2074
        return Database::update(
2075
            $servicesSaleTable,
2076
            ['recurring_profile_id' => $recurringProfileId],
2077
            ['id = ?' => intval($serviceSaleId)]
2078
        );
2079
    }
2080
    
2081
    /**
2082
     * Check if a node got an activated service