Exemplo n.º 1
0
Arquivo: index.php Projeto: 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));
     }
 }
Exemplo n.º 2
0
 /**
  * Associates an Email/Name/Etc. to this communication list
  * @param string $strEmail
  * @param string $strFirstName
  * @param string $strMiddleName
  * @param string $strLastName
  * @return CommunicationListEntry
  */
 public function AddEntry($strEmail, $strFirstName, $strMiddleName, $strLastName)
 {
     $strEmail = strtolower($strEmail);
     if (!($objEntry = CommunicationListEntry::LoadByEmail($strEmail))) {
         $objEntry = new CommunicationListEntry();
         $objEntry->Email = $strEmail;
     }
     $objEntry->FirstName = $strFirstName;
     $objEntry->MiddleName = $strMiddleName;
     $objEntry->LastName = $strLastName;
     $objEntry->Save();
     if (!$this->IsCommunicationListEntryAssociated($objEntry)) {
         $this->AssociateCommunicationListEntry($objEntry);
     }
     return $objEntry;
 }
 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";');
 }
Exemplo n.º 4
0
 /**
  * Counts all many-to-many associated CommunicationListEntries
  * @return int
  */
 public function CountCommunicationListEntries()
 {
     if (is_null($this->intId)) {
         return 0;
     }
     return CommunicationListEntry::CountByCommunicationList($this->intId);
 }
