예제 #1
0
 function run()
 {
     $this->setValues();
     $this->setIsOptOut($this->contactId, 0);
     $groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id');
     $activityStatus = 'Completed';
     // Completed existing member
     if (!$this->isGroupContactAdded($this->contactId, $groupId)) {
         CRM_Speakcivi_Logic_Activity::join($this->contactId, 'confirmation_link', $this->campaignId);
         $this->setGroupContactAdded($this->contactId, $groupId);
         $activityStatus = 'optin';
         // Completed new member
     }
     if ($this->campaignId) {
         $campaign = new CRM_Speakcivi_Logic_Campaign($this->campaignId);
         $locale = $campaign->getLanguage();
         $language = substr($locale, 0, 2);
         $this->setLanguageGroup($this->contactId, $language);
         $this->setLanguageTag($this->contactId, $language);
     }
     $aids = $this->findActivitiesIds($this->activityId, $this->campaignId, $this->contactId);
     $this->setActivitiesStatuses($this->activityId, $aids, $activityStatus);
     $email = CRM_Speakcivi_Logic_Contact::getEmail($this->contactId);
     $speakcivi = new CRM_Speakcivi_Page_Speakcivi();
     $speakcivi->sendConfirm($email, $this->contactId, $this->activityId, $this->campaignId, false);
     $country = $this->getCountry($this->campaignId);
     $url = "{$country}/post_confirm";
     CRM_Utils_System::redirect($url);
 }
예제 #2
0
 function run()
 {
     $this->setActivityStatusIds();
     $this->setValues();
     $contactParams = array('is_opt_out' => 0);
     $groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id');
     $activityStatus = 'optin';
     // default status: Completed new member
     if (!$this->isGroupContactAdded($this->contactId, $groupId)) {
         if (!CRM_Speakcivi_Logic_Activity::hasJoin($this->activityId)) {
             CRM_Speakcivi_Logic_Activity::join($this->contactId, 'confirmation_link', $this->campaignId, $this->activityId);
         }
         $this->setGroupContactAdded($this->contactId, $groupId);
     } else {
         $activityStatus = 'Completed';
         // Completed existing member
     }
     if ($this->campaignId) {
         $campaign = new CRM_Speakcivi_Logic_Campaign($this->campaignId);
         $locale = $campaign->getLanguage();
         $language = substr($locale, 0, 2);
         $rlg = $this->setLanguageGroup($this->contactId, $language);
         $this->setLanguageTag($this->contactId, $language);
         if ($rlg == 1) {
             $contactParams['preferred_language'] = $locale;
         }
     }
     CRM_Speakcivi_Logic_Contact::set($this->contactId, $contactParams);
     $aids = $this->findActivitiesIds($this->activityId, $this->campaignId, $this->contactId);
     $this->setActivitiesStatuses($this->activityId, $aids, $activityStatus);
     $email = CRM_Speakcivi_Logic_Contact::getEmail($this->contactId);
     $speakcivi = new CRM_Speakcivi_Page_Speakcivi();
     $speakcivi->sendConfirm($email, $this->contactId, $this->activityId, $this->campaignId, false, 'new_member');
     $country = $this->getCountry($this->campaignId);
     $url = "{$country}/post_confirm";
     CRM_Utils_System::redirect($url);
 }
예제 #3
0
 /**
  * Create a petition in Civi: contact and activity
  *
  * @param $param
  */
 public function petition($param)
 {
     $contact = $this->createContact($param);
     $optInForActivityStatus = $this->optIn;
     if (!CRM_Speakcivi_Logic_Contact::isContactNeedConfirmation($this->newContact, $contact['id'], $this->groupId, $contact['values'][0]['is_opt_out'])) {
         $this->confirmationBlock = false;
         $optInForActivityStatus = 0;
     }
     $optInMapActivityStatus = array(0 => 'Completed', 1 => 'Scheduled');
     if ($this->addJoinActivity && !$this->optIn) {
         $optInMapActivityStatus[0] = 'optin';
     }
     $activityStatus = $optInMapActivityStatus[$optInForActivityStatus];
     $activity = $this->createActivity($param, $contact['id'], 'Petition', $activityStatus);
     CRM_Speakcivi_Logic_Activity::setSourceFields($activity['id'], @$param->source);
     if ($this->newContact) {
         CRM_Speakcivi_Logic_Contact::setContactCreatedDate($contact['id'], $activity['values'][0]['activity_date_time']);
         CRM_Speakcivi_Logic_Contact::setSourceFields($contact['id'], @$param->source);
     }
     $h = $param->cons_hash;
     if ($this->optIn == 1) {
         $this->sendConfirm($h->emails[0]->email, $contact['id'], $activity['id'], $this->campaignId, $this->confirmationBlock);
     } else {
         $language = substr($this->locale, 0, 2);
         $pagePost = new CRM_Speakcivi_Page_Post();
         $rlg = $pagePost->setLanguageGroup($contact['id'], $language);
         $pagePost->setLanguageTag($contact['id'], $language);
         if ($this->addJoinActivity) {
             CRM_Speakcivi_Logic_Activity::join($contact['id'], 'optIn:0', $this->campaignId);
         }
         if ($contact['values'][0]['preferred_language'] != $this->locale && $rlg == 1) {
             CRM_Speakcivi_Logic_Contact::set($contact['id'], array('preferred_language' => $this->locale));
         }
         $share_utm_source = 'new_' . str_replace('gb', 'uk', strtolower($this->country)) . '_member';
         $this->sendConfirm($h->emails[0]->email, $contact['id'], $activity['id'], $this->campaignId, false, $share_utm_source);
     }
 }
예제 #4
0
 /**
  * Create a petition in Civi: contact and activity
  *
  * @param $param
  */
 public function petition($param)
 {
     $contact = $this->createContact($param);
     $optInForActivityStatus = $this->optIn;
     if (!$this->isContactNeedConfirmation($this->newContact, $contact['id'], $contact['values'][0]['is_opt_out'])) {
         $this->confirmationBlock = false;
         $optInForActivityStatus = 0;
     }
     $optInMapActivityStatus = array(0 => 'Completed', 1 => 'Scheduled');
     if ($this->addJoinActivity && !$this->optIn) {
         $optInMapActivityStatus[0] = 'optin';
     }
     $activityStatus = $optInMapActivityStatus[$optInForActivityStatus];
     $activity = $this->createActivity($param, $contact['id'], 'Petition', $activityStatus);
     CRM_Speakcivi_Logic_Activity::setSourceFields($activity['id'], @$param->source);
     if ($this->newContact) {
         $this->setContactCreatedDate($contact['id'], $activity['values'][0]['activity_date_time']);
     }
     $h = $param->cons_hash;
     if ($this->optIn == 1) {
         $this->sendConfirm($h->emails[0]->email, $contact['id'], $activity['id'], $this->campaignId, $this->confirmationBlock);
     } else {
         $language = substr($this->locale, 0, 2);
         $pagePost = new CRM_Speakcivi_Page_Post();
         $pagePost->setLanguageGroup($contact['id'], $language);
         $pagePost->setLanguageTag($contact['id'], $language);
         if ($this->addJoinActivity) {
             CRM_Speakcivi_Logic_Activity::join($contact['id'], 'optIn:0', $this->campaignId);
         }
         $this->sendConfirm($h->emails[0]->email, $contact['id'], $activity['id'], $this->campaignId, false);
     }
 }