summaryrefslogtreecommitdiffstats
path: root/controllers/AnimelistController.php
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-07-25 01:16:16 -0700
committerraylu <raylu@mixpanel.com>2011-07-25 01:16:16 -0700
commit6ee2eb60112e5ecd23be3d5cfe04eda321794898 (patch)
tree22d239391d95bee8685c767e88fb2d7a1a70ef76 /controllers/AnimelistController.php
parent2d2842845b648571e8fc38cf1b3df65386532469 (diff)
downloadotakuhub-6ee2eb60112e5ecd23be3d5cfe04eda321794898.tar.xz
fix null checks
invalid username should probably do something; perhaps handled in view
Diffstat (limited to 'controllers/AnimelistController.php')
-rw-r--r--controllers/AnimelistController.php28
1 files changed, 6 insertions, 22 deletions
diff --git a/controllers/AnimelistController.php b/controllers/AnimelistController.php
index 47e5de2..736921a 100644
--- a/controllers/AnimelistController.php
+++ b/controllers/AnimelistController.php
@@ -16,6 +16,10 @@ class AnimeListController extends \lithium\action\Controller {
public function view($username, $sort = "all")
{
$user = User::find('first', array('conditions' => compact('username')));
+ if ($user == NULL)
+ {
+ return;
+ }
$watching = array();
$paused = array();
@@ -23,9 +27,6 @@ class AnimeListController extends \lithium\action\Controller {
$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
@@ -63,46 +64,30 @@ class AnimeListController extends \lithium\action\Controller {
}
}
- //Ensure the correct user here
public function add($id = null)
{
- //If id is null,
- if ('id' == null) {
- //Redirect them to the search page
+ if (!is_numeric($id)) {
return $this->redirect('Animelist::addsearch');
}
- //Find the requested anime
$anime = Anime::find('first', array('conditions' => array('special_id' => $id)));
$entry = null;
-
- //If data was submitted
if ($this->request->data)
{
- //Create an entry with the data
$entry = Entry::create($this->request->data);
-
-
- //Get the current user
$user = Auth::check('default');
$username = $user['username'];
-
- //Break the tags into an array
if (isset($this->request->data['tags']))
{
$entry->my_tags = explode(',', $this->request->data['tags']);
unset($this->request->data['tags']);
}
-
if($entry->add($username))
{
-
- //Redirect the user to their anime list
return $this->redirect("/animelist/view/$username");
}
}
-
return compact('entry', 'anime');
}
@@ -118,5 +103,4 @@ class AnimeListController extends \lithium\action\Controller {
}
}
-
-} \ No newline at end of file
+}