Added all users in global notifications config
Former-commit-id: d4bf0067f3ffe2e4fdef25158579716bdfd78d5d
This commit is contained in:
parent
50030b6933
commit
d2a3d3bbbc
|
@ -35,7 +35,8 @@ if (get_parameter('update_config', 0)) {
|
|||
$mail_value = (int)get_parameter("mail-{$id}", 0);
|
||||
$user_value = (int)get_parameter("user-{$id}", 0);
|
||||
$postpone_value = (int)get_parameter("postpone-{$id}", 0);
|
||||
$res = mysql_db_process_sql_update(
|
||||
$all_users = (int)get_parameter("all-{$id}", 0);
|
||||
$res = db_process_sql_update(
|
||||
'tnotification_source',
|
||||
array(
|
||||
'enabled' => $enable_value,
|
||||
|
@ -45,7 +46,10 @@ if (get_parameter('update_config', 0)) {
|
|||
),
|
||||
array('id' => $source['id'])
|
||||
);
|
||||
return $res && $carry;
|
||||
$all_users_res = $all_users
|
||||
? notifications_add_group_to_source($source['id'], array(0))
|
||||
: notifications_remove_group_from_source($source['id'], array(0));
|
||||
return $all_users_res && $res && $carry;
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,53 @@ function notifications_get_group_sources_for_select($source_id) {
|
|||
return index_array($groups, 'id_group', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a set of groups from notification source
|
||||
*
|
||||
* @param int Source id
|
||||
* @param array Id of groups to be deleted
|
||||
*
|
||||
* @return bool True if success. False otherwise.
|
||||
*/
|
||||
function notifications_remove_group_from_source ($source_id, $groups) {
|
||||
// Source id is mandatory
|
||||
if (!isset($source_id)) return false;
|
||||
|
||||
// Delete from database
|
||||
return db_process_sql_delete (
|
||||
'tnotification_source_group',
|
||||
array(
|
||||
'id_group' => $groups,
|
||||
'id_source' => $source_id
|
||||
)
|
||||
) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a set of groups to notification source
|
||||
*
|
||||
* @param int Source id
|
||||
* @param array Id of groups to be deleted
|
||||
*
|
||||
* @return bool True if success. False otherwise.
|
||||
*/
|
||||
function notifications_add_group_to_source ($source_id, $groups) {
|
||||
// Source id is mandatory
|
||||
if (!isset($source_id)) return false;
|
||||
|
||||
// Insert into database all groups passed
|
||||
$res = true;
|
||||
foreach ($groups as $group) {
|
||||
$res = db_process_sql_insert(
|
||||
'tnotification_source_group',
|
||||
array(
|
||||
'id_group' => $group,
|
||||
'id_source' => $source_id)
|
||||
) !== false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the notification ball to see unread messages
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue