function replace_tags($tags = array()) { global $config, $lang; require_once $config['basepath'] . '/include/login.inc.php'; $login = new login(); require_once $config['basepath'] . '/include/misc.inc.php'; $misc = new misc(); // Remove tags not found in teh template $new_tags = $tags; $tags = array(); foreach ($new_tags as $tag) { if (strpos($this->page, '{' . $tag . '}') !== false) { $tags[] = $tag; } } unset($new_tags); if (sizeof($tags) > 0) { foreach ($tags as $tag) { $data = ''; switch ($tag) { case 'content': $data = $this->replace_user_action(); break; case 'templated_search_form': require_once $config['basepath'] . '/include/search.inc.php'; $search = new search_page(); $data = $search->create_searchpage('no', true); break; case 'baseurl': $data = $config['baseurl']; break; case 'template_url': $data = $config['template_url']; break; case 'addthis_button': global $jscript_last; $jscript_last .= "\r\n" . '<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>'; $data = '<a href="http://www.addthis.com/bookmark.php?v=250" class="addthis_button"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" border="0" alt="Share" /></a>'; break; case 'load_js': $data = $this->load_js(); break; case 'load_js_last': global $jscript_last; $data = $jscript_last; break; case 'tabbed_js': global $jscript; $jscript .= '<script type="text/javascript" src="' . $config['baseurl'] . '/tabpane.js"></script>' . "\r\n"; $data = ''; break; case 'license_tag': $data = "<!--Open-Realty is distributed by Transparent Technologies and is Licensed under the Open-Realty License. See http://www.open-realty.org/license_info.html for more information.-->"; break; case 'main_listing_data': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->getMainListingData($_GET['listingID']); break; case 'featured_listings_vertical': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(); break; case 'featured_listings_horizontal': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsHorizontal(); break; case 'featured_listings_horizontal_latest': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderLatestFeaturedListingsHorizontal(); break; case 'random_listings_vertical': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(0, true); break; case 'random_listings_horizontal': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); //$data = $listing->renderFeaturedListingsHorizontal(0, true); $data = $listing->renderRandomListingsHorizontal(); break; case 'latest_listings_vertical': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(0, false, '', true); break; case 'latest_listings_horizontal': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsHorizontal(0, false, '', true); break; case preg_match("/^featured_listings_horizontal_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsHorizontal(0, FALSE, $feat_class[1]); break; case preg_match("/^featured_listings_vertical_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(0, FALSE, $feat_class[1]); break; case preg_match("/^random_listings_horizontal_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsHorizontal(0, TRUE, $feat_class[1]); break; case preg_match("/^random_listings_vertical_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(0, TRUE, $feat_class[1]); break; case preg_match("/^latest_listings_horizontal_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsHorizontal(0, false, $feat_class[1], true); break; case preg_match("/^latest_listings_vertical_class_([0-9]*)/", $tag, $feat_class) ? $tag : !$tag: require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderFeaturedListingsVertical(0, false, $feat_class[1], true); break; case 'headline': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderTemplateAreaNoCaption('headline', $_GET['listingID']); break; case 'full_description': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderTemplateAreaNoCaption('center', $_GET['listingID']); break; case 'listing_images': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImages($_GET['listingID'], 'yes'); break; case 'listing_images_nocaption': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImages($_GET['listingID'], 'no'); break; case 'listing_files_select': require_once $config['basepath'] . '/include/files.inc.php'; $files = new file_handler(); $data = $files->render_files_select($_GET['listingID'], 'listing'); break; case 'files_listing_vertical': require_once $config['basepath'] . '/include/files.inc.php'; $files = new file_handler(); $data = $files->render_templated_files($_GET['listingID'], 'listing', 'vertical'); break; case 'files_listing_horizontal': require_once $config['basepath'] . '/include/files.inc.php'; $files = new file_handler(); $data = $files->render_templated_files($_GET['listingID'], 'listing', 'horizontal'); break; case 'slideshow_images': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsMainImageSlideShow($_GET['listingID']); break; case 'link_calc': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_calc_link(); break; case 'link_calc_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_calc_link($url_only = 'yes'); break; case 'link_add_favorites': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_add_favorite_link(); break; case 'link_add_favorites_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_add_favorite_link($url_only = 'yes'); break; case 'link_printer_friendly': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_printer_friendly_link(); break; case 'link_email_friend': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_email_friend_link(); break; case 'link_map': require_once $config['basepath'] . '/include/maps.inc.php'; $maps = new maps(); $data = $maps->create_map_link(); break; case 'link_yahoo_school': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_yahoo_school_link(); break; case 'link_yahoo_neighborhood': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_yahoo_neighborhood_link(); break; case 'link_printer_friendly_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_printer_friendly_link($url_only = 'yes'); break; case 'link_email_friend_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_email_friend_link($url_only = 'yes'); break; case 'link_map_url': require_once $config['basepath'] . '/include/maps.inc.php'; $maps = new maps(); $data = $maps->create_map_link($url_only = 'yes'); break; case 'link_yahoo_school_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_yahoo_school_link($url_only = 'yes'); break; case 'link_yahoo_neighborhood_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->create_yahoo_neighborhood_link($url_only = 'yes'); break; case 'contact_agent_link_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->contact_agent_link($url_only = 'yes'); break; case 'agent_info': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->renderUserInfoOnListingsPage($_GET['listingID']); break; case 'listing_email': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->getListingEmail($_GET['listingID']); break; case 'hitcount': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->hitcount($_GET['listingID']); break; case 'main_image': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsMainImage($_GET['listingID'], 'yes', 'no'); break; case 'main_image_nodesc': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsMainImage($_GET['listingID'], 'no', 'no'); break; case 'main_image_java': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsMainImage($_GET['listingID'], 'yes', 'yes'); break; case 'main_image_java_nodesc': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsMainImage($_GET['listingID'], 'no', 'yes'); break; case 'listing_images_java': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJava($_GET['listingID'], 'no'); break; case 'listing_images_java_caption': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJava($_GET['listingID'], 'yes'); break; case 'listing_images_java_rows': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJavaRows($_GET['listingID']); break; case 'listing_images_mouseover_java': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJava($_GET['listingID'], 'no', 'yes'); break; case 'listing_images_mouseover_java_caption': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJava($_GET['listingID'], 'yes', 'yes'); break; case 'listing_images_mouseover_java_rows': require_once $config['basepath'] . '/include/images.inc.php'; $images = new image_handler(); $data = $images->renderListingsImagesJavaRows($_GET['listingID'], 'yes'); break; case 'vtour_button': require_once $config['basepath'] . '/include/vtour.inc.php'; $vtour = new vtours(); $data = $vtour->rendervtourlink($_GET['listingID']); break; case 'listingid': $data = $_GET['listingID']; break; case 'get_creation_date': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->get_creation_date($_GET['listingID']); break; case 'get_featured_raw': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->get_featured($_GET['listingID'], 'yes'); break; case 'get_featured': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->get_featured($_GET['listingID'], 'no'); break; case 'get_modified_date': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->get_modified_date($_GET['listingID']); break; case 'contact_agent_link': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->contact_agent_link(); break; case 'select_language': // require_once($config['basepath'] . '/include/multilingual.inc.php'); // $multilingual = new multilingual(); // $data = $multilingual->multilingual_select(); break; case 'company_name': $data = $config['company_name']; break; case 'company_location': $data = $config['company_location']; break; case 'company_logo': $data = $config['company_logo']; break; case 'show_vtour': if (isset($_GET['listingID'])) { require_once $config['basepath'] . '/include/vtour.inc.php'; $vtour = new vtours(); $data = $vtour->show_vtour($_GET['listingID'], false); } else { $data = 'No Listing ID'; } break; case 'charset': $data = $config['charset']; break; case 'link_edit_listing': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->edit_listing_link(); break; case 'link_edit_listing_url': require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $data = $listing->edit_listing_link('yes'); break; case 'template_select': $data = $this->template_selector(); break; case 'money_sign': $data = $config['money_sign']; break; case 'horizontal_header_banner': if (@(include getenv('DOCUMENT_ROOT') . '/advertising/phpadsnew.inc.php')) { if (!isset($phpAds_context)) { $phpAds_context = array(); } $phpAds_raw = view_raw('zone:1', 0, '_self', '', '0', $phpAds_context); $data = $phpAds_raw['html']; } else { $data = '<img src="/images/bannerd.png">'; } break; default: if (preg_match("/^addon_(.*?)_.*/", $tag, $addon_name)) { $file = $config['basepath'] . '/addons/' . $addon_name[1] . '/addon.inc.php'; if (file_exists($file)) { include_once $file; $function_name = $addon_name[1] . '_run_template_user_fields'; $data = $function_name($tag); } else { $data = ''; } } else { $data = ''; } break; } $this->page = str_replace('{' . $tag . '}', $data, $this->page); } } unset($tags); unset($tag); }
function add_listing() { @set_time_limit(1500); global $conn, $lang, $config; require_once $config['basepath'] . '/include/misc.inc.php'; $misc = new misc(); require_once $config['basepath'] . '/include/forms.inc.php'; $forms = new forms(); require_once $config['basepath'] . '/include/listing.inc.php'; $listing = new listing_pages(); $display = ''; $display .= '<span class="section_header">' . $lang['admin_menu_add_a_listing'] . '</span>'; if (isset($_POST['action']) && $_POST['action'] == "create_new_listing") { // Check Number of Listings User has if (isset($_POST['or_owner'])) { $or_owner = $misc->make_db_safe($_POST['or_owner']); $sql = 'SELECT count(listingsdb_id) as listing_count FROM ' . $config['table_prefix'] . 'listingsdb WHERE userdb_id = ' . $or_owner; } else { $sql = 'SELECT count(listingsdb_id) as listing_count FROM ' . $config['table_prefix'] . 'listingsdb WHERE userdb_id = ' . $_SESSION['userID']; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $listing_count = $recordSet->fields['listing_count']; // Get User Listing Limit if (isset($_POST['or_owner'])) { $or_owner = $misc->make_db_safe($_POST['or_owner']); $sql = 'SELECT userdb_limit_listings FROM ' . $config['table_prefix'] . 'userdb WHERE userdb_id = ' . $or_owner; } else { $sql = 'SELECT userdb_limit_listings FROM ' . $config['table_prefix'] . 'userdb WHERE userdb_id = ' . $_SESSION['userID']; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $listing_limit = $recordSet->fields['userdb_limit_listings']; //Ok Decide if user can have more listings if ($listing_count >= $listing_limit && $listing_limit != '-1') { $display .= '<br />'; $display .= '<!-- ' . $listing_count . ' >= ' . $listing_limit . ' -->'; $display .= $lang['admin_listing_limit_reached']; } else { // creates a new listing if ($_POST['title'] == "") { $display .= "<p>{$lang['admin_new_listing_enter_a_title']}</p>"; $display .= "<form><input type=\"button\" value=\"{$lang['back_button_text']}\" onclick=\"history.back()\" /></form>"; } else { $pass_the_form = $forms->validateForm('listingsformelements', $_POST['property_class']); if ($pass_the_form != "Yes") { // if we're not going to pass it, tell that they forgot to fill in one of the fields foreach ($pass_the_form as $k => $v) { if ($v == 'REQUIRED') { $display .= "<p class=\"redtext\">{$k}: {$lang['required_fields_not_filled']}</p>"; } if ($v == 'TYPE') { $display .= "<p class=\"redtext\">{$k}: {$lang['field_type_does_not_match']}</p>"; } } $display .= "<form><input type=\"button\" value=\"{$lang['back_button_text']}\" onclick=\"history.back()\" /></form>"; } else { $title = $misc->make_db_safe($_POST['title']); $notes = $misc->make_db_safe($_POST['notes']); $mlsexport = $misc->make_db_safe($_POST['mlsexport']); if (isset($_POST['or_owner'])) { $new_listing_owner = $_POST['or_owner']; $sql_new_listing_owner = $misc->make_db_safe($_POST['or_owner']); } else { $new_listing_owner = $_SESSION['userID']; $sql_new_listing_owner = $misc->make_db_safe($_SESSION['userID']); } // check to see if moderation is turned on... if ($config['moderate_listings'] == false) { $set_active = "yes"; } else { $set_active = "no"; } if (isset($_POST['active'])) { $set_active = $_POST['active']; } // create the account with the random number as the password $expiration_date = mktime(0, 0, 0, date("m"), date("d") + $config['days_until_listings_expire'], date("Y")); $sql = "INSERT INTO " . $config['table_prefix'] . "listingsdb (listingsdb_title, listingsdb_notes, userdb_id, listingsdb_active, listingsdb_mlsexport, listingsdb_creation_date, listingsdb_last_modified, listingsdb_expiration, listingsdb_hit_count, listingsdb_featured) VALUES ({$title}, {$notes}, {$sql_new_listing_owner}, '{$set_active}', {$mlsexport}, " . $conn->DBDate(time()) . "," . $conn->DBTimeStamp(time()) . "," . $conn->DBDate($expiration_date) . ",0,'no')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } else { $new_listing_id = $conn->Insert_ID(); } // end while // Add Listing to the property class system. foreach ($_POST['property_class'] as $class_id) { $sql = 'INSERT INTO ' . $config['table_prefix_no_lang'] . 'classlistingsdb (listingsdb_id, class_id) VALUES(' . $new_listing_id . ',' . $class_id . ')'; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } } // now that that's taken care of, it's time to insert all the rest // of the variables into the database $message = listing_editor::updateListingsData($new_listing_id, $new_listing_owner); if ($message == "success") { $display .= "<p>{$lang['admin_new_listing_created']}, {$_SESSION['username']}</p>"; if ($config['moderate_listings'] === "1") { // if moderation is turned on... $display .= "<p>{$lang['admin_new_listing_moderated']}</p>"; } if (isset($_POST['or_owner'])) { $display .= "<p><a href=\"index.php?action=edit_listings&edit={$new_listing_id}\">{$lang['you_may_now_edit_the_listing']}</a></p>"; } else { $display .= "<p><a href=\"index.php?action=edit_my_listings&edit={$new_listing_id}\">{$lang['you_may_now_edit_your_listing']}</a></p>"; } $display .= "<br /><p>{$lang['admin_additional_steps']}</p>"; $display .= '<form action="index.php?action=edit_listing_images" method="post" name="edit_listing_images"><input type="hidden" name="edit" value="' . $new_listing_id . '" /><a href="javascript:document.edit_listing_images.submit()">' . $lang['upload_images'] . '</a></form>'; $display .= '<br />'; if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havevtours'] == "yes") { $display .= '<form action="index.php?action=edit_vtour_images" method="post" name="edit_vtour_images"><input type="hidden" name="edit" value="' . $new_listing_id . '" /><a href="javascript:document.edit_vtour_images.submit()">' . $lang['upload_vtours'] . '</a></form>'; $display .= '<br />'; } if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havefiles'] == "yes") { $display .= '<form action="index.php?action=edit_listing_files" method="post" name="edit_listing_files"><input type="hidden" name="edit" value="' . $new_listing_id . '" /><a href="javascript:document.edit_listing_files.submit()">' . $lang['upload_files'] . '</a></form>'; $display .= '<br />'; } $misc->log_action("{$lang['log_created_listing']} {$new_listing_id}"); if ($config['email_notification_of_new_listings'] === "1") { // if the site admin should be notified when a new listing is added global $config, $lang; $agent_email = $listing->getListingEmail($new_listing_id, true); $agent_first_name = $listing->getListingAgentFirstName($new_listing_id); $agent_last_name = $listing->getListingAgentLastName($new_listing_id); $message = $_SERVER['REMOTE_ADDR'] . " -- " . date("F j, Y, g:i:s a") . "\r\n\r\n{$lang['admin_new_listing']}:\r\n{$config['baseurl']}/admin/index.php?action=edit_listings&edit={$new_listing_id}\r\n"; $header = "From: " . $agent_first_name . " " . $agent_last_name . " <" . $agent_email . ">\r\n"; $header .= "X-Sender: {$config['admin_email']}\r\n"; $header .= "Return-Path: {$config['admin_email']}\r\n"; $sent = $misc->send_email($agent_first_name . " " . $agent_last_name, $agent_email, $config['admin_email'], $message, $lang['admin_new_listing']); } // end if } else { $display .= "<p>{$lang['alert_site_admin']}</p>"; } // end else } // end $pass_the_form == "Yes" } // end else } //End if (($listing_count >= $listing_limit) && ($listing_limit !== -1)) } else { // Check Number of Listings User has $sql = 'SELECT count(listingsdb_id) FROM ' . $config['table_prefix'] . 'listingsdb WHERE userdb_id = ' . $_SESSION['userID']; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $listing_count = $recordSet->fields[0]; // Get User Listing Limit $sql = 'SELECT userdb_limit_listings FROM ' . $config['table_prefix'] . 'userdb WHERE userdb_id = ' . $_SESSION['userID']; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $listing_limit = $recordSet->fields[0]; $display .= '<!-- ' . $listing_count . ' >= ' . $listing_limit . ' -->'; if ($listing_count >= $listing_limit && $listing_limit !== '-1') { $display .= '<br />'; $display .= $lang['admin_listing_limit_reached']; } else { //START FORM VALIDATION if (isset($_POST['property_class'])) { $class_sql = ''; foreach ($_POST['property_class'] as $class_id) { if (empty($class_sql)) { $class_sql .= ' class_id = ' . $class_id; } else { $class_sql .= ' OR class_id = ' . $class_id; } $display .= '<input type="hidden" name="property_class[]" value="' . $class_id . '" />'; } $pclass_list = ''; $sql = "SELECT DISTINCT(listingsformelements_id) FROM " . $config['table_prefix_no_lang'] . "classformelements WHERE " . $class_sql; $recordSet = $conn->execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { if (empty($pclass_list)) { $pclass_list .= $recordSet->fields['listingsformelements_id']; } else { $pclass_list .= ',' . $recordSet->fields['listingsformelements_id']; } $recordSet->Movenext(); } if ($pclass_list == '') { $pclass_list = 0; } $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required, listingsformelements_field_length, listingsformelements_tool_tip from " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_id IN (" . $pclass_list . ") ORDER BY listingsformelements_rank, listingsformelements_field_name"; } else { $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required, listingsformelements_field_length, listingsformelements_tool_tip from " . $config['table_prefix'] . "listingsformelements ORDER BY listingsformelements_rank, listingsformelements_field_name"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display .= "\r\n<script type=\"text/javascript\" >\r\n"; $display .= "<!--\r\n"; $display .= "function validate_form()\r\n"; $display .= "{\r\n"; $display .= "var msg=\"\"\r\n"; $display .= "valid = true;\r\n"; $display .= "if ( document.addlisting.title.value == \"\" )\r\n"; $display .= "{\r\n"; $display .= "msg += '{$lang['forgot_field']} {$lang['admin_listings_editor_title']} {$lang['admin_template_editor_field']}.\\r\\n';\r\n"; $display .= "valid = false;\r\n"; $display .= "}\r\n"; while (!$recordSet->EOF) { $field_name = $recordSet->fields['listingsformelements_field_name']; $field_caption = $recordSet->fields['listingsformelements_field_caption']; $required = $recordSet->fields['listingsformelements_required']; if ($required == 'Yes') { $display .= "if ( document.addlisting.{$field_name}.value == \"\" )\r\n"; $display .= "{\r\n"; $display .= "msg += '{$lang['forgot_field']} {$field_caption} {$lang['admin_template_editor_field']}.\\r\\n';\r\n"; $display .= "valid = false;\r\n"; $display .= "}\r\n"; } $recordSet->MoveNext(); } $display .= "if (msg != \"\")\r\n"; $display .= "{\r\n"; $display .= "alert (msg);"; $display .= "}\r\n"; $display .= "return valid;\r\n"; $display .= "}\r\n"; $display .= "//-->\r\n"; $display .= "</script>\r\n"; //END FORM VALIDATION $display .= '<form name="addlisting" action="index.php?action=add_listing" method="post" onsubmit="return validate_form ( );">'; $display .= '<input type="hidden" name="action" value="create_new_listing" />'; $display .= '<table class="form_main">'; $display .= '<tr>'; $display .= '<td align="right" class="row_main"><b>' . $lang['admin_listings_editor_title'] . '<span class="required">*</span></b></td>'; $display .= '<td align="left" class="row_main"> <input type="text" name="title" /></td>'; $display .= '</tr>'; // Display Agent selection Option to assign listing if ($_SESSION['admin_privs'] == "yes" || $_SESSION['edit_all_listings'] == "yes") { $display .= '<tr><td align="right"><b>' . $lang['listing_editor_listing_agent'] . ':</b></td>'; $display .= '<td align="left" class="row_main"><select name="or_owner" size="1">'; // find the name of the agent listed as ID in $edit_or_owner $sql = "SELECT userdb_user_first_name, userdb_user_last_name FROM " . $config['table_prefix'] . "userdb WHERE (userdb_id = {$_SESSION['userID']})"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } // strip slashes so input appears correctly $agent_first_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_first_name']); $agent_last_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_last_name']); if ($_SESSION['admin_privs'] != "yes") { $display .= "<option value=\"{$_SESSION['userID']}\">{$agent_last_name},{$agent_first_name}</option>"; } // fill list with names of all agents $sql = "SELECT userdb_id, userdb_user_first_name, userdb_user_last_name FROM " . $config['table_prefix'] . "userdb where userdb_is_agent = 'yes' or userdb_is_admin = 'yes' ORDER BY userdb_user_last_name,userdb_user_first_name"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { // strip slashes so input appears correctly $agent_ID = $recordSet->fields['userdb_id']; $agent_first_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_first_name']); $agent_last_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_last_name']); if ($agent_ID == $_SESSION['userID']) { $display .= "<option value=\"{$agent_ID}\" selected=\"selected\">{$agent_last_name},{$agent_first_name}</option>"; } else { $display .= "<option value=\"{$agent_ID}\">{$agent_last_name},{$agent_first_name}</option>"; } $recordSet->MoveNext(); } $display .= "</select></td>"; $display .= '</tr>'; } if ($config["show_notes_field"] == 1) { $display .= '<tr>'; $display .= '<td align="right" class="row_main"><b>' . $lang['admin_listings_editor_notes'] . '</b><br /><div class="small">(' . $lang['admin_listings_editor_notes_note'] . ')</div></td>'; $display .= '<td align="left" class="row_main"><textarea name="notes" cols="40" rows="6"></textarea></td>'; $display .= '</tr>'; } else { $display .= '<input type="hidden" name="notes" value="" />'; } if ($config["export_listings"] == 1 && $_SESSION['export_listings'] == "yes") { $display .= '<tr>'; $display .= '<td align="right" class="row_main"><b>' . $lang['admin_listings_editor_mlsexport'] . '</b><br /><div class="small">(' . $lang['admin_listings_editor_mlsexport'] . ')</div></td>'; $display .= '<td align="left" class="row_main">'; $display .= '<select size="1" name="mlsexport">'; $display .= '<option value="no" selected="selected">' . $lang['no'] . '</option>'; $display .= '<option value="yes">' . $lang['yes'] . '</option>'; $display .= '</select>'; $display .= '</td>'; $display .= '</tr>'; } else { $display .= '<input type="hidden" name="mlsexport" value="no" />'; } // Determine which fields to show based on property class if (isset($_POST['property_class'])) { $class_sql = ''; foreach ($_POST['property_class'] as $class_id) { if (empty($class_sql)) { $class_sql .= ' class_id = ' . $class_id; } else { $class_sql .= ' OR class_id = ' . $class_id; } $display .= '<input type="hidden" name="property_class[]" value="' . $class_id . '" />'; } $pclass_list = ''; $sql = "SELECT DISTINCT(listingsformelements_id) FROM " . $config['table_prefix_no_lang'] . "classformelements WHERE " . $class_sql; $recordSet = $conn->execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { if (empty($pclass_list)) { $pclass_list .= $recordSet->fields['listingsformelements_id']; } else { $pclass_list .= ',' . $recordSet->fields['listingsformelements_id']; } $recordSet->Movenext(); } if ($pclass_list == '') { $pclass_list = 0; } $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required, listingsformelements_field_length, listingsformelements_tool_tip from " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_id IN (" . $pclass_list . ") ORDER BY listingsformelements_rank, listingsformelements_field_name"; } else { $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required, listingsformelements_field_length, listingsformelements_tool_tip from " . $config['table_prefix'] . "listingsformelements ORDER BY listingsformelements_rank, listingsformelements_field_name"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $field_type = $recordSet->fields['listingsformelements_field_type']; $field_name = $recordSet->fields['listingsformelements_field_name']; $field_caption = $recordSet->fields['listingsformelements_field_caption']; $default_text = $recordSet->fields['listingsformelements_default_text']; $field_elements = $recordSet->fields['listingsformelements_field_elements']; $required = $recordSet->fields['listingsformelements_required']; $field_length = $recordSet->fields['listingsformelements_field_length']; $tool_tip = $recordSet->fields['listingsformelements_tool_tip']; $field_type = $misc->make_db_unsafe($field_type); $field_name = $misc->make_db_unsafe($field_name); $field_caption = $misc->make_db_unsafe($field_caption); $default_text = $misc->make_db_unsafe($default_text); $field_elements = $misc->make_db_unsafe($field_elements); $required = $misc->make_db_unsafe($required); $field_length = $misc->make_db_unsafe($field_length); $tool_tip = $misc->make_db_unsafe($tool_tip); $display .= $forms->renderFormElement($field_type, $field_name, $field_caption, $default_text, $field_elements, $required, $field_length, $tool_tip); $recordSet->MoveNext(); } // end while $display .= $forms->renderFormElement("submit", "", "{$lang['submit']}", "", "", ""); $display .= '<tr><td colspan="2" align="center" class="row_main">' . $lang['required_form_text'] . '</td></tr>'; $display .= '</table>'; $display .= '</form>'; } //End } // end if return $display; }