/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $condicoesJSON = Input::get('condicoes');
         $condicoes = json_decode($condicoesJSON);
         $protocoloId = Input::get('id');
         $protocoloQuery = new ParseQuery("Protocolo");
         $protocolo = $protocoloQuery->get($protocoloId);
         $condQuery = new ParseQuery("DescritivoMinimo");
         $condQuery->equalTo('protocolo', $protocolo);
         $condicoesFromServer = $condQuery->find();
         $condicoesArray = [];
         for ($serverIndex = 0; $serverIndex < count($condicoesFromServer); $serverIndex++) {
             $present = false;
             if (array_key_exists($serverIndex, $condicoesFromServer)) {
                 $keysArray = array_keys($condicoes);
                 for ($localIndex = 0; $localIndex < count($keysArray); $localIndex++) {
                     if (array_key_exists($keysArray[$localIndex], $condicoes)) {
                         if ($condicoes[$keysArray[$localIndex]]->id == $condicoesFromServer[$serverIndex]->getObjectId()) {
                             $present = true;
                             $condicoesFromServer[$serverIndex]->set('ordem', $condicoes[$keysArray[$localIndex]]->ordem);
                             $condicoesFromServer[$serverIndex]->save();
                             $condicoesArray[$condicoes[$keysArray[$localIndex]]->ordem] = $condicoesFromServer[$serverIndex]->getObjectId();
                             unset($condicoes[$keysArray[$localIndex]]);
                         }
                     }
                 }
                 if ($present == false) {
                     $condicoesFromServer[$serverIndex]->destroy();
                 }
             }
         }
         $keysArray = array_keys($condicoes);
         for ($index = 0; $index < count($keysArray); $index++) {
             $condicao = new ParseObject("DescritivoMinimo");
             $condicao->set('frase', $condicoes[$keysArray[$index]]->frase);
             $condicao->set('ordem', $condicoes[$keysArray[$index]]->ordem);
             $condicao->set('protocolo', $protocolo);
             $condicao->save();
             $condicoesArray[$condicoes[$keysArray[$index]]->ordem] = $condicao->getObjectId();
         }
         return json_encode($condicoesArray);
     } catch (ParseException $error) {
         dd($error);
         return $error;
     }
 }
 public function update($obj)
 {
     if (empty($obj)) {
         die("No hay asistentes para Actualizar.");
     }
     $con = new Connect();
     $var = $con->connect_to_db();
     $date = new DateTime();
     $resultado = new ParseObject("Asistencia", $obj["IdUsuario"]);
     $resultado->set("Fecha", $date);
     $resultado->set("Presente", $obj["Presente"]);
     try {
         $resultado->save();
         echo 'El objeto fue actualizado: ' . $resultado->getObjectId();
     } catch (ParseException $ex) {
         echo 'Fallo al actualizar, mensaje de error: ' . $ex->getMessage();
     }
 }
