public function stackData($params) { if (is_object($params)) { $paramsArray = utils::o2a($params); } nodejs::pushUpdate('influxdb::stackDataEqLogic', $paramsArray); }
public function execute($_options = array()) { $array = utils::o2a($this); if (isset($_options['utid'])) { $array['utid'] = $_options['utid']; } if ($this->getLogicalId() == 'close') { event::add('clink::close', $array); } else { event::add('clink::open', $array); } }
public function toAjax() { $return = utils::o2a($this); $return['viewZone'] = array(); foreach ($this->getViewZone() as $viewZone) { $viewZone_info = utils::o2a($viewZone); $viewZone_info['viewData'] = array(); foreach ($viewZone->getViewData() as $viewData) { $viewData_info = utils::o2a($viewData); $viewData_info['name'] = ''; switch ($viewData->getType()) { case 'cmd': $cmd = $viewData->getLinkObject(); if (is_object($cmd)) { $viewData_info['type'] = 'cmd'; $viewData_info['name'] = $cmd->getHumanName(); $viewData_info['id'] = $cmd->getId(); $viewData_info['html'] = $cmd->toHtml(init('version', 'dashboard')); } break; case 'eqLogic': $eqLogic = $viewData->getLinkObject(); if (is_object($eqLogic)) { $viewData_info['type'] = 'eqLogic'; $viewData_info['name'] = $eqLogic->getHumanName(); $viewData_info['id'] = $eqLogic->getId(); $viewData_info['html'] = $eqLogic->toHtml(init('version', 'dashboard')); } break; case 'scenario': $scenario = $viewData->getLinkObject(); if (is_object($scenario)) { $viewData_info['type'] = 'scenario'; $viewData_info['name'] = $scenario->getHumanName(); $viewData_info['id'] = $scenario->getId(); $viewData_info['html'] = $scenario->toHtml(init('version', 'dashboard')); } break; } $viewZone_info['viewData'][] = $viewData_info; } $return['viewZone'][] = $viewZone_info; } return $return; }
} } foreach ($eqReal_db->getEqLogic() as $eqLogic_db) { if (!isset($enable_eqLogic[$eqLogic_db->getId()])) { $eqLogic_db->remove(); } } break; } } ajax::success(); } if (init('action') == 'getJeenodeConf') { $jeenodeReal = jeenodeReal::byId(init('jeenodeRealId')); if (!is_object($jeenodeReal)) { throw new Exception('JeenodeReal inconnu verifié l\'id'); } $return = utils::o2a($jeenodeReal); $return['port'] = array(); foreach ($jeenodeReal->getEqLogic() as $eqLogic) { $portConfiguration = utils::o2a($eqLogic); $portConfiguration['cmd'] = utils::o2a($eqLogic->getCmd()); $return['port'][] = $portConfiguration; } ajax::success($return); } throw new Exception('Aucune methode correspondante'); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
try { require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (init('action') == 'getInfoApplication') { if (!isConnect()) { throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); } $_SESSION['user']->refresh(); $return = array(); $return['user_id'] = $_SESSION['user']->getId(); $return['nodeJsKey'] = config::byKey('nodeJsKey'); $return['userProfils'] = $_SESSION['user']->getOptions(); $return['plugins'] = array(); foreach (plugin::listPlugin(true) as $plugin) { if ($plugin->getMobile() != '') { $return['plugins'][] = utils::o2a($plugin); } } $return['custom'] = array(); $return['custom']['js'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.js'); $return['custom']['css'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.css'); ajax::success($return); } if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'ssh') { ajax::success(shell_exec(init('command'))); } if (init('action') == 'update') { jeedom::update();
public function export() { $cmd = clone $this; $cmd->setId(''); $cmd->setOrder(''); $cmd->setEqLogic_id(''); $cmd->cache = ''; $cmd->setDisplay('graphType', ''); $cmdValue = $cmd->getCmdValue(); if (is_object($cmdValue)) { $cmd->setValue($cmdValue->getName()); } else { $cmd->setValue(''); } $return = utils::o2a($cmd); foreach ($return as $key => $value) { if (is_array($value)) { foreach ($value as $key2 => $value2) { if ($value2 == '') { unset($return[$key][$key2]); } } } else { if ($value == '') { unset($return[$key]); } } } if (isset($return['configuration']) && count($return['configuration']) == 0) { unset($return['configuration']); } if (isset($return['display']) && count($return['display']) == 0) { unset($return['display']); } return $return; }
public function getAjaxElement($_mode = 'ajax') { $return = utils::o2a($this); if ($_mode == 'array') { if (isset($return['id'])) { unset($return['id']); } if (isset($return['scenarioElement_id'])) { unset($return['scenarioElement_id']); } if (isset($return['log'])) { unset($return['log']); } if (isset($return['_expression'])) { unset($return['_expression']); } } $return['subElements'] = array(); foreach ($this->getSubElement() as $subElement) { $subElement_ajax = utils::o2a($subElement); if ($_mode == 'array') { if (isset($subElement_ajax['id'])) { unset($subElement_ajax['id']); } if (isset($subElement_ajax['scenarioElement_id'])) { unset($subElement_ajax['scenarioElement_id']); } if (isset($subElement_ajax['log'])) { unset($subElement_ajax['log']); } if (isset($subElement_ajax['_expression'])) { unset($subElement_ajax['_expression']); } } $subElement_ajax['expressions'] = array(); foreach ($subElement->getExpression() as $expression) { $expression_ajax = utils::o2a($expression); if ($_mode == 'array') { if (isset($expression_ajax['id'])) { unset($expression_ajax['id']); } if (isset($expression_ajax['scenarioSubElement_id'])) { unset($expression_ajax['scenarioSubElement_id']); } if (isset($expression_ajax['log'])) { unset($expression_ajax['log']); } if (isset($expression_ajax['_expression'])) { unset($expression_ajax['_expression']); } } if ($expression->getType() == 'element') { $element = self::byId($expression->getExpression()); if (is_object($element)) { $expression_ajax['element'] = $element->getAjaxElement($_mode); if ($_mode == 'array') { if (isset($expression_ajax['element']['id'])) { unset($expression_ajax['element']['id']); } if (isset($expression_ajax['element']['scenarioElement_id'])) { unset($expression_ajax['element']['scenarioElement_id']); } if (isset($expression_ajax['element']['log'])) { unset($expression_ajax['element']['log']); } if (isset($expression_ajax['element']['_expression'])) { unset($expression_ajax['element']['_expression']); } } } } $expression_ajax = jeedom::toHumanReadable($expression_ajax); $subElement_ajax['expressions'][] = $expression_ajax; } $return['subElements'][] = $subElement_ajax; } return $return; }
</div> <div class="form-group"> <label class="col-sm-3 control-label">{{Changement}}</label> <div class="col-sm-9"> <textarea class="form-control" id="ta_marketSendChange" placeholder="{{Changement}}" style="height: 150px;"></textarea> </div> </div> <a class="btn btn-success pull-right" id="bt_marketSendValideChange"><i class="fa fa-check"></i> {{Valider}}</a> <a class="btn btn-default pull-right" id="bt_marketSendCancelChange"><i class="fa fa-times"></i> {{Annuler}}</a> </form> </div> <?php if (is_object($market)) { sendVarToJS('market_display_info', utils::o2a($market)); } ?> <script> $("#md_marketSendChangeChange").dialog({ autoOpen: false, modal: true, height: 400, width:700, position: {my: 'center', at: 'center', of: window}, open: function () { $("body").css({overflow: 'hidden'}); }, beforeClose: function (event, ui) { $("body").css({overflow: 'inherit'}); }
} if (is_numeric(init('id'))) { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { throw new Exception(__('Cmd ID inconnu : ', __FILE__) . init('id')); } $eqLogic = $cmd->getEqLogic(); if (!$eqLogic->hasRight('r')) { throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $histories = $cmd->getHistory($dateStart, $dateEnd); $return['cmd_name'] = $cmd->getName(); $return['history_name'] = $cmd->getHumanName(); $return['unite'] = $cmd->getUnite(); $return['cmd'] = utils::o2a($cmd); $return['eqLogic'] = utils::o2a($cmd->getEqLogic()); $previsousValue = null; $derive = init('derive', $cmd->getDisplay('graphDerive')); if (trim($derive) == '') { $derive = $cmd->getDisplay('graphDerive'); } foreach ($histories as $history) { $info_history = array(); $info_history[] = floatval(strtotime($history->getDatetime() . " UTC")) * 1000; $value = $history->getValue() === null ? null : floatval($history->getValue()); if ($derive == 1 || $derive == '1') { if ($value !== null && $previsousValue != null) { $value = $value - $previsousValue; } else { $value = null; }
public function save() { $cache = cache::byKey('market::info::' . $this->getLogicalId()); if (is_object($cache)) { $cache->remove(); } $market = self::getJsonRpc(); $params = utils::o2a($this); if (isset($params['changelog'])) { unset($params['changelog']); } switch ($this->getType()) { case 'plugin': $cibDir = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId(); if (file_exists($cibDir)) { rrmdir($cibDir); } mkdir($cibDir); $exclude = array('tmp'); rcopy(realpath(dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId()), $cibDir, true, $exclude, true); $tmp = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId() . '.zip'; if (file_exists($tmp)) { if (!unlink($tmp)) { throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__)); } } if (!create_zip($cibDir, $tmp)) { throw new Exception(__('Echec de création de l\'archive zip', __FILE__)); } break; default: $type = $this->getType(); if (!class_exists($type) || !method_exists($type, 'shareOnMarket')) { throw new Exception(__('Aucune fonction correspondante à : ', __FILE__) . $type . '::shareOnMarket'); } $tmp = $type::shareOnMarket($this); break; } if (!file_exists($tmp)) { throw new Exception(__('Impossible de trouver le fichier à envoyer : ', __FILE__) . $tmp); } $file = array('file' => '@' . realpath($tmp)); if (!$market->sendRequest('market::save', $params, 30, $file)) { throw new Exception($market->getError()); } $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); if (!is_object($update)) { $update = new update(); $update->setLogicalId($this->getLogicalId()); $update->setType($this->getType()); } $update->setConfiguration('version', 'beta'); $update->setLocalVersion(date('Y-m-d H:i:s', strtotime('+10 minute' . date('Y-m-d H:i:s')))); $update->save(); $update->checkUpdate(); }
<?php if (!isConnect('admin')) { throw new Exception('{{401 - Accès non autorisé}}'); } $cmd = cmd::byId(init('cmd_id')); if (!is_object($cmd)) { throw new Exception('Commande non trouvé : ' . init('cmd_id')); } sendVarToJS('cmdInfo', jeedom::toHumanReadable(utils::o2a($cmd))); $cmd_widgetDashboard = cmd::availableWidget('dashboard'); $cmd_widgetMobile = cmd::availableWidget('mobile'); ?> <div style="display: none;" id="md_displayCmdConfigure"></div> <a class="btn btn-success btn-sm pull-right" id="bt_cmdConfigureSave"><i class="fa fa-check-circle"></i> {{Enregistrer}}</a> <a class="btn btn-default pull-right btn-sm" id="bt_cmdConfigureSaveOn"><i class="fa fa-plus-circle"></i> {{Appliquer à}}</a> <div role="tabpanel"> <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"><a href="#information" aria-controls="home" role="tab" data-toggle="tab"><i class="fa fa-info-circle"></i> {{Informations}}</a></li> <li role="presentation"><a href="#configuration" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-wrench"></i> {{Configuration avancée}}</a></li> <li role="presentation"><a href="#display" aria-controls="messages" role="tab" data-toggle="tab"><i class="fa fa-desktop"></i> {{Affichage avancé}}</a></li> </ul> <div class="tab-content" id="div_displayCmdConfigure"> <div role="tabpanel" class="tab-pane active" id="information"> <br/>
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'));
if (init('action') == 'savePlanHeader') { $planHeader_ajax = json_decode(init('planHeader'), true); $planHeader = planHeader::byId($planHeader_ajax['id']); if (!is_object($planHeader)) { $planHeader = new planHeader(); } utils::a2o($planHeader, $planHeader_ajax); $planHeader->save(); ajax::success(utils::o2a($planHeader)); } if (init('action') == 'copyPlanHeader') { $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { throw new Exception(__('Plan header inconnu verifié l\'id : ', __FILE__) . init('id')); } ajax::success(utils::o2a($planHeader->copy(init('name')))); } if (init('action') == 'uploadImage') { $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { throw new Exception(__('Objet inconnu verifié l\'id', __FILE__)); } if (!isset($_FILES['file'])) { throw new Exception(__('Aucun fichier trouvé. Vérifié parametre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.jpg', '.png'))) { throw new Exception('Extension du fichier non valide (autorisé .jpg .png) : ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { throw new Exception(__('Le fichier est trop gros (maximum 5mo)', __FILE__));
public function export($_withCmd = true) { $eqLogic = clone $this; $eqLogic->setId(''); $eqLogic->setLogicalId(''); $eqLogic->setObject_id(''); $eqLogic->setIsEnable(''); $eqLogic->setIsVisible(''); $eqLogic->setTimeout(''); $eqLogic->setOrder(''); $eqLogic->setConfiguration('nerverFail', ''); $eqLogic->setConfiguration('noBatterieCheck', ''); $return = utils::o2a($eqLogic); foreach ($return as $key => $value) { if (is_array($value)) { foreach ($value as $key2 => $value2) { if ($value2 == '') { unset($return[$key][$key2]); } } } else { if ($value == '') { unset($return[$key]); } } } if (isset($return['configuration']) && count($return['configuration']) == 0) { unset($return['configuration']); } if (isset($return['display']) && count($return['display']) == 0) { unset($return['display']); } if ($_withCmd) { $return['cmd'] = array(); foreach ($this->getCmd() as $cmd) { $return['cmd'][] = $cmd->export(); } } return $return; }
} if (filesize($_FILES['file']['tmp_name']) > 5000000) { throw new Exception(__('Le fichier est trop gros (miximum 5mo)', __FILE__)); } $object->setImage('type', str_replace('.', '', $extension)); $object->setImage('size', getimagesize($_FILES['file']['tmp_name'])); $object->setImage('data', base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $object->save(); ajax::success(); } if (init('action') == 'getChild') { $object = object::byId(init('id')); if (!is_object($object)) { throw new Exception(__('Objet inconnu verifié l\'id', __FILE__)); } $return = utils::o2a($object->getChild()); ajax::success($return); } if (init('action') == 'toHtml') { if (init('id') == 'all' || is_json(init('id'))) { if (is_json(init('id'))) { $object_ajax = json_decode(init('id'), true); $objects = array(); foreach ($object_ajax as $id) { $objects[] = object::byId($id); } } else { $objects = object::all(); } $return = array(); foreach ($objects as $object) {
$interactQuery->save(); } } ajax::success(); } if (init('action') == 'execute') { ajax::success(interactQuery::tryToReply(init('query'))); } if (init('action') == 'test') { $return = array(); $interactQuery = interactQuery::recognize(init('query')); if ($interactQuery == null) { ajax::success(array('interactQuery' => null)); } $interactDef = interactDef::byId($interactQuery->getInteractDef_id()); $return['interactQuery'] = utils::o2a($interactQuery); if ($interactQuery->getLink_type() == 'cmd') { $return['cmd'] = ''; foreach (explode('&&', $interactQuery->getLink_id()) as $cmd_id) { $cmd = cmd::byId($cmd_id); if (is_object($cmd)) { $return['cmd'] .= '#' . $cmd->getHumanName() . '# && '; } } $return['cmd'] = trim($return['cmd'], '&& '); $reply = $interactDef->selectReply(); if (trim($reply) == '') { $reply = interactQuery::replyOk(); } $return['reply'] = $reply; }
* Jeedom is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ try { require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'all') { ajax::success(utils::o2a(update::all(init('filter')))); } if (init('action') == 'checkAllUpdate') { update::checkAllUpdate(); ajax::success(); } if (init('action') == 'update') { log::clear('update'); $update = update::byId(init('id')); if (!is_object($update)) { throw new Exception(__('Aucune correspondance pour l\'ID : ' . init('id'), __FILE__)); } try { if ($update->getType() != 'core') { log::add('update', 'update', __("[START UPDATE]\n", __FILE__)); }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ try { require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if (init('action') == 'getWeather') { $weather = weather::byId(init('id')); if (!is_object($weather)) { throw new Exception(__('Weather inconnu verifié l\'id', __FILE__)); } $return = utils::o2a($weather); $return['cmd'] = array(); foreach ($weather->getCmd() as $cmd) { $cmd_info = utils::o2a($cmd); $cmd_info['value'] = $cmd->execCmd(null, 0); $return['cmd'][] = $cmd_info; } ajax::success($return); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
$widget_db = widget::byPath($widget['path']); if (!is_object($widget_db)) { $widget_db = new widget(); } } else { $widget_db = new widget(); } utils::a2o($widget_db, $widget_ajax); $widget_db->save(); ajax::success(utils::o2a($widget_db)); } if (init('action') == 'add') { $widget = new widget(); $widget->setName(init('name')); $widget->save(); ajax::success(utils::o2a($widget)); } if (init('action') == 'remove') { $widget = widget::byPath(init('path')); if (!is_object($widget)) { throw new Exception('Widget non trouvé : ' . init('path')); } $widget->remove(); ajax::success(); } if (init('action') == 'applyWidget') { if (init('path') != 'default') { $widget = widget::byPath(init('path')); if (!is_object($widget)) { throw new Exception('Widget non trouvé : ' . init('path')); }
<span>({{Valeur obligatoire}})</span> </div> <div class="form-group"> <label class="col-sm-2 control-label">{{Texte d'information}}</label> <div class="col-sm-3"> <input type="text" id="gCalendar_texte" class="eqLogicAttr form-control"/> </div> <span>({{Valeur non obligatoire}}, {{s'affiche sur le calendrier à coté du nom du scénario}})</span> </div> <div class="form-group"> <label class="col-sm-2 control-label" >{{Nom de la variable}}</label> <div class="col-sm-3"> <select id="gCalendar_variable" class="eqLogicAttr form-control"> <option value="">{{Aucune}}</option> <?php foreach (utils::o2a(dataStore::byTypeLinkId('scenario')) as $_aVarScenario) { echo '<option value="' . $_aVarScenario['key'] . '">' . $_aVarScenario['key'] . '</option>'; } ?> </select> </div> <span>({{Variable obligatoire, si la valeur de début et/ou de fin est renseignée}})</span> </div> <div class="form-group"> <label class="col-sm-2 control-label">{{Valeur variable 1ère minute}}</label> <div class="col-sm-3"> <input type="text" id="gCalendar_valFirst" class="eqLogicAttr form-control"/> </div> <span>({{Valeur non obligatoire}} ; {{permet d'envoyer une valeur à la variable utilisée dans le scénario, pour la 1ère minute de la période}})</span> </div> <div class="form-group">
$dataStore = new dataStore(); $dataStore->setKey(init('key')); $dataStore->setLink_id(init('link_id')); $dataStore->setType(init('type')); } else { $dataStore = dataStore::byId(init('id')); } if (!is_object($dataStore)) { throw new Exception(__('Data store inconnu vérifer l\'id : ', __FILE__) . init('id')); } $dataStore->setValue(init('value')); $dataStore->save(); ajax::success(); } if (init('action') == 'all') { $datastores = utils::o2a(dataStore::byTypeLinkId(init('type'))); if (init('usedBy') == 1) { foreach ($datastores as &$datastore) { $datastore['usedBy'] = array('scenario' => array()); foreach (scenario::byUsedCommand($datastore['key'], true) as $scenario) { $datastore['usedBy']['scenario'][] = $scenario->getHumanName(); } } } ajax::success($datastores); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
<?php if (!isConnect('admin')) { throw new Exception('{{401 - Accès non autorisé}}'); } $object = object::byId(init('object_id')); if (!is_object($object)) { throw new Exception('Objet non trouvé : ' . init('object_id')); } sendVarToJS('objectInfo', utils::o2a($object)); ?> <div id='div_displayObjectConfigure'> <legend>{{Informations}}</legend> <div class="row"> <form class="form-horizontal"> <fieldset> <div class="form-group"> <label class="col-lg-2 col-md-3 col-sm-4 col-xs-6 control-label">{{ID}}</label> <div class="col-sm-4"> <span class="objectAttr label label-primary" data-l1key="id"></span> </div> </div> <div class="form-group"> <label class="col-lg-2 col-md-3 col-sm-4 col-xs-6 control-label">{{Nom}}</label> <div class="col-sm-4"> <span class="objectAttr label label-primary" data-l1key="name"></span> </div> </div> <div class="form-group">
<?php if (!isConnect('admin')) { throw new Exception('{{401 - Accès non autorisé}}'); } $eqLogic = eqLogic::byId(init('eqLogic_id')); if (!is_object($eqLogic)) { throw new Exception('EqLogic non trouvé : ' . init('eqLogic_id')); } sendVarToJS('eqLogicInfo', utils::o2a($eqLogic)); ?> <div style="display: none;" id="md_displayEqLogicConfigure"></div> <a class="btn btn-danger pull-right btn-sm" id="bt_eqLogicConfigureRemove"><i class="fa fa-times"></i> {{Supprimer}}</a> <a class="btn btn-success pull-right btn-sm" id="bt_eqLogicConfigureSave"><i class="fa fa-check-circle"></i> {{Enregistrer}}</a> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"><a href="#information" aria-controls="home" role="tab" data-toggle="tab">{{Informations}}</a></li> <li role="presentation"><a href="#display" aria-controls="messages" role="tab" data-toggle="tab">{{Affichage avancé}}</a></li> </ul> <div class="tab-content" id="div_displayEqLogicConfigure"> <div role="tabpanel" class="tab-pane active" id="information"> <br/> <div class="row"> <div class="col-sm-4" > <form class="form-horizontal"> <fieldset> <div class="form-group"> <label class="col-sm-4 control-label">{{ID}}</label> <div class="col-sm-4">
public static function getObjectData($_object_id, $_startDate = null, $_endDate = null) { $object = object::byId($_object_id); if (!is_object($object)) { throw new Exception('Objet non trouvé vérifiez l\'id : ' . $_object_id); } $intervals = array(); $total = null; $return = array('real' => array('power' => 0, 'consumption' => 0), 'history' => array('power' => array(), 'consumption' => array()), 'category' => array(), 'details' => array()); $childs = array_merge($object->getEqLogic(), $object->getChilds()); foreach ($childs as $child) { $datas = null; $energy = null; if (get_class($child) == 'object') { $datas = self::getObjectData($child->getId(), $_startDate, $_endDate); } else { $energy = self::byEqLogic_id($child->getId()); if (is_object($energy)) { $datas = $energy->getData($_startDate, $_endDate); if ($energy->getOptions('positionRelative') == 'total') { $total = $energy; $totalData = $datas; } else { if (!isset($return['category'][$energy->getCategory()])) { $return['category'][$energy->getCategory()] = array('data' => array('name' => $energy->getCategory(), 'real' => array('power' => 0, 'consumption' => 0), 'history' => array('power' => array(), 'consumption' => array()))); } $return['category'][$energy->getCategory()]['data']['real']['power'] += $datas['real']['power']; $return['category'][$energy->getCategory()]['data']['real']['consumption'] += $datas['real']['consumption']; } } } if (is_array($datas)) { $details = array('name' => $child->getHumanName(), get_class($child) => utils::o2a($child), 'data' => $datas); if (!is_object($energy) || $energy->getOptions('positionRelative') != 'total') { if (is_array($return['history']['power'])) { ksort($datas['history']['power']); $alreadyAdd = array(); foreach ($datas['history']['power'] as $datetime => $power) { if (!isset($return['history']['power'][$datetime])) { $prevValue = self::searchPrevisous($return['history']['power'], $datetime); if (count($prevValue) == 2) { if (isset($alreadyAdd[$prevValue[0] / 1000])) { $return['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1] - $datas['history']['power'][$prevValue[0] / 1000][1]); } else { $return['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1]); } } else { $return['history']['power'][$datetime] = array($datetime * 1000, 0); } } $return['history']['power'][$datetime][1] += $power[1]; /* * **********************Ajout a la catégorie**************************** */ if (is_object($energy)) { if (!isset($return['category'][$energy->getCategory()]['data']['history']['power'][$datetime])) { $prevValue = self::searchPrevisous($return['category'][$energy->getCategory()]['data']['history']['power'], $datetime); if (count($prevValue) == 2) { if (isset($alreadyAdd[$prevValue[0] / 1000])) { $return['category'][$energy->getCategory()]['data']['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1] - $datas['history']['power'][$prevValue[0] / 1000][1]); } else { $return['category'][$energy->getCategory()]['data']['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1]); } } else { $return['category'][$energy->getCategory()]['data']['history']['power'][$datetime] = array($datetime * 1000, 0); } } $return['category'][$energy->getCategory()]['data']['history']['power'][$datetime][1] += $power[1]; } $intervals[$datetime] = $datetime; $alreadyAdd[$datetime] = $datetime; } } if (is_array($datas['history']['consumption'])) { ksort($datas['history']['consumption']); $alreadyAdd = array(); foreach ($datas['history']['consumption'] as $datetime => $consumption) { if (!isset($return['history']['consumption'][$datetime])) { $prevValue = self::searchPrevisous($return['history']['consumption'], $datetime); if (count($prevValue) == 2) { if (isset($alreadyAdd[$prevValue[0] / 1000])) { $prevValue[1] = $prevValue[1] - $datas['history']['consumption'][$prevValue[0] / 1000][1]; } $return['history']['consumption'][$datetime] = array($datetime * 1000, $prevValue[1] >= 0 ? $prevValue[1] : 0); } else { $return['history']['consumption'][$datetime] = array($datetime * 1000, 0); } } $return['history']['consumption'][$datetime][1] += $consumption[1]; $intervals[$datetime] = $datetime; $alreadyAdd[$datetime] = $datetime; } } $return['details'][] = $details; $return['real']['power'] += $datas['real']['power']; $return['real']['consumption'] += $datas['real']['consumption']; } /* * *******************Calcul sur les categories******************************* */ if (isset($datas['category'])) { foreach ($datas['category'] as $name => $category) { if (!isset($return['category'][$name])) { $return['category'][$name] = array('name' => $name, 'data' => array('history' => array('power' => array(), 'consumption' => array()), 'real' => array('power' => 0, 'consumption' => 0))); } if (is_array($category['data']['history']['power'])) { ksort($category['data']['history']['power']); $alreadyAdd = array(); foreach ($category['data']['history']['power'] as $datetime => $power) { if (!isset($return['category'][$name]['data']['history']['power'][$datetime])) { $prevValue = self::searchPrevisous($return['category'][$name]['data']['history']['power'], $datetime); if (count($prevValue) == 2) { if (isset($alreadyAdd[$prevValue[0] / 1000])) { $return['category'][$name]['data']['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1] - $category['data']['history']['power'][$prevValue[0] / 1000][1]); } else { $return['category'][$name]['data']['history']['power'][$datetime] = array($datetime * 1000, $prevValue[1]); } } else { $return['category'][$name]['data']['history']['power'][$datetime] = array($datetime * 1000, 0); } } $return['category'][$name]['data']['history']['power'][$datetime][1] += $power[1]; $intervals[$datetime] = $datetime; $alreadyAdd[$datetime] = $datetime; } } $return['category'][$name]['data']['real']['power'] += $category['data']['real']['power']; $return['category'][$name]['data']['real']['consumption'] += $category['data']['real']['consumption']; } } } } if (is_object($total)) { $details = array('data' => array(), 'name' => 'Autre'); if (!isset($return['category']['autres'])) { $return['category']['autres'] = array('data' => array('history' => array('power' => array(), 'consumption' => array()), 'real' => array('power' => 0, 'consumption' => 0)), 'name' => 'Autres'); } foreach ($totalData['history']['power'] as $datetime => $power) { if (!isset($return['history']['power'][$datetime])) { $prevValue = self::searchPrevisous($return['history']['power'], $datetime); if (count($prevValue) == 2) { if ($power[1] - $prevValue[1] > 0) { $details['data']['history']['power'][$datetime] = array($datetime * 1000, $power[1] - $prevValue[1]); $return['category']['autres']['data']['history']['power'][$datetime] = array($datetime * 1000, $power[1] - $prevValue[1]); } } else { $return['category']['autres']['data']['history']['power'][$datetime] = array($datetime * 1000, $power[1]); } } else { if ($power[1] - $return['history']['power'][$datetime][1] > 0) { $details['data']['history']['power'][$datetime] = array($datetime * 1000, $power[1] - $return['history']['power'][$datetime][1]); $return['category']['autres']['data']['history']['power'][$datetime] = array($datetime * 1000, $power[1] - $return['history']['power'][$datetime][1]); } } } $details['data']['real']['power'] = $totalData['real']['power'] - $return['real']['power']; $details['data']['real']['consumption'] = $totalData['real']['consumption'] - $return['real']['consumption']; $return['category']['autres']['data']['real']['power'] = $totalData['real']['power'] - $return['real']['power']; $return['category']['autres']['data']['real']['consumption'] = $totalData['real']['consumption'] - $return['real']['consumption']; $return['history']['power'] = $totalData['history']['power']; $return['history']['consumption'] = $totalData['history']['consumption']; $return['real']['power'] = $totalData['real']['power']; $return['real']['consumption'] = $totalData['real']['consumption']; $return['details'][] = $details; } foreach ($return['details'] as &$details) { if (isset($details['data']['history']['consumption'])) { ksort($details['data']['history']['consumption']); $details['data']['history']['consumption'] = self::fillHoles($intervals, $details['data']['history']['consumption']); } if (isset($details['data']['history']['power'])) { ksort($details['data']['history']['power']); $details['data']['history']['power'] = self::fillHoles($intervals, $details['data']['history']['power']); } } foreach ($return['category'] as &$category) { if (isset($category['data']['history']['consumption'])) { ksort($category['data']['history']['consumption']); $category['data']['history']['consumption'] = self::fillHoles($intervals, $category['data']['history']['consumption']); } if (isset($category['data']['history']['power'])) { ksort($category['data']['history']['power']); $category['data']['history']['power'] = self::fillHoles($intervals, $category['data']['history']['power']); } } ksort($return['history']['consumption']); ksort($return['history']['power']); return $return; }
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 $default_image = 'core/img/no_image.gif'; switch ($market->getType()) { case 'widget': $default_image = 'core/img/no-image-widget.png'; break;
public function export($_mode = 'text') { if ($_mode == 'text') { $return = ''; $return .= '- Nom du scénario : ' . $this->getName() . "\n"; if (is_numeric($this->getObject_id())) { $return .= '- Objet parent : ' . $this->getObject()->getName() . "\n"; } $return .= '- Mode du scénario : ' . $this->getMode() . "\n"; $schedules = $this->getSchedule(); if ($this->getMode() == 'schedule' || $this->getMode() == 'all') { if (is_array($schedules)) { foreach ($schedules as $schedule) { $return .= ' - Programmation : ' . $schedule . "\n"; } } else { if ($schedules != '') { $return .= ' - Programmation : ' . $schedules . "\n"; } } } if ($this->getMode() == 'provoke' || $this->getMode() == 'all') { $triggers = $this->getTrigger(); if (is_array($triggers)) { foreach ($triggers as $trigger) { $return .= ' - Evènement : ' . jeedom::toHumanReadable($trigger) . "\n"; } } else { if ($triggers != '') { $return .= ' - Evènement : ' . jeedom::toHumanReadable($triggers) . "\n"; } } } $return .= "\n"; $return .= $this->getDescription(); $return .= "\n\n"; foreach ($this->getElement() as $element) { $exports = explode("\n", $element->export()); foreach ($exports as $export) { $return .= " " . $export . "\n"; } } } if ($_mode == 'array') { $return = utils::o2a($this); $return['trigger'] = jeedom::toHumanReadable($return['trigger']); $return['elements'] = array(); foreach ($this->getElement() as $element) { $return['elements'][] = $element->getAjaxElement('array'); } if (isset($return['id'])) { unset($return['id']); } if (isset($return['lastLaunch'])) { unset($return['lastLaunch']); } if (isset($return['log'])) { unset($return['log']); } if (isset($return['hlogs'])) { unset($return['hlogs']); } if (isset($return['object_id'])) { unset($return['object_id']); } if (isset($return['pid'])) { unset($return['pid']); } if (isset($return['scenarioElement'])) { unset($return['scenarioElement']); } if (isset($return['_templateArray'])) { unset($return['_templateArray']); } if (isset($return['_templateArray'])) { unset($return['_templateArray']); } if (isset($return['_changeState'])) { unset($return['_changeState']); } if (isset($return['_realTrigger'])) { unset($return['_realTrigger']); } if (isset($return['_templateArray'])) { unset($return['_templateArray']); } if (isset($return['_elements'])) { unset($return['_elements']); } } return $return; }
} } $scenario_db->setTrigger(array()); $scenario_db->setSchedule(array()); utils::a2o($scenario_db, $scenario_ajax); $scenario_db->setConfiguration('timeDependency', $time_dependance); $scenario_db->save(); $scenario_element_list = array(); if (isset($scenario_ajax['elements'])) { foreach ($scenario_ajax['elements'] as $element_ajax) { $scenario_element_list[] = scenarioElement::saveAjaxElement($element_ajax); } $scenario_db->setScenarioElement($scenario_element_list); } $scenario_db->save(); ajax::success(utils::o2a($scenario_db)); } if (init('action') == 'actionToHtml') { ajax::success(scenarioExpression::getExpressionOptions(init('expression'), init('option'))); } if (init('action') == 'templateupload') { $uploaddir = dirname(__FILE__) . '/../../core/config/scenario/'; if (!file_exists($uploaddir)) { mkdir($uploaddir); } if (!file_exists($uploaddir)) { throw new Exception(__('Répertoire d\'upload non trouvé : ', __FILE__) . $uploaddir); } if (!isset($_FILES['file'])) { throw new Exception(__('Aucun fichier trouvé. Vérifié parametre PHP (post size limit)', __FILE__)); }
$_SESSION['user']->save(); @session_write_close(); ajax::success(); } if (init('action') == 'get') { ajax::success(utils::o2a($_SESSION['user'])); } if (init('action') == 'testLdapConnection') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $connection = user::connectToLDAP(); if ($connection === false) { throw new Exception(); } ajax::success(); } if (init('action') == 'createTemporary') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $user = user::createTemporary(24); $return = utils::o2a($user); $return['directUrl'] = $user->getDirectUrlAccess(); ajax::success($return); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
if (init('action') == 'toggle') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $plugin = plugin::byId(init('id')); if (!is_object($plugin)) { throw new Exception(__('Plugin introuvable : ', __FILE__) . init('id')); } $plugin->setIsEnable(init('state')); ajax::success(); } if (init('action') == 'all') { if (!isConnect()) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } ajax::success(utils::o2a(plugin::listPlugin())); } if (init('action') == 'pluginupload') { $uploaddir = dirname(__FILE__) . '/../../tmp'; if (!file_exists($uploaddir)) { mkdir($uploaddir); } if (!file_exists($uploaddir)) { throw new Exception(__('Répertoire d\'upload non trouvé : ', __FILE__) . $uploaddir); } if (!isset($_FILES['file'])) { throw new Exception(__('Aucun fichier trouvé. Vérifié parametre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.zip'))) { throw new Exception('Extension du fichier non valide (autorisé .zip) : ' . $extension);
$result = utils::o2a(interactDef::byId(init('id'))); $result['nbInteractQuery'] = count(interactQuery::byInteractDefId($result['id'])); $result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id'], true)); ajax::success(jeedom::toHumanReadable($result)); } if (init('action') == 'save') { $interact_json = jeedom::fromHumanReadable(json_decode(init('interact'), true)); if (isset($interact_json['id'])) { $interact = interactDef::byId($interact_json['id']); } if (!isset($interact) || !is_object($interact)) { $interact = new interactDef(); } utils::a2o($interact, $interact_json); $interact->save(); ajax::success(utils::o2a($interact)); } if (init('action') == 'regenerateInteract') { interactDef::regenerateInteract(); ajax::success(); } if (init('action') == 'remove') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $interact = interactDef::byId(init('id')); if (!is_object($interact)) { throw new Exception(__('Interaction inconnu verifié l\'id', __FILE__)); } $interact->remove(); ajax::success();