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); }
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; } }
<?php /** * Run at explicit times to "clear" group participation lists, which would then cause the groups-participation-calculate to * re-refresh the lists for all groups */ SmartGroup::ForceRefreshParticipations(); GroupCategory::ForceRefreshParticipations();
/** * Refresh this MetaControl with Data from the local SearchQuery object. * @param boolean $blnReload reload SearchQuery from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objSearchQuery->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objSearchQuery->Id; } } if ($this->txtDescription) { $this->txtDescription->Text = $this->objSearchQuery->Description; } if ($this->lblDescription) { $this->lblDescription->Text = $this->objSearchQuery->Description; } if ($this->lstSmartGroup) { $this->lstSmartGroup->RemoveAllItems(); $this->lstSmartGroup->AddItem(QApplication::Translate('- Select One -'), null); $objSmartGroupArray = SmartGroup::LoadAll(); if ($objSmartGroupArray) { foreach ($objSmartGroupArray as $objSmartGroup) { $objListItem = new QListItem($objSmartGroup->__toString(), $objSmartGroup->GroupId); if ($this->objSearchQuery->SmartGroup && $this->objSearchQuery->SmartGroup->GroupId == $objSmartGroup->GroupId) { $objListItem->Selected = true; } $this->lstSmartGroup->AddItem($objListItem); } } } if ($this->lblSmartGroupId) { $this->lblSmartGroupId->Text = $this->objSearchQuery->SmartGroup ? $this->objSearchQuery->SmartGroup->__toString() : null; } if ($this->lstPerson) { $this->lstPerson->RemoveAllItems(); $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null); $objPersonArray = Person::LoadAll(); if ($objPersonArray) { foreach ($objPersonArray as $objPerson) { $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id); if ($this->objSearchQuery->Person && $this->objSearchQuery->Person->Id == $objPerson->Id) { $objListItem->Selected = true; } $this->lstPerson->AddItem($objListItem); } } } if ($this->lblPersonId) { $this->lblPersonId->Text = $this->objSearchQuery->Person ? $this->objSearchQuery->Person->__toString() : null; } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, SmartGroup::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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()); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objSmartGroup) { $objObject->objSmartGroup = SmartGroup::GetSoapObjectFromObject($objObject->objSmartGroup, false); } else { if (!$blnBindRelatedObjects) { $objObject->intSmartGroupId = null; } } if ($objObject->objPerson) { $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPersonId = null; } } return $objObject; }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = SmartGroup::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from SmartGroup, given the clauses above $this->DataSource = SmartGroup::QueryArray($objCondition, $objClauses); }
/** * 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 'GroupTypeId': // Gets the value for intGroupTypeId (Not Null) // @return integer return $this->intGroupTypeId; case 'MinistryId': // Gets the value for intMinistryId (Not Null) // @return integer return $this->intMinistryId; case 'Name': // Gets the value for strName // @return string return $this->strName; case 'Description': // Gets the value for strDescription // @return string return $this->strDescription; case 'ParentGroupId': // Gets the value for intParentGroupId // @return integer return $this->intParentGroupId; case 'HierarchyLevel': // Gets the value for intHierarchyLevel // @return integer return $this->intHierarchyLevel; case 'HierarchyOrderNumber': // Gets the value for intHierarchyOrderNumber // @return integer return $this->intHierarchyOrderNumber; case 'ConfidentialFlag': // Gets the value for blnConfidentialFlag // @return boolean return $this->blnConfidentialFlag; case 'EmailBroadcastTypeId': // Gets the value for intEmailBroadcastTypeId // @return integer return $this->intEmailBroadcastTypeId; case 'Token': // Gets the value for strToken (Unique) // @return string return $this->strToken; case 'ActiveFlag': // Gets the value for blnActiveFlag // @return boolean return $this->blnActiveFlag; case 'Status': // Gets the value for intStatus // @return integer return $this->intStatus; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Ministry': // Gets the value for the Ministry object referenced by intMinistryId (Not Null) // @return Ministry try { if (!$this->objMinistry && !is_null($this->intMinistryId)) { $this->objMinistry = Ministry::Load($this->intMinistryId); } return $this->objMinistry; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ParentGroup': // Gets the value for the Group object referenced by intParentGroupId // @return Group try { if (!$this->objParentGroup && !is_null($this->intParentGroupId)) { $this->objParentGroup = Group::Load($this->intParentGroupId); } return $this->objParentGroup; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'StatusObject': // Gets the value for the AvailabilityStatus object referenced by intStatus // @return AvailabilityStatus try { if (!$this->objStatusObject && !is_null($this->intStatus)) { $this->objStatusObject = AvailabilityStatus::Load($this->intStatus); } return $this->objStatusObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'GroupCategory': // Gets the value for the GroupCategory object that uniquely references this Group // by objGroupCategory (Unique) // @return GroupCategory try { if ($this->objGroupCategory === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objGroupCategory) { $this->objGroupCategory = GroupCategory::LoadByGroupId($this->intId); } return $this->objGroupCategory; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'GrowthGroup': // Gets the value for the GrowthGroup object that uniquely references this Group // by objGrowthGroup (Unique) // @return GrowthGroup try { if ($this->objGrowthGroup === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objGrowthGroup) { $this->objGrowthGroup = GrowthGroup::LoadByGroupId($this->intId); } return $this->objGrowthGroup; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'SmartGroup': // Gets the value for the SmartGroup object that uniquely references this Group // by objSmartGroup (Unique) // @return SmartGroup try { if ($this->objSmartGroup === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objSmartGroup) { $this->objSmartGroup = SmartGroup::LoadByGroupId($this->intId); } return $this->objSmartGroup; } 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 '_EmailMessageRoute': // Gets the value for the private _objEmailMessageRoute (Read-Only) // if set due to an expansion on the email_message_route.group_id reverse relationship // @return EmailMessageRoute return $this->_objEmailMessageRoute; case '_EmailMessageRouteArray': // Gets the value for the private _objEmailMessageRouteArray (Read-Only) // if set due to an ExpandAsArray on the email_message_route.group_id reverse relationship // @return EmailMessageRoute[] return (array) $this->_objEmailMessageRouteArray; case '_ChildGroup': // Gets the value for the private _objChildGroup (Read-Only) // if set due to an expansion on the group.parent_group_id reverse relationship // @return Group return $this->_objChildGroup; case '_ChildGroupArray': // Gets the value for the private _objChildGroupArray (Read-Only) // if set due to an ExpandAsArray on the group.parent_group_id reverse relationship // @return Group[] return (array) $this->_objChildGroupArray; case '_GroupAuthorizedSender': // Gets the value for the private _objGroupAuthorizedSender (Read-Only) // if set due to an expansion on the group_authorized_sender.group_id reverse relationship // @return GroupAuthorizedSender return $this->_objGroupAuthorizedSender; case '_GroupAuthorizedSenderArray': // Gets the value for the private _objGroupAuthorizedSenderArray (Read-Only) // if set due to an ExpandAsArray on the group_authorized_sender.group_id reverse relationship // @return GroupAuthorizedSender[] return (array) $this->_objGroupAuthorizedSenderArray; case '_GroupParticipation': // Gets the value for the private _objGroupParticipation (Read-Only) // if set due to an expansion on the group_participation.group_id reverse relationship // @return GroupParticipation return $this->_objGroupParticipation; case '_GroupParticipationArray': // Gets the value for the private _objGroupParticipationArray (Read-Only) // if set due to an ExpandAsArray on the group_participation.group_id reverse relationship // @return GroupParticipation[] return (array) $this->_objGroupParticipationArray; case '_SmsMessage': // Gets the value for the private _objSmsMessage (Read-Only) // if set due to an expansion on the sms_message.group_id reverse relationship // @return SmsMessage return $this->_objSmsMessage; case '_SmsMessageArray': // Gets the value for the private _objSmsMessageArray (Read-Only) // if set due to an ExpandAsArray on the sms_message.group_id reverse relationship // @return SmsMessage[] return (array) $this->_objSmsMessageArray; case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
<?php /** * Ongoing service to ensure that any groups that are "flagged" for refresh get recalculated */ // Up the Memory Limit ini_set('memory_limit', '1024M'); // Ensure we are NOT running QApplication::CliProcessEnsureUnique(); // Setup a Lock File QApplication::CliProcessSetupLockFile(); // Run the Logic/Code while (QApplication::CliProcessIsLockFileValid()) { foreach (SmartGroup::QueryArray(QQ::IsNull(QQN::SmartGroup()->DateRefreshed)) as $objSmartGroup) { $objSmartGroup->RefreshParticipationList(); } foreach (GroupCategory::QueryArray(QQ::IsNull(QQN::GroupCategory()->DateRefreshed)) as $objGroupCategory) { $objGroupCategory->RefreshParticipationList(); } sleep(10); }
/** * 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; } }