Completed
Push — master ( 72613d...069c91 )
by Michael
02:16
created

public-upload.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
include __DIR__ . '/header.php';
19
require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
20
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
21
require_once __DIR__ . '/class/utility.php';
22
23
if (isset($_POST['step'])) {
24
    $step = $_POST['step'];
25
} else {
26
    $step = 'default';
27
}
28
29
$permHandler = ExtgalleryPublicPermHandler::getInstance();
30 View Code Duplication
if (count($permHandler->getAuthorizedPublicCat($GLOBALS['xoopsUser'], 'public_upload')) < 1) {
31
    redirect_header('index.php', 3, _MD_EXTGALLERY_NOPERM);
32
}
33
34
$moduleDirName = basename(__DIR__);
35
$utilityClass  = ucfirst($moduleDirName) . 'Utility';
36
switch ($step) {
37
38 View Code Duplication
    case 'enreg':
39
        /** @var ExtgalleryPublicPhotoHandler $photoHandler */
40
        $photoHandler = xoops_getModuleHandler('publicphoto', 'extgallery');
41
42
        $result = $photoHandler->postPhotoTraitement('photo_file', false);
43
44
        if (2 == $result) {
45
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_NOT_AN_ALBUM);
46
        } elseif (4 == $result || 5 == $result) {
47
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_UPLOAD_ERROR . ' :<br>' . $photoHandler->photoUploader->getError());
48
        } elseif (0 == $result) {
49
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_PHOTO_UPLOADED);
50
        } elseif (1 == $result) {
51
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_PHOTO_PENDING);
52
        }
53
54
        break;
55
56
    case 'default':
57
    default:
58
59
        require_once XOOPS_ROOT_PATH . '/header.php';
60
61
        $catHandler = xoops_getModuleHandler('publiccat', 'extgallery');
62
63
        $form = new XoopsThemeForm(_MD_EXTGALLERY_PUBLIC_UPLOAD, 'add_photo', 'public-upload.php', 'post', true);
64
        $form->setExtra('enctype="multipart/form-data"');
65
        $form->addElement(new XoopsFormLabel(_MD_EXTGALLERY_ALBUMS, $catHandler->getLeafSelect('cat_id', false, 0, '', 'public_upload')));
66
67
        //DNPROSSI - editors
68
        $form->addElement(new XoopsFormText(_MD_EXTGALLERY_PHOTO_TITLE, 'photo_title', '50', '150'), false);
69
        $editor = $utilityClass::getWysiwygForm(_MD_EXTGALLERY_DESC, 'photo_desc', '', 15, 60, '100%', '350px', 'hometext_hidden');
70
        $form->addElement($editor, false);
71
72
        $form->addElement(new XoopsFormFile(_MD_EXTGALLERY_PHOTO, 'photo_file', $xoopsModuleConfig['max_photosize']), false);
73
        if ($xoopsModuleConfig['display_extra_field']) {
74
            $form->addElement(new XoopsFormTextArea(_MD_EXTGALLERY_EXTRA_INFO, 'photo_extra'));
75
        }
76
77
        // For xoops tag
78 View Code Duplication
        if ((1 == $xoopsModuleConfig['usetag']) && is_dir('../tag')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
            require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
80
            $form->addElement(new TagFormTag('tag', 60, 255, '', 0));
81
        }
82
83
        $plugin = xoops_getModuleHandler('plugin', 'extgallery');
84
        $plugin->triggerEvent('photoForm', $form);
85
86
        $form->addElement(new XoopsFormHidden('step', 'enreg'));
87
        $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
88
89
        $form->display();
90
91
        include XOOPS_ROOT_PATH . '/footer.php';
92
93
        break;
94
95
}
96