title = __('Classifieds', 'AWPCP'); $this->settings = new AWPCP_Admin_Settings(); $this->importer = new AWPCP_Admin_CSV_Importer(); $this->debug = new AWPCP_Admin_Debug(); $this->uninstall = new AWPCP_Admin_Uninstall(); add_action('wp_ajax_disable-quick-start-guide-notice', array($this, 'disable_quick_start_guide_notice')); add_action('admin_init', array($this, 'init')); add_action('admin_enqueue_scripts', array($this, 'scripts')); add_action('admin_menu', array($this, 'menu')); add_action('admin_notices', array($this, 'notices')); // make sure AWPCP admins (WP Administrators and/or Editors) can edit settings add_filter('option_page_capability_awpcp-options', 'awpcp_admin_capability'); // hook filter to output Admin panel sidebar. To remove the sidebar // just remove this action add_filter('awpcp-admin-sidebar', 'awpcp_admin_sidebar_output', 10, 2); // This functions were executed on plugins_loaded. However, // to avoid execution of AWPCP functions without propperly // upgrading the plugin database, we execute them here, only // after AWPCP_Admin has been instatiated by AWPCP. awpcp_handle_admin_requests(); awpcp_savefees(); awpcp_addfees(); } public function notices() { if (get_awpcp_option('show-quick-start-guide-notice')) { ob_start(); include(AWPCP_DIR . '/admin/templates/admin-quick-start-guide-notice.tpl.php'); $html = ob_get_contents(); ob_end_clean(); echo $html; } } public function init() { // remove_filter('awpcp-admin-sidebar', 'awpcp_admin_sidebar_output'); wp_register_style('awpcp-admin-style', AWPCP_URL . 'css/awpcp-admin.css', array(), '0.1.0'); wp_register_script('awpcp-table-ajax-admin', AWPCP_URL . 'js/jquery.table-ajax-admin.js', array('jquery-form'), '1.0', true); wp_register_script('awpcp-admin-script', AWPCP_URL . 'js/admin-panel-listings.js', array('jquery-form'), '1.0', true); } public function scripts() { wp_enqueue_style('awpcp-admin-style'); wp_enqueue_script('awpcp-admin-script'); } public function menu() { global $hasregionsmodule; global $hasextrafieldsmodule; $capability = awpcp_admin_capability(); $slug = 'awpcp.php'; add_menu_page('AWPCP Classifieds Management System', $this->title, $capability, $slug, 'awpcp_home_screen', MENUICO); add_submenu_page($slug, 'Configure General Options ', 'Settings', $capability, 'awpcp-admin-settings', array($this->settings, 'dispatch')); add_submenu_page($slug, 'Listing Fees Setup', 'Fees', $capability, 'Configure2', 'awpcp_opsconfig_fees'); add_submenu_page($slug, 'Add/Edit Categories', 'Categories', $capability, 'Configure3', 'awpcp_opsconfig_categories'); add_submenu_page($slug, 'View Ad Listings', 'Listings', $capability, 'Manage1', 'awpcp_manage_viewlistings'); // disabled because doesn't seems to be usefull anymore // add_submenu_page($slug, 'View Ad Images', 'Images', '7', 'Manage2', 'awpcp_manage_viewimages'); $hook = add_submenu_page($slug, 'Import Ad', 'Import', $capability, 'awpcp-import', array($this->importer, 'dispatch')); add_action("load-{$hook}", array($this->importer, 'scripts')); // allow plugins to define additional sub menu entries do_action('awpcp_admin_add_submenu_page', $slug, $capability); if ($hasextrafieldsmodule) { add_submenu_page($slug, 'Manage Extra Fields', 'Extra Fields', $capability, 'Configure5', 'awpcp_add_new_field'); } add_submenu_page($slug, 'Debug', 'Debug', $capability, 'awpcp-debug', array($this->debug, 'dispatch')); add_submenu_page($slug, 'Uninstall AWPCP', 'Uninstall', $capability, 'awpcp-admin-uninstall', array($this->uninstall, 'dispatch')); // allow plugins to define additional menu entries do_action('awpcp_add_menu_page'); } public function disable_quick_start_guide_notice() { global $awpcp; $awpcp->settings->update_option('show-quick-start-guide-notice', false); die('Success!'); } } // // if there's a page name collision remove AWPCP menus so that nothing can be accessed // add_action('init', 'awpcp_pagename_warning_check', -1); // function awpcp_pagename_warning_check() { // if (!get_option('awpcp_pagename_warning', false)) { // return; // } // remove_action('admin_menu', 'awpcp_launch'); // } // // display a warning if necessary // add_action('admin_notices', 'awpcp_pagename_warning', 10); // function awpcp_pagename_warning() { // if (!get_option('awpcp_pagename_warning', false)) { // return; // } // echo '

'; // echo 'WARNING: A page named AWPCP already exists. You must either delete that page and its subpages, or rename them before continuing with the plugin configuration.'; // echo '

'; // } // START FUNCTION: Check if the user side classified page exists function checkifclassifiedpage($pagename) { global $wpdb, $table_prefix; $id = awpcp_get_page_id_by_ref('main-page-name'); $query = 'SELECT ID FROM ' . $wpdb->posts . ' WHERE ID = %d'; $page_id = $wpdb->get_var($wpdb->prepare($query, $id)); return $page_id === $id; } // END FUNCTION // START FUNCTION: Display the admin home screen function awpcp_home_screen() { global $message, $user_identity, $wpdb, $awpcp_plugin_path, $awpcp_imagesurl, $awpcp_db_version; global $haspoweredbyremovalmodule, $hasregionsmodule, $hascaticonsmodule, $hasgooglecheckoutmodule, $hasextrafieldsmodule, $hasrssmodule, $hasfeaturedadsmodule, $extrafieldsversioncompatibility; $tbl_ad_settings = $wpdb->prefix . "awpcp_adsettings"; $output = ''; // get Admin panel sidebar content $sidebar = awpcp_admin_sidebar('none; width: 100% !important'); $output .= "

"; $output .= __("AWPCP Classifieds Management System", "AWPCP"); $output .= "

"; $output .= __("You are using version","AWPCP"); $output .= " $awpcp_db_version

$message
"; $output .= __("Thank you for using Another Wordpress Classifieds Plugin, the #1 Wordpress Classifieds Plugin. Please direct support requests, enhancement ideas and bug reports to the ","AWPCP"); $output .= ""; $output .= __("AWPCP support website", "AWPCP"); $output .= ""; $output .= "
"; if ($hasextrafieldsmodule == 1) { if (!($extrafieldsversioncompatibility == 1)) { $output .= "
"; $output .= __("The version of the extra fields module that you are using is not compatible with this version of Another Wordpress Classifieds Plugin. Please request the updated files for the extra fields module","AWPCP"); $output .= "

"; $output .= __("Request Updated Extra Fields Module files","AWPCP"); $output .= "

"; } } $cpagename_awpcp=get_awpcp_option('main-page-name'); $awpcppagename = sanitize_title($cpagename_awpcp, $post_ID=''); $awpcp_classifieds_page_conflict_check=checkforduplicate(add_slashes_recursive($cpagename_awpcp)); if ( $awpcp_classifieds_page_conflict_check > 1) { $output .= "
\"Alert\""; $output .= __("It appears you have a potential problem that could result in the malfunctioning of Another Wordpress Classifieds plugin. A check of your database was performed and duplicate entries were found that share the same post_name value as your classifieds page. If for some reason you uninstall and then reinstall this plugin and the duplicate pages remain in your database, it could break the plugin and prevent it from working. To fix this problem you can manually delete the duplicate pages and leave only the page with the ID of your real classifieds page, or you can use the link below to rebuild your classifieds page. The process will include first deleting all existing pages with a post name value identical to your classifieds page. Note that if you recreate the page, it will be assigned a new page ID so if you are referencing the classifieds page ID anywhere outside of the classifieds program you will need to adjust the old ID to the new ID.","AWPCP"); $output .= "
"; $output .= __("Number of duplicate pages","AWPCP"); $output .= ": $awpcp_classifieds_page_conflict_check"; $output .= "
"; $output .= __("Duplicated post name","AWPCP"); $output .= ": $awpcppagename"; $output .= "

"; $output .= __("Recreate the classifieds page to fix the conflict","AWPCP"); $output .= "

"; } // if sidebar content is empty, the left column should take the // whole page width. if (empty($sidebar)) { $output .= "
"; } else { $output .= "
"; } $output .= "
"; $output .= "
"; $output .= __("Another Wordpress Classifieds Plugin Stats","AWPCP"); $output .= "
"; $totallistings=countlistings(1); $output .= "
"; $output .= __("Number of active listings currently in the system","AWPCP"); $output .= ": $totallistings"; $output .= "
"; $totallistings=countlistings(0); $output .= "
"; $output .= __("Number of inactive/expired/disabled listings currently in the system","AWPCP"); $output .= ": $totallistings"; $output .= "
"; if (get_awpcp_option('freepay') == 1) { if (adtermsset()) { $output .= "
"; $output .= __("You have setup your listing fees. To edit your fees use the 'Manage Listing Fees' option.","AWPCP"); $output .= "
"; } else { $output .= "
"; $output .= __("You have not configured your Listing fees. Use the 'Manage Listing Fees' option to set up your listing fees. Once that is completed, if you are running in pay mode, the options will automatically appear on the listing form for users to fill out.","AWPCP"); $output .= "
"; } } else { $output .= "
"; $output .= __("You currently have your system configured to run in free mode. To change to 'pay' mode go to 'Manage General Options' and Check the box labeled 'Charge listing fee? (Pay Mode)'","AWPCP"); $output .= "
"; } if (categoriesexist()) { $totalcategories=countcategories(); $totalparentcategories=countcategoriesparents(); $totalchildrencategories=countcategorieschildren(); $output .= "
    "; $output .= "
  • "; $output .= __("Total number of categories in the system","AWPCP"); $output .= ": $totalcategories
  • "; $output .= "
  • "; $output .= __("Number of Top Level parent categories","AWPCP"); $output .= ": $totalparentcategories
  • "; $output .= "
  • "; $output .= __("Number of sub level children categories","AWPCP"); $output .= ": $totalchildrencategories
  • "; $output .= "

"; $output .= __("Use the 'Manage Categories' option to edit/delete current categories or add new categories.","AWPCP"); $output .= "

