Skip to content

Commit

Permalink
Fix issue #123 (@Nodesys)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goteo committed Aug 3, 2014
1 parent 27155ee commit 677f361
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controller/admin/blog.php
Expand Up @@ -61,7 +61,7 @@ public static function process ($action = 'list', $id = null, $filters = array()
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['blog'])) {
Message::Error('Hemos perdido de vista su blog!!!');
break;
throw new Redirection('/admin/blog');
}

$editing = false;
Expand Down
4 changes: 3 additions & 1 deletion model/blog.php
Expand Up @@ -60,14 +60,16 @@ public static function get ($owner, $type = 'project') {
$blog->project = $blog->owner;
break;
}

if ($blog->node == \GOTEO_NODE) {
$blog->posts = Blog\Post::getAll();
} elseif (!empty($blog->id)) {
$blog->posts = Blog\Post::getAll($blog->id);
} else {
$blog->posts = array();
}
return $blog;

return $blog;
}

/*
Expand Down
15 changes: 10 additions & 5 deletions model/blog/post.php
Expand Up @@ -149,18 +149,21 @@ public static function getAll ($blog = null, $limit = null, $published = true) {
if ($published) {
$sql .= " AND post.publish = 1
";
// @NODESYS
/*
if (empty($blog)) {
$sql .= " AND blog.owner IN (SELECT id FROM node WHERE active = 1)
AND blog.owner != 'testnode'
";
}
*/
}
$sql .= "ORDER BY post.date DESC, post.id DESC
";
if (!empty($limit)) {
$sql .= "LIMIT $limit";
}

$query = static::query($sql, $values);

foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $post) {
Expand Down Expand Up @@ -191,8 +194,9 @@ public static function getAll ($blog = null, $limit = null, $published = true) {

case 'node':
$post->user = User::getMini($post->author);
$node_blog = Node::get($post->owner_id);
$post->owner_name = $node_blog->name;
// @NODESYS
//$node_blog = Node::get($post->owner_id);
$post->owner_name = $post->user->name;
break;
}

Expand Down Expand Up @@ -332,8 +336,9 @@ public static function getList ($filters = array(), $published = true) {

case 'node':
$post->user = User::getMini($post->author);
$node_blog = Node::get($post->owner_id);
$post->owner_name = $node_blog->name;
// @NODESYS
// $node_blog = Node::get($post->owner_id);
$post->owner_name = $post->user->name;
break;
}

Expand Down

0 comments on commit 677f361

Please sign in to comment.