コード例 #1
0
function queryUsersWithQueryExpectResultsKey()
{
    $userQuery = new parseQuery('users');
    $userQuery->whereExists('type');
    $return = $userQuery->find();
    return $return;
}
コード例 #2
0
 public function queryUsersWithQueryExpectResultsKey()
 {
     $parseUser = $this->parseUser;
     $userQuery = new parseQuery('users');
     $userQuery->whereExists('phone');
     $return = $userQuery->find();
     \Enhance\Assert::isTrue(property_exists($return, 'results'));
 }
コード例 #3
0
 function wp_parse_api_sync()
 {
     $numberposts = 10;
     $_GET['wp-parse-api-page'] = (int) $_GET['wp-parse-api-page'];
     if ($_GET['wp-parse-api-page'] < 1) {
         $_GET['wp-parse-api-page'] = 1;
     }
     $options = array('numberposts' => $numberposts, 'offset' => $_GET['wp-parse-api-page'] * $numberposts - $numberposts);
     $wp_posts = get_posts($options);
     if (count($wp_posts) == 0) {
         wp_redirect('options-general.php?page=wp-parse-api-options');
         exit;
     }
     foreach ($wp_posts as $wp) {
         if ($wp->post_status != 'publish') {
             continue;
         }
         $post = WpParseApiHelpers::postToObject($wp->ID);
         $q = new parseQuery(WP_PARSE_API_OBJECT_NAME);
         $q->whereEqualTo('wpId', $wp->ID);
         $q->setLimit(1);
         $result = $q->find();
         if ($result->results[0]) {
             $post->update($result->results[0]->objectId);
         } else {
             $post->save();
         }
     }
     ++$_GET['wp-parse-api-page'];
     $url = $_SERVER['PHP_SELF'];
     foreach ($_GET as $k => $v) {
         $qs = strpos($url, '?') === false ? '?' : '&';
         $url .= sprintf("%s%s=%s", $qs, $k, $v);
     }
     //wp_redirect( $url );
     echo "Page:" . ($_GET['wp-parse-api-page'] - 1) . "<script> setTimeout(\"document.location='{$url}'\", 1000); </script>";
     exit;
 }
コード例 #4
0
ファイル: wp-parse-api.php プロジェクト: 76parse/wp-parse-api
 /**
  * Create/Update the post on parse.com
  *
  */
 public function save_post($post_id)
 {
     WpParseApiHelpers::log("WpParseApi::save_post({$post_id}) | START");
     // Verify post is a revision
     if (wp_is_post_revision($post_id)) {
         return;
     }
     // Check if the parse api app id is defined
     if (!defined('WP_PARSE_API_APP_ID') || WP_PARSE_API_APP_ID == null) {
         return;
     }
     WpParseApiHelpers::log("WpParseApi::save_post({$post_id}) | WP_PARSE_API_APP_ID passed");
     // Verify post is an autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     WpParseApiHelpers::log("WpParseApi::save_post({$post_id}) | DOING_AUTOSAVE passed");
     // Verify post nonce
     // if (!wp_verify_nonce( $_POST[ $this->option_name . '_nonce' ], $this->action)) return;
     // WpParseApiHelpers::log("WpParseApi::save_post($post_id) | nonce passed");
     // Verify post status
     if (get_post_status($post_id) != 'publish') {
         return;
     }
     WpParseApiHelpers::log("WpParseApi::save_post({$post_id}) | status passed");
     $post = WpParseApiHelpers::postToObject($post_id);
     // Creates a new post on parse.com
     if (!get_post_meta($post_id, 'wp_parse_api_code_run', true)) {
         update_post_meta($post_id, 'wp_parse_api_code_run', true);
         $categories = array();
         foreach ($post->data['categories'] as $row) {
             $row = trim(preg_replace('/[^a-zA-Z]/', '', $row));
             if ($row != '') {
                 $categories[] = $row;
             }
         }
         // Check if there is no categories or push notifications are disabled
         if (is_array($categories) && count($categories) > 0 && get_option('app_push_notifications') != 'Off') {
             try {
                 $push = new parsePush();
                 $push->alert = $post->data['title'];
                 $push->channels = $categories;
                 $push->badge = "increment";
                 $push->sound = "example.caf";
                 $push->post_id = $post->data[wpId];
                 $push->url = $post->data['guid'];
                 $push->category = "ACTIONABLE";
                 $push->send();
             } catch (Exception $e) {
                 // do nothing, this was added because
                 // parse lib throws an exception if the account
                 // has not been configured
                 // special thanks to raymondmuller for find the issue
             }
         }
         $post->save();
         // Update an existin post on parse.com
     } else {
         $q = new parseQuery(WP_PARSE_API_OBJECT_NAME);
         $q->where('wpId', (int) $post_id);
         $r = $q->find();
         if (is_array($r->results)) {
             $r = array_shift($r->results);
         }
         if ($r != null) {
             $post->update($r->objectId);
         }
     }
     WpParseApiHelpers::log("WpParseApi::save_post({$post_id}) | END");
 }
コード例 #5
0
<?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();
$doubtsQuery = new parseQuery("Doubt");
$doubtsQuery->equalTo("User", $currentUser);
$doubtsQuery->equalTo("Seen", 0);
$doubtsQuery->ascending("createdAt");
$doubts = $doubtsQuery->find();
$nrDoubts = count($doubts);
if ($currentUser) {
    $leftPagesLink = [""];
    $leftPages = [$currentUser->get("name")];
    $rightPagesLink = ["profile.php", "courses.php", "doubts.php", "settings.php", "logout.php"];
    $rightPages = ["Home", "Cursos", "<p class='badge badge-notify'>{$nrDoubts}</p> Dúvidas", "Definições", "Terminar Sessão"];
} else {
    $leftPagesLink = [];
    $leftPages = [];
    $rightPagesLink = ["register.php", "login.php"];
    $rightPages = ["Criar Conta", "Iniciar Sessão"];
}