Ejemplo n.º 1
0
         echo "That person was already favorited";
     }
     exit;
 }
 if ($action == 'remove_from_favorites') {
     $user = User::current_user();
     $user = recast('User', $user);
     $id = getRequest('id');
     $check = Favorites::checkFavoriteById($id, $user->id);
     if ($check) {
         // error_reporting(E_ALL);
         // ini_set('display_errors', '1');
         $check = recast("Favorites", $check[0]);
         $result = $check->delete();
         if ($result) {
             $leftovers = Favorites::getFavoritesByUser($user->id);
             $data = array();
             $data[0] = "success";
             $data[1] = array();
             $count = 0;
             foreach ($leftovers as $person) {
                 $temp = Person::getById($person->person_id);
                 $temp = recast("Person", $temp);
                 $data[1][$count] = $temp;
                 $data[1][$count]->displayName = $temp->displayName();
                 $count++;
             }
             echo json_encode($data);
             exit;
         } else {
             echo "Failure";