function execute() { $context = $this->getContext(); $controller = $context->getController(); $request = $context->getRequest(); $user = $context->getUser(); //削除処理を行う $target_community_id = $request->getParameter('id'); $diary_id = $request->getParameter('diary_id'); $diary_comment_id = $request->getParameter('diary_comment_id'); //削除コメントは、idを配列で受け渡す $diary_comment_id_array = array(); array_push($diary_comment_id_array, $diary_comment_id); //ファイル情報テーブルのデータ削除 $ret = ACSDiary::delete_diary_comment($diary_comment_id_array); if (!$ret) { echo "ERROR: Delete diary comment failed."; } //表示 $diary_change_url = $this->getControllerPath('User', 'DiaryComment'); $diary_change_url .= '&id=' . $target_community_id . '&diary_id=' . $diary_id; header("Location: {$diary_change_url}"); }
/** * ダイアリーを削除する * * @param $diary_id ダイアリーID * @return 成功(true) / 失敗(false) */ static function delete_diary($diary_id) { // BEGIN // diary コメントの取得 $sub_row_array = ACSDiary::get_diary_comment_row_array($diary_id); $diary_comment_id_array = array(); if (count($sub_row_array) > 0) { foreach ($sub_row_array as $index => $sub_row) { array_push($diary_comment_id_array, $sub_row['diary_comment_id']); } //コメントの削除 $ret = ACSDiary::delete_diary_comment($diary_comment_id_array); if (!$ret) { return false; } } //日記が持っているファイル情報の削除 $diary_row = ACSDiary::get_diary_row($diary_id); $file_id = $diary_row['file_id']; if ($file_id != '') { $ret = ACSDiaryFile::delete_diary_file($file_id, $diary_id); if (!$ret) { echo "ERROR: Delete attached file information failed."; return false; } } //日記の削除(削除フラグ扱い) $sql = "UPDATE diary"; $sql .= " SET diary_delete_flag = 't'"; $sql .= " WHERE diary.diary_id = {$diary_id}"; $ret = ACSDB::_do_query($sql); if (!$ret) { echo "ERROR: Delete parent article failed."; return false; } // COMMIT return true; }