本文整理匯總了PHP中FilePermissions::tryParse方法的典型用法代碼示例。如果您正苦於以下問題:PHP FilePermissions::tryParse方法的具體用法?PHP FilePermissions::tryParse怎麽用?PHP FilePermissions::tryParse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FilePermissions
的用法示例。
在下文中一共展示了FilePermissions::tryParse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: permission
public function permission()
{
$permission = $this->getRequestParam('permission', NULL);
$password = $this->getRequestParam('password', '');
$file_alias = $this->getRequestParam('file_alias', NULL);
$file_id = $this->getRequestParam('file_id', NULL);
$response = new AjaxResponse();
try {
if ($permission == NULL || !FilePermissions::tryParse($permission)) {
throw new Exception();
}
if ($file_alias != NULL) {
$file = File::find('alias', $file_alias);
} else {
if ($file_id != NULL) {
$file = File::find('_id', $file_id);
} else {
throw new Exception();
}
}
$file->permission = $permission;
$file->password = $password;
$file->save();
$response->success = true;
} catch (InvalidArgumentException $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidParameter');
} catch (InvalidPasswordException $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidPassword');
} catch (NotAuthorisedException $e) {
$response->success = false;
$response->message = System::getLanguage()->_('PermissionDenied');
} catch (Exception $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidParameter');
}
$response->send();
}