Skip to content

Commit

Permalink
Merge pull request #2310 from jeedom/alpha
Browse files Browse the repository at this point in the history
report Alpha to Beta
  • Loading branch information
zoic21 committed Oct 5, 2023
2 parents 6e48769 + 7f91eab commit be24b45
Show file tree
Hide file tree
Showing 32 changed files with 542 additions and 184 deletions.
1 change: 1 addition & 0 deletions core/ajax/jeedom.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
$return['custom']['js'] = file_exists(__DIR__ . '/../../mobile/custom/custom.js');
$return['custom']['css'] = file_exists(__DIR__ . '/../../mobile/custom/custom.css');
}
$return['summary'] = jeeObject::getGlobalArraySummary();
ajax::success($return);
}

Expand Down
2 changes: 1 addition & 1 deletion core/ajax/plugin.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

$header = '< Ajoutez un titre puis rédigez votre question/problème ici, sans effacer les infos de config indiquées ci-dessous ><br/><br/><br/><br/>';
$header .= '--- <br/>**Mes infos de config** : <br/>```<br/>';
$footer .= '<br/>```<br/>';
$footer = '<br/>```<br/>';

$infoPost = plugin::getConfigForCommunity();

Expand Down
40 changes: 37 additions & 3 deletions core/class/cmd.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ public static function allHistoryCmd() {
return array_merge($result1, $result2);
}

/**
*
* @param int|array<int> $_eqLogic_id
* @param string $_type ['action'|'info']
* @param bool $_visible
* @param eqLogic $_eqLogic
* @param bool $_has_generic_type
* @return array<cmd>
*/
public static function byEqLogicId($_eqLogic_id, $_type = null, $_visible = null, $_eqLogic = null, $_has_generic_type = null) {
$values = array();
if (is_array($_eqLogic_id)) {
Expand Down Expand Up @@ -196,6 +205,12 @@ public static function byEqLogicId($_eqLogic_id, $_type = null, $_visible = null
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__), $_eqLogic);
}

