コード例 #1
0
 public function export()
 {
     $return = '';
     if ($this->getType() == 'element') {
         $element = scenarioElement::byId($this->getExpression());
         if (is_object($element)) {
             $exports = explode("\n", $element->export());
             foreach ($exports as $export) {
                 $return .= "    " . $export . "\n";
             }
         }
         return rtrim($return);
     }
     $options = $this->getOptions();
     if ($this->getType() == 'action') {
         if ($this->getExpression() == 'icon') {
             return '';
         } else {
             if ($this->getExpression() == 'sleep') {
                 return '(sleep) Pause de  : ' . $options['duration'];
             } else {
                 if ($this->getExpression() == 'stop') {
                     return '(stop) Arret du scenario';
                 } else {
                     if ($this->getExpression() == 'scenario') {
                         $actionScenario = scenario::byId($this->getOptions('scenario_id'));
                         if (is_object($actionScenario)) {
                             return '(scenario) ' . $this->getOptions('action') . ' de ' . $actionScenario->getHumanName();
                         }
                     } else {
                         if ($this->getExpression() == 'variable') {
                             return '(variable) Affectation de la variable : ' . $this->getOptions('name') . ' à ' . $this->getOptions('value');
                         } else {
                             $return = jeedom::toHumanReadable($this->getExpression());
                             if (is_array($options) && count($options) != 0) {
                                 $return .= ' - Options : ' . print_r(jeedom::toHumanReadable($options), true);
                             }
                             return $return;
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->getType() == 'condition') {
             return jeedom::toHumanReadable($this->getExpression());
         }
     }
     if ($this->getType() == 'code') {
     }
 }
コード例 #2
0
ファイル: cmd.class.php プロジェクト: jimibi/core
 public function toHtml($_version = 'dashboard', $options = '', $_cmdColor = null, $_cache = 2)
 {
     $version = jeedom::versionAlias($_version);
     $html = '';
     $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.' . $this->getTemplate($version, 'default');
     $template = '';
     if (!isset(self::$_templateArray[$version . '::' . $template_name])) {
         if ($this->getTemplate($version, 'default') != 'default') {
             if (config::byKey('active', 'widget') == 1) {
                 $template = getTemplate('core', $version, $template_name, 'widget');
             }
             if ($template == '') {
                 foreach (plugin::listPlugin(true) as $plugin) {
                     $template = getTemplate('core', $version, $template_name, $plugin->getId());
                     if ($template != '') {
                         break;
                     }
                 }
             }
             if ($template == '') {
                 $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.default';
                 $template = getTemplate('core', $version, $template_name);
             }
         } else {
             $template = getTemplate('core', $version, $template_name);
         }
         self::$_templateArray[$version . '::' . $template_name] = $template;
     } else {
         $template = self::$_templateArray[$version . '::' . $template_name];
     }
     $replace = array('#id#' => $this->getId(), '#name#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#name_display#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#history#' => '', '#displayHistory#' => 'display : none;', '#unite#' => $this->getUnite(), '#minValue#' => $this->getConfiguration('minValue', 0), '#maxValue#' => $this->getConfiguration('maxValue', 100), '#logicalId#' => $this->getLogicalId());
     if ($_cmdColor == null && $version != 'scenario') {
         $eqLogic = $this->getEqLogic();
         $vcolor = $version == 'mobile' ? 'mcmdColor' : 'cmdColor';
         if ($eqLogic->getPrimaryCategory() == '') {
             $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:default:' . $vcolor);
         } else {
             $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:' . $eqLogic->getPrimaryCategory() . ':' . $vcolor);
         }
     } else {
         $replace['#cmdColor#'] = $_cmdColor;
     }
     if ($this->getDisplay('doNotShowNameOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) {
         $replace['#name_display#'] = '';
         $replace['#name#'] = '';
     } else {
         if ($this->getDisplay('doNotShowNameOnDashboard') == 1 && ($_version == 'mobile' || $_version == 'dashboard')) {
             $replace['#name_display#'] = '';
             $replace['#name#'] = '';
         } else {
             $replace['#name_display#'] .= '<br/>';
         }
     }
     if ($this->getType() == 'info') {
         $replace['#state#'] = '';
         $replace['#tendance#'] = '';
         $replace['#state#'] = $this->execCmd(null, $_cache);
         if (strpos($replace['#state#'], 'error::') !== false) {
             $template = getTemplate('core', $version, 'cmd.error');
             $replace['#state#'] = str_replace('error::', '', $replace['#state#']);
         } else {
             if ($this->getSubType() == 'binary' && $this->getDisplay('invertBinary') == 1) {
                 $replace['#state#'] = $replace['#state#'] == 1 ? 0 : 1;
             }
         }
         if (method_exists($this, 'formatValueWidget')) {
             $replace['#state#'] = $this->formatValueWidget($replace['#state#']);
         }
         $replace['#collectDate#'] = $this->getCollectDate();
         $replace['#valueDate#'] = $this->getValueDate();
         if ($this->getIsHistorized() == 1) {
             $replace['#history#'] = 'history cursor';
             if (config::byKey('displayStatsWidget') == 1 && strpos($template, '#displayHistory#') !== false) {
                 $showStat = true;
                 if ($this->getDisplay('doNotShowStatOnDashboard') == 1 && $_version == 'dashboard') {
                     $showStat = false;
                 }
                 if ($this->getDisplay('doNotShowStatOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) {
                     $showStat = false;
                 }
                 if ($this->getDisplay('doNotShowStatOnMobile') == 1 && $_version == 'mobile') {
                     $showStat = false;
                 }
                 if ($showStat) {
                     $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculPeriod') . ' hour'));
                     $replace['#displayHistory#'] = '';
                     $historyStatistique = $this->getStatistique($startHist, date('Y-m-d H:i:s'));
                     if ($historyStatistique['avg'] == 0 && $historyStatistique['min'] == 0 && $historyStatistique['max'] == 0) {
                         $replace['#averageHistoryValue#'] = round($replace['#state#'], 1);
                         $replace['#minHistoryValue#'] = round($replace['#state#'], 1);
                         $replace['#maxHistoryValue#'] = round($replace['#state#'], 1);
                     } else {
                         $replace['#averageHistoryValue#'] = round($historyStatistique['avg'], 1);
                         $replace['#minHistoryValue#'] = round($historyStatistique['min'], 1);
                         $replace['#maxHistoryValue#'] = round($historyStatistique['max'], 1);
                     }
                     $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculTendance') . ' hour'));
                     $tendance = $this->getTendance($startHist, date('Y-m-d H:i:s'));
                     if ($tendance > config::byKey('historyCalculTendanceThresholddMax')) {
                         $replace['#tendance#'] = 'fa fa-arrow-up';
                     } else {
                         if ($tendance < config::byKey('historyCalculTendanceThresholddMin')) {
                             $replace['#tendance#'] = 'fa fa-arrow-down';
                         } else {
                             $replace['#tendance#'] = 'fa fa-minus';
                         }
                     }
                 }
             }
         }
         $parameters = $this->getDisplay('parameters');
         if (is_array($parameters)) {
             foreach ($parameters as $key => $value) {
                 $replace['#' . $key . '#'] = $value;
             }
         }
         return template_replace($replace, $template);
     } else {
         $cmdValue = $this->getCmdValue();
         if (is_object($cmdValue) && $cmdValue->getType() == 'info') {
             $replace['#state#'] = $cmdValue->execCmd(null, 2);
             $replace['#valueName#'] = $cmdValue->getName();
             $replace['#unite#'] = $cmdValue->getUnite();
         } else {
             $replace['#state#'] = $this->getLastValue() != null ? $this->getLastValue() : '';
             $replace['#valueName#'] = $this->getName();
             $replace['#unite#'] = $this->getUnite();
         }
         $parameters = $this->getDisplay('parameters');
         if (is_array($parameters)) {
             foreach ($parameters as $key => $value) {
                 $replace['#' . $key . '#'] = $value;
             }
         }
         $replace['#valueName#'] .= '<br/>';
         $html .= template_replace($replace, $template);
         if (trim($html) == '') {
             return $html;
         }
         if ($options != '') {
             $options = jeedom::toHumanReadable($options);
             if (is_json($options)) {
                 $options = json_decode($options, true);
             }
             if (is_array($options)) {
                 foreach ($options as $key => $value) {
                     $replace['#' . $key . '#'] = $value;
                 }
             }
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'message') {
             if (!isset($replace['#title#'])) {
                 $replace['#title#'] = '';
             }
             if (!isset($replace['#message#'])) {
                 $replace['#message#'] = '';
             }
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#slider#'])) {
             $replace['#slider#'] = '';
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#color#'])) {
             $replace['#color#'] = '';
         }
         $replace['#title_placeholder#'] = $this->getDisplay('title_placeholder', __('Titre', __FILE__));
         $replace['#message_placeholder#'] = $this->getDisplay('message_placeholder', __('Message', __FILE__));
         $replace['#message_disable#'] = $this->getDisplay('message_disable', 0);
         $replace['#title_disable#'] = $this->getDisplay('title_disable', 0);
         $replace['#title_possibility_list#'] = $this->getDisplay('title_possibility_list', '');
         $replace['#slider_placeholder#'] = $this->getDisplay('slider_placeholder', __('Valeur', __FILE__));
         $html = template_replace($replace, $html);
         return $html;
     }
 }
コード例 #3
0
ファイル: scenario.ajax.php プロジェクト: GaelGRIFFON/core
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $scenario = scenario::byId(init('id'));
     if (!is_object($scenario)) {
         throw new Exception(__('Scénario ID inconnu', __FILE__));
     }
     ajax::success(utils::o2a($scenario->copy(init('name'))));
 }
 if (init('action') == 'get') {
     $scenario = scenario::byId(init('id'));
     if (!is_object($scenario)) {
         throw new Exception(__('Scénario ID inconnu', __FILE__));
     }
     $return = utils::o2a($scenario);
     $return['trigger'] = jeedom::toHumanReadable($return['trigger']);
     $return['forecast'] = $scenario->calculateScheduleDate();
     $return['elements'] = array();
     foreach ($scenario->getElement() as $element) {
         $return['elements'][] = $element->getAjaxElement();
     }
     ajax::success($return);
 }
 if (init('action') == 'save') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $time_dependance = 0;
     $time_keyword = array('#time#', '#seconde#', '#heure#', '#minute#', '#jour#', '#mois#', '#annee#', '#timestamp#', '#date#', '#semaine#', '#sjour#', '#njour#', '#smois#');
     foreach ($time_keyword as $keyword) {
         if (strpos(init('scenario'), $keyword) !== false) {
コード例 #4
0
ファイル: cmd.ajax.php プロジェクト: saez0pub/core
         $return['scenario'][] = $info;
     }
     ajax::success($return);
 }
 if (init('action') == 'getHumanCmdName') {
     ajax::success(cmd::cmdToHumanReadable('#' . init('id') . '#'));
 }
 if (init('action') == 'byEqLogic') {
     ajax::success(utils::o2a(cmd::byEqLogicId(init('eqLogic_id'))));
 }
 if (init('action') == 'getCmd') {
     $cmd = cmd::byId(init('id'));
     if (!is_object($cmd)) {
         throw new Exception(__('Cmd ID inconnu : ', __FILE__) . init('id'));
     }
     $return = jeedom::toHumanReadable(utils::o2a($cmd));
     $eqLogic = $cmd->getEqLogic();
     $return['eqLogic_name'] = $eqLogic->getName();
     $return['plugin'] = $eqLogic->getEqType_Name();
     if ($eqLogic->getObject_id() > 0) {
         $return['object_name'] = $eqLogic->getObject()->getName();
     }
     ajax::success($return);
 }
 if (init('action') == 'save') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $cmd_ajax = jeedom::fromHumanReadable(json_decode(init('cmd'), true));
     $cmd = cmd::byId($cmd_ajax['id']);
     if (!is_object($cmd)) {
コード例 #5
0
 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;
 }
コード例 #6
0
ファイル: scenario.class.php プロジェクト: GaelGRIFFON/core
 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;
 }
コード例 #7
0
ファイル: interact.ajax.php プロジェクト: GaelGRIFFON/core
 }
 if (init('action') == 'byId') {
     $result = utils::o2a(interactDef::byId(init('id')));
     $result['nbInteractQuery'] = count(interactQuery::byInteractDefId($result['id']));
     $result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id'], true));
     if ($result['link_type'] == 'cmd' && $result['link_id'] != '') {
         $link_id = '';
         foreach (explode('&&', $result['link_id']) as $cmd_id) {
             $cmd = cmd::byId($cmd_id);
             if (is_object($cmd)) {
                 $link_id .= cmd::cmdToHumanReadable('#' . $cmd->getId() . '# && ');
             }
         }
         $result['link_id'] = trim(trim($link_id), '&&');
     }
     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();
コード例 #8
0
ファイル: cmd.configure.php プロジェクト: saez0pub/core
    <?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/>
コード例 #9
0
ファイル: jeeNetwork.ajax.php プロジェクト: GaelGRIFFON/core
                $value = sha1($value);
            }
            $jeeNetwork->configSave($key, jeedom::fromHumanReadable($value), init('plugin', 'core'));
        }
        ajax::success();
    }
    if (init('action') == 'getKey') {
        $jeeNetwork = jeeNetwork::byId(init('id'));
        if (!is_object($jeeNetwork)) {
            throw new Exception(__('JeeNetwork inconnu, vérifiez l\'ID : ', __FILE__) . init('id'));
        }
        $keys = init('key');
        if ($keys == '') {
            throw new Exception(__('Aucune clef demandée', __FILE__));
        }
        if (is_json($keys)) {
            $keys = json_decode($keys, true);
            $return = array();
            foreach ($keys as $key => $value) {
                $return[$key] = jeedom::toHumanReadable($jeeNetwork->configByKey($key, init('plugin', 'core')));
            }
            ajax::success($return);
        } else {
            ajax::success($jeeNetwork->configByKey(init('key'), init('plugin', 'core')));
        }
    }
    throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
コード例 #10
0
ファイル: eqLogic.ajax.php プロジェクト: saez0pub/core
     if ($typeEqLogic == '' || !class_exists($typeEqLogic)) {
         throw new Exception(__('Type incorrect (classe équipement inexistante) : ', __FILE__) . $typeEqLogic);
     }
     $eqLogic = $typeEqLogic::byId(init('id'));
     if (!is_object($eqLogic)) {
         throw new Exception(__('EqLogic inconnu verifié l\'id : ', __FILE__) . init('id'));
     }
     $return = utils::o2a($eqLogic);
     if (init('status') == 1) {
         $return['status'] = array('state' => 'ok', 'lastCommunication' => $eqLogic->getStatus('lastCommunication'));
         if ($eqLogic->getTimeout() > 0 && $eqLogic->getStatus('lastCommunication', date('Y-m-d H:i:s')) < date('Y-m-d H:i:s', strtotime('-' . $eqLogic->getTimeout() . ' minutes' . date('Y-m-d H:i:s')))) {
             $return['status']['state'] = 'timeout';
         }
     }
     $return['cmd'] = utils::o2a($eqLogic->getCmd());
     ajax::success(jeedom::toHumanReadable($return));
 }
 if (init('action') == 'save') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $eqLogicsSave = json_decode(init('eqLogic'), true);
     foreach ($eqLogicsSave as $eqLogicSave) {
         if (!is_array($eqLogicSave)) {
             throw new Exception(__('Informations recues incorrecte', __FILE__));
         }
         $typeEqLogic = init('type');
         $typeCmd = $typeEqLogic . 'Cmd';
         if ($typeEqLogic == '' || !class_exists($typeEqLogic) || !class_exists($typeCmd)) {
             throw new Exception(__('Type incorrect (classe commande inexistante)', __FILE__) . $typeCmd);
         }
コード例 #11
0
ファイル: config.ajax.php プロジェクト: GaelGRIFFON/core
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     config::save('api', config::genKey());
     ajax::success(config::byKey('api'));
 }
 if (init('action') == 'getKey') {
     $keys = init('key');
     if ($keys == '') {
         throw new Exception(__('Aucune clef demandée', __FILE__));
     }
     if (is_json($keys)) {
         $keys = json_decode($keys, true);
         $return = array();
         foreach ($keys as $key => $value) {
             $return[$key] = jeedom::toHumanReadable(config::byKey($key, init('plugin', 'core')));
         }
         ajax::success($return);
     } else {
         ajax::success(config::byKey(init('key'), init('plugin', 'core')));
     }
 }
 if (init('action') == 'genNodeJsKey') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     nodejs::updateKey();
     ajax::success(config::byKey('nodeJsKey'));
 }
 if (init('action') == 'getNodeJsKey') {
     ajax::success(config::byKey('nodeJsKey'));
コード例 #12
0
ファイル: energy.ajax.php プロジェクト: Wators/jeedom_plugins
 */
try {
    require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
    include_file('core', 'authentification', 'php');
    if (!isConnect('admin')) {
        throw new Exception('401 Unauthorized');
    }
    if (init('action') == 'get') {
        $return = array();
        $eqLogic = eqLogic::byId(init('id'));
        if (!is_object($eqLogic)) {
            throw new Exception('Equipement non trouvé vérifiez l\'id : ' . init('id'));
        }
        $return['eqLogic'] = utils::o2a($eqLogic);
        $energy = energy::byEqLogic_id($eqLogic->getId());
        $return['energy'] = is_object($energy) ? jeedom::toHumanReadable(utils::o2a($energy)) : array('eqLogic_id' => $eqLogic->getId(), 'id' => '');
        ajax::success($return);
    }
    if (init('action') == 'save') {
        $energy_json = json_decode(init('energy'), true);
        $energy = energy::byId($energy_json['id']);
        if (!is_object($energy)) {
            $energy = new energy();
        }
        utils::a2o($energy, jeedom::fromHumanReadable($energy_json));
        $energy->save();
        ajax::success();
    }
    throw new Exception('Aucune methode correspondante');
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {