2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition 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 ********************************************************************************/
47 if(!is_admin($current_user)){
48 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
50 function clearPasswordSettings() {
51 $_POST['passwordsetting_SystemGeneratedPasswordON'] = '';
52 $_POST['passwordsetting_generatepasswordtmpl'] = '';
53 $_POST['passwordsetting_lostpasswordtmpl'] = '';
54 $_POST['passwordsetting_forgotpasswordON'] = '0';
55 $_POST['passwordsetting_linkexpiration'] = '1';
56 $_POST['passwordsetting_linkexpirationtime'] = '30';
57 $_POST['passwordsetting_linkexpirationtype'] = '1';
58 $_POST['passwordsetting_systexpiration'] = '0';
59 $_POST['passwordsetting_systexpirationtime'] = '';
60 $_POST['passwordsetting_systexpirationtype'] = '0';
61 $_POST['passwordsetting_systexpirationlogin'] = '';
64 require_once('modules/Administration/Forms.php');
65 echo getClassicModuleTitle(
68 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
69 $mod_strings['LBL_MANAGE_PASSWORD_TITLE'],
73 require_once('modules/Configurator/Configurator.php');
74 $configurator = new Configurator();
75 $sugarConfig = SugarConfig::getInstance();
76 $focus = new Administration();
77 $configurator->parseLoggerSettings();
78 $valid_public_key= true;
79 if(!empty($_POST['saveConfig'])){
80 if ($_POST['captcha_on'] == '1'){
81 $handle = @fopen("http://api.recaptcha.net/challenge?k=".$_POST['captcha_public_key']."&cachestop=35235354", "r");
84 while (!feof($handle)) {
85 $buffer .= fgets($handle, 4096);
89 $valid_public_key= substr($buffer, 1, 4) == 'var '? true : false;
91 if ($valid_public_key){
92 if (isset($_REQUEST['system_ldap_enabled']) && $_REQUEST['system_ldap_enabled'] == 'on') {
93 $_POST['system_ldap_enabled'] = 1;
94 clearPasswordSettings();
97 $_POST['system_ldap_enabled'] = 0;
101 if (isset($_REQUEST['authenticationClass'])) {
103 $configurator->useAuthenticationClass = true;
107 if (isset($_REQUEST['ldap_group_checkbox']) && $_REQUEST['ldap_group_checkbox'] == 'on')
108 $_POST['ldap_group'] = 1;
110 $_POST['ldap_group'] = 0;
112 if (isset($_REQUEST['ldap_authentication_checkbox']) && $_REQUEST['ldap_authentication_checkbox'] == 'on')
113 $_POST['ldap_authentication'] = 1;
115 $_POST['ldap_authentication'] = 0;
117 if( isset($_REQUEST['passwordsetting_lockoutexpirationtime']) && is_numeric($_REQUEST['passwordsetting_lockoutexpirationtime']) )
118 $_POST['passwordsetting_lockoutexpiration'] = 2;
120 $configurator->saveConfig();
122 $focus->saveConfig();
124 header('Location: index.php?module=Administration&action=index');
128 $focus->retrieveSettings();
131 require_once('include/SugarLogger/SugarLogger.php');
132 $sugar_smarty = new Sugar_Smarty();
134 // if no IMAP libraries available, disable Save/Test Settings
135 if(!function_exists('imap_open')) $sugar_smarty->assign('IE_DISABLED', 'DISABLED');
137 $config_strings=return_module_language($GLOBALS['current_language'],'Configurator');
138 $sugar_smarty->assign('CONF', $config_strings);
139 $sugar_smarty->assign('MOD', $mod_strings);
140 $sugar_smarty->assign('APP', $app_strings);
141 $sugar_smarty->assign('APP_LIST', $app_list_strings);
142 $sugar_smarty->assign('config', $configurator->config);
143 $sugar_smarty->assign('error', $configurator->errors);
144 $sugar_smarty->assign('LANGUAGES', get_languages());
145 $sugar_smarty->assign("settings", $focus->settings);
147 $sugar_smarty->assign('saml_enabled_checked', false);
149 //echo "sugar_config[authenticationClass]: " . $sugar_config['authenticationClass'];
150 //if (array_key_exists('authenticationClass', $sugar_config) && $sugar_config['authenticationClass'] == 'SAMLAuthenticate') {
151 // $sugar_smarty->assign('saml_enabled_checked', true);
153 // $sugar_smarty->assign('saml_enabled_checked', false);
157 if(!function_exists('mcrypt_cbc')){
158 $sugar_smarty->assign("LDAP_ENC_KEY_READONLY", 'readonly');
159 $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LDAP_ENC_KEY_NO_FUNC_DESC']);
161 $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LBL_LDAP_ENC_KEY_DESC']);
163 $sugar_smarty->assign("settings", $focus->settings);
165 if ($valid_public_key){
166 if(!empty($focus->settings['captcha_on'])){
167 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
169 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'none');
172 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
175 $sugar_smarty->assign("VALID_PUBLIC_KEY", $valid_public_key);
179 $res=$GLOBALS['sugar_config']['passwordsetting'];
182 require_once('include/SugarPHPMailer.php');
183 $mail = new SugarPHPMailer();
184 $mail->setMailerForSystem();
185 if($mail->Mailer == 'smtp' && $mail->Host ==''){
186 $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '1');
189 $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '0');
191 $focus = new InboundEmail();
193 $storedOptions = unserialize(base64_decode($focus->stored_options));
194 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name', '','name',true);
195 $create_case_email_template = (isset($storedOptions['create_case_email_template'])) ? $storedOptions['create_case_email_template'] : "";
196 $TMPL_DRPDWN_LOST =get_select_options_with_id($email_templates_arr, $res['lostpasswordtmpl']);
197 $TMPL_DRPDWN_GENERATE =get_select_options_with_id($email_templates_arr, $res['generatepasswordtmpl']);
199 $sugar_smarty->assign("TMPL_DRPDWN_LOST", $TMPL_DRPDWN_LOST);
200 $sugar_smarty->assign("TMPL_DRPDWN_GENERATE", $TMPL_DRPDWN_GENERATE);
202 $sugar_smarty->display('modules/Administration/PasswordManager.tpl');