Skip to content

Commit

Permalink
Merge pull request #2737 from jeedom/alpha
Browse files Browse the repository at this point in the history
Beta 4.4.9
  • Loading branch information
zoic21 authored Jul 9, 2024
2 parents 5d300a0 + d12cd59 commit 7f26d1a
Show file tree
Hide file tree
Showing 62 changed files with 5,420 additions and 3,168 deletions.
6 changes: 0 additions & 6 deletions core/ajax/cache.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
ajax::success();
}

if (init('action') == 'flushWidget') {
unautorizedInDemo();
cache::flushWidget();
ajax::success();
}

if (init('action') == 'clean') {
unautorizedInDemo();
cache::clean();
Expand Down
16 changes: 0 additions & 16 deletions core/class/cache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,6 @@ public static function flush() {
shell_exec('rm -rf ' . self::getFolder() . ' 2>&1 > /dev/null');
}


public static function flushWidget() {
foreach ((eqLogic::all()) as $eqLogic) {
try {
$eqLogic->emptyCacheWidget();
} catch (Exception $e) {
}
}
foreach ((scenario::all()) as $scenario) {
try {
$scenario->emptyCacheWidget();
} catch (Exception $e) {
}
}
}

public static function search() {
return array();
}
Expand Down
4 changes: 0 additions & 4 deletions core/class/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@ public static function postConfig_market_allowDns($_value) {
}
}

public static function postConfig_interface_advance_vertCentering($_value) {
cache::flushWidget();
}

