Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Commit

Permalink
Allow users to edit a comment with a rating
Browse files Browse the repository at this point in the history
  • Loading branch information
akrabat committed Jan 30, 2015
1 parent a1a5f8c commit 3994275
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/system/application/controllers/talk.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ function view($id, $add_act = null, $code = null)
foreach ($this->talks_model
->getUserComments($this->user_model->getId()) as $comment) {
if ($comment->talk_id == $id) {
$already_rated = true;
$already_rated = $comment->ID;
break;
}
}
}
Expand Down Expand Up @@ -681,12 +682,9 @@ function view($id, $add_act = null, $code = null)

if ($acceptable_comment && $sp_ret == true) {

// if the user has already rated, then the rating for this comment is zero
$rating = $already_rated ? 0 : $this->input->post('rating');

$arr = array(
'talk_id' => $id,
'rating' => $rating,
'rating' => $this->input->post('rating'),
'comment' => $this->input->post('comment'),
'date_made' => time(), 'private' => $priv,
'active' => 1,
Expand All @@ -704,6 +702,13 @@ function view($id, $add_act = null, $code = null)
if (isset($com_detail[0])
&& ($com_detail[0]->user_id == $uid)
) {

// if the user has already rated and we're not editing that comment,
// then the rating for this comment is zero
if ($already_rated && $already_rated != $cid) {
$arr['rating'] = 0;
}

$commentEditTime = $com_detail[0]->date_made +
$this->config->item('comment_edit_time');
if (time() >= $commentEditTime) {
Expand Down

0 comments on commit 3994275

Please sign in to comment.