Completed
Pull Request — master (#14)
by
unknown
03:22
created

public-userphoto.php (1 issue)

1
<?php
2
/**
3
 * ExtGallery User area
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   {@link https://xoops.org/ XOOPS Project}
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Zoullou (http://www.zoullou.net)
15
 * @package     ExtGallery
16
 */
17
18
use Xmf\Request;
19
use XoopsModules\Extgallery;
20
21
include __DIR__ . '/header.php';
22
//require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
24
$GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-userphoto.tpl';
25
include XOOPS_ROOT_PATH . '/header.php';
26
27
/** @var Extgallery\Helper $helper */
28
$helper = Extgallery\Helper::getInstance();
29
30
$photoId = \Xmf\Request::getInt('photoId', 0, 'GET');
31
32
/** @var Extgallery\CategoryHandler $catHandler */
33
$catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');
34
/** @var Extgallery\PublicPhotoHandler $photoHandler */
35
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
36
/** @var Extgallery\PublicRatingHandler $ratingHandler */
37
$ratingHandler = Extgallery\Helper::getInstance()->getHandler('PublicRating');
38
$permHandler   = Extgallery\PublicPermHandler::getInstance();
39
40
$photoObj = $photoHandler->getPhoto($photoId);
41
42
// Check is the photo exist
43
if (!$photoObj) {
44
    redirect_header('index.php', 3, _NOPERM);
45
}
46
47
$photo = $photoHandler->objectToArray($photoObj, ['cat_id', 'uid']);
48
49
// Check the category access permission
50
$permHandler = Extgallery\PublicPermHandler::getInstance();
51
if (!$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_access', $photo['cat']['cat_id'])) {
52
    redirect_header('index.php', 3, _NOPERM);
53
}
54
55
// Don't update counter if user come from rating page
56
if (null !== Request::getString('HTTP_REFERER', '', 'SERVER') && basename(Request::getString('HTTP_REFERER', '', 'SERVER')) != 'public-rating.php?photoId=' . $photoId) {
57
    $photoHandler->updateHits($photoId);
58
}
59
60
$photo['photo_date'] = date(_MEDIUMDATESTRING, $photo['photo_date']);
61
$xoopsTpl->assign('photo', $photo);
62
63
$photosIds = $photoHandler->getUserPhotoAlbumId($photoObj->getVar('uid'));
64
65
$nbPhoto           = count($photosIds);
66
$currentPhotoPlace = array_search($photoId, $photosIds);
67
68
if (1 == $nbPhoto) {
69
    $prev = 0;
70
    $next = 0;
71
} elseif (0 == $currentPhotoPlace) {
72
    $prev = 0;
73
    $next = $photosIds[$currentPhotoPlace + 1];
74
} elseif (($currentPhotoPlace + 1) == $nbPhoto) {
75
    $prev = $photosIds[$currentPhotoPlace - 1];
76
    $next = 0;
77
} else {
78
    $prev = $photosIds[$currentPhotoPlace - 1];
79
    $next = $photosIds[$currentPhotoPlace + 1];
80
}
81
$xoopsTpl->assign('prevId', $prev);
82
$xoopsTpl->assign('nextId', $next);
83
$xoopsTpl->assign('currentPhoto', $currentPhotoPlace + 1);
84
$xoopsTpl->assign('totalPhoto', $nbPhoto);
85
86
$albumName = $photo['user']['uname'] . _MD_EXTGALLERY_USERS_SUB_PHOTO_ALBUM;
87
$xoopsTpl->assign('xoops_pagetitle', $photo['photo_title'] . ' - ' . $albumName);
88
$xoTheme->addMeta('meta', 'description', $photo['photo_title'] . ' - ' . $albumName);
89
90
$rel                 = 'alternate';
91
$attributes['rel']   = $rel;
92
$attributes['type']  = 'application/rss+xml';
93
$attributes['title'] = _MD_EXTGALLERY_RSS;
94
$attributes['href']  = XOOPS_URL . '/modules/extgallery/public-rss.php';
95
$xoTheme->addMeta('link', $rel, $attributes);
96
$xoTheme->addStylesheet('modules/extgallery/assets/css/style.css');
97
98
$xoopsTpl->assign('rating', $ratingHandler->getRate($photoId));
99
100
$lang = [
101
    'preview'      => _MD_EXTGALLERY_PREVIEW,
102
    'next'         => _MD_EXTGALLERY_NEXT,
103
    'of'           => _MD_EXTGALLERY_OF,
104
    'voteFor'      => _MD_EXTGALLERY_VOTE_FOR_THIS_PHOTO,
105
    'photoInfo'    => _MD_EXTGALLERY_PHOTO_INFORMATION,
106
    'resolution'   => _MD_EXTGALLERY_RESOLUTION,
107
    'pixels'       => _MD_EXTGALLERY_PIXELS,
108
    'view'         => _MD_EXTGALLERY_VIEW,
109
    'hits'         => _MD_EXTGALLERY_HITS,
110
    'fileSize'     => _MD_EXTGALLERY_FILE_SIZE,
111
    'added'        => _MD_EXTGALLERY_ADDED,
112
    'score'        => _MD_EXTGALLERY_SCORE,
113
    'votes'        => _MD_EXTGALLERY_VOTES,
114
    'downloadOrig' => _MD_EXTGALLERY_DOWNLOAD_ORIG,
115
    'donwloads'    => _MD_EXTGALLERY_DOWNLOADS,
116
    'sendEcard'    => _MD_EXTGALLERY_SEND_ECARD,
117
    'sends'        => _MD_EXTGALLERY_SENDS,
118
    'submitter'    => _MD_EXTGALLERY_SUBMITTER,
119
    'allPhotoBy'   => _MD_EXTGALLERY_ALL_PHOTO_BY,
120
    'albumName'    => $albumName
121
];
122
$xoopsTpl->assign('lang', $lang);
123
124
if ($helper->getConfig('enable_rating')) {
125
    $xoopsTpl->assign('canRate', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_rate', $cat['cat_id']));
126
} else {
127
    $xoopsTpl->assign('canRate', false);
128
    //DNPROSSI - added preferences option - enable_rating
129
    $xoopsTpl->assign('enable_rating', $helper->getConfig('enable_rating'));
130
}
131
132
//DNPROSSI - added preferences option
133
//  enable_info, enable_resolution, enable_download, enable_date
134
//  enable_ecards, enable_submitter_lnk, enable_photo_hits
135
if ('photo' === $helper->getConfig('info_view') || 'both' === $helper->getConfig('info_view')) {
136
    if ('user' === $helper->getConfig('pubusr_info_view') || 'both' === $helper->getConfig('pubusr_info_view')) {
137
        if (0 == $helper->getConfig('enable_info')) {
138
            $enable_info = $helper->getConfig('enable_info');
139
        } else {
140
            $enable_info = 1;
141
        }
142
    } else {
143
        $enable_info = 1;
144
    }
145
} else {
146
    $enable_info = 1;
147
}
148
149
$xoopsTpl->assign('enable_info', $enable_info);
150
$xoopsTpl->assign('enable_resolution', $helper->getConfig('enable_resolution'));
151
$xoopsTpl->assign('enable_download', $helper->getConfig('enable_download'));
152
$xoopsTpl->assign('enable_date', $helper->getConfig('enable_date'));
153
$xoopsTpl->assign('enable_ecards', $helper->getConfig('enable_ecards'));
154
$xoopsTpl->assign('enable_submitter_lnk', $helper->getConfig('enable_submitter_lnk'));
155
$xoopsTpl->assign('enable_photo_hits', $helper->getConfig('enable_photo_hits'));
156
157
$xoopsTpl->assign('enableExtra', $helper->getConfig('display_extra_field'));
158
$xoopsTpl->assign('canSendEcard', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_ecard', $photo['cat']['cat_id']));
159
$xoopsTpl->assign('canDownload', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_download', $photo['cat']['cat_id']));
160
161
$xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name'));
162
$xoopsTpl->assign('disp_ph_title', $helper->getConfig('disp_ph_title'));
163
$xoopsTpl->assign('show_rss', $helper->getConfig('show_rss'));
164
165
// For xoops tag
166
if ((1 == $helper->getConfig('usetag')) && is_dir('../tag')) {
167
    require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php';
168
    $xoopsTpl->assign('tagbar', tagBar($photo['photo_id'], $catid = 0));
169
    $xoopsTpl->assign('tags', true);
170
} else {
171
    $xoopsTpl->assign('tags', false);
172
}
173
174
include XOOPS_ROOT_PATH . '/include/comment_view.php';
175
include XOOPS_ROOT_PATH . '/footer.php';
176