"; } else { $output .= "
"; $output .= __("You have not setup any categories. Use the 'Manage Categories' option to set up your categories.","AWPCP"); $output .= "
"; } if (get_awpcp_option('freepay') == 1) { $output .= "
"; $output .= __("You currently have your system configured to run in pay mode. To change to 'free' mode go to 'Manage General Options' and check the box that accompanies the text 'Charge listing fee?'","AWPCP"); $output .= "
"; } $output .= "
"; $output .= __("Use the buttons on the right to configure your various options","AWPCP"); $output .= "
"; $output .= "
"; // Configure AWPCP link $href = admin_url('admin.php?page=awpcp-admin-settings'); $output.= '
'; $output.= 'AWPCP is highly customizable. Please go to the Settings section to fit AWPCP to your needs. '; $output.= ''; $output.= 'Configure AWPCP
'; // $output .= " // "; if (get_awpcp_option('showlatestawpcpnews')) { $output .= "
"; $output .= "
"; $output .= __("Latest News About Another Wordpress Classifieds Plugin","AWPCP"); $output .= "
"; $awpcpwidgets = get_option( 'dashboard_widget_options' ); @extract( @$awpcpwidgets['dashboard_secondary'], EXTR_SKIP ); $awpcpfeedurl="http://feeds2.feedburner.com/Awpcp"; $awpcpgetrss = @fetch_feed( $awpcpfeedurl ); if ( is_wp_error($awpcpgetrss) ) { if ( is_admin() || current_user_can('manage_options') ) { $output .= '

'; printf(__('RSS Error: %s', 'AWPCP'), $awpcpgetrss->get_error_message()); $output .= '

'; } } else { // Figure out how many total items there are, but limit it to 5. $maxitems = $awpcpgetrss->get_item_quantity(5); // Build an array of all the items, starting with element 0 (first element). $rss_items = $awpcpgetrss->get_items(0, $maxitems); $output .= '
    '; if ($maxitems == 0) { $output .= '
  • No news right now.
  • '; } else { // Loop through each feed item and display each item as a hyperlink. foreach ( $rss_items as $item ) { $title = 'AWPCP News '.$item->get_date('j F Y | g:i a').': '.$item->get_title(); $excerpt = $item->get_description(); $output .= '
  • '.$title.'
    '.$excerpt.'

  • '; } } $output .= '
'; } $output .= "
"; } $output .= "
"; $output .= "
"; $output .= $sidebar; $output .= "
"; $output .= "
"; echo $output; } // END FUNCTION /** * Check if any of the page names is being changed. * * If $send_changes is true, an array with info about the * pages that are being changed will be returned. Otherwise just * true or false. */ // XXX: I think this can be deleted function awpcp_check_for_new_page_names($options, $send_changes = false) { global $wpdb; $pages = array('main-page-name' => array(get_awpcp_option('main-page-name'), '[AWPCP]')); $pages = $pages + awpcp_subpages(); $changed = array(); foreach($pages as $page => $data) { if (isset($options[$page]) && strcmp($options[$page], $data[0]) != 0) { $changed[] = array('key' => $page, 'oldname' => $data[0], 'newname' => $options[$page]); } } if (!empty($changed)) { return $send_changes ? $changed : true; } return false; } // START FUNCTION: Manage categories function awpcp_opsconfig_categories() { //debug(); $output = ''; $cpagename_awpcp=get_awpcp_option('main-page-name'); $awpcppagename = sanitize_title($cpagename_awpcp, $post_ID=''); $action=''; global $wpdb, $message, $awpcp_imagesurl, $clearform,$hascaticonsmodule; $tbl_ad_categories = $wpdb->prefix . "awpcp_categories"; $offset=(isset($_REQUEST['offset'])) ? (clean_field($_REQUEST['offset'])) : ($offset=0); $results=(isset($_REQUEST['results']) && !empty($_REQUEST['results'])) ? clean_field($_REQUEST['results']) : ($results=10); $cat_ID=''; $category_name=''; $aeaction=''; $category_parent_id=''; $promptmovetocat=''; $aeaction=''; /////////////////// // Check for existence of a category ID and action if ( isset($_REQUEST['editcat']) && !empty($_REQUEST['editcat']) ) { $cat_ID=$_REQUEST['editcat']; $action = "edit"; } elseif ( isset($_REQUEST['delcat']) && !empty($_REQUEST['delcat']) ) { $cat_ID=$_REQUEST['delcat']; $action = "delcat"; } elseif ( isset($_REQUEST['managecaticon']) && !empty($_REQUEST['managecaticon']) ) { $cat_ID=$_REQUEST['managecaticon']; $action = "managecaticon"; } elseif (isset($_REQUEST['cat_ID']) && !empty($_REQUEST['cat_ID'])) { $cat_ID=$_REQUEST['cat_ID']; } if ( !isset($action) || empty($action) ) { if ( isset($_REQUEST['action']) && !empty($_REQUEST['action']) ) { $action=$_REQUEST['action']; } } if ( $action == 'edit' ) { $aeaction='edit'; } if ( $action == 'editcat' ) { $aeaction='edit'; } if ( $action == 'delcat' ) { $aeaction='delete'; } if ( $action == 'managecaticon' ) { $output .= "

"; $output .= __("AWPCP Classifieds Management System Categories Management","AWPCP"); $output .= "

"; global $awpcp_plugin_path; if ($hascaticonsmodule == 1 ) { if ( is_installed_category_icon_module() ) { $output .= load_category_icon_management_page($defaultid=$cat_ID,$offset,$results); } } $output .= "
"; return $output; //die; } if ( $action == 'setcategoryicon' ) { global $awpcp_plugin_path; if ($hascaticonsmodule == 1 ) { if ( is_installed_category_icon_module() ) { if ( isset($_REQUEST['cat_ID']) && !empty($_REQUEST['cat_ID']) ) { $thecategory_id=$_REQUEST['cat_ID']; } if ( isset($_REQUEST['category_icon']) && !empty($_REQUEST['category_icon']) ) { $theiconfile=$_REQUEST['category_icon']; } if ( isset($_REQUEST['offset']) && !empty($_REQUEST['offset']) ) { $offset=$_REQUEST['offset']; } if ( isset($_REQUEST['results']) && !empty($_REQUEST['results']) ) { $results=$_REQUEST['results']; } $message=set_category_icon($thecategory_id,$theiconfile,$offset,$results); if ( isset($message) && !empty($message) ) { $clearform=1; } } } } if ( isset($clearform) && ( $clearform == 1) ) { unset($cat_ID,$action, $aeaction); } $category_name=get_adcatname($cat_ID); $category_order=get_adcatorder($cat_ID); $category_order = ($category_order != 0 ? $category_order : 0); $cat_parent_ID=get_cat_parent_ID($cat_ID); if ($aeaction == 'edit') { $aeword1=__("You are currently editing the category shown below","AWPCP"); $aeword2=__("Save Category Changes","AWPCP"); $aeword3=__("Parent Category","AWPCP"); $aeword4=__("Category List Order","AWPCP"); $addnewlink=""; $addnewlink.=__("Add A New Category","AWPCP"); $addnewlink.=""; } elseif ($aeaction == 'delete') { if ( $cat_ID != 1) { $aeword1=__("If you're sure that you want to delete this category please press the delete button","AWPCP"); $aeword2=__("Delete Category","AWPCP"); $aeword3=__("Parent Category","AWPCP"); $aeword4=''; $addnewlink=""; $addnewlink.=__("Add A New Category","AWPCP"); $addnewlink.=""; if (ads_exist_cat($cat_ID)) { if ( category_is_child($cat_ID) ) { $movetocat=get_cat_parent_ID($cat_ID); } else { $movetocat=1; } $movetoname=get_adcatname($movetocat); if ( empty($movetoname) ) { $movetoname=__("Untitled","AWPCP"); } $promptmovetocat="

"; $promptmovetocat.=__("The category contains ads. If you do not select a category to move them to the ads will be moved to:","AWPCP"); $promptmovetocat.="$movetoname

"; $defaultcatname=get_adcatname($catid=1); if ( empty($defaultcatname) ) { $defaultcatname=__("Untitled","AWPCP"); } if (category_has_children($cat_ID)) { $promptmovetocat.="

"; $promptmovetocat.=__("The category also has children. If you do not specify a move-to category the children will be adopted by","AWPCP"); $promptmovetocat.="$defaultcatname

"; $promptmovetocat.=__("Note","AWPCP"); $promptmovetocat.=":"; $promptmovetocat.=__("The move-to category specified applies to both ads and categories","AWPCP"); $promptmovetocat.="

"; } $promptmovetocat.="

"; } $thecategoryparentname=get_adparentcatname($cat_parent_ID); } else { $aeword1=__("Sorry but you cannot delete ","AWPCP"); $aeword1.="$category_name"; $aeword1.=__(" It is the default category. The default category cannot be deleted","AWPCP"); $aeword2=''; $aeword3=''; $aeword4=''; $addnewlink=""; $addnewlink.=__("Add A New Category","AWPCP"); $addnewlink.=""; } } else { if ( empty($aeaction) ) { $aeaction="newcategory"; } $aeword1=__("Enter the category name","AWPCP"); $aeword2=__("Add New Category","AWPCP"); $aeword3=__("List Category Under","AWPCP"); $aeword4=__("Category List Order","AWPCP"); $addnewlink=''; } if ($aeaction == 'delete') { $orderinput=''; if ($cat_ID == 1) { $categorynameinput=''; $selectinput=''; } else { $categorynameinput="

"; $categorynameinput.=__("Category to Delete","AWPCP"); $categorynameinput.=": $category_name

"; $selectinput="

$thecategoryparentname

"; $submitbuttoncode=""; } } elseif ($aeaction == 'edit') { $categorynameinput="

"; $categorynameinput.=__("Category to Edit","AWPCP"); $categorynameinput.=": $category_name "; $categorynamefield = ""; $selectinput=""; $categories= get_categorynameid($cat_ID,$cat_parent_ID,$exclude=''); $selectinput.="$categories "; $submitbuttoncode=""; } else { $categorynameinput="

"; $categorynameinput.=__("Add a New Category","AWPCP"); $categorynamefield =""; $selectinput=""; $categories= get_categorynameid($cat_ID,$cat_parent_ID,$exclude=''); $selectinput.="$categories "; $submitbuttoncode=""; } // Start the page display $output .= "

"; $output .= __("AWPCP Classifieds Management System Categories Management","AWPCP"); $output .= "

"; if (isset($message) && !empty($message)) { $output .= $message; } $sidebar = awpcp_admin_sidebar(); $output .= $sidebar; if (empty($sidebar)) { $output .= "

"; } else { $output .= "

"; } $output .= __("Below you can add and edit your categories. For more information about managing your categories visit the link below.","AWPCP"); $output .= "

