Exemplo n.º 1
0
function kkb_entry_delete()
{
    $kkberror = new kkbError();
    $board_id = sanitize_text_field($_POST['board_id']);
    $entry_id = sanitize_text_field($_POST['entry_id']);
    if (!empty($board_id) && !empty($entry_id)) {
        $controller = new kkbController();
        $guid = $controller->getMeta($entry_id, 'guid');
        $status = $controller->deleteEntry($board_id, $entry_id);
        if ($status == true) {
            $result['status'] = 'success';
            $result['url'] = get_the_permalink($guid);
        } else {
            $error = $kkberror->Error(016);
            $result['status'] = 'failed';
            $result['message'] = $error['message'];
        }
    } else {
        $error = $kkberror->Error(015);
        $result['status'] = 'failed';
        $result['message'] = $error['message'];
    }
    header("Content-Type: application/json");
    echo json_encode($result);
    exit;
}
Exemplo n.º 2
0
 /**
  * 올바른 글의 순서를 위해 등록글의 번호와 부모글의 리스팅 번호를 비교해 업데이트 해준다.
  * @param string $post_id, $parent
  */
 public function listChanger($board_id, $entry_id, $post_id, $parent)
 {
     global $wpdb;
     $table = $wpdb->prefix . 'kingkongboard_meta';
     $results = $wpdb->get_results("SELECT * FROM {$table} WHERE board_id = {$board_id} AND ID != {$post_id} ORDER BY date ASC");
     $lastRst = $wpdb->get_row("SELECT * FROM {$table} WHERE board_id = {$board_id} AND ID = {$post_id}");
     $kkberror = new kkbError();
     if ($lastRst) {
         if ($lastRst->depth > 1) {
             $pNumber = $this->getListnumber($lastRst->parent);
             $Upresults = $wpdb->get_results("SELECT * FROM {$table} WHERE board_id = {$board_id} AND list_number > {$pNumber}");
             if ($Upresults) {
                 foreach ($Upresults as $Upresult) {
                     $this->updateListnumber($Upresult->ID, $Upresult->list_number + 1);
                 }
             }
             $this->updateListnumber($lastRst->ID, $pNumber + 1);
             return $entry_id;
         } else {
             if ($results) {
                 foreach ($results as $result) {
                     $this->updateListnumber($result->ID, $result->list_number + 1);
                 }
             }
             return $entry_id;
         }
     } else {
         return $kkberror->Error(011);
     }
 }
Exemplo n.º 3
0
 /**
  * data, entry_id 값을 받아 포스트 메타 정보를 업데이트 한다.
  * @param string $data, $entry_id
  */
 public function writeMeta($board_id, $entry_id, $data)
 {
     $kkberror = new kkbError();
     if ($data && $entry_id) {
         if (isset($data['entry_attachment'])) {
             $entry_attachments = serialize($data['entry_attachment']);
             update_post_meta($entry_id, 'kingkongboard_attached', $entry_attachments);
         }
         if (isset($data['entry_password'])) {
             $entry_secret = $data['entry_password'];
             $entry_secret = md5($entry_secret);
             update_post_meta($entry_id, 'kingkongboard_entry_password', $entry_secret);
         }
         if (isset($data['entry_secret'])) {
             //update_post_meta($entry_id, 'kingkongboard_secret', 'on');
             $this->updateSecret($entry_id);
         }
         // 비밀글 답변글일때 기존 글 작성자가 비회원 이라면 기존글 비밀번호를 답변글에 적용한다.
         if (isset($data['write_type'])) {
             if ($data['write_type'] == 'reply') {
                 $parent_id = $this->getMeta($data['parent'], 'parent');
                 $parent_user = $this->getMeta($data['parent'], 'login_id');
                 $parent_secret = get_post_meta($parent_id, 'kingkongboard_secret', true);
                 if ($parent_user == 0 && !empty($parent_secret)) {
                     $entry_secret = get_post_meta($parent_id, 'kingkongboard_entry_password', true);
                     update_post_meta($entry_id, 'kingkongboard_entry_password', $entry_secret);
                 }
             }
         }
         $status = $this->writeTable($board_id, $entry_id, $data);
         if ($status == false) {
             return $kkberror->Error(010);
         } else {
             return $status;
         }
     } else {
         return $kkberror->Error(00);
     }
 }