Skip to content

Commit 23cfa09

Browse files
committed
media helpers also work with id instead of just media array
1 parent 1dfb7f7 commit 23cfa09

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

classes/core/obfhelpers.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ public static function sendfile($file, $type = null, $download = false)
333333
*/
334334
public static function media_file($media)
335335
{
336+
if (is_string($media)) {
337+
$media = intval($media);
338+
}
339+
340+
if (is_int($media)) {
341+
$models = OBFModels::get_instance();
342+
$media = $models->media('get_by_id', ['id' => $media]);
343+
}
344+
336345
if ($media['is_archived'] == 1) {
337346
$filedir = OB_MEDIA_ARCHIVE;
338347
} elseif ($media['is_approved'] == 0) {
@@ -351,6 +360,15 @@ public static function media_file($media)
351360
*/
352361
public static function preview_media_auth($media)
353362
{
363+
if (is_string($media)) {
364+
$media = intval($media);
365+
}
366+
367+
if (is_int($media)) {
368+
$models = OBFModels::get_instance();
369+
$media = $models->media('get_by_id', ['id' => $media]);
370+
}
371+
354372
$userInstance = OBFUser::get_instance();
355373

356374
// check permissions
@@ -370,6 +388,15 @@ public static function preview_media_auth($media)
370388
*/
371389
public static function download_media_auth($media)
372390
{
391+
if (is_string($media)) {
392+
$media = intval($media);
393+
}
394+
395+
if (is_int($media)) {
396+
$models = OBFModels::get_instance();
397+
$media = $models->media('get_by_id', ['id' => $media]);
398+
}
399+
373400
$userInstance = OBFUser::get_instance();
374401

375402
// check permissions

0 commit comments

Comments
 (0)