AnsweredAssumed Answered

Use another user credential on a custom PHP on 6.5CE

Question asked by Paulo Nascimento on Aug 27, 2014
I have a custom PHP page used on a customized listviewdev.php module. On this page I connect to SugarCRM REST API with a specific integration user in order to query modules. But I also have acess the current session of the "regular" user. My question is: is there a way to use the current logged user session in order to query the modules (in the example is the $current_user_id session)? How can I reach his session variable? My objective is to log the correct user on the audit history after changes in a bean.
I printed the whole $_SESSION and searched this session ID without sucess.

        // Get current logged user id
        $current_user_id = $_SESSION["authenticated_user_id"];

        // Connect to Sugar CRM instance with Api user
        $conn = sugarLogin();

        // Get all branches related to user
        $get_entry_list_parameters_user_branches = array(
                'session' => $conn,
                'module_name' => "Users",
                'module_id' => $current_user_id,
                'link_field_name' => "users_canal_branches_1",
                'related_module_query' => "",
                'related_fields' => array('id','name'),
                'related_module_link_name_to_fields_array' => array(),
                'deleted' => "0",
                'order_by' => ""
        $get_entry_list_result_user_branches = call("get_relationships", $get_entry_list_parameters_user_branches);