private function render_notice()
 {
     $message = __("You have payments enabled, but there are no payment terms defined. Users won't be able to post Ads. Please <fee-section-link>add payment terms</a> or <payments-settings-link>configure the website as a free board</a>.", 'AWPCP');
     $message = str_replace('<fee-section-link>', sprintf('<a href="%s">', awpcp_get_admin_fees_url()), $message);
     $message = str_replace('<payments-settings-link>', sprintf('<a href="%s">', awpcp_get_admin_settings_url('payment-settings')), $message);
     echo awpcp_print_error($message);
 }
 protected function show_missing_placeholder_notice($warning_message)
 {
     $warning_message = sprintf('<strong>%s:</strong> %s', __('Warning', 'awpcp-attachments'), $warning_message);
     $url = awpcp_get_admin_settings_url('listings-settings');
     $link = sprintf('<a href="%s">%s</a>', $url, __('Ad/Listings settings page', 'awpcp-attachments'));
     $go_to_settings_message = sprintf(__('Go to the %s to change the Single Ad layout.', 'awpcp-attachments'), $link);
     echo awpcp_print_error(sprintf('%s<br/><br/>%s', $warning_message, $go_to_settings_message));
 }
 public function dispatch($page)
 {
     $this->page = $page;
     $action = $page->get_current_action();
     $ad = AWPCP_Ad::find_by_id(awpcp_request_param('id', awpcp_request_param('adid', false)));
     $media = awpcp_media_api()->find_by_id(awpcp_request_param('picid'));
     $current_user_id = get_current_user_id();
     $is_admin_user = awpcp_current_user_is_admin();
     $ad_belongs_to_user = AWPCP_Ad::belongs_to_user($ad->ad_id, $current_user_id);
     if (!$is_admin_user && !$ad_belongs_to_user) {
         $message = _x("You don't have sufficient permissions to modify that Ad's media", 'media manager', 'AWPCP');
         return $this->page->render('content', awpcp_print_error($message));
     }
     if (!is_null($media) && $ad->ad_id != $media->ad_id) {
         $message = _x('The specified file does not belongs to the specified Ad. No action will be performed.', 'media managear', 'AWPCP');
         awpcp_flash($message, 'error');
         $action = 'show_images';
     }
     $media_actions = array('deletepic', 'rejectpic', 'approvepic', 'set-primary-image');
     if (is_null($media) && in_array($action, $media_actions)) {
         $message = _x('The specified file does not exists. No action will be performed.', 'media managear', 'AWPCP');
         awpcp_flash($message, 'error');
         $action = 'show_images';
     }
     switch ($action) {
         case 'deletepic':
             return $this->delete_file($ad, $media);
         case 'rejectpic':
             return $this->disable_picture($ad, $media);
         case 'approvepic':
             return $this->enable_picture($ad, $media);
         case 'approve-file':
             return $this->approve_file($ad, $media);
         case 'reject-file':
             return $this->reject_file($ad, $media);
         case 'set-primary-image':
             return $this->set_primary_image($ad, $media);
         case 'add-image':
             return $this->add_image($ad, $media);
         default:
             return $this->show_images($ad);
     }
 }
Example #4
0
 protected function _dispatch($default = null)
 {
     $action = $this->get_current_action();
     if (get_awpcp_option('reply-to-ad-requires-registration') && !is_user_logged_in()) {
         $message = __('Only registered users can reply to Ads. If you are already registered, please login below in order to reply to the Ad.', 'AWPCP');
         return $this->render('content', awpcp_login_form($message, awpcp_current_url()));
     }
     $ad = $this->get_ad();
     if (is_null($ad)) {
         $message = __('The specified Ad does not exist.', 'AWPCP');
         return $this->render('content', awpcp_print_error($message));
     }
     switch ($action) {
         case 'contact':
             return $this->contact_step();
         case 'docontact1':
         default:
             return $this->process_contact_form();
     }
 }
