<?php if (!isConnect('admin')) { throw new Exception('{{401 - Accès non autorisé}}'); } if (init('id') != '') { $market = market::byId(init('id')); } if (init('logicalId') != '' && init('type') != '') { $market = market::byLogicalIdAndType(init('logicalId'), init('type')); } if (!isset($market)) { throw new Exception('404 not found'); } include_file('3rdparty', 'bootstrap.rating/bootstrap.rating', 'js'); include_file('3rdparty', 'slick/slick.min', 'js'); include_file('3rdparty', 'slick/slick', 'css'); include_file('3rdparty', 'slick/slick-theme', 'css'); include_file('3rdparty', 'fancybox/jquery.fancybox', 'js'); include_file('3rdparty', 'fancybox/jquery.fancybox', 'css'); $market_array = utils::o2a($market); $market_array['rating'] = $market->getRating(); $update = update::byLogicalId($market->getLogicalId()); sendVarToJS('market_display_info', $market_array); ?> <div class='row' style='background-color: #e7e7e7; padding-top: 10px; padding-bottom: 10px;position: relative; top: -10px;'> <div class='col-sm-3'> <center> <?php
utils::a2o($market, $market_ajax); $market->save(); ajax::success(); } if (init('action') == 'getInfo') { ajax::success(market::getInfo(init('logicalId'))); } if (init('action') == 'byLogicalId') { if (init('noExecption', 0) == 1) { try { ajax::success(utils::o2a(market::byLogicalIdAndType(init('logicalId'), init('type')))); } catch (Exception $e) { ajax::success(); } } else { ajax::success(utils::o2a(market::byLogicalIdAndType(init('logicalId'), init('type')))); } } if (init('action') == 'test') { ajax::success(market::test()); } if (init('action') == 'setRating') { $market = market::byId(init('id')); if (!is_object($market)) { throw new Exception(__('Impossible de trouver l\'objet associé : ', __FILE__) . init('id')); } $market->setRating(init('rating')); ajax::success(); } if (init('action') == 'setComment') { $market = market::byId(init('id'));
public static function getInfo($_logicalId, $_version = 'stable') { $returns = array(); if (is_array($_logicalId) && is_array($_version) && count($_logicalId) == count($_version)) { if (is_array(reset($_logicalId))) { $markets = market::byLogicalIdAndType($_logicalId); } else { $markets = market::byLogicalId($_logicalId); } $returns = array(); for ($i = 0; $i < count($_logicalId); $i++) { if (is_array($_logicalId[$i])) { $logicalId = $_logicalId[$i]['type'] . $_logicalId[$i]['logicalId']; } else { $logicalId = $_logicalId[$i]; } $return['datetime'] = '0000-01-01 00:00:00'; if ($logicalId == '' || config::byKey('market::address') == '') { $return['market'] = 0; $return['market_owner'] = 0; $return['status'] = 'ok'; return $return; } if (config::byKey('market::username') != '' && config::byKey('market::password') != '') { $return['market_owner'] = 1; } else { $return['market_owner'] = 0; } $return['market'] = 0; try { if (isset($markets[$logicalId])) { $market = $markets[$logicalId]; if (!is_object($market)) { $return['status'] = 'ok'; } else { $return['datetime'] = $market->getDatetime($_version[$i]); $return['market'] = 1; $return['market_owner'] = $market->getIsAuthor(); $update = update::byTypeAndLogicalId($market->getType(), $market->getLogicalId()); $updateDateTime = '0000-01-01 00:00:00'; if (is_object($update)) { $updateDateTime = $update->getLocalVersion(); } if ($updateDateTime < $market->getDatetime($_version[$i], $updateDateTime)) { $return['status'] = 'update'; } else { $return['status'] = 'ok'; } } } else { $return['status'] = 'ok'; } } catch (Exception $e) { log::add('market', 'debug', __('Erreur market::getinfo : ', __FILE__) . $e->getMessage()); $return['status'] = 'ok'; } $returns[$logicalId] = $return; } return $returns; } $return = array(); $return['datetime'] = '0000-01-01 00:00:00'; if (config::byKey('market::address') == '') { $return['market'] = 0; $return['market_owner'] = 0; $return['status'] = 'ok'; return $return; } if (config::byKey('market::username') != '' && config::byKey('market::password') != '') { $return['market_owner'] = 1; } else { $return['market_owner'] = 0; } $return['market'] = 0; try { if (is_array($_logicalId)) { $market = market::byLogicalIdAndType($_logicalId['logicalId'], $_logicalId['type']); } else { $market = market::byLogicalId($_logicalId); } if (!is_object($market)) { $return['status'] = 'depreciated'; } else { $return['datetime'] = $market->getDatetime($_version); $return['market'] = 1; $return['market_owner'] = $market->getIsAuthor(); $update = update::byTypeAndLogicalId($market->getType(), $market->getLogicalId()); $updateDateTime = '0000-01-01 00:00:00'; if (is_object($update)) { $updateDateTime = $update->getLocalVersion(); } if ($updateDateTime < $market->getDatetime($_version, $updateDateTime)) { $return['status'] = 'update'; } else { $return['status'] = 'ok'; } } } catch (Exception $e) { log::add('market', 'debug', __('Erreur market::getinfo : ', __FILE__) . $e->getMessage()); $return['status'] = 'ok'; } return $return; }
public function deleteObjet() { if ($this->getType() == 'core') { throw new Exception('Vous ne pouvez pas supprimer le core de Jeedom'); } else { try { $market = market::byLogicalIdAndType($this->getLogicalId(), $this->getType()); } catch (Exception $e) { $market = new market(); $market->setLogicalId($this->getLogicalId()); $market->setType($this->getType()); } try { if (is_object($market)) { $market->remove(); } } catch (Exception $e) { } $this->remove(); } }