mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Enh: Added File::findByRecord for searching all attached files of a given ActiveRecord
This commit is contained in:
parent
008f751e3b
commit
78aeb563d6
@ -3,6 +3,8 @@ HumHub Change Log
|
||||
|
||||
1.2.0-beta.3 under developement
|
||||
--------------------------------
|
||||
- Enh: Added File::findByRecord for searching all attached files of a given ActiveRecord
|
||||
- Fix: Only set js view state for non full page load and pjax
|
||||
- Fix: Small gap on TopNav mouse hover (acs-ferreira)
|
||||
- Enh: Humand readable file sizes. (acs-ferreira)
|
||||
- Enh: Changed default $minInput of SpacePickerField to 2. (githubjeka)
|
||||
|
@ -136,12 +136,13 @@ class File extends FileCompat
|
||||
/**
|
||||
* Checks if given file can deleted.
|
||||
*
|
||||
* If the file is not an instance of HActiveRecordContent or HActiveRecordContentAddon
|
||||
* If the file is not an instance of ContentActiveRecord or ContentAddonActiveRecord
|
||||
* the file is readable for all unless there is method canWrite or canDelete implemented.
|
||||
*/
|
||||
public function canDelete($userId = "")
|
||||
{
|
||||
$object = $this->getPolymorphicRelation();
|
||||
|
||||
if ($object != null) {
|
||||
if ($object instanceof ContentAddonActiveRecord) {
|
||||
return $object->canWrite($userId);
|
||||
@ -186,5 +187,16 @@ class File extends FileCompat
|
||||
|
||||
return $this->_store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all attached Files of the given $record.
|
||||
*
|
||||
* @param \yii\db\ActiveRecord $record
|
||||
* @return File[]
|
||||
*/
|
||||
public static function findByRecord(\yii\db\ActiveRecord $record)
|
||||
{
|
||||
return self::findAll(['object_model' => $record->className(), 'object_id' => $record->getPrimaryKey()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user