protected function _dispatch($default = null) { $ad = $this->get_ad(); if (is_null($ad)) { $message = __("The specified Ad doesn't exist or you reached this page directly, without specifying the Ad ID.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } else { if (!$ad->is_about_to_expire() && !$ad->has_expired()) { $message = __("The specified Ad doesn't need to be renewed.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } else { if (!$this->verify_renew_ad_hash($ad)) { $message = __("There was an error trying to renew your Ad. The URL is not valid. Please contact the Administrator of this site for further assistance.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } } } $transaction = $this->get_transaction(); if (!is_null($transaction) && $transaction->get('context') != $this->context) { $page_name = awpcp_get_page_name('renew-ad-page-name'); $page_url = awpcp_get_renew_ad_url($ad->ad_id); $message = __('You are trying to post an Ad using a transaction created for a different purpose. Pelase go back to the <a href="%s">%s</a> page.<br>If you think this is an error please contact the administrator and provide the following transaction ID: %s', 'AWPCP'); $message = sprintf($message, $page_url, $page_name, $transaction->id); return $this->render('content', awpcp_print_error($message)); } $action = $this->get_current_action($default); if (!is_null($transaction) && $transaction->is_payment_completed()) { if (!$transaction->was_payment_successful()) { $message = __('You can\'t renew your Ad at this time because the payment associated with this transaction failed (see reasons below).', 'AWPCP'); $message = awpcp_print_message($message); $message = $message . awpcp_payments_api()->render_transaction_errors($transaction); return $this->render('content', $message); } $forbidden = in_array($action, array('order', 'checkout')); if ($forbidden) { $action = 'payment-completed'; } } if (!is_null($transaction) && $transaction->is_completed()) { $action = 'finish'; } $implementation = $this->get_renew_ad_page_implementation($ad); if (is_null($implementation)) { $message = __("The Ad was posted under a Payment Term that no longer exists or is disabled. The Ad can't be renewed.", 'AWPCP'); $content = '<p>' . $this->get_return_link($ad) . '</p>'; return $this->render('content', awpcp_print_error($message) . $content); } switch ($action) { case 'order': return $implementation->order_step(); case 'checkout': return $implementation->checkout_step(); case 'payment-completed': return $implementation->payment_completed_step(); case 'finish': return $implementation->finish_step(); default: return $implementation->order_step(); } }
public function settings_header() { $section_url = awpcp_get_admin_form_fields_url(); $section_link = sprintf('<a href="%s">%s</a>', $section_url, __('Form Fields', 'AWPCP')); $message = __('Go to the <form-fields-section> admin section to change the order in which the fields mentioned below are shown to users in the Ad Details form.', 'AWPCP'); $message = str_replace('<form-fields-section>', $section_link, $message); echo awpcp_print_message($message); }
protected function _dispatch($default = null) { if ($this->should_redirect_user_to_ad_management_panel()) { $url = admin_url('admin.php?page=awpcp-panel'); $message = __('Please go to the Ad Management panel to edit your Ads.', 'AWPCP'); $message = sprintf('%s <a href="%s">%s</a>.', $message, $url, __('Click here', 'AWPCP')); return $this->render('content', awpcp_print_message($message)); } else { return $this->handle_request($default); } }
private function render_listings_from_category($category_id) { $query = array('context' => 'public-listings', 'category_id' => $category_id, 'limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby')); if ($category_id == -1) { $message = __("No specific category was selected for browsing so you are viewing listings from all categories.", "AWPCP"); $output = awpcp_print_message($message); $output .= awpcp_display_listings_in_page($query, 'browse-listings'); } else { $output = awpcp_display_listings_in_page($query, 'browse-listings'); } return $output; }
<h2><?php echo esc_html(__('Enter Ad Details', 'AWPCP')); ?> </h2> <?php if (isset($transaction) && get_awpcp_option('show-create-listing-form-steps')) { echo awpcp_render_listing_form_steps('listing-details', $transaction); } ?> <?php foreach ($messages as $message) { echo awpcp_print_message($message); } awpcp_print_form_errors($errors); ?> <?php if ($ui['listing-actions']) { echo awpcp_listing_actions_component()->render($listing, array('hidden-params' => $hidden, 'current_url' => $this->url())); } ?> <!-- TODO: check where is used $formdisplayvalue --> <div> <form class="awpcp-details-form" id="adpostform" name="adpostform" action="<?php echo esc_attr($this->url()); ?> " method="post"> <?php
protected function process_contact_form() { global $nameofsite; $ad = $this->get_ad(); $form = array_merge($this->get_posted_data(), array('ad_id' => $ad->ad_id)); $errors = array(); if (!$this->validate_posted_data($form, $errors)) { return $this->contact_form($form, $errors); } $ad_title = $ad->get_title(); $ad_url = url_showad($ad->ad_id); $sender_name = stripslashes($form['awpcp_sender_name']); $sender_email = stripslashes($form['awpcp_sender_email']); $message = awpcp_strip_html_tags(stripslashes($form['awpcp_contact_message'])); if (get_awpcp_option('usesenderemailinsteadofadmin')) { $sender = awpcp_strip_html_tags($sender_name); $from = $sender_email; } else { $sender = $nameofsite; $from = awpcp_admin_sender_email_address(); } /* send email to admin */ if (get_awpcp_option('notify-admin-about-contact-message')) { $subject = __('Notification about a response regarding Ad: %s', 'AWPCP'); $subject = sprintf($subject, $ad_title); ob_start(); include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-admin.tpl.php'; $admin_body = ob_get_contents(); ob_end_clean(); $admin_email = awpcp_admin_recipient_email_address(); $result = awpcp_process_mail($from, $admin_email, $subject, $admin_body, $sender, $sender_email); } $subject = sprintf("%s %s: %s", get_awpcp_option('contactformsubjectline'), _x('regarding', 'reply email', 'AWPCP'), $ad_title); ob_start(); include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-user.tpl.php'; $body = ob_get_contents(); ob_end_clean(); $sendtoemail = get_adposteremail($ad->ad_id); $result = awpcp_process_mail($from, $sendtoemail, trim($subject), $body, $sender, $sender_email); if ($result) { $message = __("Your message has been sent.", "AWPCP"); return $this->render('content', awpcp_print_message($message)); } else { $this->messages[] = __("There was a problem encountered during the attempt to send your message. Please try again and if the problem persists, please contact the system administrator.", "AWPCP"); return $this->contact_form($form, $errors); } }
?> </h2> <?php foreach ($messages as $message) { ?> <?php echo awpcp_print_message($message); } ?> <?php foreach ($transaction_errors as $error) { ?> <?php echo awpcp_print_message($error, array('error')); } ?> <?php if (!awpcp_current_user_is_admin()) { echo $payments->render_account_balance(); } ?> <form class="awpcp-order-form" method="post"> <?php echo $payments->render_payment_terms_form_field($transaction, $table, $form_errors); ?> <p class="form-submit">
protected function _dispatch($default = null) { $is_admin_user = awpcp_current_user_is_admin(); // only admin users are allowed to place Ads if (get_awpcp_option('onlyadmincanplaceads') && $is_admin_user != 1) { $message = __("You do not have permission to perform the function you are trying to perform. Access to this page has been denied", "AWPCP"); return $this->render('content', awpcp_print_error($message)); } // only registered users are allowed to place Ads if (get_awpcp_option('requireuserregistration') && !is_user_logged_in()) { return $this->login_step(); } $transaction = $this->get_transaction(); if (!is_null($transaction) && $transaction->get('context') != $this->context) { $page_name = awpcp_get_page_name('place-ad-page-name'); $page_url = awpcp_get_page_url('place-ad-page-name'); $message = __('You are trying to post an Ad using a transaction created for a different purpose. Pelase go back to the <a href="%s">%s</a> page.<br>If you think this is an error please contact the administrator and provide the following transaction ID: %s', 'AWPCP'); $message = sprintf($message, $page_url, $page_name, $transaction->id); return $this->render('content', awpcp_print_error($message)); } $action = $this->get_current_action($default); if (!is_null($transaction) && $transaction->is_payment_completed()) { if (!($transaction->was_payment_successful() || $transaction->payment_is_canceled())) { $message = __('You can\'t post an Ad at this time because the payment associated with this transaction failed (see reasons below).', 'AWPCP'); $message = awpcp_print_message($message); $message = $message . awpcp_payments_api()->render_transaction_errors($transaction); return $this->render('content', $message); } $pay_first = get_awpcp_option('pay-before-place-ad'); $forbidden = in_array($action, array('order', 'checkout')); if ($forbidden) { $action = 'payment-completed'; } } if (!is_null($transaction) && $transaction->is_completed()) { $action = 'finish'; } switch ($action) { case 'order': return $this->order_step(); case 'checkout': return $this->checkout_step(); case 'payment-completed': return $this->payment_completed_step(); case 'details': case 'save-details': return $this->details_step(); break; case 'upload-images': return $this->upload_images_step(); break; case 'preview-ad': return $this->preview_step(); break; case 'finish': return $this->finish_step(); break; default: return $this->place_ad(); } }
<div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span><?php _e('Restore AWPCP Pages', 'AWPCP'); ?> </span></h3> <div class="inside"> <?php if (!empty($restored_pages)) { $message = __('The following pages were restored: <pages-list>.', 'AWPCP'); $pages_names = array_map('awpcp_get_option', awpcp_get_properties($restored_pages, 'page')); $pages_list = '<strong>' . implode('</strong>, <strong>', $pages_names) . '</strong>'; echo awpcp_print_message(str_replace('<pages-list>', $pages_list, $message)); } ?> <?php if (!empty($missing)) { ?> <div class="error"> <?php if (!empty($missing['not-found'])) { ?> <p><?php _e("The following pages are missing; the plugin is looking for a page with a particular ID but it seems that the page was permanently deleted.", 'AWPCP'); ?> </p> <ul>
public function render_account_balance() { if (!$this->credit_system_enabled()) { return ''; } $balance = $this->format_account_balance(); $text = sprintf(__('You currently have %s credits in your account.', 'AWPCP'), $balance); return awpcp_print_message($text); }
function awpcp_display_extra_fields($x_msg) { $output = ''; $count_extra_fields = count_extra_fields(); $add_label = __('Add New Field', 'awpcp-extra-fields'); $add_params = array('page' => 'Configure5', 'action' => 'addnewfield'); $add_url = add_query_arg($add_params, admin_url('admin.php')); $add_button = '<p><a class="button-primary" title="%1$s" href="%2$s"" accesskey="s">%1$s</a></p>'; $add_button = sprintf($add_button, $add_label, $add_url); if ($count_extra_fields > 0) { if (isset($x_msg) && !empty($x_msg)) { $output .= awpcp_print_message($x_msg); } $output .= $add_button; $order_fields_url = awpcp_get_admin_form_fields_url(); $order_fields_link = sprintf('<a href="%s">', $order_fields_url); $message = __('If you want to order the fields in a particular way, go <order-fields-link>here</a> to <order-fields-link>customize the order of all AWPCP fields</a>.', 'awpcp-extra-fields'); $message = str_replace('<order-fields-link>', $order_fields_link, $message); $output .= '<p>' . $message . '</p>'; // Setup the table $output .= "<table class=\"widefat\" cellspacing=\"0\">"; $output .= "<thead>"; $output .= "<tr>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Name", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Post Label", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("View Label", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Input Type", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Data Type", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Options", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Validation", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Privacy", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Categories", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Action", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "</tr>"; $output .= "</thead>"; $output .= "<tfoot>"; $output .= "<tr>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Name", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Post Label", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("View Label", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Input Type", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Data Type", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Options", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Validation", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Privacy", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Category", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "<th scope=\"col\" class=\"manage-column\">"; $output .= __("Action", 'awpcp-extra-fields'); $output .= "</th>"; $output .= "</tr>"; $output .= "</tfoot>"; $output .= "<tbody>"; $fields = awpcp_get_extra_fields(); foreach ($fields as $field) { if (strcasecmp($field->field_mysql_data_type, 'VARCHAR') == 0) { $input_type = 'Short Text'; } else { if (strcasecmp($field->field_mysql_data_type, 'TEXT') == 0) { $input_type = 'Long Text'; } else { if (strcasecmp($field->field_mysql_data_type, 'INT') == 0) { $input_type = 'Whole Number'; } else { if (strcasecmp($field->field_mysql_data_type, 'FLOAT') === 0) { $input_type = 'Decimal Number'; } } } } $input_type = $field->field_input_type; $output .= "<tr><td>{$field->field_name}</td>"; $output .= "<td>" . stripslashes_deep($field->field_label) . "</td>"; $output .= "<td>" . stripslashes_deep($field->field_label_view) . "</td>"; $output .= "<td>{$input_type}</td>"; $output .= "<td>{$field->field_mysql_data_type}</td>"; $output .= "<td>"; $output .= awpcp_get_comma_separated_list((array) $field->field_options); $output .= "</td>"; $required_text = __('required', 'awpcp-extra-fields'); if ($field->required && $field->field_validation) { $output .= "<td>{$field->field_validation} ({$required_text})</td>"; } else { if ($field->required) { $output .= "<td>{$required_text}</td>"; } else { $output .= "<td>{$field->field_validation}</td>"; } } $output .= "<td>{$field->field_privacy}</td>"; $output .= '<td>'; $categories = awpcp_extra_fields_get_field_categoires($field); if (count($categories) == countcategories()) { $output .= __('All', 'awpcp-extra-fields'); } else { $output .= awpcp_get_comma_separated_categories_list($categories); } $output .= '</td>'; $output .= "<td><a href=\"?page=Configure5&action=edit&id={$field->field_id}\">"; $output .= __("Edit", 'awpcp-extra-fields'); $output .= "</a> | <a href=\"?page=Configure5&action=delete&id={$field->field_id}\">"; $output .= __("Delete", 'awpcp-extra-fields'); $output .= "</a>"; $output .= "</td></tr>"; } // while ($rsrow=mysql_fetch_row($res)) { // if($rsrow[5] == 'VARCHAR'){ $rsrow[4] = "Short text";} // if($rsrow[5] == 'TEXT'){ $rsrow[4] = "Long text";} // if($rsrow[5] == 'INT'){ $rsrow[4] = "Number";} // if($rsrow[5] == 'float'){ $rsrow[4] = "Money";} // $output .= "<tr><td>$rsrow[1]</td>"; // $output .= "<td>$rsrow[2]</td>"; // $output .= "<td>$rsrow[3]</td>"; // $output .= "<td>$rsrow[4]</td>"; // $output .= "<td>$rsrow[5]</td>"; // $output .= "<td>$rsrow[6]</td>"; // $output .= "<td>$rsrow[7]</td>"; // $output .= "<td>$rsrow[8]</td>"; // $output .= "<td>$rsrow[9]</td>"; // $output .= "<td><a href=\"?page=Configure5&action=edit&id=$rsrow[0]\">"; // $output .= __("Edit",'awpcp-extra-fields' ); // $output .= "</a> | <a href=\"?page=Configure5&action=delete&id=$rsrow[0]\">"; // $output .= __("Delete",'awpcp-extra-fields' ); // $output .= "</a>"; // $output .= "</td></tr>"; // } $output .= "</tbody></table>"; } else { $output .= __("It appears you have not added any extra fields yet. Start adding extra fields using the link below", 'awpcp-extra-fields'); $output .= $add_button; $output .= "</p>"; } // Get the fields return $output; }
/** * Handles AWPCPSHOWAD shortcode. * * @param $adid An Ad ID. * @param $omitmenu * @param $preview true if the function is used to show an ad just after * it was posted to the website. * @param $send_email if true and $preview=true, a success email will be send * to the admin and poster user. * * @return Show Ad page content. */ function showad($adid = null, $omitmenu = false, $preview = false, $send_email = true, $show_messages = true) { global $wpdb; awpcp_maybe_add_thickbox(); wp_enqueue_script('awpcp-page-show-ad'); $awpcp = awpcp(); $awpcp->js->set('page-show-ad-flag-ad-nonce', wp_create_nonce('flag_ad')); $awpcp->js->localize('page-show-ad', array('flag-confirmation-message' => __('Are you sure you want to flag this ad?', 'AWPCP'), 'flag-success-message' => __('This Ad has been flagged.', 'AWPCP'), 'flag-error-message' => __('An error occurred while trying to flag the Ad.', 'AWPCP'))); $preview = $preview === true || 'preview' == awpcp_array_data('adstatus', '', $_GET); $is_moderator = awpcp_current_user_is_moderator(); $messages = array(); $permastruc = get_option('permalink_structure'); if (!isset($adid) || empty($adid)) { if (isset($_REQUEST['adid']) && !empty($_REQUEST['adid'])) { $adid = $_REQUEST['adid']; } elseif (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $adid = $_REQUEST['id']; } else { if (isset($permastruc) && !empty($permastruc)) { $adid = get_query_var('id'); } else { $adid = 0; } } } $adid = absint($adid); if (!empty($adid)) { // filters to provide alternative method of storing custom // layouts (e.g. can be outside of this plugin's directory) $prefix = 'awpcp_single_ad_template'; if (has_action("{$prefix}_action") || has_filter("{$prefix}_filter")) { do_action("{$prefix}_action"); return apply_filters("{$prefix}_filter"); } else { $results = AWPCP_Ad::query(array('where' => $wpdb->prepare('ad_id = %d', $adid))); if (count($results) === 1) { $ad = array_shift($results); } else { $ad = null; } if (is_null($ad)) { $message = __('Sorry, that listing is not available. Please try browsing or searching existing listings.', 'AWPCP'); return '<div id="classiwrapper">' . awpcp_print_error($message) . '</div><!--close classiwrapper-->'; } if ($ad->user_id > 0 && $ad->user_id == wp_get_current_user()->ID) { $is_ad_owner = true; } else { $is_ad_owner = false; } $content_before_page = apply_filters('awpcp-content-before-listing-page', ''); $content_after_page = apply_filters('awpcp-content-after-listing-page', ''); $output = '<div id="classiwrapper">%s%s<!--awpcp-single-ad-layout-->%s</div><!--close classiwrapper-->'; $output = sprintf($output, $content_before_page, $omitmenu ? '' : awpcp_menu_items(), $content_after_page); if (!$is_moderator && !$is_ad_owner && !$preview && $ad->disabled == 1) { $message = __('The Ad you are trying to view is pending approval. Once the Administrator approves it, it will be active and visible.', 'AWPCP'); return str_replace('<!--awpcp-single-ad-layout-->', awpcp_print_error($message), $output); } if (awpcp_request_param('verified') && $ad->verified) { $messages[] = awpcp_print_message(__('Your email address was successfully verified.', 'AWPCP')); } if ($show_messages && $is_moderator && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the Administrator) and the author can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && !$ad->verified) { $message = __('This Ad is currently disabled until you verify the email address used for the contact information. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } } } $layout = awpcp_get_listing_single_view_layout($ad); $layout = awpcp_do_placeholders($ad, $layout, 'single'); $output = str_replace('<!--awpcp-single-ad-layout-->', join('', $messages) . $layout, $output); $output = apply_filters('awpcp-show-ad', $output, $adid); if (!awpcp_request()->is_bot()) { $ad->visit(); } $ad->save(); } } else { $query = array('limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby')); $output = awpcp_display_listings_in_page($query, 'show-listing'); } return $output; }
function awpcp_print_error($message) { return awpcp_print_message($message, array('error')); }