zimbra-api / soap-api

Zimbra SOAP client in PHP language
BSD 3-Clause "New" or "Revised" License
62 stars 48 forks source link

grantRight #13

Closed kidandcat closed 7 years ago

kidandcat commented 7 years ago

Could I get an example of grantRight?, I can't see how to use it:

$createAccountRight = new RightModifierInfo('createAccount');
$grantee = new GranteeSelector(accountIdByName('testuser'));
$type = new TargetType('domain');
$target = new EffectiveRightsTargetSelector($type, 'zimbra-1.telcom');
$api->grantRight($target, $grantee, $createAccountRight);

new TargetType does not have construct, so extended Base constructor is protected and it gives an error.

kidandcat commented 7 years ago

Ok, got it:

$createAccountRight = new RightModifierInfo ( 'createAccount' );
    $grantee = new GranteeSelector ();
    $granteeType = new GranteeType ();
    $granteeType->value ( 'testuser' );
    $grantee->setBy ( $granteeType );
    $type = new TargetType ( 'domain' );

    $targetby = new TargetBy ( 'name' );
    $targetby->value ( 'zimbra-1.telcom' );

    $target = new EffectiveRightsTargetSelector ( $type, $targetby );
    $api->grantRight ( $target, $grantee, $createAccountRight );