XoopsModules25x /
oledrion
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 Hossein Azizabadi ([email protected]) |
||
| 18 | */ |
||
| 19 | |||
| 20 | require __DIR__ . '/classheader.php'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Class Oledrion_delivery |
||
| 24 | */ |
||
| 25 | class Oledrion_delivery extends Oledrion_Object |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * constructor |
||
| 29 | * |
||
| 30 | * normally, this is called from child classes only |
||
| 31 | * |
||
| 32 | * @access public |
||
| 33 | */ |
||
| 34 | public function __construct() |
||
| 35 | { |
||
| 36 | $this->initVar('delivery_id', XOBJ_DTYPE_INT, null, false); |
||
| 37 | $this->initVar('delivery_title', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 38 | $this->initVar('delivery_description', XOBJ_DTYPE_TXTAREA, null, false); |
||
| 39 | $this->initVar('delivery_online', XOBJ_DTYPE_INT, null, false); |
||
| 40 | $this->initVar('delivery_image', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 41 | |||
| 42 | $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Retourne l'URL de l'image de la catégorie courante |
||
| 47 | * @return string L'URL |
||
| 48 | */ |
||
| 49 | View Code Duplication | public function getPictureUrl() |
|
| 50 | { |
||
| 51 | if (xoops_trim($this->getVar('product_image_url')) != '') { |
||
| 52 | return OLEDRION_PICTURES_URL . '/' . $this->getVar('delivery_image'); |
||
| 53 | } else { |
||
| 54 | return ''; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Indique si l'image de la catégorie existe |
||
| 60 | * |
||
| 61 | * @return boolean Vrai si l'image existe sinon faux |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function pictureExists() |
|
| 64 | { |
||
| 65 | $return = false; |
||
| 66 | if (xoops_trim($this->getVar('delivery_image')) != '' |
||
| 67 | && file_exists(OLEDRION_PICTURES_PATH . '/' . $this->getVar('delivery_image')) |
||
| 68 | ) { |
||
| 69 | $return = true; |
||
| 70 | } |
||
| 71 | |||
| 72 | return $return; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Supprime l'image associée à une catégorie |
||
| 77 | * @return void |
||
| 78 | */ |
||
| 79 | View Code Duplication | public function deletePicture() |
|
| 80 | { |
||
| 81 | if ($this->pictureExists()) { |
||
| 82 | @unlink(OLEDRION_PICTURES_PATH . '/' . $this->getVar('delivery_image')); |
||
|
0 ignored issues
–
show
|
|||
| 83 | } |
||
| 84 | $this->setVar('delivery_image', ''); |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Retourne les éléments du produits formatés pour affichage |
||
| 89 | * |
||
| 90 | * @param string $format |
||
| 91 | * @return array |
||
| 92 | */ |
||
| 93 | View Code Duplication | public function toArray($format = 's') |
|
| 94 | { |
||
| 95 | global $h_oledrion_location_delivery; |
||
| 96 | $ret = array(); |
||
| 97 | $ret = parent::toArray($format); |
||
| 98 | $ret['delivery_image_url'] = $this->getPictureUrl(); |
||
| 99 | |||
| 100 | return $ret; |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Class OledrionOledrion_deliveryHandler |
||
| 106 | */ |
||
| 107 | class OledrionOledrion_deliveryHandler extends Oledrion_XoopsPersistableObjectHandler |
||
| 108 | { |
||
| 109 | /** |
||
| 110 | * OledrionOledrion_deliveryHandler constructor. |
||
| 111 | * @param XoopsDatabase|null $db |
||
| 112 | */ |
||
| 113 | public function __construct(XoopsDatabase $db) |
||
| 114 | { // Table Classe Id |
||
| 115 | parent::__construct($db, 'oledrion_delivery', 'oledrion_delivery', 'delivery_id'); |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param Oledrion_parameters $parameters |
||
| 120 | * @return array |
||
| 121 | */ |
||
| 122 | View Code Duplication | public function getAllDelivery(Oledrion_parameters $parameters) |
|
| 123 | { |
||
| 124 | $parameters = $parameters->extend(new Oledrion_parameters(array( |
||
|
0 ignored issues
–
show
new \Oledrion_parameters...id', 'order' => 'ASC')) 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...
|
|||
| 125 | 'start' => 0, |
||
| 126 | 'limit' => 0, |
||
| 127 | 'sort' => 'delivery_id', |
||
| 128 | 'order' => 'ASC' |
||
| 129 | ))); |
||
| 130 | $critere = new Criteria('delivery_id', 0, '<>'); |
||
| 131 | $critere->setLimit($parameters['limit']); |
||
| 132 | $critere->setStart($parameters['start']); |
||
| 133 | $critere->setSort($parameters['sort']); |
||
| 134 | $critere->setOrder($parameters['order']); |
||
| 135 | $categories = array(); |
||
| 136 | $categories = $this->getObjects($critere); |
||
| 137 | |||
| 138 | return $categories; |
||
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @param Oledrion_parameters $parameters |
||
| 143 | * @return array |
||
| 144 | */ |
||
| 145 | public function getLocationDelivery(Oledrion_parameters $parameters) |
||
| 146 | { |
||
| 147 | global $h_oledrion_location_delivery; |
||
| 148 | $ret = array(); |
||
| 149 | $parameters = $parameters->extend(new Oledrion_parameters(array( |
||
|
0 ignored issues
–
show
new \Oledrion_parameters...SC', 'location' => '')) 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...
|
|||
| 150 | 'start' => 0, |
||
| 151 | 'limit' => 0, |
||
| 152 | 'sort' => 'delivery_id', |
||
| 153 | 'order' => 'ASC', |
||
| 154 | 'location' => '' |
||
| 155 | ))); |
||
| 156 | $location_delivery = $h_oledrion_location_delivery->getLocationDeliveryId($parameters); |
||
| 157 | |||
| 158 | $critere = new CriteriaCompo(); |
||
| 159 | $critere->setLimit($parameters['limit']); |
||
| 160 | $critere->setStart($parameters['start']); |
||
| 161 | $critere->setSort($parameters['sort']); |
||
| 162 | $critere->setOrder($parameters['order']); |
||
| 163 | $obj = $this->getObjects($critere); |
||
| 164 | if ($obj) { |
||
| 165 | foreach ($obj as $root) { |
||
| 166 | $tab = array(); |
||
| 167 | $tab = $root->toArray(); |
||
| 168 | if (isset($location_delivery[$root->getVar('delivery_id')]['ld_delivery']) |
||
| 169 | && $location_delivery[$root->getVar('delivery_id')]['ld_delivery'] == $root->getVar('delivery_id') |
||
| 170 | ) { |
||
| 171 | $tab['ld_id']['delivery_select'] = 1; |
||
| 172 | $tab['ld_id']['ld_id'] = $location_delivery[$root->getVar('delivery_id')]['ld_id']; |
||
| 173 | $tab['ld_id']['ld_location'] = $location_delivery[$root->getVar('delivery_id')]['ld_location']; |
||
| 174 | $tab['ld_id']['ld_delivery'] = $location_delivery[$root->getVar('delivery_id')]['ld_delivery']; |
||
| 175 | $tab['ld_id']['ld_price'] = $location_delivery[$root->getVar('delivery_id')]['ld_price']; |
||
| 176 | $tab['ld_id']['ld_delivery_time'] = $location_delivery[$root->getVar('delivery_id')]['ld_delivery_time']; |
||
| 177 | } |
||
| 178 | $ret[] = $tab; |
||
| 179 | } |
||
| 180 | } |
||
| 181 | |||
| 182 | return $ret; |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @param $location_id |
||
| 187 | * @return array |
||
| 188 | */ |
||
| 189 | public function getThisLocationDelivery($location_id) |
||
| 190 | { |
||
| 191 | global $h_oledrion_location_delivery; |
||
| 192 | $oledrion_Currency = Oledrion_Currency::getInstance(); |
||
| 193 | $ret = array(); |
||
| 194 | $parameters = array('location' => $location_id); |
||
| 195 | $location_delivery = $h_oledrion_location_delivery->getLocationDeliveryId($parameters); |
||
| 196 | foreach ($location_delivery as $location) { |
||
| 197 | $id[] = $location['ld_delivery']; |
||
| 198 | } |
||
| 199 | |||
| 200 | $critere = new CriteriaCompo(); |
||
| 201 | $critere->add(new Criteria('delivery_id', '(' . implode(',', $id) . ')', 'IN')); |
||
| 202 | $critere->add(new Criteria('delivery_online', 1)); |
||
| 203 | $obj = $this->getObjects($critere); |
||
| 204 | if ($obj) { |
||
| 205 | foreach ($obj as $root) { |
||
| 206 | $tab = array(); |
||
|
0 ignored issues
–
show
$tab 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 Loading history...
|
|||
| 207 | $tab = $root->toArray(); |
||
| 208 | $tab['delivery_price'] = $location_delivery[$root->getVar('delivery_id')]['ld_price']; |
||
| 209 | $tab['delivery_price_fordisplay'] = $oledrion_Currency->amountForDisplay($tab['delivery_price']); |
||
| 210 | $tab['delivery_time'] = $location_delivery[$root->getVar('delivery_id')]['ld_delivery_time']; |
||
| 211 | $ret[] = $tab; |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | return $ret; |
||
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @param $location_id |
||
| 220 | * @param $delivery_id |
||
| 221 | * @return array |
||
| 222 | */ |
||
| 223 | public function getThisLocationThisDelivery($location_id, $delivery_id) |
||
| 224 | { |
||
| 225 | global $h_oledrion_location_delivery; |
||
| 226 | $location_delivery = $h_oledrion_location_delivery->getDelivery($location_id, $delivery_id); |
||
| 227 | $ret = array(); |
||
| 228 | $obj = $this->get($location_id); |
||
| 229 | $ret = $obj->toArray(); |
||
| 230 | $ret['delivery_price'] = $location_delivery['ld_price']; |
||
| 231 | $ret['delivery_time'] = $location_delivery['ld_delivery_time']; |
||
| 232 | |||
| 233 | return $ret; |
||
| 234 | } |
||
| 235 | } |
||
| 236 |
If you suppress an error, we recommend checking for the error condition explicitly: