|
@@ -13,7 +13,6 @@ use li3_flash_message\extensions\storage\FlashMessage;
|
|
|
use lithium\template\helper\Html;
|
|
use lithium\template\helper\Html;
|
|
|
|
|
|
|
|
class UsersController extends \lithium\action\Controller {
|
|
class UsersController extends \lithium\action\Controller {
|
|
|
- public $secret = "marshmallows"; //I don't know why either?
|
|
|
|
|
|
|
|
|
|
//Make login a public action.
|
|
//Make login a public action.
|
|
|
public $publicActions = array('login', 'logout', 'signup', 'confirm');
|
|
public $publicActions = array('login', 'logout', 'signup', 'confirm');
|
|
@@ -113,12 +112,11 @@ class UsersController extends \lithium\action\Controller {
|
|
|
{
|
|
{
|
|
|
$status = true;
|
|
$status = true;
|
|
|
|
|
|
|
|
- return array('sucseeded' => true, 'message' => 'You are now following $username');
|
|
|
|
|
|
|
+ return array('succeeded' => true, 'message' => 'You are now following $username');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Calls the user to addFriend method, then returns the status.
|
|
* Calls the user to addFriend method, then returns the status.
|
|
|
* @param username The name of the user to add as a friend
|
|
* @param username The name of the user to add as a friend
|
|
@@ -183,42 +181,12 @@ class UsersController extends \lithium\action\Controller {
|
|
|
{
|
|
{
|
|
|
//Get the currently logged in user
|
|
//Get the currently logged in user
|
|
|
$user = Auth::check('default');
|
|
$user = Auth::check('default');
|
|
|
-
|
|
|
|
|
- //If there is a user logged in (There should be since feed isn't a public function)
|
|
|
|
|
- if ($user)
|
|
|
|
|
- {
|
|
|
|
|
- //Get that user from the database
|
|
|
|
|
- $user = User::find('first', array('conditions' => array('username' => $user['username'])));
|
|
|
|
|
-
|
|
|
|
|
- //Set the feed variable scope (since we are going to use it outside the loop)
|
|
|
|
|
- $feed;
|
|
|
|
|
|
|
+ $user = User::find($user['id']);
|
|
|
|
|
|
|
|
- if (isset($user->feed)) {
|
|
|
|
|
- //For each post ID in $users feed,
|
|
|
|
|
- foreach ($user->feed as $post)
|
|
|
|
|
- {
|
|
|
|
|
- //Find the post by it's ID
|
|
|
|
|
- $post = Post::find($post);
|
|
|
|
|
-
|
|
|
|
|
- //If a post was found,
|
|
|
|
|
- if (!empty($post))
|
|
|
|
|
- {
|
|
|
|
|
- //Add it to the feed
|
|
|
|
|
- $feed[] = $post;
|
|
|
|
|
- }
|
|
|
|
|
- //Else we should remove the the ID from the users feed.
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* new posts are appended to the end of the feed array, therefore new posts naturally end up at the bottom of the feed
|
|
|
|
|
- * therefore, we reverse the order of the array so that new posts end up at the top of the feed.
|
|
|
|
|
- * This is probably faster than doing sorting by date at the database level, though it for some reason
|
|
|
|
|
- * posts don't get inserted in the right order it could cause them to come out wrong in the view */
|
|
|
|
|
- $feed = array_reverse($feed);
|
|
|
|
|
|
|
|
|
|
- //This renders a custom layout we use for the feed, then passes user and feed to the view for the variables.
|
|
|
|
|
- }
|
|
|
|
|
- return compact('user', 'feed');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return compact('user', 'feed');
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
/*
|
|
/*
|