2 if (!defined('sugarEntry') || !sugarEntry)
3 die('Not A Valid Entry Point');
4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
39 /*********************************************************************************
41 * Description: TODO: To be written.
42 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
43 * All Rights Reserved.
44 * Contributor(s): ______________________________________..
45 ********************************************************************************/
51 // Add in defensive code here.
52 $focus->user_name = $_REQUEST['user_name'];
53 $user_password = $_REQUEST['user_password'];
55 $focus->load_user($user_password);
57 if ($focus->is_authenticated()) {
58 // save the user information into the session
59 // go to the home screen
60 if (!empty($_POST['login_record'])) {
61 $login_direction = "module={$_POST['login_module']}&action={$_POST['login_action']}&record={$_POST['login_record']}";
63 $login_direction = "action=index&module=Home";
66 header("Location: index.php?{$login_direction}");
67 unset($_SESSION['login_password']);
68 unset($_SESSION['login_error']);
69 unset($_SESSION['login_user_name']);
71 $_SESSION['authenticated_user_id'] = $focus->id;
73 // store the user's theme in the session
74 if (isset($_REQUEST['login_theme'])) {
75 $authenticated_user_theme = $_REQUEST['login_theme'];
76 } elseif (isset($_REQUEST['ck_login_theme_20'])) {
77 $authenticated_user_theme = $_REQUEST['ck_login_theme_20'];
79 $authenticated_user_theme = $sugar_config['default_theme'];
82 // store the user's language in the session
83 if (isset($_REQUEST['login_language'])) {
84 $authenticated_user_language = $_REQUEST['login_language'];
85 } elseif (isset($_REQUEST['ck_login_language_20'])) {
86 $authenticated_user_language = $_REQUEST['ck_login_language_20'];
88 $authenticated_user_language = $sugar_config['default_language'];
91 // If this is the default user and the default user theme is set to reset, reset it to the default theme value on each login
92 if ($reset_theme_on_default_user && $focus->user_name == $sugar_config['default_user_name']) {
93 $authenticated_user_theme = $sugar_config['default_theme'];
95 if (isset($reset_language_on_default_user) && $reset_language_on_default_user &&
96 $focus->user_name == $sugar_config['default_user_name']) {
97 $authenticated_user_language = $sugar_config['default_language'];
100 $_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
101 $_SESSION['authenticated_user_language'] = $authenticated_user_language;
103 $GLOBALS['log']->debug("authenticated_user_theme is $authenticated_user_theme");
104 $GLOBALS['log']->debug("authenticated_user_language is $authenticated_user_language");
106 // Clear all uploaded import files for this user if it exists
108 require_once('modules/Import/ImportCacheFiles.php');
109 $tmp_file_name = ImportCacheFiles::getImportDir()."/IMPORT_" . $focus->id;
111 if (file_exists($tmp_file_name)) {
112 unlink($tmp_file_name);
116 $_SESSION['login_user_name'] = $focus->user_name;
117 $_SESSION['login_password'] = $user_password;
118 $_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
120 // go back to the login screen.
121 // create an error message for the user.
122 header("Location: index.php");