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 SmartGroupMetaControl * @param integer $intGroupId primary key value * @param QMetaControlCreateType $intCreateType rules governing SmartGroup object creation - defaults to CreateOrEdit * @return SmartGroupMetaControl */ public static function Create($objParentObject, $intGroupId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intGroupId)) { $objSmartGroup = SmartGroup::Load($intGroupId); // SmartGroup was found -- return it! if ($objSmartGroup) { return new SmartGroupMetaControl($objParentObject, $objSmartGroup); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a SmartGroup 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 SmartGroupMetaControl($objParentObject, new SmartGroup()); }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'Id': // Gets the value for intId (Read-Only PK) // @return integer return $this->intId; case 'Description': // Gets the value for strDescription // @return string return $this->strDescription; case 'SmartGroupId': // Gets the value for intSmartGroupId (Unique) // @return integer return $this->intSmartGroupId; case 'PersonId': // Gets the value for intPersonId // @return integer return $this->intPersonId; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'SmartGroup': // Gets the value for the SmartGroup object referenced by intSmartGroupId (Unique) // @return SmartGroup try { if (!$this->objSmartGroup && !is_null($this->intSmartGroupId)) { $this->objSmartGroup = SmartGroup::Load($this->intSmartGroupId); } return $this->objSmartGroup; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Person': // Gets the value for the Person object referenced by intPersonId // @return Person try { if (!$this->objPerson && !is_null($this->intPersonId)) { $this->objPerson = Person::Load($this->intPersonId); } return $this->objPerson; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '_QueryCondition': // Gets the value for the private _objQueryCondition (Read-Only) // if set due to an expansion on the query_condition.search_query_id reverse relationship // @return QueryCondition return $this->_objQueryCondition; case '_QueryConditionArray': // Gets the value for the private _objQueryConditionArray (Read-Only) // if set due to an ExpandAsArray on the query_condition.search_query_id reverse relationship // @return QueryCondition[] return (array) $this->_objQueryConditionArray; case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * Reload this SmartGroup 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 SmartGroup object.'); } // Reload the Object $objReloaded = SmartGroup::Load($this->intGroupId); // Update $this's local variables to match $this->GroupId = $objReloaded->GroupId; $this->__intGroupId = $this->intGroupId; $this->strQuery = $objReloaded->strQuery; $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; } }