-
Notifications
You must be signed in to change notification settings - Fork 1
/
comparison_list.php
executable file
·117 lines (103 loc) · 4.13 KB
/
comparison_list.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* AJAX called file for manipulating with users' comparison list
*
* @package RealEstate
* @subpackage Public Mode
* @copyright Pilot Group <http://www.pilotgroup.net/>
* @author $Author: irina $
* @version $Revision: 1.1 $ $Date: 2008/09/25 10:38:23 $
**/
include "./include/config.php";
include "./common.php";
include "./include/functions_xml.php";
include "./include/functions_auth.php";
include "./include/functions_index.php";
include "./include/functions_common.php";
include "./include/class.calendar_event.php";
header ("Content-Type: text/html; charset=utf-8");
$lang["default_select"] = GetLangContent("default_select");
$user = auth_index_user();
$action = (isset($_REQUEST["action"]) && !empty($_REQUEST["action"])) ? $_REQUEST["action"] : "";
$id_ad = (isset($_REQUEST["id_ad"]) && !empty($_REQUEST["id_ad"])) ? intval($_REQUEST["id_ad"]) : 0;
if ($action == "") {
/**
* Add listing to users' comparison list
*/
if ($id_ad) {
//for guest user
$and_str = ($user[3] == 1) ? "AND session='".$user[12]."'" : "";
$ins_str = ($user[3] == 1) ? ", session='".$user[12]."'" : "";
$strSQL = "SELECT id FROM ".COMPARISON_LIST_TABLE." ".
"WHERE id_user='".$user[0]."' AND id_ad='".$id_ad."' $and_str";
$rs = $dbconn->Execute($strSQL);
if ($rs->RowCount() == 0) {
$strSQL = "INSERT INTO ".COMPARISON_LIST_TABLE." SET ".
"id_user='".$user[0]."', id_ad='".$id_ad."'".$ins_str;
$rs = $dbconn->Execute($strSQL);
}
echo "<b>".$lang["default_select"]["in_your_comparison_list"]."</b>";
}
} elseif ($action == "get_list") {
/**
* Get users' comparison list
*/
$ads = GetUserComparisonIds();
if (count($ads) == 0) {
echo "empty";
} else {
foreach ($ads as $ad) {
echo "<div class='comp_list_item'><a href=\"".$config["server"].$config["site_root"]."/viewprofile.php?id=".$ad["id"]."\">".$ad["fname"]."</a><a href='#' onclick=\"DeleteFromComparisonList('comparison_list', ".$ad["id"]."); title='".$lang["default_select"]["delete_from_comparison"]."'\"><img src='".$config["server"].$config["site_root"].$config["index_theme_path"].$config["index_theme_images_path"]."/delete.gif' alt='".$lang["default_select"]["delete_from_comparison"]."' class='comp_list_icon'></a><br>".$lang["default_select"][$ad["type"]]." ".$ad["realty_type"]."</div>";
}
}
} elseif ($action == "get_str") {
/**
* Get users' comparison list
*/
$ads = GetUserComparisonIds();
if (count($ads) == 0) {
echo "empty";
} else {
echo " <a href=\"".$config["server"].$config["site_root"]."/compare.php\">".$lang["default_select"]["comparison_list"]." (".count($ads).")</a> <font class='text'>|</font> ";
}
} elseif ($action == "clear_list") {
//for guest user
$and_str = ($user[3] == 1) ? "AND session='".$user[12]."'" : "";
$strSQL = "SELECT id_ad FROM ".COMPARISON_LIST_TABLE." ".
"WHERE id_user='".$user[0]."' $and_str";
$rs = $dbconn->Execute($strSQL);
while (!$rs->EOF) {
$row = $rs->getRowAssoc( false );
echo GetAddElemCode($row["id_ad"]);
$rs->MoveNext();
}
/**
* Clear users' comparison list
*/
$strSQL = "DELETE FROM ".COMPARISON_LIST_TABLE." ".
"WHERE id_user='".$user[0]."' $and_str";
$rs = $dbconn->Execute($strSQL);
} elseif ($action == "delete_ad") {
/**
* Delete ad from users' comparison list
*/
if ($id_ad) {
$from_compare = (isset($_REQUEST["par"]) && $_REQUEST["par"] == "from_compare") ? true : false;
if (!$from_compare) {
echo GetAddElemCode($id_ad);
}
//for guest user
$and_str = ($user[3] == 1) ? "AND session='".$user[12]."'" : "";
$strSQL = "DELETE FROM ".COMPARISON_LIST_TABLE." ".
"WHERE id_user='".$user[0]."' AND id_ad='$id_ad' $and_str";
$rs = $dbconn->Execute($strSQL);
if ($from_compare) {
header("Location: ".$config["server"].$config["site_root"]."/compare.php");
}
}
}
function GetAddElemCode($id_ad) {
global $lang;
return "if (document.getElementById('listing_add_to_comparison_".$id_ad."')) document.getElementById('listing_add_to_comparison_".$id_ad."').innerHTML=\"<a href='#' onclick=\\\"javascript: AddToComparisonList('".$id_ad."', 'listing_add_to_comparison_".$id_ad."');\\\">".$lang["default_select"]["add_to_comparison_list"]."</a>\";";
}
?>