diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml index 8d90800544..8fa5da282f 100644 --- a/.github/workflows/phpstan.yaml +++ b/.github/workflows/phpstan.yaml @@ -2,28 +2,34 @@ name: PHPStan on: push: - branches: [ alpha ] + branches: [ alpha, feat/object_config ] pull_request: branches: [ alpha ] jobs: phpstan: runs-on: ubuntu-latest + # define every php version to test + strategy: + # do not stop at first fail + fail-fast: false + matrix: + php: [7.4, 8.2] + steps: - uses: actions/checkout@v4 - - name: Setup PHP 7.4 for dependencies + - name: Setup PHP ${{ matrix.php }} for dependencies uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: ${{ matrix.php }} - name: Install Dependencies - run: composer update --ignore-platform-reqs - - - name: Setup PHP 8.2 for PHPStan - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 + run: | + # copy common.config.php for composer autoloader + cp core/config/common.config.sample.php core/config/common.config.php + # install composer dependencies + composer update --ignore-platform-reqs - name: Restore PHPStan cache id: cache-phpstan @@ -32,12 +38,8 @@ jobs: path: phpstan.phar key: phpstan-1 - - name: Download PHPStan - if: steps.cache-phpstan.outputs.cache-hit != 'true' - run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar - - name: Run PHPStan - run: php phpstan.phar analyse --configuration phpstan.neon + run: vendor/bin/phpstan analyse --configuration phpstan.neon update-baseline: needs: phpstan @@ -50,9 +52,7 @@ jobs: - name: Delete existing branch if exists run: | - if git ls-remote --heads origin update-phpstan-baseline | grep update-phpstan-baseline; then - git push origin --delete update-phpstan-baseline - fi + git ls-remote --exit-code --heads origin update-phpstan-baseline && git push origin --delete update-phpstan-baseline - name: Setup PHP 7.4 for dependencies uses: shivammathur/setup-php@v2 @@ -62,19 +62,11 @@ jobs: - name: Install Dependencies run: composer update --ignore-platform-reqs - - name: Setup PHP 8.2 for PHPStan - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - - - name: Download PHPStan - run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar - - name: Generate new baseline id: generate-baseline run: | cp phpstan-baseline.neon phpstan-baseline.neon.old - php phpstan.phar analyse --configuration phpstan.neon --generate-baseline + vendor/bin/phpstan analyse --configuration phpstan.neon --generate-baseline if ! diff -q phpstan-baseline.neon phpstan-baseline.neon.old > /dev/null; then echo "baseline_changed=true" >> $GITHUB_OUTPUT fi diff --git a/composer.json b/composer.json index 25d7fc3830..417b6619d6 100644 --- a/composer.json +++ b/composer.json @@ -15,5 +15,24 @@ "platform": { "php": "7.4" } + }, + "require-dev": { + "phpstan/phpstan": "^2.1" + }, + "autoload": { + "psr-4": { + "Jeedom\\plugins\\": "plugins/" + }, + "files": [ + "core/config/common.config.php", + "core/php/utils.inc.php", + "core/config/jeedom.config.php", + "core/config/compatibility.config.php" + ], + "classmap": [ + "core/class/", + "core/com/", + "core/repo/" + ] } } diff --git a/composer.lock b/composer.lock index b78c8572c4..53b8a65e09 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6d3817ee337cc5ed162b1e9463030e8a", + "content-hash": "d2faa51c0ec5175dc36b46b3356938d9", "packages": [ { "name": "bacon/bacon-qr-code", @@ -243,16 +243,16 @@ }, { "name": "influxdata/influxdb-client-php", - "version": "3.6.0", + "version": "3.8.0", "source": { "type": "git", "url": "https://github.com/influxdata/influxdb-client-php.git", - "reference": "3606b12214508f22126b7ed0565d53380674312a" + "reference": "59ac11d63ce030973c79d5b05797813761a0d58e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/3606b12214508f22126b7ed0565d53380674312a", - "reference": "3606b12214508f22126b7ed0565d53380674312a", + "url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/59ac11d63ce030973c79d5b05797813761a0d58e", + "reference": "59ac11d63ce030973c79d5b05797813761a0d58e", "shasum": "" }, "require": { @@ -287,9 +287,9 @@ ], "support": { "issues": "https://github.com/influxdata/influxdb-client-php/issues", - "source": "https://github.com/influxdata/influxdb-client-php/tree/3.6.0" + "source": "https://github.com/influxdata/influxdb-client-php/tree/3.8.0" }, - "time": "2024-06-24T10:01:53+00:00" + "time": "2025-06-26T05:12:59+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -1487,7 +1487,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -1543,7 +1543,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0" }, "funding": [ { @@ -1563,16 +1563,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", "shasum": "" }, "require": { @@ -1623,7 +1623,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" }, "funding": [ { @@ -1639,7 +1639,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-01-02T08:10:11+00:00" }, { "name": "symfony/service-contracts", @@ -1856,7 +1856,66 @@ "time": "2022-06-03T18:03:27+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "2.1.21", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ccf445757458c06a04eb3f803603cb118fe5fa6", + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-07-28T19:35:08+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": {}, diff --git a/core/ajax/cache.ajax.php b/core/ajax/cache.ajax.php index ee5b5baef7..e767ecdabc 100644 --- a/core/ajax/cache.ajax.php +++ b/core/ajax/cache.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -54,7 +54,7 @@ ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/cmd.ajax.php b/core/ajax/cmd.ajax.php index 9b858a2dbc..bb20ed3246 100644 --- a/core/ajax/cmd.ajax.php +++ b/core/ajax/cmd.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -29,7 +29,7 @@ if (init('action') == 'getWidgetHelp') { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue - Vérifiez l\'id', __FILE__)); + throw new Exception(new Trad('Commande inconnue - Vérifiez l\'id', __FILE__)); } $info_cmd = array(); $info_cmd['id'] = $cmd->getId(); @@ -54,7 +54,7 @@ } else { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue - Vérifiez l\'id', __FILE__)); + throw new Exception(new Trad('Commande inconnue - Vérifiez l\'id', __FILE__)); } $info_cmd = array(); $info_cmd['id'] = $cmd->getId(); @@ -69,7 +69,7 @@ foreach ($cmds as $id) { $cmd = cmd::byId($id); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue. Vérifiez l\'ID', __FILE__) . ' ' . $id); + throw new Exception(new Trad('Commande inconnue. Vérifiez l\'ID', __FILE__) . ' ' . $id); } $cmd->setIsVisible(init('isVisible')); $cmd->save(true); @@ -80,17 +80,17 @@ if (init('action') == 'execCmd') { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('ID de commande inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('ID de commande inconnu :', __FILE__) . ' ' . init('id')); } $eqLogic = $cmd->getEqLogic(); if ($cmd->getType() == 'action' && !$eqLogic->hasRight('x')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } if (!$cmd->checkAccessCode(init('codeAccess'))) { - throw new Exception(__('Cette action nécessite un code d\'accès', __FILE__), -32005); + throw new Exception(new Trad('Cette action nécessite un code d\'accès', __FILE__), -32005); } if ($cmd->getType() == 'action' && $cmd->getConfiguration('actionConfirm') == 1 && init('confirmAction') != 1) { - throw new Exception(__('Cette action nécessite une confirmation', __FILE__), -32006); + throw new Exception(new Trad('Cette action nécessite une confirmation', __FILE__), -32006); } $options = is_json(init('value'), array()); if (init('user_login') != '') { @@ -105,7 +105,7 @@ if (init('action') == 'getByObjectNameEqNameCmdName') { $cmd = cmd::byObjectNameEqLogicNameCmdName(init('object_name'), init('eqLogic_name'), init('cmd_name')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('object_name') . '/' . init('eqLogic_name') . '/' . init('cmd_name')); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('object_name') . '/' . init('eqLogic_name') . '/' . init('cmd_name')); } ajax::success($cmd->getId()); } @@ -113,7 +113,7 @@ if (init('action') == 'getByObjectNameCmdName') { $cmd = cmd::byObjectNameCmdName(init('object_name'), init('cmd_name')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('object_name') . '/' . init('cmd_name'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('object_name') . '/' . init('cmd_name'), 9999); } ajax::success(utils::o2a($cmd)); } @@ -121,14 +121,14 @@ if (init('action') == 'byId') { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); } ajax::success(jeedom::toHumanReadable(utils::o2a($cmd))); } if (init('action') == 'copyHistoryToCmd') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); ajax::success(history::copyHistoryToCmd(init('source_id'), init('target_id'))); @@ -136,7 +136,7 @@ if (init('action') == 'replaceCmd') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); ajax::success(jeedom::replaceTag(array('#' . str_replace('#', '', init('source_id')) . '#' => '#' . str_replace('#', '', init('target_id')) . '#'))); @@ -146,18 +146,18 @@ $cmd_id = cmd::humanReadableToCmd(init('humanName')); $cmd = cmd::byId(str_replace('#', '', $cmd_id)); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('humanName'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('humanName'), 9999); } ajax::success(utils::o2a($cmd)); } if (init('action') == 'usedBy') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); } $result = $cmd->getUsedBy(); $return = array('cmd' => array(), 'eqLogic' => array(), 'scenario' => array(), 'plan' => array(), 'view' => array(), 'interactDef' => array()); @@ -207,36 +207,36 @@ if (init('action') == 'dropInflux') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $cmd = cmd::byId(init('cmd_id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); } ajax::success($cmd->dropInflux()); } if (init('action') == 'historyInflux') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $cmd = cmd::byId(init('cmd_id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('id'), 9999); } ajax::success($cmd->historyInflux()); } if (init('action') == 'dropDatabaseInflux') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(cmd::dropInfluxDatabase()); } if (init('action') == 'historyInfluxAll') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(cmd::historyInfluxAll()); } @@ -256,7 +256,7 @@ if (init('action') == 'getCmd') { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Commande inconnue :', __FILE__) . ' ' . init('id')); } $return = jeedom::toHumanReadable(utils::o2a($cmd)); $eqLogic = $cmd->getEqLogic(); @@ -270,7 +270,7 @@ if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $cmd_ajax = jeedom::fromHumanReadable(json_decode(init('cmd'), true)); @@ -290,7 +290,7 @@ if (init('action') == 'multiSave') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $cmds = json_decode(init('cmd'), true); @@ -307,7 +307,7 @@ if (init('action') == 'changeHistoryPoint') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $history = history::byCmdIdDatetime(init('cmd_id'), init('datetime')); @@ -324,7 +324,7 @@ $history = history::byCmdIdDatetime(init('cmd_id'), init('datetime'), date('Y-m-d H:i:s', strtotime(init('datetime') . ' +1 month')), init('oldValue')); } if (!is_object($history)) { - throw new Exception(__('Aucun point ne correspond pour l\'historique :', __FILE__) . ' ' . init('cmd_id') . ' - ' . init('datetime'), init('oldValue')); + throw new Exception(new Trad('Aucun point ne correspond pour l\'historique :', __FILE__) . ' ' . init('cmd_id') . ' - ' . init('datetime'), init('oldValue')); } $value = init('value', null); if ($value === '') { @@ -405,7 +405,7 @@ if (is_numeric(init('id'))) { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('ID de commande inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('ID de commande inconnu :', __FILE__) . ' ' . init('id')); } $usage = $cmd->getCache('usage::history', 0); $cmd->setCache('usage::history', $usage + 1); @@ -414,7 +414,7 @@ $eqLogic = $cmd->getEqLogic(); if (!$eqLogic->hasRight('r')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $derive = init('derive', $cmd->getDisplay('graphDerive')); if (trim($derive) == '') { @@ -500,18 +500,18 @@ if(is_object($cmd)){ ajax::success($cmd->getLastHistory($_time)); } else { - throw new Exception(__('Nombre maximum de niveaux d’éléments affichés dans les graphiques de liens', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Nombre maximum de niveaux d’éléments affichés dans les graphiques de liens', __FILE__) . ' ' . init('id')); } } if (init('action') == 'emptyHistory') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } unautorizedInDemo(); $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('ID de commande inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('ID de commande inconnu :', __FILE__) . ' ' . init('id')); } $cmd->emptyHistory(init('date')); ajax::success(); @@ -555,16 +555,16 @@ if (init('action') == 'getDeadCmd') { $return = array( - 'core' => array('cmd' => jeedom::deadCmd(), 'name' => __('Jeedom', __FILE__)), - 'cmd' => array('cmd' => cmd::deadCmd(), 'name' => __('Commande', __FILE__)), - 'jeeObject' => array('cmd' => jeeObject::deadCmd(), 'name' => __('Objet', __FILE__)), - 'scenario' => array('cmd' => scenario::consystencyCheck(true), 'name' => __('Scénario', __FILE__)), - 'interactDef' => array('cmd' => interactDef::deadCmd(), 'name' => __('Interaction', __FILE__)), - 'user' => array('cmd' => user::deadCmd(), 'name' => __('Utilisateur', __FILE__)), + 'core' => array('cmd' => jeedom::deadCmd(), 'name' => new Trad('Jeedom', __FILE__)), + 'cmd' => array('cmd' => cmd::deadCmd(), 'name' => new Trad('Commande', __FILE__)), + 'jeeObject' => array('cmd' => jeeObject::deadCmd(), 'name' => new Trad('Objet', __FILE__)), + 'scenario' => array('cmd' => scenario::consystencyCheck(true), 'name' => new Trad('Scénario', __FILE__)), + 'interactDef' => array('cmd' => interactDef::deadCmd(), 'name' => new Trad('Interaction', __FILE__)), + 'user' => array('cmd' => user::deadCmd(), 'name' => new Trad('Utilisateur', __FILE__)), ); foreach (plugin::listPlugin(true) as $plugin) { $plugin_id = $plugin->getId(); - $return[$plugin_id] = array('cmd' => array(), 'name' => __('Plugin', __FILE__) . ' ' . $plugin->getName()); + $return[$plugin_id] = array('cmd' => array(), 'name' => new Trad('Plugin', __FILE__) . ' ' . $plugin->getName()); if (method_exists($plugin_id, 'deadCmd')) { $return[$plugin_id]['cmd'] = $plugin_id::deadCmd(); } else { @@ -574,7 +574,7 @@ ajax::success($return); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/config.ajax.php b/core/ajax/config.ajax.php index 2cdb9a0fee..32d678f732 100644 --- a/core/ajax/config.ajax.php +++ b/core/ajax/config.ajax.php @@ -21,14 +21,14 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(array('uploadImage')); if (init('action') == 'genApiKey') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); if (init('plugin') == 'core') { @@ -52,7 +52,7 @@ if (init('action') == 'getKey') { $keys = init('key'); if ($keys == '') { - throw new Exception(__('Aucune clef demandée', __FILE__)); + throw new Exception(new Trad('Aucune clef demandée', __FILE__)); } if (is_json($keys)) { $keys = json_decode($keys, true); @@ -68,7 +68,7 @@ if (init('action') == 'addKey') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $values = json_decode(init('value'), true); @@ -82,7 +82,7 @@ unautorizedInDemo(); $keys = init('key'); if ($keys == '') { - throw new Exception(__('Aucune clef demandée', __FILE__)); + throw new Exception(new Trad('Aucune clef demandée', __FILE__)); } if (is_json($keys)) { $keys = json_decode($keys, true); @@ -98,7 +98,7 @@ if (init('action') == 'uploadImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); @@ -107,14 +107,14 @@ config::save($key, config::getDefaultConfiguration()['core'][$key]); if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre 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) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $uploaddir = realpath(__DIR__ . '/../../data/backgrounds'); @@ -127,7 +127,7 @@ @unlink($filepath); file_put_contents($filepath, file_get_contents($_FILES['file']['tmp_name'])); if (!file_exists($filepath)) { - throw new Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } config::save($key, '/data/backgrounds/config_' . $page . $extension); @@ -136,7 +136,7 @@ if (init('action') == 'removeImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); @@ -149,7 +149,7 @@ ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/cron.ajax.php b/core/ajax/cron.ajax.php index 654ca34b2d..a5313760a6 100644 --- a/core/ajax/cron.ajax.php +++ b/core/ajax/cron.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -36,7 +36,7 @@ unautorizedInDemo(); $cron = cron::byId(init('id')); if (!is_object($cron)) { - throw new Exception(__('Cron id inconnu', __FILE__)); + throw new Exception(new Trad('Cron id inconnu', __FILE__)); } $cron->remove(); ajax::success(); @@ -53,7 +53,7 @@ if (init('action') == 'start') { $cron = cron::byId(init('id')); if (!is_object($cron)) { - throw new Exception(__('Cron id inconnu', __FILE__)); + throw new Exception(new Trad('Cron id inconnu', __FILE__)); } $cron->run(); sleep(1); @@ -63,14 +63,14 @@ if (init('action') == 'stop') { $cron = cron::byId(init('id')); if (!is_object($cron)) { - throw new Exception(__('Cron id inconnu', __FILE__)); + throw new Exception(new Trad('Cron id inconnu', __FILE__)); } $cron->halt(); sleep(1); ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/ajax/dataStore.ajax.php b/core/ajax/dataStore.ajax.php index 4a106e9416..a69ac1f7b7 100644 --- a/core/ajax/dataStore.ajax.php +++ b/core/ajax/dataStore.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -29,7 +29,7 @@ if (init('action') == 'remove') { $dataStore = dataStore::byId(init('id')); if (!is_object($dataStore)) { - throw new Exception(__('Dépôt de données inconnu. Vérifiez l\'ID :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Dépôt de données inconnu. Vérifiez l\'ID :', __FILE__) . ' ' . init('id')); } $dataStore->remove(); ajax::success(); @@ -45,7 +45,7 @@ $dataStore = dataStore::byId(init('id')); } if (!is_object($dataStore)) { - throw new Exception(__('Dépôt de données inconnu. Vérifiez l\'ID :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Dépôt de données inconnu. Vérifiez l\'ID :', __FILE__) . ' ' . init('id')); } $dataStore->setValue(init('value')); $dataStore->save(); @@ -88,7 +88,7 @@ function jeeAjax_datastoreReturn($_datastores=[], $_usedBy=0) { $key = trim(init('key')); $dataStore = dataStore::byTypeLinkIdKey(init('type'), init('linkId'), $key); if (!is_object($dataStore)) { - throw new Exception(__('Dépôt de données inconnu.', __FILE__) . $key); + throw new Exception(new Trad('Dépôt de données inconnu.', __FILE__) . $key); } $return = jeeAjax_datastoreReturn($dataStore, init('usedBy')); ajax::success($return); @@ -99,7 +99,7 @@ function jeeAjax_datastoreReturn($_datastores=[], $_usedBy=0) { ajax::success($return); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/eqLogic.ajax.php b/core/ajax/eqLogic.ajax.php index 99f30677e3..38382ae6c0 100644 --- a/core/ajax/eqLogic.ajax.php +++ b/core/ajax/eqLogic.ajax.php @@ -21,30 +21,30 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('uploadImage')); if (init('action') == 'uploadImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); } if (init('file') == '') { if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .jpg .png .gif .svg .webp) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png .gif .svg .webp) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $upfilepath = $_FILES['file']['tmp_name']; } else { @@ -64,7 +64,7 @@ $filepath = __DIR__ . '/../../data/eqLogic/' . $filename; file_put_contents($filepath, file_get_contents($upfilepath)); if (!file_exists($filepath)) { - throw new \Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new \Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } $eqLogic->save(true); ajax::success(array('filepath' => $eqLogic->getImage())); @@ -72,12 +72,12 @@ if (init('action') == 'removeImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } $eqLogic->getConfiguration('image::data', ''); $eqLogic->getConfiguration('image::sha512', ''); @@ -95,7 +95,7 @@ $object = jeeObject::byId(init('object_id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } $return = utils::o2a($object); $return['eqLogic'] = array(); @@ -115,7 +115,7 @@ if (init('action') == 'byId') { $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); } ajax::success(utils::o2a($eqLogic)); } @@ -123,7 +123,7 @@ if (init('action') == 'byLogical') { $eqLogic = eqLogic::byLogicalId(init('logical'), init('type')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez le logicalId ou le type', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez le logicalId ou le type', __FILE__)); } ajax::success(utils::o2a($eqLogic)); } @@ -149,7 +149,7 @@ } else { $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('Eqlogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Eqlogic inconnu. Vérifiez l\'ID', __FILE__)); } $info_eqLogic = array(); $info_eqLogic['id'] = $eqLogic->getId(); @@ -260,14 +260,14 @@ if (init('action') == 'setIsEnable') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); } if (!$eqLogic->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $eqLogic->setIsEnable(init('isEnable')); $eqLogic->save(true); @@ -299,7 +299,7 @@ continue; } if (!isset($eqLogic_json['generic_type'])) { - throw new Exception(__('Pas de Type Generic fourni', __FILE__)); + throw new Exception(new Trad('Pas de Type Generic fourni', __FILE__)); } $eqLogic = eqLogic::byId($eqLogic_json['id']); if (!is_object($eqLogic)) { @@ -318,7 +318,7 @@ foreach ($eqLogics as $id) { $eqLogic = eqLogic::byId($id); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); } if (!$eqLogic->hasRight('w')) { continue; @@ -334,7 +334,7 @@ foreach ($eqLogics as $id) { $eqLogic = eqLogic::byId($id); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); } if (!$eqLogic->hasRight('w')) { continue; @@ -351,7 +351,7 @@ foreach ($eqLogics as $id) { $eqLogic = eqLogic::byId($id); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $id); } if (!$eqLogic->hasRight('w')) { continue; @@ -365,16 +365,16 @@ if (init('action') == 'simpleSave') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogicSave = json_decode(init('eqLogic'), true); $eqLogic = eqLogic::byId($eqLogicSave['id']); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $eqLogicSave['id']); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . $eqLogicSave['id']); } if (!$eqLogic->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } utils::a2o($eqLogic, $eqLogicSave); $eqLogic->save(); @@ -384,14 +384,14 @@ if (init('action') == 'copy') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); } if (init('name') == '') { - throw new Exception(__('Le nom de la copie de l\'équipement ne peut être vide', __FILE__)); + throw new Exception(new Trad('Le nom de la copie de l\'équipement ne peut être vide', __FILE__)); } ajax::success(utils::o2a($eqLogic->copy(init('name')))); } @@ -400,7 +400,7 @@ $used = array(); $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__)); } $data = array('node' => array(), 'link' => array()); $data = $eqLogic->getLinkData($data, 0, 2); @@ -439,11 +439,11 @@ if (init('action') == 'usedBy') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('Equipement inconnu :', __FILE__) . ' ' . init('id'), 9999); + throw new Exception(new Trad('Equipement inconnu :', __FILE__) . ' ' . init('id'), 9999); } $result = $eqLogic->getUsedBy(); $return = array('cmd' => array(), 'eqLogic' => array(), 'scenario' => array(), 'plan' => array(), 'view' => array(), 'interactDef' => array()); @@ -494,14 +494,14 @@ if (init('action') == 'remove') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } if (!$eqLogic->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $eqLogic->remove(); ajax::success(); @@ -510,11 +510,11 @@ if (init('action') == 'get') { $typeEqLogic = init('type'); if ($typeEqLogic == '' || !class_exists($typeEqLogic)) { - throw new Exception(__('Type incorrect (classe équipement inexistante) :', __FILE__) . ' ' . $typeEqLogic); + throw new Exception(new Trad('Type incorrect (classe équipement inexistante) :', __FILE__) . ' ' . $typeEqLogic); } $eqLogic = $typeEqLogic::byId(init('id')); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('EqLogic inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } $return = utils::o2a($eqLogic); $return['cmd'] = array(); @@ -534,7 +534,7 @@ if (init('action') == 'save') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $eqLogicSaves = init('eqLogic'); @@ -545,12 +545,12 @@ foreach ($eqLogicsSave as $eqLogicSave) { if (!is_array($eqLogicSave)) { - throw new Exception(__('Informations reçues incorrectes', __FILE__)); + throw new Exception(new Trad('Informations reçues incorrectes', __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); + throw new Exception(new Trad('Type incorrect, (classe commande inexistante)', __FILE__) . $typeCmd); } $eqLogic = null; if (isset($eqLogicSave['id'])) { @@ -561,7 +561,7 @@ $eqLogic->setEqType_name(init('type')); } else { if (!$eqLogic->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } } if (method_exists($eqLogic, 'preAjax')) { @@ -621,7 +621,7 @@ ajax::success($alerts); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/event.ajax.php b/core/ajax/event.ajax.php index f47de462d6..ddf0be3513 100644 --- a/core/ajax/event.ajax.php +++ b/core/ajax/event.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -30,7 +30,7 @@ ajax::success(event::changes(init('datetime', 0), 59)); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/history.ajax.php b/core/ajax/history.ajax.php index 5f1e0e9e58..86e1263b30 100644 --- a/core/ajax/history.ajax.php +++ b/core/ajax/history.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -31,7 +31,7 @@ ajax::success(history::removeHistoryInFutur()); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/interact.ajax.php b/core/ajax/interact.ajax.php index 31ad3f4008..a3d8db9037 100644 --- a/core/ajax/interact.ajax.php +++ b/core/ajax/interact.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -69,7 +69,7 @@ if (init('action') == 'autoCompleteGroup') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $return = array(); foreach (interactDef::listGroup(init('term')) as $group) { @@ -87,7 +87,7 @@ unautorizedInDemo(); $interact = interactDef::byId(init('id')); if (!is_object($interact)) { - throw new Exception(__('Interaction inconnue. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Interaction inconnue. Vérifiez l\'ID', __FILE__)); } $interact->remove(); ajax::success(); @@ -97,7 +97,7 @@ unautorizedInDemo(); $interactQuery = interactQuery::byId(init('id')); if (!is_object($interactQuery)) { - throw new Exception(__('InteractQuery ID inconnu', __FILE__)); + throw new Exception(new Trad('InteractQuery ID inconnu', __FILE__)); } $interactQuery->setEnable(init('enable')); $interactQuery->save(); @@ -120,7 +120,7 @@ ajax::success(interactQuery::tryToReply(init('query'))); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/jeedom.ajax.php b/core/ajax/jeedom.ajax.php index efa538d3fe..ba992288e7 100644 --- a/core/ajax/jeedom.ajax.php +++ b/core/ajax/jeedom.ajax.php @@ -38,14 +38,14 @@ $return['language'] = config::byKey('language', 'core', 'fr_FR'); $return['userProfils'] = $_SESSION['user']->getOptions(); - $return['userProfils']['defaultMobileViewName'] = __('Vue', __FILE__); + $return['userProfils']['defaultMobileViewName'] = new Trad('Vue', __FILE__); if ($_SESSION['user']->getOptions('defaultDesktopView') != '') { $view = view::byId($_SESSION['user']->getOptions('defaultDesktopView')); if (is_object($view)) { $return['userProfils']['defaultMobileViewName'] = $view->getName(); } } - $return['userProfils']['defaultMobileObjectName'] = __('Objet', __FILE__); + $return['userProfils']['defaultMobileObjectName'] = new Trad('Objet', __FILE__); if ($_SESSION['user']->getOptions('defaultDashboardObject') != '') { $object = jeeObject::byId($_SESSION['user']->getOptions('defaultDashboardObject')); if (is_object($object)) { @@ -71,7 +71,7 @@ } if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'version') { @@ -117,13 +117,13 @@ $version = substr(jeedom::version(), 0, 3); ajax::success(config::byKey('doc::base_url', 'core') . '/' . config::byKey('language', 'core', 'fr_FR') . '/core/' . $version . '/' . secureXSS($page) . '?theme=' . $theme); } - throw new Exception(__('Aucune documentation trouvée', __FILE__), -1234); + throw new Exception(new Trad('Aucune documentation trouvée', __FILE__), -1234); } if (init('action') == 'addWarnme') { $cmd = cmd::byId(init('cmd_id')); if (!is_object($cmd)) { - throw new Exception(__('Commande non trouvée :', __FILE__) . ' ' . init('cmd_id')); + throw new Exception(new Trad('Commande non trouvée :', __FILE__) . ' ' . init('cmd_id')); } $options = array( 'type' => 'cmd', @@ -142,13 +142,13 @@ $listener->save(true); ajax::success(); } else { - throw new Exception(__('Aucune Commande de Notification :', __FILE__) . ' ' . init('cmd_id')); + throw new Exception(new Trad('Aucune Commande de Notification :', __FILE__) . ' ' . init('cmd_id')); ajax::error(); } } if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'ssh') { @@ -404,23 +404,23 @@ mkdir($uploaddir); } if (!file_exists($uploaddir)) { - throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); + throw new Exception(new Trad('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.gz'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .tar.gz) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .tar.gz) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 1000000000) { - throw new Exception(__('Le fichier est trop gros (maximum 1Go)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 1Go)', __FILE__)); } if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de déplacer le fichier temporaire', __FILE__)); + throw new Exception(new Trad('Impossible de déplacer le fichier temporaire', __FILE__)); } if (!file_exists($uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); } ajax::success(); } @@ -464,107 +464,107 @@ } $object = $type::byId(init('filter_id')); if (!is_object($object)) { - throw new Exception(__('Type :', __FILE__) . init('filter_type') . ' ' . __('avec id :', __FILE__) . ' ' . init('filter_id') . ' ' . __('inconnu', __FILE__)); + throw new Exception(new Trad('Type :', __FILE__) . init('filter_type') . ' ' . new Trad('avec id :', __FILE__) . ' ' . init('filter_id') . ' ' . new Trad('inconnu', __FILE__)); } ajax::success($object->getLinkData()); } if (init('action') == 'getFileFolder') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(ls($pathfile, '*', false, array(init('type')))); } if (init('action') == 'getFileContent') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $pathinfo = pathinfo(init('path')); if (!in_array($pathinfo['extension'], array('php', 'js', 'json', 'sql', 'ini', 'css', 'py', 'css', 'html', 'yaml', 'config', 'conf'))) { - throw new Exception(__('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); + throw new Exception(new Trad('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); } $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(file_get_contents($pathfile)); } if (init('action') == 'setFileContent') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $pathinfo = pathinfo(init('path')); if (!in_array($pathinfo['extension'], array('php', 'js', 'json', 'sql', 'ini', 'css', 'py', 'css', 'html', 'yaml', 'config', 'conf'))) { - throw new Exception(__('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); + throw new Exception(new Trad('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); } $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(file_put_contents($pathfile, init('content'))); } if (init('action') == 'deleteFile') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $pathinfo = pathinfo(init('path')); if (!in_array($pathinfo['extension'], array('php', 'js', 'json', 'sql', 'ini', 'css', 'py', 'css', 'html', 'yaml', 'config', 'conf'))) { - throw new Exception(__('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); + throw new Exception(new Trad('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); } $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(unlink($pathfile)); } if (init('action') == 'createFile') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $pathinfo = pathinfo(init('name')); if (!in_array($pathinfo['extension'], array('php', 'js', 'json', 'sql', 'ini', 'css', 'py', 'css', 'html', 'yaml', 'config', 'conf'))) { - throw new Exception(__('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); + throw new Exception(new Trad('Vous ne pouvez éditer ce type d\'extension :', __FILE__) . ' ' . $pathinfo['extension']); } $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } touch($pathfile . init('name')); if (!file_exists($pathfile . init('name'))) { - throw new Exception(__('Impossible de créer le fichier, vérifiez les droits', __FILE__)); + throw new Exception(new Trad('Impossible de créer le fichier, vérifiez les droits', __FILE__)); } ajax::success(); } @@ -573,11 +573,11 @@ unautorizedInDemo(); $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } mkdir($pathfile . '/' . init('name')); ajax::success(); @@ -587,11 +587,11 @@ unautorizedInDemo(); $pathfile = calculPath(init('src')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(rename($pathfile, init('dst'))); } @@ -600,11 +600,11 @@ unautorizedInDemo(); $pathfile = calculPath(init('path')); if ($pathfile === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $rootPath = realpath(__DIR__ . '/../../'); if (strpos($pathfile, $rootPath) === false) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(rrmdir($pathfile)); } @@ -619,18 +619,18 @@ if (init('action') == 'uploadImageIcon') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .jpg .png .gif .jpeg .svg .webp) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png .gif .jpeg .svg .webp) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $path = init('filepath'); if (!file_exists(__DIR__ . '/../../' . $path)) { @@ -640,23 +640,23 @@ $filepath = __DIR__ . '/../../' . $path . $filename; file_put_contents($filepath, file_get_contents($_FILES['file']['tmp_name'])); if (!file_exists($filepath)) { - throw new \Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new \Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } ajax::success(array('filepath' => $filepath)); } if (init('action') == 'removeImageIcon') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $filepath = __DIR__ . '/../../' . init('filepath'); if (!file_exists($filepath)) { - throw new Exception(__('Fichier introuvable, impossible de le supprimer', __FILE__)); + throw new Exception(new Trad('Fichier introuvable, impossible de le supprimer', __FILE__)); } unlink($filepath); if (file_exists($filepath)) { - throw new Exception(__('Impossible de supprimer le fichier', __FILE__)); + throw new Exception(new Trad('Impossible de supprimer le fichier', __FILE__)); } ajax::success(); } @@ -690,7 +690,7 @@ ajax::success(jeedom::massReplace(init('options', array()), init('eqlogics', array()), init('cmds', array()))); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/listener.ajax.php b/core/ajax/listener.ajax.php index e0abe1d9d1..15bd7a93b0 100644 --- a/core/ajax/listener.ajax.php +++ b/core/ajax/listener.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -36,7 +36,7 @@ unautorizedInDemo(); $listener = listener::byId(init('id')); if (!is_object($listener)) { - throw new Exception(__('Listener id inconnu', __FILE__)); + throw new Exception(new Trad('Listener id inconnu', __FILE__)); } $listener->remove(); ajax::success(); @@ -54,7 +54,7 @@ ajax::success($listeners); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/ajax/log.ajax.php b/core/ajax/log.ajax.php index e3bd35cf25..42c06a5095 100644 --- a/core/ajax/log.ajax.php +++ b/core/ajax/log.ajax.php @@ -25,7 +25,7 @@ } if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -76,7 +76,7 @@ ); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/message.ajax.php b/core/ajax/message.ajax.php index ada82cadfc..56c45ab199 100644 --- a/core/ajax/message.ajax.php +++ b/core/ajax/message.ajax.php @@ -21,14 +21,14 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); if (init('action') == 'clearMessage') { if(!isConnect('admin')){ - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); } message::removeAll(init('plugin')); ajax::success(); @@ -50,17 +50,17 @@ if (init('action') == 'removeMessage') { if(!isConnect('admin')){ - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); } $message = message::byId(init('id')); if (!is_object($message)) { - throw new Exception(__('Message inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Message inconnu. Vérifiez l\'ID', __FILE__)); } $message->remove(); ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/network.ajax.php b/core/ajax/network.ajax.php index 31c9335ded..a002b23f80 100644 --- a/core/ajax/network.ajax.php +++ b/core/ajax/network.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -45,7 +45,7 @@ ajax::success(network::getInterfacesInfo()); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/note.ajax.php b/core/ajax/note.ajax.php index 3548881baa..1381bed971 100644 --- a/core/ajax/note.ajax.php +++ b/core/ajax/note.ajax.php @@ -22,28 +22,28 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); if (init('action') == 'all') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(utils::o2a(note::all())); } if (init('action') == 'byId') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(utils::o2a(note::byId(init('id')))); } if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $note_json = json_decode(init('note'), true); if (isset($note_json['id'])) { @@ -59,11 +59,11 @@ if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $note = note::byId(init('id')); if (!is_object($note)) { - throw new Exception(__('Note inconnue. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Note inconnue. Vérifiez l\'ID', __FILE__)); } $note->remove(); ajax::success(); @@ -71,7 +71,7 @@ ajax::init(); - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/object.ajax.php b/core/ajax/object.ajax.php index 43eac0e1f9..3e8aa47e50 100644 --- a/core/ajax/object.ajax.php +++ b/core/ajax/object.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('uploadImage')); @@ -29,11 +29,11 @@ if (init('action') == 'remove') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } $object->remove(); ajax::success(); @@ -42,7 +42,7 @@ if (init('action') == 'byId') { $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } ajax::success(jeedom::toHumanReadable(utils::o2a($object))); } @@ -70,7 +70,7 @@ if (init('action') == 'save') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $object_json = json_decode(init('object'), true); if (isset($object_json['id'])) { @@ -87,11 +87,11 @@ if (init('action') == 'orderEqLogicByUsage') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } $object->orderEqLogicByUsage(); ajax::success(utils::o2a($object)); @@ -100,7 +100,7 @@ if (init('action') == 'getChild') { $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } $return = utils::o2a($object->getChild()); ajax::success($return); @@ -113,7 +113,7 @@ $virtual = eqLogic::byLogicalId('summary' . init('object_id'), 'virtual'); } if (!is_object($virtual)) { - throw new Exception(__('L\'objet n\'existe pas :', __FILE__) . ' ' . init('object_id')); + throw new Exception(new Trad('L\'objet n\'existe pas :', __FILE__) . ' ' . init('object_id')); } $removeCmd = array(); foreach ($virtual->getCmd() as $cmd) { @@ -131,7 +131,7 @@ if (init('action') == 'getEqLogicsFromSummary') { $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } $return = $object->getEqLogicsFromSummary(init('summary'), init('onlyEnable'), init('onlyVisible')); ajax::success($return); @@ -213,7 +213,7 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' if (init('action') == 'setOrder') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $position = 1; foreach (json_decode(init('objects'), true) as $id) { @@ -229,7 +229,7 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' if (init('action') == 'getUISelectList') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(jeeObject::getUISelectList(init('none'), true)); } @@ -258,7 +258,7 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' } else { $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } $info_object = array(); $info_object['id'] = $object->getId(); @@ -269,12 +269,12 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' if (init('action') == 'removeImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } $object->setImage('data', ''); $object->setImage('sha512', ''); @@ -292,23 +292,23 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' if (init('action') == 'uploadImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $object = jeeObject::byId(init('id')); if (!is_object($object)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (init('file') == '') { if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .jpg .png .gif .svg .webp) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png .gif .svg .webp) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $upfilepath = $_FILES['file']['tmp_name']; } else { @@ -328,13 +328,13 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = ' $filepath = __DIR__ . '/../../data/object/' . $filename; file_put_contents($filepath, file_get_contents($upfilepath)); if (!file_exists($filepath)) { - throw new \Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new \Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } $object->save(); ajax::success(array('filepath' => $filepath)); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/plan.ajax.php b/core/ajax/plan.ajax.php index b8337fd34e..6992744760 100644 --- a/core/ajax/plan.ajax.php +++ b/core/ajax/plan.ajax.php @@ -21,14 +21,14 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('uploadImagePlan', 'uploadImage')); if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plans = json_decode(init('plans'), true); @@ -46,7 +46,7 @@ if (init('action') == 'execute') { $plan = plan::byId(init('id')); if (!is_object($plan)) { - throw new Exception(__('Aucun plan correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan correspondant', __FILE__)); } ajax::success($plan->execute()); } @@ -65,7 +65,7 @@ if (init('action') == 'create') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan = new plan(); @@ -76,12 +76,12 @@ if (init('action') == 'copy') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan = plan::byId(init('id')); if (!is_object($plan)) { - throw new Exception(__('Aucun plan correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan correspondant', __FILE__)); } ajax::success($plan->copy()->getHtml(init('version', 'dashboard'))); } @@ -89,34 +89,34 @@ if (init('action') == 'get') { $plan = plan::byId(init('id')); if (!is_object($plan)) { - throw new Exception(__('Aucun plan correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan correspondant', __FILE__)); } ajax::success($plan->getHtml('dashboard')); } if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan = plan::byId(init('id')); if (!is_object($plan)) { - throw new Exception(__('Aucun plan correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan correspondant', __FILE__)); } ajax::success($plan->remove()); } if (init('action') == 'removePlanHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (!$planHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design', __FILE__)); } $planHeader->remove(); ajax::success(); @@ -139,13 +139,13 @@ if (init('action') == 'getPlanHeader') { $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { - throw new Exception(__('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } if (!$planHeader->hasRight('r')) { - throw new Exception(__('Vous n\'avez pas le droit de voir ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de voir ce design', __FILE__)); } if (trim($planHeader->getConfiguration('accessCode', '')) != '' && $planHeader->getConfiguration('accessCode', '') != sha512(init('code'))) { - throw new Exception(__('Code d\'accès invalide', __FILE__), -32005); + throw new Exception(new Trad('Code d\'accès invalide', __FILE__), -32005); } $return = utils::o2a($planHeader); $return['image'] = $planHeader->displayImage(); @@ -154,7 +154,7 @@ if (init('action') == 'savePlanHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $planHeader_ajax = json_decode(init('planHeader'), true); @@ -166,7 +166,7 @@ $planHeader = new planHeader(); } if (!$planHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design', __FILE__)); } utils::a2o($planHeader, $planHeader_ajax); $planHeader->save(); @@ -175,30 +175,30 @@ if (init('action') == 'copyPlanHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { - throw new Exception(__('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } if (!$planHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design', __FILE__)); } ajax::success(utils::o2a($planHeader->copy(init('name')))); } if (init('action') == 'removeImageHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { - throw new Exception(__('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Plan header inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } if (!$planHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design', __FILE__)); } $filename = 'planHeader' . $planHeader->getId() . '-' . $planHeader->getImage('sha512') . '.' . $planHeader->getImage('type'); $planHeader->setImage('sha512', ''); @@ -209,25 +209,25 @@ if (init('action') == 'uploadImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $planHeader = planHeader::byId(init('id')); if (!is_object($planHeader)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (!$planHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design', __FILE__)); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.jpg', '.png', '.gif'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .jpg .png .gif) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png .gif) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $files = ls(__DIR__ . '/../../data/plan/', 'planHeader' . $planHeader->getId() . '*'); if (count($files) > 0) { @@ -243,7 +243,7 @@ $filepath = __DIR__ . '/../../data/plan/' . $filename; file_put_contents($filepath, file_get_contents($_FILES['file']['tmp_name'])); if (!file_exists($filepath)) { - throw new \Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new \Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } $planHeader->save(); ajax::success(array('filepath' => $filepath)); @@ -251,22 +251,22 @@ if (init('action') == 'uploadImagePlan') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan = plan::byId(init('id')); if (!is_object($plan)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre 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) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $uploaddir = __DIR__ . '/../../data/plan/plan_' . $plan->getId(); if (!file_exists($uploaddir)) { @@ -277,7 +277,7 @@ $filePath = $uploaddir . '/' . $fileName; $img_size = getimagesize($_FILES['file']['tmp_name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $filePath)) { - throw new Exception(__('Impossible de déplacer le fichier temporaire dans :', __FILE__) . ' ' . $uploaddir . '/' . $fileName); + throw new Exception(new Trad('Impossible de déplacer le fichier temporaire dans :', __FILE__) . ' ' . $uploaddir . '/' . $fileName); } $plan->setDisplay('width', $img_size[0]); $plan->setDisplay('height', $img_size[1]); @@ -286,7 +286,7 @@ ajax::success(array('filepath' => $filePath)); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/plan3d.ajax.php b/core/ajax/plan3d.ajax.php index 9d2bb0513b..3b5344c1df 100644 --- a/core/ajax/plan3d.ajax.php +++ b/core/ajax/plan3d.ajax.php @@ -21,14 +21,14 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('uploadModel')); if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3ds = json_decode(init('plan3ds'), true); @@ -55,7 +55,7 @@ if (init('action') == 'create') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3d = new plan3d(); @@ -67,7 +67,7 @@ if (init('action') == 'get') { $plan3d = plan3d::byId(init('id')); if (!is_object($plan3d)) { - throw new Exception(__('Aucun plan3d correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan3d correspondant', __FILE__)); } $return = jeedom::toHumanReadable(utils::o2a($plan3d)); $return['additionalData'] = $plan3d->additionalData(); @@ -84,27 +84,27 @@ if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3d = plan3d::byId(init('id')); if (!is_object($plan3d)) { - throw new Exception(__('Aucun plan3d correspondant', __FILE__)); + throw new Exception(new Trad('Aucun plan3d correspondant', __FILE__)); } ajax::success($plan3d->remove()); } if (init('action') == 'removeplan3dHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3dHeader = plan3dHeader::byId(init('id')); if (!is_object($plan3dHeader)) { - throw new Exception(__('Objet inconnu vérifiez l\'id', __FILE__)); + throw new Exception(new Trad('Objet inconnu vérifiez l\'id', __FILE__)); } if (!$plan3dHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); } $plan3dHeader->remove(); ajax::success(); @@ -124,13 +124,13 @@ if (init('action') == 'getplan3dHeader') { $plan3dHeader = plan3dHeader::byId(init('id')); if (!is_object($plan3dHeader)) { - throw new Exception(__('plan3d header inconnu vérifiez l\'id :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('plan3d header inconnu vérifiez l\'id :', __FILE__) . ' ' . init('id')); } if (!$plan3dHeader->hasRight('r')) { - throw new Exception(__('Vous n\'avez pas le droit de voir ce design 3d', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de voir ce design 3d', __FILE__)); } if (trim($plan3dHeader->getConfiguration('accessCode', '')) != '' && $plan3dHeader->getConfiguration('accessCode', '') != sha512(init('code'))) { - throw new Exception(__('Code d\'accès invalide', __FILE__), -32005); + throw new Exception(new Trad('Code d\'accès invalide', __FILE__), -32005); } $return = utils::o2a($plan3dHeader); ajax::success($return); @@ -138,7 +138,7 @@ if (init('action') == 'saveplan3dHeader') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3dHeader_ajax = json_decode(init('plan3dHeader'), true); @@ -150,7 +150,7 @@ $plan3dHeader = new plan3dHeader(); } if (!$plan3dHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); } utils::a2o($plan3dHeader, $plan3dHeader_ajax); $plan3dHeader->save(); @@ -159,32 +159,32 @@ if (init('action') == 'uploadModel') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plan3dHeader = plan3dHeader::byId(init('id')); if (!is_object($plan3dHeader)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (!$plan3dHeader->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier ce design 3d', __FILE__)); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre 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) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .zip) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 150000000) { - throw new Exception(__('Le fichier est trop gros (maximum 150Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 150Mo)', __FILE__)); } $uploaddir = '/tmp'; if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de déplacer le fichier temporaire', __FILE__)); + throw new Exception(new Trad('Impossible de déplacer le fichier temporaire', __FILE__)); } if (!file_exists($uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); } if ($plan3dHeader->getConfiguration('path') == '') { $plan3dHeader->setConfiguration('path', 'data/3d/' . config::genKey() . '/'); @@ -195,16 +195,16 @@ $res = $zip->open($file); if ($res === TRUE) { if (!$zip->extractTo($cibDir . '/')) { - throw new Exception(__('Impossible de décompresser les fichiers :', __FILE__) . ' '); + throw new Exception(new Trad('Impossible de décompresser les fichiers :', __FILE__) . ' '); } $zip->close(); unlink($file); } else { - throw new Exception(__('Impossible de décompresser l\'archive zip :', __FILE__) . ' ' . $file . ' => ' . ZipErrorMessage($res)); + throw new Exception(new Trad('Impossible de décompresser l\'archive zip :', __FILE__) . ' ' . $file . ' => ' . ZipErrorMessage($res)); } $objfile = ls($cibDir, '*.obj', false, array('files')); if (count($objfile) != 1) { - throw new Exception(__('Il faut un seul et unique fichier .obj', __FILE__)); + throw new Exception(new Trad('Il faut un seul et unique fichier .obj', __FILE__)); } $plan3dHeader->setConfiguration('objfile', $objfile[0]); $mtlfile = ls($cibDir, '*.mtl', false, array('files')); @@ -215,7 +215,7 @@ ajax::success(); } - throw new Exception(__('Aucune méthode correspondant à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondant à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/plugin.ajax.php b/core/ajax/plugin.ajax.php index a6face2566..4c04fe7e71 100644 --- a/core/ajax/plugin.ajax.php +++ b/core/ajax/plugin.ajax.php @@ -21,14 +21,14 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); if (init('action') == 'getConf') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $plugin = plugin::byId(init('id'),init('full',0)); $update = update::byLogicalId(init('id')); @@ -45,11 +45,11 @@ if (init('action') == 'toggle') { unautorizedInDemo(); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $plugin = plugin::byId(init('id')); if (!is_object($plugin)) { - throw new Exception(__('Plugin introuvable :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Plugin introuvable :', __FILE__) . ' ' . init('id')); } $plugin->setIsEnable(init('state')); ajax::success(); @@ -57,14 +57,14 @@ if (init('action') == 'all') { if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::success(utils::o2a(plugin::listPlugin(init('activateOnly', false)))); } if (init('action') == 'getDependancyInfo') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $return = array('state' => 'nok', 'log' => 'nok'); @@ -77,7 +77,7 @@ if (init('action') == 'dependancyInstall') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plugin = plugin::byId(init('id')); @@ -89,7 +89,7 @@ if (init('action') == 'dependancyChangeAutoMode') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plugin = plugin::byId(init('id')); @@ -101,7 +101,7 @@ if (init('action') == 'getDeamonInfo') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $plugin_id = init('id'); $return = array('launchable_message' => '', 'launchable' => 'nok', 'state' => 'nok', 'log' => 'nok', 'auto' => 0); @@ -115,7 +115,7 @@ if (init('action') == 'deamonStart') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plugin_id = init('id'); @@ -128,7 +128,7 @@ if (init('action') == 'deamonStop') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plugin = plugin::byId(init('id')); @@ -140,7 +140,7 @@ if (init('action') == 'deamonChangeAutoMode') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $plugin = plugin::byId(init('id')); @@ -151,9 +151,9 @@ } if (init('action') == 'createCommunityPost') { - $header = __('Remplacez ce texte par votre demande en prenant soin de ne pas effacer les informations renseignées ci-dessous.', __FILE__) . '



