Skip to content

Instantly share code, notes, and snippets.

@esimonetti
Last active April 20, 2020 05:39
Show Gist options
  • Save esimonetti/84179ec343658c6b83d2f9a9efcde0b5 to your computer and use it in GitHub Desktop.
Save esimonetti/84179ec343658c6b83d2f9a9efcde0b5 to your computer and use it in GitHub Desktop.
Add on SugarDockerized data/app/custominitsystem.php
<?php
// Enrico Simonetti
// enricosimonetti.com
// settings
$set = [
'email-admin' => 'my@email.com',
'email-user' => 'my-second@email.com',
'tzone' => 'Australia/Sydney',
'date' => 'd/m/Y',
'time' => 'H:i',
'name-format' => 's f l',
];
echo 'Updating admin user' . PHP_EOL;
$admin = \BeanFactory::newBean('Users');
$admin->getSystemUser();
$admin->first_name = 'admin';
$admin->last_name = 'admin';
$admin->email1 = $set['email-admin'];
$admin->cookie_consent = 1;
$admin->save();
$admin = \BeanFactory::getBean('Users', $admin->id);
$admin->setPreference('viewed_tour', 1);
$admin->setPreference('timezone', $set['tzone']);
$admin->setPreference('datef', $set['date']);
$admin->setPreference('time', $set['time']);
$admin->setPreference('ut', 1);
$admin->setPreference('default_locale_name_format', $set['name-format']);
$admin->savePreferencesToDB();
echo 'Creating test user' . PHP_EOL;
$u = \BeanFactory::newBean('Users');
$u->user_name = 'test';
$u->first_name = 'test';
$u->last_name = 'test';
$u->user_hash = \User::getPasswordHash('test');
$u->status = 'Active';
$u->email1 = $set['email-user'];
$u->cookie_consent = 1;
$u->save();
$u = \BeanFactory::getBean('Users', $u->id);
$u->setPreference('viewed_tour', 1);
$u->setPreference('timezone', $set['tzone']);
$u->setPreference('datef', $set['date']);
$u->setPreference('time', $set['time']);
$u->setPreference('ut', 1);
$u->setPreference('default_locale_name_format', $set['name-format']);
$u->savePreferencesToDB();
echo 'Setting default mail server to sugar-smtp' . PHP_EOL;
$oe = \BeanFactory::newBean('OutboundEmail');
$oe->mail_smtpserver = 'sugar-smtp';
$oe->mail_smtpport = 25;
$oe->mail_smtpssl = 0;
$oe->saveSystem();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment