Added a function to dashboard groups checkboxes. Ticket#2598

This commit is contained in:
Arturo Gonzalez 2016-05-31 10:05:23 +02:00
parent 9bce86d1ac
commit a4da4bbc8d
1 changed files with 30 additions and 0 deletions

View File

@ -230,6 +230,36 @@ function groups_check_used($idGroup) {
return $return;
}
/**
* Return a array of id_group of childrens (to branches down)
*
* @param integer $parent The id_group parent to search the childrens.
* @param array $groups The groups, its for optimize the querys to DB.
*/
function groups_get_childrens_ids($parent, $groups = null) {
if (empty($groups)) {
$groups = db_get_all_rows_in_table('tgrupo');
}
$return = '';
foreach ($groups as $key => $group) {
if ($group['id_grupo'] == 0) {
continue;
}
if ($group['parent'] == $parent) {
$return .= $group['id_grupo'] . ",";
$propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group['id_grupo']);
if ($propagate) {
$return .= groups_get_childrens_ids($group['id_grupo']);
}
}
}
return $return;
}
/**
* Return a array of id_group of childrens (to branches down)
*