예제 #1
0
 public function action_files()
 {
     $files = array();
     $limit = arr::get($_GET, 'limit', 10);
     $offset = arr::get($_GET, 'offset', 0);
     $query = ORM::factory('File');
     if (arr::get($_GET, 'tags', false)) {
         $tags = arr::get($_GET, 'tags');
         if (arr::get($_GET, 'matchAll', false) == "true") {
             $tagsquery = DB::select('files_tags.file_id')->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->group_by('files_tags.file_id')->having(DB::expr('COUNT(files_tags.file_id)'), '=', count($tags))->execute();
             //die(var_dump($tagsquery));
         } else {
             $tagsquery = DB::select('files_tags.file_id')->distinct(true)->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->execute();
             //die(var_dump($tagsquery));
         }
         if ((bool) $tagsquery->count()) {
             $ids = array();
             foreach ($tagsquery as $q) {
                 $ids[] = arr::get($q, 'file_id');
                 //$files[] = ORM::factory('File', arr::get($q, 'file_id'))->info();
             }
             $query = $query->where('id', 'IN', $ids);
         } else {
             // Empty resultset
             ajax::success('ok', array('files' => array()));
         }
     }
     $query = $query->order_by('created', 'DESC')->limit($limit)->offset($offset)->find_all();
     if ((bool) $query->count()) {
         foreach ($query as $file) {
             $files[] = $file->info();
         }
     }
     ajax::success('ok', array('files' => $files));
 }
