'module_name', 'order' => 'ASC'); break; case 'down': $selectModuleNameDown = $selected; $order = array('field' => 'module_name', 'order' => 'DESC'); break; } break; case 'agent_name': switch ($sort) { case 'up': $selectAgentNameUp = $selected; $order = array('field' => 'agent_name', 'order' => 'ASC'); break; case 'down': $selectAgentNameDown = $selected; $order = array('field' => 'agent_name', 'order' => 'DESC'); break; } break; default: $selectModuleNameUp = $selected; $order = array('field' => 'module_name', 'order' => 'ASC'); break; } $modules = false; if ($searchModules) { $userGroups = users_get_groups($config['id_user'], 'AR', false); $id_userGroups = array_keys($userGroups); $tags = tags_get_user_tags(); $sql_tags = "'no_check_tags' = 'no_check_tags'"; if (!empty($tags)) { if ($is_admin) { $sql_tags = "1=1"; } else { $sql_tags = " ( t1.id_agente_modulo IN ( SELECT tt.id_agente_modulo FROM ttag_module AS tt WHERE id_tag IN (" . implode(",", array_keys($tags)) . ") ) OR t1.id_agente_modulo IN ( SELECT id_agente_modulo FROM ttag_module ) ) "; } } switch ($config["dbtype"]) { case "mysql": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ' . $sql_tags . ' AND (t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = "' . $config['id_user'] . '" AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND t1.nombre COLLATE utf8_general_ci LIKE "%' . $stringSearchSQL . '%" OR t3.nombre LIKE "%' . $stringSearchSQL . '%"'; break; case "postgresql": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ' . $sql_tags . ' AND (t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = \'' . $config['id_user'] . '\' AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND t1.nombre LIKE \'%' . $stringSearchSQL . '%\' OR t3.nombre LIKE \'%' . $stringSearchSQL . '%\''; break; case "oracle": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ' . $sql_tags . ' AND ' . $subquery_enterprise . ' (t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = \'' . $config['id_user'] . '\' AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND UPPER(t1.nombre) LIKE UPPER(\'%' . $stringSearchSQL . '%\') OR t3.nombre LIKE \'%' . $stringSearchSQL . '%\''; break; } $totalModules = db_get_value_sql(" SELECT COUNT(t1.id_agente_modulo) AS count_modules " . $chunk_sql); if (!$only_count) { $select = "SELECT *, t1.nombre AS module_name, t2.nombre AS agent_name "; $limit = " ORDER BY " . $order['field'] . " " . $order['order'] . " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $modules = db_get_all_rows_sql($select . $chunk_sql . $limit); } } ?>