Completed
Push — master ( 53ea58...16270d )
by Michael
04:51
created

item.php ➔ publisher_editItem()   F

Complexity

Conditions 15
Paths 342

Size

Total Lines 160
Code Lines 112

Duplication

Lines 24
Ratio 15 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 15
eloc 112
c 2
b 0
f 0
nc 342
nop 3
dl 24
loc 160
rs 3.7313

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 382 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
14
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @package         Admin
16
 * @subpackage      Action
17
 * @since           1.0
18
 * @author          trabis <[email protected]>
19
 * @author          The SmartFactory <www.smartfactory.ca>
20
 */
21
22
include_once __DIR__ . '/admin_header.php';
23
24
$itemid = XoopsRequest::getInt('itemid', XoopsRequest::getInt('itemid', 0, 'POST'), 'GET');
25
$op     = ($itemid > 0 || XoopsRequest::getString('editor', '', 'POST')) ? 'mod' : '';
26
//$op     = XoopsRequest::getString('op', $op, 'GET');
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
27
28
$op = XoopsRequest::getString('op', XoopsRequest::getString('op', $op, 'POST'), 'GET');
29
30
//if (!empty(XoopsRequest::getString('additem', '', 'POST'))) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
31
//    $op = 'additem';
32
//} elseif (!empty(XoopsRequest::getString('del', '', 'POST'))) {
33
//    $op = 'del';
34
//}
35
36
$op = XoopsRequest::getString('additem', '', 'POST') ? 'additem' : (XoopsRequest::getString('del', '', 'POST') ? 'del' : $op);
37
38
// Where shall we start ?
39
$submittedstartitem = XoopsRequest::getInt('submittedstartitem', XoopsRequest::getInt('submittedstartitem', 0, 'GET'), 'POST');
40
$publishedstartitem = XoopsRequest::getInt('publishedstartitem', XoopsRequest::getInt('publishedstartitem', 0, 'GET'), 'POST');
41
$offlinestartitem   = XoopsRequest::getInt('offlinestartitem', XoopsRequest::getInt('offlinestartitem', 0, 'GET'), 'POST');
42
$rejectedstartitem  = XoopsRequest::getInt('rejectedstartitem', XoopsRequest::getInt('submittedstartitem', 0, 'GET'), 'POST');
43
44
switch ($op) {
45 View Code Duplication
    case 'clone':
0 ignored issues
show
Duplication introduced by
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...
46
        if ($itemid == 0) {
47
            $totalcategories = $publisher->getHandler('category')->getCategoriesCount(-1);
48
            if ($totalcategories == 0) {
49
                redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
50
                //                exit();
51
            }
52
        }
53
        publisherCpHeader();
54
        publisher_editItem(true, $itemid, true);
55
        break;
56
57 View Code Duplication
    case 'mod':
0 ignored issues
show
Duplication introduced by
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...
58
        if ($itemid == 0) {
59
            $totalcategories = $publisher->getHandler('category')->getCategoriesCount(-1);
60
            if ($totalcategories == 0) {
61
                redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
62
                //                exit();
63
            }
64
        }
65
66
        publisherCpHeader();
67
        publisher_editItem(true, $itemid);
68
        break;
69
70
    case 'additem':
71
        $redirect_msg = $error_msg = '';
72
        // Creating the item object
73
        if ($itemid != 0) {
74
            $itemObj = $publisher->getHandler('item')->get($itemid);
75
        } else {
76
            $itemObj = $publisher->getHandler('item')->create();
77
        }
78
79
        $itemObj->setVarsFromRequest();
80
81
        $old_status = $itemObj->status();
82
        $newStatus  = XoopsRequest::getInt('status', PublisherConstants::PUBLISHER_STATUS_PUBLISHED); //_PUBLISHER_STATUS_NOTSET;
83
84
        switch ($newStatus) {
85 View Code Duplication
            case PublisherConstants::PUBLISHER_STATUS_SUBMITTED:
0 ignored issues
show
Duplication introduced by
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...
86
                $error_msg = _AM_PUBLISHER_ITEMNOTCREATED;
87
                if ($old_status == PublisherConstants::PUBLISHER_STATUS_NOTSET) {
88
                    $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED;
89
                }
90
                $redirect_msg = _AM_PUBLISHER_ITEM_RECEIVED_NEED_APPROVAL;
91
                break;
92
93
            case PublisherConstants::PUBLISHER_STATUS_PUBLISHED:
94
                if (($old_status == PublisherConstants::PUBLISHER_STATUS_NOTSET) || ($old_status == PublisherConstants::PUBLISHER_STATUS_SUBMITTED)) {
95
                    $redirect_msg = _AM_PUBLISHER_SUBMITTED_APPROVE_SUCCESS;
96
                    $notifToDo    = array(PublisherConstants::PUBLISHER_NOTIFY_ITEM_PUBLISHED);
97
                } else {
98
                    $redirect_msg = _AM_PUBLISHER_PUBLISHED_MOD_SUCCESS;
99
                }
100
                $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED;
101
                break;
102
103 View Code Duplication
            case PublisherConstants::PUBLISHER_STATUS_OFFLINE:
0 ignored issues
show
Duplication introduced by
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...
104
                $redirect_msg = _AM_PUBLISHER_OFFLINE_MOD_SUCCESS;
105
                if ($old_status == PublisherConstants::PUBLISHER_STATUS_NOTSET) {
106
                    $redirect_msg = _AM_PUBLISHER_OFFLINE_CREATED_SUCCESS;
107
                }
108
                $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED;
109
                break;
110
111 View Code Duplication
            case PublisherConstants::PUBLISHER_STATUS_REJECTED:
0 ignored issues
show
Duplication introduced by
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...
112
                $error_msg = _AM_PUBLISHER_ITEMNOTCREATED;
113
                if ($old_status == PublisherConstants::PUBLISHER_STATUS_NOTSET) {
114
                    $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED;
115
                }
116
                $redirect_msg = _AM_PUBLISHER_ITEM_REJECTED;
117
                break;
118
        }
119
        $itemObj->setVar('status', $newStatus);
120
121
        // Storing the item
122
        if (!$itemObj->store()) {
123
            redirect_header('javascript:history.go(-1)', 3, $error_msg . publisherFormatErrors($itemObj->getErrors()));
124
            //            exit;
125
        }
126
127
        // attach file if any
128
        if (($item_upload_file = XoopsRequest::getArray('item_upload_file', '', 'FILES')) && $item_upload_file['name'] !== '') {
129
            $file_upload_result = publisherUploadFile(false, false, $itemObj);
130
            if ($file_upload_result !== true) {
131
                redirect_header('javascript:history.go(-1)', 3, $file_upload_result);
132
                //                exit;
133
            }
134
        }
135
136
        // Send notifications
137
        if ($notifToDo) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $notifToDo of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
138
            $itemObj->sendNotifications($notifToDo);
139
        }
