function portal_login($portal_auth, $user_name, $application_name) { $error = new SoapError(); $contact = new Contact(); $result = login_user($portal_auth); if ($result == 'fail' || $result == 'sessions_exceeded') { if ($result == 'sessions_exceeded') { $error->set_error('sessions_exceeded'); } else { $error->set_error('no_portal'); } return array('id' => -1, 'error' => $error->get_soap_array()); } global $current_user; if ($user_name == 'lead') { session_start(); $_SESSION['is_valid_session'] = true; $_SESSION['ip_address'] = query_client_ip(); $_SESSION['portal_id'] = $current_user->id; $_SESSION['type'] = 'lead'; login_success(); return array('id' => session_id(), 'error' => $error->get_soap_array()); } else { if ($user_name == 'portal') { session_start(); $_SESSION['is_valid_session'] = true; $_SESSION['ip_address'] = query_client_ip(); $_SESSION['portal_id'] = $current_user->id; $_SESSION['type'] = 'portal'; $GLOBALS['log']->debug("Saving new session"); login_success(); return array('id' => session_id(), 'error' => $error->get_soap_array()); } else { $contact = $contact->retrieve_by_string_fields(array('portal_name' => $user_name, 'portal_active' => '1', 'deleted' => 0)); if ($contact != null) { session_start(); $_SESSION['is_valid_session'] = true; $_SESSION['ip_address'] = query_client_ip(); $_SESSION['user_id'] = $contact->id; $_SESSION['portal_id'] = $current_user->id; $_SESSION['type'] = 'contact'; $_SESSION['assigned_user_id'] = $contact->assigned_user_id; login_success(); build_relationship_tree($contact); return array('id' => session_id(), 'error' => $error->get_soap_array()); } } } $error->set_error('invalid_login'); return array('id' => -1, 'error' => $error->get_soap_array()); }
function portal_login_contact($portal_auth, $contact_portal_auth, $application_name) { $error = new SoapError(); $contact = BeanFactory::getBean('Contacts'); $result = login_user($portal_auth); if ($result == 'fail' || $result == 'sessions_exceeded') { if ($result == 'sessions_exceeded') { $error->set_error('sessions_exceeded'); } else { $error->set_error('no_portal'); } return array('id' => -1, 'error' => $error->get_soap_array()); } global $current_user; $sessionManager = new SessionManager(); $contact = $contact->retrieve_by_string_fields(array('portal_name' => $contact_portal_auth['user_name'], 'portal_active' => '1', 'deleted' => 0)); if (!empty($contact) && !User::checkPasswordMD5($contact_portal_auth['password'], $contact->portal_password)) { $contact = null; } if (!empty($contact)) { session_start(); $_SESSION['is_valid_session'] = true; $_SESSION['ip_address'] = query_client_ip(); $_SESSION['user_id'] = $contact->id; $_SESSION['portal_id'] = $current_user->id; $_SESSION['type'] = 'contact'; $_SESSION['team_id'] = $contact->team_id; $_SESSION['team_set_id'] = $contact->team_set_id; $_SESSION['assigned_user_id'] = $contact->assigned_user_id; //C.L - Set the admin modules granted for portal user. This change is necessary since the new Link2.php class does a bean retrieval //against the modules to which to associate relationships. It could be possible that the Contact's teams are not accessible by the //portal user's team security restrictions. $_SESSION[$current_user->user_name . '_get_admin_modules_for_user'] = array('Cases', 'Notes', 'Accounts', 'Contacts', 'Bugs', 'KBDocuments', 'Campaigns'); $sessionManager->session_type = 'contact'; $sessionManager->last_request_time = TimeDate::getInstance()->nowDb(); $sessionManager->session_id = session_id(); $sessionManager->save(); login_success(); build_relationship_tree($contact); return array('id' => session_id(), 'error' => $error->get_soap_array()); } else { $error->set_error('invalid_login'); return array('id' => -1, 'error' => $error->get_soap_array()); } }