Exemple #1
0
 /*             * ************************datastore*************************** */
 if ($jsonrpc->getMethod() == 'datastore::byTypeLinkIdKey') {
     $jsonrpc->makeSuccess(dataStore::byTypeLinkIdKey($params['type'], $params['linkId'], $params['key']));
 }
 if ($jsonrpc->getMethod() == 'datastore::save') {
     $dataStore = new dataStore();
     $dataStore->setType($params['type']);
     $dataStore->setKey($params['key']);
     $dataStore->setValue($params['value']);
     $dataStore->setLink_id($params['linkId']);
     $dataStore->save();
     $jsonrpc->makeSuccess('ok');
 }
 /*             * ************************Equipement*************************** */
 if ($jsonrpc->getMethod() == 'eqLogic::all') {
     $jsonrpc->makeSuccess(utils::o2a(eqLogic::all()));
 }
 if ($jsonrpc->getMethod() == 'eqLogic::byType') {
     $jsonrpc->makeSuccess(utils::o2a(eqLogic::byType($params['type'])));
 }
 if ($jsonrpc->getMethod() == 'eqLogic::byObjectId') {
     $jsonrpc->makeSuccess(utils::o2a(eqLogic::byObjectId($params['object_id'])));
 }
 if ($jsonrpc->getMethod() == 'eqLogic::byId') {
     $eqLogic = eqLogic::byId($params['id']);
     if (!is_object($eqLogic)) {
         throw new Exception('EqLogic introuvable : ' . $params['id'], -32602);
     }
     $jsonrpc->makeSuccess(utils::o2a($eqLogic));
 }
 if ($jsonrpc->getMethod() == 'eqLogic::fullById') {
Exemple #2
0
                    <option value="all">{{Tous}}</option>
                    <?php 
foreach (object::all() as $object) {
    echo '<option value="' . $object->getId() . '" >' . $object->getName() . '</option>';
}
?>
               </select>
           </div>
       </div>
       <div class="form-group">
        <label class="col-sm-6 control-label">{{Limiter à l'équipement}}</label>
        <div class="col-sm-4">
            <select class='interactAttr form-control' data-l1key='filtres' data-l2key='eqLogic_id' >
                <option value="all">{{Tous}}</option>
                <?php 
foreach (eqLogic::all() as $eqLogic) {
    echo '<option value="' . $eqLogic->getId() . '" >' . $eqLogic->getHumanName() . '</option>';
}
?>
           </select>
       </div>
   </div>
   <div class="form-group">
    <label class="col-sm-6 control-label">{{Limiter au plugin}}</label>
    <div class="col-sm-4">
        <select class='interactAttr form-control' data-l1key='filtres' data-l2key='plugin'>
            <option value="all">{{Tous}}</option>
            <?php 
foreach (eqLogic::allType() as $type) {
    echo '<option value="' . $type['type'] . '" >' . $type['type'] . '</option>';
}
 public static function changeMode($_mode)
 {
     switch ($_mode) {
         case 'master':
             if (config::byKey('jeeNetwork::mode') != 'master') {
                 $cron = new cron();
                 $cron->setClass('history');
                 $cron->setFunction('historize');
                 $cron->setSchedule('*/5 * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('scenario');
                 $cron->setFunction('check');
                 $cron->setSchedule('* * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('cmd');
                 $cron->setFunction('collect');
                 $cron->setSchedule('*/5 * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('history');
                 $cron->setFunction('archive');
                 $cron->setSchedule('00 * * * * *');
                 $cron->setTimeout(20);
                 $cron->save();
                 config::save('jeeNetwork::mode', 'master');
             }
             break;
         case 'slave':
             if (config::byKey('jeeNetwork::mode') != 'slave') {
                 foreach (eqLogic::all() as $eqLogic) {
                     $eqLogic->remove();
                 }
                 foreach (object::all() as $object) {
                     $object->remove();
                 }
                 foreach (update::all() as $update) {
                     switch ($update->getType()) {
                         case 'core':
                             break;
                         case 'plugin':
                             try {
                                 $plugin = plugin::byId($update->getLogicalId());
                                 if (is_object($plugin) && $plugin->getAllowRemote() != 1) {
                                     $update->deleteObjet();
                                 }
                             } catch (Exception $e) {
                             }
                             break;
                         default:
                             $update->deleteObjet();
                             break;
                     }
                 }
                 foreach (view::all() as $view) {
                     $view->remove();
                 }
                 foreach (plan::all() as $plan) {
                     $plan->remove();
                 }
                 foreach (scenario::all() as $scenario) {
                     $scenario->remove();
                 }
                 foreach (listener::all() as $listener) {
                     $listener->remove();
                 }
                 $cron = cron::byClassAndFunction('history', 'historize');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('scenario', 'check');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('cmd', 'collect');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('history', 'archive');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $user = new user();
                 $user->setLogin('jeedom_master');
                 $user->setPassword(config::genKey(255));
                 $user->setRights('admin', 1);
                 $user->save();
                 config::save('jeeNetwork::mode', 'slave');
             }
             break;
     }
 }