Beispiel #1
0
/**
 * コミュニティ削除
 * 関連情報を合わせて削除する
 *
 * @param int $c_commu_id
 */
function db_common_delete_c_commu($c_commu_id)
{
    //function cacheの削除
    cache_drop_c_commu($c_commu_id);
    $single = array(intval($c_commu_id));
    $sql = 'SELECT * FROM c_commu WHERE c_commu_id = ?';
    $c_commu = db_get_row($sql, $single);
    // 画像削除
    db_image_data_delete($c_commu['image_filename'], $c_commu['c_member_id_admin']);
    // c_commu_admin_confirm
    $sql = 'DELETE FROM c_commu_admin_confirm WHERE c_commu_id = ?';
    db_query($sql, $single);
    // c_commu_member
    $sql = 'DELETE FROM c_commu_member WHERE c_commu_id = ?';
    db_query($sql, $single);
    // c_commu_member_confirm
    $sql = 'DELETE FROM c_commu_member_confirm WHERE c_commu_id = ?';
    db_query($sql, $single);
    // c_commu_review
    $sql = 'DELETE FROM c_commu_review WHERE c_commu_id = ?';
    db_query($sql, $single);
    ///トピック関連
    $sql = 'SELECT * FROM c_commu_topic WHERE c_commu_id = ?';
    $topic_list = db_get_all($sql, $single);
    foreach ($topic_list as $topic) {
        // c_commu_topic_comment(画像)
        $sql = 'SELECT image_filename1, image_filename2, image_filename3, filename' . ' FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
        $params = array(intval($topic['c_commu_topic_id']));
        $topic_comment_list = db_get_all($sql, $params);
        foreach ($topic_comment_list as $topic_comment) {
            db_image_data_delete($topic_comment['image_filename1'], $c_member_id);
            db_image_data_delete($topic_comment['image_filename2'], $c_member_id);
            db_image_data_delete($topic_comment['image_filename3'], $c_member_id);
            db_file_delete_c_file($topic_comment['filename']);
        }
        $sql = 'DELETE FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
        db_query($sql, $params);
        // c_event_member
        $sql = 'DELETE FROM c_event_member WHERE c_commu_topic_id = ?';
        db_query($sql, $params);
    }
    // c_commu_topic
    $sql = 'DELETE FROM c_commu_topic WHERE c_commu_id = ?';
    db_query($sql, $single);
    // c_commu
    $sql = 'DELETE FROM c_commu WHERE c_commu_id = ?';
    db_query($sql, $single);
}
Beispiel #2
0
function db_admin_delete_c_image_link4image_filename($image_filename)
{
    $parts = explode('_', $image_filename);
    $prefix = $parts[0];
    switch ($prefix) {
        case 'b':
            $pkey = (int) $parts[1];
            $sql = 'DELETE FROM c_banner WHERE c_banner_id = ? AND image_filename = ?';
            $params = array($pkey, $image_filename);
            db_query($sql, $params);
            break;
        case 'c':
            $tbl = 'c_commu';
            $pkey = (int) $parts[1];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename', $pkey);
            //function cacheの削除
            cache_drop_c_commu($pkey);
            break;
        case 't':
            $tbl = 'c_commu_topic_comment';
            $pkey = (int) $parts[1];
            $number = (int) $parts[2];
            $sql = 'SELECT c_commu_topic_comment_id FROM c_commu_topic WHERE c_commu_topic_id = ? AND number = 0';
            $pkey = (int) db_get_one($sql, array($pkey));
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename' . $number, $pkey);
            break;
        case 'tc':
            $tbl = 'c_commu_topic_comment';
            $pkey = (int) $parts[1];
            $number = (int) $parts[2];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename' . $number, $pkey);
            break;
        case 'd':
            $tbl = 'c_diary';
            $pkey = (int) $parts[1];
            $number = (int) $parts[2];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_' . $number, $pkey);
            break;
        case 'dc':
            $tbl = 'c_diary_comment';
            $pkey = (int) $parts[1];
            $number = (int) $parts[2];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_' . $number, $pkey);
            break;
        case 'm':
            $tbl = 'c_member';
            $pkey = (int) $parts[1];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename', $pkey);
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_1', $pkey);
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_2', $pkey);
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_3', $pkey);
            //function cacheの削除
            cache_drop_c_member_profile($pkey);
            break;
        case 'ms':
            $tbl = 'c_message';
            $pkey = (int) $parts[1];
            $number = (int) $parts[2];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename_' . $number, $pkey);
            break;
        case 'r':
            $tbl = 'c_rank';
            $pkey = (int) $parts[1];
            _db_admin_empty_filename($tbl, $image_filename, 'image_filename', $pkey);
            break;
        case 'a':
            $tbl = 'c_album';
            $pkey = (int) $parts[1];
            _db_admin_empty_filename($tbl, $image_filename, 'album_cover_image', $pkey);
            $sql = 'DELETE FROM c_album_image WHERE c_album_id = ? AND image_filename = ?';
            $params = array($pkey, $image_filename);
            db_query($sql, $params);
            break;
        case 'g':
            $tbl = 'biz_group';
            _db_admin_empty_filename($tbl, $image_filename);
            break;
        case 's':
            $tbl = 'biz_shisetsu';
            _db_admin_empty_filename($tbl, $image_filename);
            break;
    }
}
Beispiel #3
0
/**
 * コミュニティ削除
 * 関連情報を合わせて削除する
 * 
 * @param int $c_commu_id
 */