140
141
        redirect_header('item.php', 2, $redirect_msg);
142
143
        break;
144
145
    case 'del':
146
        $itemObj = $publisher->getHandler('item')->get($itemid);
147
        $confirm = XoopsRequest::getInt('confirm', '', 'POST');
148
149 View Code Duplication
        if ($confirm) {
0 ignored issues
show
Duplication introduced by
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...
150
            if (!$publisher->getHandler('item')->delete($itemObj)) {
151
                redirect_header('item.php', 2, _AM_PUBLISHER_ITEM_DELETE_ERROR . publisherFormatErrors($itemObj->getErrors()));
152
                //                exit();
153
            }
154
            redirect_header('item.php', 2, sprintf(_AM_PUBLISHER_ITEMISDELETED, $itemObj->getTitle()));
155
            //            exit();
156
        } else {
157
            xoops_cp_header();
158
            xoops_confirm(array('op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->getTitle()), 'item.php', _AM_PUBLISHER_DELETETHISITEM . " <br>'" . $itemObj->getTitle() . "'. <br> <br>", _AM_PUBLISHER_DELETE);
159
            xoops_cp_footer();
160
        }
161
        exit();
162
        break;
163
164
    case 'default':
165
    default:
166
        publisherCpHeader();
167
        //publisher_adminMenu(2, _AM_PUBLISHER_ITEMS);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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...
168
        xoops_load('XoopsPageNav');
169
170
        echo "<br>\n";
171
        echo "<form><div style=\"margin-bottom: 12px;\">";
172
        echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
173
        echo '</div></form>';
174
175
        $orderBy   = 'datesub';
176
        $ascOrDesc = 'DESC';
177
178
        // Display Submited articles
179
        publisherOpenCollapsableBar('submiteditemstable', 'submiteditemsicon', _AM_PUBLISHER_SUBMISSIONSMNGMT, _AM_PUBLISHER_SUBMITTED_EXP);
180
181
        // Get the total number of submitted ITEM
182
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_SUBMITTED));
183
184
        $itemsObj = $publisher->getHandler('item')->getAllSubmitted($publisher->getConfig('idxcat_perpage'), $submittedstartitem, -1, $orderBy, $ascOrDesc);
