Passed
Push — master ( ddb18f...758072 )
by Michael
06:17
created

public-upload.php (1 issue)

Labels
Severity
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 (https://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
use XoopsModules\Tag\FormTag;
21
22
require_once __DIR__ . '/header.php';
23
24
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
25
//require_once __DIR__ . '/class/Utility.php';
26
27
if (Request::hasVar('step', 'POST')) {
28
    $step = $_POST['step'];
29
} else {
30
    $step = 'default';
31
}
32
33
$permHandler = Extgallery\PublicPermHandler::getInstance();
34
if (count($permHandler->getAuthorizedPublicCat($GLOBALS['xoopsUser'], 'public_upload')) < 1) {
35
    redirect_header('index.php', 3, _MD_EXTGALLERY_NOPERM);
36
}
37
38
$moduleDirName = basename(__DIR__);
39
$utility       = new Extgallery\Utility();
40
switch ($step) {
41
    case 'enreg':
42
        /** @var Extgallery\PublicPhotoHandler $photoHandler */
43
        $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
44
45
        $result = $photoHandler->postPhotoTraitement('photo_file', false);
46
47
        if (2 == $result) {
48
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_NOT_AN_ALBUM);
49
        } elseif (4 == $result || 5 == $result) {
50
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_UPLOAD_ERROR . ' :<br>' . $photoHandler->photoUploader->getError());
51
        } elseif (0 == $result) {
52
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_PHOTO_UPLOADED);
53
        } elseif (1 == $result) {
54
            redirect_header('public-upload.php', 3, _MD_EXTGALLERY_PHOTO_PENDING);
55
        }
56
57
        break;
58
    case 'default':
59
    default:
60
61
        require_once XOOPS_ROOT_PATH . '/header.php';
62
63
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');
64
65
        $form = new \XoopsThemeForm(_MD_EXTGALLERY_PUBLIC_UPLOAD, 'add_photo', 'public-upload.php', 'post', true);
66
        $form->setExtra('enctype="multipart/form-data"');
67
        $form->addElement(new \XoopsFormLabel(_MD_EXTGALLERY_ALBUMS, $catHandler->getLeafSelect('cat_id', false, 0, '', 'public_upload')));
68
69
        //DNPROSSI - editors
70
        $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_PHOTO_TITLE, 'photo_title', '50', '150'), false);
71
        $editor = $utility::getWysiwygForm(_MD_EXTGALLERY_DESC, 'photo_desc', '', 15, 60, '100%', '350px', 'hometext_hidden');
72
        $form->addElement($editor, false);
73
74
        $form->addElement(new \XoopsFormFile(_MD_EXTGALLERY_PHOTO, 'photo_file', $helper->getConfig('max_photosize')), false);
75
        if ($helper->getConfig('display_extra_field')) {
76
            $form->addElement(new \XoopsFormTextArea(_MD_EXTGALLERY_EXTRA_INFO, 'photo_extra'));
77
        }
78
79
        // For xoops tag
80
        if ((1 == $helper->getConfig('usetag')) && is_dir('../tag')) {
81
            require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
82
            $form->addElement(new FormTag('tag', 60, 255, '', 0));
83
        }
84
85
        $plugin = Extgallery\Helper::getInstance()->getHandler('Plugin');
86
        $plugin->triggerEvent('photoForm', $form);
0 ignored issues
show
The method triggerEvent() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsNotificationHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

86
        $plugin->/** @scrutinizer ignore-call */ 
87
                 triggerEvent('photoForm', $form);
Loading history...
87
88
        $form->addElement(new \XoopsFormHidden('step', 'enreg'));
89
        $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
90
91
        $form->display();
92
93
        require_once XOOPS_ROOT_PATH . '/footer.php';
94
95
        break;
96
}
97