public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) {
         case AttributeDataType::Checkbox:
             $this->objAttributeValue->BooleanValue = $this->chkValue->SelectedValue;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::Date:
             $this->objAttributeValue->DateValue = $this->dtxValue->DateTime;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::DateTime:
             $this->objAttributeValue->DatetimeValue = $this->dtxValue->DateTime;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::Text:
             $this->objAttributeValue->TextValue = trim($this->txtValue->Text);
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::ImmutableSingleDropdown:
             $this->objAttributeValue->SingleAttributeOptionId = $this->lstValue->SelectedValue;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::ImmutableMultipleDropdown:
             $this->objAttributeValue->Save();
             $this->objAttributeValue->UnassociateAllAttributeOptionsAsMultiple();
             foreach ($this->lstValue->SelectedValues as $intOptionId) {
                 $this->objAttributeValue->AssociateAttributeOptionAsMultiple(AttributeOption::Load($intOptionId));
             }
             break;
         case AttributeDataType::MutableSingleDropdown:
             if ($this->lstValue->SelectedValue == -1) {
                 $objAttributeOption = new AttributeOption();
                 $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId;
                 $objAttributeOption->Name = trim($this->txtAddItem->Text);
                 $objAttributeOption->Save();
                 $this->objAttributeValue->SingleAttributeOption = $objAttributeOption;
                 $this->objAttributeValue->Save();
             } else {
                 $this->objAttributeValue->SingleAttributeOptionId = $this->lstValue->SelectedValue;
                 $this->objAttributeValue->Save();
             }
             break;
         case AttributeDataType::MutableMultipleDropdown:
             $this->objAttributeValue->Save();
             $this->objAttributeValue->UnassociateAllAttributeOptionsAsMultiple();
             foreach ($this->lstValue->SelectedItems as $objListItem) {
                 $intOptionId = $objListItem->Value;
                 if ($intOptionId > 0) {
                     $this->objAttributeValue->AssociateAttributeOptionAsMultiple(AttributeOption::Load($intOptionId));
                 } else {
                     if ($objListItem->Selected) {
                         $objAttributeOption = new AttributeOption();
                         $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId;
                         $objAttributeOption->Name = $objListItem->Name;
                         $objAttributeOption->Save();
                         $this->objAttributeValue->AssociateAttributeOptionAsMultiple($objAttributeOption);
                     }
                 }
             }
             break;
         default:
             throw new Exception('Unhandled AttributeDataTypeId: ' . $this->objAttributeValue->Attribute->AttributeDataTypeId);
     }
     return $this->ReturnTo('#attributes');
 }
Beispiel #2
0
 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;
     }
 }
Beispiel #3
0
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $this->mctAttribute->SaveAttribute();
     if ($this->pnlAttributeOptions) {
         foreach ($this->pnlAttributeOptions->GetChildControls() as $txtAttributeOption) {
             if ($txtAttributeOption->ActionParameter) {
                 $objAttributeOption = AttributeOption::Load($txtAttributeOption->ActionParameter);
                 if ($objAttributeOption->AttributeId != $this->mctAttribute->Attribute->Id) {
                     throw new Exception('Unlinked Attribute Option Found');
                 }
                 if ($objAttributeOption->Name != trim($txtAttributeOption->Text)) {
                     $objAttributeOption->Name = trim($txtAttributeOption->Text);
                     $objAttributeOption->Save();
                 }
             } else {
                 if ($strOptionName = trim($txtAttributeOption->Text)) {
                     $objAttributeOption = new AttributeOption();
                     $objAttributeOption->Attribute = $this->mctAttribute->Attribute;
                     $objAttributeOption->Name = $strOptionName;
                     $objAttributeOption->Save();
                 }
             }
         }
     }
     $this->ReturnToList();
 }