summaryrefslogtreecommitdiffstats
path: root/controllers/FeedsController.php
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
committerMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
commit2389d66da849798f8d4ec5f10e3b07c11da49185 (patch)
treee22556d12982395b469a23420c662662e3e064cc /controllers/FeedsController.php
downloadotakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz
Initial Commit
Diffstat (limited to 'controllers/FeedsController.php')
-rw-r--r--controllers/FeedsController.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/controllers/FeedsController.php b/controllers/FeedsController.php
new file mode 100644
index 0000000..dfbd5f3
--- /dev/null
+++ b/controllers/FeedsController.php
@@ -0,0 +1,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');
+
+ }
+}
+
+?> \ No newline at end of file