Completed
Branch master (d81c7d)
by Michael
04:25
created

item.php ➔ publisher_editItem()   F

Complexity

Conditions 15
Paths 342

Size

Total Lines 161
Code Lines 113

Duplication

Lines 21
Ratio 13.04 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 15
eloc 113
c 3
b 0
f 0
nc 342
nop 3
dl 21
loc 161
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 402 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',
159
                          _AM_PUBLISHER_DELETETHISITEM . " <br>'" . $itemObj->getTitle() . "'. <br> <br>", _AM_PUBLISHER_DELETE);
160
            xoops_cp_footer();
161
        }
162
        exit();
163
        break;
164
165
    case 'default':
166
    default:
167
        publisherCpHeader();
168
        //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...
169
        xoops_load('XoopsPageNav');
170
171
        echo "<br>\n";
172
        echo "<form><div style=\"margin-bottom: 12px;\">";
173
        echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
174
        echo '</div></form>';
175
176
        $orderBy   = 'datesub';
177
        $ascOrDesc = 'DESC';
178
179
        // Display Submited articles
180
        publisherOpenCollapsableBar('submiteditemstable', 'submiteditemsicon', _AM_PUBLISHER_SUBMISSIONSMNGMT, _AM_PUBLISHER_SUBMITTED_EXP);
181
182
        // Get the total number of submitted ITEM
183
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_SUBMITTED));
184
185
        $itemsObj = $publisher->getHandler('item')->getAllSubmitted($publisher->getConfig('idxcat_perpage'), $submittedstartitem, -1, $orderBy, $ascOrDesc);
186
187
        $totalItemsOnPage = count($itemsObj);
188
189
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
190
        echo '<tr>';
191
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
192
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
193
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
194
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
195
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
196
        echo '</tr>';
197
        if ($totalitems > 0) {
198
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
199
                $categoryObj = $itemsObj[$i]->getCategory();
200
201
                $approve =
202
                    "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/approve.gif' title='" . _AM_PUBLISHER_SUBMISSION_MODERATE
203
                    . "' alt='" . _AM_PUBLISHER_SUBMISSION_MODERATE . "' /></a>&nbsp;";
204
                $clone   = '';
205
                $delete  =
206
                    "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='"
207
                    . _AM_PUBLISHER_DELETEITEM . "' /></a>";
208
                $modify  = '';
209
210
                echo '<tr>';
211
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
212
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
213
                echo "<td class='even' align='left'><a href='" . PUBLISHER_URL . '/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $itemsObj[$i]->getTitle() . '</a></td>';
214
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
215
                echo "<td class='even' align='center'> $approve $clone $modify $delete </td>";
216
                echo '</tr>';
217
            }
218
        } else {
219
            $itemid = 0;
220
            echo '<tr>';
221
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_SUBMITTED . '</td>';
222
            echo '</tr>';
223
        }
224
        echo "</table>\n";
225
        echo "<br>\n";
226
227
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $submittedstartitem, 'submittedstartitem');
228
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
229
230
        publisherCloseCollapsableBar('submiteditemstable', 'submiteditemsicon');
231
232
        // Display Published articles
233
        publisherOpenCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon', _AM_PUBLISHER_PUBLISHEDITEMS, _AM_PUBLISHER_PUBLISHED_DSC);
234
235
        // Get the total number of published ITEM
236
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED));
237
238
        $itemsObj = $publisher->getHandler('item')->getAllPublished($publisher->getConfig('idxcat_perpage'), $publishedstartitem, -1, $orderBy, $ascOrDesc);
239
240
        $totalItemsOnPage = count($itemsObj);
241
242
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
243
        echo '<tr>';
244
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
245
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
246
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
247
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
248
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
249
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
250
        echo '</tr>';
251 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...
252
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
253
                $categoryObj = $itemsObj[$i]->getCategory();
254
255
                $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='"
256
                          . _AM_PUBLISHER_EDITITEM . "' /></a>";
257
                $delete =
258
                    "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='"
259
                    . _AM_PUBLISHER_DELETEITEM . "'/></a>";
260
                $clone  =
261
                    "<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='"
262
                    . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
263
264
                echo '<tr>';
265
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
266
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
267
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
268
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
269
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
270
                echo "<td class='even' align='center'> $modify $delete $clone</td>";
271
                echo '</tr>';
272
            }
273
        } else {
274
            $itemid = 0;
275
            echo '<tr>';
276
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . '</td>';
277
            echo '</tr>';
278
        }
279
        echo "</table>\n";
280
        echo "<br>\n";
281
282
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $publishedstartitem, 'publishedstartitem');
283
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
284
285
        publisherCloseCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon');
286
287
        // Display Offline articles
