$captcha_js = "";
$Captcha = "";
if (isset($admin->settings['captcha_on']) && $admin->settings['captcha_on'] == '1' && !empty($admin->settings['captcha_private_key']) && !empty($admin->settings['captcha_public_key'])) {
    $add_captcha = 1;
    $captcha_privatekey = $admin->settings['captcha_private_key'];
    $captcha_publickey = $admin->settings['captcha_public_key'];
    $captcha_js .= "<script type='text/javascript' src='" . getJSPath('include/javascript/sugar_grp1_yui.js') . "'></script><script type='text/javascript' src='" . getJSPath('include/javascript/sugar_grp_yui2.js') . "'></script>\n\t\t<script type='text/javascript' src='http://api.recaptcha.net/js/recaptcha_ajax.js'></script>\n\t\t<script> //var oldFormAction = document.getElementById('form').action; //save old action\n\t\tfunction initCaptcha(){\n\t\t\t\tRecaptcha.create('{$captcha_publickey}' ,'captchaImage',{theme:'custom',callback:Recaptcha.focus_response_field});\n\t\t\t\t}\n\n\t\twindow.onload=initCaptcha;\n\n\t\tvar handleFailure=handleSuccess;\n\t\tvar handleSuccess = function(o){\n\t\t\tif(o.responseText!==undefined && o.responseText =='Success'){\n\t\t\t\t\n\t\t\t\tdocument.getElementById('user_password').value=document.getElementById('new_password').value;\n\t\t\t\tdocument.getElementById('ChangePasswordForm').submit();\n\t\t\t}\n\t\t\telse{\n\t\t\t\talert(o.responseText);\n\t\t\t\tRecaptcha.reload();\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tvar callback2 =\n\t\t{\n\t\t  success:handleSuccess,\n\t\t  failure: handleFailure\n\t\t};\n\t\tfunction validateCaptchaAndSubmit(){\n\t\t\t\tvar form = document.getElementById('form');\n\t\t\t\tvar url = '&to_pdf=1&module=Home&action=index&entryPoint=Changenewpassword&recaptcha_challenge_field='+Recaptcha.get_challenge()+'&recaptcha_response_field='+ Recaptcha.get_response();\n\t\t\t\tYAHOO.util.Connect.asyncRequest('POST','index.php',callback2,url);\n\t\t\t\t\n\t\t}\n\t\t\n\t</script>";
    $Captcha .= $captcha_js;
    $Captcha .= "<tr>\n\t\t\t\t\t<td scope='row' width='20%'>" . $mod_strings['LBL_RECAPTCHA_INSTRUCTION_OPPOSITE'] . ":</td>\n\t\t            <td width='70%'><input type='text' size='26' id='recaptcha_response_field' value=''></td>\n\t\t        \t<th rowsapn='2' class='x-sqs-list' ><div  id='recaptcha_image'></div></th>\n\t\t\t    </tr>\n\t\t\t    \n\t\t\t    <tr>\n\t\t         \t<td colspan='2'>\n\t\t         \t\t<a href='javascript:Recaptcha.reload()'> " . $mod_strings['LBL_RECAPTCHA_NEW_CAPTCHA'] . "</a>&nbsp;&nbsp;\n\t\t         \t\t<a class='recaptcha_only_if_image' href='javascript:Recaptcha.switch_type('audio')'>" . $mod_strings['LBL_RECAPTCHA_SOUND'] . "</a>\n\t\t         \t\t<a class='recaptcha_only_if_audio' href='javascript:Recaptcha.switch_type('image')'>" . $mod_strings['LBL_RECAPTCHA_IMAGE'] . "</a>\n\t\t         \t</td>\n\t\t        </tr>";
} else {
    echo "<script>function validateCaptchaAndSubmit(){document.getElementById('user_password').value=document.getElementById('new_password').value;document.getElementById('ChangePasswordForm').submit();}</script>";
}
$pwd_settings = $GLOBALS['sugar_config']['passwordsetting'];
$sugar_smarty->assign('sugar_md', getWebPath('include/images/sugar_md_open.png'));
$sugar_smarty->assign("MOD", $mod_strings);
$sugar_smarty->assign("CAPTCHA", $Captcha);
$sugar_smarty->assign("IS_ADMIN", '1');
$sugar_smarty->assign("ENTRY_POINT", 'Changenewpassword');
$sugar_smarty->assign('return_action', 'login');
$sugar_smarty->assign("APP", $app_strings);
$sugar_smarty->assign("INSTRUCTION", $app_strings['NTC_LOGIN_MESSAGE']);
$sugar_smarty->assign("USERNAME_FIELD", '<td scope="row" width="30%">' . $mod_strings['LBL_USER_NAME'] . ':</td><td width="70%"><input type="text" size="20" tabindex="1" id="user_name" name="user_name"  value=""</td>');
$sugar_smarty->assign('PWDSETTINGS', $GLOBALS['sugar_config']['passwordsetting']);
$rules = "'','',''";
$sugar_smarty->assign('SUBMIT_BUTTON', '<input title="' . $mod_strings['LBL_LOGIN_BUTTON_TITLE'] . '" accessKey="' . $mod_strings['LBL_LOGIN_BUTTON_TITLE'] . '" class="button" ' . 'onclick="if(!set_password(form,newrules(' . $rules . '))) return false; validateCaptchaAndSubmit();" ' . 'type="button" tabindex="3" id="login_button" name="Login" value="' . $mod_strings['LBL_LOGIN_BUTTON_LABEL'] . '" /><br>&nbsp');
if (!empty($_REQUEST['guid'])) {
    $sugar_smarty->assign("GUID", $_REQUEST['guid']);
}
$sugar_smarty->display('modules/Users/Changenewpassword.tpl');
$view->displayFooter();
Beispiel #2
0
 function save($check_notify = false)
 {
     $isUpdate = !empty($this->id) && !$this->new_with_id;
     // this will cause the logged in admin to have the licensed user count refreshed
     if (isset($_SESSION)) {
         unset($_SESSION['license_seats_needed']);
     }
     $query = "SELECT count(id) as total from users WHERE " . self::getLicensedUsersWhere();
     global $sugar_flavor;
     $admin = Administration::getSettings();
     if (isset($sugar_flavor) && $sugar_flavor != null && ($sugar_flavor == 'CE' || isset($admin->settings['license_enforce_user_limit']) && $admin->settings['license_enforce_user_limit'] == 1)) {
         // Begin Express License Enforcement Check
         // this will cause the logged in admin to have the licensed user count refreshed
         if (isset($_SESSION['license_seats_needed'])) {
             unset($_SESSION['license_seats_needed']);
         }
         if ($this->portal_only != 1 && $this->is_group != 1 && (empty($this->fetched_row) || $this->fetched_row['status'] == 'Inactive' || $this->fetched_row['status'] == '') && $this->status == 'Active') {
             global $sugar_flavor;
             //if((isset($sugar_flavor) && $sugar_flavor != null) && ($sugar_flavor=='CE')){
             $license_users = $admin->settings['license_users'];
             if ($license_users != '') {
                 global $db;
                 //$query = "SELECT count(id) as total from users WHERE status='Active' AND deleted=0 AND is_group=0 AND portal_only=0";
                 $result = $db->query($query, true, "Error filling in user array: ");
                 $row = $db->fetchByAssoc($result);
                 $license_seats_needed = $row['total'] - $license_users;
             } else {
                 $license_seats_needed = -1;
             }
             if ($license_seats_needed >= 0) {
                 // displayAdminError( translate('WARN_LICENSE_SEATS_MAXED', 'Administration'). ($license_seats_needed + 1) . translate('WARN_LICENSE_SEATS2', 'Administration')  );
                 if (isset($_REQUEST['action']) && $_REQUEST['action'] != 'MassUpdate' && $_REQUEST['action'] != 'Save') {
                     die(translate('WARN_LICENSE_SEATS_EDIT_USER', 'Administration') . ' ' . translate('WARN_LICENSE_SEATS2', 'Administration'));
                 } else {
                     if (isset($_REQUEST['action'])) {
                         // When this is not set, we're coming from the installer.
                         $sv = new SugarView();
                         $sv->init('Users');
                         $sv->renderJavascript();
                         $sv->displayHeader();
                         $sv->errors[] = translate('WARN_LICENSE_SEATS_EDIT_USER', 'Administration') . ' ' . translate('WARN_LICENSE_SEATS2', 'Administration');
                         $sv->displayErrors();
                         $sv->displayFooter();
                         die;
                     }
                 }
             }
             //}
         }
     }
     // End Express License Enforcement Check
     // wp: do not save user_preferences in this table, see user_preferences module
     $this->user_preferences = '';
     // if this is an admin user, do not allow is_group or portal_only flag to be set.
     if ($this->is_admin) {
         $this->is_group = 0;
         $this->portal_only = 0;
     }
     // set some default preferences when creating a new user
     $setNewUserPreferences = empty($this->id) || !empty($this->new_with_id);
     // If the 'Primary' team changed then the team widget has set 'team_id' to a new value and we should
     // assign the same value to default_team because User module uses it for setting the 'Primary' team
     if (!empty($this->team_id)) {
         $this->default_team = $this->team_id;
     }
     // track the current reports to id to be able to use it if it has changed
     $old_reports_to_id = isset($this->fetched_row['reports_to_id']) ? $this->fetched_row['reports_to_id'] : '';
     parent::save($check_notify);
     $GLOBALS['sugar_config']['disable_team_access_check'] = true;
     if ($this->status != 'Reserved' && !$this->portal_only) {
         // If this is not an update, then make sure the new user logic is executed.
         if (!$isUpdate) {
             // If this is a new user, make sure to add them to the appriate default teams
             if (!$this->team_exists) {
                 $team = BeanFactory::getBean('Teams');
                 $team->new_user_created($this);
             }
         } else {
             if (empty($GLOBALS['sugar_config']['noPrivateTeamUpdate'])) {
                 //if this is an update, then we need to ensure we keep the user's
                 //private team name and name_2 in sync with their name.
                 $team_id = $this->getPrivateTeamID();
                 if (!empty($team_id)) {
                     $team = BeanFactory::getBean('Teams', $team_id);
                     Team::set_team_name_from_user($team, $this);
                     $team->save();
                 }
             }
         }
     }
     // If reports to has changed, call update team memberships to correct the membership tree
     if ($old_reports_to_id != $this->reports_to_id) {
         $this->update_team_memberships($old_reports_to_id);
     }
     // set some default preferences when creating a new user
     if ($setNewUserPreferences) {
         $this->setPreference('reminder_time', 1800);
         if (!$this->getPreference('calendar_publish_key')) {
             $this->setPreference('calendar_publish_key', create_guid());
         }
     }
     $this->savePreferencesToDB();
     //CurrentUserApi needs a consistent timestamp/format of the data modified for hash purposes.
     $this->hashTS = $this->date_modified;
     // In case this new/updated user changes the system status, reload it here
     apiLoadSystemStatus(true);
     return $this->id;
 }
 public function testdisplayFooter()
 {
     $SugarView = new SugarView();
     //execute the method and check if it works and doesn't throws an exception
     //secondly check if it outputs any content to browser
     try {
         ob_start();
         $SugarView->displayFooter();
         $renderedContent = ob_get_contents();
         ob_end_clean();
         $this->assertGreaterThan(0, strlen($renderedContent));
     } catch (Exception $e) {
         $this->fail();
     }
 }