Beispiel #1
0
 /**
  * Register Ad Management Panel menu
  */
 public function menu()
 {
     /* Profile Menu */
     // We are using read as an alias for edit_classifieds_listings. If a user can `read`,
     // he or she can `edit_classifieds_listings`.
     $capability = 'read';
     // Account Balance
     if (awpcp_payments_api()->credit_system_enabled() && !awpcp_current_user_is_admin()) {
         $parts = array($this->account->title, $this->account->menu, $this->account->page);
         $hook = add_users_page($parts[0], $parts[1], $capability, $parts[2], array($this->account, 'dispatch'));
         add_action("admin_print_styles-{$hook}", array($this->account, 'scripts'));
     }
     $current_user_is_non_admin_moderator = awpcp_current_user_is_moderator() && !awpcp_current_user_is_admin();
     if (get_awpcp_option('enable-user-panel') != 1 || $current_user_is_non_admin_moderator) {
         return;
     }
     /* Ad Management Menu */
     $slug = 'awpcp-panel';
     $title = sprintf(__('%s Ad Management Panel', 'AWPCP'), get_bloginfo());
     $menu = __('Ad Management', 'AWPCP');
     $hook = add_menu_page($title, $menu, $capability, $slug, array($this->listings, 'dispatch'), MENUICO);
     // Listings
     $title = __('Manage Ad Listings', 'AWPCP');
     $menu = __('Listings', 'AWPCP');
     $hook = add_submenu_page($slug, $title, $menu, $capability, $slug, array($this->listings, 'dispatch'));
     add_action("admin_print_styles-{$hook}", array($this->listings, 'scripts'));
     do_action('awpcp_panel_add_submenu_page', $slug, $capability);
 }
Beispiel #2
0
 protected function get_panel_url()
 {
     if (awpcp_current_user_is_moderator() || !get_awpcp_option('enable-user-panel')) {
         return awpcp_get_admin_listings_url();
     }
     return awpcp_get_user_panel_url();
 }
function awpcp_listings_table_search_by_condition_parser()
{
    $conditions = array(new AWPCP_ListingsTableSearchByIdCondition(), new AWPCP_ListingsTableSearchByKeywordCondition(), new AWPCP_ListingsTableSearchByLocationCondition(), new AWPCP_ListingsTableSearchByTitleCondition(), new AWPCP_ListingsTableSearchByUserCondition());
    if (awpcp_current_user_is_moderator()) {
        $conditions[] = new AWPCP_ListingsTableSearchByPayerEmailCondition();
    }
    return new AWPCP_ListingsTableSearchConditionsParser($conditions);
}
 public function renew_ad()
 {
     if (awpcp_current_user_is_moderator()) {
         return parent::renew_ad();
     } else {
         $page = new AWPCP_UserListingsRenewAd();
         return $page->dispatch('renew');
     }
 }
 public function is_readonly($value)
 {
     $make_contact_fields_writable = $this->settings->get_option('make-contact-fields-writable-for-logged-in-users');
     if (is_user_logged_in() && $make_contact_fields_writable) {
         return false;
     }
     if (!is_user_logged_in() || awpcp_current_user_is_moderator() || empty($value)) {
         return false;
     }
     return true;
 }
 protected function is_read_only()
 {
     if (awpcp_current_user_is_moderator()) {
         return false;
     }
     if ($this->settings->get_option('allow-regions-modification')) {
         return false;
     }
     // ugly hack to figure out if we are editing or creating a list...
     if ($transaction = $this->payments->get_transaction()) {
         return false;
     }
     return true;
 }
Beispiel #7
0
 public function create($args)
 {
     extract(wp_parse_args($args, array('enabled' => true, 'status' => null, 'is_primary' => false)));
     $image_mime_types = awpcp_get_image_mime_types();
     if (is_null($status)) {
         if (!awpcp_current_user_is_moderator() && in_array($mime_type, $image_mime_types) && get_awpcp_option('imagesapprove')) {
             $status = AWPCP_Media::STATUS_AWAITING_APPROVAL;
         } else {
             $status = AWPCP_Media::STATUS_APPROVED;
         }
     }
     $data = compact('ad_id', 'name', 'path', 'mime_type', 'enabled', 'status', 'is_primary');
     if ($insert_id = $this->save($data)) {
         return $this->find_by_id($insert_id);
     } else {
         return null;
     }
 }
 public function get_columns()
 {
     $columns = array();
     $columns['cb'] = '<input type="checkbox" />';
     $columns['title'] = __('Headline', 'AWPCP');
     $columns['manage'] = __('Manage Ad', 'AWPCP');
     $columns['start_date'] = __('Start Date', 'AWPCP');
     $columns['end_date'] = __('End Date', 'AWPCP');
     $columns['renewed_date'] = __('Renewed Date', 'AWPCP');
     $columns['status'] = __('Status', 'AWPCP');
     $columns['payment_term'] = __('Payment Term', 'AWPCP');
     $columns['payment_status'] = __('Payment Status', 'AWPCP');
     if (defined('AWPCP_FEATURED_ADS_MODULE')) {
         $columns['featured'] = __('Featured', 'AWPCP');
     }
     if (awpcp_current_user_is_moderator()) {
         $columns['owner'] = __('Owner', 'AWPCP');
     }
     return $columns;
 }
