/** * 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); } }
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'); } }
public function __construct($objectId = null) { parent::__construct("Camera", $objectId, false); $query = new ParseQuery("Camera"); $query->equalTo("objectId", $objectId); $this->_cam = $query->first(); }
public function __construct($objectId = null) { parent::__construct("AnimalV2", $objectId, false); $query = new ParseQuery("AnimalV2"); $query->equalTo("objectId", $objectId); $this->_animal = $query->first(); }
public function getById($objectId) { $query = new ParseQuery($this->getClassName()); $query->equalTo('objectId', $objectId); $results = $query->first(); return $results; }
/** * @param $field * @param $value * @param array $columns * @param array $keyToInclude * * @return ParseObject */ public function findBy($field, $value, $columns = ['*'], $keyToInclude = []) { $this->query->equalTo($field, $value); for ($i = 0; $i < count($keyToInclude); $i++) { $this->query->includeKey($keyToInclude[$i]); } return $this->query->first($this->useMasterKey); }
/** * Retrieve a user by the given credentials. * * @param array $credentials * * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null * @throws \Exception * @throws \Parse\ParseException */ public function retrieveByCredentials(array $credentials) { $username = $this->getUsernameFromCredentials($credentials); $query = new ParseQuery('_User'); $query->equalTo('username', $username); $user = $query->first(true); return empty($user) ? null : $user; }
/** * Get the first record that matches the query. * * @param mixed $selectKeys * * @return ObjectModel|null */ public function first($selectKeys = null) { if ($selectKeys) { $this->parseQuery->select($selectKeys); } $data = $this->parseQuery->first($this->useMasterKey); if ($data) { return $this->createModel($data); } }
/** * Envia push de atualizaçao. * * @return Response */ public function enviarAtualizacao() { try { ParseClient::initialize('YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0', 'zNGQwg11i4fQRhGUCZIR777A8VRWjCqe3BQeZgDI', '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o'); $session = Cache::get('sessionToken', 'default'); $usuario = ParseUser::become($session); $texto = Input::get('texto'); $atualizacaoQuery = new ParseQuery("Atualizacao"); $atualizacaoQuery->descending("numero"); $ultimaAtualizacao = $atualizacaoQuery->first(); $novoNumero = $ultimaAtualizacao->get('numero') + 1; $novaAtualizacao = new ParseObject("Atualizacao"); $novaAtualizacao->set('numero', $novoNumero); $novaAtualizacao->set('usuario', $usuario); $novaAtualizacao->set('texto', $texto); $novaAtualizacao->save(); // $fields = array('Accept'=>'application/json', // 'X-Parse-Application-Id' => 'YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0', // 'X-Parse-Master-Key' => '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o'); // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'https://api.parse.com/1/jobs/jobTeste'); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); // curl_setopt($ch, CURLOPT_HEADER, $fields); // curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); // // curl_setopt(CURLOPT_USERPWD, 'XXXXXX'); // $result = curl_exec($ch); // curl_close($ch); // $cmd='curl -X POST \ // -H \"X-Parse-Application-Id: YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0\" \ // -H \"X-Parse-Master-Key: 4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o\" \ // -H \"Content-Type: application/json\" \ // -d \"{\"plan\":\"paid\"}\" \ // https://api.parse.com/1/jobs/jobTeste'; // Log::info($cmd); // exec($cmd,$result); Log::info("CHEGUEI NEGAO"); // Log::info($result); return 200; } catch (ParseException $error) { return $error; } }
public function firstQuery() { $query = new ParseQuery("Test"); try { ParseClient::$THROW_RESPONSE = true; $results = $query->first(); } catch (\Exception $ex) { $msg = json_decode($ex->getMessage(), true); return $msg ? $msg : $ex->getMessage(); } }
public function testIncludeMultipleKeys() { Helper::clearClass("Foo"); Helper::clearClass("Bar"); Helper::clearClass("Parent"); $foo = ParseObject::create('Foo'); $foo->set('rev', 'oof'); $foo->save(); $bar = ParseObject::create('Bar'); $bar->set('rev', 'rab'); $bar->save(); $parent = ParseObject::create('Parent'); $parent->set('foofoo', $foo); $parent->set('barbar', $bar); $parent->save(); $query = new ParseQuery('Parent'); $query->includeKey(['foofoo', 'barbar']); $result = $query->first(); $this->assertEquals('oof', $result->get('foofoo')->get('rev'), 'Object should be fetched'); $this->assertEquals('rab', $result->get('barbar')->get('rev'), 'Object should be fetched'); }
require 'vendor/autoload.php'; use Parse\ParseClient; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseQuery; use Parse\ParseObject; ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ'); if (session_status() == PHP_SESSION_NONE) { session_start(); } ParseClient::setStorage(new ParseSessionStorage()); $currentUser = ParseUser::getCurrentUser(); $courseTitle = $_POST["course"]; $classNumber = $_POST["classNumber"]; $courseQuery = new ParseQuery("Course"); $courseQuery->equalTo("Title", $courseTitle); $course = $courseQuery->first(); $classQuery = new ParseQuery("Class"); $classQuery->equalTo("Course", $course); $classQuery->equalTo("ClassNumber", intval($classNumber)); $class = $classQuery->first(); $comment = new ParseObject("Comment"); $comment->set("User", $currentUser); $currentUser->fetch(); $username = $currentUser->get("UserName"); $comment->set("UserName", $username); $comment->set("Course", $course); $comment->set("Class", $class); $comment->set("Text", $_POST["comment"]); $comment->save();
private function pageExists($name) { $query = new ParseQuery('Pages'); $query->equalTo('name', $name); $object = $query->first(); if (is_object($object)) { return true; } return false; }
<?php require 'vendor/autoload.php'; use Parse\ParseClient; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseQuery; use Parse\ParseObject; ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ'); session_start(); $emailfriend = $_GET["friendEmail"]; ParseClient::setStorage(new ParseSessionStorage()); $currentUser = ParseUser::getCurrentUser(); $emailuser = $currentUser->getUsername(); $friendRequestQuery = new ParseQuery("Friends"); $friendRequestQuery->equalTo("email1", $emailfriend); $friendRequestQuery->equalTo("email2", $emailuser); $request = $friendRequestQuery->first(); $request->set("Aceite", 0); $request->save(); $friendRequestQuery = new ParseQuery("Friends"); $friendRequestQuery->equalTo("email2", $emailfriend); $friendRequestQuery->equalTo("email1", $emailuser); $request = $friendRequestQuery->first(); $request->set("Aceite", 0); $request->save();
} $response = new Response(); $response->id = $ids; $response->name = $names; $response->avatar = $avatars; echo json_encode($response); } if ($func == 'get_user_direct') { $query = new ParseQuery("_User"); $query->equalTo('objectId', $_POST['user']); $users = $query->first(); $ids = array(); $names = array(); $avatars = array(); foreach ($users->get('connected') as $user) { $query = new ParseQuery("_User"); $query->equalTo('objectId', $user); $conn = $query->first(); array_push($ids, $conn->getObjectId()); array_push($names, $conn->get('first')); array_push($avatars, $conn->get('avatar')); } $response = new Response(); $response->id = $ids; $response->name = $names; $response->avatar = $avatars; echo json_encode($response); } ?>
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'); } }
require 'js/parse/autoload.php'; require_once "config.php"; require 'lib/Mailer/PHPMailerAutoload.php'; use Parse\ParseException; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseClient; use Parse\ParseObject; use Parse\ParseQuery; use Parse\ParseGeoPoint; session_start(); /* Find user **/ $query = new ParseQuery("_User"); $query->equalTo("username", $_POST['username']); $user = $query->first(); if (!$user) { echo "Error: User please select valid username"; return; } $result = false; $nice_thing = new ParseObject("NiceThing"); $nice_thing->set("nice_thing", $_POST['content']); $nice_thing->set("location_name", $_POST['location']); $point = new ParseGeoPoint(floatval($_POST['lat']), floatval($_POST['lng'])); $nice_thing->set("location", $point); $nice_thing->set("nice_thing", $_POST['content']); $nice_thing->set("whom", $_POST['who']); $nice_thing->set("feel", $_POST['feel']); $nice_thing->set("message", $_POST['message']); $nice_thing->set("feel", $_POST['feel']);
public function do_update(array $params = []) { $mark = array(); for ($x = 0; $x < count($_POST['title']); $x++) { $tag = new ParseObject("BrandTag"); $tag->set("xCoordinate", (double) $_POST['x'][$x]); $tag->set("yCoordinate", (double) $_POST['y'][$x]); $tag->set("tagName", $_POST['title'][$x]); $tag->save(); $query = new ParseQuery("BrandTag"); $query->descending("createdAt"); $object = $query->first(); $idq = $object->getObjectId(); $mark[] = array('__type' => 'Pointer', 'className' => 'BrandTag', 'objectId' => '' . $idq . ''); } $brandName = $_POST['brandName']; $id = $_POST['id']; $query = new ParseQuery("BrandPost"); $query->equalTo("objectId", $id); $question = $query->first(); $question->setArray("tagArray", $mark); $question->set("brandName", $brandName); $question->set("content", $_POST['content']); if (isset($_POST['items'])) { $it = array(); foreach ($_POST['items'] as $item) { $it[] = array('__type' => 'Pointer', 'className' => 'BrandItem', 'objectId' => '' . $item . ''); $question->setArray("brandItems", $it); } } if (isset($_FILES['image']) && !empty($_FILES['image'])) { if (($_FILES["image"]["type"] == "image/png" || $_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/jpeg") && $_FILES["image"]["size"] < 10000000) { $size = getimagesize($_FILES['image']['tmp_name']); $file = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $_FILES['image']['name']); $file->save(); $question->set("postImage", $file); } } $question->save(); redirect(ADMIN_URL . 'brand_post'); $this->template = false; }
<?php require 'vendor/autoload.php'; use Parse\ParseClient; ParseClient::initialize('4n6JU0CQuBv0LzLoV3dSXDLZTPtPj5ZPd7wSlcRm', 'b8R8Dyh5UTSsJt8WGLWikf93JWDoYxixP9Py9CKF', 'G1ZkAFkBH3QAlruSd8WZ9jvOq20clO3EzMoEBjGZ'); use Parse\ParseObject; use Parse\ParseQuery; try { $query = new ParseQuery("Ads"); $query->equalTo("CallSid", $_GET["CallSid"]); $object = $query->first(); $object->set('Product', $_GET["product"]); $object->save(); echo 0; } catch (execption $e) { echo 1; } try { $post_data = array('From' => '08039511969', 'To' => array('07772823928', $_GET["From"]), 'Body' => 'Your Ad has been approved. You will receive calls and messages soon. Thankyou.'); $exotel_sid = "recursion"; // Your Exotel SID - Get it from here: http://my.exotel.in/Exotel/settings/site#api-settings $exotel_token = "6ce7e6c1450d7017e7694827e109011d0895d09f"; // Your exotel token - Get it from here: http://my.exotel.in/Exotel/settings/site#api-settings $url = "https://" . $exotel_sid . ":" . $exotel_token . "@twilix.exotel.in/v1/Accounts/" . $exotel_sid . "/Sms/send"; $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
<?php require 'vendor/autoload.php'; use Parse\ParseClient; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseQuery; ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ'); if (session_status() == PHP_SESSION_NONE) { session_start(); } ParseClient::setStorage(new ParseSessionStorage()); include_once "template/header.php"; include_once "template/nav.php"; $course = $_GET["course"]; $coursequery = new ParseQuery("Course"); $coursequery->equalTo("Title", $course); $result = $coursequery->first(); $enrollquery = new ParseQuery("Enrolled"); $currentUser = ParseUser::getCurrentUser(); $enrollquery->equalTo("User", $currentUser); $enrollquery->equalTo("Course", $result); $enrolled = $enrollquery->first(); $enrolled->destroy(); $enrolled->save(); header("Location: perfil.php");
$template = $twig->loadTemplate('bank.html'); //render a template echo $template->render(array('title' => 'Нийт гүйлгээ')); } else { //Database operations $query = new ParseQuery("loss"); $query->equalTo("objectId", '7hOOm7UuHu'); $loss = $query->first(); $daily_loss = $loss->get('daily_loss'); $query = new ParseQuery("loan"); $query->equalTo("objectId", $_GET["cid"]); $loan = $query->first(); $id = $loan->get("customer")->getObjectId(); $query = new ParseQuery("customer"); $query->equalTo("objectId", $id); $customer = $query->first(); $query = new ParseQuery("grafiks"); $query->equalTo("loan", $loan); $query->ascending("step"); $graphics = $query->find(); date_default_timezone_set('Asia/Ulaanbaatar'); $today = new DateTime(); $total_due = 0; $total_paid = 0; $total_loss = 0; $total_left = 0; $early_pay = 0; foreach ($graphics as $graph) { $pay_amount = $graph->get('pay_amount'); $total_due = $total_due + $pay_amount; $paid_amount = $graph->get('paid_amount1');
function change_password($id, $pass) { $response = new Response(); $query = new ParseQuery("_User"); $query->equalTo("objectId", $id); $user = $query->first(); $user->set('password', $pass); try { $user->save(true); session_unset(); session_destroy(); $response->success = true; $response->message = "changed password"; echo json_encode($response); } catch (ParseException $ex) { $response->success = false; $response->message = 'Error: Failed to change: ' . $ex; echo json_encode($response); } }
public function doAddCampaign1($title, $desc, $type, $points, $date, $section, $userpoints, $startdate, $age, $gender, $venueId) { $date1 = date('Y-m-d H:i', strtotime((string) date('Y-m-d'))); $date2 = date_create($date1); $outletCheck = new ParseObject("Outlets", $venueId); $sectionObject = new ParseObject("Sections", $section); $starto = date_format($startdate, 'Y-M-d'); $query = new ParseQuery("Outlets"); $query->equalTo("objectId", $venueId); $outlet = $query->first(); $city = $outlet->get("city"); $city->fetch(); $activity = new ParseObject("ActivityLog"); $activity->set("city", $city); $activity->set("activity", "Campaign Added"); $activity->set("startDate", $starto); $offers = new ParseObject("OutletOffers"); $offers->set("offerTitle", $title); $offers->set("offerDescription", $desc); $offers->set("offerType", $type); $offers->set("pointBalance", $points); if ($startdate >= $date2) { $offers->set("offerStatus", "sent"); } else { $offers->set("offerStatus", "expired"); } $offers->set("age", $age); $offers->set("gender", $gender); $offers->set("offerPoints", $points); $offers->set("userAllocation", $userpoints); $offers->set("expiryDate", $date); $offers->set("startDate", $startdate); $offers->set("startStrDate", $starto); $offers->set("outlet", $outletCheck); $offers->set("section", $sectionObject); try { $offers->save(); $activity->set("campaign", $offers); $activity->save(); return ['status' => true]; } catch (ParseException $ex) { return ['status' => false, 'parseMsg' => $ex->getMessage()]; } }
<?php require_once 'includes/Twig/Autoloader.php'; require_once "config.php"; use Parse\ParseClient; use Parse\ParseObject; use Parse\ParseQuery; use Parse\ParseACL; use Parse\ParsePush; use Parse\ParseUser; use Parse\ParseInstallation; use Parse\ParseException; use Parse\ParseAnalytics; use Parse\ParseFile; use Parse\ParseCloud; $_SESSION = "Array ( [parseData] => Array ( [user] => Parse\\ParseUser [_sessionToken:protected] => r:LAy74EsFuobzvlAQgmRdF00LV [serverData:protected] => Array ( [username] => admin ) [operationSet:protected] => Array ( ) [estimatedData:Parse\\ParseObject:private] => Array ( [username] => admin ) [dataAvailability:Parse\\ParseObject:private] => Array ( [sessionToken] => 1 [username] => 1 ) [className:Parse\\ParseObject:private] => _User [objectId:Parse\\ParseObject:private] => D6C1mdK86t [createdAt:Parse\\ParseObject:private] => DateTime Object ( [date] => 2015-08-28 18:56:27.592000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\\ParseObject:private] => DateTime Object ( [date] => 2015-08-28 18:56:27.592000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\\ParseObject:private] => 1 ) ) [count] => 1 ) "; $new = $_POST['loan']; $query = new ParseQuery("loan"); $query->equalTo("objectId", $new); $loan = $query->first(); $loan->set("status", 0); try { $loan->save(); } catch (ParseException $ex) { // Execute any logic that should take place if the save fails. // error is a ParseException object with an error code and message. echo 'Failed to create new object, with error message: ' . $ex->getMessage(); } echo 'Эээлийн бүртгэл идэвхгүй боллоо ' . $loan->getObjectId();
public function testIncludedObjectsGetACLWithDefaultACL() { Helper::clearClass("Test"); Helper::clearClass("Related"); $defaultACL = new ParseACL(); $defaultACL->setPublicReadAccess(true); $defaultACL->setPublicWriteAccess(true); ParseACL::setDefaultACL($defaultACL, true); $object = ParseObject::create('Test'); $acl = new ParseACL(); $acl->setPublicReadAccess(true); $object->setACL($acl); $object->save(); $this->assertTrue($object->getACL()->getPublicReadAccess()); $related = ParseObject::create('Related'); $related->set('test', $object); $related->save(); $query = new ParseQuery('Related'); $query->includeKey('test'); $objectAgain = $query->first()->get('test'); $this->assertTrue($objectAgain->getACL()->getPublicReadAccess()); $this->assertFalse($objectAgain->getACL()->getPublicWriteAccess()); }
public function testIncrementEmptyFieldSolidifiesType() { $obj = ParseObject::create('TestObject'); $obj->save(); $query = new ParseQuery('TestObject'); $query->equalTo('objectId', $obj->getObjectId()); $objAgain = $query->first(); $objAgain->set('randomkeyagain', 'bar'); $obj->increment('randomkeyagain'); $obj->save(); $this->setExpectedException('Parse\\ParseException', 'invalid type for key randomkeyagain, ' . 'expected number, but got string'); $objAgain->save(); }
public function destroy($id) { $query = new ParseQuery("attractions"); try { $query->equalTo("objectId", $id); $attraction = $query->first(); $attraction->destroy(); return \Redirect::route('displayAttractions')->with('message', 'Attraction has been deleted'); } catch (ParseException $ex) { } }
<?php require 'vendor/autoload.php'; use Parse\ParseClient; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseQuery; ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ'); if (session_status() == PHP_SESSION_NONE) { session_start(); } ParseClient::setStorage(new ParseSessionStorage()); include_once "template/header.php"; include_once "template/nav.php"; $course = $_GET["course"]; $coursequery = new ParseQuery("Course"); $coursequery->equalTo("Title", $course); $result = $coursequery->first(); $viewlaterquery = new ParseQuery("ViewLater"); $currentUser = ParseUser::getCurrentUser(); $viewlaterquery->equalTo("User", $currentUser); $viewlaterquery->equalTo("Course", $result); $viewlater = $viewlaterquery->first(); $viewlater->destroy(); $viewlater->save(); header("Location: profile.php");
use Parse\ParseQuery; $currentUser = ParseUser::getCurrentUser(); if (empty($currentUser)) { header('Location: ../login.php'); exit; } if ($currentUser->get('role') !== "admin") { header('Location: ../login.php'); exit; } if (empty($_GET['username'])) { exit; } $query = new ParseQuery("_User", $currentUser); $query->EqualTo("username", $_GET['username']); $results = $query->first(); $location = $results->get('location'); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>A.S.H.I. | Admin</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.5 --> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<?php require 'vendor/autoload.php'; use Parse\ParseClient; use Parse\ParseUser; use Parse\ParseSessionStorage; use Parse\ParseQuery; use Parse\ParseObject; ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ'); if (session_status() == PHP_SESSION_NONE) { session_start(); } ParseClient::setStorage(new ParseSessionStorage()); $currentUser = ParseUser::getCurrentUser(); $course = $_GET["course"]; if ($currentUser == null) { header("Location: login.php?back=1&course={$course}"); } else { $coursequery = new ParseQuery("Course"); $coursequery->equalTo("Title", $course); $result = $coursequery->first(); $result->fetch(); $finished = new ParseObject("Finished"); $finished->set("User", $currentUser); $finished->set("Course", $result); $finished->save(); header("Location: unenroll.php?course={$course}"); }