/** * determines if a globalID has access priviledges for a specific resource * * @param $gid the GlobalID of the user accessing the content * @param $uoid UOID of the resource being accessed * * @return boolean */ public function hasContentAccessPriviledges($gid, $uoid) { if (!UOID::isValid($uoid) && $uoid) { throw new AccessControlManagerException('Illegal argument UOID: ' . $uoid); } try { $rules = $this->loadAccessControlRulesForUOID($gid, $uoid); return $this->executeAccessControlRules($gid, $rules); } catch (AccessControlManagerException $e) { if ($this->baseDirectiveInterface == AccessControlManager::DIRECTIVE_DENY) { return false; } else { return true; } } }
public static function performPOSTLikeRequest($targetedGID, $likedContentID) { // create an instance of PersonRequestBuilder $likeRequest = new LikeRequestBuilder($targetedGID); // create the LIKE object for the content to be liked $likeObject = (new LikeObjectBuilder())->objectID(UOID::createUOID())->targetID($likedContentID)->author(Sonic::getUserGlobalID())->build(); // perform the request $response = $likeRequest->createGETLike($likeObject)->dispatch(); // to access contents of the response, use // $response->getPayload(); <-- the actual object data // $response->getResponseBody(); <-- the complete response body if ($response->getResponseStatusCode() != 200) { // in case the request returned something else thatn a 200 throw new \Exception('Request failed with status code ' . $response->getResponseStatusCode()); } else { // request was performed successfully return true; } }