Example #5
0
 public function finish_step()
 {
     $transaction = $this->get_transaction();
     $messages = $this->messages;
     $send_email = false;
     if (is_null($transaction)) {
         $message = __('We were unable to find a Payment Transaction assigned to this operation.', 'AWPCP');
         return $this->render('content', awpcp_print_error($message));
     }
     $ad = AWPCP_Ad::find_by_id($transaction->get('ad-id', 0));
     if (is_null($ad)) {
         $message = __('The Ad associated with this transaction doesn\'t exists.', 'AWPCP');
         return $this->render('content', awpcp_print_error($message));
     }
     if (!$transaction->is_completed()) {
         awpcp_payments_api()->set_transaction_status_to_completed($transaction, $errors);
         if (!empty($errors)) {
             return $this->render('content', join(',', array_map('awpcp_print_error', $errors)));
         }
         $transaction->save();
     }
     // reload Ad, since modifications were probably made as part of the
     // transaction handling workflow
     $ad = AWPCP_Ad::find_by_id($transaction->get('ad-id', 0));
     $params = array('edit' => false, 'ad' => $ad, 'messages' => array_merge($messages, awpcp_listings_api()->get_ad_alerts($ad)), 'transaction' => $transaction, 'transaction_id' => $transaction->id);
     $template = AWPCP_DIR . '/frontend/templates/page-place-ad-finish-step.tpl.php';
     return $this->render($template, $params);
 }
Example #6
0
 public function render_transaction_errors($transaction)
 {
     $errors = array();
     foreach ($transaction->errors as $index => $error) {
         if (is_array($error)) {
             $errors = array_merge($errors, array_map('awpcp_print_error', $error));
         } else {
             $errors[] = awpcp_print_error($error);
         }
     }
     return join("\n", $errors);
 }
Example #7
0
<?php

