/**
*  Delete an ad and associated photos
*
*  @param integer $ad_id    Ad ID number
*  @param boolean $admin    True if this is an administrator
*/
function adDelete($ad_id = '', $admin = false, $table = 'ad_ads')
{
    global $_USER, $_TABLES, $_CONF_ADVT;
    $ad_id = COM_sanitizeID($ad_id);
    if ($ad_id == '') {
        return 1;
    }
    if ($table != 'ad_ads' && $table != 'ad_submission') {
        return 2;
    }
    // Check the user's access level.  If this is an admin call,
    // force access to read-write.
    $myaccess = $admin ? 3 : CLASSIFIEDS_checkAccess($ad_id);
    if ($myaccess < 3) {
        return 3;
    }
    /*    $selection = "ad_id = '$ad_id'";
        if (!$admin) {
            $selection.= " AND uid={$_USER['uid']}";
        }
        $ad = DB_getItem($_TABLES[$table], 'ad_id', $selection);
        if ($ad == '')
            return 5;*/
    // If we've gotten this far, then the current user has access
    // to delete this ad.
    if ($table == 'ad_submission') {
        // Do the normal plugin rejection stuff
        plugin_moderationdelete_classifieds($ad_id);
    } else {
        // Do the extra cleanup manually
        if (deletePhotos($ad_id) != 0) {
            return 5;
        }
    }
    // After the cleanup stuff, delete the ad record itself.
    DB_delete($_TABLES[$table], 'ad_id', $ad_id);
    CLASSIFIEDS_auditLog("Ad {$ad_id} deleted.");
    if (DB_error()) {
        COM_errorLog(DB_error());
        return 4;
    } else {
        return 0;
    }
}
示例#2
0
                 $cat_id = (int) $_GET['cat_id'];
             } else {
                 $cat_id = 0;
             }
             if ($cat_id > 0) {
                 //USES_classifieds_categories();
                 //catDelete($_REQUEST['cat_id']);
                 USES_classifieds_class_category();
                 adCategory::Delete($_REQUEST['cat_id']);
                 $view = 'admin';
             }
             break;
         case 'ad':
         default:
             if ($type == 'submission' || $type == 'editsubmission' || $type == 'moderate') {
                 CLASSIFIEDS_auditLog("Deleting submission {$ad_id}");
                 adDelete($ad_id, true, 'ad_submission');
                 $view = 'moderation';
             } else {
                 adDelete($ad_id, true);
                 $view = 'admin';
                 $actionval = 'ad';
             }
             break;
     }
     break;
 case 'delete_ad':
     // Delete a specific ad
     adDelete($ad_id, true);
     $view = 'admin';
     $actionval = 'ad';