public static function GenerateGroup(Ministry $objMinistry, Group $objParentGroup = null) { $strName = QDataGen::GenerateTitle(1, 4); $strToken = strtolower(str_replace(' ', '_', $strName)); while (Group::LoadByToken($strToken)) { $strName = QDataGen::GenerateTitle(1, 4); $strToken = strtolower(str_replace(' ', '_', $strName)); } $strDescription = QDataGen::GenerateContent(rand(0, 1), 5, 20); $intGroupTypeId = QDataGen::GenerateFromArray(array_keys(GroupType::$NameArray)); $objGroup = Group::CreateGroupForMinistry($objMinistry, $intGroupTypeId, $strName, $strDescription, $objParentGroup); // Set folder options $objGroup->ConfidentialFlag = !rand(0, 8); // Email if (!rand(0, 3)) { $objGroup->EmailBroadcastTypeId = QDataGen::GenerateFromArray(array_keys(EmailBroadcastType::$NameArray)); $objGroup->Token = $strToken; } $objGroup->Save(); switch ($objGroup->GroupTypeId) { case GroupType::GrowthGroup: $objGrowthGroup = new GrowthGroup(); $objGrowthGroup->Group = $objGroup; $objGrowthGroup->GrowthGroupLocationId = rand(1, GrowthGroupLocation::CountAll()); $objGrowthGroup->Save(); break; case GroupType::SmartGroup: $objSmartGroup = new SmartGroup(); $objSmartGroup->Group = $objGroup; $objSmartGroup->Save(); break; case GroupType::GroupCategory: $objGroupCategory = new GroupCategory(); $objGroupCategory->Group = $objGroup; $objGroupCategory->Save(); // Create Subgroups $intSubFolderCount = rand(0, 5); for ($intCount = 0; $intCount < $intSubFolderCount; $intCount++) { self::GenerateGroup($objMinistry, $objGroup); } break; } // Create Participants $objGroupRoleArray = GroupRole::LoadArrayByMinistryId($objMinistry->Id); switch ($objGroup->GroupTypeId) { case GroupType::GrowthGroup: case GroupType::RegularGroup: $intParticipantCount = rand(1, 8); for ($intIndex = 0; $intIndex < $intParticipantCount; $intIndex++) { $dttStartDate = QDataGen::GenerateDateTime(self::$SystemStartDate, QDateTime::Now()); $dttEndDate = rand(0, 4) ? null : QDataGen::GenerateDateTime($dttStartDate, QDateTime::Now()); $objGroup->AddPerson(Person::Load(rand(1, self::$MaxPersonId)), QDataGen::GenerateFromArray($objGroupRoleArray)->Id, $dttStartDate, $dttEndDate); } break; } }