示例#3
0
 function add()
 {
     // validators
     $this->form_validation->set_error_delimiters($this->config->item('error_delimeter_left'), $this->config->item('error_delimeter_right'));
     $this->form_validation->set_rules('user_id', lang('reservations input user_id'), 'trim');
     $this->form_validation->set_rules('team_id', lang('reservations input team_id'), 'trim');
     $this->form_validation->set_rules('match_data[date]', lang('reservations input date'), 'required|trim');
     $this->form_validation->set_rules('match_data[time]', lang('reservations input time'), 'required|trim');
     $this->form_validation->set_rules('match_data[duration]', lang('reservations input duration'), 'required|trim|numeric');
     if ($this->form_validation->run() == true) {
         $data = $this->input->post();
         // save the new user
         $reservation = new ParseObject("Reservation");
         $relationOwner = $reservation->getRelation("userId");
         $queryOwner = ParseUser::query();
         $owner = $queryOwner->get("btPTAhtpvo");
         $relationOwner->add($owner);
         $relationStatus = $reservation->getRelation("status");
         $queryStatus = new ParseQuery("ReservationStatus");
         $status = $queryStatus->get("KIzDQVJrAV");
         $relationStatus->add($status);
         $reservation->setAssociativeArray("reservationData", $data['match_data']);
         try {
             $reservation->save();
             $this->session->set_flashdata('message', 'New object created with objectId: ' . $reservation->getObjectId());
             redirect($this->_redirect_url);
         } 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.
             $this->session->set_flashdata('error', 'Failed to create new object, with error message: ' . $ex->getMessage());
         }
         // return to list and display message
     }
     // setup page header data
     // setup page header data
     $this->set_title(sprintf(lang('reservations title reservations'), $this->settings->site_name));
     $this->set_subtitle(lang('reservations subtitle add_reservation'));
     $data = $this->includes;
     // set content data
     $content_data = array('cancel_url' => $this->_redirect_url, 'user' => null, 'password_required' => true);
     // load views
     $data['content'] = $this->load->view('reservations/form', $content_data, true);
     $this->load->view($this->template, $data);
 }
 public function price($data)
 {
     $cp = new ParseQuery("CarWashPackages");
     $results = $cp->get($data["objectId"]);
     $results->set("isRemoved", true);
     $results->save();
     $newPackage = new ParseObject("CarWashPackages");
     $newPackage->set("detail", $data["detail"]);
     $newPackage->set("isRemoved", false);
     $newPackage->set("title", $data["title"]);
     $newPackage->set("priceNum", (double) $data["priceNum"]);
     $newPackage->set("price", "\$" . $data["priceNum"]);
     $newPackage->set("estTime", (int) $data["estTime"]);
     try {
         $newPackage->save();
         $response = array("Status" => "SUCCESS", "objectId" => $newPackage->getObjectId(), "title" => $newPackage->get("title"), "detail" => $newPackage->get("detail"), "priceNum" => $newPackage->get("priceNum"), "estTime" => $newPackage->get("estTime"), "createdAt" => $newPackage->getCreatedAt());
         return $response;
     } catch (ParseException $ex) {
         $ex_array = array("Status" => "FAILED", "Message" => $ex->getMessage(), "Code" => $ex->getCode());
         return $ex_array;
     }
 }
示例#5
0
 function add()
 {
     $resto = new ParseObject("Restaurant");
     $myIsFast = $this->_isFast == "true" ? true : false;
     $resto->set("address", $this->_address);
     $resto->set("city", $this->_city);
     $resto->set("coord", $this->_coord);
     $resto->set("description", $this->_description);
     $resto->set("fast", $myIsFast);
     $resto->set("name", $this->_nom);
     $resto->set("postal", $this->_postal);
     $resto->set("website", $this->_website);
     $resto->set("validated", $this->_isValidated);
     try {
         $resto->save();
         return $resto->getObjectId();
     } 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();
     }
 }
