コード例 #1
0
ファイル: Controller.php プロジェクト: aglo35/vr_beta
 /**
  * Handles authentication via estonian id-card. Saves data into model User.
  */
 public function auth()
 {
     $ePerson = getEPerson();
     if (!$ePerson) {
         //             TODO: Better handling
         $this->user->string = "ID kaardiga autentimine ebaõnnestus!";
     } else {
         $this->user->lastName = $ePerson[0];
         $this->user->firstName = $ePerson[1];
         $this->user->nationalID = $ePerson[2];
         $this->user->string = "ID kaardiga autentimine õnnestus edukalt!";
         // Check if UserObject already exists
         // TODO: Put following code into separate function
         $query = new ParseQuery("UserObject");
         $query->equalTo("nationalID", $this->user->nationalID);
         $count = $query->count();
         $parseUser = $query->first();
         if ($count == 1 && $parseUser->get('nationalID') == $this->user->nationalID) {
             $this->user->parseMessage = $parseUser->getObjectId();
         } else {
             $this->saveUserData($this->user, $this->user->lastName, $this->user->firstName, $this->user->nationalID);
         }
         // Starts user session
         $this->begin_session();
         //            $this->signUp($this->user, $this->user->lastName, $this->user->firstName, $this->user->nationalID);
     }
 }
コード例 #2
0
 public function doQuery()
 {
     $currentUser = ParseUser::getCurrentUser();
     $companyQuery = new ParseQuery("Companies");
     $companyQuery->equalTo("owner", $currentUser);
     $companyQuery->ascending("name");
     $compResults = $companyQuery->first();
     $objectId = $compResults->getObjectId();
     $company = new ParseObject("Companies", $objectId);
     $outletQuery = new ParseQuery("Outlets");
     $outletQuery->equalTo("company", $company);
     $results = $outletQuery->find();
     $outletInfo = [];
     for ($i = 0; $i < count($results); $i++) {
         $object = $results[$i];
         $outlet = new ParseObject("Outlets", $object->getObjectId());
         $offerQuery = new ParseQuery("OutletOffers");
         $offerQuery->equalTo("outlet", $outlet);
         $offerQuery->equalTo("offerStatus", "live");
         $beacQuery = new ParseQuery("Beacons");
         $beacQuery->equalTo("outlet", $outlet);
         $beacresults = $beacQuery->count();
         $offerResults = $offerQuery->count();
         $outletInfo[] = ['venueName' => $object->get('outletName'), 'beacons' => $beacresults, 'offers' => $offerResults, 'venueId' => $object->getObjectId()];
     }
     return $outletInfo;
 }
コード例 #3
0
 public function addTask(Request $request)
 {
     $parseTask = new ParseObject("Task");
     $parseCropQuery = new ParseQuery("Crop");
     $parseCropQuery->equalTo("cropName", $request->input('crop'));
     $crop = $parseCropQuery->first();
     $parseQuery = new ParseQuery("Task");
     $parseQuery->equalTo("cropName", $crop);
     $parseQuery->equalTo("taskDesc", $request->input('taskName'));
     if ($parseQuery->count() > 0) {
         return redirect('/tasks');
     }
     $parseTask->set("cropName", $crop);
     $parseTask->set("taskDesc", $request->input('taskName'));
     $parseTask->set("taskDuration", $request->input('taskDuration'));
     $parseTask->set("taskStart", $request->input('taskStart'));
     try {
         $parseTask->save();
         \Session::put('message', 1);
         return redirect('tasks');
     } catch (ParseException $e) {
         \Session::put('message', -1);
         return redirect('tasks');
     }
 }
 /**
  * Lists all ProjectsAdmin entities.
  *
  * @Route("/index/{page}", name="admin_projects", defaults={ "page" = 1 })
  * @Method("GET")
  * @Template()
  */
 public function indexAction($page)
 {
     $query = new ParseQuery('Project');
     $query->ascending("label");
     $query->limit(12);
     $query->skip(12 * ($page - 1));
     $entities = $query->find();
     return array('entities' => $entities, 'hits' => ceil($query->count() / 12), 'page' => $page, 'csrf' => $this->get('form.csrf_provider'));
 }
コード例 #5
0
ファイル: ParseObjectTest.php プロジェクト: aglo35/vr_beta
 public function testFind()
 {
     Helper::clearClass('TestObject');
     $obj = ParseObject::create('TestObject');
     $obj->set('foo', 'bar');
     $obj->save();
     $query = new ParseQuery('TestObject');
     $query->equalTo('foo', 'bar');
     $response = $query->count();
     $this->assertTrue($response == 1);
 }