function kanshi_db_common_delete_c_commu($c_commu_id)
{
    if (db_commu_c_commu4c_commu_id($c_commu_id)) {
        //function cacheの削除
        cache_drop_c_commu($c_commu_id);
        $single = array(intval($c_commu_id));
        $sql = 'SELECT * FROM c_commu WHERE c_commu_id = ?';
        $c_commu = db_get_row($sql, $single);
        // 画像削除
        image_data_delete($c_commu['image_filename']);
        // c_commu_admin_confirm
        $sql = 'DELETE FROM c_commu_admin_confirm WHERE c_commu_id = ?';
        db_query($sql, $single);
        // c_commu_member
        $sql = 'DELETE FROM c_commu_member WHERE c_commu_id = ?';
        db_query($sql, $single);
        // c_commu_member_confirm
        $sql = 'DELETE FROM c_commu_member_confirm WHERE c_commu_id = ?';
        db_query($sql, $single);
        // c_commu_review
        $sql = 'DELETE FROM c_commu_review WHERE c_commu_id = ?';
        db_query($sql, $single);
        ///トピック関連
        $sql = 'SELECT * FROM c_commu_topic WHERE c_commu_id = ?';
        $topic_list = db_get_all($sql, $single);
        foreach ($topic_list as $topic) {
            // c_commu_topic_comment(画像)
            $sql = 'SELECT image_filename1, image_filename2, image_filename3, filename' . ' FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
            $params = array(intval($topic['c_commu_topic_id']));
            $topic_comment_list = db_get_all($sql, $params);
            foreach ($topic_comment_list as $topic_comment) {
                image_data_delete($topic_comment['image_filename1']);
                image_data_delete($topic_comment['image_filename2']);
                image_data_delete($topic_comment['image_filename3']);
                db_file_delete_c_file($topic_comment['filename']);
            }
            $sql = 'DELETE FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
            db_query($sql, $params);
            // c_event_member
            $sql = 'DELETE FROM c_event_member WHERE c_commu_topic_id = ?';
            db_query($sql, $params);
        }
        // c_commu_topic
        $sql = 'DELETE FROM c_commu_topic WHERE c_commu_id = ?';
        db_query($sql, $single);
        // c_commu
        $sql = 'DELETE FROM c_commu WHERE c_commu_id = ?';
        if (db_query($sql, $single)) {
            return array(1, 0, '');
        } else {
            return array(0, 2, 'DB更新エラー');
        }
    } else {
        //        return array(0, 99, '既に削除されているか存在しません');
        // 監視ツールがリトライを行ってしまう為、成功フラグを返してしまう
        return array(1, 0, '');
    }
}
Beispiel #4
0
/**
 * コミュニティからメンバーを削除
 */
function db_commu_delete_c_commu_member($c_commu_id, $c_member_id)
{
    //function cache削除
    cache_drop_c_commu($c_commu_id);
    cache_drop_c_commu_list4c_member_id($c_member_id);
    //おすすめレビューを削除
    $sql = 'DELETE FROM c_commu_review' . ' WHERE c_commu_id = ? AND c_member_id = ?';
    $params = array(intval($c_commu_id), intval($c_member_id));
    db_query($sql, $params);
    //副管理者なら副管理者のポストを空に
    $sql = 'UPDATE c_commu' . ' SET c_member_id_sub_admin = 0' . ' WHERE c_commu_id = ? AND c_member_id_sub_admin = ?';
    db_query($sql, $params);
    //管理者承認依頼
    $sql = 'DELETE FROM c_commu_admin_confirm' . ' WHERE c_commu_id = ? AND c_member_id_to = ?';
    db_query($sql, $params);
    //副管理者承認依頼
    $sql = 'DELETE FROM c_commu_sub_admin_confirm' . ' WHERE c_commu_id = ? AND c_member_id_to = ?';
    db_query($sql, $params);
    //参加イベント情報削除
    $sql = 'SELECT ct.c_commu_topic_id' . ' FROM c_commu_topic ct' . ' LEFT JOIN c_event_member cem ON ct.c_commu_topic_id = cem.c_commu_topic_id' . ' WHERE ct.c_commu_id = ?' . ' AND cem.c_member_id = ?';
    $c_commu_topic_id_list = db_get_col($sql, $params, 'main');
    foreach ($c_commu_topic_id_list as $c_commu_topic_id) {
        db_commu_delete_c_event_member($c_commu_topic_id, $c_member_id);
    }
    //コミュニティから退会
    $sql = 'DELETE FROM c_commu_member' . ' WHERE c_commu_id = ? AND c_member_id = ?';
    db_query($sql, $params);
}