Beispiel #9
0
 protected function show_upload_images_form($ad, $transaction, $params, $errors)
 {
     $allowed_files = awpcp_listing_upload_limits()->get_listing_upload_limits($ad);
     $params = array_merge($params, array('transaction' => $transaction, 'hidden' => array('transaction_id' => $transaction->id), 'errors' => $errors, 'media_manager_configuration' => array('nonce' => wp_create_nonce('awpcp-manage-listing-media-' . $ad->ad_id), 'allowed_files' => $allowed_files, 'show_admin_actions' => awpcp_current_user_is_moderator()), 'media_uploader_configuration' => array('listing_id' => $ad->ad_id, 'nonce' => wp_create_nonce('awpcp-upload-media-for-listing-' . $ad->ad_id), 'allowed_files' => $allowed_files)));
     return $this->upload_images_form($ad, $params);
 }
 public function manage_images($listing)
 {
     $allowed_files = awpcp_listing_upload_limits()->get_listing_upload_limits($listing);
     $params = array('listing' => $listing, 'files' => awpcp_media_api()->find_by_ad_id($listing->ad_id), 'media_manager_configuration' => array('nonce' => wp_create_nonce('awpcp-manage-listing-media-' . $listing->ad_id), 'allowed_files' => $allowed_files, 'show_admin_actions' => awpcp_current_user_is_moderator()), 'media_uploader_configuration' => array('listing_id' => $listing->ad_id, 'nonce' => wp_create_nonce('awpcp-upload-media-for-listing-' . $listing->ad_id), 'allowed_files' => $allowed_files), 'urls' => array('view-listing' => $this->url(array('action' => 'view', 'id' => $listing->ad_id)), 'listings' => $this->url(array('id' => null))));
     echo $this->render(AWPCP_DIR . '/templates/admin/listings-media-center.tpl.php', $params);
 }
<div style="padding:20px" class="postbox">
    <div style="padding:4px 0px;; margin-bottom:5px;">

        <?php 
if (awpcp_current_user_is_moderator()) {
    ?>
        <strong><?php 
    _e('Access Key', 'AWPCP');
    ?>
</strong>: <?php 
    echo $ad->get_access_key();
    ?>
        <?php 
}
?>

        &raquo; <a href="<?php 
echo esc_attr($this->url(array('action' => false)));
?>
"><?php 
_e('Return to Listings', 'AWPCP');
?>
</a>

    </div>

    <div style="padding:4px 0px;; margin-bottom:10px;">

        <b><?php 
_e('Category', 'AWPCP');
?>
Beispiel #12
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;
}
Beispiel #13
0
function awpcp_should_disable_existing_listing($listing)
{
    if (awpcp_current_user_is_moderator()) {
        $should_disable = false;
    } else {
        if (get_awpcp_option('disable-edited-listings-until-admin-approves')) {
            $should_disable = true;
        } else {
            $should_disable = false;
        }
    }
    return $should_disable;
}
 /**
  * @since 3.0.2
  * @tested
  */
 public function verify_ad($ad)
 {
     if ($ad->verified) {
         return;
     }
     $timestamp = current_time('timestamp');
     $now = awpcp_datetime('mysql', $timestamp);
     $ad->verified = true;
     $ad->verified_at = awpcp_datetime();
     $ad->set_start_date($now);
     $ad->set_end_date($ad->get_payment_term()->calculate_end_date($timestamp));
     if ($ad->disabled && awpcp_should_enable_new_listing_with_payment_status($ad, $ad->payment_status)) {
         $ad->enable(!get_awpcp_option('imagesapprove', false));
     }
     if (!awpcp_current_user_is_moderator()) {
         $this->send_ad_posted_email_notifications($ad);
     }
     $ad->save();
 }
Beispiel #15
0
 public function finish_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));
     }
     awpcp_listings_api()->consolidate_existing_ad($ad);
     if (is_admin()) {
         $message = __('The Ad has been edited successfully. <a href="%s">Go back to view listings</a>.', 'AWPCP');
         $page = awpcp_current_user_is_moderator() ? 'awpcp-listings' : 'awpcp-panel';
         $url = add_query_arg('page', $page, admin_url('admin.php'));
         $this->messages[] = sprintf($message, esc_url($url));
     }
     $template = AWPCP_DIR . '/frontend/templates/page-place-ad-finish-step.tpl.php';
     $params = array('messages' => array_merge($this->messages, awpcp_listings_api()->get_ad_alerts($ad)), 'edit' => true, 'ad' => $ad);
     return $this->render($template, $params);
 }