Skip to content

Commit d783a3f

Browse files
author
Igor Zhutaiev
authored
Merge pull request #77 from sugarcrm/develop
Develop merge to master
2 parents 5b67956 + 40688f2 commit d783a3f

File tree

23 files changed

+633
-18
lines changed

23 files changed

+633
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.lock
66
composer.phar
77
vendor/
88
build/
9+
csv/*

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ Configuration
9090
9191
Usage
9292
-----
93-
**NOTE** **Usage of Tidbit could affect your _data_ in DB**
93+
**NOTES:**
94+
95+
* Usage of Tidbit could affect your _data_ in DB
9496
Please make sure you have a backup, before running data Generation commands
9597
98+
* In case of generation csv (--storage csv)
99+
We suppose what csv-dump will be used on empty DB, so for speed up, we'll generate
100+
values (integer starting with 1) for autoincrement-type fields.
101+
96102
Tidbit uses a command line interface. To run it from the Tidbit directory:
97103
98104
$ php -f install_cli.php

bootstrap.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@
143143
--with-favorites Turn on Sugar Favorites generation. Will generate records in "sugarfavorites" table for modules
144144
describes in config as \$sugarFavoritesModules, \$sugarFavoritesModules will be multiplied with
145145
"load factor" (-l) argument
146+
--profile Name of file in folder config/profiles (without .php) or path to php-config-file with profile data.
147+
File can contain php-arrays
148+
- modules -- counts of beans to create
149+
- profile_opts -- redefines of settings listed here
150+
In case of setting profile (this setting) setting -l (load factor) will be ignored.
146151
147152
"Powered by SugarCRM"
148153
@@ -173,6 +178,7 @@
173178
'as_last_rec:',
174179
'iterator:',
175180
'insert_batch_size:',
181+
'profile:',
176182
)
177183
);
178184

@@ -192,16 +198,42 @@
192198

193199
define('TIDBIT_DIR', __DIR__);
194200
define('CONFIG_DIR', __DIR__ . '/config');
201+
define('PROFILES_DIR', CONFIG_DIR . '/profiles');
195202
define('DATA_DIR', CONFIG_DIR . '/data');
196203
define('RELATIONSHIPS_DIR', CONFIG_DIR . '/relationships');
197204

198-
require_once __DIR__ . '/vendor/autoload.php';
205+
/*
206+
* if Tidbit is running independently, the dependencies are in the /vendor
207+
* directory, but if Tidbit is part of a larger composer managed system, the
208+
* dependencies are a couple directories higher. If neither are found, bail
209+
*/
210+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
211+
require_once __DIR__ . '/vendor/autoload.php';
212+
} elseif (file_exists(__DIR__ . '../../autoload.php')) {
213+
require_once __DIR__ . '../../autoload.php';
214+
} else {
215+
exitWithError('Unable to locate composer\'s autoload.php file');
216+
}
199217

200218
// load general config
201219
require_once CONFIG_DIR . '/config.php';
202220

203221
set_exception_handler('uncaughtExceptionHandler');
204222

223+
if (isset($opts['profile'])) {
224+
if (is_file($opts['profile'])) {
225+
require_once $opts['profile'];
226+
} elseif (is_file(PROFILES_DIR . '/' . $opts['profile'] . '.php')) {
227+
require_once PROFILES_DIR . '/' . $opts['profile'] . '.php';
228+
} else {
229+
exitWithError('Given profile ' . $opts['profile'] . ' does not exist');
230+
}
231+
232+
if (isset($profile_opts)) {
233+
$opts = array_merge($opts, $profile_opts);
234+
}
235+
}
236+
205237
if (isset($opts['sugar_path'])) {
206238
$sugarPath = $opts['sugar_path'];
207239
}
@@ -292,7 +324,7 @@
292324
$moduleUsingGenerators = array('KBContents', 'Categories', 'SugarFavorites');
293325

294326

