public function testdisplayErrors() { $SugarView = new SugarView(); //execute the method and check if it works and doesn't throws an exception try { $errors = $SugarView->displayErrors(); $this->assertSame(null, $errors); } catch (Exception $e) { $this->fail(); } $this->assertTrue(true); }
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; }