foreach ($errors as $error) {
    ?>
    <?php 
    echo awpcp_print_error($error);
}
 function load_the_extra_fields_form($awpcp_x_field_id, $awpcp_x_field_name, $awpcp_x_field_label, $awpcp_x_field_label_view, $awpcp_x_field_input_type, $awpcp_x_field_mysqldata_type, $awpcp_x_field_options, $awpcp_x_field_validation, $awpcp_x_field_privacy, $awpcp_x_field_category, $x_error_msg, $awpcp_x_field_nosearch = 0, $show_on_listings = false, $required = 0)
 {
     global $wpdb, $message;
     $output = '';
     if (isset($x_error_msg) && !empty($x_error_msg)) {
         $output .= awpcp_print_error($x_error_msg);
     }
     wp_enqueue_script('awpcp-extra-fields-admin');
     $output .= "<p><a href=\"?page=Configure5\">";
     $output .= __("View Current Fields", 'awpcp-extra-fields');
     $output .= "</a>";
     $output .= "<form class=\"awpcp-extra-fields-form\" method=\"post\">";
     $output .= "<p>";
     $output .= __("Field Name", 'awpcp-extra-fields');
     $output .= " (";
     $output .= __("A short name for the form field. This is not visible to user", 'awpcp-extra-fields');
     $output .= ")";
     $output .= "<br/>";
     $output .= "<input type=\"text\" name=\"awpcp_extra_field_name\" style=\"width:50%;\" value=\"{$awpcp_x_field_name}\" />";
     $output .= "</p>";
     $output .= "<p>";
     $output .= __("Field Post Label", 'awpcp-extra-fields');
     $output .= " (";
     $output .= __("Text that tells the user what they need to enter or select in the form.", 'awpcp-extra-fields');
     $output .= ")";
     $output .= "<br/>";
     $output .= "<input type=\"text\" name=\"awpcp_extra_field_label\" style=\"width:50%;\" value=\"{$awpcp_x_field_label}\" />";
     $output .= "</p>";
     $output .= "<p>";
     $output .= __("Field View Label", 'awpcp-extra-fields');
     $output .= " (";
     $output .= __("Text to use when displaying the field data on the ad view page.", 'awpcp-extra-fields');
     $output .= ")";
     $output .= "<br/>";
     $output .= "<input type=\"text\" name=\"awpcp_extra_field_label_view\" style=\"width:50%;\" value=\"{$awpcp_x_field_label_view}\" />";
     $output .= "</p>";
     $output .= "<p>";
     $output .= __("Field Input Element Type", 'awpcp-extra-fields');
     $output .= " (";
     $output .= __("What input element type should be used to collect the data from user?", 'awpcp-extra-fields');
     $output .= ")";
     $output .= "</p><p>";
     $output .= " <select name=\"awpcp_extra_field_input_type\">";
     $output .= "<option value=\"\">";
     $output .= __("Select Field Input Type", 'awpcp-extra-fields');
     $output .= "</option>";
     if ($awpcp_x_field_input_type == 'Input Box') {
         $aef_inputtype_selected1 = " selected='selected'";
     } else {
         $aef_inputtype_selected1 = '';
     }
     if ($awpcp_x_field_input_type == 'Select') {
         $aef_inputtype_selected2 = " selected='selected'";
     } else {
         $aef_inputtype_selected2 = '';
     }
     if ($awpcp_x_field_input_type == 'Select Multiple') {
         $aef_inputtype_selected3 = " selected='selected'";
     } else {
         $aef_inputtype_selected3 = '';
     }
     if ($awpcp_x_field_input_type == 'Radio Button') {
         $aef_inputtype_selected4 = " selected='selected'";
     } else {
         $aef_inputtype_selected4 = '';
     }
     if ($awpcp_x_field_input_type == 'Checkbox') {
         $aef_inputtype_selected5 = " selected='selected'";
     } else {
         $aef_inputtype_selected5 = '';
     }
     if ($awpcp_x_field_input_type == 'Textarea Input') {
         $aef_inputtype_selected6 = " selected='selected'";
     } else {
         $aef_inputtype_selected6 = '';
     }
     if ($awpcp_x_field_input_type == 'DatePicker') {
         $aef_inputtype_selected7 = ' selected="selected"';
     } else {
         $aef_inputtype_selected7 = '';
     }
     $output .= "<option value=\"Input Box\" {$aef_inputtype_selected1}>";
     $output .= __("Input Text Box", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"Select\" {$aef_inputtype_selected2}>";
     $output .= __("Select List", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"Select Multiple\" {$aef_inputtype_selected3}>";
     $output .= __("Multiple Select List", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"Radio Button\" {$aef_inputtype_selected4}>";
     $output .= __("Radio Button", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"Checkbox\" {$aef_inputtype_selected5}>";
     $output .= __("Checkbox", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"Textarea Input\"  {$aef_inputtype_selected6}>";
     $output .= __("Textarea", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"DatePicker\"  {$aef_inputtype_selected7}>";
     $output .= __("DatePicker", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "</select>";
     $output .= "</p><p>";
     $output .= __("Field MYSQL Data Type", 'awpcp-extra-fields');
     $output .= " (";
     $output .= __("Select Number for values that must save as numbers, money for money values, short text for string values under 300 characters and long text for string values over 300 characters", 'awpcp-extra-fields');
     $output .= ")";
     $output .= "</p><p>";
     $output .= " <select name=\"awpcp_extra_field_mysqldata_type\">";
     $output .= "<option value=\"\">";
     $output .= __("Select Field MYSQL Data Type", 'awpcp-extra-fields');
     $output .= "</option>";
     if ($awpcp_x_field_mysqldata_type == 'INT') {
         $aef_mysqldt_selected1 = " selected='selected'";
     } else {
         $aef_mysqldt_selected1 = '';
     }
     if ($awpcp_x_field_mysqldata_type == 'FLOAT') {
         $aef_mysqldt_selected2 = " selected='selected'";
     } else {
         $aef_mysqldt_selected2 = '';
     }
     if ($awpcp_x_field_mysqldata_type == 'VARCHAR') {
         $aef_mysqldt_selected3 = " selected='selected'";
     } else {
         $aef_mysqldt_selected3 = '';
     }
     if ($awpcp_x_field_mysqldata_type == 'TEXT') {
         $aef_mysqldt_selected4 = " selected='selected'";
     } else {
         $aef_mysqldt_selected4 = '';
     }
     $output .= "<option value=\"INT\" {$aef_mysqldt_selected1}>";
     $output .= __("Whole Number", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"FLOAT\" {$aef_mysqldt_selected2}>";
     $output .= __("Decimal (Money and other floating values. Uses FLOAT)", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"VARCHAR\" {$aef_mysqldt_selected3}>";
     $output .= __("Short Text", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"TEXT\" {$aef_mysqldt_selected4}>";
     $output .= __("Long Text", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "</select>";
     $output .= "</p><p>";
     $output .= __("Field Options", 'awpcp-extra-fields');
     $output .= __(" for drop down lists, radio buttons, checkboxes ", 'awpcp-extra-fields');
     $output .= "(";
     $output .= __("type an option in each line", 'awpcp-extra-fields');
     $output .= ")<br/>";
     $output .= "<textarea name=\"awpcp_extra_field_options\" style=\"width:90%;\" rows=\"7\"/>";
     $output .= join("\n", (array) $awpcp_x_field_options);
     $output .= "</textarea>";
     $output .= "<p>";
     $output .= '<label for="awpcp-extra-field-validator">' . __("Validate Against", 'awpcp-extra-fields') . '</label>';
     $output .= ':&nbsp;<select id="awpcp-extra-field-validator" name="awpcp_extra_field_validation">';
     $output .= "<option value=\"\">";
     $output .= __("Select Option", 'awpcp-extra-fields');
     $output .= "</option>";
     if ($awpcp_x_field_validation == 'email') {
         $aef_validation_selected1 = " selected='selected'";
     } else {
         $aef_validation_selected1 = '';
     }
     if ($awpcp_x_field_validation == 'url') {
         $aef_validation_selected2 = " selected='selected'";
     } else {
         $aef_validation_selected2 = '';
     }
     if ($awpcp_x_field_validation == 'missing') {
         $aef_validation_selected3 = " selected='selected'";
     } else {
         $aef_validation_selected3 = '';
     }
     if ($awpcp_x_field_validation == 'numericdeci') {
         $aef_validation_selected4 = " selected='selected'";
     } else {
         $aef_validation_selected4 = '';
     }
     if ($awpcp_x_field_validation == 'numericnodeci') {
         $aef_validation_selected5 = " selected='selected'";
     } else {
         $aef_validation_selected5 = '';
     }
     if ($awpcp_x_field_validation == 'currency') {
         $aef_validation_selected6 = " selected='selected'";
     } else {
         $aef_validation_selected6 = '';
     }
     $output .= "<option value=\"email\" {$aef_validation_selected1}>";
     $output .= __('Email', 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"url\" {$aef_validation_selected2}>";
     $output .= __('URL', 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"currency\" {$aef_validation_selected6}>";
     $output .= __('Currency', 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"missing\" {$aef_validation_selected3}>";
     $output .= __("Missing Value", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"numericdeci\" {$aef_validation_selected4}>";
     $output .= __("Numeric decimal allowed", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value=\"numericnodeci\" {$aef_validation_selected5}>";
     $output .= __("Numeric no decimal allowed", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "</select>";
     $output .= "</p>";
     $output .= '</p><input type="hidden" value="0" name="awpcp-extra-field-required">';
     if ($required) {
         $output .= '<input id="awpcp-extra-field-required" type="checkbox" value="1" name="awpcp-extra-field-required" checked="checked">';
     } else {
         $output .= '<input id="awpcp-extra-field-required" type="checkbox" value="1" name="awpcp-extra-field-required">';
     }
     $output .= '&nbsp;<label for="awpcp-extra-field-required">' . __("Required (Check if this field should always have a value).", 'awpcp-extra-fields') . '</label>';
     $output .= "</p>";
     $output .= "<p>";
     $output .= '<label for="awpcp-extra-field-privacy">' . __("Privacy", 'awpcp-extra-fields') . '</label>';
     $output .= ':&nbsp;<select id="awpcp-extra-field-privacy" name="awpcp_extra_field_privacy">';
     $output .= '<option value="public"' . ($awpcp_x_field_privacy == 'public' ? ' selected="selected"' : '') . '>' . __("Public", 'awpcp-extra-fields') . '</option>';
     $output .= '<option value="restricted"' . ($awpcp_x_field_privacy == 'restricted' ? ' selected="selected"' : '') . '>' . __('Restricted', 'awpcp-extra-fields') . '</option>';
     $output .= '<option value="private"' . ($awpcp_x_field_privacy == 'private' ? ' selected="selected"' : '') . '>' . __("Private", 'awpcp-extra-fields') . '</option>';
     $output .= "</select>";
     $output .= '<br><em>' . __("If you want to collect information from users but don't want it to be displayed publicly, choose Private. Choose Restricted if you want to show the information to logged in users only.", 'awpcp-extra-fields') . '</em>';
     $output .= "</p>";
     $output .= '<div>';
     $output .= '<label>' . __('Categories', 'awpcp-extra-fields') . '</label>:';
     $output .= '&nbsp;<a href="#" data-categories="all">' . _x('All', 'all categories', 'awpcp-extra-fields') . '</a>';
     $output .= '&nbsp;<a href="#" data-categories="none">' . _x('None', 'no categories', 'awpcp-extra-fields') . '</a>';
     $output .= '<div class="category-checklist">';
     $params = array('field_name' => 'awpcp_extra_field_category', 'selected' => $awpcp_x_field_category);
     $output .= awpcp_categories_checkbox_list_renderer()->render($params);
     $output .= '</div>';
     $output .= '<em>' . __('This field will appear only in the selected categories.', 'awpcp-extra-fields') . '</em>';
     $output .= '</div>';
     if ('' == $show_on_listings) {
         $show_on_listings = 2;
     }
     $output .= "<p>";
     $output .= '<label for="awpcp-extra-field-show-on">' . __("Show this field to the user on", 'awpcp-extra-fields') . '</label>';
     $output .= ":&nbsp;<select id=\"awpcp-extra-field-show-on\" name=\"awpcp_extra_field_listings\">";
     $output .= '<option value="1"';
     if (1 == $show_on_listings) {
         $output .= ' selected="selected" ';
     }
     $output .= ">";
     $output .= __("Ad Listing Display", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value='2'";
     if (2 == $show_on_listings) {
         $output .= ' selected="selected" ';
     }
     $output .= ">";
     $output .= __("Single Ad Display", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "<option value='3'";
     if (3 == $show_on_listings) {
         $output .= ' selected="selected" ';
     }
     $output .= ">";
     $output .= __("Both", 'awpcp-extra-fields');
     $output .= "</option>";
     $output .= "</select>.</p>";
     $output .= "<p>";
     if (0 != $awpcp_x_field_nosearch) {
         $checked = "checked='checked'";
     } else {
         $checked = '';
     }
     $output .= '<input type="hidden" name="awpcp_extra_field_nosearch" value="0">';
     $output .= '<input id="awpcp-extra-field-do-not-show-in-search" type="checkbox" name="awpcp_extra_field_nosearch" value="1" ' . $checked . '>';
     $output .= '&nbsp;<label for="awpcp-extra-field-do-not-show-in-search">' . __('Do not show this field on the search form.', 'awpcp-extra-fields') . '</label>';
     $output .= "</p>";
     $output .= "<br/>";
     $output .= "<input type=\"hidden\" name=\"action\" value=\"savefielddata\" />";
     $output .= "<input type=\"hidden\" name=\"awpcp_extra_field_id\" value=\"{$awpcp_x_field_id}\" />";
     $output .= "<input type=\"hidden\" name=\"awpcp_x_field_name_old\" value=\"{$awpcp_x_field_name}\" />";
     $submit = empty($awpcp_x_field_id) ? __("Add New Field", 'awpcp-extra-fields') : __("Update Field", 'awpcp-extra-fields');
     $output .= '<input type="submit" value="' . $submit . '" class="button-primary" id="submit" name="updateextrafield">';
     $output .= "</form>";
     return $output;
 }
Example #9
0
 private function missing_gd_library_notice()
 {
     $message = __("AWPCP requires the graphics processing library GD and it is not installed. Contact your web host to fix this.", "AWPCP");
     $message = sprintf('<strong>%s</strong> %s', __('Warning', 'AWPCP'), $message);
     return awpcp_print_error($message);
 }
 private function show_module_no_registered_notice($module_name)
 {
     $message = __('Yikes, there has been a mistake. It looks like you have an outdated version of AWPCP <module-name> module or you need a newer version of AWPCP to use that module. Please contact customer support and ask for an update. Please also include a reference to this error in your message.', 'AWPCP');
     $message = str_replace('<module-name>', '<strong>' . $module_name . '</strong>', $message);
     return awpcp_print_error($message);
 }
Example #11
0
/**
 * 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;
}
Example #12
0
 public function delete_ad_step()
 {
     $ad = $this->get_ad();
     if (is_null($ad)) {
         $message = __('The specified Ad doesn\'t exists.', 'AWPCP');
         return $this->render('content', awpcp_print_error($message));
     }
     if (!awpcp_post_param('confirm', false) || !$ad->delete()) {
         $this->messages[] = __('There was a problem trying to delete your Ad. The Ad was not deleted.', 'AWPCP');
         return $this->details_step();
     }
     if (get_awpcp_option('requireuserregistration')) {
         return $this->render_delete_listing_confirmation();
     } else {
         return $this->enter_email_and_key_step();
     }
 }
Example #13
0
 public function finish_step()
 {
     $transaction = $this->page->get_transaction();
     if (is_null($transaction)) {
         $message = $this->page->transaction_error();
         return $this->page->render('content', awpcp_print_error($message));
     }
     $ad = $this->page->get_ad();
     if (is_null($ad)) {
         $message = __('The Ad associated with this transaction doesn\'t exists.', 'AWPCP');
         return $this->page->render('content', awpcp_print_error($message));
     }
     if (!$transaction->is_completed()) {
         $payments = awpcp_payments_api();
         $payments->set_transaction_status_to_completed($transaction, $errors);
         if (!empty($errors)) {
             return $this->page->render('content', join(',', array_map($errors, 'awpcp_print_error')));
         }
         $ad->renew();
         $ad->save();
         awpcp_send_ad_renewed_email($ad);
         // MOVE inside Ad::renew() ?
         do_action('awpcp-renew-ad', $ad->ad_id, $transaction);
     }
     return $this->page->render_finish_step($ad);
 }
Example #14
0
 /**
  * Shows a notice if any of the AWPCP pages shares its name with the
  * dynamic page View Categories.
  *
  * If a page share its name with the View Categories page, that page
  * will become unreachable.
  *
  * @since 3.0.2
  */
 public function check_duplicate_page_names()
 {
     global $wpdb;
     $view_categories_option = 'view-categories-page-name';
     $view_categories = sanitize_title(awpcp_get_page_name($view_categories_option));
     $view_categories_url = awpcp_get_view_categories_url();
     $duplicates = array();
     $awpcp_pages = array();
     $wp_pages = array();
     $posts = get_posts(array('post_type' => 'page', 'name' => $view_categories));
     foreach ($posts as $post) {
         if ($view_categories_url == get_permalink($post->ID)) {
             $duplicates[] = $post;
         }
     }
     $pages = empty($duplicates) ? array() : awpcp_get_plugin_pages_refs();
     foreach ($duplicates as $page) {
         if (isset($pages[$page->ID])) {
             $awpcp_pages[] = ucwords(awpcp()->settings->get_option_label($pages[$page->ID]->page));
         } else {
             $wp_pages[] = $page->post_title;
         }
     }
     if (!empty($awpcp_pages) || !empty($wp_pages)) {
         $view_categories_label = awpcp()->settings->get_option_label($view_categories_option);
         $view_categories_label = sprintf('<strong>%s</strong>', ucwords($view_categories_label));
     }
     if (!empty($awpcp_pages)) {
         $duplicated_pages = '<strong>' . join('</strong>, <strong>', $awpcp_pages) . '</strong>';
         $message = _n(count($awpcp_pages), '%1$s has the same name as the %2$s. That will cause %1$s to become unreachable. Please make sure you don\'t have duplicate page names.', '%1$s have the same name as the %2$s. That will cause %1$s to become unreachable. Please make sure you don\'t have duplicate page names.', 'AWPCP');
         $message = sprintf($message, $duplicated_pages, $view_categories_label);
         echo awpcp_print_error($message);
     }
     if (!empty($wp_pages)) {
         $duplicated_pages = '<strong>' . join('</strong>, <strong>', $wp_pages) . '</strong>';
         $message = _n(count($wp_pages), 'Page %1$s has the same name as the AWPCP %2$s. That will cause WordPress page %1$s to become unreachable. The %2$s is dynamic; you don\'t need to create a real WordPress page to show the list of cateogries, the plugin will generate it for you. If the WordPress page was created to show the default list of AWPCP categories, you can delete it and this error message will go away. Otherwise, please make sure you don\'t have duplicate page names.', 'Pages %1$s have the same name as the AWPCP %2$s. That will cause WordPress pages %1$s to become unreachable. The %2$s is dynamic; you don\'t need to create a real WordPress page to show the list of cateogries, the plugin will generate it for you. If the WordPress pages were created to show the default list of AWPCP categories, you can delete them and this error message will go away. Otherwise, please make sure you don\'t have duplicate page names.', 'AWPCP');
         $message = sprintf($message, $duplicated_pages, $view_categories_label);
         echo awpcp_print_error($message);
     }
 }
Example #15
0
/**
 * @since 3.0.2
 */
function awpcp_module_not_compatible_notice($module, $installed_version)
{
    global $awpcp_db_version;
    $modules = awpcp()->get_premium_modules_information();
    $name = $modules[$module]['name'];
    $required_version = $modules[$module]['required'];
    $message = __('This version of AWPCP %1$s module is not compatible with AWPCP version %2$s. Please get AWPCP %1$s %3$s or newer!', 'AWPCP');
    $message = sprintf($message, '<strong>' . $name . '</strong>', $awpcp_db_version, '<strong>' . $required_version . '</strong>');
    $message = sprintf('<strong>%s:</strong> %s', __('Error', 'AWPCP'), $message);
    return awpcp_print_error($message);
}
 private function render_notice()
 {
     $message = __("You enabled the Credit System, but there are no credit plans defined. Please <credits-section-link>add credit plans or disable the Credit System</a>.", 'AWPCP');
     $message = str_replace('<credits-section-link>', sprintf('<a href="%s">', awpcp_get_admin_credit_plans_url()), $message);
     echo awpcp_print_error($message);
 }