示例#6
0
 function add()
 {
     echo $this->_nom;
     $coordonees = new ParseGeoPoint(floatval($this->_latitude), floatval($this->_longitude));
     $resto = new ParseObject("Restaurant");
     $isFast = $this->_isFast == "true" ? true : false;
     $resto->set("address", $this->_address);
     $resto->set("city", $this->_city);
     $resto->set("coord", $this->coordonees);
     $resto->set("description", $this->_description);
     $resto->set("fast", $this->{$isFast});
     $resto->set("name", $this->_nom);
     $resto->set("postal", $this->_postal);
     $resto->set("website", $this->_website);
     $resto->set("validated", $this->_isValidated);
     try {
         $resto->save();
         echo 'New object created with objectId: ' . $resto->getObjectId();
     } 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();
     }
 }
 public function upload(Request $request)
 {
     if (isset($_FILES['image'])) {
         // save file to Parse
         try {
             $fname = str_replace(' ', '', $_FILES['image']['name']);
             $file = ParseFile::createFromData(file_get_contents($_FILES['image']['tmp_name']), $fname);
             $file->save();
             // save something to class TestObject
             $asset = new ParseObject("Assets");
             // add the file we saved above
             $asset->set("file", $file);
             $asset->save();
             $ret = ['status' => 'success', 'data' => ['asset' => ['id' => $asset->getObjectId()], 'file' => ['url' => $file->getUrl()]]];
             return response()->json($ret);
         } catch (ParseException $ex) {
             $ret = ['status' => 'fail', 'error' => $ex->getMessage()];
             return response()->json($ret);
         }
     } else {
         $ret = ['status' => 'fail', 'error' => 'no file selected'];
         return response()->json($ret);
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $local = Input::get('local');
         $condicoesJSON = Input::get('condicoes');
         $condicoes = json_decode($condicoesJSON);
         $encaminhamentoId = Input::get('id');
         $encaminhamentoQuery = new ParseQuery("Encaminhamento");
         $encaminhamento = $encaminhamentoQuery->get($encaminhamentoId);
         $encaminhamento->set('local', $local);
         $encaminhamento->save();
         $condQuery = new ParseQuery("Condicao");
         $condQuery->equalTo('encaminhamento', $encaminhamento);
         $condicoesFromServer = $condQuery->find();
         $condicoesArray = [];
         $destaqueArray = [];
         for ($serverIndex = 0; $serverIndex < count($condicoesFromServer); $serverIndex++) {
             $present = false;
             if (array_key_exists($serverIndex, $condicoesFromServer)) {
                 $keysArray = array_keys($condicoes);
                 for ($localIndex = 0; $localIndex < count($keysArray); $localIndex++) {
                     if (array_key_exists($keysArray[$localIndex], $condicoes)) {
                         if ($condicoes[$keysArray[$localIndex]]->id == $condicoesFromServer[$serverIndex]->getObjectId()) {
                             $present = true;
                             $condicoesFromServer[$serverIndex]->set('ordem', $condicoes[$keysArray[$localIndex]]->ordem);
                             $condicoesFromServer[$serverIndex]->set('destaque', $condicoes[$keysArray[$localIndex]]->destaque);
                             $condicoesFromServer[$serverIndex]->save();
                             $condicoesArray[$condicoes[$keysArray[$localIndex]]->ordem] = $condicoesFromServer[$serverIndex]->getObjectId();
                             $destaqueArray[$condicoes[$keysArray[$localIndex]]->ordem] = $condicoesFromServer[$serverIndex]->get('destaque');
                             unset($condicoes[$keysArray[$localIndex]]);
                         }
                     }
                 }
                 if ($present == false) {
                     $condicoesFromServer[$serverIndex]->destroy();
                 }
             }
         }
         $keysArray = array_keys($condicoes);
         for ($index = 0; $index < count($keysArray); $index++) {
             $condicao = new ParseObject("Condicao");
             $condicao->set('frase', $condicoes[$keysArray[$index]]->frase);
             $condicao->set('ordem', $condicoes[$keysArray[$index]]->ordem);
             $condicao->set('destaque', $condicoes[$keysArray[$index]]->destaque);
             $condicao->set('encaminhamento', $encaminhamento);
             $condicao->save();
             $condicoesArray[$condicoes[$keysArray[$index]]->ordem] = $condicao->getObjectId();
             $destaqueArray[$condicoes[$keysArray[$index]]->ordem] = $condicao->get('destaque');
         }
         Log::info($condicoesArray);
         Log::info($destaqueArray);
         return json_encode(['condicoesArray' => $condicoesArray, 'destaqueArray' => $destaqueArray]);
     } catch (ParseException $error) {
         dd($error);
         return $error;
     }
 }
