本文整理汇总了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();
}