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";');
 }
Example #2
0
File: list.php Project: alcf/chms
 protected function Form_Create()
 {
     $this->objList = CommunicationList::LoadById(QApplication::PathInfo(0));
     if (!$this->objList) {
         QApplication::Redirect('/communications/');
     }
     $this->strPageTitle .= $this->objList->Name;
     $this->dtgMembers = new QDataGrid($this);
     $this->dtgMembers->UseAjax = true;
     $this->dtgMembers->Paginator = new QPaginator($this->dtgMembers);
     if ($this->objList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) {
         $this->dtgMembers->AddColumn(new QDataGridColumn('Edit', '<?= $_FORM->RenderEdit($_ITEM); ?>', 'HtmlEntities=false', 'Width=140px', 'FontSize=10px'));
     }
     $this->dtgMembers->AddColumn(new QDataGridColumn('First Name', '<?= $_ITEM[0]; ?>', 'Width=150px', 'SortByCommand=0,0', 'ReverseSortByCommand=0,1'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Middle', '<?= $_ITEM[1]; ?>', 'Width=80px', 'SortByCommand=1,0', 'ReverseSortByCommand=1,1'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Last Name', '<?= $_ITEM[2]; ?>', 'Width=150px', 'SortByCommand=2,0', 'ReverseSortByCommand=2,1'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Email', '<a href="mailto:<?= QApplication::HtmlEntities($_ITEM[3]); ?>"><?= QApplication::HtmlEntities($_ITEM[3]); ?></a>', 'HtmlEntities=false', 'Width=290px', 'SortByCommand=3,0', 'ReverseSortByCommand=3,1'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Member?', '<?= $_ITEM[6]; ?>', 'Width=75px', 'SortByCommand=6,0', 'ReverseSortByCommand=6,1'));
     if ($this->objList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) {
         $this->dtgMembers->SortColumnIndex = 3;
     } else {
         $this->dtgMembers->SortColumnIndex = 2;
     }
     $this->pxyUnsubscribeEntry = new QControlProxy($this);
     $this->pxyUnsubscribeEntry->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to unsubscribe this person from the list?'));
     $this->pxyUnsubscribeEntry->AddAction(new QClickEvent(), new QAjaxAction('pxyUnsubscribeEntry_Click'));
     $this->pxyUnsubscribeEntry->AddAction(new QClickEvent(), new QTerminateAction());
     $this->pxyUnsubscribePerson = new QControlProxy($this);
     $this->pxyUnsubscribePerson->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to unsubscribe this person from the list?'));
     $this->pxyUnsubscribePerson->AddAction(new QClickEvent(), new QAjaxAction('pxyUnsubscribePerson_Click'));
     $this->pxyUnsubscribePerson->AddAction(new QClickEvent(), new QTerminateAction());
     $this->dtgMembers->SetDataBinder('dtgMembers_Bind');
     $this->SetupEmailMessageControls();
 }
Example #3
0
File: index.php Project: 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));
     }
 }
Example #4
0
File: edit.php Project: 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();
 }
Example #5
0
File: tools.php Project: alcf/chms
 protected function btnCheck_Click($strFormId, $strControlId, $strParameter)
 {
     $this->lblResult->Text = '';
     $objEmailArray = Email::LoadArrayByAddress($this->txtEmail->Text);
     if (count($objEmailArray) > 0) {
         $this->lblResult->Text .= "Found email objects<br><br>";
         $intPersonIdArray = array();
         foreach ($objEmailArray as $objEmail) {
             $objPerson = Person::LoadByPrimaryEmailId($objEmail->Id);
             if ($objPerson) {
                 $intPersonIdArray[] = $objPerson->Id;
             }
         }
         $this->lblResult->Text .= "<h3>GROUPS</h3>";
         $objGroupCursor = Group::QueryCursor(QQ::All());
         while ($objGroup = Group::InstantiateCursor($objGroupCursor)) {
             $objGroupParticipationArr = $objGroup->GetGroupParticipationArray();
             foreach ($objGroupParticipationArr as $objGroupParticipant) {
                 if (in_array($objGroupParticipant->PersonId, $intPersonIdArray)) {
                     $this->lblResult->Text .= sprintf("%s is in %s: %s<br>", $this->txtEmail->Text, $objGroup->Ministry->Name, $objGroup->Name);
                     break;
                 }
             }
         }
         $this->lblResult->Text .= "<br><h3>COMMUNICATION LISTS</h3>";
         $objCommuncationsCursor = CommunicationList::QueryCursor(QQ::All());
         while ($objCommunicationList = CommunicationList::InstantiateCursor($objCommuncationsCursor)) {
             $objCommListArray = $objCommunicationList->GetMemberAsArray();
             foreach ($objCommListArray as $objComListEntry) {
                 if ($objComListEntry[3] == $this->txtEmail->Text) {
                     $this->lblResult->Text .= sprintf("%s is in %s: %s<br>", $this->txtEmail->Text, $objCommunicationList->Ministry->Name, $objCommunicationList->Name);
                     break;
                 }
             }
         }
     } else {
         $this->lblResult->Text .= "No email object found<br>";
     }
 }
