public function btnSave_Click()
 {
     $this->objPerson->MailingAddressId = $this->lstMailing->SelectedValue;
     $this->objPerson->StewardshipAddressId = $this->lstStewardship->SelectedValue;
     $this->objPerson->CanMailFlag = $this->lstCanMail->SelectedValue;
     $this->objPerson->CanEmailFlag = $this->lstCanEmail->SelectedValue;
     $this->objPerson->CanPhoneFlag = $this->lstCanPhone->SelectedValue;
     $this->objPerson->Save();
     // Check to see if we need to remove person from email.
     if (!$this->objPerson->CanEmailFlag) {
         $objList = CommunicationList::LoadByToken('allchurch_nl');
         // NOTE: this is the hard coded token of the congregational newsletter.
         if ($objList) {
             // Check communications list for an existing communications entry
             $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($this->objPerson->PrimaryEmail->Address);
             if ($objCommunicationListEntry) {
                 if ($objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) {
                     $objList->UnassociateCommunicationListEntry($objCommunicationListEntry);
                 }
             }
             //Check communications list for existing person entry
             if ($objList->IsPersonAssociated($this->objPerson)) {
                 $objList->UnassociatePerson($this->objPerson);
             }
         }
     }
     $this->objPerson->RefreshPrimaryContactInfo();
     QApplication::ExecuteJavaScript('document.location="#contact";');
 }
예제 #2
0
파일: index.php 프로젝트: alcf/chms
 protected function btnSubscribe_Click()
 {
     $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($this->txtEmail->Text);
     if (!$objCommunicationListEntry) {
         // create new entry and add to the communications list
         $objCommunicationListEntry = new CommunicationListEntry();
         $objCommunicationListEntry->Email = $this->txtEmail->Text;
         $objCommunicationListEntry->FirstName = $this->txtFirstName->Text;
         $objCommunicationListEntry->LastName = $this->txtLastName->Text;
         $objCommunicationListEntry->Save();
     }
     $strSubscribedList = '';
     $success = false;
     foreach ($this->chkBtnListArray as $objItem) {
         if ($objItem->Checked) {
             $this->objList = CommunicationList::LoadByToken($objItem->Name);
             if ($this->objList) {
                 if ($this->objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) {
                     $this->lblMessage->Text .= 'You are already subscribed to the "' . $objItem->Name . '" list';
                     $this->lblMessage->ForeColor = 'red';
                     $this->lblMessage->Visible = true;
                 } else {
                     // See if Person exists in Noah, and if so, then associate. Else associate the Communications Entry
                     $bFoundPerson = false;
                     $emailArray = Email::LoadArrayByAddress($this->txtEmail->Text);
                     foreach ($emailArray as $email) {
                         $objPerson = Person::LoadByPrimaryEmailId($email->Id);
                         if ($objPerson) {
                             if (!$this->objList->IsPersonAssociated($objPerson)) {
                                 $bFoundPerson = true;
                                 $this->objList->AssociatePerson($objPerson);
                             } else {
                                 $this->lblMessage->Text .= 'You are already subscribed to the "' . $objItem->Name . '" list';
                                 $this->lblMessage->ForeColor = 'red';
                                 $this->lblMessage->Visible = true;
                             }
                         }
                     }
                     if (!$bFoundPerson) {
                         $this->objList->AssociateCommunicationListEntry($objCommunicationListEntry);
                     }
                     $strSubscribedList .= $objItem->Name . ',';
                     $success = true;
                 }
             }
         } else {
             $this->lblMessage->Text .= 'You must select a list to subscribe to.';
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Visible = true;
         }
     }
     if ($success) {
         $strSubscribedList = substr($strSubscribedList, 0, strlen($strSubscribedList) - 1);
         // Send confirmation email here.
         $this->SendMessage($strSubscribedList);
         QApplication::Redirect('/subscribe/success.php/subscribed/' . urlencode($strSubscribedList));
     }
 }
