PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / import / classes / reviews.php
vikappointments / site / helpers / libraries / import / classes Last commit date
cities.php 3 days ago coupons.php 3 days ago customers.php 3 days ago empgroups.php 3 days ago employees.php 3 days ago groups.php 3 days ago index.html 3 days ago locations.php 3 days ago optiongroups.php 3 days ago options.php 3 days ago reviews.php 3 days ago services.php 3 days ago states.php 3 days ago
reviews.php
91 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 VAPLoader::import('libraries.import.object');
15
16 /**
17 * Class used to handle an import event for the REVIEWS.
18 *
19 * @see ImportObject
20 * @since 1.7
21 */
22 class ImportObjectReviews extends ImportObject
23 {
24 /**
25 * Builds the base query to export all the records.
26 * @since 1.7 $app and $dbo are now included within the $options argument.
27 *
28 * @param JObject $options A registry of export options.
29 * @param string $alias The table alias.
30 *
31 * @return mixed The query builder object.
32 *
33 * @uses getColumns()
34 * @uses getTable()
35 * @uses getPrimaryKey()
36 */
37 protected function buildExportQuery($options, $alias = 'r')
38 {
39 $app = $options->get('app');
40 $dbo = $options->get('dbo');
41
42 $filters = array();
43 $filters['keys'] = $app->getUserStateFromRequest('vapreviews.keys', 'keys', '', 'string');
44 $filters['status'] = $app->getUserStateFromRequest('vapreviews.status', 'status', '', 'string');
45 $filters['rating'] = $app->getUserStateFromRequest('vapreviews.rating', 'rating', 0, 'uint');
46 $filters['type'] = $app->getUserStateFromRequest('vapreviews.type', 'type', '', 'string');
47 $filters['lang'] = $app->getUserStateFromRequest('vapreviews.lang', 'lang', '', 'string');
48
49 $q = parent::buildExportQuery($options, $alias);
50
51 // join reviews with services and employees
52 $q->leftjoin($dbo->qn('#__vikappointments_service', 's') . ' ON ' . $dbo->qn('r.id_service') . ' = ' . $dbo->qn('s.id'));
53 $q->leftjoin($dbo->qn('#__vikappointments_employee', 'e') . ' ON ' . $dbo->qn('r.id_employee') . ' = ' . $dbo->qn('e.id'));
54
55 // init where to prevent errors with andWhere search
56 $q->where(1);
57
58 if (strlen($filters['keys']))
59 {
60 $q->andWhere(array(
61 $dbo->qn('r.name') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
62 $dbo->qn('r.title') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
63 $dbo->qn('s.name') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
64 $dbo->qn('e.nickname') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
65 ), 'OR');
66 }
67
68 if (strlen($filters['status']))
69 {
70 $q->where($dbo->qn('r.published') . ' = ' . (int) $filters['status']);
71 }
72
73 if ($filters['rating'])
74 {
75 $q->where($dbo->qn('r.rating') . ' = ' . $filters['rating']);
76 }
77
78 if (!empty($filters['type']))
79 {
80 $q->where($dbo->qn('r.id_' . $filters['type']) . ' > 0');
81 }
82
83 if (!empty($filters['lang']))
84 {
85 $q->where($dbo->qn('r.langtag') . ' = ' . $dbo->q($filters['lang']));
86 }
87
88 return $q;
89 }
90 }
91