예제 #2
0
 public function action_create()
 {
     try {
         user::create($_POST);
         ajax::success(__('User created'), array('redirect' => 'users'));
     } catch (ORM_Validation_Exception $e) {
         $errors = $e->errors('models');
         $errstr = array('<ul>');
         if ((bool) count($errors)) {
             foreach ($errors as $error) {
                 if (is_array($error)) {
                     foreach ($error as $err) {
                         $errstr[] = '<li>' . $err . '</li>';
                     }
                 } else {
                     $errstr[] = '<li>' . $error . '</li>';
                 }
             }
         }
         $errstr[] = '</li>';
         ajax::error(implode('', $errstr));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
예제 #3
0
 public function action_get()
 {
     $content = ORM::factory('Content')->order_by('hits', 'DESC')->limit(10)->find_all();
     $contents = array();
     if ((bool) $content->count()) {
         foreach ($content as $c) {
             $contents[] = array('id' => $c->id, 'title' => $c->title, 'type' => $c->contenttype->display, 'hits' => $c->hits);
         }
     }
     ajax::success('', array('contents' => $contents));
 }
예제 #4
0
 public function action_get()
 {
     $visitors = ORM::factory('Visitor')->find_all();
     $varray = array();
     if ((bool) $visitors->count()) {
         foreach ($visitors as $visitor) {
             $varray[] = $visitor->info();
         }
     }
     ajax::success('ok', array('visitors' => $varray));
 }
예제 #5
0
 public function action_get()
 {
     $errors = ORM::factory('Error')->order_by('time', 'DESC')->limit(10)->find_all();
     $errs = array();
     if ((bool) $errors->count()) {
         foreach ($errors as $e) {
             $errs[] = array('id' => $e->id, 'type' => $e->type, 'ip' => $e->ip, 'when' => date('d/m/Y H:i', $e->time), 'url' => $e->url);
         }
     }
     ajax::success('', array('errors' => $errs));
 }
예제 #6
0
 public function action_delete()
 {
     $vacation = ORM::factory('Vacation', arr::get($_POST, 'id', ''));
     if (!$vacation->loaded()) {
         ajax::error('Ferien blev ikke fundet. Er den allerede blevet slettet?');
     }
     try {
         $vacation->delete();
         ajax::success();
     } catch (exception $e) {
         ajax::error('Der opstod en fejl: ' . $e->getMessage());
     }
 }
예제 #7
0
 public function action_toggleread()
 {
     $message = ORM::factory('Message', arr::get($_POST, 'id'));
     if (!$message->loaded()) {
         ajax::error(__('The message wasn\'t found. Has it already been deleted?'));
     }
     $message->read = arr::get($_POST, 'read', '0');
     try {
         $message->save();
         ajax::success();
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
예제 #8
0
 public function action_getautosave()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $autosave = ORM::factory('Page')->where('user_id', '=', $user->id)->where('type', '=', 'autosave')->find();
     $content = '';
     if ($autosave->loaded() && $autosave->content != '') {
         $content = $autosave->decode($autosave->content);
         $autosave->delete();
     }
     ajax::success('', array('content' => $content, 'md5' => md5($content)));
 }
예제 #9
0
 public function action_create()
 {
     $role = ORM::factory('Role');
     $role->name = arr::get($_POST, 'name', false);
     if (!$role->name) {
         ajax::error(__('Enter a name to create a new role'));
     }
     $role->description = arr::get($_POST, 'description', '');
     try {
         $role->save();
         ajax::success('', array('role' => $role->info()));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
예제 #10
0
 public function action_get()
 {
     $contenttype = ORM::factory('Contenttype', arr::get($_GET, 'id', ''));
     if (!$contenttype->loaded()) {
         ajax::error(__('Contenttype not found. Has it been deleted?'));
     }
     $items = array();
     $contents = $contenttype->contents->find_all();
     if ((bool) $contents->count()) {
         foreach ($contents as $content) {
             $items[] = array('id' => $content->id, 'title' => $content->title());
         }
     }
     ajax::success('', array('id' => $contenttype->id, 'type' => $contenttype->type, 'slug' => $contenttype->slug, 'icon' => $contenttype->icon, 'hierarchical' => $contenttype->hierarchical, 'has_categories' => $contenttype->has_categories, 'has_tags' => $contenttype->has_tags, 'has_timestamp' => $contenttype->has_timestamp, 'has_thumbnail' => $contenttype->has_thumbnail, 'has_author' => $contenttype->has_author, 'display' => $contenttype->display, 'items' => $items));
 }
예제 #11
0
 public function action_add()
 {
     $title = arr::get($_POST, 'title', false);
     if (!$title || empty($title)) {
         ajax::error('A title is required');
     }
     $option = ORM::factory('Option');
     $option->optiongroup_id = arr::get($_POST, 'group');
     $option->title = $title;
     $option->key = arr::get($_POST, 'key', '');
     $option->type = arr::get($_POST, 'type', 'text');
     $option->description = arr::get($_POST, 'description', '');
     $option->editable = arr::get($_POST, 'editable', '1');
     try {
         $option->save();
         ajax::success('Option added', array('option' => $option->info()));
     } catch (exception $e) {
         ajax::error('Something went wrong: ' . $e->getMessage());
     }
 }
예제 #12
0
 public function action_create()
 {
     $content = ORM::factory('Content', arr::get($_POST, 'parent', ''));
     if (!$content->loaded()) {
         ajax::error('The content wasn\'t found. Has it been deleted?');
     }
     $title = arr::get($_POST, 'title', false);
     if (!$title) {
         $title = $content->title;
     }
     $clone = $content->copy();
     $clone->splittest = $content->id;
     $clone->splittest_title = $title;
     try {
         $clone->save();
         ajax::success('Splittest created', array('splittest' => array('id' => $clone->id, 'title' => $clone->splittest_title)));
     } catch (exception $e) {
         ajax::error('An error occurred and the splittest couldn\'t be created. The site said: ' . $e->getMessage());
     }
 }
예제 #13
0
 public function action_info()
 {
     maintenance::delete_inactive_visitors();
     $messages = 0;
     if (user::logged()) {
         $user = user::get();
         $messages += $user->messages->where('read', '=', '0')->count_all();
         $roles = $user->roles->find_all();
         $roleids = array();
         if ((bool) $roles->count()) {
             foreach ($roles as $role) {
                 $roleids[] = $role->id;
             }
         }
         if ((bool) count($roleids)) {
             $messages += ORM::factory('Message')->where('role_id', 'in', $roleids)->where('read', '=', '0')->where('user_id', '!=', $user->id)->count_all();
         }
     }
     ajax::success('', array('current_visitors' => $visitors = ORM::factory('Visitor')->count_all(), 'unread_messages' => $messages));
 }
예제 #14
0
 public function action_takechallenge()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to sign up for the challenge!');
     }
     $user = user::get();
     if ($user->doing_challenge()) {
         ajax::error('You are already doing the challenge! Complete it first, then sign up again.');
     }
     $challenge = ORM::factory('User_Challenge');
     $challenge->user_id = $user->id;
     $challenge->start = $user->timestamp();
     $challenge->progress = 0;
     if ($user->wrote_today()) {
         $challenge->progress = 1;
     }
     $challenge->save();
     $user->add_event('Signed up for the 30 day challenge!');
     ajax::success('Awesome! You have signed up for the challenge! Good luck!', array('progress' => $challenge->progress));
 }
예제 #15
0
 public function action_new()
 {
     $contenttype = $this->check_contenttype();
     $content = ORM::factory('Content');
     $content->user_id = user::get()->id;
     $content->contenttype_id = $contenttype->id;
     $typeid = $this->request->param('typeid');
     $content->contenttypetype_id = isset($typeid) && !empty($typeid) ? $typeid : '0';
     $content->title = '';
     $content->status = 'draft';
     $content->created = time();
     try {
         $content->save();
         $blocks = $contenttype->blocktypes->where('min', '>', 0)->where('parent', '=', 0)->where('contenttypetype_id', '=', $content->contenttypetype_id)->find_all();
         if ((bool) $blocks->count()) {
             $loop = 0;
             foreach ($blocks as $block) {
                 for ($i = 0; $i < $block->min; $i++) {
                     $contentblock = ORM::factory('Block');
                     $contentblock->content_id = $content->id;
                     $contentblock->blocktype_id = $block->id;
                     $contentblock->order = $loop;
                     $contentblock->save();
                     $loop++;
                 }
             }
         }
         //cms::redirect('content/edit/'.$content->id);
         ajax::success('ok', array('id' => $content->id));
     } catch (HTTP_Exception_Redirect $e) {
         throw $e;
     } catch (exception $e) {
         notes::add('error', 'Der opstod en fejl: ' . $e->getMessage());
         echo 'error';
         //cms::redirect('content/index/'.$contenttype->id);
     }
 }
예제 #16
0
        }
        ajax::success($eqLogic->getInfo());
    }
    if (init('action') == 'getDeviceConfiguration') {
        $eqLogic = zwave::byId(init('id'));
        if (!is_object($eqLogic)) {
            throw new Exception('Razberry plugin non trouvé : ' . init('id'));
        }
        ajax::success($eqLogic->getDeviceConfiguration(init('forceRefresh', false), init('parameter_id', null)));
    }
    if (init('action') == 'setDeviceConfiguration') {
        $eqLogic = zwave::byId(init('id'));
        if (!is_object($eqLogic)) {
            throw new Exception('Razberry plugin non trouvé : ' . init('id'));
        }
        ajax::success($eqLogic->setDeviceConfiguration(json_decode(init('configurations'), true)));
    }
    if (init('action') == 'inspectQueue') {
        ajax::success(zwave::inspectQueue());
    }
    if (init('action') == 'getRoutingTable') {
        ajax::success(zwave::getRoutingTable());
    }
    if (init('action') == 'updateRoute') {
        ajax::success(zwave::updateRoute());
    }
    throw new Exception('Aucune methode correspondante');
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
예제 #17
0
            $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());
}
예제 #18
0
                $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());
}
예제 #19
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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__));
    }
    if (init('action') == 'configPush') {
        $eqLogic = ecodevice::byId(init('id'));
        if (!is_object($eqLogic)) {
            throw new Exception(__('ecodevice eqLogic non trouvé : ', __FILE__) . init('id'));
        }
        $eqLogic->configPush();
        ajax::success(__('Url de push sur ecodevice configuré', __FILE__));
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
예제 #20
0
    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__));
    }
    // action qui permet d'obtenir l'ensemble des eqLogic
    if (init('action') == 'getAll') {
        $eqLogics = eqLogic::byType('vmc');
        // ne pas oublier de modifier pour le nom de votre plugin
        // la liste des équipements
        foreach ($eqLogics as $eqLogic) {
            $data['id'] = $eqLogic->getId();
            $data['humanSidebar'] = $eqLogic->getHumanName(true, false);
            $data['humanContainer'] = $eqLogic->getHumanName(true, true);
            $return[] = $data;
        }
        ajax::success($return);
    }
    // action qui permet d'effectuer la sauvegarde des donéée en asynchrone
    if (init('action') == 'saveStack') {
        $params = init('params');
        ajax::success(vmc::saveStack($params));
        // ne pas oublier de modifier pour le nom de votre plugin
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
?>
3
예제 #21
0
    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__));
    }
    // action qui permet d'obtenir l'ensemble des eqLogic
    if (init('action') == 'getAll') {
        $eqLogics = eqLogic::byType('template');
        // ne pas oublier de modifier pour le nom de votre plugin
        // la liste des équipements
        foreach ($eqLogics as $eqLogic) {
            $data['id'] = $eqLogic->getId();
            $data['humanSidebar'] = $eqLogic->getHumanName(true, false);
            $data['humanContainer'] = $eqLogic->getHumanName(true, true);
            $return[] = $data;
        }
        ajax::success($return);
    }
    // action qui permet d'effectuer la sauvegarde des donéée en asynchrone
    if (init('action') == 'saveStack') {
        $params = init('params');
        ajax::success(template::saveStack($params));
        // ne pas oublier de modifier pour le nom de votre plugin
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
?>
3
예제 #22
0
 public function action_addmeta()
 {
     $meta = ORM::factory('Blocktype_Meta');
     $meta->blocktype_id = arr::get($_POST, 'blocktype_id', '');
     $meta->key = arr::get($_POST, 'key', '');
     $meta->value = arr::get($_POST, 'value', '');
     try {
         $meta->save();
         ajax::success('', array('meta' => $meta->info()));
     } catch (exception $e) {
         ajax::error($e->getMessage());
     }
 }
예제 #23
0
        }
        $interact->remove();
        ajax::success();
    }
    if (init('action') == 'changeState') {
        $interactQuery = interactQuery::byId(init('id'));
        if (!is_object($interactQuery)) {
            throw new Exception(__('InteractQuery ID inconnu', __FILE__));
        }
        $interactQuery->setEnable(init('enable'));
        $interactQuery->save();
        ajax::success();
    }
    if (init('action') == 'changeAllState') {
        $interactQueries = interactQuery::byInteractDefId(init('id'));
        if (is_array($interactQueries)) {
            foreach ($interactQueries as $interactQuery) {
                $interactQuery->setEnable(init('enable'));
                $interactQuery->save();
            }
        }
        ajax::success();
    }
    if (init('action') == 'execute') {
        ajax::success(interactQuery::tryToReply(init('query')));
    }
    throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
