Пример #1
0
 /**
  *  Delete a category, and all sub-categories, and all ads
  *
  *  @param  integer  $id     Category ID to delete
  *  @return boolean          True on success, False on failure
  */
 public static function Delete($id)
 {
     global $_TABLES, $_CONF_ADVT;
     $id = (int) $id;
     // find all sub-categories of this one and delete them.
     $sql = "SELECT cat_id FROM {$_TABLES['ad_category']} \n                WHERE papa_id={$id}";
     $result = DB_query($sql);
     if ($result) {
         while ($row = DB_fetcharray($result)) {
             if (!adCategory::Delete($row['cat_id'])) {
                 return false;
             }
         }
     }
     // now delete any ads associated with this category
     $sql = "SELECT ad_id FROM {$_TABLES['ad_ads']} \n             WHERE cat_id={$id}";
     $result = DB_query($sql);
     if ($result) {
         while ($row = DB_fetcharray($result)) {
             if (adDelete($row['ad_id'], true) != 0) {
                 return false;
             }
         }
     }
     // Delete this category
     // First, see if there's an image to delete
     $img_name = DB_getItem($_TABLES['ad_category'], 'image', "cat_id={$id}");
     if ($img_name != '' && file_exists($this->imgPath . $img_name)) {
         unlink($this->imgPath . $img_name);
     }
     DB_delete($_TABLES['ad_category'], 'cat_id', $id);
     // If we made it this far, must have worked ok
     return true;
 }
Пример #2
0
$content = '';
// Start by processing the specified action, if any
switch ($mode) {
    case $LANG_ADMIN['delete']:
        if (empty($LANG_ADMIN['delete'])) {
            break;
        }
        if ($id > 0) {
            adDelete($id);
        }
        $page = 'manage';
        break;
    case 'delete_ad':
        // DEPRECATE
        if ($id > 0) {
            adDelete($id);
        }
        $page = 'manage';
        break;
    case 'update_account':
        // only valid users allowed
        if ($isAnon) {
            $content .= CLASSIFIEDS_errorMsg($LANG_ADVT['login_required'], 'alert', $LANG_ADVT['access_denied']);
            break;
        }
        USES_classifieds_class_userinfo();
        $U = new adUserInfo();
        $U->SetVars($_POST);
        $U->Save();
        $page = $page == '' ? 'account' : $page;
        break;
Пример #3
0
                 $view = 'admin';
                 $actionval = 'ad';
             }
             break;
     }
     break;
 case 'delete_ad':
     // Delete a specific ad
     adDelete($ad_id, true);
     $view = 'admin';
     $actionval = 'ad';
     break;
 case 'deletesubmission':
     // DEPRECATE
     // Delete a specific ad
     adDelete($ad_id, true, 'ad_submission');
     $view = 'moderation';
     break;
 case 'update_ad':
     // DEPRECATE
 // DEPRECATE
 case 'updatesubmission':
     $r = adSave('adminupdate');
     $content .= $r[1];
     $view = 'admin';
     $actionval = 'ad';
     break;
 case 'save':
     if ($type == 'submission') {
         // new submission
         $r = adSave('submission');