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