Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
6b7eb9df | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
6b7eb9df TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d631cdc8 | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 | 16 | */ |
5c5ed6db | 17 | if (!(php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))) { |
a9f3bf65 SL |
18 | header("HTTP/1.0 404 Not Found"); |
19 | return; | |
20 | } | |
6a488035 TO |
21 | |
22 | require_once '../civicrm.config.php'; | |
23 | ||
24 | require_once 'CRM/Core/Config.php'; | |
25 | require_once 'CRM/Core/Error.php'; | |
26 | require_once 'CRM/Core/I18n.php'; | |
27 | ||
28 | require_once 'CRM/Contact/BAO/Group.php'; | |
29 | ||
30 | $config = CRM_Core_Config::singleton(); | |
31 | ||
32 | $prefix = 'Automated Generated Group: '; | |
33 | $query = "DELETE FROM civicrm_group where name like '%{$prefix}%'"; | |
33621c4f | 34 | CRM_Core_DAO::executeQuery($query); |
6a488035 TO |
35 | |
36 | $numGroups = 100; | |
37 | ||
38 | $visibility = array('User and User Admin Only', 'Public Pages'); | |
39 | $groupType = array(NULL, '\ 11\ 1', '\ 12\ 1', '\ 11\ 12\ 1'); | |
40 | ||
41 | for ($i = 1; $i <= $numGroups; $i++) { | |
42 | $group = new CRM_Contact_BAO_Group(); | |
43 | $cnt = sprintf('%05d', $i); | |
44 | $alphabet = mt_rand(97, 122); | |
45 | $group->name = $group->title = chr($alphabet) . ": $prefix $cnt"; | |
46 | $group->is_active = 1; | |
47 | ||
48 | $v = mt_rand(0, 1); | |
49 | $group->visibility = $visibility[$v]; | |
50 | ||
51 | $t = mt_rand(0, 3); | |
52 | $group->group_type = $groupType[$t]; | |
53 | ||
54 | $group->save(); | |
d631cdc8 | 55 | |
6a488035 | 56 | } |