Beispiel #1
0
 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;
     }
 }
Beispiel #2
0
    $objParentGroup = Group::CreateGroupForMinistry($objMinistry, GroupType::GroupCategory, trim($strTokens[0]), 'Growth Groups in ' . $objGrowthGroupLocation->Location);
    $objGroupCategory = new GroupCategory();
    $objGroupCategory->Group = $objParentGroup;
    $objGroupCategory->Save();
    $objGgResult = $objMySqli->Query('SELECT * FROM growth_group WHERE growth_group_location_id=' . $objRow['id'] . ' ORDER BY id');
    while ($objGgRow = $objGgResult->fetch_array()) {
        $objGroup = Group::CreateGroupForMinistry($objMinistry, GroupType::GrowthGroup, $objGgRow['name'], 'Growth Group for ' . $objGgRow['name'], $objParentGroup);
        $objGrowthGroup = new GrowthGroup();
        $objGrowthGroup->Group = $objGroup;
        $objGrowthGroup->GrowthGroupLocationId = $objGgRow['growth_group_location_id'];
        $objGrowthGroup->GrowthGroupDayTypeId = $objGgRow['growth_group_day_type_id'];
        $objGrowthGroup->MeetingBitmap = $objGgRow['meeting_bitmap'];
        $objGrowthGroup->StartTime = $objGgRow['start_time'];
        $objGrowthGroup->EndTime = $objGgRow['end_time'];
        $objGrowthGroup->Address1 = $objGgRow['address_1'];
        $objGrowthGroup->Address2 = $objGgRow['address_2'];
        $objGrowthGroup->CrossStreet1 = $objGgRow['cross_street_1'];
        $objGrowthGroup->CrossStreet2 = $objGgRow['cross_street_2'];
        $objGrowthGroup->ZipCode = $objGgRow['zip_code'];
        $objGrowthGroup->Longitude = $objGgRow['longitude'];
        $objGrowthGroup->Latitude = $objGgRow['latitude'];
        $objGrowthGroup->Accuracy = $objGgRow['accuracy'];
        $objGrowthGroup->Save();
        $objStructureResult = $objMySqli->Query('SELECT * FROM growthgroupstructure_growthgroup_assn where growth_group_id=' . $objGgRow['id']);
        while ($objStructureRow = $objStructureResult->fetch_array()) {
            $objGrowthGroup->AssociateGrowthGroupStructure(GrowthGroupStructure::Load($objStructureRow['growth_group_structure_id']));
        }
    }
}
$objMySqli->Close();
Group::RefreshHierarchyDataForMinistry($objMinistry->Id);