示例#9
0
        $response->speakers = $spkArray;
        $response->avatar = $imgArray;
        $response->date = $dateArray;
        echo json_encode($response);
    } else {
        $chat = new ParseObject("Chat");
        $users = array();
        array_push($users, $host->getObjectId());
        array_push($users, $user->getObjectId());
        $chat->setArray('users', $users);
        try {
            $chat->save();
            $response = new Response();
            $response->success = true;
            $response->type = 2;
            $response->chat = $chat->getObjectId();
            $response->user = $user->getObjectId();
            echo json_encode($response);
        } catch (ParseException $ex) {
            $response->success = false;
            $response->message = 'Error: Failed to chat: ' . $ex;
            echo json_encode($response);
        }
    }
}
if ($func == 'get_user_all') {
    $query = new ParseQuery("_User");
    $query->equalTo('status', 1);
    $users = $query->find();
    $ids = array();
    $names = array();
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$chatData = new ParseObject("ChatData");
if ($user_id_1 !== NULL && $user_id_2 !== NULL) {
    //insert
    $like_insert_sql = "INSERT INTO likes (user_id_1,user_id_2) VALUES ('{$user_id_1}','{$user_id_2}');";
    if ($conn->query($like_insert_sql) == true) {
        $json_response["success"] = true;
        //checking for a new match
        $sql = "SELECT * FROM likes WHERE user_id_1 = '{$user_id_2}' AND user_id_2 = '{$user_id_1}';";
        $result = $conn->query($sql);
        if ($result->num_rows > 0) {
            try {
                $chatData->setArray("messages", array());
                $chatData->save();
                $chat_id = $chatData->getObjectId();
                $match_sql_1 = "INSERT INTO matches (user_id_1,user_id_2,chat_id) VALUES ('{$user_id_1}','{$user_id_2}','{$chat_id}');";
                $match_sql_2 = "INSERT INTO matches (user_id_1,user_id_2,chat_id) VALUES ('{$user_id_2}','{$user_id_1}','{$chat_id}');";
                $conn->query($match_sql_1);
                $conn->query($match_sql_2);
            } 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();
            }
        }
    }
} else {
    $json_response["success"] = false;
    echo mysql_error();
}
ParseClient::initialize('jVbb8uYocFpOhxTnZtY8DqvVmiEVgWQyU71K24p0', 'ilsN27z74t3N7FAxGVNk7KNDZPwprFbMqWGlQQk8', 'XWMlF7HBGQgblHHN242MfBMjuZJzxH17zzkvo0SB');
?>
    </head>

    <body>
        <?php 
if (isset($_POST['insertData'])) {
    $question = $_POST['question'];
    $answer = $_POST['answer'];
    $QA = new ParseObject("QuestionAnswer");
    $QA->set($QUESTION, $question);
    $QA->set($ANSWER, $answer);
    $QA->set($IS_ANSWERED, TRUE);
    try {
        $QA->save();
        $_SESSION['qid'] = $QA->getObjectId();
        //echo 'qid '.$_SESSION['qid'];
        die("<script>location.href = 'addNameInfo.php'</script>");
    } catch (Parse\ParseException $exc) {
        echo $exc->getTraceAsString() . '. Please try again';
    }
}
?>
        <div class="container" style="margin-top: 200px;">
            <form action="index.php" method="post">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">Data entry form for Kajol vai and his team</h3>
                    </div>
                    <div class="panel-body">
示例#12
0
    $result = true;
} 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 'Error: Failed to create new object, with error message: ' . $ex->getMessage();
    return;
}
class Response
{
}
if ($result) {
    $response = new Response();
    $response->success = true;
    $response->message = "Your nice thing is added";
    $response->user = $res_user;
    $response->data = $nice_thing->getObjectId();
    $_SESSION['id'] = $nice_thing->getObjectId();
    echo json_encode($response);
} else {
    echo "Error: User please select valid username";
}
function sendmail($user, $message)
{
    $body = $message;
    date_default_timezone_set('Etc/UTC');
    $mail = new PHPMailer();
    $mail->isSMTP();
    //      $mail->SMTPDebug = 2;
    $mail->Debugoutput = 'html';
    $mail->Host = '1nicethingnet.domain.com';
    $mail->Port = 587;
$results = $query->find();
$result = $results[0];
//get garden sensors list
$sensors = $result->get("pName");
echo "<br>We are expecting these sensors: " . $sensors;
/* assign sensor values based on above sensor list
   	
   	for ($i = 0; $i < count($sensors); $i++) {
  		$object = $sensors[$i];
 	 	echo $object;
 	 	
	}
   	
   	*/
//assemble sensor array
function arrayize($input)
{
    return array_map('intval', array_filter(explode(",", $input), 'is_numeric'));
}
//$currentReadings = preg_split("\"",
$reading = new ParseObject("Reading");
$reading->set("gardenID", $result);
$reading->setArray("readings", [arrayize($airTemp), arrayize($hum), arrayize($waterTemp), arrayize($sun), arrayize($wet), arrayize($waterPH)]);
try {
    $reading->save();
    echo '<br>New reading created with objectId: ' . $reading->getObjectId() . '<br>';
} 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();
}
示例#14
0
<?php

