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

blocks/oledrion_my_lists.php (1 issue)

Upgrade to new PHP Analysis Engine

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

1
<?php
2
/*
3
 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
 * Affiche les listes de l'utilisateur
22
 *
23
 * @param  array $options [0] = Nombre maximum de listes à voir
24
 * @return array
25
 */
26
function b_oledrion_my_lists_show($options)
27
{
28
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
29
    OledrionUtility::loadLanguageFile('modinfo.php');
30
    $start = 0;
31
    $limit = (int)$options[0];
32
    $uid   = OledrionUtility::getCurrentUserID();
33
    if ($uid == 0) {
34
        return null;
35
    }
36
    $listType = OLEDRION_LISTS_ALL;
37
    $block    = array();
38
    $handlers = OledrionHandler::getInstance();
39
    $items    = array();
40
    $items    = $handlers->h_oledrion_lists->getRecentLists(new Oledrion_parameters(array(
41
                                                                                        'start'    => $start,
42
                                                                                        'limit'    => $limit,
43
                                                                                        'sort'     => 'list_date',
44
                                                                                        'order'    => 'DESC',
45
                                                                                        'idAsKey'  => true,
46
                                                                                        'listType' => $listType,
47
                                                                                        'list_uid' => $uid
48
                                                                                    )));
49
    if (count($items) > 0) {
50
        foreach ($items as $item) {
51
            $block['my_lists'][] = $item->toArray();
52
        }
53
    }
54
55
    return $block;
56
}
57
58
/**
59
 * Edition des paramètres du bloc
60
 *
61
 * @param  array $options [0] = Nombre maximum de listes à voir
62
 * @return array
63
 */
64 View Code Duplication
function b_oledrion_my_lists_edit($options)
0 ignored issues
show
This function seems to be duplicated in 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...
65
{
66
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
67
    $form = '';
68
    $form .= "<table border='0'>";
69
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "'></td></tr>";
70
    $form .= '</table>';
71
72
    return $form;
73
}
74
75
/**
76
 * Bloc à la volée
77
 * @param $options
78
 */
79 View Code Duplication
function b_oledrion_my_lists_duplicatable($options)
80
{
81
    $options = explode('|', $options);
82
    $block   = b_oledrion_my_lists_show($options);
83
84
    $tpl = new XoopsTpl();
85
    $tpl->assign('block', $block);
86
    $tpl->display('db:oledrion_block_my_lists.tpl');
87
}
88