getPath( 'front_html')); include_once(EA_SITE_PATH.DS."user.estateagent.php"); require_once(EA_SITE_PATH.DS.'templates'.DS.'template.estateagent.php'); require_once(EA_SITE_PATH.DS.'helpers'.DS.'search.estateagent.php'); require_once(EA_SITE_PATH.DS.'helpers'.DS.'helper.estateagent.php'); $document->addStyleSheet('components/com_estateagent/assets/messages.css'); $eaconf=&EAConf::getInstance(); $eahelper=&EA_Helper::getInstance(); $my = &JFactory::getUser(); $database = &JFactory::getDBO(); global $mainframe; // check session-handling if(!session_is_registered("sres")) session_register("sres"); $act = JRequest::getString( 'act', 'cat' ); $task = JRequest::getString('task'); $id = JRequest::getInt( 'id', 0 ); $cid = JArrayHelper::getValue( $_REQUEST, 'cid', array(0) ); $limitstart = JRequest::getInt( 'limitstart', 0); $limit = $mainframe->getUserStateFromRequest( 'com_estateagent.limit', 'limit', $eaconf->ea_perpage, 'int' ); $gid = $my->gid; // Check if EstateAgent is offline if ($eaconf->ea_offline == 1) { require(EA_SITE_PATH.DS.'offline.php'); return; }//else { //===========================Header==================================================== function EAHeader() { global $mainframe; $pathway =& $mainframe->getPathway(); $eaconf=&EAConf::getInstance(); $act = JRequest::getString( 'act', 'cat' ); $id = JRequest::getInt( 'id', 0 ); if($act=='pdfexport' ) return; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // pathway if ($act == "showCE" )EA_helper::catPathway($id); else if ($act == "showEO") EA_helper::objPathway($id); else if ($act=="profileAgent") EA_helper::agentPathway($id); else if ($act=="listAO")EA_helper::listagentPathway($id); else if($act=="easearch") $pathway->addItem(JText::_('EA_FASTSEARCH'),''); else if($act=="eaadmin") $pathway->addItem(JText::_('Administration'),''); else if ($act=="listAgents") $pathway->addItem(JText::_('EA_AGENT_LIST'),''); else if ($act == "print") return; else if ($act == "pdfexport") return; // menu bar if ($eaconf->ea_enable_main_menu): include_once(EA_SITE_PATH.DS.'helpers'.DS.'mainmenu.estateagent.php'); endif; ?> loadRenderer('module'); $options = array('style' => 'raw'); $module = JModuleHelper::getModule('mod_ea_properties'); //$module->params = "heading=2\nlimit=10"; echo $renderer->render($module, $options);*/ $document = &JFactory::getDocument(); $renderer = $document->loadRenderer('modules'); $options = array('style' => 'xhtml'); $position = 'ea_top_module'; echo $renderer->render($position, $options, null); //echo "
"; return; } //=======================Footer =========================================================== function EAFooter() { global $mainframe; $eaconf=&EAConf::getInstance(); //echo "
"; switch($eaconf->ea_footer) { case "2": $document=& JFactory::getDocument(); $document->addCustomTag(""); ?>
by EA Improved team
:: Estate Agent Improved by EA Improved team ::
ea_allowsubmission==1) { if (authorizeFrontEnd()==false) { $mainframe->redirect( 'index.php?option=com_estateagent', JText::_('ALERTNOTAUTH') ); } } require( EA_ADMIN_PATH.DS.'includes'.DS.'gallery'.DS.'admin.gallery.php'); break; case 'newCaptcha': $eahelper->CaptchaSecurityImages(); break; case "mailform": showContactForm(); break; case "sendmail": sendContactMail(); break; case "mtfform": mailToFriendForm(); break; case "sendmtf": mailToFriend(); break; case "showEO": //show a Property case "pdfexport": case "print": showEstateObject(); break; case "showAll": //show all Properties ShowAllProperties(); break; case "easearch": showSearchForm(); break; case "showEASR": showSearchResults(); break; case "dosearch": doEASearch(); break; case "shortlist": showSearchResults(); break; case "emailmyshortlist": sendmyshortlist(); break; case "rss": include(EA_SITE_PATH.DS.'rss.estateagent.php'); break; case "export": /*if(file_exists(EA_SITE_PATH.DS.'export'.$task.'.php')) include(EA_SITE_PATH.DS.'export'.$task.'.php'); $mainframe->redirect( "index.php?option=com_estateagent", JText::_( 'Export type not supported' ));*/ //extractdb(); break; case "listAgents": listAgents(); break; case "profileAgent": //id = id from table contact_details profileAgent($id); break; case "listAO": //id = user_id from table contact_details listAgentObjects($act,$id); break; case "showTO": // show entries of a type ShowAllProperties(); break; case "showhot": // show hot properties //ShowHotProperties(); ShowAllProperties(); break; case "showCE": // show entries of a single category showCategoryEntries(); break; case "cat": default: showCategoriesOverview($id); break; //Front End Administration case "eaadmin": if($eaconf->ea_allowsubmission==1) { if (authorizeFrontEnd()==false) { $mainframe->redirect( 'index.php?option=com_estateagent', JText::_('ALERTNOTAUTH') ); } switch($task) { case "add": case "edit": editMyEAObject($id,$cid); break; case "clone": cloneMyEAObject($cid); break; case "save": case "apply": saveMyEAObject(); break; case "publish": case "unpublish": publishMyEAObject($cid); break; case 'cancel': EAcancel(); break; case "remove": removeMyEAObject($cid); break; case "showContact": showContact(); break; case "saveContact": saveContact(); break; default: showEACPanel(); break; } } break; } if($act!="sendmtf"&&$act!="mailform"&&$act!="mtfform"&&$act!="rss"&&$act!="newCaptcha"&$act!="gallery"&$act!="mtgcalc"&$act!="curncyconverter") EAFooter(); //} //==========Show Contact Form======== function showContactForm(){ $database = &JFactory::getDBO(); $id = JRequest::getInt( 'id', 0 ); $q= 'SELECT * FROM #__estateagent WHERE id ='.$id; $database->setQuery($q); $obj=$database->loadObject(); EA_Template::contactForm($obj); } //==================================== function sendmyshortlist(){ global $mainframe; $my =& JFactory::getUser(); $today =JHTML::_('date', 'now', '%d-%m-%Y %H:%M' ); $ids=array(); if (@$my->id) { if (@$my->email){ $mail_body=""; $header="From: " . $my->email. "\n"; $mail_body .= $mainframe->getCfg('sitename'). "\n"; $mail_body .= $today."\n"; $mail_body .= "My ShortList"."\n"; //echo "
";
					//print_r($_COOKIE['ea_shortlist']);
					//echo "
