protected function btnUnsubscribe_Click() { $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($this->txtEmail->Text); $objEmailArray = Email::LoadArrayByAddress($this->txtEmail->Text); foreach ($objEmailArray as $objEmail) { $objPerson = Person::LoadByPrimaryEmailId($objEmail->Id); if ($objPerson != null) { $strUnsubscribedList = ''; $success = false; foreach ($this->chkBtnListArray as $objItem) { if ($objItem->Checked) { $this->objList = CommunicationList::LoadByToken($objItem->Name); if ($this->objList) { $bFound = false; if ($this->objList->IsPersonAssociated($objPerson)) { $this->objList->UnassociatePerson($objPerson); // If church newletter is the one being unsubscribed, document reason. if ($this->lstTerminationReason->SelectedValue == -1) { $objAttributeOption = new AttributeOption(); $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId; $objAttributeOption->Name = trim($this->txtOther->Text); $objAttributeOption->Save(); $objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->objAttribute->Id, $objPerson->Id); if ($objAttributeValue) { $objAttributeValue->SingleAttributeOption = $objAttributeOption; $objAttributeValue->Save(); } else { $objAttributeValue = new AttributeValue(); $objAttributeValue->AttributeId = $this->objAttribute->Id; $objAttributeValue->PersonId = $objPerson->Id; $objAttributeValue->SingleAttributeOption = $objAttributeOption; $objAttributeValue->Save(); $objPerson->AssociateAttributeValue($objAttributeValue); } } else { $objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->objAttribute->Id, $objPerson->Id); if ($objAttributeValue) { $objAttributeValue->SingleAttributeOptionId = $this->lstTerminationReason->SelectedValue; $objAttributeValue->Save(); } else { $objAttributeValue = new AttributeValue(); $objAttributeValue->AttributeId = $this->objAttribute->Id; $objAttributeValue->PersonId = $objPerson->Id; $objAttributeValue->SingleAttributeOptionId = $this->lstTerminationReason->SelectedValue; $objAttributeValue->Save(); $objPerson->AssociateAttributeValue($objAttributeValue); } } $strUnsubscribedList .= $objItem->Text . ','; $success = true; $bFound = true; } if (!$bFound) { $this->lblMessage->Text = '(Person Entry) You cannot Unsubscribe because you are not subscribed to the ' . $objItem->Text . ' Mailing List.'; $this->lblMessage->Visible = true; } } } } if ($success) { $strUnsubscribedList = substr($strUnsubscribedList, 0, strlen($strUnsubscribedList) - 1); QApplication::Redirect('/unsubscribe/success.php/' . urlencode($strUnsubscribedList) . '/' . $objPerson->Id); } } } if ($objCommunicationListEntry) { $strUnsubscribedList = ''; $success = false; $bChecked = false; foreach ($this->chkBtnListArray as $objItem) { if ($objItem->Checked) { $this->objList = CommunicationList::LoadByToken($objItem->Name); if ($this->objList) { $bFound = false; if ($objCommunicationListEntry != null) { if ($this->objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) { $this->objList->UnassociateCommunicationListEntry($objCommunicationListEntry); $strUnsubscribedList .= $objItem->Text . ','; $success = true; $bFound = true; } } if (!$bFound) { $this->lblMessage->Text = '(CommunicationsEntry) You cannot Unsubscribe because you are not subscribed to the ' . $objItem->Text . ' Mailing List.'; $this->lblMessage->Visible = true; } } } } if ($success) { $strUnsubscribedList = substr($strUnsubscribedList, 0, strlen($strUnsubscribedList) - 1); QApplication::Redirect('/unsubscribe/success.php/' . urlencode($strUnsubscribedList)); } } $bChecked = false; foreach ($this->chkBtnListArray as $objItem) { if ($objItem->Checked) { $bChecked = true; break; } } if (!$bChecked) { $this->lblMessage->Text = 'You must select a list to subscribe to.'; $this->lblMessage->Visible = true; } else { $this->lblMessage->Text = 'Failed to unsubscribe from the list. The email may not exist.'; $this->lblMessage->Visible = true; } }
/** * Merges two records together. * @param Person $objPersonMergeWith * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's */ public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails) { QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right')); Person::GetDatabase()->TransactionBegin(); // Household Participation Records if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) { $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this); } else { if ($this->HouseholdAsHead) { // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge this head of household with a person record that exists in other households'); } else { $objHouseholdParticipation->Delete(); } } } else { if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) { // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households'); } else { $objHouseholdParticipation->Delete(); } } $objHousehold->HeadPerson = $this; $objHousehold->Save(); $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id); $objParticipation->PersonId = $this->Id; $objParticipation->Save(); } else { // Otherwise: members of multiple households! but head of none foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) { $objHouseholdParticipation->Delete(); } else { $objHouseholdParticipation->PersonId = $this->Id; $objHouseholdParticipation->Save(); } } } } } if (!$blnUseThisDetails) { $this->FirstName = $objPersonMergeWith->FirstName; $this->MiddleName = $objPersonMergeWith->MiddleName; $this->LastName = $objPersonMergeWith->LastName; $this->MailingLabel = $objPersonMergeWith->MailingLabel; $this->PriorLastNames = $objPersonMergeWith->PriorLastNames; $this->Nickname = $objPersonMergeWith->Nickname; $this->Title = $objPersonMergeWith->Title; $this->Suffix = $objPersonMergeWith->Suffix; $this->Gender = $objPersonMergeWith->Gender; $this->DateOfBirth = $objPersonMergeWith->DateOfBirth; $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag; $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag; $this->Age = $objPersonMergeWith->Age; $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag; $this->DateDeceased = $objPersonMergeWith->DateDeceased; } // Attributes foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) { // Check for double-defined attributes if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) { if ($blnUseThisDetails) { $objAttributeValue->Delete(); } else { $objDoubleDefinedAttribute->Delete(); $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } // Nothing double-defined -- just move it over! } else { $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } } // Comments foreach ($objPersonMergeWith->GetCommentArray() as $objComment) { $objComment->PersonId = $this->Id; $objComment->Save(); } // Memberships foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) { $objMembership->PersonId = $this->Id; $objMembership->Save(); } // Communication Lists foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) { $objPersonMergeWith->UnassociateCommunicationList($objCommList); if (!$this->IsCommunicationListAssociated($objCommList)) { $this->AssociateCommunicationList($objCommList); } } // Head Shots foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) { $objHeadShot->PersonId = $this->Id; $objHeadShot->Save(); } // Group Participation foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) { $objGroupParticipation->PersonId = $this->Id; $objGroupParticipation->Save(); } // NameItemAssn $objPersonMergeWith->UnassociateAllNameItems(); // Marrriage Records foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } // Family Relationships foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) { $this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) { $this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } // Phones foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Addresses foreach ($objPersonMergeWith->GetAddressArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Email foreach ($objPersonMergeWith->GetEmailArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Other Contact Info foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Checking Account Lookups foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) { $objPersonMergeWith->UnassociateCheckingAccountLookup($objCheckingAccount); if (!$this->IsCheckingAccountLookupAssociated($objCheckingAccount)) { $this->AssociateCheckingAccountLookup($objCheckingAccount); } } // Stewardship Contributions foreach ($objPersonMergeWith->GetStewardshipContributionArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Stewardship Pledges foreach ($objPersonMergeWith->GetStewardshipPledgeArray() as $objPledge) { // Check for double-defined pledge if ($objDoubleDefinedPledge = StewardshipPledge::LoadByPersonIdStewardshipFundId($this->Id, $objPledge->StewardshipFundId)) { if ($blnUseThisDetails) { $objPledge->Delete(); } else { $objDoubleDefinedPledge->Delete(); $objPledge->PersonId = $this->Id; $objPledge->Save(); } // Nope, just move it over like normal } else { $objPledge->PersonId = $this->Id; $objPledge->Save(); } } // Online Donations foreach ($objPersonMergeWith->GetOnlineDonationArray() as $objOnlineDonation) { $objOnlineDonation->PersonId = $this->Id; $objOnlineDonation->Save(); } // Public Login if ($objPublicLogin = $objPersonMergeWith->PublicLogin) { $objPublicLogin->PersonId = $this->Id; $objPublicLogin->Save(); } // Events and Classes foreach ($objPersonMergeWith->GetSignupEntryArray() as $objSignupEntry) { $objSignupEntry->PersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetSignupEntryAsSignupByArray() as $objSignupEntry) { $objSignupEntry->SignupByPersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetClassRegistrationArray() as $objClassRegistration) { $objClassRegistration->PersonId = $this->Id; $objClassRegistration->Save(); } // Stewardship Post Line Items foreach ($objPersonMergeWith->GetStewardshipPostLineItemArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Email Message Route foreach ($objPersonMergeWith->GetEmailMessageRouteArray() as $objEmailMessageRoute) { $objEmailMessageRoute->PersonId = $this->Id; $objEmailMessageRoute->Save(); } // Search Query foreach ($objPersonMergeWith->GetSearchQueryArray() as $objSearchQuery) { $objSearchQuery->PersonId = $this->Id; $objSearchQuery->Save(); } // Final Refresh/Cleanup $this->RefreshAge(false); $this->RefreshMaritalStatusTypeId(false); $this->RefreshMembershipStatusTypeId(false); $this->RefreshPrimaryContactInfo(false); $this->Save(); $this->RefreshNameItemAssociations(); $objPersonMergeWith->Delete(); Person::GetDatabase()->TransactionCommit(); }
protected function SetupPanel() { $this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->strUrlHashArgument, $this->objPerson->Id); if (!$this->objAttributeValue) { $this->objAttributeValue = new AttributeValue(); $this->objAttributeValue->AttributeId = $this->strUrlHashArgument; $this->objAttributeValue->Person = $this->objPerson; } else { $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this attribute?')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) { case AttributeDataType::Checkbox: $this->chkValue = new QRadioButtonList($this); $this->chkValue->Name = $this->objAttributeValue->Attribute->Name; $this->chkValue->Required = true; $this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true); $this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false); break; case AttributeDataType::Date: case AttributeDataType::DateTime: $this->dtxValue = new QDateTimeTextBox($this); $this->dtxValue->Name = $this->objAttributeValue->Attribute->Name; $this->dtxValue->Required = true; if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) { $this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null; } else { $this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null; } $this->calValue = new QCalendar($this, $this->dtxValue); $this->dtxValue->RemoveAllActions(QClickEvent::EventName); break; case AttributeDataType::Text: $this->txtValue = new QTextBox($this); $this->txtValue->Name = $this->objAttributeValue->Attribute->Name; $this->txtValue->Required = true; $this->txtValue->TextMode = QTextMode::MultiLine; $this->txtValue->Text = trim($this->objAttributeValue->TextValue); $this->txtValue->FontNames = QFontFamily::Arial; $this->txtValue->FontSize = '11px'; $this->txtValue->Width = '400px'; $this->txtValue->Height = '200px'; break; case AttributeDataType::ImmutableSingleDropdown: $this->lstValue = new QListBox($this); $this->lstValue->Name = $this->objAttributeValue->Attribute->Name; $this->lstValue->Required = true; if (!$this->objAttributeValue->SingleAttributeOptionId) { $this->lstValue->AddItem('- Select One -'); } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId); } break; case AttributeDataType::ImmutableMultipleDropdown: $this->lstValue = new QListBox($this); $this->lstValue->Name = $this->objAttributeValue->Attribute->Name; $this->lstValue->Required = true; $this->lstValue->SelectionMode = QSelectionMode::Multiple; $this->lstValue->Width = '200px'; $this->lstValue->Height = '200px'; $intSelectedIdArray = array(); if ($this->objAttributeValue->Id) { foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) { $intSelectedIdArray[$objOption->Id] = $objOption->Id; } } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray)); } break; case AttributeDataType::MutableSingleDropdown: $this->lstValue = new QListBox($this); $this->lstValue->Name = $this->objAttributeValue->Attribute->Name; $this->lstValue->Required = true; if (!$this->objAttributeValue->SingleAttributeOptionId) { $this->lstValue->AddItem('- Select One -'); } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId); } $this->lstValue->AddItem('- Other... -', -1); $this->txtAddItem = new QTextBox($this); $this->txtAddItem->Name = 'Add a Value'; $this->txtAddItem->Visible = false; $this->lstValue->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstValue_Change')); $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction()); break; case AttributeDataType::MutableMultipleDropdown: $this->lstValue = new QListBox($this); $this->lstValue->Name = $this->objAttributeValue->Attribute->Name; $this->lstValue->Required = true; $this->lstValue->SelectionMode = QSelectionMode::Multiple; $this->lstValue->Width = '200px'; $this->lstValue->Height = '200px'; $intSelectedIdArray = array(); if ($this->objAttributeValue->Id) { foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) { $intSelectedIdArray[$objOption->Id] = $objOption->Id; } } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray)); } $this->txtAddItem = new QTextBox($this); $this->txtAddItem->Name = 'Add a Value'; $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, 'txtAddItem_Enter')); $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction()); break; default: throw new Exception('Unhandled AttributeDataTypeId: ' . $this->objAttributeValue->Attribute->AttributeDataTypeId); } }
public function btnEditAttribute_Click($strFormId, $strControlId, $strParameter) { $paramArray = explode("_", $strParameter); // First, remove all children panels from pnlRight $this->pnlRight->Display = "block"; $this->pnlRight->DisplayStyle = "block"; $this->pnlRight->RemoveChildControls(true); // Determine where to display the panel $range = 1; if ($paramArray[3] < 5) { $range = 1; } elseif ($paramArray[3] < 15) { $range = 2; } else { $range = 3; } $height = $this->iAttributeCount / $range * 35; $this->strAttributeHeight = sprintf("-%dpx", $height); $this->pnlRight->Top = $this->strAttributeHeight; // Now create a new AttributeEditPanel, setting pnlRight as its parent // and specifying parent form's "CloseRightPanel" as the method callback // See the note in _constructor, above, for more information /*new Vicp_Attributes_Edit($this->pnlRight, null, $this->objPerson,$this->strUrlHashArgument);*/ // Test to see if it works // Special case for Co-Primary. If co-primary, then ensure there is a date of birth if ($paramArray[2] == 'Co-Primary' && !$this->objPerson->DateOfBirth) { $this->lblTitle = new QLabel($this->pnlRight); $this->lblTitle->HtmlEntities = false; $this->lblTitle->Text = "You cannot specify a Co-primary email unless the person has a Date Of Birth specified. <br>Please ensure that this is the case before setting this attribute."; } else { $this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($strParameter, $this->objPerson->Id); if (!$this->objAttributeValue) { $this->objAttributeValue = new AttributeValue(); $this->objAttributeValue->AttributeId = $paramArray[0]; $this->objAttributeValue->Person = $this->objPerson; $this->objAttributeValue->Attribute = Attribute::Load($paramArray[0]); } // Determine what to display $this->lblTitle = new QLabel($this->pnlRight); $this->lblTitle->Text = $paramArray[2]; if ($paramArray[2] == 'Co-Primary') { $this->lblTitle->HtmlEntities = false; $this->lblTitle->Text .= '<br>Please not that the Co-Primary email entered MUST be an existing person in noah.'; } $this->lblTitle->CssClass = 'attributeLbl'; switch ($paramArray[1]) { case AttributeDataType::Checkbox: $this->chkValue = new QRadioButtonList($this->pnlRight); $this->chkValue->Name = $paramArray[2]; $this->chkValue->Required = true; $this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true); $this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false); break; case AttributeDataType::Date: case AttributeDataType::DateTime: $this->dtxValue = new QDateTimeTextBox($this->pnlRight); $this->dtxValue->Name = $paramArray[2]; $this->dtxValue->Required = true; $this->calValue = new QCalendar($this->pnlRight, $this->dtxValue); $this->dtxValue->RemoveAllActions(QClickEvent::EventName); if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) { $this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null; } else { $this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null; } break; case AttributeDataType::Text: $this->txtValue = new QTextBox($this->pnlRight); $this->txtValue->Name = $paramArray[2]; $this->txtValue->Required = true; $this->txtValue->TextMode = QTextMode::MultiLine; $this->txtValue->Text = trim($this->objAttributeValue->TextValue); $this->txtValue->FontNames = QFontFamily::Arial; $this->txtValue->FontSize = '11px'; $this->txtValue->Width = '380px'; $this->txtValue->Height = '200px'; break; case AttributeDataType::ImmutableSingleDropdown: $this->lstValue = new QListBox($this->pnlRight); $this->lstValue->Name = $paramArray[2]; $this->lstValue->Required = true; if (!$this->objAttributeValue->SingleAttributeOptionId) { $this->lstValue->AddItem('- Select One -'); } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId); } break; case AttributeDataType::ImmutableMultipleDropdown: $this->lstValue = new QListBox($this->pnlRight); $this->lstValue->Name = $paramArray[2]; $this->lstValue->Required = true; $this->lstValue->SelectionMode = QSelectionMode::Multiple; $this->lstValue->Width = '200px'; $this->lstValue->Height = '200px'; $intSelectedIdArray = array(); if ($this->objAttributeValue->Id) { foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) { $intSelectedIdArray[$objOption->Id] = $objOption->Id; } } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray)); } break; case AttributeDataType::MutableSingleDropdown: $this->lstValue = new QListBox($this->pnlRight); $this->lstValue->Name = $paramArray[2]; $this->lstValue->Required = true; foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId); } $this->lstValue->AddItem('- Other... -', -1); $this->txtAddItem = new QTextBox($this->pnlRight); $this->txtAddItem->Name = 'Add a Value'; $this->txtAddItem->Visible = false; $this->lstValue->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstValue_Change')); $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction()); break; case AttributeDataType::MutableMultipleDropdown: $this->lstValue = new QListBox($this->pnlRight); $this->lstValue->Name = $paramArray[2]; $this->lstValue->Required = true; $this->lstValue->SelectionMode = QSelectionMode::Multiple; $this->lstValue->Width = '200px'; $this->lstValue->Height = '200px'; $intSelectedIdArray = array(); if ($this->objAttributeValue->Id) { foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) { $intSelectedIdArray[$objOption->Id] = $objOption->Id; } } foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray)); } $this->txtAddItem = new QTextBox($this->pnlRight); $this->txtAddItem->Name = 'Add a Value'; $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, 'txtAddItem_Enter')); $this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction()); break; default: throw new Exception('Unhandled AttributeDataTypeId: ' . $this->objAttributeValue->Attribute->AttributeDataTypeId); } // Add a save button $this->btnSaveEdit = new QButton($this->pnlRight); $this->btnSaveEdit->Text = 'Save'; $this->btnSaveEdit->CssClass = 'attributeBtn'; $this->btnSaveEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSaveEdit_Click')); $this->btnSaveEdit->CausesValidation = $this; } }