Exemplo n.º 5
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objEmailMessage) {
         $objObject->objEmailMessage = EmailMessage::GetSoapObjectFromObject($objObject->objEmailMessage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intEmailMessageId = null;
         }
     }
     if ($objObject->objGroup) {
         $objObject->objGroup = Group::GetSoapObjectFromObject($objObject->objGroup, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intGroupId = null;
         }
     }
     if ($objObject->objCommunicationList) {
         $objObject->objCommunicationList = CommunicationList::GetSoapObjectFromObject($objObject->objCommunicationList, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCommunicationListId = null;
         }
     }
     if ($objObject->objLogin) {
         $objObject->objLogin = Login::GetSoapObjectFromObject($objObject->objLogin, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLoginId = null;
         }
     }
     if ($objObject->objCommunicationListEntry) {
         $objObject->objCommunicationListEntry = CommunicationListEntry::GetSoapObjectFromObject($objObject->objCommunicationListEntry, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCommunicationListEntryId = null;
         }
     }
     if ($objObject->objPerson) {
         $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPersonId = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 6
0
Arquivo: new.php Projeto: 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);
             }
         }
     }
 }
 /**
  * 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 CommunicationListEntryMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing CommunicationListEntry object creation - defaults to CreateOrEdit
  * @return CommunicationListEntryMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objCommunicationListEntry = CommunicationListEntry::Load($intId);
         // CommunicationListEntry was found -- return it!
         if ($objCommunicationListEntry) {
             return new CommunicationListEntryMetaControl($objParentObject, $objCommunicationListEntry);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a CommunicationListEntry object with PK arguments: ' . $intId);
             }
         }
         // 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 CommunicationListEntryMetaControl($objParentObject, new CommunicationListEntry());
 }
 /**
  * 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 = CommunicationListEntry::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 CommunicationListEntry, given the clauses above
     $this->DataSource = CommunicationListEntry::QueryArray($objCondition, $objClauses);
 }
 protected function lstCommunicationListEntries_Update()
 {
     if ($this->lstCommunicationListEntries) {
         $this->objCommunicationList->UnassociateAllCommunicationListEntries();
         $objSelectedListItems = $this->lstCommunicationListEntries->SelectedItems;
         if ($objSelectedListItems) {
             foreach ($objSelectedListItems as $objListItem) {
                 $this->objCommunicationList->AssociateCommunicationListEntry(CommunicationListEntry::Load($objListItem->Value));
             }
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Refresh this MetaControl with Data from the local SignupEntry object.
  * @param boolean $blnReload reload SignupEntry from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objSignupEntry->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objSignupEntry->Id;
         }
     }
     if ($this->lstSignupForm) {
         $this->lstSignupForm->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstSignupForm->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objSignupFormArray = SignupForm::LoadAll();
         if ($objSignupFormArray) {
             foreach ($objSignupFormArray as $objSignupForm) {
                 $objListItem = new QListItem($objSignupForm->__toString(), $objSignupForm->Id);
                 if ($this->objSignupEntry->SignupForm && $this->objSignupEntry->SignupForm->Id == $objSignupForm->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSignupForm->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSignupFormId) {
         $this->lblSignupFormId->Text = $this->objSignupEntry->SignupForm ? $this->objSignupEntry->SignupForm->__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->objSignupEntry->Person && $this->objSignupEntry->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objSignupEntry->Person ? $this->objSignupEntry->Person->__toString() : null;
     }
     if ($this->lstSignupByPerson) {
         $this->lstSignupByPerson->RemoveAllItems();
         $this->lstSignupByPerson->AddItem(QApplication::Translate('- Select One -'), null);
         $objSignupByPersonArray = Person::LoadAll();
         if ($objSignupByPersonArray) {
             foreach ($objSignupByPersonArray as $objSignupByPerson) {
                 $objListItem = new QListItem($objSignupByPerson->__toString(), $objSignupByPerson->Id);
                 if ($this->objSignupEntry->SignupByPerson && $this->objSignupEntry->SignupByPerson->Id == $objSignupByPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSignupByPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSignupByPersonId) {
         $this->lblSignupByPersonId->Text = $this->objSignupEntry->SignupByPerson ? $this->objSignupEntry->SignupByPerson->__toString() : null;
     }
     if ($this->lstSignupEntryStatusType) {
         $this->lstSignupEntryStatusType->SelectedValue = $this->objSignupEntry->SignupEntryStatusTypeId;
     }
     if ($this->lblSignupEntryStatusTypeId) {
         $this->lblSignupEntryStatusTypeId->Text = $this->objSignupEntry->SignupEntryStatusTypeId ? SignupEntryStatusType::$NameArray[$this->objSignupEntry->SignupEntryStatusTypeId] : null;
     }
     if ($this->calDateCreated) {
         $this->calDateCreated->DateTime = $this->objSignupEntry->DateCreated;
     }
     if ($this->lblDateCreated) {
         $this->lblDateCreated->Text = sprintf($this->objSignupEntry->DateCreated) ? $this->objSignupEntry->__toString($this->strDateCreatedDateTimeFormat) : null;
     }
     if ($this->calDateSubmitted) {
         $this->calDateSubmitted->DateTime = $this->objSignupEntry->DateSubmitted;
     }
     if ($this->lblDateSubmitted) {
         $this->lblDateSubmitted->Text = sprintf($this->objSignupEntry->DateSubmitted) ? $this->objSignupEntry->__toString($this->strDateSubmittedDateTimeFormat) : null;
     }
     if ($this->txtAmountTotal) {
         $this->txtAmountTotal->Text = $this->objSignupEntry->AmountTotal;
     }
     if ($this->lblAmountTotal) {
         $this->lblAmountTotal->Text = $this->objSignupEntry->AmountTotal;
     }
     if ($this->txtAmountPaid) {
         $this->txtAmountPaid->Text = $this->objSignupEntry->AmountPaid;
     }
     if ($this->lblAmountPaid) {
         $this->lblAmountPaid->Text = $this->objSignupEntry->AmountPaid;
     }
     if ($this->txtAmountBalance) {
         $this->txtAmountBalance->Text = $this->objSignupEntry->AmountBalance;
     }
     if ($this->lblAmountBalance) {
         $this->lblAmountBalance->Text = $this->objSignupEntry->AmountBalance;
     }
     if ($this->txtInternalNotes) {
         $this->txtInternalNotes->Text = $this->objSignupEntry->InternalNotes;
     }
     if ($this->lblInternalNotes) {
         $this->lblInternalNotes->Text = $this->objSignupEntry->InternalNotes;
     }
     if ($this->lstCommunicationsEntry) {
         $this->lstCommunicationsEntry->RemoveAllItems();
         $this->lstCommunicationsEntry->AddItem(QApplication::Translate('- Select One -'), null);
         $objCommunicationsEntryArray = CommunicationListEntry::LoadAll();
         if ($objCommunicationsEntryArray) {
             foreach ($objCommunicationsEntryArray as $objCommunicationsEntry) {
                 $objListItem = new QListItem($objCommunicationsEntry->__toString(), $objCommunicationsEntry->Id);
                 if ($this->objSignupEntry->CommunicationsEntry && $this->objSignupEntry->CommunicationsEntry->Id == $objCommunicationsEntry->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCommunicationsEntry->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCommunicationsEntryId) {
         $this->lblCommunicationsEntryId->Text = $this->objSignupEntry->CommunicationsEntry ? $this->objSignupEntry->CommunicationsEntry->__toString() : null;
     }
     if ($this->lstClassRegistration) {
         $this->lstClassRegistration->RemoveAllItems();
         $this->lstClassRegistration->AddItem(QApplication::Translate('- Select One -'), null);
         $objClassRegistrationArray = ClassRegistration::LoadAll();
         if ($objClassRegistrationArray) {
             foreach ($objClassRegistrationArray as $objClassRegistration) {
                 $objListItem = new QListItem($objClassRegistration->__toString(), $objClassRegistration->SignupEntryId);
                 if ($objClassRegistration->SignupEntryId == $this->objSignupEntry->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstClassRegistration->AddItem($objListItem);
             }
         }
         // Because ClassRegistration's ClassRegistration is not null, if a value is already selected, it cannot be changed.
         if ($this->lstClassRegistration->SelectedValue) {
             $this->lstClassRegistration->Enabled = false;
         } else {
             $this->lstClassRegistration->Enabled = true;
         }
     }
     if ($this->lblClassRegistration) {
         $this->lblClassRegistration->Text = $this->objSignupEntry->ClassRegistration ? $this->objSignupEntry->ClassRegistration->__toString() : null;
     }
 }
Exemplo n.º 11
0
 /**
  * Given a valid From EmailAddress, this will lookup and return a "Sender" array, a 3-item array containing:
  * 	Login
  * 	CommunicationListEntry
  * 	Person[]
  * that would correspond to this From EmailAddress.  Note that any one of those indexes can also be null
  * if there is no object corresponding to this From Email Address.
  * @return mixed[]
  */
 protected function CalculatePotentialSenderArray()
 {
     $objArrayToReturn = array();
     $objArrayToReturn[] = Login::LoadByEmail($this->FromAddress);
     $objArrayToReturn[] = CommunicationListEntry::LoadByEmail($this->FromAddress);
     // Get all Person objects that have this as an email address
     $objArrayToReturn[] = Person::QueryArray(QQ::Equal(QQN::Person()->Email->Address, $this->FromAddress), QQ::Distinct());
     return $objArrayToReturn;
 }
