-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloopthrough.php
63 lines (57 loc) · 1.61 KB
/
loopthrough.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?
$allFormFields = $hook->getValues();
//check to see if this is type 0 user submit
$type = base64_decode($allFormFields['type']);
if(!is_numeric($type)){
return;
}else{
if($type == 0){
$url = $modx->makeUrl(13629);
$modx->sendRedirect($url);
}
}
//testing info
//$allFormFields['City'] = 'Anaheim';
//$allFormFields['state'] = 'California';
//$allFormFields['Country'] = 'United States';
//this is a business listing
//echo "<pre>";
//print_r($allFormFields);
//echo "</pre>";
$pid = base64_decode($allFormFields['pid']);
//check if we have the city
$checkers = array('Country','state','City');
$opid = $pid;
$row['id'] = $pid;
//$row = TRUE;
foreach ($checkers as $key => $value) {
$value = trim($value);
if(empty($allFormFields[$value])){
continue;
}
if($row == false){
$newCity = TRUE;
continue;
}
$c = $modx->newQuery('modResource');
$c->select('id');
// echo "Checking {$allFormFields[$value]} WITH PARENT {$row['modResource_id']}<br/>";
$where = array('LOWER(pagetitle) ="'.strtolower($allFormFields[$value]).'"',
'parent' => $row['id']);
$c->where($where);
$c->limit(1);
$stmt = $c->prepare();
// echo $c->toSql();
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
}
//md5 pricing is calculated on number of child md5(ids * 9348378272)
if($newCity){
//this city is not in our database we are going to be giving them base pricing
$row['id'] = 13677;
}
//var_dump($childIds);
$url = $modx->makeUrl(28,'','req='.$row['id']);
$modx->sendRedirect($url);
return;
?>