예제 #3
0
파일: edit.php 프로젝트: alcf/chms
 public function btnSave_Click()
 {
     $strToken = QApplication::Tokenize($this->txtToken->Text);
     if (Group::LoadByToken($strToken) || ($objList = CommunicationList::LoadByToken($strToken)) && $objList->Id != $this->mctList->CommunicationList->Id) {
         $this->txtToken->Warning = 'Email Address is already taken';
         return;
     }
     $this->txtToken->Text = $strToken;
     $this->mctList->SaveCommunicationList();
     $this->RedirectToView();
 }
예제 #4
0
            $isFirst = false;
        } else {
            $strTokens = explode(',', trim($line));
            $firstName = $strTokens[0];
            $lastName = $strTokens[1];
            $email = $strTokens[2];
            $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($email);
            if (!$objCommunicationListEntry) {
                // If not found then create new entry and add to the communications list
                $objCommunicationListEntry = new CommunicationListEntry();
                $objCommunicationListEntry->Email = $email;
                $objCommunicationListEntry->FirstName = $firstName;
                $objCommunicationListEntry->LastName = $lastName;
                $objCommunicationListEntry->Save();
            }
            $objList = CommunicationList::LoadByToken($groupList);
            if ($objList) {
                if ($objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) {
                    print $email . " is already subscribed to the '" . $groupList . "' list\r\n";
                } else {
                    $objList->AssociateCommunicationListEntry($objCommunicationListEntry);
                    print "Added email: " . $email . "\n\r";
                }
            } else {
                print $groupList . " List could not be found. No entries added.\n\r";
            }
        }
    }
} else {
    exit(0);
}
예제 #5
0
파일: index.php 프로젝트: alcf/chms
 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;
     }
 }
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $this->objPerson->Title = $this->lstTitle->SelectedValue;
     $this->objPerson->FirstName = trim($this->txtFirstName->Text);
     $this->objPerson->MiddleName = trim($this->txtMiddleName->Text);
     $this->objPerson->LastName = trim($this->txtLastName->Text);
     $this->objPerson->Suffix = $this->lstSuffix->SelectedValue;
     $this->objPerson->Nickname = trim($this->txtNickname->Text);
     $this->objPerson->PriorLastNames = trim($this->txtPriorLastNames->Text);
     $this->objPerson->MailingLabel = trim($this->txtMailingLabel->Text);
     $this->objPerson->Gender = trim($this->lstGender->SelectedValue);
     // Date of Birth Stuff
     switch ($this->lstDateOfBirth->SelectedValue) {
         case self::DobNone:
             $this->objPerson->DateOfBirth = null;
             $this->objPerson->DobGuessedFlag = null;
             $this->objPerson->DobYearApproximateFlag = null;
             break;
         case self::DobExact:
             $this->objPerson->DateOfBirth = $this->dtxDateOfBirth->DateTime;
             $this->objPerson->DobGuessedFlag = false;
             $this->objPerson->DobYearApproximateFlag = false;
             break;
         case self::DobApproximateDay:
             if ($this->objPerson->DateOfBirth) {
                 $dttDate = new QDateTime($this->objPerson->DateOfBirth);
                 $dttDate->Year = QDateTime::Now()->Year;
                 if ($dttDate->IsLaterThan(QDateTime::Now())) {
                     $dttDate->Year -= 1;
                 }
             } else {
                 $dttDate = QDateTime::Now();
                 $dttDate->Month -= 6;
             }
             $dttDate->Year -= $this->txtAge->Text;
             $this->objPerson->DateOfBirth = $dttDate;
             $this->objPerson->DobGuessedFlag = true;
             $this->objPerson->DobYearApproximateFlag = false;
             break;
         case self::DobApproximateYear:
             $dttDate = QDateTime::Now();
             $dttDate->Month = $this->lstMonth->SelectedValue;
             $dttDate->Day = $this->lstDay->SelectedValue;
             if ($dttDate->IsLaterThan(QDateTime::Now())) {
                 $dttDate->Year -= 1;
             }
             $dttDate->Year -= $this->txtAge->Text;
             $this->objPerson->DateOfBirth = $dttDate;
             $this->objPerson->DobGuessedFlag = false;
             $this->objPerson->DobYearApproximateFlag = true;
             break;
         case self::DobApproximateYearAndDay:
             if ($this->objPerson->DateOfBirth) {
                 $dttDate = new QDateTime($this->objPerson->DateOfBirth);
                 $dttDate->Year = QDateTime::Now()->Year;
                 if ($dttDate->IsLaterThan(QDateTime::Now())) {
                     $dttDate->Year -= 1;
                 }
             } else {
                 $dttDate = QDateTime::Now();
                 $dttDate->Month -= 6;
             }
             $dttDate->Year -= $this->txtAge->Text;
             $this->objPerson->DateOfBirth = $dttDate;
             $this->objPerson->DobGuessedFlag = true;
             $this->objPerson->DobYearApproximateFlag = true;
             break;
         default:
             throw new Exception('Invalid DOB Type');
     }
     $this->objPerson->RefreshAge(false);
     // Deceased Flag and Date
     if ($this->objPerson->DeceasedFlag = $this->chkDeceased->Checked) {
         $this->objPerson->DateDeceased = $this->dtxDateDeceased->DateTime;
         // Also unsubscribe from church newsletter
         $objList = CommunicationList::LoadByToken('allchurch_nl');
         if ($objList->IsPersonAssociated($this->objPerson)) {
             $objList->UnassociatePerson($this->objPerson);
         }
     } else {
         $this->objPerson->DateDeceased = null;
     }
     $this->objPerson->Save();
     $this->objPerson->RefreshNameItemAssociations();
     // Refresh Name of teh Household (if applicable)
     if ($this->objPerson->HouseholdAsHead) {
         $this->objPerson->HouseholdAsHead->RefreshName();
     }
     foreach ($this->objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
         $objHouseholdParticipation->Household->RefreshMembers();
     }
     QApplication::ExecuteJavaScript('document.location = "#general";');
 }