288
        publisherOpenCollapsableBar('offlineitemstable', 'offlineitemsicon', _AM_PUBLISHER_ITEMS . ' ' . _CO_PUBLISHER_OFFLINE, _AM_PUBLISHER_OFFLINE_EXP);
289
290
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_OFFLINE));
291
292
        $itemsObj = $publisher->getHandler('item')->getAllOffline($publisher->getConfig('idxcat_perpage'), $offlinestartitem, -1, $orderBy, $ascOrDesc);
293
294
        $totalItemsOnPage = count($itemsObj);
295
296
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
297
        echo '<tr>';
298
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
299
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
300
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
301
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
302
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
303
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
304
        echo '</tr>';
305 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...
306
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
307
                $categoryObj = $itemsObj[$i]->getCategory();
308
309
                $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='"
310
                          . _AM_PUBLISHER_EDITITEM . "' /></a>";
311
                $delete =
312
                    "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='"
313
                    . _AM_PUBLISHER_DELETEITEM . "'/></a>";
314
                $clone  =
315
                    "<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='"
316
                    . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
317
318
                echo '<tr>';
319
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
320
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
321
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
322
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
323
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
324
                echo "<td class='even' align='center'>  $modify $delete $clone</td>";
325
                echo '</tr>';
326
            }
327
        } else {
328
            $itemid = 0;
329
            echo '<tr>';
330
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_OFFLINE . '</td>';
331
            echo '</tr>';
332
        }
333
        echo "</table>\n";
334
        echo "<br>\n";
335
336
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $offlinestartitem, 'offlinestartitem');
337
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
338
339
        publisherCloseCollapsableBar('offlineitemstable', 'offlineitemsicon');
340
341
        // Display Rejected articles
342
        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...
343
344
        // Get the total number of Rejected ITEM
345
        $totalitems = $publisher->getHandler('item')->getItemsCount(-1, array(PublisherConstants::PUBLISHER_STATUS_REJECTED));
346
        $itemsObj   = $publisher->getHandler('item')->getAllRejected($publisher->getConfig('idxcat_perpage'), $rejectedstartitem, -1, $orderBy, $ascOrDesc);
347
348
        $totalItemsOnPage = count($itemsObj);
349
350
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
351
        echo '<tr>';
352
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
353
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
354
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
355
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
356
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
357
        echo '</tr>';
358
359
        if ($totalitems > 0) {
360
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
361
                $categoryObj = $itemsObj[$i]->getCategory();
362
363
                $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='"
364
                          . _AM_PUBLISHER_EDITITEM . "' /></a>";
365
                $delete =
366
                    "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='"
367
                    . _AM_PUBLISHER_DELETEITEM . "'/></a>";
368
                $clone  =
369
                    "<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='"
370
                    . _AM_PUBLISHER_CLONE_ITEM . "' /></a>";
371
372
                echo '<tr>';
373
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
374
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
375
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
376
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
377
                echo "<td class='even' align='center'> $modify $delete $clone</td>";
378
                echo '</tr>';
379
            }
380
        } else {
381
            $itemid = 0;
382
            echo '<tr>';
383
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_REJECTED . '</td>';
384
            echo '</tr>';
385
        }
386
        echo "</table>\n";
387
        echo "<br>\n";
388
389
        $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $rejectedstartitem, 'rejectedstartitem');
390
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
391
392
        publisherCloseCollapsableBar('Rejecteditemstable', 'rejecteditemsicon');
393
        break;
394
}
395
include_once __DIR__ . '/admin_footer.php';
396
397
/**
398
 * @param bool $showmenu
399
 * @param int  $itemid
400
 * @param bool $clone
401
 */
