diff --git a/lib/json_user_section.py b/lib/json_user_section.py index 4822b9766b48e46aed6f6bec4fb7bcec40ea4d57..f5b2599e8b4cefb78bedd4567a5706a788c57c7d 100644 --- a/lib/json_user_section.py +++ b/lib/json_user_section.py @@ -382,6 +382,9 @@ def write_users_section (json, \ json.write_tag("uid",user_attr,",") json.write_tag("nome",name,",") + accType=qry.user_acctype(json.database, guid) + json.write_tag("tipo_perfil",accType,",") + # Write a list of user friend's names #write_userfriends_subsection(json, guid) diff --git a/lib/opendata_queries_definition.py b/lib/opendata_queries_definition.py index 24ffd64f0819758835df7d964e68e78923b612d2..ef5771b5b4f5db4fb71270dbd54881fcacafeae0 100644 --- a/lib/opendata_queries_definition.py +++ b/lib/opendata_queries_definition.py @@ -34,6 +34,24 @@ qry_users_info = \ AND (e.access_id = 1 OR e.access_id = 2); ") #--------------------------------------------------------------------# +#--------------------------------------------------------------------# +# Argument: Post_ID / InfoType_ID +# Return: Essential information about the group or post, such as +# blog's excerpts and bookmark's link +qry_user_acctype = \ +(" SELECT \ + CASE \ + WHEN s.string = '1' THEN 'Ativista' \ + WHEN s.string = '2' THEN 'Pesquisador' \ + WHEN s.string = '3' THEN 'Usuario' \ + ELSE 'Desconhecido' \ + END \ + FROM elgg_metadata d, elgg_metastrings s \ + WHERE d.value_id = s.id \ + AND d.entity_guid = %s AND d.name_id = %s \ + AND (d.access_id = 1 OR d.access_id = 2); "); +#--------------------------------------------------------------------# + #--------------------------------------------------------------------# # Argument: Group_ID / InfoType_ID # Return: All InfoTypes' posts made by this group. @@ -160,7 +178,27 @@ qry_post_content = \ (" SELECT s.string\ FROM elgg_metadata d, elgg_metastrings s \ WHERE d.value_id = s.id \ - AND d.entity_guid = %s AND d.name_id = %s; ") + AND d.entity_guid = %s AND d.name_id = %s \ + AND (d.access_id = 1 OR d.access_id = 2); ") +#--------------------------------------------------------------------# + +#--------------------------------------------------------------------# +def user_acctype (db, user_guid): + + content = db.cursor() + + # 51477 = select * from elgg_metastrings where string='accType'; + content.execute(qry_user_acctype, (user_guid, 51477,)) + + if content.rowcount == 1: + user_acctype = content.fetchone()[0] + else: + user_acctype='' + print "ERRO! Nenhum ou Mais do que um resultado para a query" + + content.close() + + return user_acctype #--------------------------------------------------------------------# #--------------------------------------------------------------------# diff --git a/lib/xml_user_section.py b/lib/xml_user_section.py index 6d5c7ff1b2f7ddb3050328579d0a9487edf3e417..7eab36981cbe9b35f20fd2e3f4bf3e8bd53d47e4 100644 --- a/lib/xml_user_section.py +++ b/lib/xml_user_section.py @@ -315,6 +315,9 @@ def write_users_section (xml, \ # Write all user's information xml.write_tag("nome",name,'') + accType=qry.user_acctype(xml.database, guid) + xml.write_tag("tipo_perfil",accType,'') + # Write a list of user friend's names #write_userfriends_subsection(xml, guid)