public static function postConfig_theme_start_day_hour($_value) {
event::add('checkThemechange', array('theme_start_day_hour' => $_value));
}
Expand Down
78 changes: 28 additions & 50 deletions core/class/eqLogic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static function byCategorie($_category) {
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

public static function byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable=false, $_onlyVisible=false) {
public static function byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable = false, $_onlyVisible = false) {
if (is_array($_configuration)) {
$values = array(
'eqType_name' => $_eqType_name,
Expand All @@ -238,9 +238,9 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
}
if ($_onlyVisible) {
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
}
$sql .= ' AND JSON_CONTAINS(configuration,:configuration)
ORDER BY name';
if ($_eqType_name != null && class_exists($_eqType_name)) {
Expand All @@ -255,13 +255,13 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
$sql = 'SELECT ' . DB::buildField(__CLASS__) . '
FROM eqLogic
WHERE eqType_name=:eqType_name';
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
}
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
$sql .= '
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
$sql .= '
AND configuration LIKE :configuration
ORDER BY name';
if ($_eqType_name != null && class_exists($_eqType_name)) {
Expand All @@ -270,7 +270,7 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

public static function byTypeAndSearhConfiguration($_eqType_name, $_configuration, $_onlyEnable=false, $_onlyVisible=false) {
public static function byTypeAndSearhConfiguration($_eqType_name, $_configuration, $_onlyEnable = false, $_onlyVisible = false) {
trigger_error('eqLogic::byTypeAndSearhConfiguration() is deprecated since Core v4.4, eqLogic::byTypeAndSearchConfiguration() has been introduced since Core v4.1', E_USER_DEPRECATED);
return self::byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable, $_onlyVisible);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ public static function toHumanReadable($_input) {
}

public static function fromHumanReadable($_input) {
if(empty($_input)){
if (empty($_input)) {
return $_input;
}
$isJson = false;
Expand Down Expand Up @@ -528,7 +528,7 @@ public static function fromHumanReadable($_input) {
return $_input;
}
$text = $_input;
preg_match_all( "/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
preg_match_all("/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
if (count($matches) == 3) {
$countMatches = count($matches[0]);
for ($i = 0; $i < $countMatches; $i++) {
Expand Down Expand Up @@ -557,12 +557,6 @@ public static function byString($_string) {
return $eqLogic;
}

public static function clearCacheWidget() {
foreach ((self::all()) as $eqLogic) {
$eqLogic->emptyCacheWidget();
}
}

public static function generateHtmlTable($_nbLine, $_nbColumn, $_options = array()) {
$return = array('html' => '', 'replace' => array());
if (!isset($_options['styletd'])) {
Expand All @@ -583,19 +577,19 @@ public static function generateHtmlTable($_nbLine, $_nbColumn, $_options = array
$styletd = (isset($_options['style::td::' . $i . '::' . $j]) && $_options['style::td::' . $i . '::' . $j] != '') ? $_options['style::td::' . $i . '::' . $j] : '';
$attrs = '';
$style = '';
if(trim($styletd) != ''){
foreach (explode(';',$styletd) as $value) {
if($value == '') continue;
if(strpos($value, '=') !== false){
if (trim($styletd) != '') {
foreach (explode(';', $styletd) as $value) {
if ($value == '') continue;
if (strpos($value, '=') !== false) {
$attrs .= $value;
}else{
$style .= $value.';';
} else {
$style .= $value . ';';
}
}
}
$style = $_options['styletd'] . $style;
$classTd = ($style != '') ? 'tableCmdcss' : '';
$return['html'] .= '<td class="' . $classTd . (($_options['center'] == 1) ? ' tableCenter' : '') . '" style="' . $style . '" '.$attrs.' data-line="' . $i . '" data-column="' . $j . '">';
$return['html'] .= '<td class="' . $classTd . (($_options['center'] == 1) ? ' tableCenter' : '') . '" style="' . $style . '" ' . $attrs . ' data-line="' . $i . '" data-column="' . $j . '">';
if (isset($_options['text::td::' . $i . '::' . $j])) {
$return['html'] .= $_options['text::td::' . $i . '::' . $j];
}
Expand Down Expand Up @@ -648,8 +642,8 @@ public function batteryWidget($_version = 'dashboard') {
if ($_version == 'mobile') {
$html .= '<div class="widget-name"><span class="name">' . $eqName . '</span><span class="object">' . $object_name . '</span></div>';
} else {
$html .= '<div class="#battery widget-name"><a href="' . $this->getLinkToConfiguration() . '">' . $eqName . '</a><br><span>' . $object_name . '</span></div>';
}
$html .= '<div class="#battery widget-name"><a href="' . $this->getLinkToConfiguration() . '">' . $eqName . '</a><br><span>' . $object_name . '</span></div>';
}
$html .= '<div class="jeedom-batterie">';
$html .= '<i class="icon jeedom-batterie' . $niveau . '"></i>';
$html .= '<span>' . $this->getStatus('battery', -2) . '%</span>';
Expand Down Expand Up @@ -710,12 +704,9 @@ public function checkAndUpdateCmd($_logicalId, $_value, $_updateTime = null) {
return false;
}

public function copy($_name, $_logicalId = null) {
public function copy($_name) {
$eqLogicCopy = clone $this;
$eqLogicCopy->setName($_name);
if($_logicalId){
$eqLogicCopy->setLogicalId($_logicalId);
}
$eqLogicCopy->setId('');
$eqLogicCopy->save();
foreach (($eqLogicCopy->getCmd()) as $cmd) {
Expand All @@ -738,6 +729,12 @@ public function copy($_name, $_logicalId = null) {
$cmd_link[$cmd->getId()]->save();
}
}

$backGraphCmd = $this->getDisplay('backGraph::info', 0);
if ($backGraphCmd != 0 && isset($cmd_link[$backGraphCmd])) {
$eqLogicCopy->setDisplay('backGraph::info', $cmd_link[$backGraphCmd]->getId());
$eqLogicCopy->save(true);
}
return $eqLogicCopy;
}

Expand All @@ -757,12 +754,6 @@ public function preToHtml($_version = 'dashboard', $_default = array(), $_noCach
if (!$this->hasRight('r') || !$this->getIsEnable()) {
return '';
}
if (!$_noCache && config::byKey('widget::disableCache', 'core', 0) == 0) {
$mc = cache::byKey('widgetHtml' . $this->getId() . $_version);
if (trim($mc->getValue()) != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
}
}
$translate_category = '';
foreach ($JEEDOM_INTERNAL_CONFIG['eqLogic']['category'] as $key => $value) {
if ($this->getCategory($key, 0) == 1) {
Expand Down Expand Up @@ -916,7 +907,6 @@ public function toHtml($_version = 'dashboard') {
}
$replace['#cmd#'] = template_replace($table['tag'], $table['html']);
break;

default:
$replace['#eqLogic_class#'] = 'eqLogic_layout_default';
$cmd_html = '';
Expand All @@ -942,19 +932,10 @@ public function toHtml($_version = 'dashboard') {
}

public function postToHtml($_version, $_html) {
if (config::byKey('widget::disableCache', 'core', 0) == 0) {
cache::set('widgetHtml' . $this->getId() . $_version, $_html);
}
return $_html;
}

public function emptyCacheWidget() {
if (config::byKey('widget::disableCache', 'core', 0) == 0) {
$mc = cache::byKey('widgetHtml' . $this->getId() . 'mobile');
$mc->remove();
$mc = cache::byKey('widgetHtml' . $this->getId() . 'dashboard');
$mc->remove();
}
}

public function getAlert() {
Expand Down Expand Up @@ -997,7 +978,6 @@ public function remove() {
}
viewData::removeByTypeLinkId('eqLogic', $this->getId());
dataStore::removeByTypeLinkId('eqLogic', $this->getId());
$this->emptyCacheWidget();
cache::delete('eqLogicCacheAttr' . $this->getId());
cache::delete('eqLogicStatusAttr' . $this->getId());
jeedom::addRemoveHistory(array('id' => $this->getId(), 'name' => $this->getHumanName(), 'date' => date('Y-m-d H:i:s'), 'type' => 'eqLogic'));
Expand All @@ -1010,7 +990,6 @@ public function save($_direct = false) {
}
if ($this->getChanged()) {
if ($this->getId() != '') {
$this->emptyCacheWidget();
$this->setConfiguration('updatetime', date('Y-m-d H:i:s'));
} else {
$this->setConfiguration('createtime', date('Y-m-d H:i:s'));
Expand Down Expand Up @@ -1243,7 +1222,6 @@ public function batteryStatus($_pourcent = '', $_datetime = '') {

public function refreshWidget() {
$this->_needRefreshWidget = false;
$this->emptyCacheWidget();
event::add('eqLogic::update', array('eqLogic_id' => $this->getId(), 'visible' => $this->getIsVisible(), 'enable' => $this->getIsEnable()));
}

Expand Down
2 changes: 2 additions & 0 deletions core/class/history.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ public static function archive() {
);
$sql = 'DELETE FROM historyArch WHERE cmd_id=:cmd_id AND `datetime` < :datetime';
DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
$sql = 'DELETE FROM history WHERE cmd_id=:cmd_id AND `datetime` < :datetime';
DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
}
if (!$JEEDOM_INTERNAL_CONFIG['cmd']['type']['info']['subtype'][$cmd->getSubType()]['isHistorized']['canBeSmooth'] || $cmd->getConfiguration('historizeMode', 'avg') == 'none') {
$values = array(
Expand Down
13 changes: 0 additions & 13 deletions core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,6 @@ public static function health() {
'comment' => '',
'key' => 'uptodate'
);
if (version_compare(system::getOsVersion(), '12', '<')) {
$status = shell_exec('systemctl status fail2ban.service');
$failed = stripos($status, 'failed') !== false;
$running = stripos($status, 'running') !== false;
$state = $failed ? 0 : ($running ? 1 : 2);
$return[] = array(
'name' => __('Etat du service fail2ban', __FILE__),
'state' => $failed ? 0 : ($running ? 1 : 2),
'result' => $failed ? __('En échec', __FILE__) : ($running ? __('Actif', __FILE__) : __('Désactivé', __FILE__)),
'comment' => ($failed || !$running) ? __("Le service Linux fail2ban est désactivé ou en échec : les tentatives d'accès infructueuses à Jeedom ne résulteront pas en un bannissement des IP concernées. Vérifiez l'état du service si vous souhaitez réactiver fail2ban.", __FILE__) : '',
'key' => 'service::fail2ban'
);
}

$state = (config::byKey('enableCron', 'core', 1, true) != 0) ? true : false;
$return[] = array(
Expand Down
9 changes: 0 additions & 9 deletions core/class/scenario.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,6 @@ public function toHtml($_version) {
if (!$this->hasRight('r')) {
return '';
}
if (config::byKey('widget::disableCache', 'core', 0) == 0) {
$mc = cache::byKey('scenarioHtml' . $_version . $this->getId());
if ($mc->getValue() != '') {
return $mc->getValue();
}
}
$version = jeedom::versionAlias($_version);
$name = ($this->getDisplay('name') != '') ? $this->getDisplay('name') : $this->getName();
$replace = array(
Expand Down Expand Up @@ -1021,9 +1015,6 @@ public function toHtml($_version) {
}
$html = template_replace($replace, self::$_templateArray[$version]);
$html = translate::exec($html, 'core/template/widgets.html');
if (config::byKey('widget::disableCache', 'core', 0) == 0) {
cache::set('scenarioHtml' . $version . $this->getId(), $html);
}
return $html;
}
/**
Expand Down
Loading

0 comments on commit 7f26d1a

Please sign in to comment.