Esempio n. 1
0
 public function Send()
 {
     if (!$this->blnErrorFlag) {
         $this->blnErrorFlag = true;
         $this->Save();
         $objEmailMessage = new QEmailMessage($this->strFromAddress, $this->strToAddress, $this->strSubject, $this->strBody);
         $objEmailMessage->Cc = $this->strCcAddress;
         $objEmailMessage->Bcc = $this->strBccAddress;
         try {
             QEmailServer::Send($objEmailMessage);
         } catch (QCallerException $objExc) {
             QLog::Log('Email Failed to Send #' . $this->intId);
             QLog::Log($objExc->getMessage());
             $this->strErrorMessage = $objExc->getMessage();
             $this->Save();
         }
         $this->Delete();
     }
 }
Esempio n. 2
0
 /**
  * Merges two records together.
  * @param Person $objPersonMergeWith
  * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's
  */
 public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails)
 {
     QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right'));
     Person::GetDatabase()->TransactionBegin();
     // Household Participation Records
     if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) {
         $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this);
     } else {
         if ($this->HouseholdAsHead) {
             // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head
             foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                 if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) {
                     throw new QCallerException('Cannot merge this head of household with a person record that exists in other households');
                 } else {
                     $objHouseholdParticipation->Delete();
                 }
             }
         } else {
             if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) {
                 // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head
                 foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) {
                         throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households');
                     } else {
                         $objHouseholdParticipation->Delete();
                     }
                 }
                 $objHousehold->HeadPerson = $this;
                 $objHousehold->Save();
                 $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id);
                 $objParticipation->PersonId = $this->Id;
                 $objParticipation->Save();
             } else {
                 // Otherwise: members of multiple households! but head of none
                 foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) {
                         $objHouseholdParticipation->Delete();
                     } else {
                         $objHouseholdParticipation->PersonId = $this->Id;
                         $objHouseholdParticipation->Save();
                     }
                 }
             }
         }
     }
     if (!$blnUseThisDetails) {
         $this->FirstName = $objPersonMergeWith->FirstName;
         $this->MiddleName = $objPersonMergeWith->MiddleName;
         $this->LastName = $objPersonMergeWith->LastName;
         $this->MailingLabel = $objPersonMergeWith->MailingLabel;
         $this->PriorLastNames = $objPersonMergeWith->PriorLastNames;
         $this->Nickname = $objPersonMergeWith->Nickname;
         $this->Title = $objPersonMergeWith->Title;
         $this->Suffix = $objPersonMergeWith->Suffix;
         $this->Gender = $objPersonMergeWith->Gender;
         $this->DateOfBirth = $objPersonMergeWith->DateOfBirth;
         $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag;
         $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag;
         $this->Age = $objPersonMergeWith->Age;
         $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag;
         $this->DateDeceased = $objPersonMergeWith->DateDeceased;
     }
     // Attributes
     foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) {
         // Check for double-defined attributes
         if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) {
             if ($blnUseThisDetails) {
                 $objAttributeValue->Delete();
             } else {
                 $objDoubleDefinedAttribute->Delete();
                 $objAttributeValue->PersonId = $this->Id;
                 $objAttributeValue->Save();
             }
             // Nothing double-defined -- just move it over!
         } else {
             $objAttributeValue->PersonId = $this->Id;
             $objAttributeValue->Save();
         }
     }
     // Comments
     foreach ($objPersonMergeWith->GetCommentArray() as $objComment) {
         $objComment->PersonId = $this->Id;
         $objComment->Save();
     }
     // Memberships
     foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) {
         $objMembership->PersonId = $this->Id;
         $objMembership->Save();
     }
     // Communication Lists
     foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) {
         $objPersonMergeWith->UnassociateCommunicationList($objCommList);
         if (!$this->IsCommunicationListAssociated($objCommList)) {
             $this->AssociateCommunicationList($objCommList);
         }
     }
     // Head Shots
     foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) {
         $objHeadShot->PersonId = $this->Id;
         $objHeadShot->Save();
     }
     // Group Participation
     foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) {
         $objGroupParticipation->PersonId = $this->Id;
         $objGroupParticipation->Save();
     }
     // NameItemAssn
     $objPersonMergeWith->UnassociateAllNameItems();
     // Marrriage Records
     foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) {
         $this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
         $objMarriage->DeleteThisAndLinked();
     }
     foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) {
         $this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
         $objMarriage->DeleteThisAndLinked();
     }
     // Family Relationships
     foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) {
         if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) {
             $this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId);
         }
         $objRelationship->DeleteThisAndLinked();
     }
     foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) {
         if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) {
             $this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId);
         }
         $objRelationship->DeleteThisAndLinked();
     }
     // Phones
     foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Addresses
     foreach ($objPersonMergeWith->GetAddressArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Email
     foreach ($objPersonMergeWith->GetEmailArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Other Contact Info
     foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) {
         $objContact->PersonId = $this->Id;
         $objContact->Save();
     }
     // Checking Account Lookups
     foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) {
         $objPersonMergeWith->UnassociateCheckingAccountLookup($objCheckingAccount);
         if (!$this->IsCheckingAccountLookupAssociated($objCheckingAccount)) {
             $this->AssociateCheckingAccountLookup($objCheckingAccount);
         }
     }
     // Stewardship Contributions
     foreach ($objPersonMergeWith->GetStewardshipContributionArray() as $objStewardship) {
         $objStewardship->PersonId = $this->Id;
         $objStewardship->Save();
     }
     // Stewardship Pledges
     foreach ($objPersonMergeWith->GetStewardshipPledgeArray() as $objPledge) {
         // Check for double-defined pledge
         if ($objDoubleDefinedPledge = StewardshipPledge::LoadByPersonIdStewardshipFundId($this->Id, $objPledge->StewardshipFundId)) {
             if ($blnUseThisDetails) {
                 $objPledge->Delete();
             } else {
                 $objDoubleDefinedPledge->Delete();
                 $objPledge->PersonId = $this->Id;
                 $objPledge->Save();
             }
             // Nope, just move it over like normal
         } else {
             $objPledge->PersonId = $this->Id;
             $objPledge->Save();
         }
     }
     // Online Donations
     foreach ($objPersonMergeWith->GetOnlineDonationArray() as $objOnlineDonation) {
         $objOnlineDonation->PersonId = $this->Id;
         $objOnlineDonation->Save();
     }
     // Public Login
     if ($objPublicLogin = $objPersonMergeWith->PublicLogin) {
         $objPublicLogin->PersonId = $this->Id;
         $objPublicLogin->Save();
     }
     // Events and Classes
     foreach ($objPersonMergeWith->GetSignupEntryArray() as $objSignupEntry) {
         $objSignupEntry->PersonId = $this->Id;
         $objSignupEntry->Save();
     }
     foreach ($objPersonMergeWith->GetSignupEntryAsSignupByArray() as $objSignupEntry) {
         $objSignupEntry->SignupByPersonId = $this->Id;
         $objSignupEntry->Save();
     }
     foreach ($objPersonMergeWith->GetClassRegistrationArray() as $objClassRegistration) {
         $objClassRegistration->PersonId = $this->Id;
         $objClassRegistration->Save();
     }
     // Stewardship Post Line Items
     foreach ($objPersonMergeWith->GetStewardshipPostLineItemArray() as $objStewardship) {
         $objStewardship->PersonId = $this->Id;
         $objStewardship->Save();
     }
     // Email Message Route
     foreach ($objPersonMergeWith->GetEmailMessageRouteArray() as $objEmailMessageRoute) {
         $objEmailMessageRoute->PersonId = $this->Id;
         $objEmailMessageRoute->Save();
     }
     // Search Query
     foreach ($objPersonMergeWith->GetSearchQueryArray() as $objSearchQuery) {
         $objSearchQuery->PersonId = $this->Id;
         $objSearchQuery->Save();
     }
     // Final Refresh/Cleanup
     $this->RefreshAge(false);
     $this->RefreshMaritalStatusTypeId(false);
     $this->RefreshMembershipStatusTypeId(false);
     $this->RefreshPrimaryContactInfo(false);
     $this->Save();
     $this->RefreshNameItemAssociations();
     $objPersonMergeWith->Delete();
     Person::GetDatabase()->TransactionCommit();
 }