コード例 #6
0
ファイル: Categorias.php プロジェクト: royergarci/ipc
 public function traerCategorias()
 {
     //$categorias = new stdClass();
     $query = new ParseQuery("noticias");
     $query->equalTo("categorias", "noticia");
     $categorias[0]['nombre'] = 'noticia';
     $categorias[0]['num'] = $query->count();
     $query->equalTo("categorias", "intervencion");
     $categorias[1]['nombre'] = 'intervenciones';
     $categorias[1]['num'] = $query->count();
     $query->equalTo("categorias", "video");
     $categorias[2]['nombre'] = 'videos';
     $categorias[2]['num'] = $query->count();
     $query->equalTo("categorias", "iniciativa");
     $categorias[3]['nombre'] = 'iniciativas';
     $categorias[3]['num'] = $query->count();
     $query->equalTo("categorias", "prensa");
     $categorias[4]['nombre'] = 'prensa';
     $categorias[4]['num'] = $query->count();
     $query->equalTo("categorias", "comunicado");
     $categorias[5]['nombre'] = 'comunicados';
     $categorias[5]['num'] = $query->count();
     return $categorias;
 }
コード例 #7
0
ファイル: Campaigns.php プロジェクト: Lawrence94/sme4me
 public function get_beacons()
 {
     $user = ParseUser::getCurrentUser();
     $outletCheck = $user->get("outlet");
     $outletCheck->fetch();
     $sectionId = $this->uri->segment(4);
     $section = new ParseObject("Sections", $sectionId);
     $beaconQuery = new ParseQuery("Beacons");
     $beaconQuery->equalTo("section", $section);
     $beaconQuery->equalTo("outlet", $outletCheck);
     $result = $beaconQuery->count();
     if (!empty($result)) {
         $beaconInfo = [];
         $beaconInfo['234'] = $result;
         echo json_encode($beaconInfo);
     } else {
         echo 'none';
     }
 }
コード例 #8
0
 public function testRestrictedCount()
 {
     $obj = ParseObject::create("TestObject");
     $restrictedACL = new ParseACL();
     $obj->setACL($restrictedACL);
     $obj->save();
     $query = new ParseQuery("TestObject");
     $count = $query->count();
     $this->assertEquals(0, $count);
     $count = $query->count(true);
     $this->assertEquals(1, $count);
 }