402
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...
403
{
404
    $publisher = PublisherPublisher::getInstance();
405
    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...
406
407
    xoops_load('XoopsFormLoader');
408
409
    $formTpl = new XoopsTpl();
410
    //publisher_submit.html
411
412
    // if there is a parameter, and the id exists, retrieve data: we're editing a item
413
414
    if ($itemid != 0) {
415
        // Creating the ITEM object
416
        $itemObj = $publisher->getHandler('item')->get($itemid);
417
418
        if (!$itemObj) {
419
            redirect_header('item.php', 1, _AM_PUBLISHER_NOITEMSELECTED);
420
            //            exit();
421
        }
422
423
        if ($clone) {
424
            $itemObj->setNew();
425
            $itemObj->setVar('itemid', 0);
426
            $itemObj->setVar('status', PublisherConstants::PUBLISHER_STATUS_NOTSET);
427
            $itemObj->setVar('datesub', time());
428
        }
429
430
        switch ($itemObj->status()) {
431
            case PublisherConstants::PUBLISHER_STATUS_SUBMITTED:
432
                $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...
433
                $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...
434
                $pageTitle         = _AM_PUBLISHER_SUBMITTED_TITLE;
435
                $pageInfo          = _AM_PUBLISHER_SUBMITTED_INFO;
436
                $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...
437
                $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...
438
                break;
439
440 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...
441
                $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...
442
                $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...
443
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
444
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
445
                $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...
446
                $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...
447
                break;
448
449
            case PublisherConstants::PUBLISHER_STATUS_OFFLINE:
450
                $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...
451
                $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...
452
                $pageTitle         = _AM_PUBLISHER_OFFLINEEDITING;
453
                $pageInfo          = _AM_PUBLISHER_OFFLINEEDITING_INFO;
454
                $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...
455
                $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...
456
                break;
457
458
            case PublisherConstants::PUBLISHER_STATUS_REJECTED:
459
                $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...
460
                $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...
461
                $pageTitle         = _AM_PUBLISHER_REJECTED_EDIT;
462
                $pageInfo          = _AM_PUBLISHER_REJECTED_EDIT_INFO;
463
                $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...
464
                $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...
465
                break;
466
467
            case PublisherConstants::PUBLISHER_STATUS_NOTSET: // Then it's a clone...
468
                $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...
469
                $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...
470
                $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...
471
                $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...
472
                $pageTitle         = _AM_PUBLISHER_ITEM_DUPLICATING;
473
                $pageInfo          = _AM_PUBLISHER_ITEM_DUPLICATING_DSC;
474
                break;
475
476
            case 'default':
477 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...
478
                $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...
479
                $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...
480
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
481
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
482
                $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...
483
                $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...
484
                break;
485
        }
486
487
        $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...
488
489
        echo "<br>\n";
490
        publisherOpenCollapsableBar('edititemtable', 'edititemicon', $pageTitle, $pageInfo);
491
492
        if ($clone) {
493
            echo "<form><div style=\"margin-bottom: 10px;\">";
494
            echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->itemid() . "'\" value='" . _AM_PUBLISHER_CLONE_ITEM . "'>&nbsp;&nbsp;";
495
            echo '</div></form>';
496
        }
497
    } else {
498
        // there's no parameter, so we're adding an item
499
500
        $itemObj = $publisher->getHandler('item')->create();
501
        $itemObj->setVarsFromRequest();
502
503
        $categoryObj       = $publisher->getHandler('category')->create();
504
        $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...
505
        $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...
506
        $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...
507
        $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...
508
509
        $categoryObj->setVar('categoryid', XoopsRequest::getInt('categoryid', 0, 'GET'));
510
511
        publisherOpenCollapsableBar('createitemtable', 'createitemicon', _AM_PUBLISHER_ITEM_CREATING, _AM_PUBLISHER_ITEM_CREATING_DSC);
512
    }
513
514
    $sform = $itemObj->getForm(_AM_PUBLISHER_ITEMS);
515
516
    $sform->assign($formTpl);
517
    $formTpl->display('db:publisher_submit.tpl');
518
519
    publisherCloseCollapsableBar('edititemtable', 'edititemicon');
520
521
    publisherOpenCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
522
523
    $dir = publisherGetUploadDir(true, 'content');
524
525
    if (!is_writable($dir)) {
526
        echo "<span style='color:#ff0000;'><h4>" . _AM_PUBLISHER_PERMERROR . '</h4></span>';
527
    }
528
529
    // Upload File
530
    echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>";
531
    echo "<table cellspacing='1' width='100%' class='outer'>";
532
    echo "<tr><th colspan='2'>" . _AM_PUBLISHER_UPLOAD_FILE . '</th></tr>';
533
    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>";
534
    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='"
535
         . _AM_PUBLISHER_UPLOAD . "' /></td></tr>";
536
    echo "<input type='hidden' name='backto' value='$publisherCurrentPage'/>";
537
    echo '</table>';
538
    echo '</form>';
539
540
    // Delete File
541
    $form = new XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php');
542
543
    $pWrapSelect = new XoopsFormSelect(publisherGetUploadDir(true, 'content'), 'address');
544
    $folder      = dir($dir);
545 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...
546
        if ($file !== '.' && $file !== '..') {
547
            $pWrapSelect->addOption($file, $file);
548
        }
549
    }
550
    $folder->close();
551
    $form->addElement($pWrapSelect);
552
553
    $delfile = 'delfile';
554
    $form->addElement(new XoopsFormHidden('op', $delfile));
555
    $submit = new XoopsFormButton('', 'submit', _AM_PUBLISHER_BUTTON_DELETE, 'submit');
556
    $form->addElement($submit);
557
558
    $form->addElement(new XoopsFormHidden('backto', $publisherCurrentPage));
559
    $form->display();
560
561
    publisherCloseCollapsableBar('pagewraptable', 'pagewrapicon');
562
}
563