예제 #24
0
 public function action_get()
 {
     $newusers = ORM::factory('User')->where('created', '>', time() - 60 * 60 * 24)->count_all();
     $pages = ORM::factory('Page')->where('type', '=', 'page')->count_all();
     ajax::success('ok', array('newusers' => $newusers, 'pages' => $pages));
 }
예제 #25
0
        tesla::syncEqLogicWithTeslaSite();
        ajax::success();
    }
    if (init('action') == 'createToken') {
        $result = tesla::createToken(init('email'), init('password'));
        //config::save('token',$result,'tesla');
        ajax::success($result);
    }
    if (init('action') == 'checkAPI') {
        ajax::success(tesla::checkAPI());
    }
    // action qui permet d'obtenir l'ensemble des eqLogic
    if (init('action') == 'getAll') {
        $eqLogics = eqLogic::byType('tesla');
        // ne pas oublier de modifier pour le nom de votre plugin
        // la liste des équipements
        foreach ($eqLogics as $eqLogic) {
            $data['id'] = $eqLogic->getId();
            $data['humanSidebar'] = $eqLogic->getHumanName(true, false);
            $data['humanContainer'] = $eqLogic->getHumanName(true, true);
            $return[] = $data;
        }
        ajax::success($return);
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
?>
3
예제 #26
0
 public function action_delete()
 {
     $block = ORM::factory('Block', arr::get($_POST, 'block_id'));
     if (!$block->loaded()) {
         ajax::error('Blokken blev ikke fundet.');
     }
     try {
         $block->delete();
         ajax::success('ok');
     } catch (exception $e) {
         ajax::error('Der opstod en fejl og blokken kunne ikke slettes. Siden sagde: ' . $e->getMessage());
     }
 }
예제 #27
0
 public function action_savesetting()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $option = $user->option;
     $setting = arr::get($_POST, 'setting', false);
     $value = arr::get($_POST, 'value', false);
     if (!$setting || $value === false) {
         ajax::error('Something wen\'t wrong and your setting couldn\'t be saved. I received no data!');
     }
     $update_timestamp = false;
     switch ($setting) {
         case 'reminder':
             $option->reminder = $value;
             $update_timestamp = true;
             break;
         case 'reminder_hour':
             $option->reminder_hour = $value;
             $update_timestamp = true;
             break;
         case 'reminder_minute':
             $option->reminder_minute = $value;
             $update_timestamp = true;
             break;
         case 'reminder_meridiem':
             $option->reminder_meridiem = $value;
             $update_timestamp = true;
             break;
         case 'timezone_id':
             $option->timezone_id = $value;
             $update_timestamp = true;
             break;
         case 'privacymode':
             $option->privacymode = $value;
             break;
         case 'privacymode_minutes':
             $option->privacymode_minutes = $value;
             break;
         case 'hemingwaymode':
             $option->hemingwaymode = $value;
             break;
         case 'public':
             $option->public = $value;
             break;
         case 'rtl':
             $option->rtl = $value;
             break;
         case 'language':
             $option->language = (int) $value;
             break;
         default:
             ajax::error('Something wen\'t wrong and your setting couldn\'t be saved. I received no data!');
             break;
     }
     try {
         if ($update_timestamp) {
             $option->next_reminder = $user->get_next_reminder($user);
         }
         $option->save();
         ajax::success('Saved');
     } catch (ORM_Validation_Exception $e) {
         ajax::error('An error occurred and your setting couldn\'t be saved.', array('errors' => $e->errors()));
     }
 }