Example #6
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;
     }
 }
Example #7
0
    /**
     * Deletes all associated CommunicationLists
     * @return void
     */
    public function DeleteAllCommunicationLists()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateCommunicationList on this unsaved Ministry.');
        }
        // Get the Database Object for this Class
        $objDatabase = Ministry::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (CommunicationList::LoadArrayByMinistryId($this->intId) as $objCommunicationList) {
                $objCommunicationList->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`communication_list`
				WHERE
					`ministry_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
Example #8
0
<?php

require dirname(__FILE__) . '/../../includes/prepend.inc.php';
QApplication::Authenticate();
$objList = CommunicationList::Load(QApplication::PathInfo(0));
if (!$objList) {
    QApplication::Redirect('/communications/');
}
if (!$objList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) {
    QApplication::Redirect('/communications/');
}
// Disable strict no-cache for IE due to IE issues with downloading no-cache items
if (QApplication::IsBrowser(QBrowserType::InternetExplorer)) {
    header("Pragma:");
    header("Expires:");
}
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=' . $objList->CsvFilename);
print "First Name, Middle Name, Last Name,E-mail, Gender, Phone, Address,City, State, Zipcode\r\n";
// iterate through the Communications List. sort by Last Name, then First Name
$objMembersListArray = $objList->GetMemberAsArray('2,0');
//asort($objMembersListArray);
foreach ($objMembersListArray as $objMember) {
    print EscapeCsv($objMember[0]);
    // First Name
    print ",";
    print EscapeCsv($objMember[1]);
    // Middle Name
    print ",";
    print EscapeCsv($objMember[2]);
    // Last Name
Example #9
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $objList = CommunicationList::Load($this->lstCommunicationLists->SelectedValue);
     $this->objPerson->AssociateCommunicationList($objList);
     QApplication::ExecuteJavaScript('document.location = "#groups";');
 }
 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";');
 }
Example #11
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;
 }
Example #12
0
 /**
  * Counts all many-to-many associated CommunicationLists
  * @return int
  */
 public function CountCommunicationLists()
 {
     if (is_null($this->intId)) {
         return 0;
     }
     return CommunicationList::CountByPerson($this->intId);
 }
Example #13
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;
 }
Example #14
0
File: add.php Project: alcf/chms
 protected function Form_Create()
 {
     $this->objList = CommunicationList::LoadById(QApplication::PathInfo(0));
     if (!$this->objList) {
         QApplication::Redirect('/communications/');
     }
     if (!$this->objList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) {
         $this->RedirectToView();
     }
     $this->objSearchQuery = new SearchQuery();
     $this->pnlSearchQuery = new SearchQueryPanel($this->objSearchQuery, $this);
     $this->btnQuery = new QButton($this);
     $this->btnQuery->Text = 'Initialize with Query';
     $this->btnQuery->CssClass = 'primary';
     $this->btnQuery->CausesValidation = false;
     $this->btnQuery->AddAction(new QClickEvent(), new QAjaxAction('btnQuery_Click', null, true));
     $this->dtgMembers = new QDataGrid($this);
     $this->dtgMembers->UseAjax = true;
     $this->dtgMembers->Paginator = new QPaginator($this->dtgMembers);
     if ($this->objList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) {
         $this->dtgMembers->AddColumn(new QDataGridColumn('&nbsp;', '<?= $_FORM->RenderEdit($_ITEM); ?>', 'HtmlEntities=false', 'Width=140px', 'FontSize=10px'));
     }
     $this->dtgMembers->AddColumn(new QDataGridColumn('First Name', '<?= $_ITEM->FirstName; ?>', 'Width=170px'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Middle Name', '<?= $_ITEM->MiddleName; ?>', 'Width=100px'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Last Name', '<?= $_ITEM->LastName; ?>', 'Width=170px'));
     $this->dtgMembers->AddColumn(new QDataGridColumn('Email', '<?= $_FORM->RenderEmail($_ITEM); ?>', 'HtmlEntities=false', 'Width=310px'));
     $this->dtgMembers->SetDataBinder('dtgMembers_Bind');
     $this->txtFirstName = new QTextBox($this);
     $this->txtFirstName->Name = 'First Name';
     $this->txtMiddleName = new QTextBox($this);
     $this->txtMiddleName->Name = 'Middle Name';
     $this->txtLastName = new QTextBox($this);
     $this->txtLastName->Name = 'Last Name';
     $this->txtEmail = new QEmailTextBox($this);
     $this->txtEmail->Name = 'Email';
     $this->txtEmail->CausesValidation = false;
     $this->txtEmail->Required = false;
     $this->btnAdd = new QButton($this);
     $this->btnAdd->Text = 'Add';
     $this->btnAdd->CssClass = 'primary';
     $this->btnAdd->CausesValidation = true;
     $this->pxyUndo = new QControlProxy($this);
     $this->pxyUndo->AddAction(new QClickEvent(), new QAjaxAction('pxyUndo_Click'));
     $this->pxyUndo->AddAction(new QClickEvent(), new QTerminateAction());
     $this->txtEmail->Focus();
     $this->txtEmail->AddAction(new QEnterKeyEvent(), new QFocusControlAction($this->txtFirstName));
     $this->txtEmail->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QFocusControlAction($this->txtMiddleName));
     $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtMiddleName->AddAction(new QEnterKeyEvent(), new QFocusControlAction($this->txtLastName));
     $this->txtMiddleName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtLastName->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnAdd_Click', null, true));
     $this->txtLastName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->btnAdd->AddAction(new QClickEvent(), new QAjaxAction('btnAdd_Click', null, true));
     $this->btnSave = new QButton($this);
     $this->btnSave->Text = 'Save';
     $this->btnSave->CssClass = 'primary';
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnCancel->CssClass = 'cancel';
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
 }
 /**
  * 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 CommunicationListMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing CommunicationList object creation - defaults to CreateOrEdit
  * @return CommunicationListMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objCommunicationList = CommunicationList::Load($intId);
         // CommunicationList was found -- return it!
         if ($objCommunicationList) {
             return new CommunicationListMetaControl($objParentObject, $objCommunicationList);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a CommunicationList 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 CommunicationListMetaControl($objParentObject, new CommunicationList());
 }
Example #16
0
File: new.php Project: 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);
             }
         }
     }
 }
Example #17
0
 public function pxyUnsubscribe_Click($strFormId, $strControlId, $strParameter)
 {
     $objCommunicationList = CommunicationList::Load($strParameter);
     if ($objCommunicationList->IsPersonAssociated($this->objPerson)) {
         $objCommunicationList->UnassociatePerson($this->objPerson);
     }
     $this->dtgCommunicationLists->Refresh();
 }
 /**
  * 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;
     }
 }
Example #19
0
 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);
             }
         }
     }
 }
    print "GROUPS\n";
    $objGroupCursor = Group::QueryCursor(QQ::All());
    QDataGen::DisplayForEachTaskStart('Checking for email in Group Lists', Group::CountAll());
    while ($objGroup = Group::InstantiateCursor($objGroupCursor)) {
        QDataGen::DisplayForEachTaskNext('Checking for email in Group Lists');
        $objGroupParticipationArr = $objGroup->GetGroupParticipationArray();
        foreach ($objGroupParticipationArr as $objGroupParticipant) {
            if (in_array($objGroupParticipant->PersonId, $intPersonIdArray)) {
                printf("\n%s is in %s: %s\n", $txtEmail, $objGroup->Ministry->Name, $objGroup->Name);
                break;
            }
        }
    }
    QDataGen::DisplayForEachTaskEnd('Checking for email in Group Lists');
    print "COMMUNICATION LISTS\n";
    $objCommuncationsCursor = CommunicationList::QueryCursor(QQ::All());
    QDataGen::DisplayForEachTaskStart('Checking for email in Communication Lists', CommunicationList::CountAll());
    while ($objCommunicationList = CommunicationList::InstantiateCursor($objCommuncationsCursor)) {
        QDataGen::DisplayForEachTaskNext('Checking for email in Communication Lists');
        $objCommListArray = $objCommunicationList->GetMemberAsArray();
        foreach ($objCommListArray as $objComListEntry) {
            if ($objComListEntry[3] == $txtEmail) {
                printf("\n%s is in %s: %s\n", $txtEmail, $objCommunicationList->Ministry->Name, $objCommunicationList->Name);
                break;
            }
        }
    }
    QDataGen::DisplayForEachTaskEnd('Checking for email in Communication Lists');
} else {
    print "No email object found\n";
}
Example #21
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, CommunicationList::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Example #22
0
 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');
     }
 }
Example #23
0
File: index.php Project: 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;
     }
 }
 protected function lstCommunicationLists_Update()
 {
     if ($this->lstCommunicationLists) {
         $this->objCommunicationListEntry->UnassociateAllCommunicationLists();
         $objSelectedListItems = $this->lstCommunicationLists->SelectedItems;
         if ($objSelectedListItems) {
             foreach ($objSelectedListItems as $objListItem) {
                 $this->objCommunicationListEntry->AssociateCommunicationList(CommunicationList::Load($objListItem->Value));
             }
         }
     }
 }
Example #25
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);
}
 /**
  * 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 = CommunicationList::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 CommunicationList, given the clauses above
     $this->DataSource = CommunicationList::QueryArray($objCondition, $objClauses);
 }