Enh: Added optional ActiveRecordContent::canEdit() method for custom ACLs

This commit is contained in:
Lucas Bartholemy 2017-03-09 22:36:28 +01:00
parent 1b3d389ace
commit 6aff307f3f
3 changed files with 10 additions and 3 deletions

View File

@ -21,6 +21,7 @@ HumHub Change Log
- Enh: Added User module 'displayNameCallback' attribute for custom display name formats
- Enh: Added Clipboard.js and Permalink "Copy to clipboard" link
- Enh: Validate minimum PHP version in Console Application
- Enh: Added optional ActiveRecordContent::canEdit() method for custom ACLs
1.2.0-beta.2 (February 24, 2017)
--------------------------------

View File

@ -179,7 +179,7 @@ class Content extends ContentDeprecated
\humhub\modules\content\activities\ContentCreated::instance()
->about($contentSource)->save();
Yii::$app->live->send(new \humhub\modules\content\live\NewContent([
'sguid' => ($this->container instanceof Space) ? $this->container->guid : null,
@ -432,7 +432,7 @@ class Content extends ContentDeprecated
return true;
}
if ($this->getContainer()->permissionManager->can(new ManageContent())) {
if ($this->getContainer() !== null && $this->getContainer()->permissionManager->can(new ManageContent())) {
return true;
}
@ -441,6 +441,12 @@ class Content extends ContentDeprecated
return true;
}
// Check if underlying content implements own canEdit method
// ToDo: Implement this as interface
if (method_exists($this->getPolymorphicRelation(), 'canEdit') && $this->getPolymorphicRelation()->canEdit($user)) {
return true;
}
return false;
}

View File

@ -36,7 +36,7 @@ class DownloadFileHandler extends BaseFileHandler
'target' => '_blank',
];
}
public static function getUrl($file, $download = 0)
{
return Url::to(['/file/file/download', 'guid' => $file->guid, 'download' => $download]);