Skip to content

Commit

Permalink
Fix label for editing posts
Browse files Browse the repository at this point in the history
  • Loading branch information
daleharvey committed Jun 18, 2012
1 parent 8d0a559 commit 62a94e1
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions application/models/thread_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
class Thread_model extends Model
{
var $meta, $return, $page;

public function get_thread($thread_id, $meta, $page)
{
if (!is_numeric($thread_id))
return NULL;

$this->page = $page;

// set the internal happiness
$this->meta = $meta;

// get thread information from the database
$this->return = (object) array(
'information' => $this->get_information($thread_id)
);

// if the thread info is null, no need to continue
if ($this->return->information == NULL)
return NULL;

// get the comments from the database
$this->return->comments = $this->get_comments($thread_id);

// has to be called DIRECTLY AFTER $this->get_comments()
$this->return->information->comment_count = (int) $this->db->query('SELECT FOUND_ROWS() AS thread_count')->row()->thread_count;

// send it back
return $this->return;
}

/*
* Gets basic header information for a given thread
*
Expand Down Expand Up @@ -60,17 +60,17 @@ private function get_information($thread_id)
ON favorites.user_id = ?
AND favorites.thread_id = threads.thread_id
LEFT JOIN hidden_threads
ON hidden_threads.user_id = ?
ON hidden_threads.user_id = ?
AND hidden_threads.thread_id = threads.thread_id
WHERE threads.thread_id = ? AND threads.deleted != 1";

$result = $this->db->query($sql, array(
$this->meta['user_id'],
$this->meta['user_id'],
$this->meta['user_id'],
$thread_id)
)->row();

if (count($result))
{
return (object) array(
Expand All @@ -92,7 +92,7 @@ private function get_information($thread_id)
return NULL;
}
}

/**
* Get a count of all the comments for a given thread id
*
Expand Down Expand Up @@ -124,23 +124,23 @@ private function get_comments($thread_id)
LIMIT ?, ?";

$result = $this->db->query($sql, array(
$this->meta['user_id'],
$this->meta['user_id'],
$thread_id,
$this->page,
$this->meta['comments_shown']
));

if (!$result->num_rows())
{
return NULL;
} else {
$return = array();

$i = 0;
foreach($result->result() as $row)
{
if ($row->deleted == '0')
{
{
$return[$i] = (object) array(
'comment_id' => $row->comment_id,
'content' => $row->content,
Expand All @@ -154,18 +154,18 @@ private function get_comments($thread_id)
'author_acquaintance_type' => (int) $row->author_acquaintance_type,
'author_acquaintance_name' => $row->author_acquaintance_type == 1 ? 'buddy' : ($row->author_acquaintance_type == 2 ? 'enemy' : NULL),
'owner' => $this->meta['user_id'] == $row->author_id,
'editable' => ($this->meta['user_id'] == $row->author_id) && ($row->created > time() - (60 * 60 * 24)),
'editable' => ($this->meta['user_id'] == $row->author_id) && ($row->created < time() - (60 * 60 * 24)),
'show_controls' => $this->page == 0 && ($this->meta['user_id'] == $row->author_id) && !$i
);

// update comments if the content doesnt match original
if ($row->content === '' && $row->content == _process_post($row->original_content))
{
$return[$i]->content = _process_post($row->original_content);
$this->db->query("UPDATE comments SET content = ? WHERE comment_id = ?",
array($return[$i]->content, $row->comment_id));
}

if ($return[$i]->author_acquaintance_type == 2)
++$this->return->information->enemies;
} else {
Expand All @@ -175,14 +175,14 @@ private function get_comments($thread_id)
'deleted' => 1
);
}

++$i;
}

return $return;
}
}

/**
* Insert a new comment into the database
*
Expand All @@ -191,7 +191,7 @@ private function get_comments($thread_id)
function new_comment($comment)
{
$created = date("Y-m-d H:i:s", utc_time());

$sql = "INSERT
INTO comments (
thread_id,
Expand All @@ -201,7 +201,7 @@ function new_comment($comment)
created
) VALUES (?, ?, ?, ?, ?)";

$this->db->query($sql,
$this->db->query($sql,
array(
$comment->thread_id,
$comment->user_id,
Expand All @@ -227,7 +227,7 @@ function new_comment($comment)
);

$sql = "UPDATE
categories
categories
SET
last_comment_created = ?
WHERE category_id = (
Expand Down

0 comments on commit 62a94e1

Please sign in to comment.