-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpublic-userphoto.php
175 lines (149 loc) · 7.03 KB
/
public-userphoto.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* ExtGallery User area
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @author Zoullou (http://www.zoullou.net)
* @package ExtGallery
*/
use Xmf\Request;
use XoopsModules\Extgallery;
require_once __DIR__ . '/header.php';
//require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
$GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-userphoto.tpl';
require_once XOOPS_ROOT_PATH . '/header.php';
/** @var Extgallery\Helper $helper */
$helper = Extgallery\Helper::getInstance();
$photoId = \Xmf\Request::getInt('photoId', 0, 'GET');
/** @var Extgallery\CategoryHandler $catHandler */
$catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');
/** @var Extgallery\PublicPhotoHandler $photoHandler */
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
/** @var Extgallery\PublicRatingHandler $ratingHandler */
$ratingHandler = Extgallery\Helper::getInstance()->getHandler('PublicRating');
$permHandler = Extgallery\PublicPermHandler::getInstance();
$photoObj = $photoHandler->getPhoto($photoId);
// Check is the photo exist
if (!$photoObj) {
redirect_header('index.php', 3, _NOPERM);
}
$photo = $photoHandler->objectToArray($photoObj, ['cat_id', 'uid']);
// Check the category access permission
$permHandler = Extgallery\PublicPermHandler::getInstance();
if (!$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_access', $photo['cat']['cat_id'])) {
redirect_header('index.php', 3, _NOPERM);
}
// Don't update counter if user come from rating page
if (null !== Request::getString('HTTP_REFERER', '', 'SERVER') && basename(Request::getString('HTTP_REFERER', '', 'SERVER')) != 'public-rating.php?photoId=' . $photoId) {
$photoHandler->updateHits($photoId);
}
$photo['photo_date'] = date(_MEDIUMDATESTRING, $photo['photo_date']);
$xoopsTpl->assign('photo', $photo);
$photosIds = $photoHandler->getUserPhotoAlbumId($photoObj->getVar('uid'));
$nbPhoto = count($photosIds);
$currentPhotoPlace = array_search($photoId, $photosIds, true);
if (1 == $nbPhoto) {
$prev = 0;
$next = 0;
} elseif (0 == $currentPhotoPlace) {
$prev = 0;
$next = $photosIds[$currentPhotoPlace + 1];
} elseif (($currentPhotoPlace + 1) == $nbPhoto) {
$prev = $photosIds[$currentPhotoPlace - 1];
$next = 0;
} else {
$prev = $photosIds[$currentPhotoPlace - 1];
$next = $photosIds[$currentPhotoPlace + 1];
}
$xoopsTpl->assign('prevId', $prev);
$xoopsTpl->assign('nextId', $next);
$xoopsTpl->assign('currentPhoto', $currentPhotoPlace + 1);
$xoopsTpl->assign('totalPhoto', $nbPhoto);
$albumName = $photo['user']['uname'] . _MD_EXTGALLERY_USERS_SUB_PHOTO_ALBUM;
$xoopsTpl->assign('xoops_pagetitle', $photo['photo_title'] . ' - ' . $albumName);
$xoTheme->addMeta('meta', 'description', $photo['photo_title'] . ' - ' . $albumName);
$rel = 'alternate';
$attributes['rel'] = $rel;
$attributes['type'] = 'application/rss+xml';
$attributes['title'] = _MD_EXTGALLERY_RSS;
$attributes['href'] = XOOPS_URL . '/modules/extgallery/public-rss.php';
$xoTheme->addMeta('link', $rel, $attributes);
$xoTheme->addStylesheet('modules/extgallery/assets/css/style.css');
$xoopsTpl->assign('rating', $ratingHandler->getRate($photoId));
$lang = [
'preview' => _MD_EXTGALLERY_PREVIEW,
'next' => _MD_EXTGALLERY_NEXT,
'of' => _MD_EXTGALLERY_OF,
'voteFor' => _MD_EXTGALLERY_VOTE_FOR_THIS_PHOTO,
'photoInfo' => _MD_EXTGALLERY_PHOTO_INFORMATION,
'resolution' => _MD_EXTGALLERY_RESOLUTION,
'pixels' => _MD_EXTGALLERY_PIXELS,
'view' => _MD_EXTGALLERY_VIEW,
'hits' => _MD_EXTGALLERY_HITS,
'fileSize' => _MD_EXTGALLERY_FILE_SIZE,
'added' => _MD_EXTGALLERY_ADDED,
'score' => _MD_EXTGALLERY_SCORE,
'votes' => _MD_EXTGALLERY_VOTES,
'downloadOrig' => _MD_EXTGALLERY_DOWNLOAD_ORIG,
'donwloads' => _MD_EXTGALLERY_DOWNLOADS,
'sendEcard' => _MD_EXTGALLERY_SEND_ECARD,
'sends' => _MD_EXTGALLERY_SENDS,
'submitter' => _MD_EXTGALLERY_SUBMITTER,
'allPhotoBy' => _MD_EXTGALLERY_ALL_PHOTO_BY,
'albumName' => $albumName,
];
$xoopsTpl->assign('lang', $lang);
if ($helper->getConfig('enable_rating')) {
$xoopsTpl->assign('canRate', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_rate', $cat['cat_id']));
} else {
$xoopsTpl->assign('canRate', false);
//DNPROSSI - added preferences option - enable_rating
$xoopsTpl->assign('enable_rating', $helper->getConfig('enable_rating'));
}
//DNPROSSI - added preferences option
// enable_info, enable_resolution, enable_download, enable_date
// enable_ecards, enable_submitter_lnk, enable_photo_hits
if ('photo' === $helper->getConfig('info_view') || 'both' === $helper->getConfig('info_view')) {
if ('user' === $helper->getConfig('pubusr_info_view') || 'both' === $helper->getConfig('pubusr_info_view')) {
if (0 == $helper->getConfig('enable_info')) {
$enable_info = $helper->getConfig('enable_info');
} else {
$enable_info = 1;
}
} else {
$enable_info = 1;
}
} else {
$enable_info = 1;
}
$xoopsTpl->assign('enable_info', $enable_info);
$xoopsTpl->assign('enable_resolution', $helper->getConfig('enable_resolution'));
$xoopsTpl->assign('enable_download', $helper->getConfig('enable_download'));
$xoopsTpl->assign('enable_date', $helper->getConfig('enable_date'));
$xoopsTpl->assign('enable_ecards', $helper->getConfig('enable_ecards'));
$xoopsTpl->assign('enable_submitter_lnk', $helper->getConfig('enable_submitter_lnk'));
$xoopsTpl->assign('enable_photo_hits', $helper->getConfig('enable_photo_hits'));
$xoopsTpl->assign('enableExtra', $helper->getConfig('display_extra_field'));
$xoopsTpl->assign('canSendEcard', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_ecard', $photo['cat']['cat_id']));
$xoopsTpl->assign('canDownload', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_download', $photo['cat']['cat_id']));
$xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name'));
$xoopsTpl->assign('disp_ph_title', $helper->getConfig('disp_ph_title'));
$xoopsTpl->assign('show_rss', $helper->getConfig('show_rss'));
// For xoops tag
if ((1 == $helper->getConfig('usetag')) && is_dir('../tag')) {
require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php';
$xoopsTpl->assign('tagbar', tagBar($photo['photo_id'], $catid = 0));
$xoopsTpl->assign('tags', true);
} else {
$xoopsTpl->assign('tags', false);
}
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
require_once XOOPS_ROOT_PATH . '/footer.php';