"; $output .= __("Useful Information for Classifieds Categories Management","AWPCP"); $output .= "

"; $output .= __("Icon Meanings","AWPCP"); $output .= ":    \"";"; $output .= __("Edit Category","AWPCP"); $output .= "    \"";"; $output .= __("Delete Category","AWPCP"); if ($hascaticonsmodule == 1 ) { if ( is_installed_category_icon_module() ) { $label = __("Manage Category Icon", "AWPCP"); $output .= "    \"";"; $output .= $label; } } else { $output .= "

"; $output .= __("There is a premium module available that allows you to add icons to your categories. If you are interested in adding icons to your categories ","AWPCP"); $output .= ""; $output .= __("Click here to find out about purchasing the Category Icons Module","AWPCP"); $output .= "

"; } $output .= "
"; if (empty($sidebar)) { $output .= "

"; } else { $output .= "

"; } $output .= "

$aeword1

$categorynameinput $aeword3 $aeword4
$categorynamefield $selectinput $orderinput
$promptmovetocat

$submitbuttoncode $addnewlink

"; if (empty($sidebar)) { $output .= "

"; } else { $output .= "

"; } /////////////////////////// // Show the paginated categories list for management ////////////////////////// $from="$tbl_ad_categories"; $where="category_name <> ''"; $pager1=create_pager($from,$where,$offset,$results,$tpname=''); $pager2=create_pager($from,$where,$offset,$results,$tpname=''); $output .= "$pager1

"; $output .= __("If deleting categories","AWPCP"); $output .= ""; $output .= __("Move Ads if any","AWPCP"); $output .= ""; $output .= __("Delete Ads if any","AWPCP"); $output .= "

"; $items=array(); $query="SELECT category_id,category_name,category_parent_id,category_order FROM $from WHERE $where ORDER BY category_order,category_name ASC LIMIT $offset,$results"; $res = awpcp_query($query, __LINE__); while ($rsrow=mysql_fetch_row($res)) { $thecategoryicon=''; if ( function_exists('get_category_icon') ) { $category_icon=get_category_icon($rsrow[0]); } if ( isset($category_icon) && !empty($category_icon) ) { $caticonsurl="$awpcp_imagesurl/caticons/$category_icon"; $thecategoryicon="\"$rsrow[1]\""; } $thecategory_id=$rsrow[0]; $thecategory_name="$thecategoryicon".stripslashes($rsrow[1]).""; $thecategory_parent_id=$rsrow[2]; $thecategory_order=($rsrow[3] != '' ? $rsrow[3] : 0); $thecategory_parent_name=stripslashes(get_adparentcatname($thecategory_parent_id)); $totaladsincat=total_ads_in_cat($thecategory_id); if ($hascaticonsmodule == 1 && is_installed_category_icon_module()) { $managecaticon = "\"";"; } else { $managecaticon = ''; } $awpcpeditcategoryword=__("Edit Category","AWPCP"); $awpcpdeletecategoryword=__("Delete Category","AWPCP"); $items[] = "$thecategory_name ($totaladsincat) $thecategory_parent_name $thecategory_order \"$awpcpeditcategoryword\" \"$awpcpdeletecategoryword\" $managecaticon"; } $opentable=""; $closetable="
"; $opentable.=__("Category Name (Total Ads)","AWPCP"); $opentable.=""; $opentable.=__("Parent","AWPCP"); $opentable.=""; $opentable.=__("Order","AWPCP"); $opentable.=""; $opentable.=__("Action","AWPCP"); $opentable.="
"; $closetable.=__("Category Name (Total Ads)","AWPCP"); $closetable.=""; $closetable.=__("Parent","AWPCP"); $closetable.=""; $closetable.=__("Order","AWPCP"); $closetable.=""; $closetable.=__("Action","AWPCP"); $closetable.="
"; $theitems=smart_table($items,intval($results/$results),$opentable,$closetable); $showcategories="$theitems"; $output .= " $showcategories
$pager2
"; echo $output; } // END FUNCTION: Manage categories // START FUNCTION: Manage view images // function awpcp_manage_viewimages() // { // //debug(); // $output = ''; // $cpagename_awpcp=get_awpcp_option('main-page-name'); // $awpcppagename = sanitize_title($cpagename_awpcp, $post_ID=''); // $laction=''; // $isclassifiedpage = checkifclassifiedpage($cpagename_awpcp); // if ($isclassifiedpage == false) // { // $awpcpsetuptext=display_setup_text(); // $output .= $awpcpsetuptext; // } else { // global $message,$wpdb; // $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos"; // $where=''; // $output .= "

"; // $output .= __("AWPCP Classifieds Management System Manage Images","AWPCP"); // $output .= "

"; // if (isset($message) && !empty($message)) // { // $output .= $message; // } // $output .= awpcp_admin_sidebar(); // $output .= "

"; // $output .= __("Below you can manage the images users have uploaded. Your options are to delete images, and in the event you are operating with image approval turned on you can approve or disable images","AWPCP"); // $output .= "

"; // $output .= '

Return to the Listings page

'; // if (isset($_REQUEST['pdel']) && !empty( $_REQUEST['pdel'] ) ) // { // $output .= "
"; // $output .= __("The image was deleted successfully","AWPCP"); // $output .= "
"; // } // if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) // { // $laction=$_REQUEST['action']; // } // if (empty($_REQUEST['action'])) // { // if (isset($_REQUEST['a']) && !empty($_REQUEST['a'])) // { // $laction=$_REQUEST['a']; // } // } // if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) // { // $actonid=$_REQUEST['id']; // $where="ad_id='$actonid'"; // } // if (isset($_REQUEST['adid']) && !empty($_REQUEST['adid'])) // { // $adid=$_REQUEST['adid']; // } // if (isset($_REQUEST['picid']) && !empty($_REQUEST['picid'])) // { // $picid=$_REQUEST['picid']; // } // if (isset($_REQUEST['adtermid']) && !empty($_REQUEST['adtermid'])) // { // $adtermid=$_REQUEST['adtermid']; // } // if (isset($_REQUEST['adkey']) && !empty($_REQUEST['adkey'])) // { // $adkey=$_REQUEST['adkey']; // } // if (isset($_REQUEST['editemail']) && !empty($_REQUEST['editemail'])) // { // $editemail=$_REQUEST['editemail']; // } // if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) // { // $offset=$_REQUEST['offset']; // } // if (isset($_REQUEST['results']) && !empty($_REQUEST['results'])) // { // $editemail=$_REQUEST['results']; // } // if ($laction == 'approvepic') // { // $query="UPDATE ".$tbl_ad_photos." SET disabled=0 WHERE ad_id='$adid' AND key_id='$picid'"; // $res = awpcp_query($query, __LINE__); // $output .= "
"; // $output .= __("The image has been enabled and can now be viewed","AWPCP"); // $output .= "
"; // } // elseif ($laction == 'rejectpic') // { // $query="UPDATE ".$tbl_ad_photos." SET disabled=1 WHERE ad_id='$adid' AND key_id='$picid'"; // $res = awpcp_query($query, __LINE__); // $output .= "
"; // $output .= __("The image has been disabled and can no longer be viewed","AWPCP"); // $output .= "
"; // } // elseif ($laction == 'deletepic') // { // $message=deletepic($picid,$adid,$adtermid,$adkey,$editemail); // $output .= "
$message
"; // } // $output .= viewimages($where); // } // //Echo OK here: // echo $output; // } // END FUNCTION: Manage view images // START FUNCTION: Manage view listings function awpcp_manage_viewlistings() { global $hasextrafieldsmodule, $wpdb; $cpagename_awpcp = get_awpcp_option('main-page-name'); $awpcppagename = sanitize_title($cpagename_awpcp, $post_ID=''); $laction = ''; $output = ''; global $awpcp_imagesurl, $message; $output .= "

"; $output .= __("AWPCP Classifieds Management System Manage Ad Listings","AWPCP"); $output .= "

