Completed
Push — master ( 9d3fbd...af269e )
by Michael
09:48
created

admin/actions/lists.php (2 issues)

Upgrade to new PHP Analysis Engine

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

1
<?php
2
/*
3
 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
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
/**
21
 * Gestion des listes
22
 *
23
 * @since 2.3.2009.06.13
24
 */
25
if (!defined('OLEDRION_ADMIN')) {
26
    exit();
27
}
28
global $baseurl; // Pour faire taire les warnings de Zend Studio
29
$operation = 'lists';
30
31
switch ($action) {
32
    // ****************************************************************************************************************
33
    case 'default': // Liste des listes
34
        // ****************************************************************************************************************
35
        xoops_cp_header();
36
        $adminObject = \Xmf\Module\Admin::getInstance();
37
        $adminObject->displayNavigation('index.php?op=lists');
38
39
        global $xoopsConfig;
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...
40
        $items = $usersList = array();
41
        $class = '';
42
43
        //        OledrionUtility::htitle(_MI_OLEDRION_ADMENU15, 4);
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
44
45
        $start      = isset($_GET['start']) ? (int)$_GET['start'] : 0;
46
        $itemsCount = $oledrionHandlers->h_oledrion_lists->getRecentListsCount();
47
        if ($itemsCount > $limit) {
48
            $pagenav = new XoopsPageNav($itemsCount, $limit, $start, 'start', 'op=' . $operation);
49
        }
50
        $items = $oledrionHandlers->h_oledrion_lists->getRecentLists(new Oledrion_parameters(array(
51
                                                                                                 'start' => $start,
52
                                                                                                 'limit' => $limit
53
                                                                                             )));
54
        if (count($items) > 0) {
55
            $usersList = $oledrionHandlers->h_oledrion_lists->getUsersFromLists($items);
56
        }
57
        echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>";
58
        if (isset($pagenav) && is_object($pagenav)) {
59
            echo "<tr><td colspan='2' align='left'>" . $pagenav->renderNav() . "</td><td align='right' colspan='3'>&nbsp;</td></tr>\n";
60
        }
61
        echo "<tr><th align='center'>"
62
             . _AM_OLEDRION_ID
63
             . "</th><th align='center'>"
64
             . _AM_OLEDRION_TITLE
65
             . "</th><th align='center'>"
66
             . _AM_OLEDRION_USER
67
             . "</th><th align='center'>"
68
             . _AM_OLEDRION_DATE
69
             . "</th><th align='center'>"
70
             . _AM_OLEDRION_TYPE
71
             . "</th><th align='center'>"
72
             . _AM_OLEDRION_ACTION
73
             . '</th></tr>';
74
        foreach ($items as $item) {
75
            $class     = ($class === 'even') ? 'odd' : 'even';
76
            $id        = $item->getVar('list_id');
77
            $actions   = array();
78
            $actions[] = "<a href='$baseurl?op=$operation&action=delete&id=" . $id . "' title='" . _OLEDRION_DELETE . "'" . $conf_msg . '>' . $icones['delete'] . '</a>';
79
            $userName  = isset($usersList[$item->list_uid]) ? $usersList[$item->list_uid]->getVar('uname') : _AM_OLEDRION_ANONYMOUS;
80
            echo "<tr class='" . $class . "'>\n";
81
            echo "<td align='center'>" . $id . '</td>';
82
            echo "<td align='left'><a target='blank' href='" . $item->getLink() . "'>" . $item->getVar('list_title') . '</a></td>';
83
            echo "<td align='center'><a target='_blank' href='" . XOOPS_URL . '/userinfo.php?uid=' . $item->list_uid . "'>" . $userName . '</td>';
84
            echo "<td align='center'>" . $item->getFormatedDate() . '</td>';
85
            echo "<td align='center'>" . $item->getListTypeDescription() . '</td>';
86
            echo "<td align='center'>" . implode(' ', $actions) . "</td>\n";
87
            echo "<tr>\n";
88
        }
89
        echo '</table>';
90
        if (isset($pagenav) && is_object($pagenav)) {
91
            echo "<div align='right'>" . $pagenav->renderNav() . '</div>';
92
        }
93
        require_once OLEDRION_ADMIN_PATH . 'admin_footer.php';
94
        break;
95
96
    // ****************************************************************************************************************
97
    case 'delete': // Suppression d'une liste
98
        // ****************************************************************************************************************
99
        xoops_cp_header();
100
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
101
        if (empty($id)) {
102
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . '?op=' . $operation, 5);
103
        }
104
        $list = null;
105
        $list = $oledrionHandlers->h_oledrion_lists->get($id);
106
        if (!is_object($list)) {
107
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $operation, 5);
108
        }
109
        if ($oledrionHandlers->h_oledrion_lists->deleteList($list)) {
110
            OledrionUtility::updateCache();
111
            OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $operation, 2);
112
        } else {
113
            OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $operation, 5);
114
        }
115
        break;
116
}
117