From 81c8aff7bfb6b8731153a84cea93533910c249da Mon Sep 17 00:00:00 2001 From: Rhilip Date: Sun, 17 Mar 2019 23:19:45 +0800 Subject: [PATCH] fix(View): Fix view function redeclare --- apps/views/common/helper.php | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/apps/views/common/helper.php b/apps/views/common/helper.php index 5fbaacb..554165f 100644 --- a/apps/views/common/helper.php +++ b/apps/views/common/helper.php @@ -10,29 +10,33 @@ * */ -/** - * @param \apps\models\Torrent $torrent - * @return string - */ -function get_torrent_uploader_id(\apps\models\Torrent $torrent) -{ - if ($torrent->getUplver() == 'yes' and app()->user->getClass(true) < app()->config->get('authority.see_anonymous_uploader')) { - return 0; - } else { - return $torrent->getOwnerId(); +if (!function_exists('get_torrent_uploader_id')) { + /** + * @param \apps\models\Torrent $torrent + * @return string + */ + function get_torrent_uploader_id(\apps\models\Torrent $torrent) + { + if ($torrent->getUplver() == 'yes' and app()->user->getClass(true) < app()->config->get('authority.see_anonymous_uploader')) { + return 0; + } else { + return $torrent->getOwnerId(); + } } } -/** - * @param \apps\models\Torrent $torrent - * @return string - */ -function get_torrent_uploader(\apps\models\Torrent $torrent) -{ - $owner_id = get_torrent_uploader_id($torrent); - if ($owner_id == 0) { - return 'Anonymous'; - } else { - return "getOwnerId()}\" data-toggle=\"tooltip\" title=\"User\">{$torrent->getOwner()->getUsername()}"; +if (!function_exists('get_torrent_uploader')) { + /** + * @param \apps\models\Torrent $torrent + * @return string + */ + function get_torrent_uploader(\apps\models\Torrent $torrent) + { + $owner_id = get_torrent_uploader_id($torrent); + if ($owner_id == 0) { + return 'Anonymous'; + } else { + return "getOwnerId()}\" data-toggle=\"tooltip\" title=\"User\">{$torrent->getOwner()->getUsername()}"; + } } }