]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Employees/WapAuthenticate.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Employees / WapAuthenticate.php
1 <?php
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-2012 SugarCRM Inc.
7  * 
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.
14  * 
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
18  * details.
19  * 
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
23  * 02110-1301 USA.
24  * 
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.
27  * 
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.
31  * 
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  ********************************************************************************/
38
39 /*********************************************************************************
40
41  * Description:  TODO: To be written.
42  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
43  * All Rights Reserved.
44  * Contributor(s): ______________________________________..
45  ********************************************************************************/
46
47 global $mod_strings;
48
49 $focus = new User();
50
51 // Add in defensive code here.
52 $focus->user_name = $_REQUEST['user_name'];
53 $user_password = $_REQUEST['user_password'];
54
55 $focus->load_user($user_password);
56
57 if ($focus->is_authenticated()) {
58     // save the user information into the session
59     // go to the home screen
60     header("Location: ".$GLOBALS['app']->getLoginRedirect());
61     unset($_SESSION['login_password']);
62     unset($_SESSION['login_error']);
63     unset($_SESSION['login_user_name']);
64
65     $_SESSION['authenticated_user_id'] = $focus->id;
66
67     // store the user's theme in the session
68     if (isset($_REQUEST['login_theme'])) {
69         $authenticated_user_theme = $_REQUEST['login_theme'];
70     } elseif (isset($_REQUEST['ck_login_theme_20'])) {
71         $authenticated_user_theme = $_REQUEST['ck_login_theme_20'];
72     } else {
73         $authenticated_user_theme = $sugar_config['default_theme'];
74     }
75
76     // store the user's language in the session
77     if (isset($_REQUEST['login_language'])) {
78         $authenticated_user_language = $_REQUEST['login_language'];
79     } elseif (isset($_REQUEST['ck_login_language_20'])) {
80         $authenticated_user_language = $_REQUEST['ck_login_language_20'];
81     } else {
82         $authenticated_user_language = $sugar_config['default_language'];
83     }
84
85     // 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
86     if ($reset_theme_on_default_user && $focus->user_name == $sugar_config['default_user_name']) {
87         $authenticated_user_theme = $sugar_config['default_theme'];
88     }
89     if (isset($reset_language_on_default_user) && $reset_language_on_default_user &&
90          $focus->user_name == $sugar_config['default_user_name']) {
91             $authenticated_user_language = $sugar_config['default_language'];
92     }
93
94     $_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
95     $_SESSION['authenticated_user_language'] = $authenticated_user_language;
96
97     $GLOBALS['log']->debug("authenticated_user_theme is $authenticated_user_theme");
98     $GLOBALS['log']->debug("authenticated_user_language is $authenticated_user_language");
99
100     // Clear all uploaded import files for this user if it exists
101
102     require_once('modules/Import/ImportCacheFiles.php');
103     $tmp_file_name = ImportCacheFiles::getImportDir()."/IMPORT_" . $focus->id;
104
105     if (file_exists($tmp_file_name)) {
106         unlink($tmp_file_name);
107     }
108
109 } else {
110     $_SESSION['login_user_name'] = $focus->user_name;
111     $_SESSION['login_password'] = $user_password;
112     $_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
113
114     // go back to the login screen.
115     // create an error message for the user.
116     header("Location: index.php");
117 }