"; if (isset($_COOKIE['ea_shortlist'])){ $ids=split('-',$_COOKIE['ea_shortlist']); if($ids==false||is_array($ids)==false) $ids=array_filter($ids,"is_numeric"); foreach ($ids as $id) { if ($id>0) $mail_body .= JRoute::_(JURI::base().'index.php?option=com_estateagent&act=showEO&id='.$id)."\n" ; } } if (JUTility::sendMail($my->email, $my->name, $my->email, $header, $mail_body) !== true ) { JError::raiseNotice( 500, JText::_('EA_CTF_MNOSUCCESS') ); $mainframe->redirect('index.php?option=com_estateagent&act=shortlist'); }else{ $msg = JText::_('EA_CTF_MSUCCESS'); $mainframe->redirect('index.php?option=com_estateagent&act=shortlist', $msg); } } } else { JError::raiseError( 403, JText::_('ALERTNOTAUTH') ); return; } } //===========================Send Email============= function sendContactMail(){ global $mainframe; $eahelper=&EA_Helper::getInstance(); $user_id = JRequest::getInt( 'owner', 0 ); $id = JRequest::getInt( 'id', 0 ); $eaconf=&EAConf::getInstance(); if($eahelper->CaptchaValidate()==0){ JError::raiseWarning( 500, JText::_('EA_CTF_INVALID_SECURITY_CODE')); $mainframe->redirect('index.php?option=com_estateagent&act=mailform&id='.$id.'&tmpl=component'); } JRequest::checkToken() or jexit( 'Invalid Token' ); $user=&JFactory::getUser(); $today =JHTML::_('date', 'now', '%d-%m-%Y %H:%M' ); $gid= $user->gid; $eaconf=&EAConf::getInstance(); $database = &JFactory::getDBO(); jimport( 'joomla.mail.helper' ); $query='SELECT name, email_to FROM #__contact_details WHERE user_id =' .$user_id. ' AND published = 1 AND access <= '.$gid; $database->setQuery($query); $row = null; $row=$database->loadObject(); $ctf_name = JRequest::getString('ctf_name', '', 'post'); $ctf_phone = JRequest::getString('ctf_phone', '', 'post'); $ctf_fax = JRequest::getString('ctf_fax', '', 'post'); $ctf_mail = JRequest::getString('ctf_mail', '', 'post'); $ctf_subject = JRequest::getString('ctf_subject', '', 'post'); $ctf_message = JRequest::getString('ctf_message', '', 'post'); $ctf_email_copy = JRequest::getString('ctf_email_copy', 0, 'post'); $c_p = JRequest::getString('contact_preference', 'by_phone', 'post'); switch($c_p ) { case "by_email": $contact_preference = JText::_('EA_CTF_CONTACT_BY_EMAIL'); break; case "by_fax": $contact_preference = JText::_('EA_CTF_CONTACT_BY_FAX'); break; case "by_phone": default: $contact_preference = JText::_('EA_CTF_CONTACT_BY_PHONE'); break; break; } $ctf_name = JMailHelper::cleanLine($ctf_name); $ctf_phone = JMailHelper::cleanLine($ctf_phone); $ctf_fax = JMailHelper::cleanLine($ctf_fax); $ctf_mail = JMailHelper::cleanAddress($ctf_mail); $ctf_subject = JMailHelper::cleanSubject($ctf_subject); $ctf_message = JMailHelper::cleanText($ctf_message); $link=JRoute::_(JURI::base().'index.php?option=com_estateagent&act=showEO&id='.$id); $mail_body=""; $mail_body .= $ctf_name. " ".JText::_('EA_CTF_FROM')." ".$mainframe->getCfg('sitename'). "

" ; $mail_body .= "".JText::_('EA_CTF_NAME').": ".$ctf_name."
"; $mail_body .= "".JText::_('EA_CTF_MAIL').": ".$ctf_mail."
"; $mail_body .= "".JText::_('EA_CTF_PHON').": ".$ctf_phone."
"; $mail_body .= "".JText::_('EA_CTF_FAX').": ".$ctf_fax."

"; $mail_body .= "".JText::_('EA_CTF_SUBJECT').": ".$ctf_subject."

"; $mail_body .= "".JText::_('EA_CTF_MESSAGE').": ".$ctf_message."

"; $mail_body .= ""."Agent : ".$row->name."
"; $mail_body .= "".$link."

"; $mail_body .= ""."Contact Preference : ".$contact_preference."