/**
*
* @param string $_logical_id
* @param string $_type ['action'|'info']
* @return array<cmd>
*/
public static function byLogicalId($_logical_id, $_type = null) {
$values = array(
'logicalId' => $_logical_id,
Expand All @@ -211,6 +226,13 @@ public static function byLogicalId($_logical_id, $_type = null) {
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

/**
*
* @param string|array<string> $_generic_type
* @param int $_eqLogic_id
* @param boolean $_one
* @return cmd|array<cmd> first cmd if $_one is true otherwise an array of all cmd
*/
public static function byGenericType($_generic_type, $_eqLogic_id = null, $_one = false) {
if (is_array($_generic_type)) {
$in = '';
Expand Down Expand Up @@ -240,6 +262,12 @@ public static function byGenericType($_generic_type, $_eqLogic_id = null, $_one
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

/**
* Search a command on eqType, logicalId, generic_type or name
*
* @param string $_search the needle
* @return array<cmd>
*/
public static function searchByString($_search) {
$values = array(
'search' => '%' . $_search . '%'
Expand All @@ -250,6 +278,12 @@ public static function searchByString($_search) {
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

/**
*
* @param string|array<string> $_configuration
* @param string $_eqType
* @return array<cmd>
*/
public static function searchConfiguration($_configuration, $_eqType = null) {
if (!is_array($_configuration)) {
$values = array(
Expand Down Expand Up @@ -1630,9 +1664,9 @@ public function toHtml($_version = 'dashboard', $_options = '') {
$listOption .= '<option value="' . $coupleArray[0] . '">' . $coupleArray[1] . '</option>';
}
} else {
if(isset($coupleArray[1])){
if (isset($coupleArray[1])) {
$listOption .= '<option value="' . $coupleArray[0] . '">' . $coupleArray[1] . '</option>';
}else{
} else {
$listOption .= '<option value="' . $coupleArray[0] . '">' . $coupleArray[0] . '</option>';
}
}
Expand Down Expand Up @@ -2902,7 +2936,7 @@ public function setId($_id = '') {

/**
*
* @param string $name
* @param string $_name
* @return $this
*/
public function setName($_name) {
Expand Down
67 changes: 67 additions & 0 deletions core/class/eqLogic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1659,52 +1659,100 @@ public function getUsage() {

/* * **********************Getteur Setteur*************************** */

/**
*
* @return int
*/
public function getId() {
return $this->id;
}

/**
*
* @return string
*/
public function getName() {
return $this->name;
}

/**
*
* @return string
*/
public function getLogicalId() {
return $this->logicalId;
}

/**
*
* @return int
*/
public function getObject_id() {
return $this->object_id;
}

/**
*
* @return jeeObject
*/
public function getObject() {
if ($this->_object === null) {
$this->setObject(jeeObject::byId($this->object_id));
}
return $this->_object;
}

/**
*
* @param jeeObject $_object
* @return $this
*/
public function setObject($_object) {
$this->_object = $_object;
return $this;
}

/**
*
* @return string
*/
public function getEqType_name() {
return $this->eqType_name;
}

/**
*
* @param integer $_default
* @return int
*/
public function getIsVisible($_default = 0) {
if ($this->isVisible == '' || !is_numeric($this->isVisible)) {
return $_default;
}
return $this->isVisible;
}

/**
*
* @param integer $_default
* @return int
*/
public function getIsEnable($_default = 0) {
if ($this->isEnable == '' || !is_numeric($this->isEnable)) {
return $_default;
}
return $this->isEnable;
}

/**
* get one or multiple cmd of the eqLogic
*
* @param string $_type ['action'|'info']
* @param string $_logicalId
* @param boolean $_visible
* @param boolean $_multiple
* @return cmd|cmd[]
*/
public function getCmd($_type = null, $_logicalId = null, $_visible = null, $_multiple = false) {
if ($_logicalId !== null) {
if (isset($this->_cmds[$_logicalId . '.' . $_multiple . '.' . $_type])) {
Expand All @@ -1727,6 +1775,15 @@ public function getCmd($_type = null, $_logicalId = null, $_visible = null, $_mu
return $cmds;
}

/**
* get one or multiple cmd of the eqLogic
*
* @param string $_type ['action'|'info']
* @param string $_generic_type
* @param boolean $_visible
* @param boolean $_multiple
* @return cmd|cmd[]
*/
public function getCmdByGenericType($_type = null, $_generic_type = null, $_visible = null, $_multiple = false) {
if ($_generic_type !== null) {
if (isset($this->_cmds[$_generic_type . '.' . $_multiple . '.' . $_type])) {
Expand All @@ -1749,6 +1806,12 @@ public function getCmdByGenericType($_type = null, $_generic_type = null, $_visi
return $cmds;
}

/**
*
* @param string $_configuration
* @param string $_type ['action'|'info']
* @return cmd[]
*/
public function searchCmdByConfiguration($_configuration, $_type = null) {
return cmd::searchConfigurationEqLogic($this->id, $_configuration, $_type);
}
Expand Down Expand Up @@ -1917,6 +1980,10 @@ public function setDebug($_debug) {
$this->_debug = $_debug;
}

/**
*
* @return int
*/
public function getOrder() {
if ($this->order == '' || !is_numeric($this->order)) {
return 0;
Expand Down
75 changes: 75 additions & 0 deletions core/class/jeeObject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,81 @@ public static function getGlobalHtmlSummary($_version = 'dashboard') {
return $return;
}

public static function getGlobalArraySummary($_version = 'dashboard') {
$objects = self::all();
$def = config::byKey('object:summary');
$values = array();
$return = array();
foreach ($def as $key => $value) {
foreach ($objects as $object) {
if ($object->getConfiguration('summary::global::' . $key, 0) == 0) {
continue;
}
if (!isset($values[$key])) {
$values[$key] = array();
}
$result = $object->getSummary($key, true);
if ($result === null || !is_array($result)) {
continue;
}
$values[$key] = array_merge($values[$key], $result);
}
}
foreach ($values as $key => $value) {
if (count($value) == 0) {
continue;
}
$allowDisplayZero = $def[$key]['allowDisplayZero'];
if ($def[$key]['calcul'] == 'text') {
$result = trim(implode(',', $value), ',');
$allowDisplayZero = 1;
} else {
$result = jeedom::calculStat($def[$key]['calcul'], $value);
}
if (!isset($def[$key]['hidenumber'])) {
$def[$key]['hidenumber'] = 0;
}
if (!isset($def[$key]['hidenulnumber'])) {
$def[$key]['hidenulnumber'] = 0;
}

$return[$key]['icon'] = array();
if (isset($def[$key]['icon']) && $def[$key]['icon'] != '') {
$def[$key]['icon'] = substr(substr($def[$key]['icon'], 10), 0, -6);
$def[$key]['icon'] = str_replace(array(' fab', ' fas'), '', $def[$key]['icon']);
$arrayIcon = explode(' ', $def[$key]['icon']);
$iconName = substr(strstr($arrayIcon[1], '-'), 1);
$libName = strstr($arrayIcon[1], '-', true);
$iconColor = (isset($arrayIcon[2])) ? substr(strstr($arrayIcon[2], '_'), 1) : '';
if ($libName == 'mdi') $libName = 'Mdi';
$return[$key]['icon']['type'] = $libName;
$return[$key]['icon']['name'] = $iconName;
$return[$key]['icon']['color'] = $iconColor;
}

$return[$key]['iconnul'] = array();
if (isset($def[$key]['iconnul']) && $def[$key]['iconnul'] != '') {
$def[$key]['iconnul'] = substr(substr($def[$key]['iconnul'], 10), 0, -6);
$def[$key]['iconnul'] = str_replace(array(' fab', ' fas', 'far'), '', $def[$key]['iconnul']);
$arrayIcon = explode(' ', $def[$key]['iconnul']);
$iconName = substr(strstr($arrayIcon[1], '-'), 1);
$libName = strstr($arrayIcon[1], '-', true);
$iconColor = (isset($arrayIcon[2])) ? substr(strstr($arrayIcon[2], '_'), 1) : '';
if ($libName == 'mdi') $libName = 'Mdi';
$return[$key]['iconnul']['type'] = $libName;
$return[$key]['iconnul']['name'] = $iconName;
$return[$key]['iconnul']['color'] = $iconColor;
}
else $return[$key]['iconnul'] = $return[$key]['icon'];

$return[$key]['displayzerovalue'] = $allowDisplayZero;
$return[$key]['hidenulnumber'] = $def[$key]['hidenulnumber'];
$return[$key]['value'] = $result;
$return[$key]['unit'] = $def[$key]['unit'];
}
return $return;
}

public static function createSummaryToVirtual($_key = '') {
if ($_key == '') {
return;
Expand Down
25 changes: 25 additions & 0 deletions core/class/listener.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public static function byClass($_class) {
return DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}

/**
*
* @param string $_class
* @param string $_function
* @param array $_option
* @return listener
*/
public static function byClassAndFunction($_class, $_function, $_option = '') {
$value = array(
'class' => $_class,
Expand All @@ -99,6 +106,13 @@ public static function byClassAndFunction($_class, $_function, $_option = '') {
return DB::Prepare($sql, $value, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
}

/**
*
* @param string $_class
* @param string $_function
* @param array $_option
* @return array<listener>
*/
public static function searchClassFunctionOption($_class, $_function, $_option = '') {
$value = array(
'class' => $_class,
Expand All @@ -113,6 +127,13 @@ public static function searchClassFunctionOption($_class, $_function, $_option =
return DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}

/**
*
* @param string $_class
* @param string $_function
* @param string $_event
* @return array<listener>
*/
public static function byClassFunctionAndEvent($_class, $_function, $_event) {
$value = array(
'class' => $_class,
Expand Down Expand Up @@ -277,6 +298,10 @@ public function addEvent($_id, $_type = 'cmd') {

/* * **********************Getteur Setteur*************************** */

/**
*
* @return int
*/
public function getId() {
return $this->id;
}
Expand Down
2 changes: 1 addition & 1 deletion core/class/log.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function getLogger($_log) {
$handler = new SyslogHandler(self::getLogLevel($_log));
break;
case 'SyslogUdp':
$handler = new SyslogUdpHandler(config::byKey('log::syslogudphost'), config::byKey('log::syslogudpport'), 'user', self::getLogLevel($_log));
$handler = new SyslogUdpHandler(config::byKey('log::syslogudphost'), config::byKey('log::syslogudpport'), config::byKey('log::syslogudpfacility'), self::getLogLevel($_log),true,'jeedom');
break;
case 'StreamHandler':
default:
Expand Down
Loading

0 comments on commit be24b45

Please sign in to comment.