コード例 #9
0
 public function submitForm(Request $request)
 {
     $parseCrop = new ParseObject("Crop");
     $newCropType = new CropTypeBusiness();
     /*$crop->strCropType = $request->input('cropType');
             $crop->strCropName = $request->input('cropName');
             $crop->dblMinPh = $request->input('minPh');
             $crop->dblMaxPh = $request->input('maxPh');
             $crop->$dblMinSunlight = $request->input('minSunlight');
             $crop->$dblMaxSunlight = $request->input('maxSunlight');
             $crop->$dblMinMoisture = $request->input('minMoisture');
             $crop->$dblMaxMoisture = $request->input('maxMoisture');
             $crop->$dblMinTemp = $request->input('minTemp');
             $crop->$dblMaxTemp = $request->input('maxTemp');
             $crop->$dblPlantingDistance = $request->input('plantDist');
             $crop->$strSeason = $request->input('season');
             $crop->$strFertilizer = $request->input('fertSelect');
             $crop->$dblAmountOfFertilizer = $request->input('fertAmt');
             //$crop->$listTask = $request->input('listTask');               //how listTask? how array?
             
     public $strCropName;
             public $strCropType;
             public $dblMinPh;
             public $dblMaxPh;
             public $dblMinSunlight;
             public $dblMaxSunlight;
             public $dblMinMoisture;
             public $dblMaxMoisture;
             public $dblMinTemp;
             public $dblMaxTemp;
             public $dblPlantingDistance;
             public $strSeason;
             public $strFertilizer;
             public $dblAmountOfFertilizer;
     
             $status = $this->cropBusiness($this->crop);
             
             if ($status == "error-validation"){
     
             }
             else if ($status == "error-validation"){
                 
             }
             else if ($status == "success"){
                 
             }*/
     $cropTypeVar = null;
     $fertTypeVar = null;
     $parseCropType = null;
     $parseFertilizer = null;
     $parseQuery = new ParseQuery("Crop");
     $parseQuery->equalTo("cropName", $request->input('cropName'));
     if ($parseQuery->count() > 0) {
         return redirect('/maintenance');
     }
     $parseCrop->set("cropName", $request->input('cropName'));
     $parseCrop->set("price", $request->input('cropPrice'));
     $parseCrop->set("minPh", $request->input('minPh'));
     $parseCrop->set("maxPh", $request->input('maxPh'));
     $parseCrop->set("minMoisture", $request->input('minMoisture'));
     $parseCrop->set("maxMoisture", $request->input('maxMoisture'));
     $parseCrop->set("minSunlight", $request->input('minSunlight'));
     $parseCrop->set("maxSunlight", $request->input('maxSunlight'));
     $parseCrop->set("minTemp", $request->input('minTemp'));
     $parseCrop->set("maxTemp", $request->input('maxTemp'));
     $parseCrop->set("plantingDistance", $request->input('plantDist'));
     $parseCrop->set("fertilizerAmount", $request->input('fertAmt'));
     $parseCrop->set("season", $request->input('season'));
     $parseCrop->set("cropDesc", $request->input('cropDesc'));
     $parseCrop->set("daysBeforeHarvest", $request->input('cropBeforeHarvest'));
     // Tawag mo nalang
     if ($request->input('newcroptype') == null || strcmp($request->input('newcroptype'), "") == 0) {
         $parseQuery = new ParseQuery("CropType");
         $parseQuery->equalTo("cropTypeDesc", $request->input('cropType'));
         $cropType = $parseQuery->first();
         $parseCrop->set("cropType", $cropType);
     } else {
         $cropTypeVar = $request->input('newcroptype');
         $parseQuery = new ParseQuery("CropType");
         $parseQuery->equalTo("cropTypeDesc", $cropTypeVar);
         if ($parseQuery->count() > 0) {
             $cropType = $parseQuery->first();
             $parseCrop->set("cropType", $cropType);
         } else {
             $parseCropType = new ParseObject("CropType");
             $parseCropType->set("cropTypeDesc", $cropTypeVar);
             $parseCropType->save();
             $parseCrop->set("cropType", $parseCropType);
         }
     }
     if ($request->input('newferttype') == null || strcmp($request->input('newferttype'), "") == 0) {
         $parseQuery = new ParseQuery("Fertilizer");
         $parseQuery->equalTo("fertilizerDesc", $request->input('fertSelect'));
         $fertilizer = $parseQuery->first();
         $parseCrop->set("fertilizer", $fertilizer);
     } else {
         $fertTypeVar = $request->input('newferttype');
         $parseQuery = new ParseQuery("Fertilizer");
         $parseQuery->equalTo("fertilizerDesc", $fertTypeVar);
         if ($parseQuery->count() > 0) {
             $fertilizer = $parseQuery->first();
             $parseCrop->set("fertilizer", $fertilizer);
         } else {
             $parseFertilizer = new ParseObject("Fertilizer");
             $parseFertilizer->set("fertilizerDesc", $fertTypeVar);
             $parseFertilizer->save();
             $parseCrop->set("fertilizer", $parseFertilizer);
         }
     }
     //task insertion
     try {
         $parseCrop->save();
         \Session::put('message', 1);
         return redirect('maintenance');
     } catch (ParseException $e) {
         \Session::put('message', -1);
         return redirect('maintenance');
     }
 }
コード例 #10
0
ファイル: APIUsuario.php プロジェクト: sterben93/casa
 public static function agregarAFavoritos($inmueble)
 {
     $usuario = APIUsuario::usuarioActual();
     if (!$usuario->isAuthenticated()) {
         return false;
     }
     $query = new ParseQuery("Favoritos");
     $query->equalTo("idInmueble", $inmueble);
     $query->equalTo("idUsuario", $usuario);
     if ($query->count() > 0) {
         return;
     }
     $favoritos = new ParseObject("Favoritos");
     $favoritos->set("idInmueble", $inmueble);
     $favoritos->set("idUsuario", $usuario);
     $favoritos->save();
 }
コード例 #11
0
<?php