예제 #7
0
파일: datagen.cli.php 프로젝트: alcf/chms
 public static function GenerateCommunicationLists()
 {
     $objPersonArray = Person::LoadAll();
     while (QDataGen::DisplayWhileTask('Generating Communication Lists', self::CommunicationListCount, false)) {
         $objCommunicationList = new CommunicationList();
         $objCommunicationList->EmailBroadcastTypeId = QDataGen::GenerateFromArray(array_keys(EmailBroadcastType::$NameArray));
         $objCommunicationList->Ministry = QDataGen::GenerateFromArray(self::$MinistryArray);
         $objCommunicationList->Name = QDataGen::GenerateTitle(1, 4);
         $objCommunicationList->Token = strtolower(str_replace(' ', '_', $objCommunicationList->Name));
         while (CommunicationList::LoadByToken($objCommunicationList->Token)) {
             $objCommunicationList->Name = QDataGen::GenerateTitle(1, 4);
             $objCommunicationList->Token = strtolower(str_replace(' ', '_', $objCommunicationList->Name));
         }
         $objCommunicationList->Save();
         $intCount = rand(5, 100);
         for ($i = 0; $i < $intCount; $i++) {
             if (rand(0, 3)) {
                 $objPerson = QDataGen::GenerateFromArray($objPersonArray);
                 while ($objCommunicationList->IsPersonAssociated($objPerson)) {
                     $objPerson = QDataGen::GenerateFromArray($objPersonArray);
                 }
                 $objCommunicationList->AssociatePerson($objPerson);
             } else {
                 $strFirstName = QDataGen::GenerateFirstName();
                 if (!rand(0, 5)) {
                     $strMiddleName = QDataGen::GenerateMiddleInitial() . '.';
                 } else {
                     $strMiddleName = null;
                 }
                 $strLastName = QDataGen::GenerateLastName();
                 $strEmail = QDataGen::GenerateEmail($strFirstName, $strLastName);
                 $objCommunicationList->AddEntry($strEmail, $strFirstName, $strMiddleName, $strLastName);
             }
         }
     }
 }
