Skip to content

Commit

Permalink
add removeNotifsCmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekiro-kost committed Oct 14, 2024
1 parent 73bf72f commit a35f5b4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/class/mobile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,21 @@ public function postSave()
$cmdNotif->setType('action');
$cmdNotif->setSubType('message');
$cmdNotif->save();

$cmdRemoveNotifs = $this->getCmd(null, 'removeNotifs');
if (!is_object($cmdRemoveNotifs)) {
$cmdRemoveNotifs = new mobileCmd();
$cmdRemoveNotifs->setIsVisible(1);
$cmdRemoveNotifs->setName(__('Supprimer les notifications', __FILE__));
$cmdRemoveNotifs->setOrder(0);
}
$cmdRemoveNotifs->setLogicalId('removeNotifs');
$cmdRemoveNotifs->setEqLogic_id($this->getId());
$cmdRemoveNotifs->setDisplay('generic_type', 'GENERIC_ACTION');
$cmdRemoveNotifs->setType('action');
$cmdRemoveNotifs->setSubType('other');
$cmdRemoveNotifs->save();

}

$cmdaskText = $this->getCmd(null, 'ask_Text');
Expand Down Expand Up @@ -1001,6 +1016,18 @@ public function execute($_options = array())
$optionsNotif = [];
$eqLogic = $this->getEqLogic();


if($this->getLogicalId() == 'removeNotifs') {
$Iq = $eqLogic->getId();
$filePath = dirname(__FILE__) . '/../../data/notifications/' . $Iq . '.json';
if (file_exists($filePath)) {
file_put_contents($filePath, '');
log::add('mobile', 'info', '| Suppression des notifications effectuée: ');
} else {
log::add('mobile', 'info', '| Fichier de notifications non trouvé: ' . $filePath);
}
}

if ($this->getLogicalId() == 'notif' || $this->getLogicalId() == 'notifCritical') {
$critical = false;
$defaultName = empty(config::byKey('name')) ? config::byKey('product_name') : config::byKey('name');
Expand Down

0 comments on commit a35f5b4

Please sign in to comment.