185
186
        $totalItemsOnPage = count($itemsObj);
187
188
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
189
        echo '<tr>';
190
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
191
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
192
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
193
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
194
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
195
        echo '</tr>';
196
        if ($totalitems > 0) {
197
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
198
                $categoryObj = $itemsObj[$i]->getCategory();
199
200
                $approve = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/approve.gif' title='" . _AM_PUBLISHER_SUBMISSION_MODERATE . "' alt='" . _AM_PUBLISHER_SUBMISSION_MODERATE . "' /></a>&nbsp;";
201
                $clone   = '';
202
                $delete  = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
203
                $modify  = '';
204
205
                echo '<tr>';
206
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
207
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
208
                echo "<td class='even' align='left'><a href='" . PUBLISHER_URL . '/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $itemsObj[$i]->getTitle() . '</a></td>';
209
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
210
                echo "<td class='even' align='center'> $approve $clone $modify $delete </td>";
211
                echo '</tr>';
212
            }
213
        } else {
214
            $itemid = 0;
215
            echo '<tr>';
216
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_SUBMITTED . '</td>';
217
            echo '</tr>';
218
        }
219
        echo "</table>\n";
220
        echo "<br>\n";
221
222
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $submittedstartitem, 'submittedstartitem');
223
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
224
225
        publisherCloseCollapsableBar('submiteditemstable', 'submiteditemsicon');
226
227
        // Display Published articles
228
        publisherOpenCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon', _AM_PUBLISHER_PUBLISHEDITEMS, _AM_PUBLISHER_PUBLISHED_DSC);
229
230
        // Get the total number of published ITEM
231
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED));
232
233
        $itemsObj = $publisher->getHandler('item')->getAllPublished($publisher->getConfig('idxcat_perpage'), $publishedstartitem, -1, $orderBy, $ascOrDesc);
234
235
        $totalItemsOnPage = count($itemsObj);
236
237
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
238
        echo '<tr>';
239
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
240
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
241
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
242
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
243
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
244
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
245
        echo '</tr>';
246 View Code Duplication
        if ($totalitems > 0) {
0 ignored issues
show
Duplication introduced by
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...
247
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
248
                $categoryObj = $itemsObj[$i]->getCategory();
249
250
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>";
251
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>";
252
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
253
254
                echo '<tr>';
255
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
256
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
257
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
258
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
259
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
260
                echo "<td class='even' align='center'> $clone $modify $delete </td>";
261
                echo '</tr>';
262
            }
