Completed
Push — master ( 00e474...9d3fbd )
by Michael
04:26
created

class/oledrion_vendors.php (1 issue)

Severity

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 http://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 vendeurs
22
 */
23
require __DIR__ . '/classheader.php';
24
25
/**
26
 * Class Oledrion_vendors
27
 */
28
class Oledrion_vendors extends Oledrion_Object
29
{
30
    /**
31
     * constructor
32
     *
33
     * normally, this is called from child classes only
34
     *
35
     * @access public
36
     */
37
    public function __construct()
38
    {
39
        $this->initVar('vendor_id', XOBJ_DTYPE_INT, null, false);
40
        $this->initVar('vendor_name', XOBJ_DTYPE_TXTBOX, null, false);
41
    }
42
}
43
44
/**
45
 * Class OledrionOledrion_vendorsHandler
46
 */
47
class OledrionOledrion_vendorsHandler extends Oledrion_XoopsPersistableObjectHandler
48
{
49
    /**
50
     * OledrionOledrion_vendorsHandler constructor.
51
     * @param XoopsDatabase|null $db
52
     */
53
    public function __construct(XoopsDatabase $db)
54
    { //                            Table               Classe          Id          Libellé
55
        parent::__construct($db, 'oledrion_vendors', 'oledrion_vendors', 'vendor_id', 'vendor_name');
56
    }
57
58
    /**
59
     * Renvoie la liste de tous les vendeurs du module
60
     *
61
     * @param  Oledrion_parameters $parameters
62
     * @return array               tableau d'objets de type vendors
63
     * @internal param int $start Position de départ
64
     * @internal param int $limit Nombre total d'enregistrements à renvoyer
65
     * @internal param string $order Champ sur lequel faire le tri
66
     * @internal param string $order Ordre du tri
67
     * @internal param bool $idaskey Indique si le tableau renvoyé doit avoir pour clé l'identifiant unique de l'enregistrement
68
     */
69
    public function getAllVendors(Oledrion_parameters $parameters)
70
    {
71
        $parameters = $parameters->extend(new Oledrion_parameters(array(
0 ignored issues
show
new \Oledrion_parameters...C', 'idaskey' => true)) is of type object<Oledrion_parameters>, but the function expects a object<self>.

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...
72
                                                                      'start'   => 0,
73
                                                                      'limit'   => 0,
74
                                                                      'sort'    => 'vendor_name',
75
                                                                      'order'   => 'ASC',
76
                                                                      'idaskey' => true
77
                                                                  )));
78
        $critere    = new Criteria('vendor_id', 0, '<>');
79
        $critere->setLimit($parameters['limit']);
80
        $critere->setStart($parameters['start']);
81
        $critere->setSort($parameters['sort']);
82
        $critere->setOrder($parameters['order']);
83
        $categories = array();
84
        $categories = $this->getObjects($critere, $parameters['idaskey']);
85
86
        return $categories;
87
    }
88
89
    /**
90
     * Retourne le nombre de produits associés à un vendeur
91
     *
92
     * @param  integer $vendor_id L'ID du vendeur
93
     * @return integer Le nombre de produits du vendeur
94
     */
95
    public function getVendorProductsCount($vendor_id)
96
    {
97
        global $h_oledrion_products;
98
99
        return $h_oledrion_products->getVendorProductsCount($vendor_id);
100
    }
101
102
    /**
103
     * Supprime un vendeur
104
     *
105
     * @param  oledrion_vendors $vendor
106
     * @return boolean          Le résultat de la suppression
107
     */
108
    public function deleteVendor(Oledrion_vendors $vendor)
109
    {
110
        return $this->delete($vendor, true);
111
    }
112
113
    /**
114
     * Retourne des vendeurs selon leur ID
115
     *
116
     * @param  array $ids Les ID des vendeurs à retrouver
117
     * @return array Objets de type oledrion_vendors
118
     */
119 View Code Duplication
    public function getVendorsFromIds($ids)
120
    {
121
        $ret = array();
122
        if (is_array($ids) && count($ids) > 0) {
123
            $criteria = new Criteria('vendor_id', '(' . implode(',', $ids) . ')', 'IN');
124
            $ret      = $this->getObjects($criteria, true, true, '*', false);
125
        }
126
127
        return $ret;
128
    }
129
}
130