Bitrix Site Manager

CSaleAuxiliary::CheckAccess

bool
CSaleAuxiliary::CheckAccess(
 int userID,
 string itemMD5,
 int periodLength,
 string periodType
);

The method CheckAccess checks if the visitor userID can get access to a resource identified by itemMD5. The periodLength of the type periodType define the period of time within which the user is granted access to the resource.

Parameters

ParameterDescription
userID The user ID.
itemMD5 The string that uniquely identifies the resource.
periodLength The period length, within which the user has the access to the resource.
periodType The type of the period length. Possible values:
  • I - minute;
  • H - hour;
  • D - day;
  • W - week;
  • M - month;
  • Q - quarter;
  • S - half year;
  • Y - year.

Return Values

The method returns true if the user can get an access to this resource, or false otherwise.

Example



<?
if (CSaleAuxiliary::CheckAccess($USER->GetID(), "pict.jpg", 2, "D"))
{
    echo '<a href="'.pict.jpg.'">the file is available for download</a>';
}
else
{
    echo "The file is not available for download";
}
?>