PageRenderTime 51ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_hotproperty/sef_ext.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 828 lines | 523 code | 187 blank | 118 comment | 140 complexity | 8e577ba550158a052832f520e7006e84 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. // sef_ext_create.html.php
  3. /**
  4. * Hot Property
  5. *
  6. * This extension will give the SEF advance style URLs to Hot Property
  7. * Place this file (sef_ext_create.php) in the main component directory:
  8. * /components/com_hotproperty/
  9. *
  10. * For SEF advance > v3.7
  11. *
  12. * @package Hot Property 0.9
  13. * @copyright (C) 2004-2006 Lee Cher Yeong
  14. * @url http://www.Mosets.com/
  15. * @author Lee Cher Yeong <hotproperty@mosets.com>**/
  16. defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  17. # Include the config file
  18. global $mosConfig_absolute_path;
  19. require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' );
  20. define("_HP_SEF_PROPERTY", "property");
  21. define("_HP_SEF_COMPANY", "company");
  22. define("_HP_SEF_EMAIL", "email");
  23. define("_HP_SEF_FEATURED", "featured");
  24. define("_HP_SEF_SENDENQUIRY", "sendemail");
  25. define("_HP_SEF_SEARCH", "search");
  26. define("_HP_SEF_ADVSEARCH", "advsearch");
  27. define("_HP_SEF_SEARCHRESULT", "advsearchr");
  28. define("_HP_SEF_VIEWAGENT", "viewagent");
  29. define("_HP_SEF_MANAGEPROP", "manage");
  30. define("_HP_SEF_EDITAGENT", "editagent");
  31. define("_HP_SEF_ADDPROPERTY", "addproperty");
  32. define("_HP_SEF_EDITPROPERTY", "editproperty");
  33. class sef_hotproperty {
  34. /********************************************************
  35. * CREATE
  36. ********************************************************/
  37. /**
  38. * Creates the SEF advance URL out of the Mambo request
  39. * Input: $string, string, The request URL (index.php?option=com_example&Itemid=$Itemid)
  40. * Output: $sefstring, string, SEF advance URL ($var1/$var2/)
  41. **/
  42. function create ($string) {
  43. global $database;
  44. $sefstring = "";
  45. # View Property
  46. if (eregi("&amp;task=view&amp;id=",$string)) {
  47. $temp = split("&amp;id=", $string);
  48. $temp = split("&", $temp[1]);
  49. $property_id = $temp[0];
  50. if ( is_numeric($property_id) ) {
  51. $database->setQuery( "SELECT t.name AS type_name, p.name AS property_name FROM #__hp_properties AS p"
  52. . "\nLEFT JOIN #__hp_prop_types AS t ON p.type = t.id"
  53. . "\nWHERE p.id = '".$property_id."'"
  54. . "\nLIMIT 1"
  55. );
  56. $database->loadObject( $row );
  57. $sefstring .= _HP_SEF_PROPERTY."/".sefencode($row->type_name)."/".sefencode($row->property_name)."/";
  58. }
  59. }
  60. # View Type
  61. if (eregi("&amp;task=viewtype&amp;id=",$string)) {
  62. $temp = split("&amp;id=", $string);
  63. $temp = split("&", $temp[1]);
  64. $type_id = $temp[0];
  65. if ( is_numeric($type_id) ) {
  66. $database->setQuery( "SELECT t.name AS type_name FROM #__hp_prop_types AS t"
  67. . "\nWHERE t.id = '".$type_id."'"
  68. . "\nLIMIT 1"
  69. );
  70. $database->loadObject( $row );
  71. $sefstring .= _HP_SEF_PROPERTY."/".sefencode($row->type_name)."/";
  72. // --- Sort & Order
  73. $temp = split("&amp;sort=", $string);
  74. if (!empty($temp[1])) {
  75. $temp = split("&", $temp[1]);
  76. $sort = $temp[0];
  77. } else {
  78. //$sort='';
  79. global $hp_default_order;
  80. $sort = $hp_default_order;
  81. }
  82. $temp = split("&amp;order=", $string);
  83. if (!empty($temp[1])) {
  84. $temp = split("&", $temp[1]);
  85. $order = $temp[0];
  86. } else {
  87. //$order='';
  88. global $hp_default_order2;
  89. $order = $hp_default_order2;
  90. }
  91. if ( $sort == '' ) {
  92. // global $hp_default_order;
  93. // $sort = $hp_default_order;
  94. }
  95. if ( $order == '' ) {
  96. // global $hp_default_order2;
  97. // $order = $hp_default_order2;
  98. }
  99. // limit & limitstart
  100. $temp = split("&amp;limit=", $string);
  101. if(!empty($temp[1])) {
  102. $temp = split("&", $temp[1]);
  103. $limit = $temp[0];
  104. } else {
  105. global $hp_default_limit;
  106. $limit = $hp_default_limit;
  107. }
  108. $temp = split("&amp;limitstart=", $string);
  109. if(!empty($temp[1])) {
  110. $temp = split("&", $temp[1]);
  111. $limitstart = $temp[0];
  112. } else {
  113. $limitstart = 0;
  114. }
  115. if ( $limit == '' ) {
  116. // global $hp_default_limit;
  117. // $limit = $hp_default_limit;
  118. }
  119. if ( $limitstart == '' ) {
  120. // $limitstart = 0;
  121. }
  122. global $hp_default_order,$hp_default_order2,$hp_default_limit;
  123. if ( $sort <> '' && $order <> '' && !( $sort == $hp_default_order && $order == $hp_default_order2 && $limitstart == 0 && $limit == $hp_default_limit) ) {
  124. $sefstring .= $sort."/".$order."/";
  125. if ( $limit <> '' && $limitstart <> '' ) {
  126. $sefstring .= $limit."/".$limitstart."/";
  127. }
  128. }
  129. } // END IF is_numeric
  130. }
  131. # View Featured
  132. if (eregi("&amp;task=viewfeatured",$string)) {
  133. $sefstring .= _HP_SEF_PROPERTY."/"._HP_SEF_FEATURED."/";
  134. // limit
  135. $temp = split("&amp;limit=", $string);
  136. if( isset($temp[1]) ) {
  137. $temp = split("&", $temp[1]);
  138. $limit = $temp[0];
  139. } else {
  140. $limit = '';
  141. }
  142. // limitstart
  143. $temp = split("&amp;limitstart=", $string);
  144. if( isset($temp[1]) ) {
  145. $temp = split("&", $temp[1]);
  146. $limitstart = $temp[0];
  147. } else {
  148. $limitstart = '';
  149. }
  150. if ( $limit <> '' && $limitstart <> '' ) {
  151. $sefstring .= $limit."/".$limitstart."/";
  152. }
  153. }
  154. # View Agent
  155. if (eregi("&amp;task=viewagent&amp;id=",$string)) {
  156. $temp = split("&amp;id=", $string);
  157. $temp = split("&", $temp[1]);
  158. $agent_id = $temp[0];
  159. // This condition allows listagent module to work so that $agent_id can be a javascript expression.
  160. if ( is_numeric($agent_id) ) {
  161. $database->setQuery( "SELECT a.name AS agent_name, c.name AS company_name FROM #__hp_agents AS a"
  162. . "\nLEFT JOIN #__hp_companies AS c ON a.company = c.id"
  163. . "\nWHERE a.id = '".$agent_id."'"
  164. . "\nLIMIT 1"
  165. );
  166. $database->loadObject( $row );
  167. }
  168. // Default virtual directory would be: _HP_SEF_COMPANY/company_name/agent_name/.
  169. // There is an alternative way to represent this as to allow List Agents module to work: _HP_SEF_VIEWAGENT/agent_id
  170. if ( !is_numeric($agent_id) || count($row) <= 0 ) {
  171. $sefstring .= _HP_SEF_VIEWAGENT."/".$agent_id;
  172. } else {
  173. $sefstring .= _HP_SEF_COMPANY."/".sefencode($row->company_name)."/".sefencode($row->agent_name)."/";
  174. }
  175. // limit
  176. $temp = split("&amp;limit=", $string);
  177. if( isset($temp[1]) ) {
  178. $temp = split("&", $temp[1]);
  179. $limit = $temp[0];
  180. } else {
  181. $limit='';
  182. }
  183. // limitstart
  184. $temp = split("&amp;limitstart=", $string);
  185. if( isset($temp[1]) ) {
  186. $temp = split("&", $temp[1]);
  187. $limitstart = $temp[0];
  188. } else {
  189. $limitstart='';
  190. }
  191. if ( $limit <> '' && $limitstart <> '' ) {
  192. $sefstring .= $limit."/".$limitstart."/";
  193. }
  194. }
  195. # View Company / View Company Email / Send Company Email
  196. if ( eregi("&amp;task=viewco&amp;id=",$string) || eregi("&amp;task=viewcoemail&amp;id=",$string) || eregi("&amp;task=sendenquiry&amp;id=",$string) ) {
  197. $temp = split("&amp;id=", $string);
  198. $temp = split("&", $temp[1]);
  199. $company_id = $temp[0];
  200. // This condition allows listagent module to work so that $agent_id can be a javascript expression.
  201. if ( is_numeric($company_id) ) {
  202. $database->setQuery( "SELECT c.name AS company_name FROM #__hp_companies AS c"
  203. . "\nWHERE c.id = '".$company_id."'"
  204. . "\nLIMIT 1"
  205. );
  206. $database->loadObject( $row );
  207. }
  208. # View Company
  209. if ( eregi("&amp;task=viewco&amp;id=",$string) ) {
  210. // Default virtual directory would be: _HP_SEF_COMPANY/company_name/.
  211. // There is an alternative way to represent this as to allow List Companies module to work: _HP_SEF_COMPANY/company_id
  212. if ( !is_numeric($company_id) || count($row) <= 0 ) {
  213. $sefstring .= _HP_SEF_COMPANY."/".$company_id;
  214. } else {
  215. $sefstring .= _HP_SEF_COMPANY."/".sefencode($row->company_name)."/";
  216. }
  217. // limit
  218. $temp = split("&amp;limit=", $string);
  219. if( isset($temp[1]) ) {
  220. $temp = split("&", $temp[1]);
  221. $limit = $temp[0];
  222. } else {
  223. $limit='';
  224. }
  225. // limitstart
  226. $temp = split("&amp;limitstart=", $string);
  227. if( isset($temp[1]) ) {
  228. $temp = split("&", $temp[1]);
  229. $limitstart = $temp[0];
  230. } else {
  231. $limitstart = '';
  232. }
  233. if ( $limit <> '' && $limitstart <> '' ) {
  234. $sefstring .= $limit."/".$limitstart."/";
  235. }
  236. # View Company Email
  237. } elseif ( eregi("&amp;task=viewcoemail&amp;id=",$string) ) {
  238. $sefstring .= _HP_SEF_EMAIL."/".sefencode($row->company_name)."/";
  239. # Send Enquiry Email
  240. } elseif (eregi("&amp;task=sendenquiry&amp;id=",$string) ) {
  241. $sefstring .= _HP_SEF_SENDENQUIRY."/".$company_id."/"; // Sendenquiry does not use this ID to determine whether this is directed to company or agent, the form has a hidden field called 'sbj' to distinguish this.
  242. }
  243. }
  244. # View Agent Email
  245. if ( eregi("&amp;task=viewagentemail&amp;id=",$string) ) {
  246. $temp = split("&amp;id=", $string);
  247. $temp = split("&", $temp[1]);
  248. $agent_id = $temp[0];
  249. if ( is_numeric($agent_id) ) {
  250. $database->setQuery( "SELECT a.name AS agent_name, c.name AS company_name FROM #__hp_agents AS a"
  251. . "\nLEFT JOIN #__hp_companies AS c ON a.company = c.id"
  252. . "\nWHERE a.id = '".$agent_id."'"
  253. . "\nLIMIT 1"
  254. );
  255. $database->loadObject( $row );
  256. $sefstring .= _HP_SEF_EMAIL."/".sefencode($row->company_name)."/".sefencode($row->agent_name)."/";
  257. }
  258. }
  259. # Standard Search
  260. if (eregi("&amp;task=search",$string)) {
  261. global $mosConfig_absolute_path, $sufix;
  262. require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' );
  263. // search string
  264. $temp = split("&amp;search=", $string);
  265. $temp = split("&", $temp[1]);
  266. // This condition prevents url encoding to be performed on javascript expression in standard search form.
  267. if ( strpos(trim($temp[0]), "encodeURI(document.searchfrm.search.value)") >= 0 ||
  268. strpos(trim($temp[0]), "encodeURI(document.searchfrm_mod.search.value)") >= 0 ) {
  269. $search = $temp[0];
  270. } else {
  271. $search = urlencode($temp[0]);
  272. }
  273. // type
  274. $temp = split("&amp;type=", $string);
  275. $temp = split("&", $temp[1]);
  276. $type = $temp[0];
  277. // limit
  278. $temp = split("&amp;limit=", $string);
  279. $temp = split("&", $temp[1]);
  280. $limit = $temp[0];
  281. if ( $limit == '' ) {
  282. $limit = $hp_default_limit_search;
  283. }
  284. // limitstart
  285. $temp = split("&amp;limitstart=", $string);
  286. $temp = split("&", $temp[1]);
  287. $limitstart = $temp[0];
  288. if ( $limitstart == '' ) {
  289. $limitstart = 0;
  290. }
  291. $sefstring .= _HP_SEF_SEARCH."/".$type."/".$limit."/".$limitstart."/".$search;
  292. if ( !empty($sufix) ) {
  293. $sefstring .= "/";
  294. }
  295. }
  296. # Advanced Search
  297. if (eregi("&amp;task=advsearch",$string)) {
  298. $sefstring .= _HP_SEF_ADVSEARCH."/";
  299. }
  300. # Advanced Search Result
  301. if (eregi("&amp;task=asearch",$string)) {
  302. $sefstring .= _HP_SEF_SEARCHRESULT."/";
  303. // search_id
  304. $temp = split("&amp;search_id=", $string);
  305. if ( isset($temp[1]) ) {
  306. $temp = split("&", $temp[1]);
  307. $search_id = $temp[0];
  308. } else {
  309. $search_id = '';
  310. }
  311. // limit
  312. $temp = split("&amp;limit=", $string);
  313. if ( isset($temp[1]) ) {
  314. $temp = split("&", $temp[1]);
  315. $limit = $temp[0];
  316. } else {
  317. $limit = '';
  318. }
  319. // limitstart
  320. $temp = split("&amp;limitstart=", $string);
  321. if ( isset($temp[1]) ) {
  322. $temp = split("&", $temp[1]);
  323. $limitstart = $temp[0];
  324. } else {
  325. $limitstart = '';
  326. }
  327. if ( $search_id <> '' ) {
  328. $sefstring .= $search_id ."/";
  329. if ( $limit <> '' && $limitstart <> '' ) {
  330. $sefstring .= $limit ."/". $limitstart ."/";
  331. } // End if
  332. } // End if
  333. }
  334. # Manage Property
  335. if (eregi("&amp;task=manageprop",$string)) {
  336. $sefstring .= _HP_SEF_MANAGEPROP."/";
  337. // limit
  338. $temp = split("&amp;limit=", $string);
  339. $temp = split("&", $temp[1]);
  340. $limit = $temp[0];
  341. // limitstart
  342. $temp = split("&amp;limitstart=", $string);
  343. $temp = split("&", $temp[1]);
  344. $limitstart = $temp[0];
  345. if ( $limit <> '' && $limitstart <> '' ) {
  346. $sefstring .= $limit ."/". $limitstart ."/";
  347. }
  348. }
  349. # Edit Agent
  350. if (eregi("&amp;task=editagent",$string)) {
  351. $sefstring .= _HP_SEF_EDITAGENT."/";
  352. }
  353. # Add Property
  354. if (eregi("&amp;task=addprop",$string)) {
  355. $sefstring .= _HP_SEF_ADDPROPERTY."/";
  356. }
  357. # Edit Property
  358. if (eregi("&amp;task=editprop",$string)) {
  359. $temp = split("&amp;id=", $string);
  360. $temp = split("&", $temp[1]);
  361. $id = $temp[0];
  362. // Using IDs instead of Property name to aviod conflicts with same property name.
  363. $sefstring .= _HP_SEF_EDITPROPERTY."/".$id."/";
  364. }
  365. return $sefstring;
  366. }
  367. /********************************************************
  368. * REVERT
  369. ********************************************************/
  370. /**
  371. * Reverts to the Mambo query string out of the SEF advance URL
  372. * Input:
  373. * $url_array, array, The SEF advance URL split in arrays (first custom virtual directory beginning at $pos+1)
  374. * $pos, int, The position of the first virtual directory (component)
  375. * Output: $QUERY_STRING, string, Mambo query string (var1=$var1&var2=$var2)
  376. * Note that this will be added to already defined first part (option=com_example&Itemid=$Itemid)
  377. **/
  378. function revert ($url_array, $pos) {
  379. global $database;
  380. // define all variables you pass as globals
  381. // global $var1, $var2;
  382. // Examine the SEF advance URL and extract the variables building the query string
  383. $QUERY_STRING = "";
  384. if ( isset($url_array[$pos+2]) ) {
  385. switch($url_array[$pos+2]) {
  386. # Types & Properties
  387. case _HP_SEF_PROPERTY:
  388. # View Property
  389. if (isset($url_array[$pos+4]) && $url_array[$pos+4]!="" && $url_array[$pos+5]=="") {
  390. $type_name = sefdecode($url_array[$pos+3]);
  391. $property_name = sefdecode($url_array[$pos+4]);
  392. $database->setQuery( "SELECT p.id FROM #__hp_properties AS p "
  393. . "\nLEFT JOIN #__hp_prop_types AS t ON t.id = p.type"
  394. . "\nWHERE p.name ='".$property_name."' AND t.name ='".$type_name."' LIMIT 1"
  395. );
  396. $property_id = $database->loadResult();
  397. $_GET['task'] = "view";
  398. $_REQUEST['task'] = "view";
  399. $_GET['id'] = $property_id;
  400. $_REQUEST['id'] = $property_id;
  401. $QUERY_STRING .= "&task=view&id=$property_id";
  402. } elseif ( $url_array[$pos+3] == _HP_SEF_FEATURED ) {
  403. # View Featured
  404. $_GET['task'] = "viewfeatured";
  405. $_REQUEST['task'] = "viewfeatured";
  406. $QUERY_STRING .= "&task=viewfeatured";
  407. $limit = $url_array[$pos+4];
  408. if ( isset($url_array[$pos+5]) ) {
  409. $limitstart = $url_array[$pos+5];
  410. } else {
  411. $limitstart = 0;
  412. }
  413. // Limit & Limit Start
  414. if ( $limit <> '' && $limitstart <> '' ) {
  415. $_GET['limit'] = $limit;
  416. $_REQUEST['limit'] = $limit;
  417. $_GET['limitstart'] = $limitstart;
  418. $_REQUEST['limitstart'] = $limitstart;
  419. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  420. } // End if
  421. } else {
  422. # View Type
  423. $type_name = sefdecode($url_array[$pos+3]);
  424. $database->setQuery( "SELECT t.id FROM #__hp_prop_types AS t WHERE t.name ='".$type_name."' LIMIT 1" );
  425. $type_id = $database->loadResult();
  426. $_GET['task'] = "viewtype";
  427. $_REQUEST['task'] = "viewtype";
  428. $_GET['id'] = $type_id;
  429. $_REQUEST['id'] = $type_id;
  430. $QUERY_STRING .= "&task=viewtype&id=$type_id";
  431. if( isset($url_array[$pos+4]) ) $sort = $url_array[$pos+4];
  432. if( isset($url_array[$pos+5]) ) $order = $url_array[$pos+5];
  433. if( isset($url_array[$pos+6]) ) $limit = $url_array[$pos+6];
  434. if( isset($url_array[$pos+7]) ) $limitstart = $url_array[$pos+7];
  435. // Sort & Order
  436. if ( $sort <> '' && $order <> '' ) {
  437. $_GET['sort'] = $sort;
  438. $_REQUEST['sort'] = $sort;
  439. $_GET['order'] = $order;
  440. $_REQUEST['order'] = $order;
  441. $QUERY_STRING .= "&sort=$sort&order=$order";
  442. // Limit & Limit Start
  443. if ( $limit <> '' && $limitstart <> '' ) {
  444. $_GET['limit'] = $limit;
  445. $_REQUEST['limit'] = $limit;
  446. $_GET['limitstart'] = $limitstart;
  447. $_REQUEST['limitstart'] = $limitstart;
  448. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  449. } // End if
  450. } // End if
  451. }
  452. break;
  453. # Companies & Agents
  454. // _HP_SEF_COMPANY/company_name/agent_name/
  455. case _HP_SEF_COMPANY:
  456. # View Agent
  457. // _HP_SEF_COMPANY/company_name/agent_name/
  458. if (isset($url_array[$pos+2]) && isset($url_array[$pos+3]) && isset($url_array[$pos+4]) && $url_array[$pos+2]!="" && (
  459. ($url_array[$pos+3] == '' && $url_array[$pos+4] == '') || ($url_array[$pos+3] <> '' && $url_array[$pos+4] <> '')
  460. ) ) {
  461. $agent_name = sefdecode($url_array[$pos+4]);
  462. $company_name = sefdecode($url_array[$pos+3]);
  463. $database->setQuery( "SELECT a.id FROM (#__hp_agents AS a, #__hp_companies AS c) "
  464. . "\n WHERE c.id=a.company AND a.name ='".$agent_name."' AND c.name = '".$company_name."' LIMIT 1" );
  465. $agent_id = $database->loadResult();
  466. $_GET['task'] = "viewagent";
  467. $_REQUEST['task'] = "viewagent";
  468. $_GET['id'] = $agent_id;
  469. $_REQUEST['id'] = $agent_id;
  470. $QUERY_STRING .= "&task=viewagent&id=$agent_id";
  471. // Limit & Limit Start
  472. $limit = $url_array[$pos+5];
  473. $limitstart = $url_array[$pos+6];
  474. if ( $limit <> '' && $limitstart <> '' ) {
  475. $_GET['limit'] = $limit;
  476. $_REQUEST['limit'] = $limit;
  477. $_GET['limitstart'] = $limitstart;
  478. $_REQUEST['limitstart'] = $limitstart;
  479. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  480. }
  481. } else {
  482. # View Company
  483. // _HP_SEF_COMPANY/company_name/
  484. // _HP_SEF_COMPANY/company_id
  485. $company_name = sefdecode($url_array[$pos+3]);
  486. $database->setQuery( "SELECT c.id FROM #__hp_companies AS c WHERE c.name ='".$company_name."' LIMIT 1" );
  487. $company_id = $database->loadResult();
  488. if ( $company_id == '' && is_numeric($company_name) ) {
  489. $company_id = $company_name;
  490. }
  491. $_GET['task'] = "viewco";
  492. $_REQUEST['task'] = "viewco";
  493. $_GET['id'] = $company_id;
  494. $_REQUEST['id'] = $company_id;
  495. $QUERY_STRING .= "&task=viewco&id=$company_id";
  496. // Limit & Limit Start
  497. if(isset($url_array[$pos+4])) $limit = $url_array[$pos+4];
  498. if(isset($url_array[$pos+5])) $limitstart = $url_array[$pos+5];
  499. if ( $limit <> '' && $limitstart <> '' ) {
  500. $_GET['limit'] = $limit;
  501. $_REQUEST['limit'] = $limit;
  502. $_GET['limitstart'] = $limitstart;
  503. $_REQUEST['limitstart'] = $limitstart;
  504. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  505. }
  506. }
  507. break;
  508. # View Agent
  509. // _HP_SEF_VIEWAGENT/agent_id
  510. case _HP_SEF_VIEWAGENT:
  511. $agent_id = sefdecode($url_array[$pos+3]);
  512. $_GET['task'] = "viewagent";
  513. $_REQUEST['task'] = "viewagent";
  514. $_GET['id'] = $agent_id;
  515. $_REQUEST['id'] = $agent_id;
  516. $QUERY_STRING .= "&task=viewagent&id=$agent_id";
  517. break;
  518. case _HP_SEF_EMAIL:
  519. # View Company Email
  520. if ( $url_array[$pos+4] == '' ) {
  521. $company_name = sefdecode($url_array[$pos+3]);
  522. $database->setQuery( "SELECT c.id FROM #__hp_companies AS c WHERE c.name ='".$company_name."' LIMIT 1" );
  523. $company_id = $database->loadResult();
  524. $_GET['id'] = $company_id;
  525. $_REQUEST['id'] = $company_id;
  526. $_GET['task'] = "viewcoemail";
  527. $_REQUEST['task'] = "viewcoemail";
  528. $QUERY_STRING .= "&task=viewcoemail&id=$company_id";
  529. # View Agent Email
  530. } else {
  531. $company_name = sefdecode($url_array[$pos+3]);
  532. $agent_name = sefdecode($url_array[$pos+4]);
  533. $database->setQuery( "SELECT a.id FROM #__hp_agents AS a"
  534. . "\nLEFT JOIN #__hp_companies AS c ON c.id = a.company"
  535. . "\nWHERE c.name ='".$company_name."'"
  536. . "\nAND a.name ='".$agent_name."'"
  537. . "\nLIMIT 1"
  538. );
  539. $agent_id = $database->loadResult();
  540. $_GET['id'] = $agent_id;
  541. $_REQUEST['id'] = $agent_id;
  542. $_GET['task'] = "viewagentemail";
  543. $_REQUEST['task'] = "viewagentemail";
  544. $QUERY_STRING .= "&task=viewagentemail&id=$agent_id";
  545. }
  546. break;
  547. case _HP_SEF_SENDENQUIRY:
  548. # Send Enquiry Email
  549. $company_id = sefdecode($url_array[$pos+3]);
  550. $_GET['id'] = $company_id;
  551. $_REQUEST['id'] = $company_id;
  552. $_GET['task'] = "sendenquiry";
  553. $_REQUEST['task'] = "sendenquiry";
  554. $QUERY_STRING .= "&task=sendenquiry&id=$company_id";
  555. break;
  556. case _HP_SEF_SEARCH:
  557. # Standard Search
  558. $_GET['task'] = "search";
  559. $_REQUEST['task'] = "search";
  560. $_GET['type'] = $url_array[$pos+3];
  561. $_REQUEST['type'] = $url_array[$pos+3];
  562. $_GET['limit'] = $url_array[$pos+4];
  563. $_REQUEST['limit'] = $url_array[$pos+4];
  564. $_GET['limitstart'] = $url_array[$pos+5];
  565. $_REQUEST['limitstart'] = $url_array[$pos+5];
  566. $_GET['search'] = urldecode($url_array[$pos+6]);
  567. $_REQUEST['search'] = urldecode($url_array[$pos+6]);
  568. $QUERY_STRING .= "&task=search&type=".$url_array[$pos+3]."&limit=".$url_array[$pos+4]."&limitstart=".$url_array[$pos+5]."&search=".urldecode($url_array[$pos+6]);
  569. break;
  570. case _HP_SEF_ADVSEARCH:
  571. # Advanced Search
  572. $_GET['task'] = "advsearch";
  573. $_REQUEST['task'] = "advsearch";
  574. $QUERY_STRING .= "&task=advsearch";
  575. break;
  576. case _HP_SEF_SEARCHRESULT:
  577. # Advanced Search Result
  578. $_GET['task'] = "asearch";
  579. $_REQUEST['task'] = "asearch";
  580. $QUERY_STRING .= "&task=asearch";
  581. // search_id
  582. $search_id = $url_array[$pos+3];
  583. // Limit & Limit Start
  584. if( isset($url_array[$pos+4]) ) $limit = $url_array[$pos+4];
  585. if( isset($url_array[$pos+5]) ) $limitstart = $url_array[$pos+5];
  586. if ( $search_id <> '' ) {
  587. $_GET['search_id'] = $search_id;
  588. $_REQUEST['search_id'] = $search_id;
  589. $QUERY_STRING .= "&search_id=$search_id";
  590. if ( $limit <> '' && $limitstart <> '' ) {
  591. $_GET['limit'] = $limit;
  592. $_REQUEST['limit'] = $limit;
  593. $_GET['limitstart'] = $limitstart;
  594. $_REQUEST['limitstart'] = $limitstart;
  595. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  596. }
  597. }
  598. break;
  599. case _HP_SEF_MANAGEPROP:
  600. # Manage Property
  601. $_GET['task'] = "manageprop";
  602. $_REQUEST['task'] = "manageprop";
  603. $QUERY_STRING .= "&task=manageprop";
  604. // Limit & Limit Start
  605. $limit = $url_array[$pos+3];
  606. $limitstart = $url_array[$pos+4];
  607. if ( $limit <> '' && $limitstart <> '' ) {
  608. $_GET['limit'] = $limit;
  609. $_REQUEST['limit'] = $limit;
  610. $_GET['limitstart'] = $limitstart;
  611. $_REQUEST['limitstart'] = $limitstart;
  612. $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
  613. }
  614. break;
  615. case _HP_SEF_EDITAGENT:
  616. # Edit Agent
  617. $_GET['task'] = "editagent";
  618. $_REQUEST['task'] = "editagent";
  619. $QUERY_STRING .= "&task=editagent";
  620. break;
  621. case _HP_SEF_ADDPROPERTY:
  622. # Add Property
  623. $_GET['task'] = "addprop";
  624. $_REQUEST['task'] = "addprop";
  625. $QUERY_STRING .= "&task=addprop";
  626. break;
  627. case _HP_SEF_EDITPROPERTY:
  628. # Edit Property
  629. $id = sefdecode($url_array[$pos+3]);
  630. $_GET['id'] = $id;
  631. $_REQUEST['id'] = $id;
  632. $_GET['task'] = "editprop";
  633. $_REQUEST['task'] = "editprop";
  634. $QUERY_STRING .= "&task=editprop&id=$id";
  635. break;
  636. }
  637. }
  638. return $QUERY_STRING;
  639. }
  640. }
  641. ?>