summaryrefslogtreecommitdiffstats
path: root/controllers
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-29 16:35:13 -0400
committerMichael Francis <edude03@gmail.com>2011-05-29 16:35:13 -0400
commit88666d9644f06f2dd37516c95661f24d9f2eadbe (patch)
treea8cf506993598aebe8acbd7755626dd784817907 /controllers
parent5632af0c0e7bf914227cdf237d370858b88ac969 (diff)
downloadotakuhub-88666d9644f06f2dd37516c95661f24d9f2eadbe.tar.xz
Implemented / Fixed adding
Diffstat (limited to 'controllers')
-rw-r--r--controllers/AnimelistController.php38
1 files changed, 30 insertions, 8 deletions
diff --git a/controllers/AnimelistController.php b/controllers/AnimelistController.php
index c61577a..7eb8c4c 100644
--- a/controllers/AnimelistController.php
+++ b/controllers/AnimelistController.php
@@ -5,24 +5,29 @@ namespace app\controllers;
use app\models\contentList;
use app\models\User;
use app\models\Anime;
+use app\models\Entry;
+use \lithium\security\Auth;
class AnimeListController extends \lithium\action\Controller {
public $publicActions = array('view');
+
public function view($username, $sort = "all")
{
$user = User::find('first', array('conditions' => compact('username')));
-
$watching = array();
$paused = array();
$dropped = array();
$planning = array();
$finished = array();
-
+ //The anime list comes back as a DocumentArray, so we can
+ //parse through them with a foreach
+ //For each entry,
foreach($user->animelist as $entry)
{
+ //Sort it based on status
switch($entry->my_status)
{
case "Completed": $finished[] = $entry; break;
@@ -46,16 +51,33 @@ class AnimeListController extends \lithium\action\Controller {
}
}
- public function add($id)
+ public function addsearch()
+ {
+ if (isset($this->request->query['Search'])) {
+ $searchParam = '/' . $this->request->query['Search'] . '/i';
+ if($this->request->query['Search'])
+ {
+ return Anime::search($searchParam);
+ }
+ }
+ }
+
+ //Ensure the correct user here
+ public function add($id = null)
{
if (empty($this->request->data))
{
- $anime = Anime::find('first', array('conditions' => array('special_id' => $id)));
- $entry = null;
- return compact('anime', 'entry');
+ if ('id' != null)
+ {
+ $anime = Anime::find('first', array('conditions' => array('special_id' => $id)));
+ $entry = null;
+ return compact('anime', 'entry');
+ }
+ return array('anime' => null, 'entry' => null);
}
-
$entry = Entry::create($this->request->data);
+ $user = Auth::check('default');
+ $username = $user['username'];
if (isset($this->request->data['tags']))
{
@@ -66,7 +88,7 @@ class AnimeListController extends \lithium\action\Controller {
if ($entry->validates()) {
$entry->add($username);
- return $this->redirects('Animelist::Index');
+ return $this->redirect("/animelist/view/$username");
}
return $entry;