예제 #1
0
function JB_expire_posts($post_type)
{
    if ($post_type == 'PREMIUM') {
        if (defined('JB_P_POSTS_DISPLAY_DAYS')) {
            $display_days = JB_P_POSTS_DISPLAY_DAYS;
            $type_sql = " AND post_mode = 'premium' ";
        } else {
            $display_days = JB_POSTS_DISPLAY_DAYS;
            $type_sql = " AND post_mode != 'premium' ";
        }
    } else {
        $display_days = JB_POSTS_DISPLAY_DAYS;
        $type_sql = " AND post_mode != 'premium' ";
    }
    // select all field_id where type is Category form the post table
    // then put these field_ids in to a string, eg 13, 22, 24
    $sql = "SELECT field_id FROM form_fields WHERE field_type='CATEGORY' AND form_id='1' ";
    $cat_result = JB_mysql_query($sql) or die(mysql_error());
    $cats = array();
    if (mysql_num_rows($cat_result)) {
        while ($cat_row = mysql_fetch_array($cat_result, MYSQL_ASSOC)) {
            $cats[] = "`" . $cat_row['field_id'] . "`";
        }
        $cats = ', ' . implode(',', $cats);
    } else {
        // there are no categories to select
        $cats = '';
    }
    // Now select the $cats along with the post_id form the posts table which
    // are older than $display_days (expired)
    $now = gmdate("Y-m-d H:i:s");
    $sql = "SELECT post_id {$cats} FROM posts_table WHERE DATE_SUB('{$now}',INTERVAL " . jb_escape_sql($display_days) . " DAY) >= `post_date` AND expired='N' {$type_sql}  ";
    $exp_result = JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    $affected_cats = array();
    while ($post_row = mysql_fetch_array($exp_result, MYSQL_ASSOC)) {
        // go through each column, if the column is a post_id then expire
        // else it is a category
        foreach ($post_row as $col_name => $col_val) {
            if ($col_name == 'post_id') {
                //echo "update post_id:".$col_val."<br>";
                // set to expired
                JB_expire_post($col_val);
            } else {
                $affected_cats[$col_val] = $col_name;
                // remember the affected category
            }
        }
    }
    foreach ($affected_cats as $key => $val) {
        //JB_update_post_category_counters($leaf_cat_id, $field_id, $search_set='');
        JB_update_post_category_counters($key, $val);
        //echo "updating counters...$key, $val<br>";
    }
    JB_finalize_post_updates();
}
예제 #2
0
        $label['employer_manager_expired_posts'] = str_replace('%COUNT%', $i, $label['employer_manager_expired_posts']);
        $JBMarkup->ok_msg($label["employer_manager_expired_posts"]);
    } else {
        $JBMarkup->error_msg($label["employer_manager_not_selected_exp"]);
    }
}
if (isset($_REQUEST['undo_expire'])) {
    $post_id = (int) $_REQUEST['post_id'];
    $post_data = JB_load_post_data($post_id);
    if ($post_data['user_id'] == $_SESSION['JB_ID']) {
        // is it owned by the person who logged in?
        $sql = "UPDATE posts_table SET expired='N' where post_id='" . jb_escape_sql($post_id) . "' ";
        JB_mysql_query($sql) or $DB_ERROR = mysql_error();
        JB_update_post_category_count($post_data);
    }
    JB_finalize_post_updates();
    $JBMarkup->ok_msg($label['post_unexpire_ok']);
}
jbplug_do_callback('post_manager_action', $A = false);
JB_render_box_top(95, $label['employer_manager_head']);
// set fees flag
if (JB_POSTING_FEE_ENABLED == 'YES' || JB_PREMIUM_POSTING_FEE_ENABLED == 'YES') {
    $_FEES_ENABLED = "YES";
}
###################
JBEmployer::display_credit_status();
JB_render_box_bottom();
?>
				

<div>&nbsp;
예제 #3
0
function JB_delete_employer($id)
{
    $sql = "SELECT * from `profiles_table` WHERE `user_id`='" . jb_escape_sql($id) . "'";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    // delete profile, if exists
    if ($row['profile_id'] != '') {
        JB_delete_profile($row['profile_id']);
    }
    // get all the posts and delete them
    $sql = "SELECT * from `posts_table` WHERE `user_id`='" . jb_escape_sql($id) . "'";
    $result = JB_mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        JB_delete_post($row['post_id']);
        $sql = "DELETE FROM `saved_jobs` WHERE `post_id`='" . jb_escape_sql($row['post_id']) . "'";
        JB_mysql_query($sql) or die(mysql_error());
    }
    JB_finalize_post_updates();
    JB_delete_employer_files($id);
    // delete requests..
    $sql = "DELETE FROM `requests` WHERE `employer_id`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    // delete invoices
    $sql = "DELETE FROM `package_invoices` WHERE `employer_id`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    $sql = "DELETE FROM `subscription_invoices` WHERE `employer_id`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    $sql = "DELETE FROM `membership_invoices` WHERE `user_id`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    $sql = "DELETE FROM `applications` WHERE `employer_id`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    // finally, delete the employer account.
    $sql = "DELETE FROM `employers` WHERE `ID`='" . jb_escape_sql($id) . "'";
    JB_mysql_query($sql) or die(mysql_error());
    $affected = jb_mysql_affected_rows();
    JBPLUG_do_callback('delete_employer_account', $id);
    return $affected;
}