Skip to content

Commit 5ec15ec

Browse files
author
jalcaras
committed
code improvement, from codebeat advice
1 parent 746295c commit 5ec15ec

File tree

3 files changed

+19
-40
lines changed

3 files changed

+19
-40
lines changed

3rdparty/reolinkapi.class.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,17 @@ public function __construct(array $cnxinfo) {
160160
$this->cnxtype = strtolower($cnxinfo['cnxtype']);
161161
}
162162

163-
if ($this->cnxtype == "http") {
164-
($cnxinfo['port'] == "" || !is_numeric($cnxinfo['port'])) ? $this->port = 80 : $this->port = trim($cnxinfo['port']);
163+
if ($cnxinfo['port'] == "" || !is_numeric($cnxinfo['port'])) {
164+
if ($this->cnxtype == "http") {
165+
$this->port = 80;
166+
} else {
167+
$this->port = 443;
168+
}
165169
} else {
166-
($cnxinfo['port'] == "" || !is_numeric($cnxinfo['port'])) ? $this->port = 443 : $this->port = trim($cnxinfo['port']);
170+
$this->port = trim($cnxinfo['port']);
167171
}
168172

173+
169174
$this->user = trim($cnxinfo['username']);
170175
$this->password = trim($cnxinfo['password']);
171176
$this->tagtoken = str_replace(".", "", $this->ip);

core/ajax/reolink.ajax.php

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
*/
3131
ajax::init();
3232

33+
$camera = reolink::byId(init('id'));
34+
if (!is_object($camera)) {
35+
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
36+
}
37+
38+
3339
if (init('action') == 'CreateCMD') {
34-
$camera = reolink::byId(init('id'));
35-
if (!is_object($camera)) {
36-
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
37-
}
3840
$camera->GetCamNFO(init('id'));
3941
$res = $camera->loadCmdFromConf(init('id'));
4042

@@ -46,10 +48,6 @@
4648
}
4749

4850
if (init('action') == 'CheckConnexion') {
49-
$camera = reolink::byId(init('id'));
50-
if (!is_object($camera)) {
51-
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
52-
}
5351
$res = $camera->TryConnect(init('id'));
5452
if ($res === true) {
5553
ajax::success();
@@ -59,43 +57,15 @@
5957
}
6058

6159
if (init('action') == 'CheckDeviceInfo') {
62-
$camera = reolink::byId(init('id'));
63-
if (!is_object($camera)) {
64-
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
65-
}
6660
$res = $camera->GetCamNFO(init('id'));
6761
if ($res === true) {
6862
ajax::success();
6963
} else {
70-
throw new Exception(__('Impossible de se connecter à la caméra ('.$res.')', __FILE__));
64+
throw new Exception(__('Impossible d\'obtenir les informations de la caméra ('.$res.')', __FILE__));
7165
}
7266
}
7367

74-
if (init('action') == 'SetCAMConfig') {
75-
$camera = reolink::byId(init('id'));
76-
if (!is_object($camera)) {
77-
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
78-
}
79-
$cfgGroup = init('group');
80-
if ($cfgGroup == 'EMAIL'){
81-
$res = reolink::setEmail(init('id'));
82-
}
83-
if ($cfgGroup == 'FTP'){
84-
$res = reolink::setFTP(init('id'));
85-
}
86-
87-
if ($res == 200) {
88-
ajax::success();
89-
} else {
90-
throw new Exception(__('Echec du paramétrage de la caméra (consultez le log pour plus de détails)', __FILE__));
91-
}
92-
}
93-
9468
if (init('action') == 'GetCAMConfig') {
95-
$camera = reolink::byId(init('id'));
96-
if (!is_object($camera)) {
97-
throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__));
98-
}
9969
$res = reolink::refreshNFO(init('id'));
10070
ajax::success();
10171
}

plugin_info/install.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ function reolink_install() {
2525

2626
// Fonction exécutée automatiquement après la mise à jour du plugin
2727
function reolink_update() {
28+
$plugin = plugin::byId('reolink');
29+
$eqLogics = eqLogic::byType($plugin->getId());
30+
foreach ($eqLogics as $eqLogic) {
2831

32+
}
2933
}
3034

3135
// Fonction exécutée automatiquement après la suppression du plugin

0 commit comments

Comments
 (0)