From 129b9ce50e56aa5f1dbc3a5b48418d32292ed21f Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:39:22 -0800 Subject: [PATCH 01/24] Updated... --- EnhanceTestFramework.php | 66 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/EnhanceTestFramework.php b/EnhanceTestFramework.php index d83cca6..d5f1b21 100644 --- a/EnhanceTestFramework.php +++ b/EnhanceTestFramework.php @@ -325,6 +325,34 @@ class TextEn public $LineFile = 'Line {0} in file {1}'; } +class TextFr +{ + public $FormatForTestRunTook = 'Le test a prit {0} seconds'; + public $FormatForExpectedButWas = '{0} attendu mais finalement fut {1}'; + public $FormatForExpectedNotButWas = 'Pas {0} attendu mais finalement fut {1}'; + public $FormatForExpectedContainsButWas = 'Présence de {0} attendu mais finalement fut {1}'; + public $FormatForExpectedNotContainsButWas = 'Absence de {0} attendu mais finalement fut {1}'; + public $EnhanceTestFramework = 'Enhance Test Framework'; + public $EnhanceTestFrameworkFull = 'Enhance PHP Framework de Test Unitaire'; + public $TestResults = 'Résultats des tests '; + public $Test = 'Test'; + public $TestPassed = 'Test Réussi'; + public $TestFailed = 'Test Échoué'; + public $Passed = 'Réussi'; + public $Failed = 'Échoué'; + public $ExpectationFailed = 'Les attentes ne furent pas atteintes'; + public $Expected = 'Attendu'; + public $Called = 'Appelé '; + public $InconclusiveOrNotImplemented = 'non conclusif ou pas implémenté'; + public $Times = 'fois'; + public $MethodCoverage = 'Couverture des fonctions'; + public $Copyright = 'Copyright'; + public $ExpectedExceptionNotThrown = 'L\'exception attendu ne fut pas levée'; + public $CannotCallVerifyOnStub = 'impossible d\'appeler VerifyExpectations sur la souche'; + public $ReturnsOrThrowsNotBoth = 'Vous ne pouvez définire qu\une seul valeur de retour(1 returns() ou 1 throws())'; + public $ScenarioWithExpectMismatch = 'Les scenarios doivent être initialisé avec le même nombre d\'appel à "with" et "expect"'; + public $LineFile = 'Ligne {0} dans le fichier {1}'; +} class TextDe { public $FormatForTestRunTook = 'Fertig nach {0} Sekunden'; @@ -411,8 +439,36 @@ class TextSp public $CannotCallVerifyOnStub = 'No se puede llamar VerifyExpectations en un stub'; public $ReturnsOrThrowsNotBoth = 'Debe proporcionar un solo valor de retorno (1 returns() ó 1 throws())'; public $ScenarioWithExpectMismatch = 'Escenario debe ser inicializado con el mismo número de llamadas "with" y "expect" '; - public $LineFile = 'Linha {0} no arquivo {1}'; - public $TypeOfVar=" Tipo: "; + public $LineFile = 'Linha {0} no arquivo {1}'; + public $TypeOfVar=" Tipo: "; +} + +class TextRo{ + public $FormatForTestRunTook = 'Testul a durat {0} secunde'; + public $FormatForExpectedButWas = 'Se aștepta {0} dar a returnat {1}'; + public $FormatForExpectedNotButWas = 'Nu se aștepta {0} dar a returnat {1}'; + public $FormatForExpectedContainsButWas = 'Se aștepta sa conțină {0} dar conține {1}'; + public $FormatForExpectedNotContainsButWas = 'Nu se aștepta sa conțină {0} dar conține {1}'; + public $EnhanceTestFramework = 'Enhance Test Framework'; + public $EnhanceTestFrameworkFull = 'Enhance PHP Unit Testing Framework'; + public $TestResults = 'Rezultate Teste'; + public $Test = 'Test'; + public $TestPassed = 'Testul a fost finalizat cu succes.'; + public $TestFailed = 'Testul a eșuat.'; + public $Passed = 'Succes'; + public $Failed = 'Eșuat.'; + public $ExpectationFailed = 'Așteptare eșuată'; + public $Expected = 'Așteptare'; + public $Called = 'Apelat'; + public $InconclusiveOrNotImplemented = 'Neconcludent sau neimplementat'; + public $Times = 'Ori'; + public $MethodCoverage = 'Învăluire metoda'; + public $Copyright = 'Drepturi de autor'; + public $ExpectedExceptionNotThrown = 'Se aștepta o excepție dar nu a fost afișata'; + public $CannotCallVerifyOnStub = 'Nu a putut fi apelata metoda VerifyExpectations pe un stub'; + public $ReturnsOrThrowsNotBoth = 'Trebuie sa alegi numai o valoare pentru a fi returnata (1 returns() sau 1 throws())'; + public $ScenarioWithExpectMismatch = 'Scenariul trebuie inițializat cu același număr de apelări la metoda "with" sau "expect" '; + public $LineFile = 'Linia {0} in fișierul {1}'; } class EnhanceTestFramework @@ -1730,14 +1786,16 @@ class TemplateType class Language { + const French = "Fr"; const English = 'En'; const Deutsch = 'De'; const BrazilianPortuguese = 'PtBr'; - const Spanish = 'Sp'; + const Spanish = 'Sp'; + const Romana = 'Ro'; } class Localisation { public $Language = Language::English; } -?> \ No newline at end of file +?> From dbfa5c0b5290bd146d2846f104b492e2c2e7398c Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:39:43 -0800 Subject: [PATCH 02/24] include 'parseRole.php' --- parse.php | 1 + 1 file changed, 1 insertion(+) diff --git a/parse.php b/parse.php index 7c2412f..b7bcc57 100644 --- a/parse.php +++ b/parse.php @@ -7,6 +7,7 @@ include 'parsePush.php'; include 'parseGeoPoint.php'; include 'parseACL.php'; +include 'parseRole.php'; class parseRestClient{ From 1d4d42a0a59954f7f858277452e677c6d4631cec Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:40:10 -0800 Subject: [PATCH 03/24] Updated documentation. --- parseACL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parseACL.php b/parseACL.php index cdf7ed5..be3e2a7 100644 --- a/parseACL.php +++ b/parseACL.php @@ -10,7 +10,7 @@ $acl->setReadAccessForId('user_id',true); $acl->setWriteAccessForRole('role_name',true); -$object->ACL($acl); +$object->ACL($acl->acl); $object->save(); */ class parseACL{ From 0538b4644665c61277c0dd9afde657732ca2aa50 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:40:50 -0800 Subject: [PATCH 04/24] Added accessors that don't confuse EnhancedTestingFramework. --- parseObject.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/parseObject.php b/parseObject.php index b6b8f39..3134d1e 100644 --- a/parseObject.php +++ b/parseObject.php @@ -2,7 +2,7 @@ class parseObject extends parseRestClient{ public $_includes = array(); - private $_className = ''; + protected $_className = ''; public function __construct($class=''){ if($class != ''){ @@ -21,6 +21,23 @@ public function __set($name,$value){ } } + public function ACL($acl = null) { + if($acl) + $this->data['ACL'] = $acl; + + return $this->data['ACL']; + } + + public function setProperty($name, $value) { + if($name != '_className'){ + $this->data[$name] = $value; + } + } + + public function getProperty($name) { + return $this->data[$name]; + } + public function save(){ if(count($this->data) > 0 && $this->_className != ''){ $request = $this->request(array( @@ -78,7 +95,7 @@ public function delete($id){ return $request; } } - + public function addInclude($name){ $this->_includes[] = $name; } From 2dfad63ff271a232e21ddd38ac532deb18337008 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:41:31 -0800 Subject: [PATCH 05/24] initial commit --- parseRole.php | 221 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 parseRole.php diff --git a/parseRole.php b/parseRole.php new file mode 100644 index 0000000..327ad6f --- /dev/null +++ b/parseRole.php @@ -0,0 +1,221 @@ +data['name'] = $name; + } else { + $this->throwError('include the roleName when creating a parseRole'); + } + } + + /** + * Cannot change name of a role. + * + * @param type $name + * @param type $value + */ + public function __set($name,$value){ + if($name != '_className' && $name != 'name'){ + $this->data[$name] = $value; + } + } + + /* + $parseObject->users = array( + '__op' => 'AddRelation', + 'objects' => array( + $parseObject->dataType('pointer', array('post','8TOXdXf3tz')) + $parseObject->dataType('pointer', array('post','Ed1nuqPvc')), + ) + ); + */ + + /** + * https://parse.com/docs/rest#roles-updating + * @param type $userIds + */ + public function addUsersToRole($userIds = array()) { + $objects = array(); + foreach ($userIds as $userId) { + $objects[] = $this->dataType('pointer', array('_User', $userId)); + } + $this->setProperty('users', array( + '__op' => 'AddRelation', + 'objects' => $objects + )); + } + + /** + * https://parse.com/docs/rest#roles-updating + * @param type $userIds + */ + public function removeUsersFromRole($userIds = array()) { + $objects = array(); + foreach ($userIds as $userId) { + $objects[] = $this->dataType('pointer', array('_User', $userId)); + } + $this->setProperty('users', array( + '__op' => 'RemoveRelation', + 'objects' => $objects + )); + } + + /** + * https://parse.com/docs/rest#roles-creating + * + * @return type + */ + public function save(){ + if(!$this->data['ACL']) + $this->throwError('Must have ACL with role'); + if(count($this->data) > 0 && $this->_className != ''){ + $request = $this->request(array( + 'method' => 'POST', + 'requestUrl' => $this->_className, + 'data' => $this->data, + )); + return $request; + } + } + + /** + * https://parse.com/docs/rest#roles-retrieving + * @param type $id + * @return type + */ + public function get($id){ + if($this->_className != '' || !empty($id)){ + $request = $this->request(array( + 'method' => 'GET', + 'requestUrl' => $this->_className.'/'.$id + )); + + if(!empty($this->_includes)){ + $request['include'] = implode(',', $this->_includes); + } + + return $request; + } + } + + /** + * https://parse.com/docs/rest#roles-updating + * @param type $id + * @return type + */ + public function update($id){ + if($this->_className != '' || !empty($id)){ + $request = $this->request(array( + 'method' => 'PUT', + 'requestUrl' => $this->_className.'/'.$id, + 'data' => $this->data, + )); + + return $request; + } + } + + /** + * https://parse.com/docs/rest#roles-deleting + * @param type $id + * @return type + */ + public function delete($id){ + if($this->_className != '' || !empty($id)){ + $request = $this->request(array( + 'method' => 'DELETE', + 'requestUrl' => $this->_className.'/'.$id + )); + + return $request; + } + } + + /** + * + * @param type $field + * @param type $amount + */ + public function increment($field,$amount){ + $this->throwError("function increment makes no sense for role."); + } + + /** + * + * @param type $id + */ + public function decrement($id){ + $this->throwError("function decrement makes no sense for role."); + } + + + /** + * curl -X POST \ + -H "X-Parse-Application-Id: Z0GKPdAmkIZsKg9nGgSGU52DQBUP2xavHmACYsAI" \ + -H "X-Parse-REST-API-Key: lOQHg18qhxveTkNA6YGIWDtwBpwQ9ULyK2ZwPqTh" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Moderators", + "ACL": { + "*": { + "read": true + } + } + }' \ + https://api.parse.com/1/roles + */ + + /** + * curl -X POST \ + -H "X-Parse-Application-Id: Z0GKPdAmkIZsKg9nGgSGU52DQBUP2xavHmACYsAI" \ + -H "X-Parse-REST-API-Key: lOQHg18qhxveTkNA6YGIWDtwBpwQ9ULyK2ZwPqTh" \ + -H "Content-Type: application/json" \ + -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \ + https://api.parse.com/1/classes/GameScore + * + */ + + /** + * curl -X PUT \ + -H "X-Parse-Application-Id: Z0GKPdAmkIZsKg9nGgSGU52DQBUP2xavHmACYsAI" \ + -H "X-Parse-REST-API-Key: lOQHg18qhxveTkNA6YGIWDtwBpwQ9ULyK2ZwPqTh" \ + -H "Content-Type: application/json" \ + -d '{"opponents":{"__op":"AddRelation","objects":[{"__type":"Pointer","className":"Player","objectId":"Vx4nudeWn"}]}}' \ + https://api.parse.com/1/classes/GameScore/Ed1nuqPvcm + * + * curl -X PUT \ + -H "X-Parse-Application-Id: Z0GKPdAmkIZsKg9nGgSGU52DQBUP2xavHmACYsAI" \ + -H "X-Parse-Master-Key: F3ywLEYgKT9JzxQKCX6L2UG7Ni6Aq7oIOlZWxVf0" \ + -H "Content-Type: application/json" \ + -d '{ + "users": { + "__op": "AddRelation", + "objects": [ + { + "__type": "Pointer", + "className": "_User", + "objectId": "8TOXdXf3tz" + }, + { + "__type": "Pointer", + "className": "_User", + "objectId": "g7y9tkhB7O" + } + ] + } + }' \ + https://api.parse.com/1/roles/mrmBZvsErB + */ +} + +?> From 1833ba98bfe59cd8d285654193cf4c7307f591a5 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 13:41:41 -0800 Subject: [PATCH 06/24] initial commit. --- tests/parseRoleTest.php | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/parseRoleTest.php diff --git a/tests/parseRoleTest.php b/tests/parseRoleTest.php new file mode 100644 index 0000000..7e92ee8 --- /dev/null +++ b/tests/parseRoleTest.php @@ -0,0 +1,88 @@ +parseRole = \Enhance\Core::getCodeCoverageWrapper('parseRole', array('TestRole')); + $this->parseUser = new parseUser(); + $this->testUser = array( + 'username' => 'testUser'.rand(), + 'password' => 'testPass', + 'email' => 'testUser@parse.com', + 'customField' => 'customValue' + ); + + } + + public function testCreateRole(){ + $parseRole = $this->parseRole; + $parseACL = new parseACL(); + $parseACL->setPublicReadAccess(true); + $parseACL->setPublicWriteAccess(false); + $parseACL->setWriteAccessForRole('Administrator', true); + + $parseRole->ACL( $parseACL->acl ); + try { + $return = $parseRole->save(); + } catch (ParseLibraryException $e) { + throw $e; + } + \Enhance\Assert::isTrue( is_object($return) ); + \Enhance\Assert::isNotNull($return->objectId); + $parseRole->setProperty('objectId', $return->objectId); + + $parseRole2 = $parseRole; + $return = $parseRole2->get($parseRole2->getProperty('objectId')); + \Enhance\Assert::isObject($return); + + $return = $parseRole2->delete($parseRole2->getProperty('objectId')); + } + + public function testAddAndRemoveRoleForUser() { + $parseUser = $this->parseUser; + $retUser = $parseUser->signup($this->testUser['username'], $this->testUser['password']); + + // Recreate role + $parseRole = $this->parseRole; + $parseACL = new parseACL(); + $parseACL->setPublicReadAccess(true); + $parseACL->setPublicWriteAccess(false); + $parseACL->setWriteAccessForRole('Administrator', true); + + $parseRole->ACL( $parseACL->acl ); + try { + $return = $parseRole->save(); + $objectId = $return->objectId; + } catch (ParseLibraryException $e) { + throw $e; + } + + $parseRole2 = new parseRole('TestRole'); + $parseRole2->addUsersToRole(array($retUser->objectId)); + $return = $parseRole2->update($objectId); + \Enhance\Assert::isObject($return); + \Enhance\Assert::isNotNull($return->updatedAt); + + $parseRole2->removeUsersFromRole(array($retUser->objectId)); + $return2 = $parseRole2->update($objectId); + \Enhance\Assert::isObject($return2); + \Enhance\Assert::isNotNull($return2->updatedAt); + + } +} + +// Run the tests +\Enhance\Core::runTests(); + +?> From 154b8b91624784e8c5437ea05327721dc19450d9 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 16:51:16 -0800 Subject: [PATCH 07/24] Move config variables into public static. --- parse.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/parse.php b/parse.php index b7bcc57..ed28ffe 100644 --- a/parse.php +++ b/parse.php @@ -1,5 +1,4 @@ _appid = $parseConfig::APPID; - $this->_masterkey = $parseConfig::MASTERKEY; - $this->_restkey = $parseConfig::RESTKEY; - $this->_parseurl = $parseConfig::PARSEURL; + $this->_appid = parseRestClient::$APPID; + $this->_masterkey = parseRestClient::$MASTERKEY; + $this->_restkey = parseRestClient::$RESTKEY; + $this->_parseurl = parseRestClient::$PARSEURL; if(empty($this->_appid) || empty($this->_restkey) || empty($this->_masterkey)){ $this->throwError('You must set your Application ID, Master Key and REST API Key'); From 02ad98bfbff3425abf44bfba67472a912b30fb4c Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 19:30:35 -0800 Subject: [PATCH 08/24] Added relational queries. --- parseQuery.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/parseQuery.php b/parseQuery.php index bdff105..8d4595d 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -45,7 +45,8 @@ public function find(){ if($this->_count == 1){ $urlParams['count'] = '1'; } - + print_r($this->_requestUrl); + print_r($urlParams); $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl, @@ -250,7 +251,28 @@ public function wherePointer($key,$className,$objectId){ } } - + + /** + * Example - to find users with a particular role id + * $query->whereRelatedTo('users', '_Role', $roleId); + * + * @param type $key + * @param type $className + * @param type $objectId + */ + public function whereRelatedTo($key,$className,$objectId) { + if(isset($key) && isset($className) && isset($objectId)){ + if($className === 'Role') + $className = '_Role'; + if($className === 'User') + $className = '_User'; + $pointer = $this->dataType('pointer', array($className, $objectId)); + $this->_query['$relatedTo'] = $this->dataType('relatedTo', array($pointer, $key)); + } else { + $this->throwError('the $key and $classname and $objectId parameters must be set when setting a "whereRelatedTo" query method'); + } + } + public function whereInQuery($key,$className,$inQuery){ if(isset($key) && isset($className)){ $this->_query[$key] = array( From f033e7b25c6cc30118307aa07640c9429de6faa9 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 19:38:03 -0800 Subject: [PATCH 09/24] added dataType 'relatedTo' --- parse.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parse.php b/parse.php index ed28ffe..1a82bc0 100644 --- a/parse.php +++ b/parse.php @@ -134,6 +134,12 @@ public function dataType($type,$params){ "objectId" => $params[1] ); break; + case 'relatedTo': + $return = array( + "object" => $params[0], // pointer + "key" => $params[1] // key + ); + break; case 'geopoint': $return = array( "__type" => "GeoPoint", From bf852415e040885493ff32f84661b7f6f0b0a08a Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 19:58:13 -0800 Subject: [PATCH 10/24] added query to see if user is of a certain role. --- tests/parseRoleTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/parseRoleTest.php b/tests/parseRoleTest.php index 7e92ee8..6a1f8ed 100644 --- a/tests/parseRoleTest.php +++ b/tests/parseRoleTest.php @@ -14,6 +14,10 @@ class parseRoleTest extends \Enhance\TestFixture { public $testUser; public function setUp(){ + parseRestClient::$APPID = '22cASrmG1cWQ8LuV1kNRWjQjjpjf2rA9neNZMlLj'; // test app + parseRestClient::$MASTERKEY = 'WDXgAfDXybXJpswDacf5M4QzKT22Uxov85D12A8M'; + parseRestClient::$RESTKEY = '6tKoG4XataK6FUKJEOdxjy4xAo9J4taNit0BnMfH'; + parseRestClient::$PARSEURL = 'https://api.parse.com/1/'; $this->parseRole = \Enhance\Core::getCodeCoverageWrapper('parseRole', array('TestRole')); $this->parseUser = new parseUser(); $this->testUser = array( @@ -74,11 +78,19 @@ public function testAddAndRemoveRoleForUser() { \Enhance\Assert::isObject($return); \Enhance\Assert::isNotNull($return->updatedAt); + // Query parse role + $query = new parseQuery('users'); + $query->whereRelatedTo('users', 'Role', $objectId); + $ret = $query->find(); + \Enhance\Assert::isArray($ret); + \Enhance\Assert::isTrue(count($ret) == 1); + $parseRole2->removeUsersFromRole(array($retUser->objectId)); $return2 = $parseRole2->update($objectId); \Enhance\Assert::isObject($return2); \Enhance\Assert::isNotNull($return2->updatedAt); - + + $parseRole2->delete($objectId); } } From 48d245552561735a74f436d90bc435589bbe468b Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 20:04:33 -0800 Subject: [PATCH 11/24] Fix so that you can query 'roles' --- parseQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parseQuery.php b/parseQuery.php index 8d4595d..993c4ef 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -9,7 +9,7 @@ class parseQuery extends parseRestClient{ private $_include = array(); public function __construct($class=''){ - if($class == 'users'){ + if($class == 'users' || $class == 'roles'){ $this->_requestUrl = $class; } elseif($class != ''){ From 948bdb4991e3632c9d69f08c1e32d8324fe42324 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 20:33:34 -0800 Subject: [PATCH 12/24] got rid of print_r --- parseQuery.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/parseQuery.php b/parseQuery.php index 993c4ef..42543b8 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -45,8 +45,6 @@ public function find(){ if($this->_count == 1){ $urlParams['count'] = '1'; } - print_r($this->_requestUrl); - print_r($urlParams); $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl, @@ -300,4 +298,4 @@ public function whereNotInQuery($key,$className,$inQuery){ } } -?> \ No newline at end of file +?> From 822a95b9410baa332e716ece8571650a06f06a9e Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 20:51:44 -0800 Subject: [PATCH 13/24] added includes --- parseUser.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/parseUser.php b/parseUser.php index f78a330..6907335 100644 --- a/parseUser.php +++ b/parseUser.php @@ -1,7 +1,7 @@ 'GET', 'requestUrl' => 'users/'.$objectId, )); + if(!empty($this->_includes)){ + $request['include'] = implode(',', $this->_includes); + } return $request; @@ -146,7 +149,11 @@ public function unlinkAccount($objectId,$sessionToken,$type){ } } - + + public function addInclude($name){ + $this->_includes[] = $name; + } + } ?> \ No newline at end of file From 5540916895e445753232e96e89df3e71a2f6f43e Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 13 Dec 2012 21:12:38 -0800 Subject: [PATCH 14/24] fixed includes --- parseUser.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parseUser.php b/parseUser.php index 6907335..4060e8c 100644 --- a/parseUser.php +++ b/parseUser.php @@ -51,14 +51,15 @@ public function login(){ } public function get($objectId){ + if(!empty($this->_includes)){ + $request['include'] = implode(',', $this->_includes); + } + if($objectId != ''){ $request = $this->request(array( 'method' => 'GET', 'requestUrl' => 'users/'.$objectId, )); - if(!empty($this->_includes)){ - $request['include'] = implode(',', $this->_includes); - } return $request; From c9db3d9b8a47a8ad1d78f313440f7445dba786e5 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Sat, 15 Dec 2012 03:06:43 -0800 Subject: [PATCH 15/24] Added ACL method --- parseUser.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/parseUser.php b/parseUser.php index 4060e8c..f7deb54 100644 --- a/parseUser.php +++ b/parseUser.php @@ -155,6 +155,13 @@ public function addInclude($name){ $this->_includes[] = $name; } + public function ACL($acl = null) { + if($acl) + $this->data['ACL'] = $acl; + + return $this->data['ACL']; + } + } ?> \ No newline at end of file From 639a8294c984c505c932a45b2c4353fc00a1cc82 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Wed, 19 Dec 2012 19:40:47 -0800 Subject: [PATCH 16/24] Add date specific greaterThan lessThan --- parseQuery.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/parseQuery.php b/parseQuery.php index 42543b8..60254fa 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -141,6 +141,30 @@ public function whereGreaterThan($key,$value){ } + public function whereGreaterThanDate($key,$date){ + if(isset($key) && isset($date)){ + $this->_query[$key] = array( + '$gt' => $this->dataType('date', $date) + ); + } + else{ + $this->throwError('the $key and $value parameters must be set when setting a "where" query method'); + } + + } + + public function whereLessThanDate($key,$date){ + if(isset($key) && isset($date)){ + $this->_query[$key] = array( + '$gt' => $this->dataType('date', $date) + ); + } + else{ + $this->throwError('the $key and $value parameters must be set when setting a "where" query method'); + } + + } + public function whereLessThan($key,$value){ if(isset($key) && isset($value)){ $this->_query[$key] = array( From 2c198cc12825a97a2b736b4f31d30747928e8ba4 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Sat, 22 Dec 2012 13:59:44 -0800 Subject: [PATCH 17/24] ignore nbproject --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a17df00..4fa40ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ parseConfig.php +/nbproject/private/ \ No newline at end of file From 534db1d20d563a16676304cd60442cf53a63935a Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Sat, 22 Dec 2012 13:59:59 -0800 Subject: [PATCH 18/24] Don't delete old ACL when adding access controls. --- parseACL.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/parseACL.php b/parseACL.php index be3e2a7..bbe8802 100644 --- a/parseACL.php +++ b/parseACL.php @@ -20,14 +20,13 @@ public function __construct(){ } private function setAccessForKey($access,$key,$bool){ if(!($access == 'read' || $access == 'write')) return; - if(is_object($this->acl)) $this->acl = array(); - if($bool) $this->acl[$key][$access] = true; + if($bool) $this->acl->$key->$access = true; else { - if(isset($this->acl[$key])){ - unset($this->acl[$key][$access]); - if(sizeof($this->acl[$key]) == 0) unset($this->acl[$key]); + if(isset($this->acl->$key)){ + unset($this->acl->$key->$access); + if(sizeof((array)$this->acl->$key) == 0) unset($this->acl->$key); } - if(sizeof($this->acl) == 0) $this->acl = new stdClass(); + if(sizeof((array)$this->acl) == 0) $this->acl = new stdClass(); } } public function setPublicReadAccess($bool){ From 3738327db30f866912e6f86c58f9ff15ab966c76 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 11 Jul 2013 19:17:14 -0700 Subject: [PATCH 19/24] Fix -gt --- parseQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parseQuery.php b/parseQuery.php index 60254fa..49a11d6 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -156,7 +156,7 @@ public function whereGreaterThanDate($key,$date){ public function whereLessThanDate($key,$date){ if(isset($key) && isset($date)){ $this->_query[$key] = array( - '$gt' => $this->dataType('date', $date) + '$lt' => $this->dataType('date', $date) ); } else{ From e1f5ce0e4538079ef454104d2fd40186db779d53 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 11 Jul 2013 19:17:25 -0700 Subject: [PATCH 20/24] added clasname --- parseObject.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parseObject.php b/parseObject.php index 3134d1e..65f9cfe 100644 --- a/parseObject.php +++ b/parseObject.php @@ -21,6 +21,10 @@ public function __set($name,$value){ } } + public function setClassName($className) { + $this->_className = $className; + } + public function ACL($acl = null) { if($acl) $this->data['ACL'] = $acl; From 858962cd491b4643805f0e5d84ecdc333fdb39bb Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 11 Jul 2013 21:55:10 -0700 Subject: [PATCH 21/24] Fixed syntax error. --- parseUser.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/parseUser.php b/parseUser.php index 3d7528c..7ee8203 100644 --- a/parseUser.php +++ b/parseUser.php @@ -50,21 +50,21 @@ public function login(){ } -public function socialLogin(){ - if(!empty($this->authData)){ - $request = $this->request( array( - 'method' => 'POST', - 'requestUrl' => 'users', - 'data' => array( - 'authData' => $this->authData - ) - )); - return $request; - } - else{ - $this->throwError('authArray must be set use addAuthData method'); + public function socialLogin(){ + if(!empty($this->authData)){ + $request = $this->request( array( + 'method' => 'POST', + 'requestUrl' => 'users', + 'data' => array( + 'authData' => $this->authData + ) + )); + return $request; + } + else{ + $this->throwError('authArray must be set use addAuthData method'); + } } -} public function get($objectId){ if(!empty($this->_includes)){ @@ -180,7 +180,7 @@ public function ACL($acl = null) { public function requestPasswordReset($email){ if(!empty($email)){ - $this->email - $email; + $this->email = $email; $request = $this->request(array( 'method' => 'POST', 'requestUrl' => 'requestPasswordReset', @@ -194,7 +194,7 @@ public function requestPasswordReset($email){ $this->throwError('email is required for the requestPasswordReset method'); } -} + } ?> \ No newline at end of file From abeebf013ac594deda68d3fa3984e78fb17a4619 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Thu, 11 Jul 2013 23:59:50 -0700 Subject: [PATCH 22/24] Fixed error of assignment when supposed to be test --- parseQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parseQuery.php b/parseQuery.php index 26c8d98..3b008e9 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -9,7 +9,7 @@ class parseQuery extends parseRestClient{ private $_include = array(); public function __construct($class=''){ - if($class == 'users' || $class == 'roles' || $class = 'installation'){ + if($class == 'users' || $class == 'roles' || $class == 'installation'){ $this->_requestUrl = $class; } elseif($class != ''){ From 825799d5987d5ddd3a2056436b4fa6c74d018ff3 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Fri, 12 Jul 2013 00:00:24 -0700 Subject: [PATCH 23/24] Fixed config --- parse.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/parse.php b/parse.php index 7352312..6bfc3b2 100644 --- a/parse.php +++ b/parse.php @@ -10,11 +10,7 @@ include 'parseCloud.php'; class parseRestClient{ - public static $APPID; - public static $MASTERKEY; - public static $RESTKEY; - public static $PARSEURL; - + private $_appid = ''; private $_masterkey = ''; private $_restkey = ''; @@ -25,10 +21,11 @@ class parseRestClient{ public $returnData = ''; public function __construct(){ - $this->_appid = parseRestClient::$APPID; - $this->_masterkey = parseRestClient::$MASTERKEY; - $this->_restkey = parseRestClient::$RESTKEY; - $this->_parseurl = parseRestClient::$PARSEURL; + $parseConfig = new parseConfig; + $this->_appid = $parseConfig::APPID; + $this->_masterkey = $parseConfig::MASTERKEY; + $this->_restkey = $parseConfig::RESTKEY; + $this->_parseurl = $parseConfig::PARSEURL; if(empty($this->_appid) || empty($this->_restkey) || empty($this->_masterkey)){ $this->throwError('You must set your Application ID, Master Key and REST API Key'); From d7b4445a5b06f81d3ad644ae5f13b6e9c05d9000 Mon Sep 17 00:00:00 2001 From: jobiwankanobi Date: Fri, 12 Jul 2013 00:00:42 -0700 Subject: [PATCH 24/24] Fixed missing bracket --- parseUser.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/parseUser.php b/parseUser.php index 7ee8203..539e2c5 100644 --- a/parseUser.php +++ b/parseUser.php @@ -195,6 +195,5 @@ public function requestPasswordReset($email){ } } - - -?> \ No newline at end of file +} +?>