exit; } $display .= COM_siteFooter(1); break; //save //save case 's': $display = COM_siteHeader('menu', $LANG_CLASSIFIEDS_1['save_ad']); $display .= CLASSIFIEDS_user_menu(); if (CLASSIFIEDS_checkAdAccess($_REQUEST['ad']) == false) { $display .= COM_refresh($_CLASSIFIEDS_CONF['site_url'] . '/index.php'); exit; break; } if (COM_isAnonUser()) { $display .= CLASSIFIEDS_loginRequiredForm(); } else { } $display .= COM_siteFooter(1); break; //profile //profile case 'p': require_once $_CONF['path_system'] . 'lib-user.php'; $display = COM_siteHeader('menu', $LANG_CLASSIFIEDS_1['profile']); $display .= CLASSIFIEDS_user_menu(); function_exists('USER_showProfile') ? $display .= USER_showProfile($_GET['u'], true) : ($display .= CLASSIFIEDS_showProfile($_GET['u'], true)); $display .= COM_siteFooter(1); break; //Offert //Offert
/** * This function creates an Ad Form * * Creates an Form for an Ad using the supplied defaults (if specified). * * @param array $ad array of values describing an Ad * @return string HTML string of Ad form */ function CLASSIFIEDS_getAdForm($ad = array(), $copy = false) { global $_CONF, $_CLASSIFIEDS_CONF, $LANG_CLASSIFIEDS_2, $LANG_CLASSIFIEDS_ADMIN, $_TABLES, $LANG24, $LANG_ADMIN, $_USER; if ($_USER['uid'] < 2) { return CLASSIFIEDS_loginRequiredForm(); } if (!SEC_hasRights('classifieds.publish')) { //Give publish rights to logged-in users if there is no group with this feature $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'classifieds.publish'"); $grp_id = DB_getItem($_TABLES['access'], 'acc_grp_id', "acc_ft_id = {$ft_id}"); //COM_errorLog('Classifieds feature: ' . $ft_id . ' | Group: ' . $grp_id ); if ($grp_id == '') { // Give access } else { // Display message return $LANG_CLASSIFIEDS_2['access_reserved'] . ' <strong>"' . DB_getItem($_TABLES['groups'], 'grp_name', "grp_id = {$grp_id}") . '"</strong>'; } } $active = true; if ($ad != '') { $created = COM_getUserDateTimeFormat($A['created']); $active_days = (time() - $created['1']) / (24 * 3600); if ($active_days > $_CLASSIFIEDS_CONF['active_days']) { $active = false; } if ((SEC_hasAccess2($ad) != 3 || $ad['deleted'] == 1 || $active == false) && !SEC_hasRights('classifieds.admin')) { echo COM_refresh($_CLASSIFIEDS_CONF['site_url'] . "/index.php?error=0"); exit; } } //Display form $ad['clid'] == '' ? $retval = COM_startBlock($LANG_CLASSIFIEDS_2['insert_new_ad']) : ($retval = COM_startBlock($LANG_CLASSIFIEDS_2['edit_label'] . ' ' . $ad['title'])); $template = new Template($_CONF['path'] . 'plugins/classifieds/templates'); $template->set_file(array('ad' => 'ad_form.thtml')); $template->set_var('site_url', $_CLASSIFIEDS_CONF['site_url']); $template->set_var('xhtml', XHTML); $template->set_var('gltoken_name', CSRF_TOKEN); $template->set_var('gltoken', SEC_createToken()); if (is_numeric($ad['clid'])) { $template->set_var('clid', '<input type="hidden" name="clid" value="' . $ad['clid'] . '" />'); } else { $template->set_var('clid', ''); } //Your Ad $template->set_var('your_ad', $LANG_CLASSIFIEDS_2['your_ad']); //category $categories = ''; $template->set_var('category_label', $LANG_CLASSIFIEDS_2['category']); $categories .= '<option value="0">' . $LANG_CLASSIFIEDS_2['choose_category'] . '</option>'; $categories .= CLASSIFIEDS_adOptionList($_TABLES['cl_cat'], 'cid,category,pid', $ad['catid'], 'catorder', "catdeleted=0"); $template->set_var('categories', $categories); //type $template->set_var('type_label', $LANG_CLASSIFIEDS_2['type']); if ($ad['type'] == '1') { $template->set_var('type_d', ' selected'); $template->set_var('type_o', ''); } elseif ($ad['type'] == '0') { $template->set_var('type_d', ''); $template->set_var('type_o', ' selected'); } else { $template->set_var('type_d', ''); $template->set_var('type_o', ''); } $choosetype = '<option value="-1">' . $LANG_CLASSIFIEDS_2['choose_type'] . '</option>'; $template->set_var('choose_type', $choosetype); $template->set_var('offer', $LANG_CLASSIFIEDS_2['offer']); $template->set_var('demand', $LANG_CLASSIFIEDS_2['demand']); //title $template->set_var('title_label', $LANG_CLASSIFIEDS_2['title']); $template->set_var('title', $ad['title']); $template->set_var('currency', $_CLASSIFIEDS_CONF['currency']); //text $template->set_var('text_label', $LANG_CLASSIFIEDS_2['text']); $template->set_var('text', $ad['text']); //Price $template->set_var('price_label', $LANG_CLASSIFIEDS_2['price']); $template->set_var('price', number_format(floatval($ad['price']), $_CONF['decimal_count'])); //images $template->set_var('images', $LANG_CLASSIFIEDS_2['images']); $fileinputs = ''; $saved_images = ''; if ($_CLASSIFIEDS_CONF['max_images_per_ad'] > 0) { if ($ad['clid'] != '') { $icount = DB_count($_TABLES['cl_pic'], 'pi_pid', $ad['clid']); if ($icount > 0) { $result_pics = DB_query("SELECT * FROM {$_TABLES['cl_pic']} WHERE pi_pid = '" . $ad['clid'] . "'"); for ($z = 1; $z <= $icount; $z++) { $I = DB_fetchArray($result_pics); $saved_images .= '<div><p>' . $z . ') ' . '<a class="lightbox" href="' . $_CLASSIFIEDS_CONF['site_url'] . '/timthumb.php?src=' . $_CLASSIFIEDS_CONF['url_images'] . $I['pi_filename'] . '&w=640"><img src="' . $_CLASSIFIEDS_CONF['site_url'] . '/timthumb.php?src=' . $_CLASSIFIEDS_CONF['url_images'] . $I['pi_filename'] . '&w=' . $size . '&h=' . $size . '" align="top" alt="' . $A['title'] . '" /></a>' . ' ' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['pi_img_num'] . ']"' . XHTML . '><br' . XHTML . '></p></div>'; } } } $newallowed = $_CLASSIFIEDS_CONF['max_images_per_ad'] - $icount; for ($z = $icount + 1; $z <= $_CLASSIFIEDS_CONF['max_images_per_ad']; $z++) { $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '> '; if ($z < $_CLASSIFIEDS_CONF['max_images_per_ad']) { $fileinputs .= '<br' . XHTML . '>'; } } } $template->set_var('saved_images', $saved_images); $template->set_var('image_form_elements', $fileinputs); //your details if (!is_numeric($ad['clid'])) { $data = DB_query("SELECT *\n FROM {$_TABLES['cl_users']} \n\t\t\tWHERE user_id = {$_USER['uid']}\n\t\t"); $user_data = DB_fetchArray($data, true); $ad['status'] = $user_data['status']; $ad['tel'] = $user_data['tel']; $ad['postcode'] = $user_data['postcode']; $ad['city'] = $user_data['city']; $ad['siren'] = $user_data['siren']; } $template->set_var('your_details', $LANG_CLASSIFIEDS_2['your_details']); $template->set_var('status_label', $LANG_CLASSIFIEDS_2['status']); $template->set_var('private', $LANG_CLASSIFIEDS_2['private']); $template->set_var('professional', $LANG_CLASSIFIEDS_2['professional']); if ($ad['status'] == '1') { $template->set_var('pro_yes', ' selected'); $template->set_var('pro_no', ''); } elseif ($ad['status'] == '0') { $template->set_var('pro_yes', ''); $template->set_var('pro_no', ' selected'); } else { $template->set_var('pro_no', ''); $template->set_var('pro_yes', ''); } $choose_status = '<option value="-1">' . $LANG_CLASSIFIEDS_2['choose_status'] . '</option>'; $template->set_var('choose_status', $choose_status); $template->set_var('siren_label', $LANG_CLASSIFIEDS_2['siren']); $template->set_var('siren', $ad['siren']); $template->set_var('tel_label', $LANG_CLASSIFIEDS_2['tel']); $template->set_var('tel', $ad['tel']); $template->set_var('hide_tel_label', $LANG_CLASSIFIEDS_2['hide_tel']); $template->set_var('hide_tel', $ad['hide_tel']); if ($ad['hide_tel'] == '1') { $template->set_var('tel_ckecked', ' checked="checked"'); } else { $template->set_var('tel_ckecked', ''); } $template->set_var('postcode_label', $LANG_CLASSIFIEDS_2['postcode']); $template->set_var('postcode', $ad['postcode']); $template->set_var('city_label', $LANG_CLASSIFIEDS_2['city']); $template->set_var('city', $ad['city']); //submit $template->set_var('save_button', $LANG_CLASSIFIEDS_2['save_button']); $template->set_var('delete_button', $LANG_CLASSIFIEDS_2['delete_button']); $template->set_var('validate_button', $LANG_CLASSIFIEDS_2['validate_button']); $template->set_var('required_field', $LANG_CLASSIFIEDS_2['required_field']); //Admin options if (SEC_hasRights('classifieds.admin')) { $admin_select = LB . '<select name="op">' . LB; if (!$copy) { $admin_select .= '<option value="save" selected="selected">' . $LANG_CLASSIFIEDS_2['save_button'] . '</option>' . LB; if ($ad['clid'] != '') { $admin_select .= '<option value="delete">' . $LANG_CLASSIFIEDS_2['delete_button'] . '</option>' . LB; } } if (function_exists('CLASSIFIEDS_getBonusAdminButton') && $ad['clid'] != '') { $admin_select .= CLASSIFIEDS_getBonusAdminButton(); } $admin_select .= LB . '</select>' . LB; $template->set_var('admin_options', $admin_select); $datecreated = COM_getUserDateTimeFormat($ad['created']); $datemodified = COM_getUserDateTimeFormat($ad['modified']); $template->set_var('created', '<p>' . $LANG_CLASSIFIEDS_ADMIN['created'] . $LANG_CLASSIFIEDS_1['double_point'] . ' ' . $datecreated[0] . '</p>'); $template->set_var('modified', '<p>' . $LANG_CLASSIFIEDS_ADMIN['modified'] . $LANG_CLASSIFIEDS_1['double_point'] . ' ' . $datemodified[0] . '</p>'); } else { $template->set_var('admin_options', ''); $template->set_var('created', ''); $template->set_var('modified', ''); } $retval .= $template->parse('output', 'ad'); $retval .= COM_endBlock(); return $retval; }
/** * Display form to email a story to someone. * * @param string $sid ID of article to email * @return string HTML for email story form * */ function CLASSIFIEDS_mailAdForm($sid, $to = '', $toemail = '', $from = '', $fromemail = '', $shortmsg = '', $msg = 0) { global $_CONF, $_TABLES, $_USER, $LANG08; require_once $_CONF['path_system'] . 'lib-story.php'; $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $retval .= CLASSIFIEDS_loginRequiredForm(); return $retval; } $story = new Story(); $result = $story->loadFromDatabase($sid, 'view'); if ($result != STORY_LOADED_OK) { return COM_refresh($_CONF['site_url'] . '/index.php'); } if ($msg > 0) { $retval .= COM_showMessage($msg); } if (empty($from) && empty($fromemail)) { if (!COM_isAnonUser()) { $from = COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']); $fromemail = DB_getItem($_TABLES['users'], 'email', "uid = {$_USER['uid']}"); } } $mail_template = new Template($_CONF['path_layout'] . 'profiles'); $mail_template->set_file('form', 'contactauthorform.thtml'); $mail_template->set_var('xhtml', XHTML); $mail_template->set_var('site_url', $_CONF['site_url']); $mail_template->set_var('site_admin_url', $_CONF['site_admin_url']); $mail_template->set_var('layout_url', $_CONF['layout_url']); $mail_template->set_var('start_block_mailstory2friend', COM_startBlock($LANG08[17])); $mail_template->set_var('lang_title', $LANG08[31]); $mail_template->set_var('story_title', $story->displayElements('title')); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); $mail_template->set_var('story_url', $url); $link = COM_createLink($story->displayElements('title'), $url); $mail_template->set_var('story_link', $link); $mail_template->set_var('lang_fromname', $LANG08[20]); $mail_template->set_var('name', $from); $mail_template->set_var('lang_fromemailaddress', $LANG08[21]); $mail_template->set_var('email', $fromemail); $mail_template->set_var('lang_toname', $LANG08[18]); $mail_template->set_var('toname', $to); $mail_template->set_var('lang_toemailaddress', $LANG08[19]); $mail_template->set_var('toemail', $toemail); $mail_template->set_var('lang_cc', $LANG08[36]); $mail_template->set_var('lang_cc_description', $LANG08[37]); $mail_template->set_var('lang_shortmessage', $LANG08[27]); $mail_template->set_var('shortmsg', htmlspecialchars($shortmsg)); $mail_template->set_var('lang_warning', $LANG08[22]); $mail_template->set_var('lang_sendmessage', $LANG08[16]); $mail_template->set_var('story_id', $sid); $mail_template->set_var('end_block', COM_endBlock()); PLG_templateSetVars('emailstory', $mail_template); $mail_template->parse('output', 'form'); $retval .= $mail_template->finish($mail_template->get_var('output')); return $retval; }