コード例 #1
0
 public function save()
 {
     if ($this->getQuery() == '') {
         throw new Exception(__('La commande (demande) ne peut pas être vide', __FILE__));
     }
     $this->setLink_id(str_replace('#', '', jeedom::fromHumanReadable($this->getLink_id())));
     return DB::save($this);
 }
コード例 #2
0
 public function setOptions($_key, $_value)
 {
     $this->options = utils::setJsonAttr($this->options, $_key, jeedom::fromHumanReadable($_value));
 }
コード例 #3
0
ファイル: interact.ajax.php プロジェクト: GaelGRIFFON/core
     $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();
     ajax::success();
 }
 if (init('action') == 'remove') {
コード例 #4
0
ファイル: cmd.ajax.php プロジェクト: saez0pub/core
         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)) {
         $cmd = new cmd();
     }
     utils::a2o($cmd, $cmd_ajax);
     $cmd->save();
     ajax::success();
 }
 if (init('action') == 'changeHistoryPoint') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $history = history::byCmdIdDatetime(init('cmd_id'), init('datetime'));
     if (!is_object($history)) {
         throw new Exception(__('Aucun point ne correspond pour l\'historique : ', __FILE__) . init('cmd_id') . ' - ' . init('datetime'));
コード例 #5
0
ファイル: jeeApi.php プロジェクト: GaelGRIFFON/core
     $dbList = $typeCmd::byEqLogicId($eqLogic->getId());
     $eqLogic->save();
     $enableList = array();
     if (isset($params['cmd'])) {
         $cmd_order = 0;
         foreach ($params['cmd'] as $cmd_info) {
             $cmd = null;
             if (isset($cmd_info['id'])) {
                 $cmd = $typeCmd::byId($cmd_info['id']);
             }
             if (!is_object($cmd)) {
                 $cmd = new $typeCmd();
             }
             $cmd->setEqLogic_id($eqLogic->getId());
             $cmd->setOrder($cmd_order);
             utils::a2o($cmd, jeedom::fromHumanReadable($cmd_info));
             $cmd->save();
             $cmd_order++;
             $enableList[$cmd->getId()] = true;
         }
         //suppression des entrées inexistante.
         foreach ($dbList as $dbObject) {
             if (!isset($enableList[$dbObject->getId()]) && !$dbObject->dontRemoveCmd()) {
                 $dbObject->remove();
             }
         }
     }
     $jsonrpc->makeSuccess(utils::o2a($eqLogic));
 }
 if ($jsonrpc->getMethod() == 'eqLogic::byTypeAndId') {
     $return = array();
コード例 #6
0
ファイル: jeeNetwork.ajax.php プロジェクト: GaelGRIFFON/core
     foreach ($backups as $backup) {
         $return[$backup_dir . '/' . $backup] = $backup;
     }
     ajax::success($return);
 }
 if (init('action') == 'addKey') {
     $jeeNetwork = jeeNetwork::byId(init('id'));
     if (!is_object($jeeNetwork)) {
         throw new Exception(__('JeeNetwork inconnu, vérifiez l\'ID : ', __FILE__) . init('id'));
     }
     $values = json_decode(init('value'), true);
     foreach ($values as $key => $value) {
         if ($key == 'market::password' && !preg_match('/^[0-9a-f]{40}$/i', $value)) {
             $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();
コード例 #7
0
ファイル: eqLogic.ajax.php プロジェクト: saez0pub/core
 $eqLogic = null;
 if (isset($eqLogicSave['id'])) {
     $eqLogic = $typeEqLogic::byId($eqLogicSave['id']);
 }
 if (!is_object($eqLogic)) {
     $eqLogic = new $typeEqLogic();
     $eqLogic->setEqType_name(init('type'));
 } else {
     if (!$eqLogic->hasRight('w')) {
         throw new Exception('Vous n\'etês pas autorisé à faire cette action');
     }
 }
 if (method_exists($eqLogic, 'preAjax')) {
     $eqLogic->preAjax();
 }
 $eqLogicSave = jeedom::fromHumanReadable($eqLogicSave);
 utils::a2o($eqLogic, $eqLogicSave);
 $dbList = $typeCmd::byEqLogicId($eqLogic->getId());
 $eqLogic->save();
 $enableList = array();
 if (isset($eqLogicSave['cmd'])) {
     $cmd_order = 0;
     foreach ($eqLogicSave['cmd'] as $cmd_info) {
         $cmd = null;
         if (isset($cmd_info['id'])) {
             $cmd = $typeCmd::byId($cmd_info['id']);
         }
         if (!is_object($cmd)) {
             $cmd = new $typeCmd();
         }
         $cmd->setEqLogic_id($eqLogic->getId());
コード例 #8
0
ファイル: config.ajax.php プロジェクト: GaelGRIFFON/core
     nodejs::updateKey();
     ajax::success(config::byKey('nodeJsKey'));
 }
 if (init('action') == 'getNodeJsKey') {
     ajax::success(config::byKey('nodeJsKey'));
 }
 if (init('action') == 'addKey') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $values = json_decode(init('value'), true);
     foreach ($values as $key => $value) {
         if ($key == 'market::password' && !preg_match('/^[0-9a-f]{40}$/i', $value)) {
             $value = sha1($value);
         }
         config::save($key, jeedom::fromHumanReadable($value), init('plugin', 'core'));
         if ($key == 'internalAddr') {
             jeeNetwork::pull();
         }
         if ($key == 'market::allowDNS') {
             if ($value == 1) {
                 if (!network::dns_run()) {
                     network::dns_start();
                 }
             } else {
                 if (network::dns_run()) {
                     network::dns_stop();
                 }
             }
         }
     }
コード例 #9
0
ファイル: energy.ajax.php プロジェクト: Wators/jeedom_plugins
    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) {
    ajax::error(displayExeption($e), $e->getCode());
}