예제 #1
0
 public function run()
 {
     parent::run();
     $this->getInputJson();
     if (!($token = validateToken($this->input['token']))) {
         throw new \Exception("Invalid token.");
     }
     //TODO: delete global somehow
     global $user;
     $user = new \User($token['uid']);
     if (isset($this->input['remove'])) {
         if (!$user->removeFavorites($this->input['remove'])) {
             throw new \Exception("Could not remove favorites.");
         }
     }
     if (isset($this->input['add'])) {
         if (!$user->addFavorites($this->input['add'])) {
             throw new \Exception("Could not add favorites.");
         }
     }
     $favorites = array();
     $user->getFavorites();
     foreach ($user->favorites as $favorite) {
         $favorites[] = $favorite['tid'];
     }
     $this->return['favorites'] = $favorites;
 }
예제 #2
0
 public function run()
 {
     parent::run();
     $this->getInputJson();
     if (!($token = validateToken($this->input['token']))) {
         throw new \Exception("Invalid token.");
     }
     //TODO: delete global somehow
     global $user;
     $user = new \User($token['uid']);
     $user->getFavorites();
     $data = array('username' => $user->username, 'nickname' => $user->nickname, 'name' => $user->name, 'email' => $user->email);
     foreach ($user->favorites as $favorite) {
         $data['favorites'][] = $favorite['tid'];
     }
     $this->return['user'] = $data;
 }