require 'vendor/autoload.php';
use Parse\ParseClient;
session_start();
ParseClient::initialize('6OsMY7JbzoLcCpP1UBgMUJdc4Ol68kDskzq8b3aw', 'B7llkQxaYdCqUlFENwTCEeavarSvQp4It25a0kpH', '7QwWggaRtzFsNniqlgrXwtRqkLaXmW2BzOJMv6O9');
use Parse\ParseQuery;
use Parse\ParseObject;
use Parse\ParseUser;
use Parse\ParseException;
$currentUser = ParseUser::getCurrentUser();
$survey = new ParseObject("surveys");
$survey->set("userid", $currentUser->getObjectId());
$survey->set("logo_url", $currentUser->get("logo_url"));
$survey->save();
$_SESSION['survey'] = $survey->getObjectId();
include "assets/templates/header.php";
?>

<link href="assets/css/dropzone.css" type="text/css" rel="stylesheet" />
<script src="assets/js/dropzone.js"></script>


<br>
<div id="login-overlay" class="modal-dialog">
    <div class="well">
        <h3 class="title text-center">Upload your images here! </h3>
            <div class="form-group">
                <form action="upload.php" method="post" class="dropzone" id="my-awesome-dropzone">
                </form>
                <span class="help-block"></span>
 function createProduct($prod)
 {
     echo "<br />\n";
     echo 'Start creating product';
     $rakuten_product = new ParseObject("Rakuten_Product");
     // Set values
     $rakuten_product->set("sku", (string) $prod->sku);
     $rakuten_product->set("title", (string) $prod->name);
     $rakuten_product->set("imageUrl", (string) $prod->productImage);
     $rakuten_product->set("info", (string) $prod->long_description);
     $rakuten_product->set("affiliateUrl", (string) $prod->productUrl);
     $rakuten_product->set("price", floatval($prod->final_price));
     $rakuten_product->set("MSRP", floatval($prod->retail));
     try {
         echo "<br />\n";
         echo "Start Saving product. <br />\n";
         $rakuten_product->save();
         echo "End saving.";
         echo 'New object created with objectId: ' . $rakuten_product->getObjectId();
     } catch (Exception $ex) {
         echo "<br />\n";
         echo "Error saving";
         echo 'Failed to create new object, with error message: ' . $ex->getMessage();
     }
     // Save:
     $newId = $rakuten_product->getObjectId();
     //save to product images
 }
示例#16
0
 /**
  * @return array
  */
 public function parseObjectToArray(ParseObject $object)
 {
     $array = $object->getAllKeys();
     $array['objectId'] = $object->getObjectId();
     $createdAt = $object->getCreatedAt();
     if ($createdAt) {
         $array['createdAt'] = $this->dateToString($createdAt);
     }
     $updatedAt = $object->getUpdatedAt();
     if ($updatedAt) {
         $array['updatedAt'] = $this->dateToString($updatedAt);
     }
     if ($object->getACL()) {
         $array['ACL'] = $object->getACL()->_encode();
     }
     foreach ($array as $key => $value) {
         if ($value instanceof ParseObject) {
             if ($value->getClassName() == $this->parseObject->getClassName() && $value->getObjectId() == $this->parseObject->getObjectId()) {
                 // If a key points to this parent object, we will skip it to avoid
                 // infinite recursion.
             } elseif ($value->isDataAvailable()) {
                 $array[$key] = $this->parseObjectToArray($value);
             }
         } elseif ($value instanceof ParseFile) {
             $array[$key] = $value->_encode();
         }
     }
     return $array;
 }
