| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * |
| 14 | * @package CRM |
| 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 16 | * $Id$ |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | require_once '../civicrm.config.php'; |
| 21 | |
| 22 | require_once 'CRM/Core/Config.php'; |
| 23 | require_once 'CRM/Core/Error.php'; |
| 24 | require_once 'CRM/Core/I18n.php'; |
| 25 | |
| 26 | require_once 'CRM/Contact/BAO/Group.php'; |
| 27 | |
| 28 | $config = CRM_Core_Config::singleton(); |
| 29 | |
| 30 | $prefix = 'Automated Generated Group: '; |
| 31 | $query = "DELETE FROM civicrm_group where name like '%{$prefix}%'"; |
| 32 | CRM_Core_DAO::executeQuery($query); |
| 33 | |
| 34 | $numGroups = 100; |
| 35 | |
| 36 | $visibility = array('User and User Admin Only', 'Public Pages'); |
| 37 | $groupType = array(NULL, '\ 11\ 1', '\ 12\ 1', '\ 11\ 12\ 1'); |
| 38 | |
| 39 | for ($i = 1; $i <= $numGroups; $i++) { |
| 40 | $group = new CRM_Contact_BAO_Group(); |
| 41 | $cnt = sprintf('%05d', $i); |
| 42 | $alphabet = mt_rand(97, 122); |
| 43 | $group->name = $group->title = chr($alphabet) . ": $prefix $cnt"; |
| 44 | $group->is_active = 1; |
| 45 | |
| 46 | $v = mt_rand(0, 1); |
| 47 | $group->visibility = $visibility[$v]; |
| 48 | |
| 49 | $t = mt_rand(0, 3); |
| 50 | $group->group_type = $groupType[$t]; |
| 51 | |
| 52 | $group->save(); |
| 53 | |
| 54 | } |