Exemplo n.º 12
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, CommunicationListEntry::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Exemplo n.º 13
0
Arquivo: list.php Projeto: alcf/chms
 public function pxyUnsubscribeEntry_Click($strFormId, $strControlId, $strParameter)
 {
     $objEntry = CommunicationListEntry::Load($strParameter);
     if ($objEntry->IsCommunicationListAssociated($this->objList)) {
         $objEntry->UnassociateCommunicationList($this->objList);
     }
     $this->dtgMembers->Refresh();
 }
Exemplo n.º 14
0
Arquivo: add.php Projeto: alcf/chms
 public function btnAdd_Click()
 {
     $strEmail = trim(strtolower($this->txtEmail->Text));
     // Is this already a person?
     if (count($objEmailArray = Email::LoadArrayByAddress($strEmail, QQ::OrderBy(QQN::Email()->Id)))) {
         $objPersonToAdd = null;
         // If anyone in the resulting array has this email as "Primary" -- that person gets assigne
         foreach ($objEmailArray as $objEmail) {
             if (!$objPersonToAdd && $objEmail->Person->PrimaryEmailId == $objEmail->Id) {
                 $objPersonToAdd = $objEmail->Person;
             }
         }
         // Otherwise, assign the first person in the resultset
         if ($objPersonToAdd) {
             $this->objArrayToAdd[] = $objPersonToAdd;
         } else {
             $this->objArrayToAdd[] = $objEmailArray[0]->Person;
         }
         // No -- Is already an Entry?
     } else {
         if ($objEntry = CommunicationListEntry::LoadByEmail($strEmail)) {
             if ($strName = trim($this->txtFirstName->Text)) {
                 $objEntry->FirstName = $strName;
             }
             if ($strName = trim($this->txtMiddleName->Text)) {
                 $objEntry->MiddleName = $strName;
             }
             if ($strName = trim($this->txtLastName->Text)) {
                 $objEntry->LastName = $strName;
             }
             $this->objArrayToAdd[] = $objEntry;
             // No -- Add a New Entry
         } else {
             $objEntry = new CommunicationListEntry();
             $objEntry->FirstName = trim($this->txtFirstName->Text);
             $objEntry->MiddleName = trim($this->txtMiddleName->Text);
             $objEntry->LastName = trim($this->txtLastName->Text);
             $objEntry->Email = $strEmail;
             $this->objArrayToAdd[] = $objEntry;
         }
     }
     $this->dtgMembers->Refresh();
     $this->txtFirstName->Text = null;
     $this->txtMiddleName->Text = null;
     $this->txtLastName->Text = null;
     $this->txtEmail->Text = null;
     $this->txtEmail->Focus();
 }
