Example #1
0
function awpcpui_process($awpcppagename)
{
    global $hasrssmodule, $hasregionsmodule, $awpcp_plugin_url;
    $output = '';
    $action = '';
    $awpcppage = get_currentpagename();
    if (!isset($awpcppagename) || empty($awpcppagename)) {
        $awpcppagename = sanitize_title($awpcppage, $post_ID = '');
    }
    if (isset($_REQUEST['a']) && !empty($_REQUEST['a'])) {
        $action = $_REQUEST['a'];
    }
    // TODO: this kind of requests should be handled in Region Control's own code
    if ($action == 'setregion' || '' != get_query_var('regionid')) {
        if ($hasregionsmodule == 1) {
            if (isset($_REQUEST['regionid']) && !empty($_REQUEST['regionid'])) {
                $region_id = $_REQUEST['regionid'];
            } else {
                $region_id = get_query_var('regionid');
            }
            // double check module existence :\
            if (method_exists('AWPCP_Region_Control_Module', 'set_location')) {
                $region = awpcp_region_control_get_entry(array('id' => $region_id));
                $regions = AWPCP_Region_Control_Module::instance();
                $regions->set_location($region);
            }
        }
    }
    $categoriesviewpagename = sanitize_title(get_awpcp_option('view-categories-page-name'));
    $browsestat = '';
    $browsestat = get_query_var('cid');
    $layout = get_query_var('layout');
    $isadmin = checkifisadmin();
    awpcp_enqueue_main_script();
    $isclassifiedpage = checkifclassifiedpage($awpcppage);
    if ($isclassifiedpage == false && $isadmin == 1) {
        $output .= __("Hi admin, you need to go to your dashboard and setup your classifieds.", "AWPCP");
    } elseif ($isclassifiedpage == false && $isadmin != 1) {
        $output .= __("You currently have no classifieds", "AWPCP");
    } elseif ($browsestat == $categoriesviewpagename) {
        $output .= awpcp_display_the_classifieds_page_body($awpcppagename);
    } elseif ($layout == 2) {
        $output .= awpcp_display_the_classifieds_page_body($awpcppagename);
    } else {
        $output .= awpcp_load_classifieds($awpcppagename);
    }
    return $output;
}
Example #2
0
function deletead($adid, $adkey, $editemail, $force = false, &$errors = array())
{
    $output = '';
    $awpcppage = get_currentpagename();
    $awpcppagename = sanitize_title($awpcppage, $post_ID = '');
    $isadmin = checkifisadmin() || $force;
    if (get_awpcp_option('onlyadmincanplaceads') && $isadmin != 1) {
        $message = __("You do not have permission to perform the function you are trying to perform. Access to this page has been denied", "AWPCP");
        $errors[] = $message;
    } else {
        global $wpdb, $nameofsite;
        $tbl_ads = $wpdb->prefix . "awpcp_ads";
        $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos";
        $savedemail = get_adposteremail($adid);
        if ($isadmin == 1 || strcasecmp($editemail, $savedemail) == 0) {
            $ad = AWPCP_Ad::find_by_id($adid);
            if ($ad && $ad->delete()) {
                if ($isadmin == 1 && is_admin()) {
                    $message = __("The Ad has been deleted", "AWPCP");
                    return $message;
                } else {
                    $message = __("Your Ad details and any photos you have uploaded have been deleted from the system", "AWPCP");
                    $errors[] = $message;
                }
            } else {
                if ($ad === null) {
                    $errors[] = __("The specified Ad doesn't exists.", 'AWPCP');
                } else {
                    $errors[] = __("There was an error trying to delete the Ad. The Ad was not deleted.", 'AWPCP');
                }
            }
        } else {
            $message = __("Problem encountered. Cannot complete  request", "AWPCP");
            $errors[] = $message;
        }
    }
    $output .= "<div id=\"classiwrapper\">";
    $output .= awpcp_menu_items();
    $output .= "<p>";
    $output .= $message;
    $output .= "</p>";
    $output .= "</div>";
    return $output;
}