session_start();
require 'vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
ParseClient::initialize('ilAdpSlcSs2PYQzZtC9k549MMrEq6GWBEkgPL052', '2ptwsyysoXq6KZ055Rz6qgAVLc6kGqq4geBcYGrV', '5o87OulNuELCkqYB3cju1ETOcLllLqB5K13F12Pg');
try {
    $query = new ParseQuery("Merchant");
    $query->equalTo("contact_no", $_POST['mobileno']);
    if ($query->count() >= 1) {
        header('location:merchantregister.php');
    } else {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $mobileno = $_POST['mobileno'];
        $address = $_POST['address'];
        $location = $_POST['location'];
        $password = $_POST['password'];
        $testObject = ParseObject::create("Merchant");
        $testObject->set("Mname", $name);
        $testObject->set("contact_no", $mobileno);
        $testObject->set("Prefer_Location", $location);
        $testObject->set("emailId", $email);
        $testObject->set("Address", $address);
        $testObject->set("password", md5($password));
        $testObject->set("mob_verified", 1);
        $_SESSION["contact_no"] = $testObject->get("contact_no");
        $testObject->save();
        header('location:merchantdashboard.php');
コード例 #12
0
ファイル: Venues.php プロジェクト: Lawrence94/sme4me
 public function get_beacons($venueId)
 {
     $venue = new ParseObject("Outlets", $venueId);
     $sectionId = $this->uri->segment(5);
     $section = new ParseObject("Sections", $sectionId);
     $beaconQuery = new ParseQuery("Beacons");
     $beaconQuery->equalTo("section", $section);
     $beaconQuery->equalTo("outlet", $venue);
     $result = $beaconQuery->count();
     if (!empty($result)) {
         $beaconInfo = [];
         $beaconInfo['234'] = $result;
         echo json_encode($beaconInfo);
     } else {
         echo 'none';
     }
 }
コード例 #13
0
ファイル: Query.php プロジェクト: parziphal/parse
 public function count()
 {
     return $this->parseQuery->count($this->useMasterKey);
 }
コード例 #14
0
 public function saveCrop($crop)
 {
     $queryCrop = new ParseQuery("Crop");
     $queryCropType = new ParseQuery("CropType");
     $querySeason = new ParseQuery("Season");
     $queryFertilizer = new ParseQuery("Fertilizer");
     $queryTaskCategory = new ParseQuery("TaskCategory");
     $parseCrop = new ParseObject("Crop");
     $parseTask = new ParseObject("Task");
     try {
         $queryCrop->equalTo("cropName", $crop->strCropName);
         if ($queryCrop->count() != 0) {
             return "existing";
         }
         //getting crop type
         $queryCropType->equalTo("cropTypeDesc", $crop->strCropType);
         if ($queryCrop->count() == 0) {
             $parseCropType = new ParseObject("TaskCategory");
             $parseCropType->set("taskCatDesc", $crop->strCropType);
             $parseCropType->save();
         }
         $cropType = $queryCropType->first();
         //getting season
         $querySeason->equalTo("seasonDesc", $crop->strSeason);
         if ($querySeason->count() == 0) {
             $parseSeason = new ParseObject("Season");
             $parseSeason->set("seasonDesc", $crop->strSeason);
             $parseSeason->save();
         }
         $season = $querySeason->first();
         //getting fertilizer
         $queryFertilizer->equalTo("fertilizerDesc", $crop->strFertilizer);
         if ($queryFertilizer->count() == 0) {
             $parseFertilizer = new ParseObject("Fertilizer");
             $parseFertilizer->set("fertilizerDesc", $crop->strSeason);
             $parseFertilizer->save();
         }
         $fertilizer = $queryFertilizer->first();
         $parseCrop->set("cropName", $crop->strCropName);
         $parseCrop->set("cropType", $cropType);
         $parseCrop->set("minPh", $crop->dblMinPh);
         $parseCrop->set("maxPh", $crop->dblMaxPh);
         $parseCrop->set("minMoisture", $crop->dblMinMoisture);
         $parseCrop->set("maxMoisture", $crop->dblMaxMoisture);
         $parseCrop->set("minSunlight", $crop->dblMinSunlight);
         $parseCrop->set("maxSunlight", $crop->dblMaxSunlight);
         $parseCrop->set("minTemp", $crop->dblMinTemp);
         $parseCrop->set("maxTemp", $crop->dblMaxTemp);
         $parseCrop->set("plantingDistance", $crop->dblPlantingDistance);
         $parseCrop->set("season", $season);
         $parseCrop->set("fertilizer", $fertilizer);
         $parseCrop->set("fertilizerAmount", $crop->dblAmountOfFertilizer);
         //adding tasks
         foreach ($crop->listTask as $task) {
             $queryTaskCategory->equalTo("taskCatDesc", $task->strTaskName);
             $taskCategory = $queryTaskCategory->first();
             if ($queryTaskCategory->count() == 0) {
                 $parseTaskCategory = new ParseObject("TaskCategory");
                 $parseTaskCategory->set("taskCatDesc", $crop->strTaskName);
                 $parseTaskCategory->save();
             }
             //end if()
             $parseTask->set("taskCategory", $taskCategory);
             $parseTask->set("taskDesc", $task->strTaskDesc);
             $parseTask->set("taskDuration", $task->intTaskDuration);
             $parseTask->save();
         }
         //end foreach
         return "success";
     } catch (Exception $e) {
         dd($e);
     }
     //end try catch()
     return "error-database";
 }
コード例 #15
0
ファイル: Validator.php プロジェクト: khangaikh/golocal
 public function parseUserUnique($attribute, $value, $parameters)
 {
     $query = new ParseQuery('_User');
     $query->equalTo('username', $value);
     return !(bool) $query->count();
 }