Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
Phpvarious authored Oct 6, 2024
1 parent 76d5077 commit 9166a14
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,36 @@ function mobile_install()
/* Create folder for notifications */
$pathNotifications = dirname(__FILE__) . '/../core/data/notifications/';
if(!is_dir($pathNotifications)){
log::add('mobile', 'debug', '| creating folder for the notifications');
mkdir($pathNotifications, 0775, true);
}

$mobiles = eqLogic::byType('mobile');
foreach($mobiles as $mobile){
/* Delete mobile with bad logicalId */
if ($mobile->getLogicalId() == null || $mobile->getLogicalId() == "") {
$mobile->remove();
continue;
}
/* Set menu by defaut if no exist */
$customMenu = $mobile->getConfiguration('menuCustomArray');
if(empty($customMenu)){
$menuCustomArray = mobile::getMenuDefaultV2();
$mobile->setConfiguration('nbIcones', count($menuCustomArray));
$mobile->setConfiguration('defaultIdMobile', $mobile->getId());
$mobile->setConfiguration('menuCustomArray', $menuCustomArray);
$mobile->save();
}
}

/* Generate ApiKey if no exist */
jeedom::getApiKey('mobile');
log::add('mobile', 'debug', '└───────────────────────────────────────────');
}

function mobile_update()
{
/* function launched when updating plugin */
log::add('mobile', 'debug', ':fg-warning:Launch function mobile_update() :/fg: ──────────');
log::add('mobile', 'debug', '┌────────── :fg-warning: Launch function mobile_update() :/fg: ──────────');

/* Create folder for notifications */
$pathNotifications = dirname(__FILE__) . '/../core/data/notifications/';
if(!is_dir($pathNotifications)){
log::add('mobile', 'debug', '| creating folder for the notifications');
mkdir($pathNotifications, 0775, true);
}

$mobiles = eqLogic::byType('mobile');
foreach($mobiles as $mobile){
/* Delete mobile with bad logicalId */
if ($mobile->getLogicalId() == null || $mobile->getLogicalId() == "") {
log::add('mobile', 'debug', '| Removing equipment ' . $mobile->getId() . ' because it does not contain a logicalId');
$mobile->remove();
continue;
}
/* Set menu by defaut if no exist */
$customMenu = $mobile->getConfiguration('menuCustomArray');
if(empty($customMenu)){
log::add('mobile', 'debug', '| Assigning a default menu to the equipment ' . $mobile->getId());
$menuCustomArray = mobile::getMenuDefaultV2();
$mobile->setConfiguration('nbIcones', count($menuCustomArray));
$mobile->setConfiguration('defaultIdMobile', $mobile->getId());
Expand Down Expand Up @@ -105,6 +89,7 @@ function mobile_update()
'/../desktop/modal/sixPage.php', '/../desktop/modal/wizard.php'];
foreach ($oldFiles as $oldFile) {
if (file_exists(dirname(__FILE__) . $oldFile)) {
log::add('mobile', 'debug', '| Removing old file : ' . dirname(__FILE__) . $oldFile);
shell_exec('rm ' . dirname(__FILE__) . $oldFile);
}
}
Expand All @@ -125,10 +110,18 @@ function mobile_update()

foreach ($oldCoreImgs as $oldCoreImg) {
if (file_exists(dirname(__FILE__) . '/../core/img/' . $oldCoreImg)) {
log::add('mobile', 'debug', '| Removing old image : ' . dirname(__FILE__) . '/../core/img/' . $oldCoreImg);
shell_exec('rm ' . dirname(__FILE__) . '/../core/img/' . $oldCoreImg);
}
}
if(!glob(dirname(__FILE__) . '/../core/img/' . '*'))
{
log::add('mobile', 'debug', '| Deleting empty core/img folder');
shell_exec('rm -rf ' . dirname(__FILE__) . '/../core/img');
}

/* Generate ApiKey if no exist */
jeedom::getApiKey('mobile');

log::add('mobile', 'debug', '└───────────────────────────────────────────');
}

0 comments on commit 9166a14

Please sign in to comment.