/** * @see SugarView::displayHeader() */ public function displayHeader() { if (!empty($_REQUEST['record'])) { $module = $_SESSION['merge_module']; $this->_leadQual->load_merge_bean($module, false, $_REQUEST['record']); } parent::displayHeader(); }
public function testdisplayHeader() { $SugarView = new SugarView(); $SugarView->module = 'Users'; $GLOBALS['app'] = new SugarApplication(); //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->displayHeader(); $renderedContent = ob_get_contents(); ob_end_clean(); $this->assertGreaterThan(0, strlen($renderedContent)); } catch (Exception $e) { $this->fail(); } }
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; }
} else { $query2 = "UPDATE users_password_link SET deleted='1' where id='" . $_REQUEST['guid'] . "'"; $GLOBALS['db']->query($query2, true, "Error setting link"); } } } if ($redirect != '0') { header('location:index.php?action=Login&module=Users'); exit; } //// PASSWORD GENERATED LINK CHECK USING /////////////////////////////////////////////////////////////////////////////// require_once 'include/MVC/View/SugarView.php'; $view = new SugarView(); $view->init(); $view->displayHeader(); $sugar_smarty = new Sugar_Smarty(); $admin = new Administration(); $admin->retrieveSettings('captcha'); $add_captcha = 0; $captcha_privatekey = ""; $captcha_publickey = ""; $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> \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>";