Skip to content

Commit

Permalink
Replace explicit bean instantiations in files 11 - 20
Browse files Browse the repository at this point in the history
- File: '... /soap/SoapData.php'

   - Replaced 1 occurrence(s) of 'new Contact()'

   - Replaced 1 occurrence(s) of 'new User()'

- File: '... /soap/SoapHelperFunctions.php'

   - Replaced 2 occurrence(s) of 'new Release()'

   - Replaced 1 occurrence(s) of 'new Account()'

   - Replaced 1 occurrence(s) of 'new Administration()'

- File: '... /soap/SoapSugarUsers.php'

   - Replaced 1 occurrence(s) of 'new Contact()'

   - Replaced 1 occurrence(s) of 'new Note()'

   - Replaced 2 occurrence(s) of 'new User()'

   - Replaced 2 occurrence(s) of 'new Administration()'

   - Replaced 1 occurrence(s) of 'new DocumentRevision()'

- File: '... /soap/SoapPortalUsers.php'

   - Replaced 1 occurrence(s) of 'new aCase()'

   - Replaced 1 occurrence(s) of 'new Bug()'

   - Replaced 5 occurrence(s) of 'new Contact()'

   - Replaced 1 occurrence(s) of 'new Account()'

   - Replaced 2 occurrence(s) of 'new Note()'

   - Replaced 1 occurrence(s) of 'new User()'

- File: '... /run_job.php'

   - Replaced 1 occurrence(s) of 'new User()'

- File: '... /download.php'

   - Replaced 1 occurrence(s) of 'new DocumentRevision()'

- File: '... /soap.php'

   - Replaced 1 occurrence(s) of 'new Administration()'

- File: '... /include/Smarty/plugins/function.sugar_button.php'

   - Replaced 1 occurrence(s) of 'new SecurityGroup()'

- File: '... /include/entryPoint.php'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 1 occurrence(s) of 'new Administration()'

- File: '... /include/SubPanel/SubPanelDefinitions.php'

   - Replaced 2 occurrence(s) of 'new Administration()'
  • Loading branch information
