private function inmueblesDestacados()
 {
     $inmuebles = Inmueble::findDestacados();
     $arrInmuebles = array();
     foreach ($inmuebles as $inm) {
         array_push($arrInmuebles, $inm->toArray());
     }
     Response::ok(CJSON::encode($arrInmuebles));
 }
 public function processGet()
 {
     $list = Product::model()->findAll();
     $items = array();
     foreach ($list as $p) {
         array_push($items, array("id" => $p->id, "name" => $p->name, "description" => $p->description, "images" => $p->images));
     }
     Response::ok(CJSON::encode(array("version" => "xxxxxxxxxxxxxxxxxxx", "items" => $items)));
 }
 public function postDevice()
 {
     if (Input::has('device_type') && Input::has('token')) {
         $deviceType = Input::get('device_type');
         $token = Input::get('token');
         $user = Auth::getUser();
         $user->device_type = $deviceType;
         $user->device_token = $token;
         $user->save();
         return Response::ok($user);
     } else {
         return Response::error('Missing parameters');
     }
 }
 public function postRegister()
 {
     if (Input::has('email') && Input::has('password') && Input::has('name')) {
         $email = Input::get('email');
         $password = Input::get('password');
         $name = Input::get('name');
         $user = $this->registerService->register($email, $name, $password);
         if ($user === NULL) {
             return Response::error('Failed to register');
         } else {
             return Response::ok($user);
         }
     } else {
         return Response::error('Missing parameters');
     }
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 private function createNotification()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $ntf = new Notification();
         $ntf->customSetAttributes($this->arguments);
         if ($ntf->save()) {
             $transaction->commit();
             Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_EXITO, "message" => "notificacion con id = {$ntf->id} ingresada con exito")));
         } else {
             $transaction->rollback();
             Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => $ntf->getErrors())));
         }
     } catch (\Exception $e) {
         $transaction->rollback();
         Yii::log($e->getMessage(), DBLog::LOG_LEVEL_ERROR);
         Response::error(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => Yii::app()->params["httpErrorCode500Message"])));
     }
 }
 public function deleteIndex()
 {
     $user = Auth::getUser();
     if (Input::has('id')) {
         $friendUser = $this->meService->getUser(Input::get('id'));
         if ($friendUser === null) {
             return Response::error('Invalid friend id');
         }
         $response = $this->meService->deleteFriendship($user, $friendUser);
         if ($response !== null) {
             return Response::ok($response);
         } else {
             return Response::error('Failed to delete friendship');
         }
     } else {
         return Response::error('Missing parameters');
     }
 }
 public function ok()
 {
     $r = Response::ok();
     $this->assertEquals(200, $r->status);
 }
 public function actionGetAllEvents()
 {
     $out = array();
     try {
         $events = Event::model()->findAll("user_id=:userId", array("userId" => Yii::app()->user->id));
         foreach ($events as $e) {
             $item = array('id' => $e->id, 'title' => $e->title, 'url' => Yii::app()->baseUrl . '/index.php/event/' . $e->id, 'class' => 'event-important', 'start' => $e->start . '000', 'end' => $e->end . '000');
             array_push($out, $item);
         }
         Response::ok(CJSON::encode(array('success' => 1, 'result' => $out)));
     } catch (Exception $exc) {
         Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
         Response::error(CJSON::encode(array("result" => "error", "message" => Yii::app()->params["httpErrorCode500Message"])));
     }
 }
 public function actionGetPendingNotifications()
 {
     Response::ok(CJSON::encode(Notification::model()->findAll('id_estado_notificacion=:idEstado', array("idEstado" => 1))));
 }
 public function processGet()
 {
     Response::ok(CJSON::encode(Brand::model()->findAll()));
 }