"; $mail_body .="
"."Generated by ".$eaconf->ea_name." at ".$today."
"; $mail = JFactory::getMailer(); $mail->addRecipient(array($row->email_to)); $mail->setSender(array($ctf_mail, $ctf_name)); $mail->setSubject($mainframe->getCfg('sitename')." - ".$ctf_subject); $mail->setBody($mail_body); $mail->IsHTML(true); if($eaconf->ea_mail_to_admin_contact){ $query = "SELECT email" . "\n FROM #__users" . "\n WHERE ( gid = 24 OR gid = 25 )" . "\n AND sendEmail = 1" . "\n AND block = 0"; $database->setQuery( $query ); $admins = $database->loadResultArray(); foreach ( $admins as $emailadmin){ $mail->addRecipient(array($emailadmin)); } } if ($ctf_email_copy==1) $mail->addCC($ctf_mail); $sent = $mail->Send(); if ($sent!== true){ JError::raiseNotice( 500, JText::_('EA_CTF_MNOSUCCESS')); $mainframe->redirect('index.php?option=com_estateagent&act=mailform&id='.$id.'&tmpl=component'); }else{ $msg = JText::_('EA_CTF_MSUCCESS'); $mainframe->redirect('index.php?option=com_estateagent&act=mailform&id='.$id.'&tmpl=component', $msg); } } //============================================================== function showCategoriesOverview($id){ global $mainframe; $hot=array(); $eaconf=&EAConf::getInstance(); $database = &JFactory::getDBO(); $query = countCategories(0); $database->setQuery($query); $catinfo=EA_helper::buildCatInfo($database,$id); if($eaconf->ea_hotfp==1){ // get hot offers if avalaible $query = getHotObjects($eaconf->ea_hotfpa); //echo $query; $database->setQuery($query); $hot = $database->loadObjectList(); //echo "
";
		//print_r($hot);
		//echo "
