function getDefaultView()
 {
     $context = $this->getContext();
     $controller = $context->getController();
     $request = $context->getRequest();
     $user = $context->getUser();
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     // 対象のdiary_idを取得
     $diary_id = $request->ACSgetParameter('diary_id');
     // ダイアリー親記事の情報を取得
     $diary_row = ACSDiary::get_diary_row($diary_id);
     if ($diary_row['open_level_name'] == ACSMsg::get_mst('open_level_master', 'D05')) {
         $diary_row['trusted_community_row_array'] = ACSDiary::get_diary_trusted_community_row_array($diary_row['diary_id']);
     }
     // ユーザ情報
     $user_community_id = $diary_row['user_community_id'];
     $target_user_info_row = ACSUser::get_user_info_row_by_user_community_id($user_community_id);
     // 権限
     if (!$this->get_execute_privilege()) {
         $controller->forward(SECURE_MODULE, SECURE_ACTION);
         return;
     }
     // ダイアリーコメント
     $diary_comment_row_array = ACSDiary::get_diary_comment_row_array($diary_row['diary_id']);
     // ダイアリーアクセス履歴登録
     if ($acs_user_info_row['is_acs_user']) {
         ACSDiary::set_diary_access_history($acs_user_info_row['user_community_id'], $diary_id);
     }
     // 足跡情報取得
     $footprint_url = $this->getControllerPath('User', 'DiaryComment') . '&diary_id=' . $diary_row['diary_id'];
     $where = "foot.contents_link_url = '" . $footprint_url . "'";
     $where .= " AND foot.visitor_community_id = '" . $acs_user_info_row['user_community_id'] . "'";
     $footprint_info = ACSUser::get_footprint_list($user_community_id, $where);
     // set
     $request->setAttribute('target_user_info_row', $target_user_info_row);
     $request->setAttribute('diary_row', $diary_row);
     $request->setAttribute('diary_comment_row_array', $diary_comment_row_array);
     $request->setAttribute('footprint_info', $footprint_info);
     return View::INPUT;
 }
Пример #2
0
 /**
  * 日記htmlコンテンツの作成
  * 
  * @param string $diary_row 日記配列
  * @param string $encoding エンコーディング
  */
 function create_diary_html($diary_row, $encoding = '')
 {
     $file_head = date("Ymd_His", ACSLib::convert_pg_date_to_timestamp($diary_row['post_date']));
     $this->diary_file_names[$file_head]++;
     if ($this->diary_file_names[$file_head] > 1) {
         $file_head .= '_' . ($this->diary_file_names[$html_file] - 1);
     }
     $html_file = $file_head . '.html';
     // 基本項目の置換
     $contents = _ACSDIARYBACKUP_DIARY_FORMAT;
     $contents = mb_ereg_replace('@SUBJECT@', htmlspecialchars($diary_row['subject']), $contents);
     $contents = mb_ereg_replace('@POST_DATE@', htmlspecialchars(ACSLib::convert_pg_date_to_str($diary_row['post_date'])), $contents);
     $contents = mb_ereg_replace('@BODY@', nl2br(htmlspecialchars($diary_row['body'])), $contents);
     $contents = mb_ereg_replace('@OPEN_LEVEL_TITLE@', htmlspecialchars(ACSMsg::get_mdmsg(__FILE__, 'M001')), $contents);
     $contents = mb_ereg_replace('@OPEN_LEVEL_NAME@', htmlspecialchars($diary_row['open_level_name']), $contents);
     // イメージファイルがある場合
     $image_file_id = $diary_row['file_id'];
     if ($image_file_id != '') {
         $file_obj = ACSFile::get_file_info_instance($image_file_id);
         // 拡張子の取得
         mb_ereg("^.*(\\.[^\\.\\/]*)", $file_obj->get_display_file_name(), $matches);
         $ext = $matches[1];
         // ファイル名の生成
         $img_from = ACS_FOLDER_DIR . $file_obj->get_server_file_name();
         $img_to = $this->img_dir . '/' . $file_head . $ext;
         $img_thumb_from = ACS_FOLDER_DIR . $file_obj->get_thumbnail_server_file_name();
         $img_thumb_to = $this->img_dir . '/thumb_' . $file_head . '.jpg';
         // URLの生成
         $img_url = $this->diary_to_img_url . '/' . $file_head . $ext;
         $img_thumb_url = $this->diary_to_img_url . '/thumb_' . $file_head . '.jpg';
         // イメージファイルの作成
         @copy($img_from, $img_to);
         @copy($img_thumb_from, $img_thumb_to);
         // リンクタグの生成
         $contents = mb_ereg_replace('@IMAGE@', '<div><a href="' . $img_url . '">' . '<img src="' . $img_thumb_url . '" border="0"></a></div><br>', $contents);
     } else {
         $contents = mb_ereg_replace('@IMAGE@', '', $contents);
     }
     // コメントの取得
     $diary_comment_row_array = ACSDiary::get_diary_comment_row_array($diary_row['diary_id']);
     // コメント部分の生成
     $comments = "";
     foreach ($diary_comment_row_array as $diary_comment_row) {
         if ($diary_comment_row['diary_comment_delete_flag'] == 'f') {
             $comment_contents = _ACSDIARYBACKUP_DIARY_COMMENT_FORMAT;
             $comment_contents = mb_ereg_replace('@POST_DATE@', htmlspecialchars(ACSLib::convert_pg_date_to_str($diary_comment_row['post_date'])), $comment_contents);
             $comment_contents = mb_ereg_replace('@COMMUNITY_NAME@', htmlspecialchars($diary_comment_row['community_name']), $comment_contents);
             $comment_contents = mb_ereg_replace('@BODY@', nl2br(htmlspecialchars($diary_comment_row['body'])), $comment_contents);
             $comments .= $comment_contents;
         }
     }
     // コメントの置換
     $contents = mb_ereg_replace('@COMMENTS@', $comments, $contents);
     // contents 自身の変換
     if ($encoding != '') {
         $contents = mb_convert_encoding($contents, $encoding);
     }
     // ファイルへの出力
     $fp = fopen($this->diary_dir . '/' . $html_file, "w");
     fputs($fp, $contents);
     fclose($fp);
     return $html_file;
 }
Пример #3
0
 /**
  * ダイアリーを削除する
  *
  * @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;
 }