예제 #28
0
        $RadioLastCode = cache::byKey('arduidom_radio_lastcode');
        $RadioLastCode = $RadioLastCode->getValue();
        $RadioRepeats = cache::byKey('arduidom_radio_index');
        $RadioRepeats = $RadioRepeats->getValue();
        $RadioLeanMode = cache::byKey('arduidom_radio_learn');
        $RadioLeanMode = $RadioLeanMode->getValue();
        $text = 'UNIX TIME (for debug):' . time() . "\n" . "\n";
        $text = $text . "Mode Apprentissage : " . $RadioLeanMode . " \n";
        if ($RadioRepeats < 3) {
            $text = $text . "Appuyer sur la touche " . (3 - $RadioRepeats) . " fois avec une pause de 3 à 5 secondes entre chaque appui.\n";
            if ($RadioLastCode != '') {
                $text = $text . "Code recu : " . $RadioLastCode . "\n";
            }
        } else {
            $text = $text . "Copiez ce code dans la valeur : " . $RadioLastCode . " OK \n";
            $text = $text . "Vous pouvez fermer la fenetre. \n";
            $etat = "[END SUCCESS]\n";
            cache::set('arduidom_radio_index', 0);
            cache::set('arduidom_radio_learn', 0);
        }
        if ($etat == '') {
            ajax::success($text);
        } else {
            ajax::success([$etat, $text]);
        }
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
예제 #29
0
 * 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') == 'remove') {
        $connection = connection::byId(init('id'));
        if (!is_object($connection)) {
            throw new Exception(__('Connexion inconnue. Vérifiez l\'id', __FILE__));
        }
        $connection->remove();
        ajax::success();
    }
    if (init('action') == 'ban') {
        $connection = connection::byId(init('id'));
        if (!is_object($connection)) {
            throw new Exception(__('Connexion inconnue. Vérifiez l\'id', __FILE__));
        }
        $connection->setStatus('Ban');
        $connection->save();
        ajax::success();
    }
    throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
예제 #30
0
        }
    }
    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 (!is_object($market)) {
            throw new Exception(__('Impossible de trouver l\'objet associé : ', __FILE__) . init('id'));
        }
        $market->setComment(init('comment', null), init('order', null));
        ajax::success();
    }
    if (init('action') == 'sendReportBug') {
        $ticket = json_decode(init('ticket'), true);
        market::saveTicket($ticket);
        ajax::success(array('url' => config::byKey('market::address') . '/index.php?v=d&p=ticket'));
    }
    throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}