263
        } else {
264
            $itemid = 0;
265
            echo '<tr>';
266
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . '</td>';
267
            echo '</tr>';
268
        }
269
        echo "</table>\n";
270
        echo "<br>\n";
271
272
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $publishedstartitem, 'publishedstartitem');
273
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
274
275
        publisherCloseCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon');
276
277
        // Display Offline articles
278
        publisherOpenCollapsableBar('offlineitemstable', 'offlineitemsicon', _AM_PUBLISHER_ITEMS . ' ' . _CO_PUBLISHER_OFFLINE, _AM_PUBLISHER_OFFLINE_EXP);
279
280
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_OFFLINE));
281
282
        $itemsObj = $publisher->getHandler('item')->getAllOffline($publisher->getConfig('idxcat_perpage'), $offlinestartitem, -1, $orderBy, $ascOrDesc);
283
284
        $totalItemsOnPage = count($itemsObj);
285
286
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
287
        echo '<tr>';
288
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
289
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
290
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
291
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
292
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
293
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
294
        echo '</tr>';
295 View Code Duplication
        if ($totalitems > 0) {
0 ignored issues
show
Duplication introduced by
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...
296
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
297
                $categoryObj = $itemsObj[$i]->getCategory();
298
299
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>";
300
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>";
301
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
302
303
                echo '<tr>';
304
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
305
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
306
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
307
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
308
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
309
                echo "<td class='even' align='center'> $clone $modify $delete </td>";
310
                echo '</tr>';
311
            }
312
        } else {
313
            $itemid = 0;
314
            echo '<tr>';
315
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_OFFLINE . '</td>';
316
            echo '</tr>';
317
        }
318
        echo "</table>\n";
319
        echo "<br>\n";
320
321
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $offlinestartitem, 'offlinestartitem');
322
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
323
324
        publisherCloseCollapsableBar('offlineitemstable', 'offlineitemsicon');
325
326
        // Display Rejected articles
327
        publisherOpenCollapsableBar('Rejecteditemstable', 'rejecteditemsicon', _AM_PUBLISHER_REJECTED_ITEM, _AM_PUBLISHER_REJECTED_ITEM_EXP, _AM_PUBLISHER_SUBMITTED_EXP);
0 ignored issues
show
Documentation introduced by
_AM_PUBLISHER_SUBMITTED_EXP is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
328
329
        // Get the total number of Rejected ITEM
330
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_REJECTED));
331
        $itemsObj   = $publisher->getHandler('item')->getAllRejected($publisher->getConfig('idxcat_perpage'), $rejectedstartitem, -1, $orderBy, $ascOrDesc);
332
333
        $totalItemsOnPage = count($itemsObj);
334
335
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
336
        echo '<tr>';
337
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
338
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
339
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
340
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
341
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
342
        echo '</tr>';
343
344
        if ($totalitems > 0) {
345
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
346
                $categoryObj = $itemsObj[$i]->getCategory();
347
348
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>";
349
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>";
350
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
351
352
                echo '<tr>';
353
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
354
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
355
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
356
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
357
                echo "<td class='even' align='center'> $clone $modify $delete </td>";
358
                echo '</tr>';
359
            }
360
        } else {
361
            $itemid = 0;
362
            echo '<tr>';
363
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_REJECTED . '</td>';
364
            echo '</tr>';
365
        }
366
        echo "</table>\n";
367
        echo "<br>\n";
368
369
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $rejectedstartitem, 'rejectedstartitem');
370
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
371
372
        publisherCloseCollapsableBar('Rejecteditemstable', 'rejecteditemsicon');
373
        break;
374
}
375
include_once __DIR__ . '/admin_footer.php';
376
377
/**
378
 * @param bool $showmenu
379
 * @param int  $itemid
380
 * @param bool $clone
381
 */
