[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14630] more on json
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14630] more on json |
Date: |
Sun, 10 Jan 2016 17:53:09 +0000 |
Revision: 14630
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14630
Author: sigurdne
Date: 2016-01-10 17:53:08 +0000 (Sun, 10 Jan 2016)
Log Message:
-----------
more on json
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.soresource.inc.php
branches/dev-syncromind/booking/setup/tables_update.inc.php
branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
branches/dev-syncromind/phpgwapi/inc/class.db_pdo.inc.php
Modified: branches/dev-syncromind/booking/inc/class.soresource.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soresource.inc.php
2016-01-09 20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/booking/inc/class.soresource.inc.php
2016-01-10 17:53:08 UTC (rev 14630)
@@ -94,7 +94,7 @@
function _get_conditions($query, $filters)
{
-
+ static $custom_fields_arr = array();
if(isset($filters['activity_id']) &&
$filters['activity_id'])
{
$soactivity =
createObject('booking.soactivity');
@@ -103,6 +103,55 @@
$filters['activity_id'] = $activity_ids;
}
$conditions = parent::_get_conditions($query, $filters);
+
+ $custom_condition_arr = array();
+ if(isset($filters['custom_fields_criteria']) &&
is_array($filters['custom_fields_criteria']))
+ {
+ foreach($filters['custom_fields_criteria'] as
$custom_fields_criteria)
+ {
+ $sub_condition = array();
+ $location_id =
$custom_fields_criteria['location_id'];
+
+
if(!isset($custom_fields_arr[$location_id]))
+ {
+ $custom_fields =
$GLOBALS['phpgw']->custom_fields->find2($location_id, 0, '', 'ASC',
'attrib_sort', true, true);
+
$custom_fields_arr[$location_id] = $custom_fields;
+ $sub_condition[] = "
json_representation @> '{\"schema_location\":$location_id}'";
+ }
+
+ $field_name =
$custom_fields[$custom_fields_criteria['attribute_id']]['name'];
+ $field_value =
isset($custom_fields_criteria['choice_id']) ?
$custom_fields_criteria['choice_id'] : false;
+
+ if(!$field_value)
+ {
+ continue;
+ }
+
+
+
if($custom_fields[$custom_fields_criteria['attribute_id']]['datatype'] == 'CH')
// in array
+ {
+ /**
+ * Note: JSONB operator '?' is
troublesome: convert to '~@'
+ * CREATE OPERATOR ~@ (LEFTARG
= jsonb, RIGHTARG = text, PROCEDURE = jsonb_exists);
+ * CREATE OPERATOR ~@| (LEFTARG
= jsonb, RIGHTARG = text[], PROCEDURE = jsonb_exists_any);
+ * CREATE OPERATOR ~@& (LEFTARG
= jsonb, RIGHTARG = text[], PROCEDURE = jsonb_exists_all);
+ */
+ $sub_condition[] = "
json_representation #> '{data,$field_name}' ~@ '$field_value'";
+ }
+ else // discrete value
+ {
+ $sub_condition[] = "
json_representation #> '{data,$field_name}' = '\"$field_value\"'";
+ }
+
+
+ $custom_condition_arr[] = '(' .
implode(' AND ', $sub_condition) . ')';
+ }
+ }
+
+ if($custom_condition_arr)
+ {
+ $conditions .= ' AND ' . implode(' OR ',
$custom_condition_arr);
+ }
return $conditions;
}
}
\ No newline at end of file
Modified: branches/dev-syncromind/booking/setup/tables_update.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/tables_update.inc.php 2016-01-09
20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/booking/setup/tables_update.inc.php 2016-01-10
17:53:08 UTC (rev 14630)
@@ -3341,6 +3341,10 @@
'nullable' => true
)
);
+
+ $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@
(LEFTARG = jsonb, RIGHTARG = text, PROCEDURE =
jsonb_exists)',__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@|
(LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE =
jsonb_exists_any)',__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@&
(LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE =
jsonb_exists_all)',__LINE__,__FILE__);
if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
{
Modified: branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2016-01-09 20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2016-01-10 17:53:08 UTC (rev 14630)
@@ -13,7 +13,7 @@
$this->soevent =
CreateObject('booking.soevent');
}
- function search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town)
+ function search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town,$criteria = array())
{
$building_filter = array();
@@ -90,7 +90,10 @@
$_filter_resource['activity_id'] =
$activity_top_level;
}
- $_filter_resource['building_id'] =
$building_filter;
+ if($building_filter)
+ {
+ $_filter_resource['building_id'] =
$building_filter;
+ }
if($building_id)
{
@@ -101,6 +104,11 @@
$_filter_resource['part_of_town_id'] =
$filter_part_of_town;
}
+ if($criteria)
+ {
+
$_filter_resource['custom_fields_criteria'] = $criteria;
+ }
+
$res_result =
$this->soresource->read(array("query" => $searchterm, "sort" => "name",
"dir" => "asc", "filters" =>
$_filter_resource));
foreach($res_result['results'] as &$res)
Modified: branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2016-01-09 20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2016-01-10 17:53:08 UTC (rev 14630)
@@ -118,7 +118,7 @@
if($building_id || $type || $activity_top_level ||
(isset($filter_part_of_town[0]) && $filter_part_of_town[0]))
{
$data = array(
- 'results' =>
$this->bo->search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town)
+ 'results' =>
$this->bo->search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town, $criteria)
);
}
self::render_template_xsl('search_details', $data);
Modified: branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
===================================================================
--- branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2016-01-09 20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2016-01-10 17:53:08 UTC (rev 14630)
@@ -26,7 +26,7 @@
// Filter tree
$("#treeDiv1").jstree({
core: {
- multiple: false,
+ multiple: true,
data: filter_tree,
themes: {"stripes": true}
},
Modified: branches/dev-syncromind/phpgwapi/inc/class.db_pdo.inc.php
===================================================================
--- branches/dev-syncromind/phpgwapi/inc/class.db_pdo.inc.php 2016-01-09
20:33:46 UTC (rev 14629)
+++ branches/dev-syncromind/phpgwapi/inc/class.db_pdo.inc.php 2016-01-10
17:53:08 UTC (rev 14630)
@@ -350,6 +350,15 @@
*/
public function query($sql, $line = '', $file = '', $exec =
false, $_fetch_single = false)
{
+
+/**
+ * Note: JSONB operator '?' is troublesom: convert to '~@'
+ * CREATE OPERATOR ~@ (LEFTARG = jsonb, RIGHTARG = text, PROCEDURE =
jsonb_exists);
+ * CREATE OPERATOR ~@| (LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE =
jsonb_exists_any);
+ * CREATE OPERATOR ~@& (LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE =
jsonb_exists_all);
+ */
+
+
self::_get_fetchmode();
self::set_fetch_single($_fetch_single);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14630] more on json,
Sigurd Nes <=