Into the function 'tags_check_acl' fixed check for profile all with some tag. And added function 'tags_check_acl_by_module'

This commit is contained in:
mdtrooper 2014-10-20 16:40:20 +02:00
parent 7aa78eff25
commit 2471ca6375

View File

@ -507,7 +507,8 @@ function tags_get_module_tags ($id_agent_module) {
if (empty($id_agent_module)) if (empty($id_agent_module))
return false; return false;
$tags = db_get_all_rows_filter('ttag_module', array('id_agente_modulo' => $id_agent_module), false); $tags = db_get_all_rows_filter('ttag_module',
array('id_agente_modulo' => $id_agent_module), false);
if ($tags === false) if ($tags === false)
return array(); return array();
@ -635,7 +636,10 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) {
* @return mixed/string Tag ids * @return mixed/string Tag ids
*/ */
function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '') { function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
$return_mode = 'module_condition', $query_prefix = '',
$query_table = '') {
global $config; global $config;
if ($id_user == false) { if ($id_user == false) {
@ -989,6 +993,25 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
return $user_tags; return $user_tags;
} }
function tags_check_acl_by_module($id_module = 0, $id_user = false,
$access = 'AW') {
$return = false;
if (!empty($id_module)) {
$tags = tags_get_module_tags($id_module);
$group = modules_get_agent_group($id_module);
if ($id_user === false) {
$id_user = $config["id_user"];
}
$return = tags_check_acl($id_user, $group, $access, $tags);
}
return $return;
}
/** /**
* Check the ACLs with tags * Check the ACLs with tags
* *
@ -1009,7 +1032,8 @@ function tags_check_acl($id_user, $id_group, $access, $tags = array()) {
// Get parents to check in propagate ACL cases // Get parents to check in propagate ACL cases
if (!is_array($id_group) && $id_group != 0) { if (!is_array($id_group) && $id_group != 0) {
$id_group = array($id_group); $id_group = array($id_group);
$group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group)); $group = db_get_row_filter('tgrupo',
array('id_grupo' => $id_group));
$parents = groups_get_parents($group['parent'], true); $parents = groups_get_parents($group['parent'], true);
foreach ($parents as $parent) { foreach ($parents as $parent) {
@ -1034,7 +1058,19 @@ function tags_check_acl($id_user, $id_group, $access, $tags = array()) {
foreach ($id_group as $group) { foreach ($id_group as $group) {
if ($group > 0) { if ($group > 0) {
if(isset($acls[$group])) { if (array_key_exists(0, $acls)) {
//There is a All group
foreach ($tags as $tag) {
if (in_array($tag, $acls[0])) {
return true;
}
else {
return false;
}
}
}
else if (isset($acls[$group])) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tag = tags_get_id($tag); $tag = tags_get_id($tag);
@ -1046,7 +1082,8 @@ function tags_check_acl($id_user, $id_group, $access, $tags = array()) {
else { else {
return false; return false;
} }
} else { }
else {
foreach ($acls as $acl_tags) { foreach ($acls as $acl_tags) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tag = tags_get_id($tag); $tag = tags_get_id($tag);
@ -1057,7 +1094,8 @@ function tags_check_acl($id_user, $id_group, $access, $tags = array()) {
} }
} }
} }
} else { }
else {
if ($id_group > 0) { if ($id_group > 0) {
if (isset($acls[$id_group])) { if (isset($acls[$id_group])) {
foreach ($tags as $tag) { foreach ($tags as $tag) {