"; } HTML_frontend_estateagent::showCatOverview($catinfo,$hot); } //============================================================ function countCategories($parent=""){ $my = &JFactory::getUser(); $gid = $my->gid; $database = &JFactory::getDBO(); $nullDate = $database->getNullDate(); $today =JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $gq= is_numeric($gid)?"AND access<=$gid":""; $parent= is_numeric($parent)?" AND parent = '$parent'" : ""; return "SELECT count(id) FROM #__estateagent_categories" . "\n WHERE" . "\n (" . "\n ((publish_up >= '$nullDate' AND publish_up <= '$today') AND publish_down >= '$today')" . "\n OR ((publish_up >= '$nullDate' AND publish_up <= '$today' ) AND (publish_down = '$nullDate' OR publish_down >= '$today'))" . "\n OR (publish_up = '$nullDate' AND publish_down = '$nullDate')" . "\n )" . " $parent AND published = 1 $gq"; } //================================================================= function getHotObjects($amount, $cat=""){ $database = &JFactory::getDBO(); $nullDate = $database->getNullDate(); $my = &JFactory::getUser(); $gid = $my->gid; $today =JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $gq= is_numeric($gid)?"AND o.access<=$gid":""; $cat= is_numeric($cat)?" AND o.cat = '$cat'" : ""; $query = "SELECT o.*, c.name AS catname, t.name as typename, t.id as typeid, c.id AS cat_id FROM #__estateagent as o " . " LEFT JOIN #__estateagent_categories AS c ON (o.cat = c.id) " . " LEFT JOIN #__estateagent_type AS t ON (o.type = t.id) " . " WHERE (" . "\n ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today') AND o.publish_down >= '$today')" . "\n OR ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today' ) AND (o.publish_down = '$nullDate' OR o.publish_down >= '$today'))" . "\n OR (o.publish_up = '$nullDate' AND o.publish_down = '$nullDate')" . "\n )" . "\n $cat AND o.hot=1 $gq AND o.published=1 AND c.published=1 ORDER BY o.created DESC" . "\n LIMIT 0,$amount"; return $query; } //================================================================= function showCategoryEntries(){ global $mainframe; $eaconf=&EAConf::getInstance(); $act = JRequest::getString( 'act', 'cat' ); $task = JRequest::getString('task'); $id = JRequest::getInt( 'id', 0 ); $database = &JFactory::getDBO(); $nullDate = $database->getNullDate(); $catinfo=EA_helper::buildCatInfo($database,$id); $my = &JFactory::getUser(); $gid = $my->gid; $today =JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $limitstart = JRequest::getInt( 'limitstart', 0); $limit = $mainframe->getUserStateFromRequest( 'com_estateagent.limit', 'limit', $eaconf->ea_perpage, 'int' ); // select categorie objects $catIDs = "o.cat=$id"; if($eaconf->ea_mcat_fullview == 1){ $cats=array(); function lsSubCats(&$catinfo,&$array,$parent){ if($catinfo[$parent]->entries!=0) $array[]=$parent; if($catinfo[$parent]->entriesR!=0) foreach($catinfo[$parent]->children as $c) lsSubCats($catinfo,$array,$c); } foreach($catinfo[0]->children as $c) lsSubCats($catinfo,$cats,$c); if(count($cats)>0){ $catIDs = " (o.cat=$id OR o.cat IN("; $catIDs .= implode(",",$cats) . "))"; } } // count matching categorie objects (if $ea_mcat_fullview, then count recursive) $query = "SELECT count(id) FROM #__estateagent as o WHERE ".$catIDs." AND (" . "\n ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today') AND o.publish_down >= '$today')" . "\n OR ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today' ) AND (o.publish_down = '$nullDate' OR o.publish_down >= '$today'))" . "\n OR (o.publish_up = '$nullDate' AND o.publish_down = '$nullDate')" . "\n )" . "\n AND o.access<=$gid AND o.published=1"; //echo $query; $database->setQuery($query); $total = $database->loadResult(); $ordering=""; jimport('joomla.html.pagination'); $pageNav = new JPagination( $total, $limitstart, $limit ); $ordering= HTML_frontend_estateagent::getOrderingQuery(); if ($ordering!="") $ordering="ORDER BY ".$ordering; // select hot offer objects $query = "SELECT o.*, c.name AS catname, c.id AS cat_id, t.name as typename, t.id as typeid, o.price AS Value FROM #__estateagent as o " . " LEFT JOIN #__estateagent_categories AS c ON (o.cat = c.id) " . " LEFT JOIN #__estateagent_type AS t ON (o.type = t.id) " . " WHERE ".$catIDs." AND (" . "\n ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today') AND o.publish_down >= '$today')" . "\n OR ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today' ) AND (o.publish_down = '$nullDate' OR o.publish_down >= '$today'))" . "\n OR (o.publish_up = '$nullDate' AND o.publish_down = '$nullDate')" . "\n )" . "\n AND o.hot=1 AND o.access<=$gid AND o.published=1 $ordering"; //echo $query; $database->setQuery($query); $hot = $database->loadObjectList(); // select regular objects $query = "SELECT o.*, c.name AS catname, c.alias AS catalias, c.id AS cat_id, t.name as typename, t.id as typeid, o.price AS Value FROM #__estateagent as o " . " LEFT JOIN #__estateagent_categories AS c ON (o.cat = c.id) " . " LEFT JOIN #__estateagent_type AS t ON (o.type = t.id) " . " WHERE ".$catIDs." AND (" . "\n ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today') AND o.publish_down >= '$today')" . "\n OR ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today' ) AND (o.publish_down = '$nullDate' OR o.publish_down >= '$today'))" . "\n OR (o.publish_up = '$nullDate' AND o.publish_down = '$nullDate')" . "\n )" . "\n AND o.access<=$gid AND o.published=1 $ordering"; // BY hot DESC AND id DESC $database->setQuery($query,$pageNav->limitstart, $pageNav->limit); $regular = $database->loadObjectList(); HTML_frontend_estateagent::show_CatEntries($act,$task,$id,$catinfo,$hot,$regular,$pageNav); } //================ Object function==================== function showEstateObject(){ global $mainframe; $today =JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $user = &JFactory::getUser(); $gid= $user->gid; $id = JRequest::getInt( 'id', 0 ); $database = &JFactory::getDBO(); $eaconf=&EAConf::getInstance(); $obj=& JTable::getInstance('object', 'EA'); $obj->load($id); if (!$obj->load($id)) { $mainframe->redirect('index.php?option=com_estateagent'); } if(($gid >= $obj->access) && ($obj->published == 0) ) { $mainframe->redirect('index.php?option=com_estateagent', JText::_('EA_OBJ_TYPE_NOACCESS')); } // object hitcounter $obj->hit(); // Get category $query = "SELECT * FROM #__estateagent_categories WHERE id =".$obj->cat." AND published= 1 "; $database->setQuery($query); $cat = $database->loadObject(); $query = "SELECT * FROM #__estateagent_type WHERE id =".$obj->type; $database->setQuery($query); $objecttype = $database->loadObject(); // load images $gl = $obj->loadGallery($obj->id, 1); // load all other files (EA supports .pdf, .doc, .xls, .ppt, .avi, .mpeg, .mov ) - for evaluation only! $fl = $obj->loadFiles(null,1); $contact = HTML_frontend_estateagent::contactInformation($obj); // if MAP24 support available, generate link for estate object... if($eaconf->ea_fulllocation == 1 && $eaconf->ea_map24 == 1){ $obj->map24link = EA_Template::check_map24_sup($eaconf->ea_map24_lid, $eaconf->ea_map24_type, $obj->street."%20".$obj->streetnr,$obj->pcode, $obj->town,$obj->country,$eaconf->ea_map24_tlogo, $mainframe->getCfg('sitename'), $eaconf->ea_map24_dlg,$eaconf->ea_map24_dinfo, $eaconf->ea_map24_dimg); } else $obj->map24link = ""; // replace country ISO code with country name $obj->country = $obj->country_ISOtoName($obj->country); HTML_frontend_estateagent::show_Object($obj, $cat, $contact, $gl, $fl, $objecttype); } //=============================================================================== function mailToFriendForm(){ global $mainframe; $database = &JFactory::getDBO(); $eaconf=&EAConf::getInstance(); $id = JRequest::getInt('id', 0); $query = 'SELECT * FROM #__estateagent WHERE id='.$id.' AND published=1'; $database->setQuery( $query ); $obj=$database->loadObject(); if (($id>0) && ($obj!==null) ){ $eaconf->ea_footer = 0; // do not show EA footer in popup window HTML_frontend_estateagent::show_mtfForm( $obj); } else{ JError::raiseWarning( 500, JText::_('ALERTNOTAUTH')); return; } } //=================== Send mail ToFriend ======================================= function mailToFriend() { global $mainframe; $eahelper=&EA_Helper::getInstance(); $id = JRequest::getInt('id', 0); $eaconf=&EAConf::getInstance(); if($eahelper->CaptchaValidate()==0){ JError::raiseWarning( 500, JText::_('EA_CTF_INVALID_SECURITY_CODE')); $mainframe->redirect('index.php?option=com_estateagent&act=mtfform&id='.$id.'&tmpl=component'); } JRequest::checkToken() or jexit( 'Invalid Token' ); $today =JHTML::_('date', 'now', '%d-%m-%Y %H:%M' ); jimport( 'joomla.mail.helper' ); $email = JRequest::getString('email', '', 'post'); $sendername = JRequest::getString('sendername', '', 'post'); $senderemail = JRequest::getString('senderemail', '', 'post'); $subject_default = JText::_('EA_ETF_INFO') .' ' . $sendername; $subject = JRequest::getString('subject', $subject_default, 'post'); $comments = JRequest::getString('comments', '', 'post'); $email_copy = JRequest::getString('email_copy', 0, 'post'); // Check for a valid to address $error = false; if ( ! $email || ! JMailHelper::isEmailAddress($email) ) { $error = JText::sprintf('_EA_CTF_EMAIL_INVALID', $email); JError::raiseWarning(0, $error ); } // Check for a valid from address if ( ! $senderemail || ! JMailHelper::isEmailAddress($senderemail) ) { $error = JText::sprintf('_EA_CTF_EMAIL_INVALID', $senderemail); JError::raiseWarning(0, $error ); } if ( $error ) { $mainframe->redirect('index.php?option=com_estateagent&act=mtfform&id='.$id.'&tmpl=component'); } $link = JRoute::_(JURI::base()."index.php?option=com_estateagent&act=showEO&id=". $id ); $mail_body=""; $mail_body .= $sendername. " ".JText::_('EA_MTF_HEADER')." ".$mainframe->getCfg('sitename'). "