"; if (isset($message) && !empty($message)) { $output .= $message; } $sidebar = awpcp_admin_sidebar(); $output .= $sidebar; $tbl_ads = AWPCP_TABLE_ADS; $tbl_ad_photos = AWPCP_TABLE_ADPHOTOS; if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) { $laction=$_REQUEST['action']; } if (empty($_REQUEST['action']) && isset($_REQUEST['a']) && !empty($_REQUEST['a'])) { $laction=$_REQUEST['a']; } if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $actonid=$_REQUEST['id']; } if ($laction == 'deletead') { $message=deletead($actonid,$adkey='',$editemail=''); $output .= "
$message
"; } if ($laction == 'unflagad') { $sql = 'update '.$wpdb->prefix.'awpcp_ads set flagged = 0 where ad_id = "'.$_GET['id'].'"'; $wpdb->query($sql); $message = 'The ad was unflagged'; $output .= "
$message
"; do_action('awpcp_unflag_ad'); } elseif ($laction == 'editad') { $editemail=get_adposteremail($actonid); $adaccesskey=get_adkey($actonid); $awpcppage=get_currentpagename(); $awpcppagename = sanitize_title($awpcppage, $post_ID=''); $offset=clean_field($_REQUEST['offset']); $results=clean_field($_REQUEST['results']); $output .= load_ad_post_form($actonid, $action='editad', $awpcppagename, $adtermid='', $editemail, $adaccesskey, $adtitle='', $adcontact_name='', $adcontact_phone='', $adcontact_email='', $adcategory='', $adcontact_city='', $adcontact_state='', $adcontact_country='', $ad_county_village='', $ad_item_price='', $addetails='', $adpaymethod='', $offset, $results, $ermsg='', $websiteurl='', $checkhuman='', $numval1='', $numval2=''); } elseif ($laction == 'dopost1') { $errors = array(); $output .= awpcp_place_ad_save_details_step(array(), $errors, true); } elseif ($laction == 'approvead') { $ad = AWPCP_Ad::find_by_id($actonid); $disabled_date = $ad->get_disabled_date(); if (($ad->disabled && empty($disabled_date)) || $ad->has_expired()) { $ad->set_start_date(current_time('mysql')); $ad->set_end_date($ad->calculate_end_date()); } // TODO: create enable() method in AWPCP_Ad $ad->disabled = 0; $ad->save(); $sql = "UPDATE " . AWPCP_TABLE_ADPHOTOS . " SET disabled = 0 WHERE ad_id = %d"; $wpdb->query($wpdb->prepare($sql, $actonid)); $output .= "
"; $output .= __("The Ad has been approved", "AWPCP"); $output .= "
"; do_action('awpcp_approve_ad', $ad); } elseif ($laction == 'rejectad') { $ad = AWPCP_Ad::find_by_id($actonid); $ad->disable(); $output .= "
"; $output .= __("The ad has been disabled","AWPCP"); $output .= "
"; } elseif ($laction == 'makefeatured') { $query="UPDATE ".$tbl_ads." SET is_featured_ad=1 WHERE ad_id='$actonid'"; $res = awpcp_query($query, __LINE__); $output .= "
"; $output .= __("The ad has been marked as Featured","AWPCP"); $output .= "
"; do_action('awpcp_make_featured_ad'); } elseif ($laction == 'makenonfeatured') { $query="UPDATE ".$tbl_ads." SET is_featured_ad=0 WHERE ad_id='$actonid'"; $res = awpcp_query($query, __LINE__); $output .= "
"; $output .= __("The ad has been marked as Featured","AWPCP"); $output .= "
"; do_action('awpcp_make_featured_ad'); } elseif ($laction == 'spamad') { awpcp_submit_spam($actonid); $ad = AWCP_Ad::find_by_id($actonid); $ad->delete(); $output .= "
"; $output .= __("The Ad has been marked as SPAM and removed.","AWPCP"); $output .= "
"; } elseif ($laction == 'cps') { if (isset($_REQUEST['changeto']) && !empty($_REQUEST['changeto'])) { $changeto=$_REQUEST['changeto']; } $query="UPDATE ".$tbl_ads." SET payment_status='$changeto', disabled=0 WHERE ad_id='$actonid'"; $res = awpcp_query($query, __LINE__); $output .= "
"; $output .= __("The ad payment status has been changed","AWPCP"); $output .= "
"; do_action('awpcp_approve_ad', AWPCP_Ad::find_by_id($actonid)); } elseif ($laction == 'viewad') { if (isset($actonid) && !empty($actonid)) { if (empty($sidebar)) { $output .= "
"; } else { $output .= "
"; } // start insert delete | edit | approve/disable admin links $offset=(isset($_REQUEST['offset'])) ? (clean_field($_REQUEST['offset'])) : ($offset=0); $results=(isset($_REQUEST['results']) && !empty($_REQUEST['results'])) ? clean_field($_REQUEST['results']) : ($results=10); $deletelink= ""; $deletelink.=__("Delete","AWPCP"); $deletelink.=""; $editlink=" | "; $editlink.=__("Edit","AWPCP"); $editlink.=""; $category_id = get_adcategory($actonid); $href = add_query_arg(array('page' => 'Manage1', 'showadsfromcat_id' => $category_id), admin_url('admin.php')); $output .= "
"; $output .= "" . __("Category: ","AWPCP") . ""; $output .= '' . get_adcatname($category_id) . " » "; $output .= "" . __("Manage Listing: ","AWPCP") . ""; $output .= "$deletelink $editlink"; //if (get_awpcp_option('adapprove') == 1 || get_awpcp_option('freepay') == 1) //{ $adstatusdisabled=check_if_ad_is_disabled($actonid); if ($adstatusdisabled) { $approvelink=" | "; $approvelink.=__("Approve","AWPCP"); $approvelink.=" "; } else { $approvelink=" | "; $approvelink.=__("Disable","AWPCP"); $approvelink.=" "; } //Tack on spam control: if (get_awpcp_option('useakismet')) { $approvelink.=" | "; $approvelink.=__("Mark as SPAM","AWPCP"); $approvelink.=" "; } $output .= "$approvelink"; //} if (function_exists('awpcp_featured_ads')) $output .= ' | '.awpcp_make_featured_link($actonid, $offset, $results); $output .= "
"; // end insert delete | edit | approve/disable admin links $output .= showad($actonid, $omitmenu=1); $output .= "
"; } else { $output .= "
"; $output .= __("No ad ID was supplied","AWPCP"); $output .= "
"; } } elseif (in_array($laction, array('viewimages', 'deletepic', 'rejectpic', 'approvepic', 'set-primary-image'))) { $picid = awpcp_request_param('picid'); $adid = awpcp_request_param('adid'); $adtermid = awpcp_request_param('adtermid'); $adtermid = awpcp_request_param('adkey'); $editemaul = awpcp_request_param('editemail'); if ($laction == 'deletepic'){ $message = deletepic($picid,$adid,$adtermid,$adkey,$editemail); $output .= "
$message
"; } elseif ($laction == 'rejectpic') { $query="UPDATE ". AWPCP_TABLE_ADPHOTOS ." SET disabled=1 WHERE ad_id='$adid' AND key_id='$picid'"; $res = awpcp_query($query, __LINE__); $output .= "
"; $output .= __("The image has been disabled and can no longer be viewed","AWPCP"); $output .= "
"; } elseif ($laction == 'approvepic') { $query="UPDATE ". AWPCP_TABLE_ADPHOTOS ." SET disabled=0 WHERE ad_id='$adid' AND key_id='$picid'"; $res = awpcp_query($query, __LINE__); $output .= "
"; $output .= __("The image has been enabled and can now be viewed","AWPCP"); $output .= "
"; } elseif ($laction == 'set-primary-image') { awpcp_set_ad_primary_image($adid, $picid); } if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $picid=$_REQUEST['id']; $where="ad_id='$picid'"; } else { $where=''; } $output .= viewimages($where); } elseif ($laction == 'lookupadby') { if (isset($_REQUEST['lookupadbychoices']) && !empty($_REQUEST['lookupadbychoices'])) { $lookupadbytype=$_REQUEST['lookupadbychoices']; } else { $output .= "
"; $output .= __("You need to check whether you want to look up the ad by title id or keyword","AWPCP"); $output .= "
"; } if (isset($_REQUEST['lookupadidortitle']) && !empty($_REQUEST['lookupadidortitle'])) { $lookupadbytypevalue=$_REQUEST['lookupadidortitle']; } else { $output .= "
You need enter either an ad title or an ad id to look up
"; } if ($lookupadbytype == 'adid') { if (!is_numeric($lookupadbytypevalue)) { $output .= "
You indicated you wanted to look up the ad by ID but you entered an invalid ID. Please try again
"; } else { $where="ad_id='$lookupadbytypevalue'"; } } elseif ($lookupadbytype == 'adtitle') { $where="ad_title='$lookupadbytypevalue'"; } elseif ($lookupadbytype == 'titdet') { $where="MATCH (ad_title,ad_details) AGAINST (\"$lookupadbytypevalue\")"; } elseif ($lookupadbytype == 'location') { $where="ad_city='$lookupadbytypevalue' OR ad_state='$lookupadbytypevalue' OR ad_country='$lookupadbytypevalue' OR ad_county_village='$lookupadbytypevalue'"; } } if (isset($_REQUEST['showadsfromcat_id']) && !empty($_REQUEST['showadsfromcat_id'])){ $thecat_id=$_REQUEST['showadsfromcat_id']; $where="ad_title <> '' AND (ad_category_id='$thecat_id' OR ad_category_parent_id='$thecat_id')"; } $sortby=''; $lookupadidortitle=''; $from="$tbl_ads"; if (!isset($where) || empty($where)) { $where="ad_title <> ''"; } if (!ads_exist()) { $showadstomanage="

"; $showadstomanage.=__("There are currently no ads in the system","AWPCP"); $showadstomanage.="

"; $pager1=''; $pager2=''; $output .= $showadstomanage; } else { if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) { $offset = clean_field($_REQUEST['offset']); } else { $offset = 0; } if ((isset($_REQUEST['results']) && !empty($_REQUEST['results']))) { $results = clean_field($_REQUEST['results']); } else { $results = 10; } if (isset($_REQUEST['sortby'])) { $sortby=$_REQUEST['sortby']; if ($sortby == 'titleza') { $orderby="ad_title DESC"; } elseif ($sortby == 'titleaz') { $orderby="ad_title ASC"; } elseif ($sortby == 'awaitingapproval') { $orderby="disabled DESC, ad_key DESC"; } elseif ($sortby == 'paidfirst') { $orderby="payment_status DESC, ad_key DESC"; } elseif ($sortby == 'mostrecent') { $orderby="ad_startdate DESC"; } elseif ($sortby == 'oldest') { $orderby="ad_startdate ASC"; } else if ($sortby == 'renewed') { $orderby="renewed_date DESC, ad_startdate DESC"; } elseif ($sortby == 'featured') { $orderby="is_featured_ad DESC, ad_startdate DESC"; } elseif ($sortby == 'flagged') { $orderby="ad_startdate DESC"; $where = ' flagged = 1 '; } } if (!isset($sortby) || empty($sortby)) { $orderby="ad_id DESC"; } $sql = 'select count(*) from '.$wpdb->prefix.'awpcp_ads where flagged = 1'; $flagged_cnt = $wpdb->get_var($sql); $items=array(); $query = "SELECT ad_id, ad_category_id, ad_title, ad_contact_name "; $query.= " , ad_contact_phone, ad_city, ad_state, ad_country "; $query.= " , ad_county_village, ad_details, ad_postdate, disabled "; $query.= " , payment_status, is_featured_ad, ad_startdate, ad_enddate "; $query.= " , adterm_id, renewed_date "; $query.= "FROM $from WHERE $where ORDER BY $orderby LIMIT $offset,$results"; $ads = $wpdb->get_results($query); foreach ($ads as $result) { $ad_id = $result->ad_id; $ad_term_id = $result->adterm_id; $category_id = $result->ad_category_id; $category_name = get_adcatname($category_id); $tcname = $category_name; $disabled = $result->disabled; $paymentstatus = $result->payment_status; $is_featured = $result->is_featured_ad; $ad_start = $result->ad_startdate; $ad_end = $result->ad_enddate; $ad_renewed_date = $result->renewed_date; $fee_plan_name = awpcp_get_fee_plan_name($ad_id, $ad_term_id); if ('' != $ad_start) $ad_start = date('M d Y', strtotime($ad_start)); if ('' != $ad_end) $ad_end = date('M d, Y' ,strtotime($ad_end)); if ('' != $ad_renewed_date) $ad_renewed_date = date('M d, Y' ,strtotime($ad_renewed_date)); if (!isset($paymentstatus) || empty($paymentstatus)) { $paymentstatus="N/A"; } $pager1="

".create_pager($from,$where,$offset,$results,$tpname='')."

"; $pager2="

".create_pager($from,$where,$offset,$results,$tpname='')."

"; // XXX: this variables are unused. verify and delete them $awpcppage=get_currentpagename(); $awpcppagename = sanitize_title($awpcppage, $post_ID=''); $awpcpwppostpageid = awpcp_get_page_id_by_ref('main-page-name'); $ad_checkbox = ""; $ad_title = "" . stripslashes($result->ad_title) . ""; $handlelink=""; $handlelink.=__("Delete","AWPCP"); $handlelink.=" | "; $handlelink.=__("Edit","AWPCP"); $handlelink.=""; if ( 'flagged' == $sortby ) { $handlelink .= ' | Unflag'; } $approvelink=''; //Allow approval anytime //if (get_awpcp_option('adapprove') == 1 || get_awpcp_option('freepay') == 1) //{ if ($disabled == 1) { $approvelink=""; $approvelink.=__("Approve","AWPCP"); $approvelink.=" | "; } else { $approvelink=""; $approvelink.=__("Disable","AWPCP"); $approvelink.=" | "; } if (get_awpcp_option('useakismet')) { $approvelink.=""; $approvelink.=__("Mark as SPAM","AWPCP"); $approvelink.=" | "; } //} if (get_awpcp_option('freepay') == 1) { $paymentstatushead=""; $paymentstatushead.=__("Pay Status","AWPCP"); $paymentstatushead.=""; $changepaystatlink=''; if ($paymentstatus == 'Pending') { $changepaystatlink=""; $changepaystatlink.=__("Complete","AWPCP"); $changepaystatlink.=""; } $paymentstatus=" $paymentstatus $changepaystatlink"; } else { $paymentstatushead=""; $paymentstatus=""; } if (get_awpcp_option('imagesallowdisallow') == 1) { //$imagesnotehead=""; //$imagesnotehead.=__("Total Images","AWPCP"); //$imagesnotehead.=""; $totalimagesuploaded=get_total_imagesuploaded($ad_id); if ($totalimagesuploaded >= 1) { $viewimages=""; $viewimages.=__("View Images","AWPCP"); $viewimages.=" ($totalimagesuploaded)"; } else { $viewimages = __("No Images", "AWPCP") . " ("; $viewimages.=__("Add","AWPCP"); $viewimages.=")"; } //$imagesnote=" $viewimages"; $imagesnote = ' | ' . $viewimages; } else {$imagesnotehead="";$imagesnote="";} if (function_exists('awpcp_featured_ads')) { $makefeaturedlink = awpcp_make_featured_link($ad_id, $offset, $results); } else { $makefeaturedlink = ''; } if (function_exists('awpcp_featured_ads')) { $featured_head = awpcp_make_featured_head(); $featured_note = awpcp_make_featured_note($is_featured); } else { $featured_head = ''; $featured_note = ''; } $startend_date_head = 'Fee PlanStart DateEnd Date'; $startend_date = ''.$fee_plan_name.''.$ad_start.''.$ad_end.''; $renewed_date_head = '' . __('Renewed', 'AWPCP') . ''; $renewed_date = '' . $ad_renewed_date . ''; $items[]="$ad_checkbox$ad_title $approvelink $makefeaturedlink $handlelink $imagesnote $paymentstatus $startend_date $renewed_date $featured_note"; $opentable=""; $opentable.=""; $opentable.="$paymentstatushead $startend_date_head $renewed_date_head $featured_head"; $closetable="
"; $opentable.=__("Ad Headline","AWPCP"); $opentable.=""; $opentable.=__("Manage Ad","AWPCP"); $opentable.="
"; $theadlistitems=smart_table2($items,intval($results/$results),$opentable,$closetable,false); $showadstomanage="$theadlistitems"; $showadstomanagedeletemultiplesubmitbutton="  

"; } if (!isset($ad_id) || empty($ad_id) || $ad_id == 0 ) { $showadstomanage="

"; $showadstomanage.=__("There were no ads found","AWPCP"); $showadstomanage.="

"; $showadstomanagedeletemultiplesubmitbutton=""; $pager1=''; $pager2=''; } $output .= " "; if (empty($sidebar)) { $output .= "
"; } else { $output .= "
"; } $output .= "
"; $output .= __("Look Up Ad By","AWPCP"); $output .= "
Ad ID Ad Title Keyword Location
$pager1
$showadstomanagedeletemultiplesubmitbutton
"; $output .= __("Sort Ads By","AWPCP"); $output .= ": "; $sorts = array(); if ($sortby == 'mostrecent') { $sorts[] = "" . __("Newest","AWPCP") . ""; } else { $sorts[] = "" . __("Newest","AWPCP") . ""; } if ($sortby == 'oldest') { $sorts[] = "" . __("Oldest","AWPCP") . ""; } else { $sorts[] = "" . __("Oldest","AWPCP") . ""; } $label = __("Renewed Date","AWPCP"); if ($sortby == 'renewed') { $sorts[] = "" . $label . ""; } else { $sorts[] = "" . $label . ""; } if ($sortby == 'titleza') { $sorts[] = "" . __("Title Z-A","AWPCP") . ""; } else { $sorts[] = "" . __("Title Z-A","AWPCP") . ""; } if ($sortby == 'titleaz') { $sorts[] = "" . __("Title A-Z","AWPCP") . ""; } else { $sorts[] = "" . __("Title A-Z","AWPCP") . ""; } if (get_awpcp_option('adapprove') == 1) { if ($sortby == 'awaitingapproval') { $sorts[] = "" . __("Awaiting Approval","AWPCP") . ""; } else { $sorts[] = "" . __("Awaiting Approval","AWPCP"). ""; } } if (get_awpcp_option('freepay') == 1) { if ($sortby == 'paidfirst') { $sorts[] = "" . __("Paid Ads First","AWPCP") . ""; } else { $sorts[] = "" . __("Paid Ads First","AWPCP") . ""; } } if ($sortby == 'flagged') { $sorts[] = "" . __("Flagged Ads","AWPCP") . ""; } else { $style = $flagged_cnt > 0 ? ' style="color:#cf0000" ' : ''; $sorts[] = "" . __("Flagged Ads","AWPCP") . " ($flagged_cnt)"; } $output .= join(' | ', $sorts); if (function_exists('awpcp_featured_ads')) { $output .= awpcp_make_featured_sort($sortby); } $output .= "
$showadstomanage
$showadstomanagedeletemultiplesubmitbutton
$pager2"; $output .= "
"; } //Echo OK here: echo $output; } // END FUNCTION: Manage view listings // START FUNCTION: display images for admin view /** * Show view to manage images in AWPCP database. * * This function is called both from the AWPCP Admin Panel and * the AWPCP User Ad Management Panel. * * @param $where string SQL string to filter shown images. * @param $approve boolean Whether the Approve/Disable buttons are shown or not. * @param $delete_image_form_action string URL used as the action for the * delete form. */ function viewimages($where, $approve=true, $delete_image_form_action=null) { //debug(); $output = ''; global $wpdb; $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos"; $thumbnailwidth=get_awpcp_option('imgthumbwidth'); $thumbnailwidth.="px"; $from="$tbl_ad_photos"; if ( '' != $_GET['id'] ) { $sql = 'select ad_title from ' . $wpdb->prefix . 'awpcp_ads where ad_id ="'.absint( $_GET['id'] ).'"'; $ad_title = $wpdb->get_var( $sql ); } if (!isset($where) || empty($where)) { $where="image_name <> ''"; } $upload_result = ''; if ( isset($_POST['awpcp_action']) && 'add_image' == $_POST['awpcp_action'] && '' != $_GET['id'] ) { $adid = absint( $_GET['id'] ); if ( wp_verify_nonce( $_POST['_wpnonce'], 'awpcp_upload_image' ) ) { $upload_result = admin_handleimagesupload( $adid ); } } if (!images_exist()) { $imagesallowedstatus=''; if (get_awpcp_option('imagesallowdisallow') == 0) { $href = add_query_arg(array('page' => 'awpcp-admin-settings'), admin_url()); $imagesallowedstatus=__("You are not currently allowing users to upload images with their ad. To allow users to upload images please change the related setting in your general options configuration", "AWPCP"); $imagesallowedstatus.="

"; $imagesallowedstatus.=__("Click here to change allowed images status","AWPCP"); $imagesallowedstatus.="

"; } $showimages="

"; $showimages.=__("There are currently no images in the system","AWPCP"); $showimages="$imagesallowedstatus

"; $pager1=''; $pager2=''; } else { $offset=(isset($_REQUEST['offset'])) ? (clean_field($_REQUEST['offset'])) : ($offset=0); $results=(isset($_REQUEST['results']) && !empty($_REQUEST['results'])) ? clean_field($_REQUEST['results']) : ($results=10); $items=array(); $query = "SELECT key_id, ad_id, image_name, disabled, is_primary FROM $from "; $query.= "WHERE $where ORDER BY image_name DESC LIMIT $offset, $results"; $res = awpcp_query($query, __LINE__); while ($rsrow=mysql_fetch_row($res)) { list($ikey, $adid, $image_name, $disabled, $is_primary)=$rsrow; $adtermid=get_adterm_id($adid); $editemail=get_adposteremail($adid); $adkey=get_adkey($adid); if (is_null($delete_image_form_action)) { // $delete_image_form_action = '?page=Manage2&sortby='; $delete_image_form_action = awpcp_current_url(); } $dellink="
"; $dellink.=""; $dellink.=""; $dellink.=""; $dellink.=""; $dellink.=""; $dellink.=""; $dellink.=""; $dellink.="
"; $transval=''; if ($disabled == 1){ $transval="style=\"-moz-opacity:.20; filter:alpha(opacity=20); opacity:.20;\""; } $approvelink=''; // show Approve/Disble buttons when needed if ($disabled == 1 && $approve) { $approvelink="
"; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.="
"; } else if ($approve) { $approvelink="
"; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.=""; $approvelink.="
"; } $primary_image_form = ''; if (!$is_primary) { $primary_image_form = "
"; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= ""; $primary_image_form.= "
"; } $large_image = awpcp_get_image_url($image_name, 'large'); $thumbnail = awpcp_get_image_url($image_name, 'thumbnail'); $theimages = "
$dellink $approvelink $primary_image_form"; $pager1=create_pager($from,$where,$offset,$results,$tpname=''); $pager2=create_pager($from,$where,$offset,$results,$tpname=''); $items[]="$theimages"; } $opentable=""; $closetable="
"; $theitems=smart_table( $items, intval($results/2), $opentable, $closetable ); $showcategories="$theitems"; if (!isset($ikey) || empty($ikey) || $ikey == 0) { $showcategories="

"; $showcategories.=__("There were no images found","AWPCP"); $showcategories.="

"; $pager1=''; $pager2=''; } } $output .= " "; if ( '' != $upload_result && 1 != $upload_result ) $uploader = $upload_result; else $uploader = ''; if ( 'Manage1' == $_GET['page'] ) $uploader .= "

Images for ad titled: \"".$ad_title."\"

Upload an image for this ad: ".wp_nonce_field('awpcp_upload_image')."
"; $output .= " $uploader $showcategories"; $output .= "
"; return $output; //die; } // END FUNCTION // // Begin processor actions // /////// // Start process of creating | updating userside classified page ////// // wvega: here the pages are created and updated function awpcp_pages() { $pages = array('main-page-name' => array(get_awpcp_option('main-page-name'), '[AWPCP]')); return $pages + awpcp_subpages(); } function awpcp_subpages() { $pages = array( 'show-ads-page-name' => array(get_awpcp_option('show-ads-page-name'), '[AWPCPSHOWAD]'), 'reply-to-ad-page-name' => array(get_awpcp_option('reply-to-ad-page-name'), '[AWPCPREPLYTOAD]'), 'edit-ad-page-name' => array(get_awpcp_option('edit-ad-page-name'), '[AWPCPEDITAD]'), 'place-ad-page-name' => array(get_awpcp_option('place-ad-page-name'), '[AWPCPPLACEAD]'), 'renew-ad-page-name' => array(get_awpcp_option('renew-ad-page-name'), '[AWPCP-RENEW-AD]'), 'browse-ads-page-name' => array(get_awpcp_option('browse-ads-page-name'), '[AWPCPBROWSEADS]'), 'browse-categories-page-name' => array(get_awpcp_option('browse-categories-page-name'), '[AWPCPBROWSECATS]'), 'search-ads-page-name' => array(get_awpcp_option('search-ads-page-name'), '[AWPCPSEARCHADS]'), 'payment-thankyou-page-name' => array(get_awpcp_option('payment-thankyou-page-name'), '[AWPCPPAYMENTTHANKYOU]'), 'payment-cancel-page-name' => array(get_awpcp_option('payment-cancel-page-name'), '[AWPCPCANCELPAYMENT]') ); $pages = apply_filters('awpcp_subpages', $pages); return $pages; } function awpcp_create_pages($awpcp_page_name, $subpages=true) { global $wpdb; $refname = 'main-page-name'; $date = date("Y-m-d"); // create AWPCP main page if it does not exist if (!awpcp_find_page($refname)) { $awpcp_page = array( 'post_author' => 1, 'post_date' => $date, 'post_date_gmt' => $date, 'post_content' => '[AWPCPCLASSIFIEDSUI]', 'post_title' => add_slashes_recursive($awpcp_page_name), 'post_status' => 'publish', 'post_name' => sanitize_title($awpcp_page_name), 'post_modified' => $date, 'comments_status' => 'closed', 'post_content_filtered' => '[AWPCPCLASSIFIEDSUI]', 'post_parent' => 0, 'post_type' => 'page', 'menu_order' => 0 ); $id = wp_insert_post($awpcp_page); $previous = awpcp_get_page_id_by_ref($refname); if ($previous === false) { $wpdb->insert(AWPCP_TABLE_PAGES, array('page' => $refname, 'id' => $id)); } else { $wpdb->update(AWPCP_TABLE_PAGES, array('page' => $refname, 'id' => $id), array('page' => $refname)); } } else { $id = awpcp_get_page_id_by_ref($refname); } // create subpages if ($subpages) { awpcp_create_subpages($id); } } function awpcp_create_subpages($awpcp_page_id) { $pages = awpcp_subpages(); foreach ($pages as $key => $page) { awpcp_create_subpage($key, $page[0], $page[1], $awpcp_page_id); } do_action('awpcp_create_subpage'); } /** * Creates a subpage of the main AWPCP page. * * This functions takes care of checking if the main AWPCP * page exists, finding its id and verifying that the new * page doesn't exist already. Useful for module plugins. */ function awpcp_create_subpage($refname, $name, $shortcode, $awpcp_page_id=null) { global $wpdb; $id = 0; if (!empty($name)) { // it is possible that the main AWPCP page does not exist, in that case // we should create Subpages without a parent. if (is_null($awpcp_page_id) && awpcp_find_page('main-page-name')) { $awpcp_page_id = awpcp_get_page_id_by_ref('main-page-name'); } else if (is_null(($awpcp_page_id))) { $awpcp_page_id = ''; } if (!awpcp_find_page($refname)) { $id = maketheclassifiedsubpage($name, $awpcp_page_id, $shortcode); } } if ($id > 0) { $previous = awpcp_get_page_id_by_ref($refname); if ($previous === false) { $wpdb->insert(AWPCP_TABLE_PAGES, array('page' => $refname, 'id' => $id)); } else { $wpdb->update(AWPCP_TABLE_PAGES, array('page' => $refname, 'id' => $id), array('page' => $refname)); } } return $id; } function maketheclassifiedsubpage($theawpcppagename,$awpcpwppostpageid,$awpcpshortcodex) { global $wpdb,$table_prefix,$wp_rewrite; $pdate = date("Y-m-d"); $awpcpwppostpageid = intval($awpcpwppostpageid); // First delete any pages already existing with the title and post name of the new page to be created //checkfortotalpageswithawpcpname($theawpcppagename); $post_name = sanitize_title($theawpcppagename); $theawpcppagename = add_slashes_recursive($theawpcppagename); $query="INSERT INTO {$table_prefix}posts SET post_author=1, post_date='$pdate', post_date_gmt='$pdate', post_content='$awpcpshortcodex', post_title='$theawpcppagename', post_excerpt='', post_status='publish', comment_status='closed', post_name='$post_name', to_ping='', pinged='', post_modified='$pdate', post_modified_gmt='$pdate', post_content_filtered='$awpcpshortcodex', post_parent=$awpcpwppostpageid, guid='', post_type='page', menu_order=0"; $res = awpcp_query($query, __LINE__); $newawpcpwppostpageid=mysql_insert_id(); $guid = get_option('home') . "/?page_id=$newawpcpwppostpageid"; $query="UPDATE {$table_prefix}posts set guid='$guid' WHERE post_title='$theawpcppagename'"; $res = awpcp_query($query, __LINE__); return $newawpcpwppostpageid; } /** * This function is never called in any of the AWPCP plugin files, * perhaps in one of the modules, but most likely not. */ // function updatetheclassifiedsubpage($currentsubpagename,$subpagename,$shortcode) // { // //debug(); // global $wpdb,$table_prefix; // $post_name = sanitize_title($subpagename, $post_ID=''); // $currentsubpagename = add_slashes_recursive($currentsubpagename); // $subpagename = add_slashes_recursive($subpagename); // $query="UPDATE {$table_prefix}posts set post_title='$subpagename', post_name='$post_name' WHERE post_title='$currentsubpagename' AND post_content LIKE '%$shortcode%'"; // $res = awpcp_query($query, __LINE__); // } /** * Updates the name of the AWPCP main page. */ // function updatetheclassifiedpagename($currentuipagename,$newuipagename) { // //debug(); // global $wpdb,$table_prefix, $wp_rewrite; // $tbl_pagename = $wpdb->prefix . "awpcp_pagename"; // $post_name = sanitize_title($newuipagename, $post_ID=''); // $currentuipagename = add_slashes_recursive($currentuipagename); // $newuipagename = add_slashes_recursive($newuipagename); // //debug($currentuipagename); // //debug($newuipagename); // $query="UPDATE {$table_prefix}posts set post_title='$newuipagename', post_name='$post_name' WHERE post_title='$currentuipagename'"; // $res = awpcp_query($query, __LINE__); // $query="INSERT INTO ".$tbl_pagename." SET userpagename='$newuipagename'"; // $res = awpcp_query($query, __LINE__); // } // Start process of updating|deleting|adding new listing fees ////////////////// // Handle adding a listing fee plan ///////////////// // add_action('plugins_loaded', 'awpcp_addfees', 1); function awpcp_sanitize_fee($data) { $sanitized = array(); $sanitized['adterm_id'] = awpcp_request_param('adterm_id'); $sanitized['adterm_name'] = awpcp_request_param('adterm_name'); $sanitized['amount'] = (float) awpcp_request_param('amount', 0.0); $sanitized['rec_period'] = (int) awpcp_request_param('rec_period', 30); $sanitized['rec_increment'] = awpcp_request_param('rec_increment', 'D'); $sanitized['imagesallowed'] = (int) awpcp_request_param('imagesallowed', 0); $sanitized['characters_allowed'] = (int) awpcp_request_param('characters_allowed', 0); if (function_exists('awpcp_featured_ads')) { $sanitized['is_featured_ad_pricing'] = (int) awpcp_featured_ad_parms(); } else { $sanitized['is_featured_ad_pricing'] = 0; } if (function_exists('awpcp_price_cats')) { $sanitized['fee_cats'] = awpcp_price_cats_fees(); } else { $sanitized['fee_cats'] = ''; } return $sanitized; } function awpcp_validate_fee($data, &$errors=array()) { if (empty($data['adterm_name'])) $errors['adterm_name'] = _x('You must provide a name for the Fee plan.', 'add/edit fee', 'AWPCP'); if ($data['amount'] < 0.0) $errors['amount'] = _x('Amount must be greater or equal than zero.', 'add/edit fee', 'AWPCP'); if ($data['rec_period'] < 0) $errors['rec_period'] = _x('Term Duration must be a positive integer or zero.', 'add/edit fee', 'AWPCP'); if ($data['imagesallowed'] < 0) $errors['imagesallowed'] = _x('Images Allowed must be a positive integer or zero.', 'add/edit fee', 'AWPCP'); if ($data['characters_allowed'] < 0) $errors['characters_allowed'] = _x('Characters Allowed must be a positive integer or zero.', 'add/edit fee', 'AWPCP'); return empty($errors); } function awpcp_addfees() { global $wpdb; global $message; if (isset($_REQUEST['addnewfeesetting']) && !empty($_REQUEST['addnewfeesetting'])) { $data = awpcp_sanitize_fee($_REQUEST); $errors = array(); if (awpcp_validate_fee($data, $errors)) { extract($data); if (function_exists('awpcp_price_cats')) { $query = "INSERT INTO " . AWPCP_TABLE_ADFEES . " SET adterm_name='$adterm_name',amount='$amount',recurring=1,rec_period='$rec_period',rec_increment='$rec_increment',imagesallowed='$imagesallowed', is_featured_ad_pricing=$is_featured_ad_pricing, categories='$fee_cats', characters_allowed=$characters_allowed"; } else { $query = "INSERT INTO " . AWPCP_TABLE_ADFEES . " SET adterm_name='$adterm_name',amount='$amount',recurring=1,rec_period='$rec_period',rec_increment='$rec_increment',imagesallowed='$imagesallowed', is_featured_ad_pricing=$is_featured_ad_pricing, characters_allowed=$characters_allowed"; } $res = awpcp_query($query, __LINE__); $message = awpcp_print_message(__('The item has been added.', 'add fee', 'AWPCP')); } else { $messages = array(); foreach ($errors as $error) { $messages[] = awpcp_print_message($error, array('error')); } $message = join('', $messages); } } } ////////////////// // Handle updating of a listing fee plan ///////////////// // add_action('plugins_loaded', 'awpcp_savefees',1); function awpcp_savefees() { global $wpdb; global $message; if (isset($_REQUEST['savefeesetting']) && !empty($_REQUEST['savefeesetting'])) { $data = awpcp_sanitize_fee($_REQUEST); $errors = array(); if (awpcp_validate_fee($data, $errors)) { extract($data); if (function_exists('awpcp_price_cats')) { $query = "UPDATE " . AWPCP_TABLE_ADFEES . " SET adterm_name='$adterm_name',amount='$amount',recurring=1,rec_period='$rec_period',rec_increment='$rec_increment', imagesallowed='$imagesallowed', is_featured_ad_pricing=$is_featured_ad_pricing, characters_allowed=$characters_allowed, categories='$fee_cats' WHERE adterm_id='$adterm_id'"; } else { $query = "UPDATE " . AWPCP_TABLE_ADFEES . " SET adterm_name='$adterm_name',amount='$amount',recurring=1,rec_period='$rec_period',rec_increment='$rec_increment', imagesallowed='$imagesallowed', is_featured_ad_pricing=$is_featured_ad_pricing, characters_allowed=$characters_allowed WHERE adterm_id='$adterm_id'"; } $res = awpcp_query($query, __LINE__); $message = awpcp_print_message(__('The item has been updated.', 'add fee', 'AWPCP')); } else { $messages = array(); foreach ($errors as $error) { $messages[] = awpcp_print_message($error, array('error')); } $message = join('', $messages); } } } /** * A function created to wrap code intended to handle * Admin Panel requests. * * The body of this function was in the content of awpcp.php * being executed every time the plugin file was read. */ // add_action('plugins_loaded', 'awpcp_handle_admin_requests'); function awpcp_handle_admin_requests() { global $wpdb; global $message; ////////////////// // Handle deleting of a listing fee plan ///////////////// if (isset($_REQUEST['deletefeesetting']) && !empty($_REQUEST['deletefeesetting'])) { $tbl_ad_fees = $wpdb->prefix . "awpcp_adfees"; $awpcpfeeplanoptionitem=''; $adterm_id=''; if (isset($_REQUEST['adterm_id']) && !empty($_REQUEST['adterm_id'])) { $adterm_id = clean_field($_REQUEST['adterm_id']); } if (empty($adterm_id)) { $message="
"; $message.=__("No plan ID was provided therefore no action has been taken","AWPCP"); $message.="!
"; // First make check if there are ads that are saved under this term } elseif (adtermidinuse($adterm_id)) { $message="
"; $message.=__("The plan could not be deleted because there are active ads in the system that are associated with the plan ID. You need to switch the ads to a new plan ID before you can delete the plan.","AWPCP"); $message.="
"; $awpcpfeechangeadstonewidform="
"; $awpcpfeechangeadstonewidform.="

"; $awpcpfeechangeadstonewidform.=__("Change ads associated with plan ID $adterm_id to this plan ID","AWPCP"); $awpcpfeechangeadstonewidform.="
"; $awpcpfeechangeadstonewidform.=""; $awpcpfeechangeadstonewidform.="

"; $awpcpfeechangeadstonewidform.=""; $awpcpfeechangeadstonewidform.="
"; $message.="

$awpcpfeechangeadstonewidform

"; } else { $query="DELETE FROM ".$tbl_ad_fees." WHERE adterm_id='$adterm_id'"; $res = awpcp_query($query, __LINE__); $message="
"; $message.=__("The data has been deleted","AWPCP"); $message.="!
"; } } if (isset($_REQUEST['changeadstonewfeesetting']) && !empty($_REQUEST['changeadstonewfeesetting'])) { $tbl_ads = $wpdb->prefix . "awpcp_ads"; $adterm_id=''; $awpcpnewplanid=''; if (isset($_REQUEST['adterm_id']) && !empty($_REQUEST['adterm_id'])) { $adterm_id=clean_field($_REQUEST['adterm_id']); } if (isset($_REQUEST['awpcpnewplanid']) && !empty($_REQUEST['awpcpnewplanid'])) { $awpcpnewplanid=clean_field($_REQUEST['awpcpnewplanid']); } if (empty($adterm_id)) { $message="
"; $message.=__("No plan ID was provided therefore no action has been taken","AWPCP"); $message.="!
"; } else { $query="UPDATE ".$tbl_ads." SET adterm_id='$awpcpnewplanid' WHERE adterm_id='$adterm_id'"; $res = awpcp_query($query, __LINE__); $message="
"; $message.=__("All ads with ID $adterm_id have been associated with plan id $awpcpnewplanid. You can now delete plan ID $adterm_id","AWPCP"); $message.="!
"; } } // End process // Start process of adding | editing ad categories if (isset($_REQUEST['createeditadcategory']) && !empty($_REQUEST['createeditadcategory'])) { $tbl_ad_categories = $wpdb->prefix . "awpcp_categories"; $tbl_ads = $wpdb->prefix . "awpcp_ads"; $category_id=clean_field($_REQUEST['category_id']); if (isset($_REQUEST['$movetocat']) && !empty($_REQUEST['$movetocat'])) { $movetocat=clean_field($_REQUEST['movetocat']); } if (isset($_REQUEST['$deletetheads']) && !empty($_REQUEST['$deletetheads'])) { $deletetheads=$_REQUEST['deletetheads']; } $aeaction=clean_field($_REQUEST['aeaction']); if ($aeaction == 'newcategory') { $category_name=stripslashes(clean_field($_REQUEST['category_name'])); $category_name=addslashes(clean_field($_REQUEST['category_name'])); $category_parent_id=clean_field($_REQUEST['category_parent_id']); $category_order=clean_field($_REQUEST['category_order']); //Ensure we have something like a number: $category_order = ('' != $category_order ? (is_numeric($category_order) ? $category_order : 0) : 0); $query="INSERT INTO ".$tbl_ad_categories." SET category_name='".$category_name."',category_parent_id='".$category_parent_id."'".",category_order=".$category_order; awpcp_query($query, __LINE__); $themessagetoprint=__("The new category has been successfully added","AWPCP"); } elseif ($aeaction == 'delete') { if (isset($_REQUEST['category_name']) && !empty($_REQUEST['category_name'])) { $category_name=clean_field($_REQUEST['category_name']); } if (isset($_REQUEST['category_parent_id']) && !empty($_REQUEST['category_parent_id'])) { $category_parent_id=clean_field($_REQUEST['category_parent_id']); } // Make sure this is not the default category. If it is the default category alert that the default category can only be renamed not deleted if ($category_id == 1) { $themessagetoprint=__("Sorry but you cannot delete the default category. The default category can only be renamed","AWPCP"); } else { //Proceed with the delete instructions // Move any ads that the category contains if move-to category value is set and does not equal zero if ( isset($movetocat) && !empty($movetocat) && ($movetocat != 0) ) { $movetocatparent=get_cat_parent_ID($movetocat); $query="UPDATE ".$tbl_ads." SET ad_category_id='$movetocat' ad_category_parent_id='$movetocatparent' WHERE ad_category_id='$category_id'"; awpcp_query($query, __LINE__); // Must also relocate ads where the main category was a child of the category being deleted $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$movetocat' WHERE ad_category_parent_id='$category_id'"; awpcp_query($query, __LINE__); // Must also relocate any children categories to the the move-to-cat $query="UPDATE ".$tbl_ad_categories." SET category_parent_id='$movetocat' WHERE category_parent_id='$category_id'"; awpcp_query($query, __LINE__); } // Else if the move-to value is zero move the ads to the parent category if category is a child or the default category if // category is not a child elseif ( !isset($movetocat) || empty($movetocat) || ($movetocat == 0) ) { // If the category has a parent move the ads to the parent otherwise move the ads to the default if ( category_is_child($category_id) ) { $movetocat=get_cat_parent_ID($category_id); } else { $movetocat=1; } $movetocatparent=get_cat_parent_ID($movetocat); // Adjust any ads transferred from the main category $query="UPDATE ".$tbl_ads." SET ad_category_id='$movetocat', ad_category_parent_id='$movetocatparent' WHERE ad_category_id='$category_id'"; awpcp_query($query, __LINE__); // Must also relocate any children categories to the the move-to-cat $query="UPDATE ".$tbl_ad_categories." SET category_parent_id='$movetocat' WHERE category_parent_id='$category_id'"; awpcp_query($query, __LINE__); // Adjust any ads transferred from children categories $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$movetocat' WHERE ad_category_parent_id='$category_id'"; $res = awpcp_query($query, __LINE__); } $query="DELETE FROM ".$tbl_ad_categories." WHERE category_id='$category_id'"; awpcp_query($query, __LINE__); $themessagetoprint=__("The category has been deleted","AWPCP"); } } elseif ($aeaction == 'edit') { if (isset($_REQUEST['category_name']) && !empty($_REQUEST['category_name'])) { $category_name=clean_field($_REQUEST['category_name']); } if (isset($_REQUEST['category_parent_id']) && !empty($_REQUEST['category_parent_id'])) { $category_parent_id=clean_field($_REQUEST['category_parent_id']); } $category_order=clean_field($_REQUEST['category_order']); //Ensure we have something like a number: $category_order = ('' != $category_order ? (is_numeric($category_order) ? $category_order : 0) : 0); $query="UPDATE ".$tbl_ad_categories." SET category_name='$category_name',category_parent_id='$category_parent_id',category_order='$category_order' WHERE category_id='$category_id'"; awpcp_query($query, __LINE__); $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$category_parent_id' WHERE ad_category_id='$category_id'"; awpcp_query($query, __LINE__); $themessagetoprint=__("Your category changes have been saved.","AWPCP"); } else { $themessagetoprint=__("No changes made to categories.","AWPCP"); } $message="
$themessagetoprint
"; $clearform=1; } // Move multiple categories if ( isset($_REQUEST['movemultiplecategories']) && !empty($_REQUEST['movemultiplecategories']) ) { $tbl_ad_categories = $wpdb->prefix . "awpcp_categories"; $tbl_ads = $wpdb->prefix . "awpcp_ads"; // First get the array of categories to be deleted $categoriestomove=clean_field($_REQUEST['category_to_delete_or_move']); // Next get the value for where the admin wants to move the ads if ( isset($_REQUEST['moveadstocategory']) && !empty($_REQUEST['moveadstocategory']) && ($_REQUEST['moveadstocategory'] != 0) ) { $moveadstocategory=clean_field($_REQUEST['moveadstocategory']); // Next loop through the categories and move them to the new category foreach($categoriestomove as $cattomove) { if ($cattomove != $moveadstocategory) { // First update all the ads in the category to take on the new parent ID $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$moveadstocategory' WHERE ad_category_id='$cattomove'"; awpcp_query($query, __LINE__); $query="UPDATE ".$tbl_ad_categories." SET category_parent_id='$moveadstocategory' WHERE category_id='$cattomove'"; awpcp_query($query, __LINE__); } } $themessagetoprint=__("With the exception of any category that was being moved to itself, the categories have been moved","AWPCP"); } else { $themessagetoprint=__("The categories have not been moved because you did not indicate where you want the categories to be moved to","AWPCP"); } $message="
$themessagetoprint
"; } // Delete multiple categories if ( isset($_REQUEST['deletemultiplecategories']) && !empty($_REQUEST['deletemultiplecategories']) ) { $tbl_ad_categories = $wpdb->prefix . "awpcp_categories"; $tbl_ads = $wpdb->prefix . "awpcp_ads"; // First get the array of categories to be deleted $categoriestodelete=clean_field($_REQUEST['category_to_delete_or_move']); // Next get the value of move/delete ads if ( isset($_REQUEST['movedeleteads']) && !empty($_REQUEST['movedeleteads']) ) { $movedeleteads=clean_field($_REQUEST['movedeleteads']); } else { $movedeleteads=1; } // Next get the value for where the admin wants to move the ads if ( isset($_REQUEST['moveadstocategory']) && !empty($_REQUEST['moveadstocategory']) && ($_REQUEST['moveadstocategory'] != 0) ) { $moveadstocategory=clean_field($_REQUEST['moveadstocategory']); } else { $moveadstocategory=1; } // Next make sure there is a default category with an ID of 1 because any ads that exist in the // categories will need to be moved to a default category if admin has checked move ads but // has not selected a move to category if ( ($moveadstocategory == 1) && (!(defaultcatexists($defid=1))) ) { createdefaultcategory($idtomake=1,$titletocallit='Untitled'); } // Next loop through the categories and move all their ads foreach($categoriestodelete as $cattodel) { // Make sure this is not the default category which cannot be deleted if ($cattodel != 1) { // If admin has instructed moving ads move the ads if ($movedeleteads == 1) { // Now move the ads if any $movetocat=$moveadstocategory; $movetocatparent=get_cat_parent_ID($movetocat); // Move the ads in the category main $query="UPDATE ".$tbl_ads." SET ad_category_id='$movetocat',ad_category_parent_id='$movetocatparent' WHERE ad_category_id='$cattodel'"; awpcp_query($query, __LINE__); // Must also relocate ads where the main category was a child of the category being deleted $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$movetocat' WHERE ad_category_parent_id='$cattodel'"; awpcp_query($query, __LINE__); // Must also relocate any children categories that do not exist in the categories to delete loop to the the move-to-cat $query="UPDATE ".$tbl_ad_categories." SET category_parent_id='$movetocat' WHERE category_parent_id='$cattodel' AND category_id NOT IN (".implode(',',$categoriestodelete).")"; awpcp_query($query, __LINE__); } elseif ($movedeleteads == 2) { $movetocat=$moveadstocategory; // If the category has children move the ads in the child categories to the default category if ( category_has_children($cattodel) ) { // Relocate the ads ads in any children categories of the category being deleted $query="UPDATE ".$tbl_ads." SET ad_category_parent_id='$movetocat' WHERE ad_category_parent_id='$cattodel'"; awpcp_query($query, __LINE__); // Relocate any children categories that exist under the category being deleted $query="UPDATE ".$tbl_ad_categories." SET category_parent_id='$movetocat' WHERE category_parent_id='$cattodel'"; awpcp_query($query, __LINE__); } // Now delete the ads because the admin has checked Delete ads if any massdeleteadsfromcategory($cattodel); } // Now delete the categories $query="DELETE FROM ".$tbl_ad_categories." WHERE category_id='$cattodel'"; awpcp_query($query, __LINE__); $themessagetoprint=__("The categories have been deleted","AWPCP"); } } $message="
$themessagetoprint
"; } // End process // Start Process of deleting multiple ads if (isset($_REQUEST['deletemultipleads']) && !empty($_REQUEST['deletemultipleads'])) { $tbl_ads = $wpdb->prefix . "awpcp_ads"; $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos"; if (isset($_REQUEST['awpcp_ads_to_action']) && !empty($_REQUEST['awpcp_ads_to_action'])) { $theawpcparrayofadstodelete=$_REQUEST['awpcp_ads_to_action']; } if (!isset($theawpcparrayofadstodelete) || empty($theawpcparrayofadstodelete) ) { $themessagetoprint=__("No ads have been selected, you must select one or more ads first.","AWPCP"); } else { foreach ($theawpcparrayofadstodelete as $theawpcpadtodelete) { $fordeletionid[]=$theawpcpadtodelete; } $ads = AWPCP_Ad::find(sprintf('WHERE ad_id IN (%s)', join("','", $fordeletionid))); foreach ($ads as $ad) { $ad->delete(); } // $listofadstodelete=join("','",$fordeletionid); // // Delete the ad images // $query="SELECT image_name FROM ".$tbl_ad_photos." WHERE ad_id IN ('$listofadstodelete')"; // $res = awpcp_query($query, __LINE__); // for ($i=0;$i$themessagetoprint
"; } // End Process of deleting multiple ads // Start Process of spamming multiple ads if (isset($_REQUEST['spammultipleads']) && !empty($_REQUEST['spammultipleads'])) { $tbl_ads = $wpdb->prefix . "awpcp_ads"; if (isset($_REQUEST['awpcp_ads_to_action']) && !empty($_REQUEST['awpcp_ads_to_action'])) { $theawpcparrayofadstospam=$_REQUEST['awpcp_ads_to_action']; } if (!isset($theawpcparrayofadstospam) || empty($theawpcparrayofadstospam) ) { $themessagetoprint=__("No ads have been selected, you must select one or more ads first.","AWPCP"); } else { foreach ($theawpcparrayofadstospam as $theawpcpadtospam) { $forspamid[]=$theawpcpadtospam; awpcp_submit_spam($theawpcpadtospam); } $ads = AWPCP_Ad::find(sprintf('WHERE ad_id IN (%s)', join("','", $forspamid))); foreach ($ads as $ad) { $ad->delete(); } // $listofadstospam=join("','",$forspamid); // // Delete the ads // $query="DELETE FROM ".$tbl_ads." WHERE ad_id IN ('$listofadstospam')"; // awpcp_query($query, __LINE__); $themessagetoprint=__("The selected Ads have been marked as SPAM and removed.","AWPCP"); } $message = "
$themessagetoprint
"; } } // End Process of spamming multiple ads /** * Calls awpcp-admin-sidebar filter to output Admin panel sidebar. * * To remove Admin panel sidebar remove the mentioned filter on init. */ function awpcp_admin_sidebar($float='') { $html = apply_filters('awpcp-admin-sidebar', '', $float); return $html; } function awpcp_admin_sidebar_output($html, $float) { global $hasregionsmodule, $hascaticonsmodule, $hasgooglecheckoutmodule; global $hasextrafieldsmodule, $hasrssmodule, $hasfeaturedadsmodule; global $haspoweredbyremovalmodule; $apath = get_option('siteurl') . '/wp-admin/images'; if ('' == $float) $float = 'float:right !important'; $url = AWPCP_URL; $out = <<< AWPCP
AWPCP; $page = awpcp_request_param('page', ''); if (get_awpcp_option('showlatestawpcpnews') && strcmp($page, 'awpcp.php') == 0) { $out .= "

"; $out .= __("Plugin Support Site","AWPCP"); $out .= "

"; $out .= "

"; $out .= __("Premium Modules","AWPCP"); $out .= "

"; $out .= __("Installed","AWPCP"); $out .= "
    "; if ( ($hasregionsmodule != 1) && ($hascaticonsmodule != 1) && ($hasgooglecheckoutmodule != 1) && ($hasextrafieldsmodule != 1) && ($hasrssmodule != 1) && ($hasfeaturedadsmodule != 1) && ( !function_exists('awpcp_price_cats') ) ) { $out .= "
  • "; $out .= __("No premium modules installed","AWPCP"); $out .= "
  • "; } else { if ( ($hasregionsmodule == 1) ) { $out .= "
  • "; $out .= __("Regions Control Module","AWPCP"); $out .= "
  • "; } if ( ($hascaticonsmodule == 1) ) { $out .= "
  • "; $out .= __("Category Icons Module","AWPCP"); $out .= "
  • "; } if ( ($hasgooglecheckoutmodule == 1) ) { $out .= "
  • "; $out .= __("Google Checkout Module","AWPCP"); $out .= "
  • "; } if ( ($hasextrafieldsmodule == 1) ) { $out .= "
  • "; $out .= __("Extra Fields Module","AWPCP"); $out .= "
  • "; } if ( ($hasrssmodule == 1) ) { $out .= "
  • "; $out .= __("RSS Module","AWPCP"); $out .= "
  • "; } if ( ($hasfeaturedadsmodule == 1) ) { $out .= "
  • "; $out .= __("Featured Ads Module","AWPCP"); $out .= "
  • "; } if ( function_exists('awpcp_price_cats') ) { $out .= "
  • "; $out .= __("Fee per Category Module","AWPCP"); $out .= "
  • "; } } $out .= "
"; $out .= __("Uninstalled","AWPCP"); $out .= "

"; $out .= __("Other Modules","AWPCP"); $out .= "

"; $out .= __("Installed","AWPCP"); $out .= "
    "; if ( ($haspoweredbyremovalmodule != 1) ) { $out .= "
  • "; $out .= __("No [Other] modules installed", "AWPCP"); $out .= "
  • "; } else { if ( ($haspoweredbyremovalmodule == 1) ) { // $out .= "
  • "; // $out .= __("Powered By Link Removal Module","AWPCP"); // $out .= "
  • "; } } $out .= "
"; $out .= __("Uninstalled","AWPCP"); $out .= ""; } $out .= '
'; return $out; }