j.dang committed Jan 22, 2020
1 parent e808d92 commit 72b6569
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion download.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
// Pull up the document revision, if it's of type Document
if (isset($focus->object_name) && $focus->object_name == 'Document') {
// It's a document, get the revision that really stores this file
$focusRevision = new DocumentRevision();
$focusRevision = BeanFactory::newBean('DocumentRevisions');
$focusRevision->retrieve($_REQUEST['id']);

if (empty($focusRevision->id)) {
Expand Down
2 changes: 1 addition & 1 deletion include/Smarty/plugins/function.sugar_button.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function smarty_function_sugar_button($params, &$smarty)
global $current_user, $sugar_config;
if(isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true) {
require_once('modules/SecurityGroups/SecurityGroup.php');
$groupFocus = new SecurityGroup();
$groupFocus = BeanFactory::newBean('SecurityGroups');
if($groupFocus->getMembershipCount($current_user->id) > 1) {
$output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(); _form.action.value=\'Save\';_form.module.value=\'{$module}\';_form.return_module.value=\'{$module}\';_form.return_action.value=\'DetailView\';_form.return_id.value=\'\';" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
Expand Down
4 changes: 2 additions & 2 deletions include/SubPanel/SubPanelDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ public function get_all_subpanels($return_tab_modules_only = true, $group_by_mod
*/
public function set_hidden_subpanels($panels)
{
$administration = new Administration();
$administration = BeanFactory::newBean('Administration');
$serialized = base64_encode(serialize($panels));
$administration->saveSetting('MySettings', 'hide_subpanels', $serialized);
}
Expand All @@ -851,7 +851,7 @@ public function get_hidden_subpanels()
if (empty($hidden_subpanels)) {

//create Administration object and retrieve any settings for panels
$administration = new Administration();
$administration = BeanFactory::newBean('Administration');
$administration->retrieveSettings('MySettings');

if (isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])) {
Expand Down
4 changes: 2 additions & 2 deletions include/entryPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@
$_SERVER['REQUEST_URI'] = '';
}

$current_user = new User();
$current_user = BeanFactory::newBean('Users');
$GLOBALS['current_user'] = $current_user;
$current_entity = null;
$system_config = new Administration();
$system_config = BeanFactory::newBean('Administration');
$system_config->retrieveSettings();

LogicHook::initialize()->call_custom_logic('', 'after_entry_point');
Expand Down
2 changes: 1 addition & 1 deletion run_job.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
$app_list_strings = return_app_list_strings_language($current_language);
$app_strings = return_application_language($current_language);

$current_user = new User();
$current_user = BeanFactory::newBean('Users');
$current_user->getSystemUser();

$GLOBALS['log']->debug('Starting job {$argv[1]} execution as ${argv[2]}');
Expand Down
2 changes: 1 addition & 1 deletion soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

global $HTTP_RAW_POST_DATA;

$administrator = new Administration();
$administrator = BeanFactory::newBean('Administration');
$administrator->retrieveSettings();

// Sugarcrm namespace is necessary for backwards compatibility with existing SOAP clients
Expand Down
4 changes: 2 additions & 2 deletions soap/SoapData.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function get_attendee_list($session, $module_name, $id)
}
$xml .= '<attendees>';
$result = $seed->db->query("SELECT users.id, $table_name.date_modified, first_name, last_name FROM users INNER JOIN $table_name ON $table_name.user_id = users.id WHERE ".$table_name.".".$join_field."_id = '".DBManagerFactory::getInstance()->quote($id)."' AND $table_name.deleted = 0");
$user = new User();
$user = BeanFactory::newBean('Users');
while ($row = $seed->db->fetchByAssoc($result)) {
$user->id = $row['id'];
$email = $user->emailAddress->getPrimaryAddress($user);
Expand All @@ -321,7 +321,7 @@ function get_attendee_list($session, $module_name, $id)
//now get contacts
$table_name = $l_module_name."_contacts";
$result = $seed->db->query("SELECT contacts.id, $table_name.date_modified, first_name, last_name FROM contacts INNER JOIN $table_name ON $table_name.contact_id = contacts.id INNER JOIN $seed->table_name ON ".$seed->table_name.".id = ".$table_name.".".$join_field."_id WHERE ".$table_name.".".$join_field."_id = '".DBManagerFactory::getInstance()->quote($id)."' AND ".$table_name.".deleted = 0 AND (contacts.id != ".$seed->table_name.".parent_id OR ".$seed->table_name.".parent_id IS NULL)");
$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');
while ($row = $seed->db->fetchByAssoc($result)) {
$contact->id = $row['id'];
$email = $contact->emailAddress->getPrimaryAddress($contact);
Expand Down
8 changes: 4 additions & 4 deletions soap/SoapHelperFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function get_field_list($value, $translate = true)
} //if

if (isset($value->module_dir) && $value->module_dir == 'Bugs') {
$seedRelease = new Release();
$seedRelease = BeanFactory::newBean('Releases');
$options = $seedRelease->get_releases(true, "Active");
$options_ret = array();
foreach ($options as $name => $value) {
Expand Down Expand Up @@ -225,7 +225,7 @@ function new_get_field_list($value, $translate = true)
} //if

if ($value->module_dir == 'Bugs') {
$seedRelease = new Release();
$seedRelease = BeanFactory::newBean('Releases');
$options = $seedRelease->get_releases(true, "Active");
$options_ret = array();
foreach ($options as $name => $value) {
Expand Down Expand Up @@ -961,7 +961,7 @@ function add_create_account($seed)
$assigned_user_id = $current_user->id;

// check if it already exists
$focus = new Account();
$focus = BeanFactory::newBean('Accounts');
if ($focus->ACLAccess('Save')) {
$class = get_class($seed);
$temp = new $class();
Expand Down Expand Up @@ -1151,7 +1151,7 @@ function get_decoded($object)
function decrypt_string($string)
{
if (function_exists('openssl_decrypt')) {
$focus = new Administration();
$focus = BeanFactory::newBean('Administration');
$focus->retrieveSettings();
$key = '';
if (!empty($focus->settings['ldap_enc_key'])) {
Expand Down
22 changes: 11 additions & 11 deletions soap/SoapPortalUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
function portal_login($portal_auth, $user_name, $application_name)
{
$error = new SoapError();
$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');
$result = login_user($portal_auth);

if ($result == 'fail' || $result == 'sessions_exceeded') {
Expand Down Expand Up @@ -135,7 +135,7 @@ function portal_validate_authenticated($session_id)

if (!empty($_SESSION['is_valid_session']) && $_SESSION['ip_address'] == query_client_ip() && $valid_session != null && ($_SESSION['type'] == 'contact' || $_SESSION['type'] == 'lead' || $_SESSION['type'] == 'portal')) {
global $current_user;
$current_user = new User();
$current_user = BeanFactory::newBean('Users');
$current_user->retrieve($_SESSION['portal_id']);
login_success();
return true;
Expand Down Expand Up @@ -242,13 +242,13 @@ function portal_get_entry_list_filter($session, $module_name, $order_by, $select

$sugar = null;
if ($module_name == 'Cases') {
$sugar = new aCase();
$sugar = BeanFactory::newBean('Cases');
} elseif ($module_name == 'Contacts') {
$sugar = new Contact();
$sugar = BeanFactory::newBean('Contacts');
} elseif ($module_name == 'Accounts') {
$sugar = new Account();
$sugar = BeanFactory::newBean('Accounts');
} elseif ($module_name == 'Bugs') {
$sugar = new Bug();
$sugar = BeanFactory::newBean('Bugs');
} elseif ($module_name == 'KBDocuments' || $module_name == 'FAQ') {
$sugar = new KBDocument();
} else {
Expand Down Expand Up @@ -437,7 +437,7 @@ function portal_set_entry($session, $module_name, $name_value_list)
}
$id = $seed->save();
} else {
$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');
$contact->disable_row_level_security = true;
$contact->retrieve($_SESSION['user_id']);
$seed->contact_id = $contact;
Expand Down Expand Up @@ -500,7 +500,7 @@ function portal_remove_note_attachment($session, $id)
return array('result_count'=>-1, 'entry_list'=>array(), 'error'=>$error->get_soap_array());
}

$focus = new Note();
$focus = BeanFactory::newBean('Notes');
$focus->retrieve($id);
$result = $focus->deleteAttachment();

Expand All @@ -527,7 +527,7 @@ function portal_get_note_attachment($session, $id)
}
$current_user = $seed_user;

$note = new Note();
$note = BeanFactory::newBean('Notes');
$note->retrieve($id);
require_once('modules/Notes/NoteSoap.php');
$ns = new NoteSoap();
Expand Down Expand Up @@ -745,7 +745,7 @@ function portal_get_subscription_lists($session)

require_once('modules/Campaigns/utils.php');

$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');
$contact->retrieve($_SESSION['user_id']);

if (!empty($contact->id)) {
Expand Down Expand Up @@ -788,7 +788,7 @@ function portal_set_newsletters($session, $subscribe_ids, $unsubscribe_ids)

require_once('modules/Campaigns/utils.php');

$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');
$contact->retrieve($_SESSION['user_id']);

if (!empty($contact->id)) {
Expand Down
14 changes: 7 additions & 7 deletions soap/SoapSugarUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ function login($user_auth, $application)
global $sugar_config, $system_config;

$error = new SoapError();
$user = new User();
$user = BeanFactory::newBean('Users');
$success = false;
//rrs
$system_config = new Administration();
$system_config = BeanFactory::newBean('Administration');
$system_config->retrieveSettings('system');
$authController = new AuthenticationController();
//rrs
Expand Down Expand Up @@ -216,7 +216,7 @@ function validate_authenticated($session_id)
if (!empty($_SESSION['is_valid_session']) && is_valid_ip_address('ip_address') && $_SESSION['type'] == 'user') {
global $current_user;

$current_user = new User();
$current_user = BeanFactory::newBean('Users');
$current_user->retrieve($_SESSION['user_id']);
login_success();

Expand Down Expand Up @@ -776,7 +776,7 @@ function get_note_attachment($session, $id)
return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
}

$note = new Note();
$note = BeanFactory::newBean('Notes');

$note->retrieve($id);
if (!$note->ACLAccess('DetailView')) {
Expand Down Expand Up @@ -1085,7 +1085,7 @@ function update_portal_user($session, $portal_name, $name_value_list)

return $error->get_soap_array();
}
$contact = new Contact();
$contact = BeanFactory::newBean('Contacts');

$searchBy = array('deleted' => 0);
foreach ($name_value_list as $name_value) {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ function get_sugar_flavor()
*/
function get_server_version()
{
$admin = new Administration();
$admin = BeanFactory::newBean('Administration');
$admin->retrieveSettings('info');
if (isset($admin->settings['info_sugar_version'])) {
return $admin->settings['info_sugar_version'];
Expand Down Expand Up @@ -2215,7 +2215,7 @@ function get_document_revision($session, $id)
}


$dr = new DocumentRevision();
$dr = BeanFactory::newBean('DocumentRevisions');
$dr->retrieve($id);
if (!empty($dr->filename)) {
$filename = "upload://{$dr->id}";
Expand Down

0 comments on commit 72b6569

Please sign in to comment.