Exemplo n.º 15
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSignupForm) {
         $objObject->objSignupForm = SignupForm::GetSoapObjectFromObject($objObject->objSignupForm, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSignupFormId = null;
         }
     }
     if ($objObject->objPerson) {
         $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPersonId = null;
         }
     }
     if ($objObject->objSignupByPerson) {
         $objObject->objSignupByPerson = Person::GetSoapObjectFromObject($objObject->objSignupByPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSignupByPersonId = null;
         }
     }
     if ($objObject->dttDateCreated) {
         $objObject->dttDateCreated = $objObject->dttDateCreated->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->dttDateSubmitted) {
         $objObject->dttDateSubmitted = $objObject->dttDateSubmitted->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->objCommunicationsEntry) {
         $objObject->objCommunicationsEntry = CommunicationListEntry::GetSoapObjectFromObject($objObject->objCommunicationsEntry, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCommunicationsEntryId = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 16
0
Arquivo: index.php Projeto: 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;
     }
 }
 /**
  * Refresh this MetaControl with Data from the local EmailMessageRoute object.
  * @param boolean $blnReload reload EmailMessageRoute from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objEmailMessageRoute->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objEmailMessageRoute->Id;
         }
     }
     if ($this->lstEmailMessage) {
         $this->lstEmailMessage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstEmailMessage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objEmailMessageArray = EmailMessage::LoadAll();
         if ($objEmailMessageArray) {
             foreach ($objEmailMessageArray as $objEmailMessage) {
                 $objListItem = new QListItem($objEmailMessage->__toString(), $objEmailMessage->Id);
                 if ($this->objEmailMessageRoute->EmailMessage && $this->objEmailMessageRoute->EmailMessage->Id == $objEmailMessage->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstEmailMessage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblEmailMessageId) {
         $this->lblEmailMessageId->Text = $this->objEmailMessageRoute->EmailMessage ? $this->objEmailMessageRoute->EmailMessage->__toString() : null;
     }
     if ($this->lstGroup) {
         $this->lstGroup->RemoveAllItems();
         $this->lstGroup->AddItem(QApplication::Translate('- Select One -'), null);
         $objGroupArray = Group::LoadAll();
         if ($objGroupArray) {
             foreach ($objGroupArray as $objGroup) {
                 $objListItem = new QListItem($objGroup->__toString(), $objGroup->Id);
                 if ($this->objEmailMessageRoute->Group && $this->objEmailMessageRoute->Group->Id == $objGroup->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstGroup->AddItem($objListItem);
             }
         }
     }
     if ($this->lblGroupId) {
         $this->lblGroupId->Text = $this->objEmailMessageRoute->Group ? $this->objEmailMessageRoute->Group->__toString() : null;
     }
     if ($this->lstCommunicationList) {
         $this->lstCommunicationList->RemoveAllItems();
         $this->lstCommunicationList->AddItem(QApplication::Translate('- Select One -'), null);
         $objCommunicationListArray = CommunicationList::LoadAll();
         if ($objCommunicationListArray) {
             foreach ($objCommunicationListArray as $objCommunicationList) {
                 $objListItem = new QListItem($objCommunicationList->__toString(), $objCommunicationList->Id);
                 if ($this->objEmailMessageRoute->CommunicationList && $this->objEmailMessageRoute->CommunicationList->Id == $objCommunicationList->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCommunicationList->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCommunicationListId) {
         $this->lblCommunicationListId->Text = $this->objEmailMessageRoute->CommunicationList ? $this->objEmailMessageRoute->CommunicationList->__toString() : null;
     }
     if ($this->lstLogin) {
         $this->lstLogin->RemoveAllItems();
         $this->lstLogin->AddItem(QApplication::Translate('- Select One -'), null);
         $objLoginArray = Login::LoadAll();
         if ($objLoginArray) {
             foreach ($objLoginArray as $objLogin) {
                 $objListItem = new QListItem($objLogin->__toString(), $objLogin->Id);
                 if ($this->objEmailMessageRoute->Login && $this->objEmailMessageRoute->Login->Id == $objLogin->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLogin->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLoginId) {
         $this->lblLoginId->Text = $this->objEmailMessageRoute->Login ? $this->objEmailMessageRoute->Login->__toString() : null;
     }
     if ($this->lstCommunicationListEntry) {
         $this->lstCommunicationListEntry->RemoveAllItems();
         $this->lstCommunicationListEntry->AddItem(QApplication::Translate('- Select One -'), null);
         $objCommunicationListEntryArray = CommunicationListEntry::LoadAll();
         if ($objCommunicationListEntryArray) {
             foreach ($objCommunicationListEntryArray as $objCommunicationListEntry) {
                 $objListItem = new QListItem($objCommunicationListEntry->__toString(), $objCommunicationListEntry->Id);
                 if ($this->objEmailMessageRoute->CommunicationListEntry && $this->objEmailMessageRoute->CommunicationListEntry->Id == $objCommunicationListEntry->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCommunicationListEntry->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCommunicationListEntryId) {
         $this->lblCommunicationListEntryId->Text = $this->objEmailMessageRoute->CommunicationListEntry ? $this->objEmailMessageRoute->CommunicationListEntry->__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->objEmailMessageRoute->Person && $this->objEmailMessageRoute->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objEmailMessageRoute->Person ? $this->objEmailMessageRoute->Person->__toString() : null;
     }
 }
Exemplo n.º 18
0
// read file
if (is_file($txtSrcFile)) {
    $lineArray = file($txtSrcFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $isFirst = true;
    foreach ($lineArray as $line) {
        if ($isFirst) {
            $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";
Exemplo n.º 19
0
 protected function btnSubmit_Click($strFormId, $strControlId, $strParameter)
 {
     $this->objSignupEntry->Save();
     $this->CreateChildObject();
     if (!QApplication::$PublicLogin) {
         // Create a communcations entry object or use an existing communcations_entry
         // if user is not logged in
         $txtEmail = $this->GetControl($this->strEmailCtrlId);
         $objCommunicationsEntry = CommunicationListEntry::LoadByEmail($txtEmail->Text);
         if (!$objCommunicationsEntry) {
             $objCommunicationsEntry = new CommunicationListEntry();
             $objCommunicationsEntry->FirstName = $this->objFormQuestionControlArray[0]->Text;
             $objCommunicationsEntry->LastName = $this->objFormQuestionControlArray[1]->Text;
             if ($txtEmail) {
                 $objCommunicationsEntry->Email = $txtEmail->Text;
             }
             $objCommunicationsEntry->Save();
         }
         $this->objSignupEntry->CommunicationsEntryId = $objCommunicationsEntry->Id;
     }
     foreach ($this->objSignupForm->GetFormQuestionArray() as $objFormQuestion) {
         // Only update if this is NOT "InternalFlag"
         if ($objFormQuestion->InternalFlag) {
             continue;
         }
         $strControlId = 'fq' . $objFormQuestion->Id;
         $objFormAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($this->objSignupEntry->Id, $objFormQuestion->Id);
         if (!$objFormAnswer) {
             $objFormAnswer = new FormAnswer();
             $objFormAnswer->SignupEntry = $this->objSignupEntry;
             $objFormAnswer->FormQuestion = $objFormQuestion;
         }
         switch ($objFormQuestion->FormQuestionTypeId) {
             case FormQuestionType::SpouseName:
                 $lstSpouse = $this->GetControl($strControlId . 'id');
                 $txtSpouse = $this->GetControl($strControlId . 'nm');
                 if ($lstSpouse && $lstSpouse->SelectedValue) {
                     $objFormAnswer->TextValue = Person::Load($lstSpouse->SelectedValue)->Name;
                 } else {
                     $objFormAnswer->TextValue = trim($txtSpouse->Text);
                 }
                 break;
             case FormQuestionType::Address:
                 $rblAddress = $this->GetControl($strControlId . 'switch');
                 $txtAddress1 = $this->GetControl($strControlId . 'address1');
                 $txtAddress2 = $this->GetControl($strControlId . 'address2');
                 $txtCity = $this->GetControl($strControlId . 'city');
                 $lstState = $this->GetControl($strControlId . 'state');
                 $txtZipCode = $this->GetControl($strControlId . 'zipcode');
                 if ($rblAddress && $rblAddress->SelectedValue) {
                     $objFormAnswer->AddressId = $rblAddress->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Address->AddressFullLine;
                 } else {
                     $objFormAnswer->AddressId = null;
                     $objAddress = new Address();
                     $objAddress->Address1 = trim($txtAddress1->Text);
                     $objAddress->Address2 = trim($txtAddress2->Text);
                     $objAddress->City = trim($txtCity->Text);
                     $objAddress->State = $lstState->SelectedValue;
                     $objAddress->ZipCode = trim($txtZipCode->Text);
                     $objFormAnswer->TextValue = $objAddress->AddressFullLine;
                 }
                 break;
             case FormQuestionType::Age:
                 $txtAge = $this->GetControl($strControlId . 'age');
                 if (strlen(trim($txtAge->Text))) {
                     $objFormAnswer->IntegerValue = $txtAge->Text;
                 } else {
                     $objFormAnswer->IntegerValue = null;
                 }
                 break;
             case FormQuestionType::DateofBirth:
                 $dtxDateOfBirth = $this->GetControl($strControlId . 'dob');
                 if ($dtxDateOfBirth->DateTime) {
                     $objFormAnswer->DateValue = $dtxDateOfBirth->DateTime;
                     // Update the Person Information
                     if (QApplication::$PublicLogin) {
                         $this->objSignupEntry->Person->DateOfBirth = $objFormAnswer->DateValue;
                         $this->objSignupEntry->Person->DobGuessedFlag = false;
                         $this->objSignupEntry->Person->DobYearApproximateFlag = false;
                         $this->objSignupEntry->Person->Save();
                     }
                 } else {
                     $objFormAnswer->DateValue = null;
                 }
                 break;
             case FormQuestionType::Gender:
                 $lstGender = $this->GetControl($strControlId . 'gender');
                 if ($lstGender->SelectedValue === true) {
                     $objFormAnswer->TextValue = 'Male';
                     $objFormAnswer->BooleanValue = true;
                     if (QApplication::$PublicLogin) {
                         $this->objSignupEntry->Person->Gender = 'M';
                         $this->objSignupEntry->Person->Save();
                     }
                 } else {
                     if ($lstGender->SelectedValue === false) {
                         $objFormAnswer->TextValue = 'Female';
                         $objFormAnswer->BooleanValue = false;
                         if (QApplication::$PublicLogin) {
                             $this->objSignupEntry->Person->Gender = 'F';
                             $this->objSignupEntry->Person->Save();
                         }
                     } else {
                         $objFormAnswer->TextValue = null;
                         $objFormAnswer->BooleanValue = null;
                     }
                 }
                 break;
             case FormQuestionType::Phone:
                 $lstPhone = $this->GetControl($strControlId . 'id');
                 $txtPhone = $this->GetControl($strControlId . 'phone');
                 if ($lstPhone && $lstPhone->SelectedValue) {
                     $objFormAnswer->PhoneId = $lstPhone->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Phone->Number;
                 } else {
                     if ($strNumber = trim($txtPhone->Text)) {
                         $objFormAnswer->PhoneId = null;
                         $objFormAnswer->TextValue = $strNumber;
                     } else {
                         $objFormAnswer->PhoneId = null;
                         $objFormAnswer->TextValue = null;
                     }
                 }
                 break;
             case FormQuestionType::Email:
                 $lstEmail = $this->GetControl($strControlId . 'id');
                 $txtEmail = $this->GetControl($strControlId . 'email');
                 if ($lstEmail && $lstEmail->SelectedValue) {
                     $objFormAnswer->EmailId = $lstEmail->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Email->Address;
                 } else {
                     if ($strNumber = trim($txtEmail->Text)) {
                         $objFormAnswer->EmailId = null;
                         $objFormAnswer->TextValue = $strNumber;
                     } else {
                         $objFormAnswer->EmailId = null;
                         $objFormAnswer->TextValue = null;
                     }
                 }
                 break;
             case FormQuestionType::ShortText:
             case FormQuestionType::LongText:
                 $txtAnswer = $this->GetControl($strControlId);
                 if (strlen($strText = trim($txtAnswer->Text))) {
                     $objFormAnswer->TextValue = $strText;
                 } else {
                     $objFormAnswer->TextValue = null;
                 }
                 break;
             case FormQuestionType::Number:
                 $txtAnswer = $this->GetControl($strControlId);
                 if (strlen($strText = trim($txtAnswer->Text))) {
                     $objFormAnswer->IntegerValue = $strText;
                 } else {
                     $objFormAnswer->IntegerValue = null;
                 }
                 break;
             case FormQuestionType::YesNo:
                 $chkAnswer = $this->GetControl($strControlId);
                 $objFormAnswer->BooleanValue = $chkAnswer->Checked;
                 break;
             case FormQuestionType::SingleSelect:
                 $lstAnswer = $this->GetControl($strControlId);
                 $txtAnswer = $this->GetControl($strControlId . 'other');
                 // No item selected ("-select one-" still selected)
                 if (is_null($lstAnswer->SelectedValue)) {
                     $objFormAnswer->TextValue = null;
                     // "Other" option
                 } else {
                     if ($lstAnswer->SelectedValue === false) {
                         if (strlen($strText = trim($txtAnswer->Text))) {
                             $objFormAnswer->TextValue = $strText;
                         } else {
                             $objFormAnswer->TextValue = null;
                         }
                         // Regular List Selection
                     } else {
                         $objFormAnswer->TextValue = trim($lstAnswer->SelectedValue);
                     }
                 }
                 break;
             case FormQuestionType::MultipleSelect:
                 //GJS - changing to multiple check boxes
                 $chkAnswer = $this->GetControl($strControlId);
                 $objItemsArray = $chkAnswer->GetAllItems();
                 if (count($objItemsArray)) {
                     $strSelectedArray = array();
                     foreach ($objItemsArray as $objItem) {
                         if ($objItem->Selected) {
                             $strSelectedArray[] = $objItem->Name;
                         }
                     }
                     $objFormAnswer->TextValue = implode("\r\n", $strSelectedArray);
                 } else {
                     $objFormAnswer->TextValue = null;
                 }
                 break;
             case FormQuestionType::Instructions:
                 // Don't need to do anything here!
                 break;
             default:
                 throw new Exception('Invalid FormQuestionTypeId: ' . $objFormQuestion->FormQuestionTypeId);
         }
         $objFormAnswer->Save();
     }
     if ($this->objSignupForm->CountFormProducts()) {
         QApplication::Redirect($this->objSignupEntry->PaymentUrl);
     } else {
         $this->objSignupEntry->Complete();
         QApplication::Redirect($this->objSignupEntry->ConfirmationUrl);
     }
 }