Skip to content

Commit

Permalink
Merge pull request opencart#14282 from TheCartpenter/patch-137
Browse files Browse the repository at this point in the history
Worked on more backticks
  • Loading branch information
danielkerr authored Dec 22, 2024
2 parents 1fdff66 + ab885dc commit 16600bc
Show file tree
Hide file tree
Showing 46 changed files with 172 additions and 107 deletions.
2 changes: 1 addition & 1 deletion upload/admin/model/catalog/attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function deleteDescriptionsByLanguageId(int $language_id): void {
* @return array<string, mixed> description record that has attribute ID, language ID
*/
public function getDescription(int $attribute_id, int $language_id): array {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "attribute_description` WHERE `attribute_id` = '" . (int)$attribute_id . "' AND language_id = '" . (int)$language_id . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "attribute_description` WHERE `attribute_id` = '" . (int)$attribute_id . "' AND `language_id` = '" . (int)$language_id . "'");

return $query->row;
}
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/catalog/attribute_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getAttributeGroup(int $attribute_group_id): array {
* @return array<int, array<string, mixed>> attribute group records
*/
public function getAttributeGroups(array $data = []): array {
$sql = "SELECT * FROM `" . DB_PREFIX . "attribute_group` `ag` LEFT JOIN `" . DB_PREFIX . "attribute_group_description` `agd` ON (`ag`.`attribute_group_id` = agd.`attribute_group_id`) WHERE `agd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";
$sql = "SELECT * FROM `" . DB_PREFIX . "attribute_group` `ag` LEFT JOIN `" . DB_PREFIX . "attribute_group_description` `agd` ON (`ag`.`attribute_group_id` = `agd`.`attribute_group_id`) WHERE `agd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";

$sort_data = [
'agd.name',
Expand Down
5 changes: 4 additions & 1 deletion upload/admin/model/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,17 @@ public function deleteCategory(int $category_id): void {
$this->model_catalog_category->deleteStores($category_id);
$this->model_catalog_category->deleteLayouts($category_id);

// Product
$this->load->model('catalog/product');

$this->model_catalog_product->deleteCategoriesByCategoryId($category_id);

// Coupon
$this->load->model('marketing/coupon');

$this->model_marketing_coupon->deleteCategoriesByCategoryId($category_id);

// SEO URL
$this->load->model('design/seo_url');

$path = $this->model_catalog_category->getPath($category_id);
Expand Down Expand Up @@ -718,7 +721,7 @@ public function getStores(int $category_id): array {
* @return void
*/
public function addLayout(int $category_id, int $store_id, int $layout_id): void {
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_to_layout` SET `category_id` = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_to_layout` SET `category_id` = '" . (int)$category_id . "', `store_id` = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
}

/**
Expand Down
2 changes: 2 additions & 0 deletions upload/admin/model/catalog/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ public function deleteFilter(int $filter_id): void {

$this->model_catalog_filter->deleteDescriptions($filter_id);

// Category
$this->load->model('catalog/category');

$this->model_catalog_category->deleteFiltersByFilterId($filter_id);

// Product
$this->load->model('catalog/product');

$this->model_catalog_product->deleteFiltersByFilterId($filter_id);
Expand Down
4 changes: 3 additions & 1 deletion upload/admin/model/catalog/information.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function editInformation(int $information_id, array $data): void {
}
}

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('information_id', $information_id);
Expand Down Expand Up @@ -114,6 +115,7 @@ public function deleteInformation(int $information_id): void {
$this->model_catalog_information->deleteStores($information_id);
$this->model_catalog_information->deleteLayouts($information_id);

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('information_id', $information_id);
Expand Down Expand Up @@ -329,7 +331,7 @@ public function getStores(int $information_id): array {
* @return void
*/
public function addLayout(int $information_id, int $store_id, int $layout_id): void {
$this->db->query("INSERT INTO `" . DB_PREFIX . "information_to_layout` SET `information_id` = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "information_to_layout` SET `information_id` = '" . (int)$information_id . "', `store_id` = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
}

/**
Expand Down
3 changes: 2 additions & 1 deletion upload/admin/model/catalog/manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function deleteManufacturer(int $manufacturer_id): void {
$this->model_catalog_manufacturer->deleteStores($manufacturer_id);
$this->model_catalog_manufacturer->deleteLayouts($manufacturer_id);

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('manufacturer_id', $manufacturer_id);
Expand Down Expand Up @@ -252,7 +253,7 @@ public function getStores(int $manufacturer_id): array {
* @return void
*/
public function addLayout(int $manufacturer_id, int $store_id, int $layout_id): void {
$this->db->query("INSERT INTO `" . DB_PREFIX . "manufacturer_to_layout` SET `manufacturer_id` = '" . (int)$manufacturer_id . "', store_id = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "manufacturer_to_layout` SET `manufacturer_id` = '" . (int)$manufacturer_id . "', `store_id` = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
}

/**
Expand Down
3 changes: 3 additions & 0 deletions upload/admin/model/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,17 @@ public function deleteProduct(int $product_id): void {
$this->model_catalog_product->deleteStores($product_id);
$this->model_catalog_product->deleteSubscriptions($product_id);

// Review
$this->load->model('catalog/review');

$this->model_catalog_review->deleteReviewsByProductId($product_id);

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('product_id', $product_id);

// Coupon
$this->load->model('marketing/coupon');

$this->model_marketing_coupon->deleteProductsByProductId($product_id);
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/catalog/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function deleteReviewsByProductId(int $product_id): void {
* @return array<string, mixed> review record that has review ID
*/
public function getReview(int $review_id): array {
$query = $this->db->query("SELECT DISTINCT *, (SELECT pd.`name` FROM `" . DB_PREFIX . "product_description` pd WHERE pd.`product_id` = r.`product_id` AND pd.`language_id` = '" . (int)$this->config->get('config_language_id') . "') AS product FROM `" . DB_PREFIX . "review` r WHERE r.`review_id` = '" . (int)$review_id . "'");
$query = $this->db->query("SELECT DISTINCT *, (SELECT `pd`.`name` FROM `" . DB_PREFIX . "product_description` `pd` WHERE `pd`.`product_id` = `r`.`product_id` AND `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "') AS `product` FROM `" . DB_PREFIX . "review` `r` WHERE `r`.`review_id` = '" . (int)$review_id . "'");

return $query->row;
}
Expand Down
3 changes: 2 additions & 1 deletion upload/admin/model/catalog/subscription_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function deleteSubscriptionPlan(int $subscription_plan_id): void {

$this->model_catalog_subscription_plan->deleteDescriptions($subscription_plan_id);

// Product
$this->load->model('catalog/product');

$this->model_catalog_product->deleteSubscriptionsBySubscriptionPlanId($subscription_plan_id);
Expand All @@ -81,7 +82,7 @@ public function deleteSubscriptionPlan(int $subscription_plan_id): void {
* @return array<string, mixed> subscription plan record that has subscription plan ID
*/
public function getSubscriptionPlan(int $subscription_plan_id): array {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "subscription_plan` sp LEFT JOIN `" . DB_PREFIX . "subscription_plan_description` spd ON (sp.`subscription_plan_id` = spd.`subscription_plan_id`) WHERE `sp`.`subscription_plan_id` = '" . (int)$subscription_plan_id . "' AND `spd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "subscription_plan` `sp` LEFT JOIN `" . DB_PREFIX . "subscription_plan_description` `spd` ON (`sp`.`subscription_plan_id` = `spd`.`subscription_plan_id`) WHERE `sp`.`subscription_plan_id` = '" . (int)$subscription_plan_id . "' AND `spd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");

return $query->row;
}
Expand Down
5 changes: 3 additions & 2 deletions upload/admin/model/cms/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function deleteArticle(int $article_id): void {
$this->model_cms_article->deleteLayouts($article_id);
$this->model_cms_article->deleteCommentsByArticleId($article_id);

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('article_id', $article_id);
Expand Down Expand Up @@ -350,7 +351,7 @@ public function getStores(int $article_id): array {
* @return void
*/
public function addLayout(int $article_id, int $store_id, int $layout_id): void {
$this->db->query("INSERT INTO `" . DB_PREFIX . "article_to_layout` SET `article_id` = '" . (int)$article_id . "', store_id = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "article_to_layout` SET `article_id` = '" . (int)$article_id . "', `store_id` = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
}

/**
Expand Down Expand Up @@ -480,7 +481,7 @@ public function getComment(int $article_comment_id): array {
* @return array<int, array<string, mixed>> rating records that have article ID
*/
public function getRatings(int $article_id, int $article_comment_id = 0): array {
$sql = "SELECT rating, COUNT(*) AS total FROM `" . DB_PREFIX . "article_rating` WHERE `article_id` = '" . (int)$article_id . "'";
$sql = "SELECT rating, COUNT(*) AS `total` FROM `" . DB_PREFIX . "article_rating` WHERE `article_id` = '" . (int)$article_id . "'";

if ($article_comment_id) {
$sql .= " AND `article_comment_id` = '" . (int)$article_comment_id . "'";
Expand Down
3 changes: 2 additions & 1 deletion upload/admin/model/cms/topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function deleteTopic(int $topic_id): void {
$this->model_cms_topic->deleteDescriptions($topic_id);
$this->model_cms_topic->deleteStores($topic_id);

// SEO URL
$this->load->model('design/seo_url');

$this->model_design_seo_url->deleteSeoUrlsByKeyValue('topic_id', $topic_id);
Expand Down Expand Up @@ -314,7 +315,7 @@ public function getStores(int $topic_id): array {
* @return void
*/
public function addLayout(int $topic_id, int $store_id, int $layout_id): void {
$this->db->query("INSERT INTO `" . DB_PREFIX . "topic_to_layout` SET `article_id` = '" . (int)$topic_id . "', store_id = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "topic_to_layout` SET `article_id` = '" . (int)$topic_id . "', `store_id` = '" . (int)$store_id . "', `layout_id` = '" . (int)$layout_id . "'");
}

/**
Expand Down
5 changes: 5 additions & 0 deletions upload/admin/model/customer/customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public function deleteCustomer(int $customer_id): void {
$this->deleteWishlists($customer_id);
$this->deleteIps($customer_id);

// Affiliate
$this->load->model('marketing/affiliate');

$this->model_marketing_affiliate->deleteAffiliate($customer_id);

// Customer Approval
$this->load->model('customer/customer_approval');

$this->model_customer_customer_approval->deleteApprovalsByCustomerId($customer_id);
Expand Down Expand Up @@ -357,6 +359,7 @@ public function getAddress(int $address_id): array {
$address_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "address` WHERE `address_id` = '" . (int)$address_id . "'");

if ($address_query->num_rows) {
// Country
$this->load->model('localisation/country');

$country_info = $this->model_localisation_country->getCountry($address_query->row['country_id']);
Expand All @@ -373,6 +376,7 @@ public function getAddress(int $address_id): array {
$address_format_id = 0;
}

// Address Format
$this->load->model('localisation/address_format');

$address_format_info = $this->model_localisation_address_format->getAddressFormat($address_format_id);
Expand All @@ -383,6 +387,7 @@ public function getAddress(int $address_id): array {
$address_format = '';
}

// Zone
$this->load->model('localisation/zone');

$zone_info = $this->model_localisation_zone->getZone($address_query->row['zone_id']);
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/customer/customer_approval.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function deleteApprovalsByCustomerId(int $customer_id): void {
* @return array<int, array<string, mixed>> customer approval records
*/
public function getCustomerApprovals(array $data = []): array {
$sql = "SELECT *, CONCAT(`c`.`firstname`, ' ', `c`.`lastname`) AS customer, `cgd`.`name` AS customer_group, `ca`.`type` FROM `" . DB_PREFIX . "customer_approval` `ca` LEFT JOIN `" . DB_PREFIX . "customer` `c` ON (`ca`.`customer_id` = `c`.`customer_id`) LEFT JOIN `" . DB_PREFIX . "customer_group_description` `cgd` ON (`c`.`customer_group_id` = `cgd`.`customer_group_id`) WHERE `cgd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";
$sql = "SELECT *, CONCAT(`c`.`firstname`, ' ', `c`.`lastname`) AS `customer`, `cgd`.`name` AS `customer_group`, `ca`.`type` FROM `" . DB_PREFIX . "customer_approval` `ca` LEFT JOIN `" . DB_PREFIX . "customer` `c` ON (`ca`.`customer_id` = `c`.`customer_id`) LEFT JOIN `" . DB_PREFIX . "customer_group_description` `cgd` ON (`c`.`customer_group_id` = `cgd`.`customer_group_id`) WHERE `cgd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";

if (!empty($data['filter_customer'])) {
$sql .= " AND LCASE(CONCAT(`c`.`firstname`, ' ', `c`.`lastname`)) LIKE '" . $this->db->escape('%' . oc_strtolower($data['filter_customer']) . '%') . "'";
Expand Down
2 changes: 2 additions & 0 deletions upload/admin/model/customer/customer_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ public function deleteCustomerGroup(int $customer_group_id): void {

$this->deleteDescriptions($customer_group_id);

// Product
$this->load->model('catalog/product');

$this->model_catalog_product->deleteDiscountsByCustomerGroupId($customer_group_id);
$this->model_catalog_product->deleteRewardsByCustomerGroupId($customer_group_id);

// Tax Rate
$this->load->model('localisation/tax_rate');

$this->model_localisation_tax_rate->deleteCustomerGroupsByCustomerGroupId($customer_group_id);
Expand Down
5 changes: 5 additions & 0 deletions upload/admin/model/design/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,27 @@ public function deleteLayout(int $layout_id): void {
$this->deleteRoutes($layout_id);
$this->deleteModules($layout_id);

// Category
$this->load->model('catalog/category');

$this->model_catalog_category->deleteLayoutsByLayoutId($layout_id);

// Product
$this->load->model('catalog/product');

$this->model_catalog_product->deleteLayoutsByLayoutId($layout_id);

// Information
$this->load->model('catalog/information');

$this->model_catalog_information->deleteLayoutsByLayoutId($layout_id);

// CMS Article
$this->load->model('cms/article');

$this->model_cms_article->deleteLayoutsByLayoutId($layout_id);

// CMS Topic
$this->load->model('cms/topic');

$this->model_cms_topic->deleteLayoutsByLayoutId($layout_id);
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/localisation/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Location extends \Opencart\System\Engine\Model {
* @return int
*/
public function addLocation(array $data): int {
$this->db->query("INSERT INTO `" . DB_PREFIX . "location` SET `name` = '" . $this->db->escape((string)$data['name']) . "', address = '" . $this->db->escape((string)$data['address']) . "', `geocode` = '" . $this->db->escape((string)$data['geocode']) . "', `telephone` = '" . $this->db->escape((string)$data['telephone']) . "', `image` = '" . $this->db->escape((string)$data['image']) . "', `open` = '" . $this->db->escape((string)$data['open']) . "', `comment` = '" . $this->db->escape((string)$data['comment']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "location` SET `name` = '" . $this->db->escape((string)$data['name']) . "', `address` = '" . $this->db->escape((string)$data['address']) . "', `geocode` = '" . $this->db->escape((string)$data['geocode']) . "', `telephone` = '" . $this->db->escape((string)$data['telephone']) . "', `image` = '" . $this->db->escape((string)$data['image']) . "', `open` = '" . $this->db->escape((string)$data['open']) . "', `comment` = '" . $this->db->escape((string)$data['comment']) . "'");

return $this->db->getLastId();
}
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/localisation/tax_rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function deleteTaxRate(int $tax_rate_id): void {
* @return array<string, mixed> tax rate record that has tax rate ID
*/
public function getTaxRate(int $tax_rate_id): array {
$query = $this->db->query("SELECT `tr`.`tax_rate_id`, `tr`.`name` AS name, `tr`.`rate`, `tr`.`type`, `tr`.`geo_zone_id`, `gz`.`name` AS `geo_zone` FROM `" . DB_PREFIX . "tax_rate` `tr` LEFT JOIN `" . DB_PREFIX . "geo_zone` `gz` ON (`tr`.`geo_zone_id` = `gz`.`geo_zone_id`) WHERE `tr`.`tax_rate_id` = '" . (int)$tax_rate_id . "'");
$query = $this->db->query("SELECT `tr`.`tax_rate_id`, `tr`.`name` AS `name`, `tr`.`rate`, `tr`.`type`, `tr`.`geo_zone_id`, `gz`.`name` AS `geo_zone` FROM `" . DB_PREFIX . "tax_rate` `tr` LEFT JOIN `" . DB_PREFIX . "geo_zone` `gz` ON (`tr`.`geo_zone_id` = `gz`.`geo_zone_id`) WHERE `tr`.`tax_rate_id` = '" . (int)$tax_rate_id . "'");

return $query->row;
}
Expand Down
6 changes: 5 additions & 1 deletion upload/admin/model/sale/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function getOrder(int $order_id): array {
$order_query = $this->db->query("SELECT *, (SELECT `os`.`name` FROM `" . DB_PREFIX . "order_status` `os` WHERE `os`.`order_status_id` = `o`.`order_status_id` AND `os`.`language_id` = '" . (int)$this->config->get('config_language_id') . "') AS `order_status` FROM `" . DB_PREFIX . "order` `o` WHERE `o`.`order_id` = '" . (int)$order_id . "'");

if ($order_query->num_rows) {
// Country
$this->load->model('localisation/country');

$country_info = $this->model_localisation_country->getCountry($order_query->row['payment_country_id']);
Expand All @@ -46,6 +47,7 @@ public function getOrder(int $order_id): array {
$payment_iso_code_3 = '';
}

// Zone
$this->load->model('localisation/zone');

$zone_info = $this->model_localisation_zone->getZone($order_query->row['payment_zone_id']);
Expand Down Expand Up @@ -82,6 +84,7 @@ public function getOrder(int $order_id): array {
$reward += $product['reward'];
}

// Customer
$this->load->model('customer/customer');

$affiliate_info = $this->model_customer_customer->getCustomer($order_query->row['affiliate_id']);
Expand All @@ -92,6 +95,7 @@ public function getOrder(int $order_id): array {
$affiliate = '';
}

// Language
$this->load->model('localisation/language');

$language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
Expand Down Expand Up @@ -131,7 +135,7 @@ public function getOrder(int $order_id): array {
* @return array<int, array<string, mixed>> order records
*/
public function getOrders(array $data = []): array {
$sql = "SELECT `o`.`order_id`, CONCAT(`o`.`firstname`, ' ', `o`.`lastname`) AS customer, (SELECT `os`.`name` FROM `" . DB_PREFIX . "order_status` `os` WHERE `os`.`order_status_id` = `o`.`order_status_id` AND `os`.`language_id` = '" . (int)$this->config->get('config_language_id') . "') AS order_status, `o`.`store_name`, `o`.`custom_field`, `o`.`payment_method`, `o`.`payment_custom_field`, `o`.`shipping_method`, `o`.`shipping_custom_field`, `o`.`total`, `o`.`currency_code`, `o`.`currency_value`, `o`.`date_added`, `o`.`date_modified` FROM `" . DB_PREFIX . "order` `o`";
$sql = "SELECT `o`.`order_id`, CONCAT(`o`.`firstname`, ' ', `o`.`lastname`) AS `customer`, (SELECT `os`.`name` FROM `" . DB_PREFIX . "order_status` `os` WHERE `os`.`order_status_id` = `o`.`order_status_id` AND `os`.`language_id` = '" . (int)$this->config->get('config_language_id') . "') AS `order_status`, `o`.`store_name`, `o`.`custom_field`, `o`.`payment_method`, `o`.`payment_custom_field`, `o`.`shipping_method`, `o`.`shipping_custom_field`, `o`.`total`, `o`.`currency_code`, `o`.`currency_value`, `o`.`date_added`, `o`.`date_modified` FROM `" . DB_PREFIX . "order` `o`";

if (!empty($data['filter_order_status'])) {
$implode = [];
Expand Down
Loading

0 comments on commit 16600bc

Please sign in to comment.