blob: dfbd5f3510a5a0ff77326706e61dea2e4444346e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
namespace app\FeedsController;
use lithium\security\Auth;
use app\models\Post;
class FeedsController extends \lithium\action\Controller {
//Class Variables
//public $validates =
public function index()
{
//If the user isn't authenticated
if(!Auth::check('default'))
{
//Redirect them to the login/welcome page
$this->redirect('Users::login');
}
//else
//Figure out what user is logged in (from their session cookie presumably)
/* Display the users last 20 posts in decending order. */
$user = Session::read('username');
//Since there can only be one of each username, getting the first occurence of $user should be fine
$query = User::find('first', array('conditions' => array('username' => $user)));
$feed = $query->posts;
return compact($feed); //Return the feed array to the
}
/**
* New needs to do a few things
* 1) Validation,
* Ensure that the post is unique,
* Flood protection
* Spam Protection at some point
* 2) Storage
* The post needs to be stored in the users feed as well as users who are friends with them
*
*/
public function new()
{
}
/**
* Hide needs to put a "HIDES" edge on the graph
* By getting the users document from the database, querying its id
*then doing something like $thisUser->hides($username)
*/
public function hide($username)
{
}
/**
*Does the same sort of validation as new, but deletes a post obviously :P
*/
public function delete($id)
{
$user = Auth::check('default');
$post = Post::find($id);
if ($post->username == $user['username']) {
$post->delete();
}
return $this->redirect('Feed::Index');
}
}
?>
|