예제 #8
0
파일: new.php 프로젝트: alcf/chms
 protected function AddToChurchEmailList()
 {
     if ($this->chkAddToNewsletter->Checked) {
         // First create a CommunicationListEntry for the person
         $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($this->txtPersonEmail->Text);
         // Then add person to the church newsletter list
         $objList = CommunicationList::LoadByToken('alcfweekly');
         // NOTE: this is the hard coded token of the congregational newsletter.
         if ($objList) {
             if (!$objList->IsPersonAssociated($this->mctPerson->Person)) {
                 if ($objCommunicationListEntry) {
                     if (!$objList->IsCommunicationListEntryAssociated($objCommunicationListEntry)) {
                         // unassociate the communications entry if it exists because we'll associate the person directly instead.
                         $objList->UnassociateCommunicationListEntry($objCommunicationListEntry);
                     }
                 }
                 $objList->AssociatePerson($this->mctPerson->Person);
             }
         }
     }
 }
예제 #9
0
 public function ValidateToken()
 {
     if (!$this->txtToken) {
         return true;
     }
     $strToken = QApplication::Tokenize($this->txtToken->Text);
     if (strlen($strToken)) {
         if (CommunicationList::LoadByToken($strToken) || ($objGroup = Group::LoadByToken($strToken)) && $objGroup->Id != $this->mctGroup->Group->Id) {
             $this->txtToken->Warning = 'Email Address is already taken';
             return false;
         } else {
             $this->txtToken->Text = $strToken;
             return true;
         }
     } else {
         return true;
     }
 }
예제 #10
0
파일: details.php 프로젝트: alcf/chms
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     // Create address record(s)
     $objHomeAddress = $this->objHomeAddressValidator->CreateAddressRecord();
     if ($this->objMailingAddressValidator) {
         $objMailingAddress = $this->objMailingAddressValidator->CreateAddressRecord();
     } else {
         $objMailingAddress = null;
     }
     if (trim($this->dtxDateOfBirth->Text)) {
         $dttDateOfBirth = $this->dtxDateOfBirth->DateTime;
     } else {
         $dttDateOfBirth = null;
     }
     $objPerson = QApplication::$PublicLogin->ProvisionalPublicLogin->Reconcile(trim(strtolower($this->txtPassword->Text)), $this->lstQuestion->SelectedValue ? $this->lstQuestion->SelectedValue : trim($this->txtQuestion->Text), trim(strtolower($this->txtAnswer->Text)), trim($this->txtHomePhone->Text), trim($this->txtMobilePhone->Text), $objHomeAddress, $objMailingAddress, $dttDateOfBirth, $this->rblGender->SelectedValue);
     if ($objPerson->PublicLogin->Id != QApplication::$PublicLogin->Id) {
         QLog::Log(sprintf('Provisioned PublicLogin::Reconcile() matched against a Person with an existing PublicLogin: PublicLogin(%s) and Person(%s)', QApplication::$PublicLogin->Id, $objPerson->Id));
         QApplication::DisplayAlert('It appears that another registration exists with the same name and home address.  Before we can proceed, please contact ALCF Online Member Support at 650-625-1500 or records@alcf.net for more information.  Please reference PLID ' . QApplication::$PublicLogin->Id . ' when calling.');
     } else {
         // OptOut Email Flag
         if (!$this->chkBulkEmail->Checked) {
             $objPerson->CanEmailFlag = false;
             $objPerson->Save();
         } else {
             //Upon confirmation, add them to the newletter list
             $objList = CommunicationList::LoadByToken('alcfweekly');
             if ($objList) {
                 if (!$objList->IsPersonAssociated($objPerson)) {
                     $objList->AssociatePerson($objPerson);
                 }
                 $objPerson->Save();
             }
         }
         QApplication::RedirectOnPublicLogin('/register/thankyou.php');
     }
 }
예제 #11
0
 /**
  * Given an array of @groups.alcf.net email addresses, lookup which CommLists they belong to.
  * 
  * Any FOUND CommList will remove it from the Array!
  * 
  * @param string $strEmailAddressArray
  * @return CommunicationList[]
  */
 protected function LookupCommunicationLists(&$strEmailAddressArray)
 {
     $objArrayToReturn = array();
     foreach ($strEmailAddressArray as $strEmailAddress) {
         $strTokens = explode('@', $strEmailAddress);
         if ($objCommunicationList = CommunicationList::LoadByToken($strTokens[0])) {
             $objArrayToReturn[] = $objCommunicationList;
             unset($strEmailAddressArray[$strEmailAddress]);
         }
     }
     return $objArrayToReturn;
 }