'; + $header = new Trad('Remplacez ce texte par votre demande en prenant soin de ne pas effacer les informations renseignées ci-dessous.', __FILE__) . '



'; $header .= '
---
'; - $header .= '**' . __('Informations', __FILE__) . ' ' . config::byKey('product_name') . '**'; + $header .= '**' . new Trad('Informations', __FILE__) . ' ' . config::byKey('product_name') . '**'; $header .= '
```
'; $footer = '
```
'; @@ -172,17 +172,17 @@ $isBeta = ($version && $version != 'stable'); } - $infoPost .= __('Version', __FILE__) . ' : ' . $update->getLocalVersion() . ' (' . ($isBeta ? 'beta' : 'stable') . ')'; + $infoPost .= new Trad('Version', __FILE__) . ' : ' . $update->getLocalVersion() . ' (' . ($isBeta ? 'beta' : 'stable') . ')'; if ($plugin->getHasOwnDeamon()) { $daemon_info = $plugin->deamon_info(); - $infoPost .= '
' . __('Statut Démon', __FILE__) . ' : ' . ($daemon_info['state'] == 'ok' ? __('Démarré', __FILE__) : __('Stoppé', __FILE__)); - $infoPost .= ' - (' . ($daemon_info['last_launch'] ?? __('Inconnue', __FILE__)) . ')'; + $infoPost .= '
' . new Trad('Statut Démon', __FILE__) . ' : ' . ($daemon_info['state'] == 'ok' ? new Trad('Démarré', __FILE__) : new Trad('Stoppé', __FILE__)); + $infoPost .= ' - (' . ($daemon_info['last_launch'] ?? new Trad('Inconnue', __FILE__)) . ')'; } $infoPlugin = ''; if (method_exists($plugin_id, 'getConfigForCommunity')) { - $infoPlugin .= '**' . __('Informations complémentaires', __FILE__) . '**
'; + $infoPlugin .= '**' . new Trad('Informations complémentaires', __FILE__) . '**
'; $infoPlugin .= $plugin_id::getConfigForCommunity(); } @@ -203,7 +203,7 @@ ajax::success(array('url' => $url, 'plugin' => $plugin->getName())); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/queue.ajax.php b/core/ajax/queue.ajax.php index 3e094df417..bda429b27d 100644 --- a/core/ajax/queue.ajax.php +++ b/core/ajax/queue.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -36,7 +36,7 @@ unautorizedInDemo(); $queue = queue::byId(init('id')); if (!is_object($queue)) { - throw new Exception(__('Queue id inconnu', __FILE__)); + throw new Exception(new Trad('Queue id inconnu', __FILE__)); } $queue->remove(); ajax::success(); @@ -53,7 +53,7 @@ if (init('action') == 'start') { $queue = queue::byId(init('id')); if (!is_object($queue)) { - throw new Exception(__('Queue id inconnu', __FILE__)); + throw new Exception(new Trad('Queue id inconnu', __FILE__)); } $queue->run(); sleep(1); @@ -63,14 +63,14 @@ if (init('action') == 'stop') { $queue = queue::byId(init('id')); if (!is_object($queue)) { - throw new Exception(__('Queue id inconnu', __FILE__)); + throw new Exception(new Trad('Queue id inconnu', __FILE__)); } $queue->halt(); sleep(1); ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/ajax/recovery.ajax.php b/core/ajax/recovery.ajax.php index c7dc2a0bfc..2906dfe428 100644 --- a/core/ajax/recovery.ajax.php +++ b/core/ajax/recovery.ajax.php @@ -22,7 +22,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -44,7 +44,7 @@ ajax::success(recovery::usbConnected(init('hardware'))); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/repo.ajax.php b/core/ajax/repo.ajax.php index cc6a8be32e..f39e6412c5 100644 --- a/core/ajax/repo.ajax.php +++ b/core/ajax/repo.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(); @@ -56,14 +56,14 @@ $class = 'repo_' . init('repo'); $repo = $class::byId(init('id')); if (!is_object($repo)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); } $update = update::byTypeAndLogicalId($repo->getType(), $repo->getLogicalId()); if (!is_object($update)) { $update = new update(); } if ($update->getConfiguration('doNotUpdate') == 1) { - throw new Exception(__('Mise à jour et réinstallation désactivées sur ', __FILE__) . ' ' . $repo->getLogicalId()); + throw new Exception(new Trad('Mise à jour et réinstallation désactivées sur ', __FILE__) . ' ' . $repo->getLogicalId()); } $update->setSource(init('repo')); $update->setLogicalId($repo->getLogicalId()); @@ -86,7 +86,7 @@ $class = 'repo_' . init('repo'); $repo = $class::byId(init('id')); if (!is_object($market)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); } $update = update::byTypeAndLogicalId($repo->getType(), $repo->getLogicalId()); try { @@ -140,7 +140,7 @@ $class = 'repo_' . init('repo'); $repo = $class::byId(init('id')); if (!is_object($repo)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . init('id')); } $repo->setRating(init('rating')); ajax::success(); @@ -151,7 +151,7 @@ ajax::success($class::backup_list()); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/ajax/report.ajax.php b/core/ajax/report.ajax.php index 178b0dc16d..c875749a4d 100644 --- a/core/ajax/report.ajax.php +++ b/core/ajax/report.ajax.php @@ -22,7 +22,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -51,7 +51,7 @@ unlink($path); } if (file_exists($path)) { - throw new Exception(__('Impossible de supprimer :', __FILE__) . ' ' . $path); + throw new Exception(new Trad('Impossible de supprimer :', __FILE__) . ' ' . $path); } ajax::success(); } @@ -64,7 +64,7 @@ ajax::success($return); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/scenario.ajax.php b/core/ajax/scenario.ajax.php index 25b199c7cf..d6de10c753 100644 --- a/core/ajax/scenario.ajax.php +++ b/core/ajax/scenario.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('templateupload')); @@ -29,15 +29,15 @@ if (init('action') == 'changeState') { $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); } if (!$scenario->hasRight('x')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } switch (init('state')) { case 'start': if (!$scenario->getIsActive()) { - throw new Exception(__('Impossible de lancer le scénario car il est désactivé. Veuillez l\'activer', __FILE__)); + throw new Exception(new Trad('Impossible de lancer le scénario car il est désactivé. Veuillez l\'activer', __FILE__)); } $scenario->addTag('trigger','user'); $scenario->addTag('trigger_value',$_SESSION['user']->getLogin()); @@ -106,19 +106,19 @@ if (init('action') == 'convertToTemplate') { $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); } $path = __DIR__ . '/../../data/scenario'; if (!file_exists($path)) { mkdir($path); } if (trim(init('template')) == '' || trim(init('template')) == '.json') { - throw new Exception(__('Le nom du template ne peut être vide', __FILE__) . ' '); + throw new Exception(new Trad('Le nom du template ne peut être vide', __FILE__) . ' '); } $name = init('template'); file_put_contents($path . '/' . $name, json_encode($scenario->export('array'), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); if (!file_exists($path . '/' . $name)) { - throw new Exception(__('Impossible de créer le template, vérifiez les droits :', __FILE__) . ' ' . $path . '/' . $name); + throw new Exception(new Trad('Impossible de créer le template, vérifiez les droits :', __FILE__) . ' ' . $path . '/' . $name); } ajax::success(); } @@ -135,7 +135,7 @@ if (init('action') == 'loadTemplateDiff') { $path = __DIR__ . '/../../data/scenario'; if (!file_exists($path . '/' . init('template'))) { - throw new Exception(__('Fichier non trouvé :', __FILE__) . ' ' . $path . '/' . init('template')); + throw new Exception(new Trad('Fichier non trouvé :', __FILE__) . ' ' . $path . '/' . init('template')); } $return = array(); $fileContent = file_get_contents($path . '/' . init('template')); @@ -161,7 +161,7 @@ $return[$match[0]] = ''; try { $eqLogic = eqLogic::byString($match[0]); - if (is_object($cmd)) { + if (is_object($eqLogic)) { $return[$match[0]] = '#' . $eqLogic->getHumanName() . '#'; } } catch (Exception $e) { @@ -184,11 +184,11 @@ unautorizedInDemo(); $path = __DIR__ . '/../../data/scenario'; if (!file_exists($path . '/' . init('template'))) { - throw new Exception(__('Fichier non trouvé :', __FILE__) . ' ' . $path . '/' . init('template')); + throw new Exception(new Trad('Fichier non trouvé :', __FILE__) . ' ' . $path . '/' . init('template')); } foreach (json_decode(init('convert'), true) as $value) { if (trim($value['end']) == '') { - throw new Exception(__('La conversion suivante ne peut être vide :', __FILE__) . ' ' . $value['begin']); + throw new Exception(new Trad('La conversion suivante ne peut être vide :', __FILE__) . ' ' . $value['begin']); } $converts[$value['begin']] = $value['end']; } @@ -203,10 +203,10 @@ } $scenario_db = scenario::byId(init('id')); if (!is_object($scenario_db)) { - throw new Exception(__('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Scénario ID inconnu :', __FILE__) . ' ' . init('id')); } if (!$scenario_db->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $scenario_db->setTrigger(array()); $scenario_db->setSchedule(array()); @@ -237,7 +237,7 @@ if (init('action') == 'byId') { $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu', __FILE__)); + throw new Exception(new Trad('Scénario ID inconnu', __FILE__)); } ajax::success(utils::o2a($scenario)); } @@ -284,7 +284,7 @@ if (init('action') == 'autoCompleteGroup') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $return = array(); foreach (scenario::listGroup(init('term')) as $group) { @@ -320,15 +320,15 @@ if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu', __FILE__)); + throw new Exception(new Trad('Scénario ID inconnu', __FILE__)); } if (!$scenario->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } $scenario->remove(); ajax::success(); @@ -336,7 +336,7 @@ if (init('action') == 'clearAllLogs') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $scenarios = scenario::all(); foreach ($scenarios as $scenario) { @@ -349,11 +349,11 @@ if (init('action') == 'emptyLog') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu', __FILE__)); + throw new Exception(new Trad('Scénario ID inconnu', __FILE__)); } if (file_exists(__DIR__ . '/../../log/scenarioLog/scenario' . $scenario->getId() . '.log')) { unlink(__DIR__ . '/../../log/scenarioLog/scenario' . $scenario->getId() . '.log'); @@ -363,12 +363,12 @@ if (init('action') == 'copy') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu', __FILE__)); + throw new Exception(new Trad('Scénario ID inconnu', __FILE__)); } ajax::success(utils::o2a($scenario->copy(init('name')))); } @@ -376,7 +376,7 @@ if (init('action') == 'get') { $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Scénario ID inconnu', __FILE__)); + throw new Exception(new Trad('Scénario ID inconnu', __FILE__)); } $return = utils::o2a($scenario); $return['trigger'] = jeedom::toHumanReadable($return['trigger']); @@ -456,10 +456,10 @@ if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } if (!is_json(init('scenario'))) { - throw new Exception(__('Champs json invalide', __FILE__)); + throw new Exception(new Trad('Champs json invalide', __FILE__)); } unautorizedInDemo(); $time_dependance = 0; @@ -485,7 +485,7 @@ if (!isset($scenario_db) || !is_object($scenario_db)) { $scenario_db = new scenario(); } elseif (!$scenario_db->hasRight('w')) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } if (isset($scenario_ajax['trigger'])) { $scenario_db->setTrigger(array()); @@ -536,28 +536,28 @@ mkdir($uploaddir); } if (!file_exists($uploaddir)) { - throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); + throw new Exception(new Trad('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } $extension = strtolower(strrchr($_FILES['file']['name'], '.')); if (!in_array($extension, array('.json'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .json) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .json) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 10000000) { - throw new Exception(__('Le fichier est trop gros (maximum 10Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 10Mo)', __FILE__)); } if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de déplacer le fichier temporaire', __FILE__)); + throw new Exception(new Trad('Impossible de déplacer le fichier temporaire', __FILE__)); } if (!file_exists($uploaddir . '/' . $_FILES['file']['name'])) { - throw new Exception(__('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); } ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/timeline.ajax.php b/core/ajax/timeline.ajax.php index d6b31a783d..d2c7a25929 100644 --- a/core/ajax/timeline.ajax.php +++ b/core/ajax/timeline.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -61,7 +61,7 @@ ajax::success(timeline::removeEventInFutur()); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/update.ajax.php b/core/ajax/update.ajax.php index db8bfa10f7..bbaaf3051d 100644 --- a/core/ajax/update.ajax.php +++ b/core/ajax/update.ajax.php @@ -21,7 +21,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(array('preUploadFile')); @@ -31,7 +31,7 @@ } if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'all') { @@ -73,15 +73,15 @@ log::clear('update'); $update = update::byId(init('id')); if (!is_object($update)) { - throw new Exception(__('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); } try { if ($update->getType() != 'core') { - log::add('update', 'alert', __("[START UPDATE]", __FILE__)); + log::add('update', 'alert', new Trad("[START UPDATE]", __FILE__)); } $update->doUpdate(); if ($update->getType() != 'core') { - log::add('update', 'alert', __("Launch cron dependancy plugins", __FILE__)); + log::add('update', 'alert', new Trad("Launch cron dependancy plugins", __FILE__)); try { $cron = cron::byClassAndFunction('plugin', 'checkDeamon'); if (is_object($cron)) { @@ -89,12 +89,12 @@ } } catch (Exception $e) { } - log::add('update', 'alert', __("[END UPDATE SUCCESS]", __FILE__)); + log::add('update', 'alert', new Trad("[END UPDATE SUCCESS]", __FILE__)); } } catch (Exception $e) { if ($update->getType() != 'core') { log::add('update', 'alert', $e->getMessage()); - log::add('update', 'alert', __("[END UPDATE ERROR]", __FILE__)); + log::add('update', 'alert', new Trad("[END UPDATE ERROR]", __FILE__)); } } ajax::success(); @@ -108,7 +108,7 @@ $update = update::byLogicalId(init('id')); } if (!is_object($update)) { - throw new Exception(__('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); } $update->deleteObjet(); ajax::success(); @@ -121,7 +121,7 @@ $update = update::byLogicalId(init('id')); } if (!is_object($update)) { - throw new Exception(__('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id')); } $update->checkUpdate(); ajax::success(); @@ -173,25 +173,25 @@ unautorizedInDemo(); $uploaddir = '/tmp'; if (!file_exists($uploaddir)) { - throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); + throw new Exception(new Trad('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . $uploaddir); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); } if (filesize($_FILES['file']['tmp_name']) > 100000000) { - throw new Exception(__('Le fichier est trop gros (maximum 100Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 100Mo)', __FILE__)); } $filename = str_replace(array(' ', '(', ')'), '', $_FILES['file']['name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $filename)) { - throw new Exception(__('Impossible de déplacer le fichier temporaire', __FILE__)); + throw new Exception(new Trad('Impossible de déplacer le fichier temporaire', __FILE__)); } if (!file_exists($uploaddir . '/' . $filename)) { - throw new Exception(__('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier (limite du serveur web ?)', __FILE__)); } ajax::success($uploaddir . '/' . $filename); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/user.ajax.php b/core/ajax/user.ajax.php index 8cb6103efb..b75690bb66 100644 --- a/core/ajax/user.ajax.php +++ b/core/ajax/user.ajax.php @@ -44,15 +44,15 @@ @session_start(); $_SESSION['user'] = $user; @session_write_close(); - log::add('connection', 'info', __('Connexion de l\'utilisateur par REMOTE_USER :', __FILE__) . ' ' . $_SESSION['user']->getLogin()); + log::add('connection', 'info', new Trad('Connexion de l\'utilisateur par REMOTE_USER :', __FILE__) . ' ' . $_SESSION['user']->getLogin()); } } $user = user::connect(init('username'), init('password')); if (is_object($user) && network::getUserLocation() != 'internal' && $user->getOptions('twoFactorAuthentification', 0) == 1 && $user->getOptions('twoFactorAuthentificationSecret') != '' && init('twoFactorCode') == '') { - throw new Exception(__('Double authentification requise', __FILE__), -32012); + throw new Exception(new Trad('Double authentification requise', __FILE__), -32012); } if (!login(init('username'), init('password'), init('twoFactorCode'))) { - throw new Exception(__('Mot de passe ou nom d\'utilisateur incorrect', __FILE__)); + throw new Exception(new Trad('Mot de passe ou nom d\'utilisateur incorrect', __FILE__)); } } @@ -83,13 +83,13 @@ if (init('action') == 'getApikey') { if (!login(init('username'), init('password'), init('twoFactorCode'))) { - throw new Exception(__('Mot de passe ou nom d\'utilisateur incorrect', __FILE__)); + throw new Exception(new Trad('Mot de passe ou nom d\'utilisateur incorrect', __FILE__)); } ajax::success($_SESSION['user']->getHash()); } if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -109,7 +109,7 @@ if (init('action') == 'removeTwoFactorCode') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $user = user::byId(init('id')); @@ -139,7 +139,7 @@ if (init('action') == 'all') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $users = array(); @@ -152,7 +152,7 @@ if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $users = jeedom::fromHumanReadable(json_decode(init('users'), true)); @@ -163,7 +163,7 @@ } if (!is_object($user)) { if (config::byKey('ldap::enable') == '1') { - throw new Exception(__('Vous devez désactiver l\'authentification LDAP pour pouvoir ajouter un utilisateur', __FILE__)); + throw new Exception(new Trad('Vous devez désactiver l\'authentification LDAP pour pouvoir ajouter un utilisateur', __FILE__)); } $user = new user(); } @@ -186,12 +186,12 @@ if (init('action') == 'copyRights') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $from = user::byId(init('from')); $to = user::byId(init('to')); if (!is_object($from) || !is_object($to)) { - throw new Exception(__('Utilisateur invalide', __FILE__)); + throw new Exception(new Trad('Utilisateur invalide', __FILE__)); } $rights = $from->getRights(); foreach ($rights as $key => $value) { @@ -203,18 +203,18 @@ if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); if (config::byKey('ldap::enable') == '1') { - throw new Exception(__('Vous devez désactiver l\'authentification LDAP pour pouvoir supprimer un utilisateur', __FILE__)); + throw new Exception(new Trad('Vous devez désactiver l\'authentification LDAP pour pouvoir supprimer un utilisateur', __FILE__)); } if (init('id') == $_SESSION['user']->getId()) { - throw new Exception(__('Vous ne pouvez pas supprimer le compte avec lequel vous êtes connecté', __FILE__)); + throw new Exception(new Trad('Vous ne pouvez pas supprimer le compte avec lequel vous êtes connecté', __FILE__)); } $user = user::byId(init('id')); if (!is_object($user)) { - throw new Exception(__('User ID inconnu', __FILE__)); + throw new Exception(new Trad('User ID inconnu', __FILE__)); } $user->remove(); ajax::success(); @@ -224,7 +224,7 @@ unautorizedInDemo(); $user_json = jeedom::fromHumanReadable(json_decode(init('profils'), true)); if (isset($user_json['id']) && $user_json['id'] != $_SESSION['user']->getId()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } @session_start(); $_SESSION['user']->refresh(); @@ -243,11 +243,11 @@ if (init('action') == 'get') { if (init('id') > 0) { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } $user = user::byId(init('id')); if (!is_object($user)) { - throw new Exception(__('Utilisateur non trouvé :', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Utilisateur non trouvé :', __FILE__) . ' ' . init('id')); } ajax::success(jeedom::toHumanReadable(utils::o2a($user))); } @@ -258,7 +258,7 @@ unautorizedInDemo(); if (init('key') == '' && init('user_id') == '') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } foreach ((user::all()) as $user) { if ($user->getId() == $_SESSION['user']->getId()) { @@ -276,11 +276,11 @@ } if (init('user_id') != '') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } $user = user::byId(init('user_id')); if (!is_object($user)) { - throw new Exception(__('Utilisateur non trouvé :', __FILE__) . ' ' . init('user_id')); + throw new Exception(new Trad('Utilisateur non trouvé :', __FILE__) . ' ' . init('user_id')); } $registerDevice = $user->getOptions('registerDevice', array()); } else { @@ -326,12 +326,12 @@ } if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } if (init('action') == 'testLdapConnection') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $connection = user::connectToLDAP(); @@ -351,7 +351,7 @@ ajax::success(user::supportAccess(init('enable'))); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/view.ajax.php b/core/ajax/view.ajax.php index 033976e1de..f5358cedbc 100644 --- a/core/ajax/view.ajax.php +++ b/core/ajax/view.ajax.php @@ -21,37 +21,37 @@ include_file('core', 'authentification', 'php'); if (!isConnect()) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } ajax::init(array('uploadImage')); if (init('action') == 'copy') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $view = view::byId(init('id')); if (!is_object($view)) { - throw new Exception(__('Vue non trouvée. Vérifiez l\'iD', __FILE__)); + throw new Exception(new Trad('Vue non trouvée. Vérifiez l\'iD', __FILE__)); } if (!$view->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); } ajax::success(utils::o2a($view->copy(init('name')))); } if (init('action') == 'remove') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $view = view::byId(init('id')); if (!is_object($view)) { - throw new Exception(__('Vue non trouvée. Vérifiez l\'iD', __FILE__)); + throw new Exception(new Trad('Vue non trouvée. Vérifiez l\'iD', __FILE__)); } if (!$view->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); } $view->remove(); ajax::success(); @@ -91,10 +91,10 @@ } else { $view = view::byId(init('id')); if (!is_object($view)) { - throw new Exception(__('Vue non trouvée. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Vue non trouvée. Vérifiez l\'ID', __FILE__)); } if (!$view->hasRight('r')) { - throw new Exception(__('Vous n\'avez pas le droit de voir cette vue', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de voir cette vue', __FILE__)); } ajax::success($view->toAjax(init('version', 'dashboard'), init('html'))); } @@ -102,7 +102,7 @@ if (init('action') == 'save') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $view = view::byId(init('view_id')); @@ -110,11 +110,11 @@ $view = new view(); } if (!$view->hasRight('w')) { - throw new Exception(__('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de modifier cette vue', __FILE__)); } $view_ajax = json_decode(init('view'), true); if (!is_array($view_ajax) || count($view_ajax) == 0) { - throw new Exception(__('Erreur dans le decodage json veuiller réessaye : ', __FILE__) . init('view')); + throw new Exception(new Trad('Erreur dans le decodage json veuiller réessaye : ', __FILE__) . init('view')); } utils::a2o($view, $view_ajax); $view->save(); @@ -146,7 +146,7 @@ if (init('action') == 'getEqLogicviewZone') { $viewZone = viewZone::byId(init('viewZone_id')); if (!is_object($viewZone)) { - throw new Exception(__('Vue non trouvée. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Vue non trouvée. Vérifiez l\'ID', __FILE__)); } $return = utils::o2a($viewZone); $return['eqLogic'] = array(); @@ -160,7 +160,7 @@ if (init('action') == 'setComponentOrder') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $components = json_decode(init('components'), true); @@ -196,7 +196,7 @@ if (init('action') == 'setOrder') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $order = 1; @@ -213,12 +213,12 @@ if (init('action') == 'removeImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $view = view::byId(init('id')); if (!is_object($view)) { - throw new Exception(__('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); + throw new Exception(new Trad('Vue inconnu. Vérifiez l\'ID', __FILE__) . ' ' . init('id')); } $view->setImage('sha512', ''); $view->save(); @@ -228,22 +228,22 @@ if (init('action') == 'uploadImage') { if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__)); } unautorizedInDemo(); $view = view::byId(init('id')); if (!is_object($view)) { - throw new Exception(__('Objet inconnu. Vérifiez l\'ID', __FILE__)); + throw new Exception(new Trad('Objet inconnu. Vérifiez l\'ID', __FILE__)); } if (!isset($_FILES['file'])) { - throw new Exception(__('Aucun fichier trouvé. Vérifiez le paramètre PHP (post size limit)', __FILE__)); + throw new Exception(new Trad('Aucun fichier trouvé. Vérifiez le paramètre 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) :', __FILE__) . ' ' . $extension); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .jpg .png) :', __FILE__) . ' ' . $extension); } if (filesize($_FILES['file']['tmp_name']) > 5000000) { - throw new Exception(__('Le fichier est trop gros (maximum 5Mo)', __FILE__)); + throw new Exception(new Trad('Le fichier est trop gros (maximum 5Mo)', __FILE__)); } $files = ls(__DIR__ . '/../../data/view/', 'view' . $view->getId() . '*'); if (count($files) > 0) { @@ -257,13 +257,13 @@ $filepath = __DIR__ . '/../../data/view/' . $filename; file_put_contents($filepath, file_get_contents($_FILES['file']['tmp_name'])); if (!file_exists($filepath)) { - throw new \Exception(__('Impossible de sauvegarder l\'image', __FILE__)); + throw new \Exception(new Trad('Impossible de sauvegarder l\'image', __FILE__)); } $view->save(); ajax::success(); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); diff --git a/core/ajax/widgets.ajax.php b/core/ajax/widgets.ajax.php index 49c758bf17..154923c618 100644 --- a/core/ajax/widgets.ajax.php +++ b/core/ajax/widgets.ajax.php @@ -22,7 +22,7 @@ include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234); + throw new Exception(new Trad('401 - Accès non autorisé', __FILE__), -1234); } ajax::init(); @@ -47,7 +47,7 @@ if (init('action') == 'remove') { $widgets = widgets::byId(init('id')); if(!is_object($widgets)){ - throw new Exception(__('Widgets inconnus - Vérifiez l\'id', __FILE__).init('id')); + throw new Exception(new Trad('Widgets inconnus - Vérifiez l\'id', __FILE__).init('id')); } $widgets->remove(); ajax::success(); @@ -76,7 +76,7 @@ $widget = widgets::byId(init('id')); $usedBy = $widget->getUsedBy(); if(!is_array($usedBy) || count($usedBy) == 0){ - ajax::success(array('html' => '
'.__('Aucune commande affectée au widget, prévisualisation impossible',__FILE__).'
')); + ajax::success(array('html' => '
'.new Trad('Aucune commande affectée au widget, prévisualisation impossible',__FILE__).'
')); } ajax::success(array('html' =>$usedBy[0]->getEqLogic()->toHtml('dashboard'))); } @@ -85,7 +85,7 @@ ajax::success(widgets::replacement(init('version'),init('replace'),init('by'))); } - throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); + throw new Exception(new Trad('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/api/jeeApi.php b/core/api/jeeApi.php index f479948485..52c130a0a5 100644 --- a/core/api/jeeApi.php +++ b/core/api/jeeApi.php @@ -40,46 +40,46 @@ if (init('type') == 'ask') { if (trim(init('token')) == '' || strlen(init('token')) < 64) { - throw new Exception(__('Commande inconnue ou Token invalide', __FILE__)); + throw new Exception(new Trad('Commande inconnue ou Token invalide', __FILE__)); } $cmd = cmd::byId(init('cmd_id')); if (!is_object($cmd)) { - throw new Exception(__('Commande inconnue ou Token invalide', __FILE__)); + throw new Exception(new Trad('Commande inconnue ou Token invalide', __FILE__)); } if (trim($cmd->getCache('ask::token', config::genKey())) != init('token')) { - throw new Exception(__('Commande inconnue ou Token invalide', __FILE__)); + throw new Exception(new Trad('Commande inconnue ou Token invalide', __FILE__)); } if (!$cmd->askResponse(init('response'))) { - throw new Exception(__('Erreur response ask, temps écoulé ou réponse invalide', __FILE__)); + throw new Exception(new Trad('Erreur response ask, temps écoulé ou réponse invalide', __FILE__)); } die(); } $plugin = init('plugin', 'core'); if (in_array($plugin, array('apitts', 'apipro', 'apimarket'))) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); } if (!jeedom::apiAccess(init('apikey', init('api')), $plugin)) { user::failedLogin(); sleep(5); - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); } if(config::byKey('api::forbidden::method', 'core', '') !== '' && preg_match(config::byKey('api::forbidden::method', 'core', ''), init('type'))){ - throw new Exception(__('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); } if(config::byKey('api::allow::method', 'core', '') !== '' && !preg_match(config::byKey('api::allow::method', 'core', ''), init('type'))){ - throw new Exception(__('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); } $type = init('type'); - log::add('api', 'debug', __('Demande sur l\'api http venant de :', __FILE__) . ' ' . getClientIp() . ' => ' . json_encode($_GET)); + log::add('api', 'debug', new Trad('Demande sur l\'api http venant de :', __FILE__) . ' ' . getClientIp() . ' => ' . json_encode($_GET)); if ($type == 'event' && class_exists($plugin) && method_exists($plugin, 'event')) { - log::add('api', 'info', __('Appels de', __FILE__) . ' ' . secureXSS($plugin) . '::event()'); + log::add('api', 'info', new Trad('Appels de', __FILE__) . ' ' . secureXSS($plugin) . '::event()'); $plugin::event(); die(); } if ($_RESTRICTED) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__)); } if ($type == 'cmd') { if (is_json(init('id'))) { @@ -88,10 +88,10 @@ foreach ($ids as $id) { $cmd = cmd::byId($id); if (!is_object($cmd)) { - throw new Exception(__('Aucune commande correspondant à l\'ID :', __FILE__) . ' ' . secureXSS($id)); + throw new Exception(new Trad('Aucune commande correspondant à l\'ID :', __FILE__) . ' ' . secureXSS($id)); } if ($plugin != 'core' && $plugin != $cmd->getEqType() && $_RESTRICTED) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); } if ($_USER_GLOBAL != null && !$cmd->hasRight($_USER_GLOBAL)) { continue; @@ -103,18 +103,18 @@ } else { $cmd = cmd::byId(init('id')); if (!is_object($cmd)) { - throw new Exception(__('Aucune commande correspondant à l\'ID :', __FILE__) . ' ' . secureXSS(init('id'))); + throw new Exception(new Trad('Aucune commande correspondant à l\'ID :', __FILE__) . ' ' . secureXSS(init('id'))); } if ($plugin != 'core' && $plugin != $cmd->getEqType() && $_RESTRICTED) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); } if ($_USER_GLOBAL != null && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); } if ($cmd->getType() == 'info' && init('value') != '') { $cmd->event(init('value')); } - log::add('api', 'debug', __('Exécution de :', __FILE__) . ' ' . $cmd->getHumanName()); + log::add('api', 'debug', new Trad('Exécution de :', __FILE__) . ' ' . $cmd->getHumanName()); echo $cmd->execCmd($_REQUEST); die(); } @@ -143,7 +143,7 @@ die(); } if ($type == 'scenario') { - log::add('api', 'debug', __('Demande API pour les scénarios', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les scénarios', __FILE__)); if (!init('id')) { header('Content-Type: application/json'); echo json_encode(utils::o2a(scenario::all()), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024); @@ -151,15 +151,15 @@ } $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { - throw new Exception(__('Aucun scénario correspondant à l\'ID :', __FILE__) . ' ' . secureXSS(init('id'))); + throw new Exception(new Trad('Aucun scénario correspondant à l\'ID :', __FILE__) . ' ' . secureXSS(init('id'))); } if ($_USER_GLOBAL != null && !$scenario->hasRight('x', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas le droit de faire une action sur ce scénario', __FILE__)); + throw new Exception(new Trad('Vous n\'avez pas le droit de faire une action sur ce scénario', __FILE__)); } $return = 'ok'; switch (init('action')) { case 'start': - log::add('api', 'debug', __('Démarrage scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Démarrage scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $tags = array(); foreach ($_REQUEST as $key => $value) { $tags['#' . $key . '#'] = $value; @@ -175,73 +175,73 @@ $scenario->setTags(init('tags')); } $scenario->addTag('trigger','api'); - $scenario->addTag('trigger_message',__('Scénario exécuté sur appel API', __FILE__)); + $scenario->addTag('trigger_message',new Trad('Scénario exécuté sur appel API', __FILE__)); $scenario_return = $scenario->launch(); if (is_string($scenario_return)) { $return = $scenario_return; } break; case 'stop': - log::add('api', 'debug', __('Arrêt scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Arrêt scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $scenario->stop(); break; case 'deactivate': - log::add('api', 'debug', __('Désactivation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Désactivation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $scenario->setIsActive(0); $scenario->save(); break; case 'disable': - log::add('api', 'debug', __('Désactivation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Désactivation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $scenario->setIsActive(0); $scenario->save(); break; case 'activate': - log::add('api', 'debug', __('Activation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Activation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $scenario->setIsActive(1); $scenario->save(); break; case 'enable': - log::add('api', 'debug', __('Activation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); + log::add('api', 'debug', new Trad('Activation scénario de :', __FILE__) . ' ' . $scenario->getHumanName()); $scenario->setIsActive(1); $scenario->save(); break; default: - throw new Exception(__('Action non trouvée ou invalide [start,stop,deactivate,activate]', __FILE__)); + throw new Exception(new Trad('Action non trouvée ou invalide [start, stop,deactivate,activate]', __FILE__)); } echo $return; die(); } if ($type == 'message') { - log::add('api', 'debug', __('Demande API pour ajouter un message', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour ajouter un message', __FILE__)); message::add(init('category'), init('message')); die(); } if ($type == 'object') { - log::add('api', 'debug', __('Demande API pour les objets', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les objets', __FILE__)); header('Content-Type: application/json'); echo json_encode(utils::o2a(jeeObject::all()), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024); die(); } if ($type == 'eqLogic') { - log::add('api', 'debug', __('Demande API pour les équipements', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les équipements', __FILE__)); header('Content-Type: application/json'); echo json_encode(utils::o2a(eqLogic::byObjectId(init('object_id'))), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024); die(); } if ($type == 'command') { - log::add('api', 'debug', __('Demande API pour les commandes', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les commandes', __FILE__)); header('Content-Type: application/json'); echo json_encode(utils::o2a(cmd::byEqLogicId(init('eqLogic_id'))), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024); die(); } if ($type == 'fullData') { - log::add('api', 'debug', __('Demande API pour les commandes', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les commandes', __FILE__)); header('Content-Type: application/json'); echo json_encode(jeeObject::fullData(null,$_USER_GLOBAL), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024); die(); } if ($type == 'variable') { - log::add('api', 'debug', __('Demande API pour les variables', __FILE__)); + log::add('api', 'debug', new Trad('Demande API pour les variables', __FILE__)); if (init('value') == '') { $dataStore = dataStore::byTypeLinkIdKey('scenario', -1, trim(init('name'))); if (is_object($dataStore)) { @@ -278,14 +278,14 @@ if ($jsonrpc->getJsonrpc() != '2.0') { user::failedLogin(); - throw new Exception(__('Requête invalide. Version JSON-RPC invalide :', __FILE__) . ' ' . $jsonrpc->getJsonrpc(), -32001); + throw new Exception(new Trad('Requête invalide. Version JSON-RPC invalide :', __FILE__) . ' ' . $jsonrpc->getJsonrpc(), -32001); } if(config::byKey('api::forbidden::method', 'core', '') !== '' && preg_match(config::byKey('api::forbidden::method', 'core', ''), $jsonrpc->getMethod())){ - throw new Exception(__('Cette demande n\'est pas autorisée', __FILE__)); + throw new Exception(new Trad('Cette demande n\'est pas autorisée', __FILE__)); } if(config::byKey('api::allow::method', 'core', '') !== '' && !preg_match(config::byKey('api::allow::method', 'core', ''), $jsonrpc->getMethod())){ - throw new Exception(__('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Cette demande n\'est pas autorisée', __FILE__) . ' ' . getClientIp()); } $params = $jsonrpc->getParams(); @@ -294,11 +294,11 @@ $params['plugin'] = 'core'; } if (in_array($params['plugin'], array('apitts', 'apipro', 'apimarket'))) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } if (!jeedom::apiModeResult(config::byKey('api::' . $params['plugin'] . '::mode', 'core', 'enable'))) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } if ($params['plugin'] == 'core') { @@ -317,19 +317,19 @@ if (!isset($params['login']) || !isset($params['password']) || $params['login'] == '' || $params['password'] == '') { user::failedLogin(); sleep(5); - throw new Exception(__('L\'identifiant ou le mot de passe ne peuvent pas être vide', __FILE__), -32001); + throw new Exception(new Trad('L\'identifiant ou le mot de passe ne peuvent pas être vide', __FILE__), -32001); } $user = user::connect($params['login'], $params['password']); if (!is_object($user) || $user->getEnable() != 1) { user::failedLogin(); sleep(5); - throw new Exception(__('Echec lors de l\'authentification', __FILE__), -32001); + throw new Exception(new Trad('Echec lors de l\'authentification', __FILE__), -32001); } if (network::getUserLocation() != 'internal' && $user->getOptions('twoFactorAuthentification', 0) == 1 && $user->getOptions('twoFactorAuthentificationSecret') != '') { if (!isset($params['twoFactorCode']) || trim($params['twoFactorCode']) == '' || !$user->validateTwoFactorCode($params['twoFactorCode'])) { user::failedLogin(); sleep(5); - throw new Exception(__('Echec lors de l\'authentification', __FILE__), -32001); + throw new Exception(new Trad('Echec lors de l\'authentification', __FILE__), -32001); } } $jsonrpc->makeSuccess($user->getHash()); @@ -341,12 +341,12 @@ } if (!isset($params['apikey']) && !isset($params['api'])) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } $apikey = isset($params['apikey']) ? $params['apikey'] : $params['api']; if (!jeedom::apiAccess($apikey, $params['plugin']) && !jeedom::apiAccess($apikey, 'core')) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32002); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32002); } if ($params['plugin'] != 'core') { @@ -360,7 +360,7 @@ } if ($_RESTRICTED) { - throw new Exception(__('Aucune méthode correspondante :', __FILE__) . ' ' . $jsonrpc->getMethod(), -32500); + throw new Exception(new Trad('Aucune méthode correspondante :', __FILE__) . ' ' . $jsonrpc->getMethod(), -32500); } /* * ************************config*************************** */ @@ -396,7 +396,7 @@ if ($jsonrpc->getMethod() == 'jeedom::halt') { unautorizedInDemo(); if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } jeedom::haltSystem(); $jsonrpc->makeSuccess('ok'); @@ -405,7 +405,7 @@ if ($jsonrpc->getMethod() == 'jeedom::reboot') { unautorizedInDemo(); if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } jeedom::rebootSystem(); $jsonrpc->makeSuccess('ok'); @@ -414,7 +414,7 @@ if ($jsonrpc->getMethod() == 'jeedom::update') { unautorizedInDemo(); if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } jeedom::update($params['options'], 0); $jsonrpc->makeSuccess('ok'); @@ -423,7 +423,7 @@ if ($jsonrpc->getMethod() == 'jeedom::backup') { unautorizedInDemo(); if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } jeedom::backup(true); $jsonrpc->makeSuccess('ok'); @@ -462,7 +462,7 @@ if ($jsonrpc->getMethod() == 'jeeObject::byId' || $jsonrpc->getMethod() == 'object::byId') { $object = jeeObject::byId($params['id']); if (!is_object($object)) { - throw new Exception(__('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); + throw new Exception(new Trad('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); } $jsonrpc->makeSuccess(utils::o2a($object)); } @@ -474,7 +474,7 @@ if ($jsonrpc->getMethod() == 'jeeObject::fullById' || $jsonrpc->getMethod() == 'object::fullById') { $object = jeeObject::byId($params['id']); if (!is_object($object)) { - throw new Exception(__('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); + throw new Exception(new Trad('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); } $return = utils::o2a($object); $return['eqLogics'] = array(); @@ -494,7 +494,7 @@ if ($jsonrpc->getMethod() == 'jeeObject::save' || $jsonrpc->getMethod() == 'object::save') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); if (isset($params['id'])) { @@ -525,7 +525,7 @@ if ($jsonrpc->getMethod() == 'summary::byId') { $object = jeeObject::byId($params['id']); if (!is_object($object)) { - throw new Exception(__('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); + throw new Exception(new Trad('Objet introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32601); } if (!isset($params['key'])) { $params['key'] = ''; @@ -554,14 +554,14 @@ if ($jsonrpc->getMethod() == 'datastore::byTypeLinkIdKey') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a(dataStore::byTypeLinkIdKey($params['type'], $params['linkId'], $params['key']))); } if ($jsonrpc->getMethod() == 'datastore::save') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); $dataStore = new dataStore(); @@ -610,10 +610,10 @@ if ($jsonrpc->getMethod() == 'eqLogic::byId') { $eqLogic = eqLogic::byId($params['id']); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32602); + throw new Exception(new Trad('EqLogic introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32602); } if (is_object($_USER_GLOBAL) && !$eqLogic->hasRight('r', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } $jsonrpc->makeSuccess(utils::o2a($eqLogic)); } @@ -621,10 +621,10 @@ if ($jsonrpc->getMethod() == 'eqLogic::fullById') { $eqLogic = eqLogic::byId($params['id']); if (!is_object($eqLogic)) { - throw new Exception(__('EqLogic introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32602); + throw new Exception(new Trad('EqLogic introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32602); } if (is_object($_USER_GLOBAL) && !$eqLogic->hasRight('r', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } $return = utils::o2a($eqLogic); $return['cmds'] = array(); @@ -639,7 +639,7 @@ $typeEqLogic = $params['eqType_name']; $typeCmd = $typeEqLogic . 'Cmd'; if ($typeEqLogic == '' || !class_exists($typeEqLogic) || !class_exists($typeCmd)) { - throw new Exception(__('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); + throw new Exception(new Trad('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); } $eqLogic = null; if (isset($params['id'])) { @@ -650,7 +650,7 @@ $eqLogic->setEqType_name($params['eqType_name']); } if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001); } utils::a2o($eqLogic, jeedom::fromHumanReadable($params)); $eqLogic->save(); @@ -740,10 +740,10 @@ if ($jsonrpc->getMethod() == 'cmd::byId') { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32701); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32701); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); } $jsonrpc->makeSuccess($cmd->exportApi()); } @@ -754,7 +754,7 @@ foreach ($params['id'] as $id) { $cmd = cmd::byId($id); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($id), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($id), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { continue; @@ -764,10 +764,10 @@ $params['codeAccess'] = ''; } if (!$cmd->checkAccessCode($params['codeAccess'])) { - throw new Exception(__('Cette action nécessite un code d\'accès', __FILE__), -32005); + throw new Exception(new Trad('Cette action nécessite un code d\'accès', __FILE__), -32005); } if ($cmd->getType() == 'action' && $cmd->getConfiguration('actionConfirm') == 1 && $params['confirmAction'] != 1) { - throw new Exception(__('Cette action nécessite une confirmation', __FILE__), -32006); + throw new Exception(new Trad('Cette action nécessite une confirmation', __FILE__), -32006); } if ($cmd->getType() == 'info') { $return[$id] = array('value' => $cmd->execCmd($params['options']), 'collectDate' => $cmd->getCollectDate()); @@ -778,19 +778,19 @@ } else { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } if (!isset($params['codeAccess'])) { $params['codeAccess'] = ''; } if (!$cmd->checkAccessCode($params['codeAccess'])) { - throw new Exception(__('Cette action nécessite un code d\'accès', __FILE__), -32005); + throw new Exception(new Trad('Cette action nécessite un code d\'accès', __FILE__), -32005); } if ($cmd->getType() == 'action' && $cmd->getConfiguration('actionConfirm') == 1 && $params['confirmAction'] != 1) { - throw new Exception(__('Cette action nécessite une confirmation', __FILE__), -32006); + throw new Exception(new Trad('Cette action nécessite une confirmation', __FILE__), -32006); } if ($cmd->getType() == 'info') { $return = array('value' => $cmd->execCmd($params['options']), 'collectDate' => $cmd->getCollectDate()); @@ -807,7 +807,7 @@ throw new Exception('Commande introuvable : ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); } $jsonrpc->makeSuccess($cmd->getStatistique($params['startTime'], $params['endTime'])); } @@ -818,7 +818,7 @@ throw new Exception('Commande introuvable : ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); } $jsonrpc->makeSuccess($cmd->getTendance($params['startTime'], $params['endTime'])); } @@ -829,7 +829,7 @@ throw new Exception('Commande introuvable : ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a($cmd->getHistory($params['startTime'], $params['endTime']))); } @@ -839,18 +839,18 @@ if (isset($params['id'])) { $cmd = cmd::byId($params['id']); if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à faire cette action', __FILE__)); } } else { $typeEqLogic = $params['eqType_name']; $typeCmd = $typeEqLogic . 'Cmd'; if ($typeEqLogic == '' || !class_exists($typeEqLogic) || !class_exists($typeCmd)) { - throw new Exception(__('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); + throw new Exception(new Trad('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); } } if (!is_object($cmd)) { if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } $cmd = new cmd(); } @@ -865,7 +865,7 @@ throw new Exception('Commande introuvable : ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur cette commande', __FILE__), -32701); } if (!isset($params['datetime'])) { $params['datetime'] = null; @@ -889,10 +889,10 @@ if ($jsonrpc->getMethod() == 'scenario::byId') { $scenario = scenario::byId($params['id']); if (!is_object($scenario)) { - throw new Exception(__('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32703); + throw new Exception(new Trad('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32703); } if (is_object($_USER_GLOBAL) && !$scenario->hasRight('r', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a($scenario)); } @@ -900,17 +900,17 @@ if ($jsonrpc->getMethod() == 'scenario::changeState') { $scenario = scenario::byId($params['id']); if (!is_object($scenario)) { - throw new Exception(__('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$scenario->hasRight('w', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); } if ($params['state'] == 'stop') { $jsonrpc->makeSuccess($scenario->stop()); } if ($params['state'] == 'run') { $scenario->addTag('trigger','api'); - $scenario->addTag('trigger_message',__('Scénario exécuté sur appel API', __FILE__)); + $scenario->addTag('trigger_message',new Trad('Scénario exécuté sur appel API', __FILE__)); $jsonrpc->makeSuccess($scenario->launch()); } if ($params['state'] == 'enable') { @@ -921,16 +921,16 @@ $scenario->setIsActive(0); $jsonrpc->makeSuccess($scenario->save()); } - throw new Exception(__('Le paramètre "state" ne peut être vide et doit avoir pour valeur [run,stop,enable,disable]', __FILE__)); + throw new Exception(new Trad('Le paramètre "state" ne peut être vide et doit avoir pour valeur [run, stop,enable,disable]', __FILE__)); } if ($jsonrpc->getMethod() == 'scenario::export') { $scenario = scenario::byId($params['id']); if (!is_object($scenario)) { - throw new Exception(__('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } if (is_object($_USER_GLOBAL) && !$scenario->hasRight('w', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); } $jsonrpc->makeSuccess(array('humanName' => $scenario->getHumanName(), 'export' => $scenario->export('array'))); } @@ -940,12 +940,12 @@ if (isset($params['id'])) { $scenario = scenario::byId($params['id']); if (!is_object($scenario)) { - throw new Exception(__('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } } else if (isset($params['humanName'])) { $scenario = scenario::byString($params['humanName']); if (!is_object($scenario)) { - throw new Exception(__('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Scénario introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } } else { $scenario = new scenario(); @@ -960,7 +960,7 @@ $scenario->setName(config::genKey()); } if (is_object($_USER_GLOBAL) && !$scenario->hasRight('w', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); } $scenario->setTrigger(array()); $scenario->setSchedule(array()); @@ -986,7 +986,7 @@ $scenario = new scenario(); } if (is_object($_USER_GLOBAL) && !$scenario->hasRight('w', $_USER_GLOBAL)) { - throw new Exception(__('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits sur ce scénario', __FILE__), -32701); } utils::a2o($scenario, jeedom::fromHumanReadable($params)); $scenario->save(); @@ -996,20 +996,19 @@ /* * ************************Log*************************** */ if ($jsonrpc->getMethod() == 'log::get') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(log::get($params['log'], $params['start'], $params['nbLine'])); } if ($jsonrpc->getMethod() == 'log::getDelta') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(log::getDelta( $params['log'], $params['position'], $params['search'], - $params['position'], $params['colored'], $params['numbered'], $params['numStart'], @@ -1019,14 +1018,14 @@ if ($jsonrpc->getMethod() == 'log::getLastLine') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(log::getLastLine($params['log'])); } if ($jsonrpc->getMethod() == 'log::add') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } if (!isset($params['logicalId'])) $params['logicalId'] = ''; $jsonrpc->makeSuccess(log::add($params['log'], $params['type'], $params['message'], $params['logicalId'])); @@ -1034,7 +1033,7 @@ if ($jsonrpc->getMethod() == 'log::list') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } if (!isset($params['filtre'])) { $params['filtre'] = null; @@ -1044,14 +1043,14 @@ if ($jsonrpc->getMethod() == 'log::empty') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(log::clear($params['log'])); } if ($jsonrpc->getMethod() == 'log::remove') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); $jsonrpc->makeSuccess(log::remove($params['log'])); @@ -1060,7 +1059,7 @@ /* * ************************Messages*************************** */ if ($jsonrpc->getMethod() == 'message::removeAll') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } message::removeAll(); $jsonrpc->makeSuccess('ok'); @@ -1068,27 +1067,27 @@ if ($jsonrpc->getMethod() == 'message::removebyId') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $message = message::byId($params['messageId']); if (is_object($message)) { $message->remove(); $jsonrpc->makeSuccess('ok'); } else { - throw new Exception(__('Impossible de trouver le message :', __FILE__) . ' ' . secureXSS($params['messageId'])); + throw new Exception(new Trad('Impossible de trouver le message :', __FILE__) . ' ' . secureXSS($params['messageId'])); } } if ($jsonrpc->getMethod() == 'message::all') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a(message::all())); } if ($jsonrpc->getMethod() == 'message::add') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } if (!isset($params['action'])) $params['action'] = ''; if (!isset($params['logicalId'])) $params['logicalId'] = ''; @@ -1098,7 +1097,7 @@ /* * ************************Interact*************************** */ if ($jsonrpc->getMethod() == 'interact::tryToReply') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } if (isset($params['reply_cmd'])) { $reply_cmd = cmd::byId($params['reply_cmd']); @@ -1112,7 +1111,7 @@ if ($jsonrpc->getMethod() == 'interactQuery::all') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a(interactQuery::all())); } @@ -1120,7 +1119,7 @@ /* * ************************USB mapping*************************** */ if ($jsonrpc->getMethod() == 'jeedom::getUsbMapping') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $name = (isset($params['name'])) ? $params['name'] : ''; $gpio = (isset($params['gpio'])) ? $params['gpio'] : false; @@ -1130,7 +1129,7 @@ /* * ************************Plugin*************************** */ if ($jsonrpc->getMethod() == 'plugin::install') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); if (isset($params['plugin_id'])) { @@ -1149,7 +1148,7 @@ if ($jsonrpc->getMethod() == 'plugin::remove') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); if (isset($params['plugin_id'])) { @@ -1159,7 +1158,7 @@ $update = update::byLogicalId($params['logicalId']); } if (!is_object($update)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); } $update->remove(); $jsonrpc->makeSuccess('ok'); @@ -1167,7 +1166,7 @@ if ($jsonrpc->getMethod() == 'plugin::dependancyInfo') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $plugin = plugin::byId($params['plugin_id']); if (!is_object($plugin)) { @@ -1178,7 +1177,7 @@ if ($jsonrpc->getMethod() == 'plugin::dependancyInstall') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); $plugin = plugin::byId($params['plugin_id']); @@ -1191,7 +1190,7 @@ if ($jsonrpc->getMethod() == 'plugin::deamonInfo') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $plugin = plugin::byId($params['plugin_id']); if (!is_object($plugin)) { @@ -1202,7 +1201,7 @@ if ($jsonrpc->getMethod() == 'plugin::deamonInfoAll') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $deamons_infos = []; foreach ((plugin::listPlugin()) as $plugin) { @@ -1215,7 +1214,7 @@ if ($jsonrpc->getMethod() == 'plugin::deamonStart') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $plugin = plugin::byId($params['plugin_id']); if (!is_object($plugin)) { @@ -1233,7 +1232,7 @@ if ($jsonrpc->getMethod() == 'plugin::deamonStop') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); $plugin = plugin::byId($params['plugin_id']); @@ -1246,7 +1245,7 @@ if ($jsonrpc->getMethod() == 'plugin::deamonChangeAutoMode') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); $plugin = plugin::byId($params['plugin_id']); @@ -1260,21 +1259,21 @@ /* * ************************Update*************************** */ if ($jsonrpc->getMethod() == 'update::all') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user', 'restrict'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a(update::all())); } if ($jsonrpc->getMethod() == 'update::nbNeedUpdate') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(update::nbNeedUpdate()); } if ($jsonrpc->getMethod() == 'update::update') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); jeedom::update('', 0); @@ -1283,7 +1282,7 @@ if ($jsonrpc->getMethod() == 'update::checkUpdate') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } update::checkAllUpdate(); $jsonrpc->makeSuccess('ok'); @@ -1291,7 +1290,7 @@ if ($jsonrpc->getMethod() == 'update::doUpdate') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); if (isset($params['plugin_id'])) { @@ -1301,7 +1300,7 @@ $update = update::byLogicalId($params['logicalId']); } if (!is_object($update)) { - throw new Exception(__('Impossible de trouver l\'objet', __FILE__)); + throw new Exception(new Trad('Impossible de trouver l\'objet', __FILE__)); } $update->doUpdate(); $jsonrpc->makeSuccess('ok'); @@ -1311,7 +1310,7 @@ if ($jsonrpc->getMethod() == 'network::restartDns') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); config::save('market::allowDNS', 1); @@ -1321,7 +1320,7 @@ if ($jsonrpc->getMethod() == 'network::stopDns') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } unautorizedInDemo(); config::save('market::allowDNS', 0); @@ -1331,7 +1330,7 @@ if ($jsonrpc->getMethod() == 'network::dnsRun') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(network::dns_run()); } @@ -1340,14 +1339,14 @@ if ($jsonrpc->getMethod() == 'user::all') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $jsonrpc->makeSuccess(utils::o2a(user::all())); } if ($jsonrpc->getMethod() == 'user::save') { if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) { - throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); + throw new Exception(new Trad('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701); } $user = user::byId($params['id']); if (!is_object($user)) { @@ -1361,7 +1360,7 @@ /* * ************************************************************************ */ if (isset($params['plugin']) && $params['plugin'] != '' && $params['plugin'] != 'core') { - log::add('api', 'info', __('Demande pour le plugin :', __FILE__) . ' ' . secureXSS($params['plugin'])); + log::add('api', 'info', new Trad('Demande pour le plugin :', __FILE__) . ' ' . secureXSS($params['plugin'])); try { include_file('core', $params['plugin'], 'api', $params['plugin']); } catch (\Exception $e) { @@ -1375,7 +1374,7 @@ if ($jsonrpc->getMethod() == 'getJson') { log::add('api', 'debug', 'Demande du RDK to send with Json'); if (!is_object($_USER_GLOBAL)) { - throw new Exception(__('Utilisateur non défini', __FILE__), -32500); + throw new Exception(new Trad('Utilisateur non défini', __FILE__), -32500); } $registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array()); if (!is_array($registerDevice)) { @@ -1409,7 +1408,7 @@ $return[$idBox]['name'] = config::byKey('name'); $jsonrpc->makeSuccess($return); } - throw new Exception(__('Aucune méthode correspondante :', __FILE__) . ' ' . secureXSS($jsonrpc->getMethod()), -32500); + throw new Exception(new Trad('Aucune méthode correspondante :', __FILE__) . ' ' . secureXSS($jsonrpc->getMethod()), -32500); /* * *********Catch exeption*************** */ } catch (Exception $e) { $message = $e->getMessage(); diff --git a/core/api/marketApi.php b/core/api/marketApi.php index 08e3f342cf..762a171812 100644 --- a/core/api/marketApi.php +++ b/core/api/marketApi.php @@ -30,11 +30,11 @@ if (!jeedom::apiAccess(init('apikey'), 'apimarket')) { user::failedLogin(); sleep(5); - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp()); } if (init('action') == 'resync') { if (jeedom::isStarted() && config::byKey('enableCron', 'core', 1, true) == 0) { - die(__('Tous les crons sont actuellement désactivés', __FILE__)); + die(new Trad('Tous les crons sont actuellement désactivés', __FILE__)); } $cron = new cron(); $cron->setClass('repo_market'); @@ -47,7 +47,7 @@ if (init('action') == 'pullInstall') { if (jeedom::isStarted() && config::byKey('enableCron', 'core', 1, true) == 0) { - die(__('Tous les crons sont actuellement désactivés', __FILE__)); + die(new Trad('Tous les crons sont actuellement désactivés', __FILE__)); } $cron = new cron(); $cron->setClass('repo_market'); diff --git a/core/api/proApi.php b/core/api/proApi.php index 180eb02087..9a3985ce9d 100644 --- a/core/api/proApi.php +++ b/core/api/proApi.php @@ -43,20 +43,20 @@ $jsonrpc = new jsonrpc($request); if ($jsonrpc->getJsonrpc() != '2.0') { - throw new Exception(__('Requête invalide. Version JSON-RPC invalide :', __FILE__) . ' ' . $jsonrpc->getJsonrpc(), -32001); + throw new Exception(new Trad('Requête invalide. Version JSON-RPC invalide :', __FILE__) . ' ' . $jsonrpc->getJsonrpc(), -32001); } $params = $jsonrpc->getParams(); if (!isset($params['proapi'])) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } if (!jeedom::apiAccess($params['proapi'], 'apipro')) { - throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); + throw new Exception(new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__), -32001); } - log::add('api', 'info', __('connexion valide et verifiée :', __FILE__) . ' ' . $jsonrpc->getMethod()); + log::add('api', 'info', new Trad('connexion valide et verifiée :', __FILE__) . ' ' . $jsonrpc->getMethod()); /* * ************************config*************************** */ if ($jsonrpc->getMethod() == 'config::byKey') { @@ -101,7 +101,7 @@ if (config::byKey('enableCron', 'core', 1, true) == 0) { $defaut = 1; $result = 'NOK'; - $advice = __('Erreur cron : les crons sont désactivés. Allez dans Administration -> Moteur de tâches pour les réactiver', __FILE__); + $advice = new Trad('Erreur cron : les crons sont désactivés. Allez dans Administration -> Moteur de tâches pour les réactiver', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Cron actif', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -111,7 +111,7 @@ if (config::byKey('enableScenario') == 0 && count(scenario::all()) > 0) { $defaut = 1; $result = 'NOK'; - $advice = __('Erreur scénario : tous les scénarios sont désactivés. Allez dans Outils -> Scénarios pour les réactiver', __FILE__); + $advice = new Trad('Erreur scénario : tous les scénarios sont désactivés. Allez dans Outils -> Scénarios pour les réactiver', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Scénario actif', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -154,7 +154,7 @@ $advice = ''; if (version_compare(phpversion(), '5.5', '<')) { $defaut = 1; - $advice = __('Si vous êtes en version 5.4.x, on vous indiquera quand la version 5.5 sera obligatoire', __FILE__); + $advice = new Trad('Si vous êtes en version 5.4.x, on vous indiquera quand la version 5.5 sera obligatoire', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Version PHP', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -178,7 +178,7 @@ if (!network::test('internal')) { $defaut = 1; $result = 'NOK'; - $advice = __('Allez sur Administration -> Configuration -> Réseaux, puis configurez correctement la partie réseau', __FILE__); + $advice = new Trad('Allez sur Administration -> Configuration -> Réseaux, puis configurez correctement la partie réseau', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Configuration réseau interne', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -188,7 +188,7 @@ if (!network::test('external')) { $defaut = 1; $result = 'NOK'; - $advice = __('Allez sur Administration -> Configuration -> Réseaux, puis configurez correctement la partie réseau', __FILE__); + $advice = new Trad('Allez sur Administration -> Configuration -> Réseaux, puis configurez correctement la partie réseau', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Configuration réseau externe', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -204,7 +204,7 @@ } else { $result = 'NOK'; $defaut = 1; - $advice = __('Votre cache n\'est pas sauvegardé. En cas de redémarrage, certaines informations peuvent être perdues. Essayez de lancer (à partir du moteur de tâches) la tâche cache::persist.', __FILE__); + $advice = new Trad('Votre cache n\'est pas sauvegardé. En cas de redémarrage, certaines informations peuvent être perdues. Essayez de lancer (à partir du moteur de tâches) la tâche cache::persist.', __FILE__); } $health[] = array('plugin' => 'core', 'type' => 'Persistance du cache', 'defaut' => $defaut, 'result' => $result, 'advice' => $advice); @@ -403,7 +403,7 @@ $typeEqLogic = $params['eqType_name']; $typeCmd = $typeEqLogic . 'Cmd'; if ($typeEqLogic == '' || !class_exists($typeEqLogic) || !class_exists($typeCmd)) { - throw new Exception(__('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); + throw new Exception(new Trad('Type incorrect (classe commande inexistante)', __FILE__) . secureXSS($typeCmd)); } $eqLogic = null; if (isset($params['id'])) { @@ -498,7 +498,7 @@ if ($jsonrpc->getMethod() == 'cmd::byId') { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32701); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32701); } $jsonrpc->makeSuccess(utils::o2a($cmd)); } @@ -509,14 +509,14 @@ foreach ($params['id'] as $id) { $cmd = cmd::byId($id); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($id), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($id), -32702); } $return[$id] = array('value' => $cmd->execCmd($params['options']), 'collectDate' => $cmd->getCollectDate()); } } else { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } $return = array('value' => $cmd->execCmd($params['options']), 'collectDate' => $cmd->getCollectDate()); } @@ -526,7 +526,7 @@ if ($jsonrpc->getMethod() == 'cmd::getStatistique') { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } $jsonrpc->makeSuccess($cmd->getStatistique($params['startTime'], $params['endTime'])); } @@ -534,7 +534,7 @@ if ($jsonrpc->getMethod() == 'cmd::getTendance') { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { - throw new Exception(__('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); + throw new Exception(new Trad('Commande introuvable :', __FILE__) . ' ' . secureXSS($params['id']), -32702); } $jsonrpc->makeSuccess($cmd->getTendance($params['startTime'], $params['endTime'])); } @@ -570,7 +570,7 @@ } if ($params['state'] == 'run') { $scenario->addTag('trigger','api'); - $scenario->addTag('trigger_message',__('Scénario exécuté sur appel API', __FILE__)); + $scenario->addTag('trigger_message',new Trad('Scénario exécuté sur appel API', __FILE__)); $jsonrpc->makeSuccess($scenario->launch()); } if ($params['state'] == 'enable') { @@ -581,13 +581,13 @@ $scenario->setIsActive(0); $jsonrpc->makeSuccess($scenario->save()); } - throw new Exception(__('Le paramètre "state" ne peut être vide et doit avoir pour valeur [run,stop,enable,disable]', __FILE__)); + throw new Exception(new Trad('Le paramètre "state" ne peut être vide et doit avoir pour valeur [run, stop,enable,disable]', __FILE__)); } /* * ************************JeeNetwork*************************** */ if ($jsonrpc->getMethod() == 'jeeNetwork::handshake') { if (config::byKey('jeeNetwork::mode') != 'slave') { - throw new Exception(__('Impossible d\'ajouter une box Jeedom non esclave à un réseau Jeedom', __FILE__)); + throw new Exception(new Trad('Impossible d\'ajouter une box Jeedom non esclave à un réseau Jeedom', __FILE__)); } $auiKey = config::byKey('auiKey'); if ($auiKey == '') { @@ -654,11 +654,11 @@ if ($jsonrpc->getMethod() == 'jeeNetwork::receivedBackup') { if (config::byKey('jeeNetwork::mode') == 'slave') { - throw new Exception(__('Seul un maître peut recevoir une sauvegarde', __FILE__)); + throw new Exception(new Trad('Seul un maître peut recevoir une sauvegarde', __FILE__)); } $jeeNetwork = jeeNetwork::byId($params['slave_id']); if (!is_object($jeeNetwork)) { - throw new Exception(__('Aucun esclave correspondant à l\'ID :', __FILE__) . ' ' . secureXSS($params['slave_id'])); + throw new Exception(new Trad('Aucun esclave correspondant à l\'ID :', __FILE__) . ' ' . secureXSS($params['slave_id'])); } if (substr(config::byKey('backup::path'), 0, 1) != '/') { $backup_dir = __DIR__ . '/../../' . config::byKey('backup::path'); @@ -670,19 +670,19 @@ mkdir($uploaddir); } if (!file_exists($uploaddir)) { - throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir)); + throw new Exception(new Trad('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir)); } $_file = $_FILES['file']; $extension = strtolower(strrchr($_file['name'], '.')); if (!in_array($extension, array('.tar.gz', '.gz', '.tar'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension)); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension)); } if (filesize($_file['tmp_name']) > 50000000) { - throw new Exception(__('La taille du fichier est trop importante (maximum 50Mo)', __FILE__)); + throw new Exception(new Trad('La taille du fichier est trop importante (maximum 50Mo)', __FILE__)); } $uploadfile = $uploaddir . $jeeNetwork->getId() . '-' . $jeeNetwork->getName() . '-' . $jeeNetwork->getConfiguration('version') . '-' . date('Y-m-d_H\hi') . '.tar' . $extension; if (!move_uploaded_file($_file['tmp_name'], $uploadfile)) { - throw new Exception(__('Impossible de téléverser le fichier', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier', __FILE__)); } system('find ' . $uploaddir . $jeeNetwork->getId() . '*' . ' -mtime +' . config::byKey('backup::keepDays') . ' -print | xargs -r rm'); $jsonrpc->makeSuccess('ok'); @@ -690,7 +690,7 @@ if ($jsonrpc->getMethod() == 'jeeNetwork::restoreBackup') { if (config::byKey('jeeNetwork::mode') != 'slave') { - throw new Exception(__('Seul un esclave peut restaurer une sauvegarde', __FILE__)); + throw new Exception(new Trad('Seul un esclave peut restaurer une sauvegarde', __FILE__)); } if (substr(config::byKey('backup::path'), 0, 1) != '/') { $uploaddir = __DIR__ . '/../../' . config::byKey('backup::path'); @@ -701,20 +701,20 @@ mkdir($uploaddir); } if (!file_exists($uploaddir)) { - throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir)); + throw new Exception(new Trad('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir)); } $_file = $_FILES['file']; $extension = strtolower(strrchr($_file['name'], '.')); if (!in_array($extension, array('.tar.gz', '.gz', '.tar'))) { - throw new Exception(__('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension)); + throw new Exception(new Trad('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension)); } if (filesize($_file['tmp_name']) > 50000000) { - throw new Exception(__('La taille du fichier est trop importante (maximum 50Mo)', __FILE__)); + throw new Exception(new Trad('La taille du fichier est trop importante (maximum 50Mo)', __FILE__)); } $backup_name = 'backup-' . jeedom::version() . '-' . date("d-m-Y-H\hi") . '.tar.gz'; $uploadfile = $uploaddir . '/' . $backup_name; if (!move_uploaded_file($_file['tmp_name'], $uploadfile)) { - throw new Exception(__('Impossible de téléverser le fichier', __FILE__)); + throw new Exception(new Trad('Impossible de téléverser le fichier', __FILE__)); } jeedom::restore($uploadfile, true); $jsonrpc->makeSuccess('ok'); @@ -765,7 +765,6 @@ $params['log'], $params['position'], $params['search'], - $params['position'], $params['colored'], $params['numbered'], $params['numStart'], @@ -820,7 +819,7 @@ $market = market::byLogicalId($params['plugin_id']); } if (!is_object($market)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); } if (!isset($params['version'])) { $params['version'] = 'stable'; @@ -832,7 +831,7 @@ if ($jsonrpc->getMethod() == 'plugin::remove') { $market = market::byId($params['plugin_id']); if (!is_object($market)) { - throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); + throw new Exception(new Trad('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id'])); } if (!isset($params['version'])) { $params['version'] = 'stable'; @@ -906,7 +905,7 @@ /* * ************************************************************************ */ } - throw new Exception(__('Aucune méthode correspondante :', __FILE__) . ' ' . secureXSS($jsonrpc->getMethod()), -32500); + throw new Exception(new Trad('Aucune méthode correspondante :', __FILE__) . ' ' . secureXSS($jsonrpc->getMethod()), -32500); /* * *********Catch exeption*************** */ } catch (Exception $e) { $message = $e->getMessage(); diff --git a/core/api/tts.php b/core/api/tts.php index 5288d53043..609ddf2147 100644 --- a/core/api/tts.php +++ b/core/api/tts.php @@ -27,7 +27,7 @@ } if (!jeedom::apiAccess(init('apikey'), 'apitts')) { - echo __('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__); + echo new Trad('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__); die(); } @@ -44,14 +44,14 @@ } $text = init('text'); if ($text == '') { - echo __('Aucun texte à dire', __FILE__); + echo new Trad('Aucun texte à dire', __FILE__); die(); } if (substr(init('text'), -1) == '#' && substr(init('text'), 0, 1) == '#' && class_exists('songs') && class_exists('songs_song')) { - log::add('tts', 'debug', __('Tag detécté dans le tts et plugin song présent', __FILE__)); + log::add('tts', 'debug', new Trad('Tag detécté dans le tts et plugin song présent', __FILE__)); $song = songs_song::byLogicalId(strtolower(str_replace('#', '', init('text')))); if (is_object($song) && file_exists($song->getPath())) { - log::add('tts', 'debug', __('Son trouvé path :', __FILE__) . ' ' . $song->getPath()); + log::add('tts', 'debug', new Trad('Son trouvé path :', __FILE__) . ' ' . $song->getPath()); if (init('path') == 1) { echo $song->getPath(); } else { @@ -130,7 +130,7 @@ } } if ($older['file'] == null) { - log::add('tts', 'error', __('Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :', __FILE__) . ' ' . getDirectorySize($tts_dir)); + log::add('tts', 'error', new Trad('Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :', __FILE__) . ' ' . getDirectorySize($tts_dir)); } unlink($older['file']); } diff --git a/core/class/Trad.class.php b/core/class/Trad.class.php new file mode 100644 index 0000000000..3af378b42d --- /dev/null +++ b/core/class/Trad.class.php @@ -0,0 +1,35 @@ +key = $key; + $this->file = $file; + $this->backslash = $backslash; + $this->prefix = $prefix; + $this->suffix = $suffix; + } + + public function __toString(): string { + return $this->prefix.\translate::sentence(str_replace("\'", "'", $this->key), $this->file, $this->backslash).$this->suffix; + } + +} \ No newline at end of file diff --git a/core/class/ajax.class.php b/core/class/ajax.class.php index 87bd69986a..651fb2ac12 100644 --- a/core/class/ajax.class.php +++ b/core/class/ajax.class.php @@ -46,7 +46,7 @@ public static function init($_allowGetAction = array()) { header('Content-Type: application/json'); } if(isset($_GET['action']) && !in_array($_GET['action'], $_allowGetAction)){ - throw new \Exception(__('Méthode non autorisée en GET : ',__FILE__).$_GET['action']); + throw new \Exception(new Trad('Méthode non autorisée en GET : ', __FILE__).$_GET['action']); } } diff --git a/core/class/cmd.class.php b/core/class/cmd.class.php index 9000d3935f..184cd3519d 100644 --- a/core/class/cmd.class.php +++ b/core/class/cmd.class.php @@ -534,7 +534,7 @@ public static function byObjectNameEqLogicNameCmdName($_object_name, $_eqLogic_n 'cmd_name' => (html_entity_decode($_cmd_name) != '') ? html_entity_decode($_cmd_name) : $_cmd_name, ); - if ($_object_name == __('Aucun', __FILE__)) { + if ($_object_name == new Trad('Aucun', __FILE__)) { $sql = 'SELECT ' . DB::buildField(__CLASS__, 'c') . ' FROM cmd c INNER JOIN eqLogic el ON c.eqLogic_id=el.id @@ -772,7 +772,7 @@ public static function convertColor($_color) { if (isset($colors[$_color])) { return $colors[$_color]; } - throw new Exception(__('Impossible de traduire la couleur en code hexadécimal :', __FILE__) . $_color); + throw new Exception(new Trad('Impossible de traduire la couleur en code hexadécimal :', __FILE__) . $_color); } public static function availableWidget($_version) { @@ -888,7 +888,7 @@ public static function availableWidget($_version) { public static function getSelectOptionsByTypeAndSubtype($_type = false, $_subtype = false, $_version = 'dashboard', $_availWidgets = false) { if ($_type === false || $_subtype === false) { - throw new Exception(__('Type ou sous-type de commande invalide', __FILE__)); + throw new Exception(new Trad('Type ou sous-type de commande invalide', __FILE__)); } if (!$_availWidgets) { $_availWidgets = self::availableWidget($_version); @@ -1042,6 +1042,10 @@ public function formatValue($_value, $_quote = false) { return intval($binary xor boolval($this->getConfiguration('invertBinary', false))); case 'numeric': if ($this->getConfiguration('historizeRound') !== '' && is_numeric($this->getConfiguration('historizeRound')) && $this->getConfiguration('historizeRound') >= 0) { + if (!is_numeric($_value)) { + log::add('cmd', 'error', __('La formule de calcul doit retourner une valeur numérique uniquement : ', __FILE__) . $this->getHumanName() . ' => ' . $_value); + $_value = (float) (str_replace(',', '.', $_value)); + } $_value = round($_value, $this->getConfiguration('historizeRound')); } if ($_value > $this->getConfiguration('maxValue', $_value)) { @@ -1070,19 +1074,19 @@ public function getTableName() { public function save($_direct = false) { if ($this->getName() == '') { - throw new Exception(__('Le nom de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); + throw new Exception(new Trad('Le nom de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); } if ($this->getType() == '') { - throw new Exception($this->getHumanName() . ' ' . __('Le type de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); + throw new Exception($this->getHumanName() . ' ' . new Trad('Le type de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); } if ($this->getSubType() == '') { - throw new Exception($this->getHumanName() . ' ' . __('Le sous-type de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); + throw new Exception($this->getHumanName() . ' ' . new Trad('Le sous-type de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); } if ($this->getEqLogic_id() == '') { - throw new Exception($this->getHumanName() . ' ' . __('Vous ne pouvez pas créer une commande sans la rattacher à un équipement', __FILE__)); + throw new Exception($this->getHumanName() . ' ' . new Trad('Vous ne pouvez pas créer une commande sans la rattacher à un équipement', __FILE__)); } if ($this->getConfiguration('maxValue') != '' && $this->getConfiguration('minValue') != '' && $this->getConfiguration('minValue') > $this->getConfiguration('maxValue')) { - throw new Exception($this->getHumanName() . ' ' . __('La valeur minimum de la commande ne peut être supérieure à la valeur maximum', __FILE__)); + throw new Exception($this->getHumanName() . ' ' . new Trad('La valeur minimum de la commande ne peut être supérieure à la valeur maximum', __FILE__)); } if ($this->getEqType() == '') { $this->setEqType($this->getEqLogic()->getEqType_name()); @@ -1159,10 +1163,10 @@ private function pre_postExecCmd($_values = array(), $_type = 'jeedomPreExecCmd' $message = ''; switch ($_type) { case 'jeedomPreExecCmd': - $message = '. ' . __('Sur preExec de la commande', __FILE__); + $message = '. ' . new Trad('Sur preExec de la commande', __FILE__); break; case 'jeedomPostExecCmd': - $message = '. ' . __('Sur postExec de la commande', __FILE__); + $message = '. ' . new Trad('Sur postExec de la commande', __FILE__); break; } @@ -1184,7 +1188,7 @@ private function pre_postExecCmd($_values = array(), $_type = 'jeedomPreExecCmd' } scenarioExpression::createAndExec('action', $action['cmd'], $options); } catch (Exception $e) { - log::add('cmd', 'error', __('Erreur lors de l\'exécution de', __FILE__) . ' ' . $action['cmd'] . ': ' . $message . '. ' . $this->getHumanName() . __('Détails :', __FILE__) . ' ' . log::exception($e)); + log::add('cmd', 'error', new Trad('Erreur lors de l\'exécution de', __FILE__) . ' ' . $action['cmd'] . ': ' . $message . '. ' . $this->getHumanName() . new Trad('Détails :', __FILE__) . ' ' . log::exception($e)); } } } @@ -1310,14 +1314,14 @@ public function execCmd($_options = null, $_sendNodeJsEvent = false, $_quote = f } if ($this->isAlreadyInStateAllow() && $this->alreadyInState($options)) { if (is_array($options) && ((count($options) > 1 && isset($options['uid'])) || count($options) > 0)) { - log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . __('avec les paramètres', __FILE__) . ' ' . json_encode($options) . ' ' . __('(ignorée)', __FILE__)); + log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . new Trad('avec les paramètres', __FILE__) . ' ' . json_encode($options) . ' ' . new Trad('(ignorée)', __FILE__)); } else { - log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . __('(ignorée)', __FILE__)); + log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . new Trad('(ignorée)', __FILE__)); } return; } if (is_array($options) && ((count($options) > 1 && isset($options['uid'])) || count($options) > 0)) { - log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . __('avec les paramètres', __FILE__) . ' ' . json_encode($options)); + log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName() . ' ' . new Trad('avec les paramètres', __FILE__) . ' ' . json_encode($options)); } else { log::add('event', 'info', $GLOBALS['JEEDOM_SCLOG_TEXT']['execCmd']['txt'] . $this->getHumanName()); } @@ -1344,14 +1348,14 @@ public function execCmd($_options = null, $_sendNodeJsEvent = false, $_quote = f $numberTryWithoutSuccess = $eqLogic->getStatus('numberTryWithoutSuccess', 0); $eqLogic->setStatus('numberTryWithoutSuccess', $numberTryWithoutSuccess); if ($numberTryWithoutSuccess >= config::byKey('numberOfTryBeforeEqLogicDisable')) { - $message = __('Désactivation de', __FILE__) . ' ' . $eqLogic->getName() . ' ' . __('car il n\'a pas répondu ou mal répondu lors des 3 derniers essais', __FILE__); - $action = '' . __('Equipement', __FILE__) . ''; + $message = new Trad('Désactivation de', __FILE__) . ' ' . $eqLogic->getName() . ' ' . new Trad('car il n\'a pas répondu ou mal répondu lors des 3 derniers essais', __FILE__); + $action = '' . new Trad('Equipement', __FILE__) . ''; message::add($type, $message, $action); $eqLogic->setIsEnable(0); $eqLogic->save(); } } - log::add($type, 'error', __('Erreur exécution de la commande', __FILE__) . ' ' . $this->getHumanName() . ' : ' . log::exception($e)); + log::add($type, 'error', new Trad('Erreur exécution de la commande', __FILE__) . ' ' . $this->getHumanName() . ' : ' . log::exception($e)); throw $e; } if ($options !== null && $this->getValue() == '') { @@ -1397,7 +1401,7 @@ public function getWidgetsSelectOptions($_version = 'dashboard', $_availWidgets $this->setTemplate($_version, 'core::default'); $this->save(true); } - $display = ''; + $display = ''; return $display .= self::getSelectOptionsByTypeAndSubtype($this->getType(), $this->getSubType(), $_version, $_availWidgets); } @@ -1446,7 +1450,7 @@ public function getWidgetHelp($_version = 'dashboard', $_widgetName = '') { $widgetHelp = explode('', $widgetCode)[0]; $widgetHelp = explode('