indexing description: "Provide an interface to user data." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class USER_INTERFACE inherit BASE_INTERFACE redefine make end O_CONFIG_CONSTANTS O_USER_CONSTANTS create make feature {NONE} -- Initialization make (a_node: like node; a_db_handler: like db_handler; a_policy_cache: like policy_cache) is -- Initialize. do Precursor(a_node, a_db_handler, a_policy_cache) -- purge all sessions as they are not valid anymore user_access.purge_sessions end feature -- Commands user_create (a_msg: O_MESSAGE) is -- Create a new user according to a_msg. require a_msg_ok: a_msg /= Void local l_uc_msg: O_USER_CREATE_MESSAGE l_user: USER l_assoc: USER_ASSOCIATION l_status: O_GENERAL_STATUS_MESSAGE do l_uc_msg ?= a_msg check user_create_message: l_uc_msg /= Void end create l_user.make l_user.set_name (l_uc_msg.name) l_user.set_pass (l_uc_msg.password) l_user.set_email (l_uc_msg.email) -- check if the user already exists (this includes the disabled users as well) user_access.retrieve_user_by_name (l_user.name, True) if user_access.is_found then create l_status.make (False, err_user_name_already_used) else user_access.insert_user (l_user) -- we need the user to get the id, to add an according user_association user_access.retrieve_user_by_name (l_user.name, False) check found: user_access.is_found end create l_assoc.make l_assoc.set_group_id (2) l_assoc.set_user_id (user_access.last_user.user_id) user_access.insert_user_association (l_assoc) -- insert user_id and registration_date in user_information table user_access.insert_user_information (user_access.last_user.user_id) create l_status.make (True, Void) end node.send_message_reply (l_status, a_msg) end user_login (a_msg: O_MESSAGE) is -- Try to login a user according to a_msg. require a_msg_ok: a_msg /= Void local l_ul_msg: O_USER_LOGIN_MESSAGE l_ses_msg: O_USER_SESSION_MESSAGE l_user: USER l_session: SESSION l_status: O_GENERAL_STATUS_MESSAGE do l_ul_msg ?= a_msg check user_login_message: l_ul_msg /= Void end user_access.retrieve_user_by_name (l_ul_msg.name, False) -- did we find the user? if not user_access.is_found then create l_status.make (False, err_user_password_invalid) node.send_message_reply (l_status, a_msg) else l_user := user_access.last_user -- password correct? if not l_user.pass.is_equal (l_ul_msg.password) then create l_status.make (False, err_user_password_invalid) node.send_message_reply (l_status, a_msg) else -- also retrieve the user and team associations and add them to the cache policy_cache.retrieve_associations (l_user.user_id) create l_session.make l_session.set_user_id (l_user.user_id) user_access.insert_session (l_session) user_access.update_user_last_login (l_user.user_id) create l_ses_msg.make (l_session.session_id) node.send_message_reply (l_ses_msg, a_msg) end end end user_login_authenticated (a_msg: O_MESSAGE) is -- Try to login a user according to a_msg. require a_msg_ok: a_msg /= Void local l_ul_msg: O_USER_LOGIN_AUTHENTICATED_MESSAGE l_ses_msg: O_USER_SESSION_MESSAGE l_user: USER l_session: SESSION l_status: O_GENERAL_STATUS_MESSAGE do l_ul_msg ?= a_msg check user_login_message: l_ul_msg /= Void end user_access.retrieve_user_by_name (l_ul_msg.name, False) -- did we find the user? if not user_access.is_found then create l_status.make (False, err_user_password_invalid) node.send_message_reply (l_status, a_msg) else l_user := user_access.last_user -- also retrieve the user and team associations and add them to the cache policy_cache.retrieve_associations (l_user.user_id) create l_session.make l_session.set_user_id (l_user.user_id) user_access.insert_session (l_session) user_access.update_user_last_login (l_user.user_id) create l_ses_msg.make (l_session.session_id) node.send_message_reply (l_ses_msg, a_msg) end end user_login_key (a_msg: O_MESSAGE) is -- Try to login a user with a key according to a_msg. require a_msg_ok: a_msg /= Void local l_ul_msg: O_USER_LOGIN_KEY_MESSAGE l_ses_msg: O_USER_SESSION_MESSAGE l_user: USER l_session: SESSION l_status: O_GENERAL_STATUS_MESSAGE do l_ul_msg ?= a_msg check user_login_key_message: l_ul_msg /= Void end user_access.retrieve_user_by_key (l_ul_msg.user_key) -- did we find the user? if not user_access.is_found then create l_status.make (False, err_invalid_user_key) node.send_message_reply (l_status, a_msg) else l_user := user_access.last_user -- did we find the application? if user_access.retrieve_application_by_key (l_ul_msg.app_key) = Void then create l_status.make (False, err_application_invalid) node.send_message_reply (l_status, a_msg) else -- also retrieve the user and team associations and add them to the cache policy_cache.retrieve_associations (l_user.user_id) create l_session.make l_session.set_user_id (l_user.user_id) user_access.insert_session (l_session) user_access.update_user_last_login (l_user.user_id) user_access.increase_application_login_count(l_ul_msg.app_key) create l_ses_msg.make (l_session.session_id) node.send_message_reply (l_ses_msg, a_msg) end end end user_authorized_for_project (a_msg: O_MESSAGE) is -- Check authorization of a session against an instruction for a project. require a_msg_ok: a_msg /= Void local l_auth_msg: O_USER_AUTHORIZED_FOR_PROJECT_MESSAGE l_session: SESSION l_policy: LINKED_SET [INTEGER] l_group, l_project_group: LINKED_SET [INTEGER] l_allowed, l_reply_sent: BOOLEAN l_status: O_GENERAL_STATUS_MESSAGE l_user_id: INTEGER do l_auth_msg ?= a_msg check authorized_message: l_auth_msg /= Void end -- check if the session is still valid and retrieve the user user_access.retrieve_session_by_id (l_auth_msg.session) if not user_access.is_found and not (l_auth_msg.session.is_empty or l_auth_msg.session.is_equal({O_CONSTANTS}.anonymous_user_session)) then -- session timeout/invalid create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) l_reply_sent := True elseif not user_access.is_found then -- anonymous user l_user_id := 0 create l_group.make l_group.put (8) else l_session := user_access.last_session user_access.update_session (l_session) l_user_id := l_session.user_id end if not l_reply_sent then l_allowed := False -- check if the user is authorized for the instruction l_policy := policy_cache.policies.item (l_auth_msg.instruction) -- only if we have a policy we can be allowed if l_policy /= Void then if user_access.is_found then l_group := policy_cache.user_associations.item (l_user_id) end -- are we in one group that is allowed from the policy? from l_group.start until l_allowed or l_group.after loop l_allowed := l_policy.has (l_group.item) l_group.forth end -- if we have a project and aren't yet allowed, check those if l_auth_msg.project > 0 and l_session /= Void then l_project_group := policy_cache.user_project_associations.item (l_session.user_id).item (l_auth_msg.project) if l_project_group /= Void then from l_project_group.start until l_allowed or l_project_group.after loop l_allowed := l_policy.has (l_project_group.item) l_project_group.forth end end end end -- return allowed/denied if l_allowed then create l_status.make (True, "") else create l_status.make (False, err_access_denied) end node.send_message_reply (l_status, a_msg) end end user_authorized_for_community (a_msg: O_MESSAGE) is -- Check authorization of a session against an instruction for a community. require a_msg_ok: a_msg /= Void local l_auth_msg: O_USER_AUTHORIZED_FOR_COMMUNITY_MESSAGE l_session: SESSION l_policy: LINKED_SET [INTEGER] l_group, l_community_group: LINKED_SET [INTEGER] l_allowed, l_reply_sent: BOOLEAN l_status: O_GENERAL_STATUS_MESSAGE l_community_id, l_user_id: INTEGER do l_auth_msg ?= a_msg check authorized_message: l_auth_msg /= Void end -- check if the session is still valid and retrieve the user user_access.retrieve_session_by_id (l_auth_msg.session) if not user_access.is_found and not (l_auth_msg.session.is_empty or l_auth_msg.session.is_equal({O_CONSTANTS}.anonymous_user_session)) then -- session timeout/invalid create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) l_reply_sent := True elseif not user_access.is_found then -- anonymous user l_user_id := 0 create l_group.make l_group.put (8) else l_session := user_access.last_session user_access.update_session (l_session) l_user_id := l_session.user_id end if not l_reply_sent then l_allowed := False -- check if the user is authorized for the instruction l_policy := policy_cache.policies.item (l_auth_msg.instruction) -- only if we have a policy we can be allowed if l_policy /= Void then if user_access.is_found then l_group := policy_cache.user_associations.item (l_user_id) end -- are we in one group that is allowed from the policy? check l_group_set: l_group /= Void end from l_group.start until l_allowed or l_group.after loop l_allowed := l_policy.has (l_group.item) l_group.forth end -- if we have a community and aren't yet allowed, check those if not l_auth_msg.community_name.is_empty and l_session /= Void then community_access.retrieve_community_by_name (l_auth_msg.community_name) if community_access.is_found then l_community_id := community_access.last_community.community_id l_community_group := policy_cache.user_community_associations.item (l_session.user_id).item (l_community_id) if l_community_group /= Void then from l_community_group.start until l_allowed or l_community_group.after loop l_allowed := l_policy.has (l_community_group.item) l_community_group.forth end end else create l_status.make (False, err_invalid_community) node.send_message_reply (l_status, a_msg) end end end -- return allowed/denied if l_allowed then create l_status.make (True, "") else create l_status.make (False, err_access_denied) end node.send_message_reply (l_status, a_msg) end end user_change_email (a_msg: O_MESSAGE) is -- Change email address of a user require a_msg_ok: a_msg /= Void local l_msg: O_USER_CHANGE_EMAIL_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_email: STRING l_session: SESSION l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end l_email := l_msg.email_address -- session valid? user_access.retrieve_session_by_id (l_msg.session) if user_access.is_found then l_session := user_access.last_session user_access.retrieve_user_by_id (l_session.user_id) if user_access.is_found then l_user := user_access.last_user user_access.update_user_email (l_user.user_id, l_email) create l_status.make (True, "") else create l_status.make (False, err_invalid_user) end else create l_status.make (False, err_session_timeout) end -- send status node.send_message_reply (l_status, a_msg) end user_change_account_enabled (a_msg: O_USER_CHANGE_ACCOUNT_ENABLED_MESSAGE) is -- if `enabled' is set to false, will call disable account. -- otherwise we just set the enabled flag to true. require a_msg_ok: a_msg /= Void local l_msg: O_USER_CHANGE_ACCOUNT_ENABLED_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.name, True) if user_access.is_found then l_user := user_access.last_user if l_msg.enabled.item = True then -- enable account user_access.enable_account (l_user.user_id) else -- disable account disable_account (l_user) end create l_status.make (True, Void) node.send_message_reply (l_status, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_change_password (a_msg: O_MESSAGE) is -- Change password of a user require a_msg_ok: a_msg /= Void local l_msg: O_USER_CHANGE_PASSWORD_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_password: STRING l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end l_password := l_msg.password -- session valid? user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then l_user := user_access.last_user user_access.update_user_password (l_user.user_id, l_password) create l_status.make (True, "") else create l_status.make (False, err_invalid_user) end -- send status node.send_message_reply (l_status, a_msg) end user_reset_password (a_msg: O_MESSAGE) is -- Reset password of a user require a_msg_ok: a_msg /= Void local l_msg: O_USER_RESET_PASSWORD_MESSAGE l_reply: O_USER_RESET_PASSWORD_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_password: STRING l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end l_password := token_generator.generate_id.substring (1, 15) user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then l_user := user_access.last_user user_access.update_user_password (l_user.user_id, l_password) create l_reply.make (l_password, l_user.email) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_my_name (a_msg: O_MESSAGE) is -- Returns username of user require a_msg_ok: a_msg /= Void local l_msg: O_USER_MY_NAME_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check user_my_name_message: l_msg /= Void end -- check session user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then create l_reply.make (user_access.retrieve_my_name(l_msg.session)) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_my_password (a_msg: O_MESSAGE) is -- Returns password of user require a_msg_ok: a_msg /= Void local l_msg: O_USER_MY_PASSWORD_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check user_my_name_message: l_msg /= Void end -- check session user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then create l_reply.make (user_access.retrieve_my_password(l_msg.session)) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_my_email (a_msg: O_MESSAGE) is -- Returns email address of user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_MY_EMAIL_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end -- check session user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then create l_reply.make (user_access.retrieve_my_email (l_msg.session)) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_retrieve_password (a_msg: O_MESSAGE) is -- Returns password of user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_PASSWORD_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end -- check session user_access.retrieve_user_by_name (l_msg.name, True) if user_access.is_found then create l_reply.make (user_access.last_user.pass) node.send_message_reply (l_reply, a_msg) else create l_status.make (False,err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_retrieve_email (a_msg: O_MESSAGE) is -- Returns email address of user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_EMAIL_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end -- check session user_access.retrieve_user_by_name (l_msg.name, True) if user_access.is_found then create l_reply.make (user_access.last_user.email) node.send_message_reply (l_reply, a_msg) else create l_status.make (False,err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_retrieve_user_from_email (a_msg: O_MESSAGE) is -- Returns user from email address of user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_USER_FROM_EMAIL_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end -- check session user_access.retrieve_user_by_email (l_msg.email, False) if user_access.is_found then create l_reply.make (user_access.last_user.name) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_email) node.send_message_reply (l_status, a_msg) end end user_profile_visible (a_msg: O_MESSAGE) is -- Returns the profile visibility. require a_msg_ok: a_msg /= Void local l_msg: O_USER_PROFILE_VISIBLE_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then -- user found l_user := user_access.last_user create l_reply.make (user_access.retrieve_profile_visible (l_user.user_id).out) node.send_message_reply (l_reply, a_msg) else -- user not found or disabled create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_change_profile_visible (a_msg: O_MESSAGE) is -- Set profile visibility require a_msg_ok: a_msg /= Void local l_message: O_USER_CHANGE_PROFILE_VISIBLE_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER do l_message ?= a_msg check valid_message: l_message /= Void valid_value: l_message.value >= 0 end -- check session user_access.retrieve_user_by_session (l_message.session) if user_access.is_found then l_user_ret := user_access.last_user user_access.update_profile_visible (l_user_ret.user_id, l_message.value) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_retrieve_openids_from_user (a_msg: O_MESSAGE) is -- retrieve openids from a user name. require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_OPENIDS_FROM_USER_MESSAGE l_reply: O_USER_STRINGARRAY_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_openids: ARRAY [STRING] l_user: USER l_visible: BOOLEAN do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then l_user := user_access.last_user -- check if the user from the session is the same as a_msg.name l_visible := True user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found and then user_access.last_user.name.is_equal (l_user.name) then l_visible := False end -- retrieve the openids user_access.retrieve_openids_from_user (l_user.user_id, l_visible) l_openids := user_access.last_openids create l_reply.make (l_openids) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_retrieve_user_from_openid (a_msg: O_MESSAGE) is -- retrieve user from openid (internal). require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_USER_FROM_OPENID_MESSAGE l_reply: O_GENERAL_STRING_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: STRING do l_msg ?= a_msg check valid_message: l_msg /= Void end l_user := user_access.retrieve_user_from_openid (l_msg.openid) if l_user /= Void and then not l_user.is_empty then -- a user has been found create l_reply.make (l_user) node.send_message_reply (l_reply, a_msg) else -- user not found create l_status.make (False, err_invalid_openid) node.send_message_reply (l_status, a_msg) end end user_remove_openid (a_msg: O_MESSAGE) is -- Remove openid require a_msg_ok: a_msg /= Void local l_msg: O_USER_REMOVE_OPENID_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER l_username: STRING do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user l_username := user_access.retrieve_user_from_openid (l_msg.openid) if l_user.name.is_equal (l_username) then user_access.delete_openid (l_msg.openid, l_user.user_id) create l_status.make (True, Void) else -- the session does not match the openid create l_status.make (False, err_access_denied) end else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_change_openid (a_msg: O_MESSAGE) is -- Remove openid require a_msg_ok: a_msg /= Void local l_msg: O_USER_CHANGE_OPENID_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user user_access.update_openid (l_msg.openid, l_user.user_id, l_msg.visible.item) create l_status.make (True, Void) else create l_status.make (False, err_invalid_session) end node.send_message_reply (l_status, a_msg) end user_remove_foaf (a_msg: O_MESSAGE) is -- Remove foaf require a_msg_ok: a_msg /= Void local l_msg: O_USER_REMOVE_FOAF_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user user_access.delete_foaf (l_msg.foaf, l_user.user_id) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_add_foaf (a_msg: O_MESSAGE) is -- Add foaf require a_msg_ok: a_msg /= Void local l_msg: O_USER_ADD_FOAF_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user user_access.insert_foaf (l_msg.foaf, l_user.user_id) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_add_openid (a_msg: O_MESSAGE) is -- add openid (internal). require a_msg_ok: a_msg /= Void local l_msg: O_USER_ADD_OPENID_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then l_user := user_access.last_user -- add openid to DB user_access.insert_openid (l_user.user_id,l_msg.openid) create l_status.make (True, Void) node.send_message_reply (l_status, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_retrieve_foaf (a_msg: O_MESSAGE) is -- retrieve foaf. require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_FOAF_MESSAGE l_reply: O_USER_STRINGARRAY_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_foaf: ARRAY [STRING] l_user: USER l_visible: BOOLEAN l_export: INTEGER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.name, False) if user_access.is_found then l_user := user_access.last_user -- check if the user wants his FOAF exported or if session fits to the user user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found and then user_access.last_user.name.is_equal (l_user.name) then l_visible := True else -- users don't match, does the user export his foaf? l_export := user_access.retrieve_profile_visible (l_user.user_id) if l_export.bit_shift_right (1).bit_and (1) = 1 then l_visible := True end end if l_visible then -- retrieve the foafs create l_reply.make (user_access.retrieve_foaf (l_user.user_id)) node.send_message_reply (l_reply, a_msg) else create l_foaf.make (0, -1) create l_reply.make (l_foaf) node.send_message_reply (l_reply, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_retrieve_information (a_msg: O_MESSAGE) is -- Retrieve information about a user require a_msg_ok: a_msg /= Void local l_msg: O_USER_RETRIEVE_INFORMATION_MESSAGE l_reply: O_USER_RETRIEVE_INFORMATION_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_information: DS_HASH_TABLE[ANY, STRING] do l_msg ?= a_msg check valid_message: l_msg /= Void end --check user to retrieve information for user_access.retrieve_user_by_name (l_msg.user_name, False) if user_access.is_found then -- get its user ID and gather information user_access.retrieve_user_information_by_id (user_access.last_user.user_id) if user_access.is_found then create l_user_information.make (10) l_user_information.force (user_access.last_user_information.first_name, "first_name") l_user_information.force (user_access.last_user_information.last_name, "last_name") l_user_information.force (user_access.last_user_information.gender, "gender") l_user_information.force (user_access.last_user_information.icon, "icon") l_user_information.force (user_access.last_user_information.languages, "languages") l_user_information.force (user_access.last_user_information.registration_date.out, "registration_date") l_user_information.force (user_access.last_user_information.birthday, "birthday") l_user_information.force (user_access.last_user_information.timezone, "timezone") l_user_information.force (user_access.last_user_information.signature, "signature") l_user_information.force (user_access.last_user_information.message, "message") l_user_information.force (user_access.last_user_information.homepage, "homepage") l_user_information.force (user_access.last_user_information.blog, "blog") l_user_information.force (user_access.last_user_information.ohloh_profile, "ohloh_profile") l_user_information.force (user_access.last_user_information.icq, "icq") l_user_information.force (user_access.last_user_information.aim, "aim") l_user_information.force (user_access.last_user_information.jabber, "jabber") l_user_information.force (user_access.last_user_information.yahoo, "yahoo") l_user_information.force (user_access.last_user_information.msn, "msn") l_user_information.force (user_access.last_user_information.skype, "skype") l_user_information.force (user_access.last_user_information.sip, "sip") create l_reply.make (l_msg.user_name, l_user_information) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_set_information (a_msg: O_MESSAGE) is -- Set user information require a_msg_ok: a_msg /= Void local l_pc_msg: O_USER_SET_INFORMATION_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER l_information_type: STRING l_information_value: STRING do l_pc_msg ?= a_msg check valid_message: l_pc_msg /= Void end user_access.retrieve_user_by_session (l_pc_msg.session) if user_access.is_found then l_user_ret := user_access.last_user from l_pc_msg.informations.start until l_pc_msg.informations.after loop l_information_type := l_pc_msg.informations.item.information_type l_information_value := l_pc_msg.informations.item.information_value user_access.update_user_information (l_user_ret.user_id, l_information_type, l_information_value) l_pc_msg.informations.forth end create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_set_icon (a_msg: O_MESSAGE) is -- Set user icon require a_msg_ok: a_msg /= Void local l_pc_message: O_USER_SET_ICON_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER do l_pc_message ?= a_msg check valid_message: l_pc_message /= Void valid_icon: l_pc_message.icon /= Void and then not l_pc_message.icon.is_empty end -- check session user_access.retrieve_user_by_session (l_pc_message.session) if user_access.is_found then l_user_ret := user_access.last_user user_access.update_user_icon (l_user_ret.user_id, l_pc_message.icon) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_reset_icon (a_msg: O_MESSAGE) is -- Reset user icon require a_msg_ok: a_msg /= Void local l_pc_message: O_USER_RESET_ICON_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER do l_pc_message ?= a_msg check valid_message: l_pc_message /= Void end -- check session user_access.retrieve_user_by_session (l_pc_message.session) if user_access.is_found then l_user_ret := user_access.last_user user_access.update_user_icon (l_user_ret.user_id, l_pc_message.icon) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_list_reported_issues (a_msg: O_MESSAGE) is -- List reported issues for a specific user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_LIST_REPORTED_ISSUES_MESSAGE l_reply: O_USER_LIST_REPORTED_ISSUES_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER l_issues: DS_HASH_TABLE [TUPLE [issue_id: INTEGER; project_name: STRING; creation_time: INTEGER; title: STRING; tags: STRING], INTEGER] do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then user_access.retrieve_user_by_name (l_msg.username, False) if user_access.is_found then l_user := user_access.last_user -- retrieve issues l_issues := issue_access.retrieve_user_issues (l_user.user_id) create l_reply.make(l_issues) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_request_friendship (a_msg: O_MESSAGE) is -- Add friendship request in USER_FRIENDSHIP_REQUEST and return information of requester. require a_msg_ok: a_msg /= Void local l_msg: O_USER_REQUEST_FRIENDSHIP_MESSAGE l_reply: O_USER_REQUEST_FRIENDSHIP_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_requester: USER l_requestee: USER l_requester_information: USER_INFORMATION l_requester_fullname: STRING found_friendship_request: BOOLEAN found_reversed_friendship_request: BOOLEAN found_friendship: BOOLEAN do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_requester := user_access.last_user user_access.retrieve_user_by_name (l_msg.requestee, False) if user_access.is_found then l_requestee := user_access.last_user -- only add request if request does not already exists -- and request where requester and requestee are reversed does not exist -- and requester /= requestee -- and friendship not already exists user_access.retrieve_friendship_request (l_requester.user_id, l_requestee.user_id) found_friendship_request := user_access.is_found user_access.retrieve_friendship_request (l_requestee.user_id, l_requester.user_id) found_reversed_friendship_request := user_access.is_found user_access.retrieve_friendship (l_requester.user_id, l_requestee.user_id) found_friendship := user_access.is_found if not found_friendship and not found_friendship_request and not found_reversed_friendship_request and l_requester.user_id /= l_requestee.user_id then user_access.insert_friendship_request (l_requester.user_id, l_requestee.user_id) -- generate and send reply l_requester_fullname := "" user_access.retrieve_user_information_by_id (l_requester.user_id) if user_access.is_found then l_requester_information := user_access.last_user_information if not l_requester_information.first_name.is_empty and not l_requester_information.last_name.is_empty then l_requester_fullname := l_requester_information.first_name + " " + l_requester_information.last_name elseif not l_requester_information.first_name.is_empty then l_requester_fullname := l_requester_information.first_name elseif not l_requester_information.last_name.is_empty then l_requester_fullname := l_requester_information.last_name end end create l_reply.make (l_requestee.email, l_requester.name, l_requester_fullname) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_request) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_process_friendship_request (a_msg: O_MESSAGE) is -- Process friendship request: if accepted, add friendship in USER_FRIENDSHIP -- Delete request from USER_FRIENDSHIP_REQUEST and return information of requestee. require a_msg_ok: a_msg /= Void local l_msg: O_USER_PROCESS_FRIENDSHIP_REQUEST_MESSAGE l_reply: O_USER_PROCESS_FRIENDSHIP_REQUEST_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_requester: USER l_requestee: USER l_requestee_information: USER_INFORMATION l_requestee_fullname: STRING do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_requestee := user_access.last_user user_access.retrieve_user_by_name (l_msg.requester, False) if user_access.is_found then l_requester := user_access.last_user -- only process if request exists user_access.retrieve_friendship_request (l_requester.user_id, l_requestee.user_id) if user_access.is_found then -- check accept status if l_msg.accept then user_access.insert_friendship (l_requester.user_id, l_requestee.user_id) end user_access.delete_friendship_request (l_requester.user_id, l_requestee.user_id) -- generate and send reply l_requestee_fullname := "" user_access.retrieve_user_information_by_id (l_requestee.user_id) if user_access.is_found then l_requestee_information := user_access.last_user_information if not l_requestee_information.first_name.is_empty and not l_requestee_information.last_name.is_empty then l_requestee_fullname := l_requestee_information.first_name + " " + l_requestee_information.last_name elseif not l_requestee_information.first_name.is_empty then l_requestee_fullname := l_requestee_information.first_name elseif not l_requestee_information.last_name.is_empty then l_requestee_fullname := l_requestee_information.last_name end end create l_reply.make (l_requester.email, l_requestee.name, l_requestee_fullname) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_request) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end user_remove_friendship (a_msg: O_MESSAGE) is -- Remove friendship between users. require a_msg_ok: a_msg /= Void local l_msg: O_USER_REMOVE_FRIENDSHIP_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_id: INTEGER l_friend_id: INTEGER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user_id := user_access.last_user.user_id user_access.retrieve_user_by_name (l_msg.friend, False) if user_access.is_found then l_friend_id := user_access.last_user.user_id user_access.retrieve_friendship (l_user_id, l_friend_id) if user_access.is_found then -- now remove friendship from DB user_access.delete_friendship (l_user_id, l_friend_id) -- send True back create l_status.make (True, Void) node.send_message_reply (l_status, a_msg) else create l_status.make (False, err_invalid_friendship) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_list_friends (a_msg: O_MESSAGE) is -- List friends of a user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_LIST_FRIENDS_MESSAGE l_reply: O_USER_LIST_FRIENDS_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_friend: USER l_friends: LIST [USER] l_friend_details: TUPLE[name:STRING; icon: STRING; real_name: STRING] l_friend_list: DS_HASH_TABLE [TUPLE[name: STRING; icon: STRING; real_name: STRING], INTEGER] l_user: USER i: INTEGER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.username, False) if user_access.is_found then l_user := user_access.last_user -- retrieve friends and map them into a HASH_TABLE user_access.retrieve_friends_of_user (l_user.user_id) if user_access.is_found then l_friends := user_access.last_friends create l_friend_list.make (l_friends.count) from l_friends.start i := 0 until l_friends.after loop l_friend := l_friends.item create l_friend_details l_friend_details.name := l_friends.item.name l_friend_details.icon := "" l_friend_details.real_name := "" user_access.retrieve_user_information_by_id (l_friends.item.user_id) if user_access.is_found then l_friend_details.icon := user_access.last_user_information.icon if not user_access.last_user_information.first_name.is_empty and not user_access.last_user_information.last_name.is_empty then l_friend_details.real_name := user_access.last_user_information.first_name + " " + user_access.last_user_information.last_name elseif not user_access.last_user_information.first_name.is_empty then l_friend_details.real_name := user_access.last_user_information.first_name elseif not user_access.last_user_information.last_name.is_empty then l_friend_details.real_name := user_access.last_user_information.last_name end end l_friend_list.force (l_friend_details, i) l_friends.forth i := i + 1 end else create l_friend_list.make (0) end create l_reply.make (l_friend_list) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_send_message (a_msg: O_MESSAGE) is -- Send message call -> reply with email address and names. require a_msg_ok: a_msg /= Void local l_msg: O_USER_SEND_MESSAGE_MESSAGE l_reply: O_USER_SEND_MESSAGE_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_sender: USER l_sender_name: STRING l_sender_information: USER_INFORMATION l_recipient: USER l_recipient_name: STRING l_recipient_information: USER_INFORMATION do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_sender := user_access.last_user user_access.retrieve_user_by_name (l_msg.username, False) if user_access.is_found then l_recipient := user_access.last_user l_sender_name := l_sender.name user_access.retrieve_user_information_by_id (l_sender.user_id) if user_access.is_found then l_sender_information := user_access.last_user_information if not l_sender_information.first_name.is_empty and not l_sender_information.last_name.is_empty then l_sender_name := l_sender_information.first_name + " " + l_sender_information.last_name + " (" + l_sender.name + ")" elseif not l_sender_information.first_name.is_empty then l_sender_name := l_sender_information.first_name + " (" + l_sender.name + ")" elseif not l_sender_information.last_name.is_empty then l_sender_name := l_sender_information.last_name + " (" + l_sender.name + ")" end end l_recipient_name := l_recipient.name user_access.retrieve_user_information_by_id (l_recipient.user_id) if user_access.is_found then l_recipient_information := user_access.last_user_information if not l_recipient_information.first_name.is_empty and not l_recipient_information.last_name.is_empty then l_recipient_name := l_recipient_information.first_name + " " + l_recipient_information.last_name + " (" + l_recipient.name + ")" elseif not l_recipient_information.first_name.is_empty then l_recipient_name := l_recipient_information.first_name + " (" + l_recipient.name + ")" elseif not l_recipient_information.last_name.is_empty then l_recipient_name := l_recipient_information.last_name + " (" + l_recipient.name + ")" end end create l_reply.make (l_recipient.email, l_recipient_name, l_sender_name) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_session) node.send_message_reply (l_status, a_msg) end end user_disable_account (a_msg: O_USER_DISABLE_ACCOUNT_MESSAGE) is -- Disable account of user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_DISABLE_ACCOUNT_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user disable_account (l_user) create l_status.make (True, Void) node.send_message_reply (l_status, a_msg) else create l_status.make (False, err_invalid_session) node.send_message_reply (l_status, a_msg) end end user_list_communities (a_msg: O_MESSAGE) is -- List communities of a user. require a_msg_ok: a_msg /= Void local l_msg: O_USER_LIST_COMMUNITIES_MESSAGE l_reply: O_COMMUNITY_LIST_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_list: LIST [COMMUNITY] l_communities: DS_ARRAYED_LIST [STRING] l_community: COMMUNITY l_user: USER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then user_access.retrieve_user_by_name (l_msg.username, False) if user_access.is_found then l_user := user_access.last_user -- retrieve communities and map them into a LIST community_access.retrieve_communities_of_user (l_user.user_id) from l_list := community_access.last_community_list create l_communities.make (l_list.count) l_list.start until l_list.after loop l_community := l_list.item l_communities.force_last (l_community.name) l_list.forth end create l_reply.make (l_communities) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_session) node.send_message_reply (l_status, a_msg) end end key (a_msg: O_MESSAGE) is -- Retrieve the user key. require a_msg_ok: a_msg /= Void local l_msg: O_USER_KEY_MESSAGE l_reply: O_USER_KEY_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_key: STRING do l_msg ?= a_msg check user_key_message: l_msg /= Void end l_key := user_access.retrieve_key(l_msg.session) if l_key /= Void and then not l_key.is_empty then create l_reply.make (l_key) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_no_user_key) node.send_message_reply (l_status, a_msg) end end key_generate (a_msg: O_MESSAGE) is -- Generate a new user key for a user require a_msg_ok: a_msg /= Void local l_msg: O_USER_KEY_GENERATE_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user user_access.update_user_key (l_user.user_id, token_generator.generate_id) create l_status.make (True, Void) else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end add_bookmark (a_msg: O_MESSAGE) is -- Add bookmark to a project require a_msg_ok: a_msg /= Void local l_msg: O_USER_ADD_BOOKMARK_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER l_project_bookmark: PROJECT_BOOKMARK do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user project_access.retrieve_project_by_id (l_msg.project) if project_access.is_found then create l_project_bookmark.make l_project_bookmark.set_project_id (l_msg.project) l_project_bookmark.set_user_id (l_user.user_id) user_access.insert_bookmark (l_project_bookmark) -- subscribe to all workitems if user is not already a member of this project if user_access.retrieve_user_project_association_group (l_msg.project, l_user.user_id) = 0 then user_access.insert_all_project_workitem_subscriptions (l_user.user_id, l_msg.project) end create l_status.make (True, Void) else create l_status.make (False, err_invalid_project) end else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end remove_bookmark (a_msg: O_MESSAGE) is -- Remove bookmark to a project require a_msg_ok: a_msg /= Void local l_msg: O_USER_REMOVE_BOOKMARK_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user: USER do l_msg ?= a_msg check valid_msg: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then l_user := user_access.last_user project_access.retrieve_project_by_id (l_msg.project) if project_access.is_found then user_access.delete_bookmark (l_msg.project, l_user.user_id) -- remove all subscriptions if user is not still a member of this project if user_access.retrieve_user_project_association_group (l_msg.project, l_user.user_id) = 0 then user_access.delete_project_workitem_subscriptions (l_user.user_id, l_msg.project) end create l_status.make (True, Void) else create l_status.make (False, err_invalid_project) end else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end list_bookmark (a_msg: O_MESSAGE) is -- List bookmarks. require a_msg_ok: a_msg /= Void local l_msg: O_USER_LIST_BOOKMARK_MESSAGE l_reply: O_USER_LIST_BOOKMARK_REPLY_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_lst: LIST [PROJECT] l_projects: HASH_TABLE [STRING, INTEGER] l_proj: PROJECT l_user: USER do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_name (l_msg.username, False) if user_access.is_found then l_user := user_access.last_user -- retrieve projects and map them into a HASH_TABLE project_access.retrieve_bookmark_projects_of_user(l_user.user_id) from l_lst := project_access.last_project_list create l_projects.make (l_lst.count) l_lst.start until l_lst.after loop l_proj := l_lst.item l_projects.force (l_proj.name, l_proj.project_id) l_lst.forth end create l_reply.make (l_projects) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end user_set_workitem_subscription (a_msg: O_MESSAGE) is -- Set workitem subscription according to a_msg. require a_msg_ok: a_msg /= Void local l_pc_msg: O_USER_SET_WORKITEM_SUBSCRIPTION_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER l_project_ret: PROJECT do l_pc_msg ?= a_msg check valid_message: l_pc_msg /= Void end user_access.retrieve_user_by_session (l_pc_msg.session) if user_access.is_found then l_user_ret := user_access.last_user project_access.retrieve_project_by_id (l_pc_msg.project) if project_access.is_found then l_project_ret := project_access.last_project from l_pc_msg.settings.start until l_pc_msg.settings.after loop --TODO: add checks for workitem_type and subscription_type user_access.update_user_workitem_subscription (l_project_ret.project_id, l_user_ret.user_id, l_pc_msg.settings.item.workitem_type, l_pc_msg.settings.item.subscription_type, l_pc_msg.settings.item.is_enabled) l_pc_msg.settings.forth end create l_status.make (True, Void) else create l_status.make (False, err_invalid_project) end else create l_status.make (False, err_invalid_user) end node.send_message_reply (l_status, a_msg) end user_list_workitem_subscription (a_msg: O_MESSAGE) is -- List workitem subscriptions. require a_msg_ok: a_msg /= Void local l_msg: O_USER_LIST_WORKITEM_SUBSCRIPTION_MESSAGE l_reply: O_USER_WORKITEM_SUBSCRIPTIONS_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_query_result: ARRAYED_LIST [TUPLE [workitem_type: INTEGER; subscription_type: INTEGER]] do l_msg ?= a_msg check workitem_list_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then project_access.retrieve_project_by_id (l_msg.project) if project_access.is_found then l_query_result := user_access.retrieve_workitem_subscription (user_access.last_user.user_id, project_access.last_project.project_id) create l_reply.make (l_query_result) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_project) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end svn_configuration (a_msg: O_MESSAGE) is -- Retrieve configuration files for subversion. require a_msg_ok: a_msg /= Void local l_files: O_GENERIC_MESSAGE do create l_files.make (config_namespace, config_file_type) l_files.add_argument ("/data/svnusers/users", user_access.retrieve_auth_users) l_files.add_argument ("/data/svnusers/access", user_access.retrieve_svn_access) node.send_message_reply (l_files, a_msg) end ftp_configuration (a_msg: O_MESSAGE) is -- Retrieve configuration files for ftp. require a_msg_ok: a_msg /= Void local l_files: O_GENERIC_MESSAGE do create l_files.make (config_namespace, config_file_type) l_files.add_argument ("/etc/pure-ftpd/pureftpd.passwd", user_access.retrieve_ftp_users) node.send_message_reply (l_files, a_msg) end mail_addresses (a_msg: O_MESSAGE) is -- Retrieve all email addresses. require a_msg_ok: a_msg /= Void local l_addresses: LIST [STRING] l_msg: O_GENERIC_MESSAGE i: NATURAL do create l_msg.make (user_namespace, user_mail_list_reply_type) from i := 0 l_addresses := user_access.retrieve_mail_addresses l_addresses.start until l_addresses.after loop l_msg.add_argument (i.out, l_addresses.item) i := i + 1 l_addresses.forth end node.send_message_reply (l_msg, a_msg) end cleanup is -- Cleanup old sessions. do user_access.purge_old_sessions(session_lifetime) user_access.purge_old_friendship_requests(friendship_request_lifetime) end feature {NONE} -- Implementation disable_account (a_user: USER) is -- disable the account of `a_user' require a_user_not_void: a_user /= Void do -- modify user table and set user_association to '5' -> disabled user user_access.disable_account (a_user.user_id) -- remove bookmarks user_access.delete_all_bookmarks (a_user.user_id) -- remove read_workitems user_access.delete_all_user_read_workitems (a_user.user_id) -- remove user information -- disabled because we do want to keep user information for statistic usage -- user_access.delete_user_information (a_user.user_id) -- remove user_workitem_subscription user_access.delete_all_workitem_subscriptions (a_user.user_id) -- remove user from user-project-association table user_access.delete_all_user_project_associations (a_user.user_id) -- remove friendships user_access.delete_all_friendships (a_user.user_id) -- remove friendship_requests user_access.delete_all_friendship_requests (a_user.user_id) -- remove foaf user_access.delete_all_foaf (a_user.user_id) -- remove openid user_access.delete_all_openid (a_user.user_id) end config_parser: ORIGO_CONF_PARSER is -- parser for origo.conf once create Result.make_default end session_lifetime: INTEGER is -- session lifetime in seconds require config_parser_is_ok: config_parser /= Void local l_lifetime: STRING once l_lifetime := config_parser.get("session_lifetime") if l_lifetime = Void then node_logger.warn ("Loading of session_lifetime failed. Using fallback value 3600") Result := 3600 else Result := l_lifetime.to_integer end ensure result_is_valid: Result > 0 end friendship_request_lifetime: INTEGER is -- friendship request lifetime in days require config_parser_is_ok: config_parser /= Void local l_lifetime: STRING once l_lifetime := config_parser.get("friendship_request_lifetime") if l_lifetime = Void then node_logger.warn ("Loading of friendship_request_lifetime failed. Using fallback value 14") Result := 14 else Result := l_lifetime.to_integer end ensure result_is_valid: Result > 0 end feature {NONE} -- Cache token_generator: SESSION_ID_GENERATOR is -- Generate random strings. once create Result.make end end