Documentation

CanUserOperateDocument

bool
public static function CBPDocument::CanUserOperateDocument(
 int operation,
 int userId,
 array documentId,
 array arParameters = array()
);

This method verifies if a user can perform the specified operation with a document. Verification is performed by addressing the document entity.

Note: Method accepts an array of configuration parameters and generates scripts, required to show file dialog. Static method.

arParametersAssociative array of auxiliary parameters. It is used to avoid recalculation of the computed values, which are already known at the moment of method call. Standard keys for the DocumentStates array - workflows statuses array for this document, WorkflowId - workflow ID code (if required, operation must be checked on one of workflows). The array can be supplemented by other arbitrary keys.

Method parameters

ParameterDescription
operationOperation from CBPCanUserOperateOperation
userIdUser ID code
documentIdDocument ID code as an array(module, document_class, document_code_in_module)
arParametersAssociative array of auxiliary parameters. It is used to avoid recalculation of the computed values, which are already known at the moment of method call. Keys for the DocumentStates array - workflows statuses array for this document, are deemed as standard, WorkflowId - workflow ID code (if required, operation must be checked on one of workflows). Array can be supplemented by other arbitrary keys.

Returned value

Returns "true", if the user has the right to complete the specified operation. Otherwise, returns "false".

See Also

Example

<?
$bCanAccess = CBPDocument::CanUserOperateDocument(
CBPCanUserOperateOperation::CreateWorkflow,
$GLOBALS["USER"]->GetID(),
$documentId,
array("UserGroups" => $arUserGroups)
);
if (!$bCanAccess)
die("Access denied");
?>


© «Bitrix24», 2001-2024
Up