Skip to content

Commit

Permalink
Merge branch 'jeedom:beta' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWaloo authored Nov 10, 2024
2 parents 932bc0b + 3147cdf commit 3c774ea
Show file tree
Hide file tree
Showing 36 changed files with 534 additions and 194 deletions.
6 changes: 6 additions & 0 deletions core/ajax/message.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
ajax::init();

if (init('action') == 'clearMessage') {
if(!isConnect('admin')){
throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__));
}
message::removeAll(init('plugin'));
ajax::success();
}
Expand All @@ -46,6 +49,9 @@
}

if (init('action') == 'removeMessage') {
if(!isConnect('admin')){
throw new Exception(__('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__));
Expand Down
10 changes: 9 additions & 1 deletion core/api/jeeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,15 @@
/* * *********Catch exeption*************** */
} catch (Exception $e) {
$message = $e->getMessage();
$jsonrpc = new jsonrpc(init('request'));
if(!isset($jsonrpc) || !is_object($jsonrpc)){
if(!isset($request)){
$request = init('request');
if ($request == '') {
$request = file_get_contents("php://input");
}
}
$jsonrpc = new jsonrpc($request);
}
$errorCode = (is_numeric($e->getCode())) ? -32000 - $e->getCode() : -32599;
log::add('api', 'info', 'Error code ' . $errorCode . ' : ' . secureXSS($message));
$jsonrpc->makeError($errorCode, $message);
Expand Down
29 changes: 13 additions & 16 deletions core/class/listener.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ public static function clean() {
if (count($events) > 0) {
$listener->emptyEvent();
foreach ($events as $event) {
if ($event == '#*#') {
$listener->addEvent('#*#');
} else {
$cmd = cmd::byId(str_replace('#', '', $event));
if (is_object($cmd)) {
$listener->addEvent($cmd->getId());
}
if (strpos($event, '*') !== false || strpos($event, '::') !== false || is_object(cmd::byId(trim($event, '#')))) {
$listener->addEvent($event);
}
}
$listener->save();
Expand All @@ -54,11 +49,11 @@ public static function clean() {
$listener->remove();
}
}
$sql = 'SELECT '.DB::buildField(__CLASS__).'
FROM listener GROUP BY class, function, event, option
$sql = 'SELECT ' . DB::buildField(__CLASS__) . '
FROM listener GROUP BY class, function, event, option
HAVING count(*) > 1';
$duplicateds = DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
if(count($duplicateds) > 0){
if (count($duplicateds) > 0) {
foreach ($duplicateds as $duplicated) {
$value = array(
'class' => $duplicated->getClass(),
Expand All @@ -73,7 +68,7 @@ public static function clean() {
AND `option`=:option
AND `event`=:event';
$listeners = DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
for($i=1;$i<count($listeners);$i++){
for ($i = 1; $i < count($listeners); $i++) {
$listeners[$i]->remove();
}
}
Expand Down Expand Up @@ -206,11 +201,11 @@ public static function searchEvent($_event) {
return DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}

public static function check($_event, $_value, $_datetime = null,$_object = null) {
public static function check($_event, $_value, $_datetime = null, $_object = null) {
$listeners = self::searchEvent($_event);
if (is_array($listeners) && count($listeners) > 0) {
foreach ($listeners as $listener) {
$listener->run(str_replace('#', '', $_event), $_value, $_datetime,$_object);
$listener->run(str_replace('#', '', $_event), $_value, $_datetime, $_object);
}
}
}
Expand All @@ -233,13 +228,13 @@ public function getName() {

/* * *********************Méthodes d'instance************************* */

public function run($_event, $_value, $_datetime = null,$_object = null) {
public function run($_event, $_value, $_datetime = null, $_object = null) {
$option = array();
if (count($this->getOption()) > 0) {
$option = $this->getOption();
}
if (isset($option['background']) && $option['background'] == false) {
$this->execute($_event, $_value, $_datetime,$_object);
$this->execute($_event, $_value, $_datetime, $_object);
} else {
$cmd = __DIR__ . '/../php/jeeListener.php';
$cmd .= ' listener_id=' . $this->getId() . ' event_id=' . $_event . ' "value=' . escapeshellarg($_value) . '"';
Expand All @@ -250,7 +245,7 @@ public function run($_event, $_value, $_datetime = null,$_object = null) {
}
}

public function execute($_event, $_value, $_datetime = '',$_object = null) {
public function execute($_event, $_value, $_datetime = '', $_object = null) {
try {
$option = array();
if (count($this->getOption()) > 0) {
Expand Down Expand Up @@ -306,6 +301,7 @@ public function remove() {

public function emptyEvent() {
$this->event = array();
return $this;
}

public function addEvent($_id) {
Expand All @@ -318,6 +314,7 @@ public function addEvent($_id) {
$event[] = '#' . $id . '#';
}
$this->setEvent($event);
return $this;
}

/* * **********************Getteur Setteur*************************** */
Expand Down
5 changes: 3 additions & 2 deletions core/class/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function doUpdate() {
}
} catch (Exception $e) {
}
shell_exec('find '.$cibDir.'/ -exec touch {} +');
shell_exec('find ' . $cibDir . '/ -exec touch {} +');
rmove($cibDir . '/', __DIR__ . '/../../plugins/' . $this->getLogicalId(), false, array(), true);
rrmdir($cibDir);
$cibDir = jeedom::getTmpFolder('market') . '/' . $this->getLogicalId();
Expand Down Expand Up @@ -476,10 +476,11 @@ public function postInstallUpdate($_infos) {
$this->remove();
throw new Exception(__("Impossible d'installer le plugin. Le nom du plugin est différent de l'ID ou le plugin n'est pas correctement formé. Veuillez contacter l'auteur", __FILE__));
}
$plugin->callInstallFunction('post_plugin_install');
if (is_object($plugin) && $plugin->isActive()) {
$plugin->setIsEnable(1);
}
$plugin->setCache('usedSpace',null);
$plugin->setCache('usedSpace', null);
break;
}
if (isset($_infos['localVersion'])) {
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Die Info",
"Action": "Aktion",
"Sélectionner la commande": "Befehl auswählen",
"Valider": "Validate",
"Annuler": "Abbrechen"
"Annuler": "Abbrechen",
"Valider": "Validate"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Wählen Sie das Szenario aus",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Nicht autorisierter Zugriff",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Sie sind nicht berechtigt, diese Aktion durchzuführen",
"Message inconnu. Vérifiez l\\'ID": "Unbekannte Nachricht. Überprüfen Sie die ID",
"Aucune méthode correspondante à :": "Keine Methode entsprechend:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Info",
"Action": "Action",
"Sélectionner la commande": "Select command",
"Valider": "Ok",
"Annuler": "Cancel"
"Annuler": "Cancel",
"Valider": "Ok"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Select the scenario",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Unauthorized access",
"Vous n\\'êtes pas autorisé à effectuer cette action": "You are not allowed to perform this action",
"Message inconnu. Vérifiez l\\'ID": "Unknown message. Check the ID",
"Aucune méthode correspondante à :": "No method corresponding to:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Información",
"Action": "Acción",
"Sélectionner la commande": "Seleccione el comando",
"Valider": "Validar",
"Annuler": "Cancelar"
"Annuler": "Cancelar",
"Valider": "Validar"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Seleccione el escenario",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Acceso no autorizado",
"Vous n\\'êtes pas autorisé à effectuer cette action": "No estás autorizado a realizar esta acción",
"Message inconnu. Vérifiez l\\'ID": "Mensaje desconocido. Verifica el ID",
"Aucune méthode correspondante à :": "Ningún método correspondiente a:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Info",
"Action": "Action",
"Sélectionner la commande": "Sélectionner la commande",
"Valider": "Valider",
"Annuler": "Annuler"
"Annuler": "Annuler",
"Valider": "Valider"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Sélectionner le scénario",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Accès non autorisé",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "Message inconnu. Vérifiez l\\'ID",
"Aucune méthode correspondante à :": "Aucune méthode correspondante à :"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/id_ID.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Info",
"Action": "Tindakan",
"Sélectionner la commande": "Pilih perintah",
"Valider": "Mengesahkan",
"Annuler": "Tidak jadi"
"Annuler": "Tidak jadi",
"Valider": "Mengesahkan"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Pilih skenario",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Akses tidak sah",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "Message inconnu. Vérifiez l\\'ID",
"Aucune méthode correspondante à :": "Aucune methode correspondante à :"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Info",
"Action": "Azione",
"Sélectionner la commande": "Seleziona comando",
"Valider": "Convalidare",
"Annuler": "Cancella"
"Annuler": "Cancella",
"Valider": "Convalidare"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Seleziona lo scenario",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Accesso non autorizzato",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "Messaggio sconosciuto. Controlla l'ID",
"Aucune méthode correspondante à :": "Nessun metodo corrispondente a:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "インフォ",
"Action": "アクション",
"Sélectionner la commande": "コマンドを選択",
"Valider": "検証",
"Annuler": "キャンセル"
"Annuler": "キャンセル",
"Valider": "検証"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "シナリオを選択",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401-不正アクセス",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "不明なメッセージ。 IDを確認してください",
"Aucune méthode correspondante à :": "以下に対応するメソッドはありません:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Informações",
"Action": "Açao",
"Sélectionner la commande": "Selecione o comando",
"Valider": "Validar",
"Annuler": "Cancelar"
"Annuler": "Cancelar",
"Valider": "Validar"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Selecione o cenário",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Acesso não autorizado",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Você não está autorizado a realizar esta ação",
"Message inconnu. Vérifiez l\\'ID": "Mensagem desconhecida. Verifique o ID",
"Aucune méthode correspondante à :": "Nenhum método correspondente a:"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Информация",
"Action": "Действие",
"Sélectionner la commande": "Выберите команду",
"Valider": "Validate",
"Annuler": "Отменить"
"Annuler": "Отменить",
"Valider": "Validate"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Выберите сценарий",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Несанкционированный доступ",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "Message inconnu. Vérifiez l\\'ID",
"Aucune méthode correspondante à :": "Aucune methode correspondante à :"
},
Expand Down
5 changes: 3 additions & 2 deletions core/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,8 @@
"Info": "Bilgi",
"Action": "Eylem",
"Sélectionner la commande": "Komutayı seçin",
"Valider": "Onaylayın",
"Annuler": "Iptal et"
"Annuler": "Iptal et",
"Valider": "Onaylayın"
},
"core\/js\/scenario.class.js": {
"Sélectionner le scénario": "Senaryoyu seçin",
Expand Down Expand Up @@ -4078,6 +4078,7 @@
},
"core\/ajax\/message.ajax.php": {
"401 - Accès non autorisé": "401 - Yetkisiz erişim",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Message inconnu. Vérifiez l\\'ID": "Message inconnu. Vérifiez l\\'ID",
"Aucune méthode correspondante à :": "Aşağıdakilere karşılık gelen bir yöntem yok:"
},
Expand Down
26 changes: 13 additions & 13 deletions core/js/cmd.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,20 @@ jeedom.cmd.getSelectModal = function(_options, _callback) {
contentUrl: 'index.php?v=d&modal=cmd.human.insert',
callback: function() { mod_insertCmd.setOptions(_options) },
buttons: {
cancel: {
label: '<i class="fas fa-times"></i> {{Annuler}}',
className: 'warning',
callback: {
click: function(event) {
if (isset(_options.returnCancel) && 'function' === typeof (_callback)) {
_callback({})
}
document.getElementById('mod_insertCmdValue')._jeeDialog.destroy()
}
}
},
confirm: {
label: '{{Valider}}',
label: '<i class="fas fa-check"></i> {{Valider}}',
className: 'success',
callback: {
click: function(event) {
Expand All @@ -1006,18 +1018,6 @@ jeedom.cmd.getSelectModal = function(_options, _callback) {
document.getElementById('mod_insertCmdValue')._jeeDialog.destroy()
}
}
},
cancel: {
label: '{{Annuler}}',
className: 'warning',
callback: {
click: function(event) {
if (isset(_options.returnCancel) && 'function' === typeof (_callback)) {
_callback({})
}
document.getElementById('mod_insertCmdValue')._jeeDialog.destroy()
}
}
}
}
})
Expand Down
Loading

0 comments on commit 3c774ea

Please sign in to comment.