示例#17
0
文件: init.php 项目: raxjethvaa/HTML
     $updateEmp->set("name", $dataObject['name']);
     $updateEmp->set("primaryColor", $dataObject['primaryColor']);
     $updateEmp->set("secondaryColor", $dataObject['secondaryColor']);
     $updateEmp->set("agencyId", $dataObject['agencyId']);
     $updateEmp->set("loginCode", $dataObject['loginCode']);
     $updateEmp->setArray("logo", $dataObject['logo']);
     $updateEmp->setArray("html_content", $dataObject['html_content']);
     $dataSuccess = $updateEmp->save();
     $returnData = '{"code":1}';
     break;
 case 'addAgency':
     $dataObject = json_decode(file_get_contents("php://input"), true);
     $agency = new ParseObject("Agency");
     $agency->set("name", $dataObject['name']);
     $agency->save();
     $returnData = json_encode(array("success" => true, "objectId" => $agency->getObjectId()));
     break;
 case 'checkLoginCodeUnique':
     $employee = new ParseQuery("Employers");
     $employee->limit(1000);
     $employee->equalTo("loginCode", $_REQUEST['loginCode']);
     $results = $employee->find();
     $returnData = json_encode(array("success" => true, "data" => $results));
     break;
 case "updateDirectly":
     $dataObject = json_decode(file_get_contents("php://input"), true);
     $user = ParseUser::logIn($dataObject['username'], $dataObject['password']);
     $objectId = $user['objectId'];
     $userObject = new ParseObject("_User", $objectId);
     if (isset($dataObject['name']) != "") {
         $userObject->set("name", $dataObject['name']);
示例#18
0
 private function saveUserData($user, $lastName, $firstName, $nationalID)
 {
     $userData = new ParseObject("UserObject");
     $userData->set("lastName", $lastName);
     $userData->set("firstName", $firstName);
     $userData->set("nationalID", $nationalID);
     try {
         $userData->save();
         $user->parseMessage = $userData->getObjectId();
     } 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.
         $user->parseMessage = 'Failed to create new object, with error message: ' . $ex->getMessage();
     }
 }
     // check that again on the server side.
     // Do not use $_FILES["file"]["type"] as it can be easily forged.
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);
     if (in_array($mime, $allowedMINEs) && in_array($extension, $allowedExts)) {
         // Generate new random name.
         $name = sha1(microtime()) . "." . $extension;
         // Save file in the uploads folder.
         move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . '/' . $subFolderPath . '/' . $name);
         $photoImage = new ParseObject(IDP_PHOTO_IMAGE_CLASS_NAME);
         $photoImage->set('path', $subFolderPath . '/' . $name);
         try {
             $photoImage->save();
             // Generate response.
             $response = new StdClass();
             $response->objectID = $photoImage->getObjectId();
             header('Content-type: application/json');
             echo stripslashes(json_encode($response));
         } catch (ParseException $ex) {
             $response = new StdClass();
             $response->errorDescription = "save failue";
             header('Content-type: application/json');
             echo stripslashes(json_encode($response));
         }
     }
     // Ticketを削除
     $ticketObject->destroy();
 } else {
     $response = new StdClass();
     $response->errorDescription = "upload failue";
     header('Content-type: application/json');
示例#20
0
 /**
  * Merge data from other object.
  *
  * @param ParseObject $other
  */
 private function mergeFromObject($other)
 {
     if (!$other) {
         return;
     }
     $this->objectId = $other->getObjectId();
     $this->createdAt = $other->getCreatedAt();
     $this->updatedAt = $other->getUpdatedAt();
     $this->serverData = $other->serverData;
     $this->operationSet = [];
     $this->hasBeenFetched = true;
     $this->rebuildEstimatedData();
 }
示例#21
0
function getABeacon(ParseObject $object)
{
    $beacon = new stdClass();
    $beacon->objectId = $object->getObjectId();
    $beacon->uuid = $object->get('UUID');
    $beacon->beaconColor = $object->get('beaconColor');
    if (count($object->getRelation("brand")->getQuery()->find()) != 0) {
        $beaconBrand = $object->getRelation("brand")->getQuery()->find();
        $beacon->brand = getABrand($beaconBrand[0]);
    } else {
        $beacon->brand = null;
    }
    $beacon->major = $object->get('major');
    $beacon->minor = $object->get('minor');
    $beacon->name = $object->get('name');
    if ($object->get('region') != null) {
        $beaconRegion = $object->get('region')->fetch();
        $beacon->region = getARegion($beaconRegion);
    } else {
        $beacon->region = null;
    }
    $beacon->type = $object->get('type');
    $beacon->createdAt = $object->getCreatedAt();
    $beacon->upadtedAt = $object->getUpdatedAt();
    return $beacon;
}
示例#22
0
                 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
                     echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.<br>";
                 }
             } catch (Exception $e) {
                 echo 'Sorry, there was an error uploading your file. Please send it again.' + $e->getMessage() + '<br>';
             }
     }
     $saving->set("NEWS_IMG", $target_file);
     //if($edit) $savingEdit[0]->set("NEWS_IMG", $target_file);
 }
 if (($_POST["newsTS"] != "" || $_POST["newsTS"] != null) && ($_POST["postTS"] != "" || $_POST["postTS"] != null)) {
     try {
         $savingEdit[0]->save();
         $savingLog->save();
         //$deleteQuery[0]->save();
         echo 'Object creath with objectId: ' . $saving->getObjectId();
         if ($_POST["priority"] == "true") {
             // Notification for Android users
             $queryAndroid = ParseInstallation::query();
             $queryAndroid->equalTo('deviceType', 'android');
             ParsePush::send(array("where" => $queryAndroid, "data" => array("alert" => $topic)));
         }
     } 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 edit object, with error message: ' + $ex->getMessage();
     }
 } else {
     try {
         $saving->save();
         $savingLog->save();
示例#23
0
 public function processGroup(Request $request)
 {
     //if logged process otherwise go to login form
     $current_user = ParseUser::getCurrentUser();
     if (!empty($current_user)) {
         //process form
         $lastAction = $request->session()->get('lastAction');
         $groupName = $request->input('groupname') ?: $request->session()->get('newgroup:groupName');
         $invites = $request->input('invites') ?: $request->session()->get('newgroup:invites');
         $public = $request->input('public') ?: $request->session()->get('newgroup:public');
         $reroute = $request->input('reroute');
         $st = $request->input('st');
         $groupId = $request->input('id');
         if (!empty($groupId)) {
             //does this user have permission to edit group
             $qry = new ParseQuery('Groups');
             $groupObj = $qry->get($groupId);
             if ($groupObj->get('public') !== true) {
                 if ($current_user->getObjectId() != $groupObj->get('user')->getObjectId()) {
                     throw new HttpException(401, 'Sorry you don\'t have permission to edit group');
                 }
             }
         } else {
             $groupObj = new ParseObject('Groups');
         }
         $groupObj->set('name', $groupName);
         $groupObj->set('user', $current_user);
         if ($public == 'y') {
             $groupObj->set('public', true);
         } else {
             $groupObj->set('public', false);
         }
         if (empty($invites)) {
             $invites = [];
         }
         $invites = array_keys(array_flip($invites));
         $prevInvites = $groupObj->get('invites') ?: array();
         $diffInvites = array_diff($invites, $prevInvites);
         $groupObj->setArray('invites', $invites);
         if (empty($groupObj->get('inviteCode'))) {
             $groupObj->set('inviteCode', $this->generate_random_letters(6));
         }
         try {
             $groupObj->save();
             $relation = $groupObj->getRelation('members');
             $relation->add($current_user);
             $groupObj->save();
             //send email
             if (!empty($diffInvites)) {
                 $send = new Mail\Send();
                 $send->sendInviteEmail($diffInvites, $current_user, $groupObj->get('inviteCode'), $groupObj->get('name'));
             }
             if ($reroute == 'newevents') {
                 $url = route('newEvent', ['gid' => $groupObj->getObjectId()]) . '?st=' . $st;
                 return redirect($url);
             } else {
                 return redirect('/groups');
             }
         } 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();
         }
     } else {
         //save form show login
         $request->session()->set('lastAction', 'newgroup');
         $request->session()->set('newgroup:groupName', $request->input('groupname'));
         $request->session()->set('newgroup:invites', $request->input('invites'));
         $request->session()->set('newgroup:public', $request->input('public'));
         return redirect()->route('register');
     }
 }