Esempio n. 3
0
 /**
  * This will submit a NVP Request to paypal and return the repsonse
  * or NULL if there was a connection error.
  * 
  * @param string[] $strNvpRequestArray a structured array containing the NVP Request
  * @return string[] a structured array based on the NVP Response, or NULL if there was a connection error
  */
 protected static function PaymentGatewaySubmitRequest($strNvpRequestArray)
 {
     $strLogFile = 'paypal_' . QDateTime::NowToString('YYYY-MM-DD');
     $strLogHash = substr(md5(microtime()), 0, 8);
     $objCurl = curl_init();
     curl_setopt($objCurl, CURLOPT_URL, PAYPAL_ENDPOINT);
     curl_setopt($objCurl, CURLOPT_VERBOSE, false);
     // Turning off the server and peer verification (TrustManager Concept)
     curl_setopt($objCurl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($objCurl, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($objCurl, CURLOPT_POST, true);
     // Add Credentials to NVP-based Request for submitting to server
     $strNvpRequestArray['PARTNER'] = PAYPAL_PARTNER;
     $strNvpRequestArray['USER'] = PAYPAL_USER;
     $strNvpRequestArray['VENDOR'] = PAYPAL_VENDOR;
     $strNvpRequestArray['PWD'] = PAYPAL_PASSWORD;
     $strNvpRequest = self::FormatNvp($strNvpRequestArray);
     // First, we Sanitize NVP Request for Logging and then log it
     $strNvpRequestToLog = $strNvpRequestArray;
     $strNvpRequestToLog['PARTNER'] = 'xxxxx';
     $strNvpRequestToLog['USER'] = '******';
     $strNvpRequestToLog['VENDOR'] = 'xxxxx';
     $strNvpRequestToLog['PWD'] = 'xxxxx';
     if (array_key_exists('ACCT', $strNvpRequestToLog)) {
         $intLength = strlen($strNvpRequestToLog['ACCT']);
         $strNvpRequestToLog['ACCT'] = str_repeat('x', $intLength - 4) . substr($strNvpRequestToLog['ACCT'], $intLength - 4);
     }
     QLog::Log($strLogHash . ' - ' . self::FormatNvp($strNvpRequestToLog), QLogLevel::Normal, $strLogFile);
     // Setting the entire NvpRequest as POST FIELD to curl
     curl_setopt($objCurl, CURLOPT_POSTFIELDS, $strNvpRequest);
     // Getting response from server
     $strResponse = @curl_exec($objCurl);
     curl_close($objCurl);
     if ($strResponse) {
         $arrToReturn = self::DeformatNvp($strResponse);
         QLog::Log($strLogHash . ' - ' . var_export($arrToReturn, true), QLogLevel::Normal, $strLogFile);
         return $arrToReturn;
     } else {
         QLog::Log($strLogHash . ' - ' . 'ERROR', QLogLevel::Normal, $strLogFile);
         return null;
     }
 }
Esempio n. 4
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');
     }
 }
 /**
  * Returns an string array of check information indexed by:
  * 	0:	Routing Number
  *	1:	Checking Account Number
  *	2:	Check Number
  *	3:	Amount (optional)
  * @param string $strCheckInfo
  * @return string[]
  */
 public static function ParseCheckingInformation($strCheckInfo)
 {
     $strCheckInfo = trim(strtoupper($strCheckInfo));
     if (strpos($strCheckInfo, '?') !== false) {
         QLog::Log('Cannot Read Check Info: ' . $strCheckInfo);
         return null;
     }
     $strTokens = explode(',', $strCheckInfo);
     if (count($strTokens) == 3 || count($strTokens) == 4) {
         if (strlen($strTokens[0]) == 9 && strlen($strTokens[1]) > 4) {
             return $strTokens;
         }
     }
     QLog::Log('Cannot Read Check Info: ' . $strCheckInfo);
     return null;
 }