" ; $mail_body .= "".JText::_('EA_MTF_NAME').": ".$sendername."
"; $mail_body .= "".JText::_('EA_MTF_EMAIL').": ".$senderemail."

"; $mail_body .= "".JText::_('EA_MTF_SUBJECT').": ".$subject."
"; $mail_body .= "".JText::_('EA_MTF_COMMENTS').": ".$comments."

"; $mail_body .= JText::_('EA_MTF_FOLLOW_LINK')."
"; $mail_body .= "".$link."

"; $mail_body .="
"."Generated by ".$eaconf->ea_name." at ".$today."
"; $mail = JFactory::getMailer(); $mail->addRecipient($email); $mail->setSender($senderemail, $sendername); $mail->setSubject($mainframe->getCfg('sitename')." - ".$subject); $mail->setBody($mail_body); $mail->IsHTML(true); if ($email_copy==1) $mail->addCC($senderemail); $sent = $mail->Send(); if ($sent!== true){ JError::raiseNotice( 500, JText::_('EA_CTF_MNOSUCCESS')); $mainframe->redirect('index.php?option=com_estateagent&act=mtfform&id='.$id.'&tmpl=component'); }else{ $msg = sprintf( JText::_('EA_ETF_SENT'), $email); $mainframe->redirect('index.php?option=com_estateagent&act=mtfform&id='.$id.'&tmpl=component', $msg); } } //=================== search functions================================== function showSearchForm(){ global $mainframe; $database = &JFactory::getDBO(); $my = &JFactory::getUser(); $gid= $my->gid; $eaconf=&EAConf::getInstance(); if($eaconf->ea_f_srch || $eaconf->ea_l_srch || $eaconf->ea_d_srch){ $map = 0; $countries=array();$countrynames=array();$states=array();$districts=array();$towns=array(); $countrieslist=array();$countrynameslist=array();$stateslist=array();$districtslist=array();$townslist=array(); $param["option_text"] = ""; $sp=array();$pageNav = ""; // get main- and subcategories and generate selectlist $query = EA_helper::getCategories(0); $database->setQuery($query); $cats = $database->loadObjectList(); $select_cat = EAHTML::catSelectList('src_cat', 'class="inputbox" style="width: 140px" ', 0 ); // get Types and generate selectlist $t[] = JHTML::_('select.option', '0', JText::_('EA_OBJ_TYPE1')); $query = 'SELECT * FROM #__estateagent_type ORDER BY ordering'; $database->setQuery($query); $rows = $database->loadObjectList(); foreach($rows as $row){ $t[] = JHTML::_('select.option', $row->id, $row->name ); }; $propertyType['type'] = JHTML::_('select.genericlist', $t,'type',' class="inputbox" style="width: 140px" ', 'value', 'text','0' ); //----Local Search ------------- if($eaconf->ea_l_srch){ $param["option_text"] = JText::_('EA_NO_OPTION'); // get location map $map = getMap(); // generate countries array $x=0; foreach($map as $m){ $countries[$x] = $m->country; $x++; } $countries = array_values(array_unique($countries)); sort($countries);//-------------sort countries $x=0; foreach($countries as $c_iso){ $countrynames[$x] = EAObject::country_ISOtoName($c_iso); $x++; } //-- Step By step Search type----- if($eaconf->ea_loc_srchtype == 0){ // generate array states for($country=0;$countrycountry == $countries[$country]){ if(trim($row->locstate)!="") $states[$country][$state] = $row->locstate; } } } for($country=0;$countrylocstate == $states[$country][$state]&& $row->country == $countries[$country] ){ if(trim($row->town)!="") $towns[$country][$state][$town] = $row->town; } } } } for($country=0;$countrytown) && $row->town == $towns[$country][$state][$town] && $row->locstate == $states[$country][$state]&& $row->country == $countries[$country]) { if(trim($row->district)!="") $districts[$country][$state][$town][$district] = $row->district; } } } } } for($country=0;$countryea_loc_srchtype){ $param["option_text"] = JText::_('EA_NOT_SELECTED'); foreach($map as $m){ if(trim($m->locstate)!="") $stateslist[] = $m->locstate; if(trim($m->town)!="") $townslist[] = $m->town; if(trim($m->district)!="") $districtslist[] = $m->district; $x++; } $stateslist = array_values(array_unique($stateslist)); $townslist = array_values(array_unique($townslist)); $districtslist = array_values(array_unique($districtslist)); sort($stateslist); sort($townslist); sort($districtslist); } //---End Free searsch type---- } //---------Extended Search-------------------------- if($eaconf->ea_d_srch){ $dws[] = JHTML::_('select.option', '0', JText::_('EA_NO_OPTION') ); $dws[] = JHTML::_('select.option', '1', JText::_('EA_SRCH_FOR_DWSPACE_1').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '2', JText::_('EA_SRCH_FOR_DWSPACE_2').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '3', JText::_('EA_SRCH_FOR_DWSPACE_3').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '4', JText::_('EA_SRCH_FOR_DWSPACE_4').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '5', JText::_('EA_SRCH_FOR_DWSPACE_5').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '6', JText::_('EA_SRCH_FOR_DWSPACE_6').$eaconf->ea_measure ); $dws[] = JHTML::_('select.option', '7', JText::_('EA_SRCH_FOR_DWSPACE_7').$eaconf->ea_measure ); $sp[0] = JHTML::_('select.genericlist', $dws, 'space', 'class="inputbox" style="width: 100px" ', 'value', 'text', 0 ); $yblt[] = JHTML::_('select.option', '0', JText::_('EA_NO_OPTION')); $yblt[] = JHTML::_('select.option', '1', JText::_('EA_SRCH_YOBUILT_1') ); $yblt[] = JHTML::_('select.option', '2', JText::_('EA_SRCH_YOBUILT_2') ); $yblt[] = JHTML::_('select.option', '3', JText::_('EA_SRCH_YOBUILT_3') ); $yblt[] = JHTML::_('select.option', '4', JText::_('EA_SRCH_YOBUILT_4') ); $yblt[] = JHTML::_('select.option', '5', JText::_('EA_SRCH_YOBUILT_5') ); $yblt[] = JHTML::_('select.option', '6', JText::_('EA_SRCH_YOBUILT_6') ); $yblt[] = JHTML::_('select.option', '7', JText::_('EA_SRCH_YOBUILT_7') ); $sp[1] = JHTML::_('select.genericlist', $yblt, 'yobuilt', 'class="inputbox" style="width: 100px" ', 'value', 'text', 0 ); $srm[] = JHTML::_('select.option', '0', JText::_( '_EA_NO_OPTION') ); $srm[] = JHTML::_('select.option', '1', JText::_( '1') ); $srm[] = JHTML::_('select.option', '2', JText::_( '2+') ); $srm[] = JHTML::_('select.option', '3', JText::_( '3+') ); $srm[] = JHTML::_('select.option', '4', JText::_( '4+') ); $srm[] = JHTML::_('select.option', '5', JText::_( '5+') ); $srm[] = JHTML::_('select.option', '6', JText::_( '6+') ); $srm[] = JHTML::_('select.option', '7', JText::_( '7+') ); $srm[] = JHTML::_('select.option', '8', JText::_( '8+') ); $srm[] = JHTML::_('select.option', '9', JText::_( '9+') ); $srm[] = JHTML::_('select.option', '10', JText::_( '10+') ); $sp[2] = JHTML::_('select.genericlist', $srm, 'rooms', 'class="inputbox" style="width:60px" ', 'value', 'text', 0 ); $sp[3] = JHTML::_('select.genericlist', $srm, 'bedrooms', 'class="inputbox" style="width:60px" ', 'value', 'text', 0 ); $sp[4] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'lift', '', 0, 0 ); $sp[5] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'handicap', '', 0, 0 ); $sp[6] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'toheat_ufloor', '', 0, 0 ); $sp[7] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'fireside', '', 0, 0 ); $sp[8] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'aircondition', '', 0, 0 ); $sp[9] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'tv', '', 0, 0 ); $sp[10] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'dsl', '', 0, 0 ); $sp[11] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'balcony', '', 0, 0 ); $sp[12] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'terrace', '', 0, 0 ); $sp[13] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'swpool', '', 0, 0 ); $sp[14] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'garden', '', 0, 0 ); $sp[15] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'parkarea', '', 0, 0 ); $sp[16] = EAHTML::checkbox( "atb[]", 'class="inputbox"', 'garage', '', 0, 0 ); } HTML_frontend_estateagent::easearchform($map, $select_cat, $countries, $countrynames, $states, $towns, $districts, $stateslist, $townslist, $districtslist, $sp, $propertyType); } else{ $msg = JText::_('EA_SRCH_DISABLED'); $mainframe->redirect(JRoute::_("index.php?option=com_estateagent"), $msg); } } //================ JF support ==================== function jf_showEASearchResult($searchstring){ global $mainframe; $database = &JFactory::getDBO(); $my = &JFactory::getUser(); $gid= $my->gid; $eaconf=&EAConf::getInstance(); $eahelper=&EA_Helper::getInstance(); $estateagent='estateagent'; $searchstring = $mainframe->getUserStateFromRequest( 'com_estateagent.searchstring','searchstring','','string' ); $state = $mainframe->getUserStateFromRequest( 'com_estateagent.src_state','src_state','' ); $district = $mainframe->getUserStateFromRequest( 'com_estateagent.src_district','src_district',''); $town = $mainframe->getUserStateFromRequest( 'com_estateagent.src_town','src_town',''); $state = prepairestring($state); $district = prepairestring($district); $town = prepairestring($town); $searchstring = prepairestring($searchstring); if( $searchstring && $eaconf->ea_f_srch==1 ){ $searchstring = ' AND value LIKE '.$searchstring; } $jf_query = 'SELECT DISTINCT reference_id FROM #__jf_content WHERE reference_table = \''.$estateagent.'\''. $searchstring ; $database->setQuery($jf_query); $results = $database->loadResultArray(); $locstate='locstate'; if($state!=null&&$state!="no") { $jf_query = 'SELECT DISTINCT reference_id FROM #__jf_content WHERE reference_field=\''.$locstate.'\' AND value LIKE '.$state; $database->setQuery($jf_query); $resultsp = $database->loadResultArray(); $q= 'SELECT id FROM #__estateagent WHERE locstate LIKE '.$state; //die($resultsp); $database->setQuery($q); $resultsp= array_merge($resultsp, $database->loadResultArray()); $results = array_intersect($results, $resultsp); } $district_field='district'; if($district!=null&&$district!="no") { $jf_query = 'SELECT DISTINCT reference_id FROM #__jf_content WHERE reference_field = \''.$district_field.'\' AND value LIKE '.$district; $database->setQuery($jf_query); $resultsp = $database->loadResultArray(); $q= 'SELECT id FROM #__estateagent WHERE district LIKE '.$district; $database->setQuery($q); $resultsp= array_merge($resultsp,$database->loadResultArray()); $results = array_intersect($results,$resultsp); } $town_field='town'; if($town!=null&&$town!="no") { $jf_query = 'SELECT DISTINCT reference_id FROM #__jf_content WHERE reference_field = \''.$town_field.'\' AND value LIKE '.$town; $database->setQuery($jf_query); $resultsp = $database->loadResultArray(); $q= 'SELECT id FROM #__estateagent WHERE town LIKE'.$town; $database->setQuery($q); $resultsp= array_merge($resultsp,$database->loadResultArray()); $results = array_intersect($results,$resultsp); } return $results; } //============================================================================ function doEASearch(){ global $mainframe; $database = &JFactory::getDBO(); $nullDate = $database->getNullDate(); $today =JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $my = &JFactory::getUser(); $gid= $my->gid; $eaconf=&EAConf::getInstance(); $eahelper=&EA_Helper::getInstance(); $limitstart = JRequest::getInt( 'limitstart', 0); $limit = $mainframe->getUserStateFromRequest( 'com_estateagent.limit', 'limit', $eaconf->ea_perpage, 'int' ); //Create search results $searchstring = $mainframe->getUserStateFromRequest( 'com_estateagent.searchstring','searchstring','','string' ); $minvalue = $mainframe->getUserStateFromRequest( 'com_estateagent.minvalue','minvalue','0','int'); $maxvalue = $mainframe->getUserStateFromRequest( 'com_estateagent.maxvalue','maxvalue','0','int'); $where=""; if($eaconf->ea_l_srch) $where = location_srch_query(); //die($where); if($where !="") $where = $where. ' AND '; if( $searchstring && $eaconf->ea_f_srch==1 ){ $searchstring = prepairestring($searchstring); $where= 'obj_id LIKE '.$searchstring. ' OR title LIKE '.$searchstring. ' OR other LIKE '.$searchstring. ' OR location LIKE '.$searchstring. ' OR country LIKE '.$searchstring. ' OR locstate LIKE '.$searchstring. ' OR district LIKE '.$searchstring. ' OR town LIKE '.$searchstring. ' OR toheat LIKE '.$searchstring. ' OR description LIKE '.$searchstring. ' AND '. $where; } $query = 'SELECT id FROM #__estateagent WHERE ' . $where. '(((publish_up >= \''.$nullDate.'\' AND publish_up <= \''.$today.'\') AND publish_down >= \''.$today.'\')'. ' OR ((publish_up >= \''.$nullDate.'\' AND publish_up <= \''.$today.'\' ) AND (publish_down =\''.$nullDate.'\' OR publish_down >= \''.$today.'\'))'. ' OR (publish_up = \''.$nullDate.'\' AND publish_down = \''.$nullDate.'\'))'. ' AND access<='.$gid.' AND published=1'; $database->setQuery($query); $total = $database->loadResultArray(); $conf = &JFactory::getConfig(); $jfbot = $conf->getValue('config.mbf_content'); if(isset($jfbot) && $jfbot) $jf_results = jf_showEASearchResult($searchstring); if (isset($jf_results) && count($jf_results)>0) $total=array_values(array_unique(array_merge($total,$jf_results))); //===Final query if(count($total)>0){ $where=""; $where=searchQuery(); if($where!="") $where="( ".$where." ) AND "; $where = $where."id IN (".implode(',',$total).") AND "; $cat = $mainframe->getUserStateFromRequest( 'com_estateagent.src_cat','src_cat','0','int' ); if($cat!='0'&&$cat!=""){ $query = "SELECT id FROM #__estateagent_categories WHERE id =".$cat." OR parent=". $cat." AND published='1'"; $database->setQuery($query); $results = $database->loadResultArray(); if(count($results) > 1) { $comma_separated = "(". implode(",", $results).")"; $where = " ( cat IN $comma_separated ) AND ". $where; } else { $where = " ( cat = $cat ) AND ". $where; } } if($minvalue!="" && $minvalue !=null && $minvalue !=0){ $where = " ( price >= '$minvalue' ) AND ". $where; } if($maxvalue!="" && $maxvalue !=null && $maxvalue !=0){ $where = " ( price <= '$maxvalue' ) AND ". $where; } $query = "SELECT id FROM #__estateagent WHERE " . $where . " (" . "\n ((publish_up >= '$nullDate' AND publish_up <= '$today') AND publish_down >= '$today')" . "\n OR ((publish_up >= '$nullDate' AND publish_up <= '$today' ) AND (publish_down = '$nullDate' OR publish_down >= '$today'))" . "\n OR (publish_up = '$nullDate' AND publish_down = '$nullDate')" . "\n )" . "\n AND access<=$gid AND published='1'"; $database->setQuery($query); $total = $database->loadResultArray(); echo $database->getErrorMsg(); } else{ $total =array(); } //STORE cookie with search results. $_SESSION['sres']=$total; //showSearchResults(); $mainframe->redirect(JRoute::_('index.php?option=com_estateagent&act=showEASR')); } //=============================================================================== function showSearchResults(){ global $mainframe; $database = &JFactory::getDBO(); $eaconf=&EAConf::getInstance(); $act = JRequest::getString( 'act', 'easearch' ); $task = JRequest::getString('task'); $limitstart = JRequest::getInt( 'limitstart', 0); $limit = $mainframe->getUserStateFromRequest( 'com_estateagent.limit', 'limit', $eaconf->ea_perpage, 'int' ); $ordering=""; $ordering= HTML_frontend_estateagent::getOrderingQuery(); $ids=array(); //GET and Load results from cookies SESSION. if ($act == 'shortlist'){ if (isset($_COOKIE['ea_shortlist'])){ $ids=split('-',$_COOKIE['ea_shortlist']); if($ids==false||is_array($ids)==false) $ids=array(); $ids=array_filter($ids,"is_numeric"); } } else { $ids=$_SESSION['sres']; } if ($ordering!="") $ordering="ORDER BY ".$ordering; if(count($ids)>0){ $idstring = implode(" , ",$ids); $query= "SELECT count(*) FROM #__estateagent WHERE id IN ( ". $idstring." ) AND published=1"; $database->setQuery($query); $count = $database->loadResult(); } else{ $count=0; } jimport('joomla.html.pagination'); $pageNav = new JPagination( $count, $limitstart, $limit ); if ($count>0){ $query= "SELECT o.*, c.name AS catname, t.name as typename, t.id as typeid, c.id AS cat_id, o.price AS Value FROM #__estateagent AS o " ." LEFT JOIN #__estateagent_categories AS c ON (o.cat = c.id) " . " LEFT JOIN #__estateagent_type AS t ON (o.type = t.id) " ." WHERE o.id IN ( ". $idstring." ) AND c.published=1 $ordering "; $database->setQuery($query,$pageNav->limitstart, $pageNav->limit); $results = $database->loadObjectList(); } else{ $results =array(); } HTML_frontend_estateagent::show_result($act,$task,$results,$pageNav); } //=============================================================================================================================== function EAcancel(){ global $mainframe; $obj = & JTable::getInstance('object', 'EA'); $fedit = JRequest::getInt( 'fastedit', 0 ); if (!$obj->bind( $_POST )) { echo "\n"; exit(); } $obj->checkin(); if($fedit) $mainframe->redirect('index.php?option=com_estateagent&act=showEO&id='.$obj->id); else $mainframe->redirect('index.php?option=com_estateagent&act=eaadmin'); } //=============================================================================================================================== function ShowAllProperties(){ global $mainframe; $eaconf = &EAConf::getInstance(); $today = JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $database = &JFactory::getDBO(); $nullDate = $database->getNullDate(); $my = &JFactory::getUser(); $gid = $my->gid; $act = JRequest::getString( 'act', 'cat' ); $id = JRequest::getInt( 'id', 0 ); $selecttype=""; $cselecttype=""; if (($act=="showTO") && ($id>0)) { $cselecttype = " AND type=".$id; $selecttype = " AND o.type=".$id; } if ($act=="showhot") { $cselecttype = " AND hot=1 "; $selecttype = " AND o.hot=1 "; } $limitstart = JRequest::getInt( 'limitstart', 0); $limit = $mainframe->getUserStateFromRequest( 'com_estateagent.limit', 'limit', $eaconf->ea_perpage, 'int' ); $ordering=""; $ordering= HTML_frontend_estateagent::getOrderingQuery(); if ($ordering!="") $ordering="ORDER BY ".$ordering; $query = "SELECT COUNT(*) FROM #__estateagent WHERE (" . "\n ((publish_up >= '$nullDate' AND publish_up <= '$today') AND publish_down >= '$today')" . "\n OR ((publish_up >= '$nullDate' AND publish_up <= '$today' ) AND (publish_down = '$nullDate' OR publish_down >= '$today'))" . "\n OR (publish_up = '$nullDate' AND publish_down = '$nullDate')" . "\n )" . "\n AND access<=$gid AND published='1' ".$cselecttype; $database->setQuery($query); $total = $database->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination( $total, $limitstart, $limit ); $query = "SELECT o.*, c.name AS catname, c.id AS cat_id, t.name as typename, t.id as typeid, o.price AS Value" . "\n FROM #__estateagent as o " . "\n LEFT JOIN #__estateagent_categories AS c ON (o.cat = c.id) " . "\n LEFT JOIN #__estateagent_type AS t ON (o.type = t.id) " . "\n WHERE (" . "\n ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today') AND o.publish_down >= '$today')" . "\n OR ((o.publish_up >= '$nullDate' AND o.publish_up <= '$today' ) AND (o.publish_down = '$nullDate' OR o.publish_down >= '$today'))" . "\n OR (o.publish_up = '$nullDate' AND o.publish_down = '$nullDate')" . "\n )" . "\n AND o.access<=$gid AND o.published=1 " .$selecttype." ".$ordering; $database->setQuery($query, $pageNav->limitstart, $pageNav->limit); $results = $database->loadObjectList(); ?> 0){ $mainframe->enqueueMessage(JText::_('EA_PROPERTIES_FOUND')." : ".$pageNav->total); echo"
".$pageNav->getResultsCounter()."
"; $line=1; foreach($results as $obj) { HTML_frontend_estateagent::show_Object_short($obj,1,$line,$total); $line++; }?>
getPagesLinks();?>
getResultsCounter();?>