mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
wip supervisor
Former-commit-id: 991922a7dd18ace8fd831d02ada2cf20e81d27c2
This commit is contained in:
parent
27495845ba
commit
9ea3980b26
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Library. Notification system auxiliary functions.
|
* Library. Notification system auxiliary functions.
|
||||||
*
|
*
|
||||||
@ -46,7 +45,7 @@ function get_notification_source_id(string $source)
|
|||||||
return db_get_value_sql(
|
return db_get_value_sql(
|
||||||
"SELECT id
|
"SELECT id
|
||||||
FROM `tnotification_source`
|
FROM `tnotification_source`
|
||||||
WHERE `description` LIKE '{$source}%'"
|
WHERE `description` LIKE '".$source."%'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ function get_notification_source_id(string $source)
|
|||||||
/**
|
/**
|
||||||
* Converts description into a handable identifier
|
* Converts description into a handable identifier
|
||||||
*
|
*
|
||||||
* @param string $desc Full description
|
* @param string $desc Full description.
|
||||||
*
|
*
|
||||||
* @return string First word in lowercase. Empty string if no word detected.
|
* @return string First word in lowercase. Empty string if no word detected.
|
||||||
*/
|
*/
|
||||||
@ -163,6 +162,65 @@ function check_notification_readable(int $id_message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the target users and groups assigned to be notified on
|
||||||
|
* desired source.
|
||||||
|
*
|
||||||
|
* @param integer $id_source
|
||||||
|
*
|
||||||
|
* @return array [users] and [groups] with the targets.
|
||||||
|
*/
|
||||||
|
function get_notification_source_targets(int $id_source)
|
||||||
|
{
|
||||||
|
$ret = [];
|
||||||
|
|
||||||
|
$users = db_get_all_rows_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT
|
||||||
|
id_user,
|
||||||
|
IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail
|
||||||
|
FROM tnotification_source_user nsu
|
||||||
|
INNER JOIN tnotification_source ns
|
||||||
|
ON ns.id=nsu.id_source
|
||||||
|
WHERE ns.id = %d
|
||||||
|
AND ((ns.enabled is NULL OR ns.enabled != 0)
|
||||||
|
OR (nsu.enabled is NULL OR nsu.enabled != 0))',
|
||||||
|
$id_source
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($users !== false) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$ret['users'][$i]['id_user'] = $user['id_user'];
|
||||||
|
$ret['users'][$i++]['also_mail'] = $also_mail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups = db_get_all_rows_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT id_group,ns.also_mail
|
||||||
|
FROM tnotification_source_group nsg
|
||||||
|
INNER JOIN tnotification_source ns
|
||||||
|
ON ns.id=nsg.id_source
|
||||||
|
WHERE ns.id = %d
|
||||||
|
AND (ns.enabled is NULL OR ns.enabled != 0)',
|
||||||
|
$id_source
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($groups !== false) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ($groups as $group) {
|
||||||
|
$ret['groups'][$i]['id_group'] = $group['id_group'];
|
||||||
|
$ret['groups'][$i++]['also_mail'] = $group['also_mail'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all info from tnotification_source
|
* Return all info from tnotification_source
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user