Exemple #1
0
     $user->primary_email = $email;
     $user->alerts_eanbled = false;
     $user->news_eanbled = false;
     //Creating of new user. $clientId - user id, $firstName - entered first name, $user - object with new user info
     $newUser = $mgmtApi->UpdateAccountUser($clientId, $email, $user);
     //Check the result of the request
     if ($newUser->status == "Ok") {
         //Get user GUID
         $userGuid = $newUser->result->guid;
     } else {
         //Throw error message
         throw new Exception($newUser->error_message);
     }
 }
 //Get all collaborators for current document
 $getCollaborators = $antApi->GetAnnotationCollaborators($clientId, $fileId);
 if ($getCollaborators->status == "Ok") {
     //Loop for checking all collaborators
     for ($n = 0; $n < count($getCollaborators->result->collaborators); $n++) {
         //Check is user with entered email already in collaborators
         if ($getCollaborators->result->collaborators[$n]->guid == $userGuid) {
             //Add user GUID as "uid" parameter to the iframe URL
             $url = $url . "?uid=" . $userGuid;
             //Sign iframe URL
             $url = $signer->signUrl($url);
             break;
         }
     }
     //Check whether user was founded in collaborators list
     if (strpos($url, "?uid=")) {
         //If was set variable with URL for iframe
$json = file_get_contents("php://input");
//path to settings file - temporary save userId and apiKey like to property file
//Decode json with raw data to array
$callBack_data = json_decode($json, true);
$serializedData = json_decode($callBack_data['SerializedData'], true);
$documentGuid = $serializedData['DocumentGuid'];
$collaboratorGuid = $serializedData['UserGuid'];
if ($documentGuid != "" && $collaboratorGuid != '') {
    //Create signer object
    $signer = new GroupDocsRequestSigner(trim($privateKey));
    //Create apiClient object
    $apiClient = new APIClient($signer);
    //Create AsyncApi object
    $antApi = new AntApi($apiClient);
    //Get all collaborators for current document
    $getCollaborators = $antApi->GetAnnotationCollaborators($clientId, $documentGuid);
    if ($getCollaborators->status == "Ok") {
        //Create ReviewerInfo array
        $reviewer = new ReviewerInfo();
        //Loop for checking all collaborators
        for ($n = 0; $n < count($getCollaborators->result->collaborators); $n++) {
            //Set reviewer rights to view only
            if ($getCollaborators->result->collaborators[$n]->guid == $collaboratorGuid) {
                //Add riviewer to ReviewerInfo array
                $reviewer->id = $getCollaborators->result->collaborators[$n]->id;
                $reviewer->access_rights = 1;
                $reviewer = array($reviewer);
            }
        }
        $setReviewer = $antApi->SetReviewerRights($clientId, $documentGuid, $reviewer);
    }