295-
if (isset($opts['l'])) {
327+
if (isset($opts['l']) && !isset($opts['profile'])) {
296328
if (!is_numeric($opts['l'])) {
297329
exitWithError($usageStr);
298330
}
@@ -301,7 +333,7 @@
301333
$modules[$m] *= $factor;
302334
}
303335

304-
// Multiple favorites with $factor too
336+
// Multiple favorites with $factor too
305337
if (isset($opts['with-favorites'])) {
306338
foreach ($sugarFavoritesModules as $m => $n) {
307339
$sugarFavoritesModules[$m] *= $factor;

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$defaultMaxTeamsPerSet = 10;
4343

4444
// Default Sugar location path, could be overridden by "--sugar_path" argument
45-
$sugarPath = __DIR__ . '/..';
45+
$sugarPath = __DIR__ . '/../..';
4646

4747
$modules = array(
4848
'Tags' => 100,

config/data/Accounts.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@
6262
'prefixlist' => array('companyPre'),
6363
'suffixlist' => array('companyExt')
6464
);
65+
$GLOBALS['dataTool']['Accounts']['phone_alternate'] = array('phone' => true);
66+
$GLOBALS['dataTool']['Accounts']['phone_fax'] = array('phone' => true);
67+
$GLOBALS['dataTool']['Accounts']['phone_office'] = array('phone' => true);

config/data/Contacts.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@
5858
$GLOBALS['dataTool']['Contacts']['portal_name'] = array('incname' => 'contact');
5959
$GLOBALS['dataTool']['Contacts']['portal_password'] = array('same_hash' => 'portal_name');
6060
$GLOBALS['dataTool']['Contacts']['portal_active'] = array('value' => "'1'");
61+
$GLOBALS['dataTool']['Contacts']['phone_fax'] = array('phone' => true);
62+
$GLOBALS['dataTool']['Contacts']['phone_work'] = array('phone' => true);
63+
$GLOBALS['dataTool']['Contacts']['phone_other'] = array('phone' => true);
64+
$GLOBALS['dataTool']['Contacts']['phone_mobile'] = array('phone' => true);
65+
$GLOBALS['dataTool']['Contacts']['phone_home'] = array('phone' => true);

config/data/DefaultData.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@
6464
);
6565
$GLOBALS['dataTool']['default']['bool'] = array('range' => array('min' => 0, 'max' => 1));
6666
$GLOBALS['dataTool']['default']['email'] = array('list' => 'last_name_array', 'suffix' => '@example.com');
67-
$GLOBALS['dataTool']['default']['phone'] = array(
68-
'range' => array('min' => 1000, 'max' => 9999),
69-
'prefix' => '(555)555-',
70-
'isQuoted' => true
71-
);
67+
$GLOBALS['dataTool']['default']['phone'] = array('phone' => true);
7268
$GLOBALS['dataTool']['default']['meeting_probability'] = array('set' => false);
7369
$GLOBALS['dataTool']['default']['team_id'] = array('related' => array('module' => 'Teams'));
7470
$GLOBALS['dataTool']['default']['created_by'] = array('related' => array('module' => 'Users'));

config/data/Leads.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@
5656
$GLOBALS['dataTool']['Leads']['account_id'] = array('related' => array('module' => 'Accounts'));
5757
$GLOBALS['dataTool']['Leads']['contact_id'] = array('related' => array('module' => 'Contacts'));
5858
$GLOBALS['dataTool']['Leads']['lead_source_description'] = array('gibberish' => 8);
59+
$GLOBALS['dataTool']['Leads']['phone_fax'] = array('phone' => true);
60+
$GLOBALS['dataTool']['Leads']['phone_work'] = array('phone' => true);
61+
$GLOBALS['dataTool']['Leads']['phone_other'] = array('phone' => true);
62+
$GLOBALS['dataTool']['Leads']['phone_mobile'] = array('phone' => true);
63+
$GLOBALS['dataTool']['Leads']['phone_home'] = array('phone' => true);

config/data/Notes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@
4040
$GLOBALS['dataTool']['Notes']['parent_type'] = array('value' => "'Accounts'");
4141
$GLOBALS['dataTool']['Notes']['filename'] = array('skip' => true);
4242
$GLOBALS['dataTool']['Notes']['file_mime_type'] = array('skip' => true);
43+
$GLOBALS['dataTool']['Notes']['contact_phone'] = array('phone' => true);

config/data/Tasks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
$GLOBALS['dataTool']['Tasks']['parent_id'] = array('related' => array('module' => 'Accounts'));
4040
$GLOBALS['dataTool']['Tasks']['parent_type'] = array('value' => "'Accounts'");
4141
$GLOBALS['dataTool']['Tasks']['status'] = array('meeting_probability' => true);
42+
$GLOBALS['dataTool']['Tasks']['contact_phone'] = array('phone' => true);
4243

4344
/* We want tasks to be in the past 90% of the time. */
4445
$GLOBALS['dataTool']['Tasks']['date'] = array(

0 commit comments

Comments
 (0)