- Timestamp:
- 09/30/08 22:16:35 (2 months ago)
- Location:
- events/phpframework/codeigniter/trunk/system/application
- Files:
-
- 4 modified
-
controllers/status.php (modified) (4 diffs)
-
models/status_model.php (modified) (2 diffs)
-
views/js/default.php (modified) (1 diff)
-
views/status/comment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/codeigniter/trunk/system/application/controllers/status.php
r19980 r20315 16 16 function update() 17 17 { 18 $this->session->keep_flashdata('ticket'); 19 header('Content-Type: application/json; charset=UTF-8'); 20 18 21 // CSRF チェック 19 22 $ticket = $this->session->flashdata('ticket'); … … 23 26 { 24 27 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted Comment but Wrong Ticket'); 28 echo json_encode(array('status' => 'ng', 'html' => 'チケットが異なります')); 25 29 exit; 26 30 } 27 28 $this->session->keep_flashdata('ticket');29 31 30 32 $comment = $this->input->post('msg'); … … 36 38 { 37 39 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted Comment but strlen = ' . $len); 40 echo json_encode(array('status' => 'ng', 'html' => '文字数が不正です: ' . $len)); 38 41 exit; 39 42 } … … 55 58 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted Page: ' . $page); 56 59 57 $id= $this->Status_model->add_comment($user_id, $reply_username, $comment);60 list($id, $reply_username) = $this->Status_model->add_comment($user_id, $reply_username, $comment); 58 61 62 $this->load->helper(array('url')); 63 59 64 $data->page = $page; 60 65 $data->username = $this->session->userdata('username'); 61 66 $data->image = $this->session->userdata('image'); 62 $data->comment = htmlspecialchars($comment, ENT_QUOTES); 67 68 $comment = h($comment); 69 if ($reply_username) { 70 $comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $reply_username), $reply_username) . ' ', $comment); 71 } 72 73 $data->comment = $comment; 63 74 $data->user_id = $user_id; 64 75 $data->id = $id; 65 76 66 $this->load->helper(array('url'));67 77 $data->created_at = time(); 68 78 69 $this->load->view('status/comment', $data); 79 $html = $this->load->view('status/comment', $data, TRUE); 80 81 echo json_encode(array('status' => 'ok', 'html' => $html)); 70 82 } 71 83 else 72 84 { 85 echo json_encode(array('status' => 'ng', 'html' => 'ログインしていません')); 73 86 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted Comment but Not Logged in'); 74 87 } -
events/phpframework/codeigniter/trunk/system/application/models/status_model.php
r20309 r20315 15 15 { 16 16 $statuses->reply_user_id = $this->get_userid($reply_username); 17 if ( ! $statuses->reply_user_id ) 18 { 19 $reply_username = ''; 20 } 17 21 } 18 22 else … … 26 30 $id = $this->db->insert_id(); 27 31 28 return $id;32 return array($id, $reply_username); 29 33 } 30 34 -
events/phpframework/codeigniter/trunk/system/application/views/js/default.php
r20311 r20315 4 4 comment = $('#message').val(); 5 5 $.post('<?=site_url('status/update')?>', {msg: comment, 6 ticket: $('#ticket').val(), p: $('#page_').val()}, addComment, ' html');6 ticket: $('#ticket').val(), p: $('#page_').val()}, addComment, 'json'); 7 7 $('#message').val('').focus(); 8 }); 9 }); 10 function addComment(data){ 11 if (data.status == 'ok') { 12 $('tbody:first').prepend(data.html); 8 13 $('p#last_comment').text(comment); 9 14 count = parseInt($('#side_count_post').text()) + 1; 10 15 $('#side_count_post').text(count); 11 } );12 }); 13 function addComment(data){ 14 $('tbody:first').prepend(data);16 } 17 else { 18 alert(data.html); 19 } 15 20 } 16 21 -
events/phpframework/codeigniter/trunk/system/application/views/status/comment.php
r20198 r20315 8 8 <?=anchor(site_url('user/index/' . $username), $username)?> 9 9 <?php endif ?> 10 <?= h($comment)?>10 <?=$comment?> 11 11 <?=anchor(site_url('user/statuses/' . $username . '/' . $id), posted_time($created_at))?> 12 12 </p>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)