382
function publisher_editItem($showmenu = false, $itemid = 0, $clone = false)
0 ignored issues
show
Unused Code introduced by
The parameter $showmenu is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
383
{
384
    $publisher = PublisherPublisher::getInstance();
385
    global $publisherCurrentPage;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
386
387
    xoops_load('XoopsFormLoader');
388
389
    $formTpl = new XoopsTpl();
390
    //publisher_submit.html
391
392
    // if there is a parameter, and the id exists, retrieve data: we're editing a item
393
394
    if ($itemid != 0) {
395
        // Creating the ITEM object
396
        $itemObj = $publisher->getHandler('item')->get($itemid);
397
398
        if (!$itemObj) {
399
            redirect_header('item.php', 1, _AM_PUBLISHER_NOITEMSELECTED);
400
            //            exit();
401
        }
402
403
        if ($clone) {
404
            $itemObj->setNew();
405
            $itemObj->setVar('itemid', 0);
406
            $itemObj->setVar('status', PublisherConstants::PUBLISHER_STATUS_NOTSET);
407
            $itemObj->setVar('datesub', time());
408
        }
409
410
        switch ($itemObj->status()) {
411
            case PublisherConstants::PUBLISHER_STATUS_SUBMITTED:
412
                $breadcrumbAction1 = _CO_PUBLISHER_SUBMITTED;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
413
                $breadcrumbAction2 = _AM_PUBLISHER_APPROVING;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
414
                $pageTitle         = _AM_PUBLISHER_SUBMITTED_TITLE;
415
                $pageInfo          = _AM_PUBLISHER_SUBMITTED_INFO;
416
                $buttonCaption     = _AM_PUBLISHER_APPROVE;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
417
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
418
                break;
419
420 View Code Duplication
            case PublisherConstants::PUBLISHER_STATUS_PUBLISHED:
0 ignored issues
show
Duplication introduced by
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...
421
                $breadcrumbAction1 = _CO_PUBLISHER_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
422
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
423
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
424
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
425
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
426
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
427
                break;
428
429
            case PublisherConstants::PUBLISHER_STATUS_OFFLINE:
430
                $breadcrumbAction1 = _CO_PUBLISHER_OFFLINE;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
431
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
432
                $pageTitle         = _AM_PUBLISHER_OFFLINEEDITING;
433
                $pageInfo          = _AM_PUBLISHER_OFFLINEEDITING_INFO;
434
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
435
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_OFFLINE;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
436
                break;
437
438
            case PublisherConstants::PUBLISHER_STATUS_REJECTED:
439
                $breadcrumbAction1 = _CO_PUBLISHER_REJECTED;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
440
                $breadcrumbAction2 = _AM_PUBLISHER_REJECTED;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
441
                $pageTitle         = _AM_PUBLISHER_REJECTED_EDIT;
442
                $pageInfo          = _AM_PUBLISHER_REJECTED_EDIT_INFO;
443
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
444
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_REJECTED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
445
                break;
446
447
            case PublisherConstants::PUBLISHER_STATUS_NOTSET: // Then it's a clone...
448
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
449
                $breadcrumbAction2 = _AM_PUBLISHER_CLONE_NEW;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
450
                $buttonCaption     = _AM_PUBLISHER_CREATE;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
451
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
452
                $pageTitle         = _AM_PUBLISHER_ITEM_DUPLICATING;
453
                $pageInfo          = _AM_PUBLISHER_ITEM_DUPLICATING_DSC;
454
                break;
455
456
            case 'default':
457 View Code Duplication
            default:
0 ignored issues
show
Duplication introduced by
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...
458
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
459
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
460
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
461
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
462
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
463
                $newStatus         = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
464
                break;
465
        }
466
467
        $categoryObj = $itemObj->getCategory();
0 ignored issues
show
Unused Code introduced by
$categoryObj is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
468
469
        echo "<br>\n";
470
        publisherOpenCollapsableBar('edititemtable', 'edititemicon', $pageTitle, $pageInfo);
471
472
        if ($clone) {
473
            echo "<form><div style=\"margin-bottom: 10px;\">";
474
            echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->itemid() . "'\" value='" . _AM_PUBLISHER_CLONE_ITEM . "'>&nbsp;&nbsp;";
475
            echo '</div></form>';
476
        }
477
    } else {
478
        // there's no parameter, so we're adding an item
479
480
        $itemObj = $publisher->getHandler('item')->create();
481
        $itemObj->setVarsFromRequest();
482
483
        $categoryObj       = $publisher->getHandler('category')->create();
484
        $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
485
        $breadcrumbAction2 = _AM_PUBLISHER_CREATINGNEW;
0 ignored issues
show
Unused Code introduced by
$breadcrumbAction2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
486
        $buttonCaption     = _AM_PUBLISHER_CREATE;
0 ignored issues
show
Unused Code introduced by
$buttonCaption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
487
        $newStatus         = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
Unused Code introduced by
$newStatus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
488
489
        $categoryObj->setVar('categoryid', XoopsRequest::getInt('categoryid', 0, 'GET'));
490
491
        publisherOpenCollapsableBar('createitemtable', 'createitemicon', _AM_PUBLISHER_ITEM_CREATING, _AM_PUBLISHER_ITEM_CREATING_DSC);
492
    }
493
494
    $sform = $itemObj->getForm(_AM_PUBLISHER_ITEMS);
495
496
    $sform->assign($formTpl);
497
    $formTpl->display('db:publisher_submit.tpl');
498
499
    publisherCloseCollapsableBar('edititemtable', 'edititemicon');
500
501
    publisherOpenCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
502
503
    $dir = publisherGetUploadDir(true, 'content');
0 ignored issues
show
Documentation introduced by
'content' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
504
505 View Code Duplication
    if (false !== strpos(decoct(fileperms($dir)), '755')) {
0 ignored issues
show
Duplication introduced by
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...
506
        echo "<span style='color:#ff0000;'><h4>" . _AM_PUBLISHER_PERMERROR . '</h4></span>';
507
    }
508
509
    // Upload File
510
    echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>";
511
    echo "<table cellspacing='1' width='100%' class='outer'>";
512
    echo "<tr><th colspan='2'>" . _AM_PUBLISHER_UPLOAD_FILE . '</th></tr>';
513
    echo "<tr valign='top' align='left'><td class='head'>" . _AM_PUBLISHER_SEARCH_PW . "</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30' /></td></tr>";
514
    echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /></td><td class='even'><input type='submit' name='submit' value='" . _AM_PUBLISHER_UPLOAD . "' /></td></tr>";
515
    echo "<input type='hidden' name='backto' value='$publisherCurrentPage'/>";
516
    echo '</table>';
517
    echo '</form>';
518
519
    // Delete File
520
    $form = new XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php');
521
522
    $pWrapSelect = new XoopsFormSelect(publisherGetUploadDir(true, 'content'), 'address');
0 ignored issues
show
Documentation introduced by
'content' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
523
    $folder      = dir($dir);
524 View Code Duplication
    while (($file = $folder->read()) !== false) {
0 ignored issues
show
Duplication introduced by
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...
525
        if ($file !== '.' && $file !== '..') {
526
            $pWrapSelect->addOption($file, $file);
527
        }
528
    }
529
    $folder->close();
530
    $form->addElement($pWrapSelect);
531
532
    $delfile = 'delfile';
533
    $form->addElement(new XoopsFormHidden('op', $delfile));
534
    $submit = new XoopsFormButton('', 'submit', _AM_PUBLISHER_BUTTON_DELETE, 'submit');
535
    $form->addElement($submit);
536
537
    $form->addElement(new XoopsFormHidden('backto', $publisherCurrentPage));
538
    $form->display();
539
540
    publisherCloseCollapsableBar('pagewraptable', 'pagewrapicon');
541
}
542