Skip to content

Commit

Permalink
Saved map bugfixes
Browse files Browse the repository at this point in the history
* Fixed handling of location types when saving maps
* Extended width of x2_maps.locationType field
  • Loading branch information
raymondcolebaugh committed Nov 15, 2016
1 parent 6bf3087 commit 827a808
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x2engine/protected/data/core.sql
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ CREATE TABLE x2_maps(
centerLat FLOAT,
centerLng FLOAT,
zoom INT,
locationType VARCHAR(50)
locationType VARCHAR(250)
) COLLATE = utf8_general_ci;
/*&*/
DROP TABLE IF EXISTS x2_tips;
Expand Down
12 changes: 12 additions & 0 deletions x2engine/protected/models/Locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ public function relations() {
);
}

public static function renderLocationTypes($types) {
if (!is_array($types)) $types = array($types);
$availableTypes = self::getLocationTypes();
foreach ($types as $i => $type) {
if ($type)
$types[$i] = $availableTypes[$type];
else
$types[$i] = $availableTypes['address'];
}
return implode(', ', $types);
}

/**
* Perform a GeoIP lookup of the specified IP. Dual layered caching is used here, first
* checking the cache, before consulting the db, resorting to a GeoIP lookup if missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ public function actionGoogleMaps($contactId = null, $params = array(), $loadMap
if(isset($map)){
$contactId = $map->contactId;
$params = json_decode($map->params, true);
if (isset($params['tags']) && is_array($params['tags']))
$params['tags'] = implode(',', $params['tags']);
}
}
$conditions = "TRUE";
Expand Down Expand Up @@ -594,8 +596,8 @@ public function actionGoogleMaps($contactId = null, $params = array(), $loadMap
'leadSource' =>
isset($_POST['params']['leadSource']) ?
$_POST['params']['leadSource'] : '',
'tags' => ((isset($_POST['params']['tags']) && !empty($_POST['params']['tags'])) ?
Tags::parseTags($_POST['params']['tags']) : array()),
'tags' => ((isset($params['tags']) && !empty($params['tags'])) ?
Tags::parseTags($params['tags']) : array()),
'zoom' => isset($zoom) ? $zoom : null,
'mapFlag' => isset($map) ? 'true' : 'false',
'noHeatMap' => $noHeatMap,
Expand Down Expand Up @@ -623,7 +625,7 @@ public function actionSaveMap(){
$map->name = $mapName;
$map->owner = Yii::app()->user->getName();
$map->contactId = $contactId;
$map->locationType = $locationType;
$map->locationType = Locations::renderLocationTypes($locationType);
$map->zoom = $zoom;
$map->centerLat = $centerLat;
$map->centerLng = $centerLng;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
array(
'header'=>Yii::t('contacts','Location Type'),
'type'=>'raw',
'value'=>'!is_null($data->locationType) ? Locations::getLocationTypes()[$data->locationType] : Yii::t("contacts", "All")'
'value'=>'!is_null($data->locationType) ? $data->locationType : Yii::t("contacts", "All")'
),
array(
'header'=>Yii::t('contacts','Delete Map'),
Expand Down

0 comments on commit 827a808

Please sign in to comment.