public function btnSave_Click($strFormId, $strControlId, $strParameter) { //Create New Group from information stored in mctGroup $objCloneGroup = new Group(); // Update any fields for controls that have been created if ($this->mctGroup->GroupTypeIdControl) { $objCloneGroup->GroupTypeId = $this->mctGroup->GroupTypeIdControl->SelectedValue; } if ($this->mctGroup->MinistryIdControl) { $objCloneGroup->MinistryId = $this->mctGroup->MinistryIdControl->SelectedValue; } if ($this->mctGroup->NameControl) { $objCloneGroup->Name = $this->mctGroup->NameControl->Text; } if ($this->mctGroup->DescriptionControl) { $objCloneGroup->Description = $this->mctGroup->DescriptionControl->Text; } if ($this->mctGroup->ParentGroupIdControl) { $objCloneGroup->ParentGroupId = $this->mctGroup->ParentGroupIdControl->SelectedValue; } if ($this->mctGroup->HierarchyLevelControl) { $objCloneGroup->HierarchyLevel = $this->mctGroup->HierarchyLevelControl->Text; } if ($this->mctGroup->HierarchyOrderNumberControl) { $objCloneGroup->HierarchyOrderNumber = $this->mctGroup->HierarchyOrderNumberControl->Text; } if ($this->mctGroup->ConfidentialFlagControl) { $objCloneGroup->ConfidentialFlag = $this->mctGroup->ConfidentialFlagControl->Checked; } if ($this->mctGroup->EmailBroadcastTypeIdControl) { $objCloneGroup->EmailBroadcastTypeId = $this->mctGroup->EmailBroadcastTypeIdControl->SelectedValue; } if ($this->mctGroup->TokenControl) { $objCloneGroup->Token = $this->mctGroup->TokenControl->Text; } if ($this->mctGroup->ActiveFlagControl) { $objCloneGroup->ActiveFlag = $this->mctGroup->ActiveFlagControl->Checked; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->mctGroup->GroupCategoryControl) { $objCloneGroup->GroupCategory = GroupCategory::Load($this->mctGroup->GroupCategoryControl->SelectedValue); } if ($this->mctGroup->GrowthGroupControl) { $objCloneGroup->GrowthGroup = GrowthGroup::Load($this->mctGroup->GrowthGroupControl->SelectedValue); } if ($this->mctGroup->SmartGroupControl) { $objCloneGroup->SmartGroup = SmartGroup::Load($this->mctGroup->SmartGroupControl->SelectedValue); } // Save the Cloned Group object $objCloneGroup->Save(); // Get Participation List and propogate it $objGroupParticipationArray = $this->mctGroup->Group->GetActiveGroupParticipationArray(); foreach ($objGroupParticipationArray as $objGroupParticipation) { $objCloneGroup->AddPerson(Person::Load($objGroupParticipation->PersonId), $objGroupParticipation->GroupRoleId); } Group::RefreshHierarchyDataForMinistry($objCloneGroup->MinistryId); $this->objForm->pnlGroups_Refresh(); // Go to new Group. $this->ReturnTo('#' . $objCloneGroup->Id); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this GroupCategoryMetaControl * @param integer $intGroupId primary key value * @param QMetaControlCreateType $intCreateType rules governing GroupCategory object creation - defaults to CreateOrEdit * @return GroupCategoryMetaControl */ public static function Create($objParentObject, $intGroupId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intGroupId)) { $objGroupCategory = GroupCategory::Load($intGroupId); // GroupCategory was found -- return it! if ($objGroupCategory) { return new GroupCategoryMetaControl($objParentObject, $objGroupCategory); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a GroupCategory object with PK arguments: ' . $intGroupId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new GroupCategoryMetaControl($objParentObject, new GroupCategory()); }
/** * Reload this GroupCategory from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved GroupCategory object.'); } // Reload the Object $objReloaded = GroupCategory::Load($this->intGroupId); // Update $this's local variables to match $this->GroupId = $objReloaded->GroupId; $this->__intGroupId = $this->intGroupId; $this->dttDateRefreshed = $objReloaded->dttDateRefreshed; $this->intProcessTimeMs = $objReloaded->intProcessTimeMs; }
/** * This will save this object's Group instance, * updating only the fields which have had a control created for it. */ public function SaveGroup() { try { // Update any fields for controls that have been created if ($this->lstGroupType) { $this->objGroup->GroupTypeId = $this->lstGroupType->SelectedValue; } if ($this->lstMinistry) { $this->objGroup->MinistryId = $this->lstMinistry->SelectedValue; } if ($this->txtName) { $this->objGroup->Name = $this->txtName->Text; } if ($this->txtDescription) { $this->objGroup->Description = $this->txtDescription->Text; } if ($this->lstParentGroup) { $this->objGroup->ParentGroupId = $this->lstParentGroup->SelectedValue; } if ($this->txtHierarchyLevel) { $this->objGroup->HierarchyLevel = $this->txtHierarchyLevel->Text; } if ($this->txtHierarchyOrderNumber) { $this->objGroup->HierarchyOrderNumber = $this->txtHierarchyOrderNumber->Text; } if ($this->chkConfidentialFlag) { $this->objGroup->ConfidentialFlag = $this->chkConfidentialFlag->Checked; } if ($this->lstEmailBroadcastType) { $this->objGroup->EmailBroadcastTypeId = $this->lstEmailBroadcastType->SelectedValue; } if ($this->txtToken) { $this->objGroup->Token = $this->txtToken->Text; } if ($this->chkActiveFlag) { $this->objGroup->ActiveFlag = $this->chkActiveFlag->Checked; } if ($this->lstStatusObject) { $this->objGroup->Status = $this->lstStatusObject->SelectedValue; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstGroupCategory) { $this->objGroup->GroupCategory = GroupCategory::Load($this->lstGroupCategory->SelectedValue); } if ($this->lstGrowthGroup) { $this->objGroup->GrowthGroup = GrowthGroup::Load($this->lstGrowthGroup->SelectedValue); } if ($this->lstSmartGroup) { $this->objGroup->SmartGroup = SmartGroup::Load($this->lstSmartGroup->SelectedValue); } // Save the Group object $this->objGroup->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }