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); }
/** * Get country prefix based on campaign id. * * @param int $campaign_id * * @return string */ public function getCountry($campaign_id) { $country = ''; if ($campaign_id > 0) { $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $speakcivi->setDefaults(); $speakcivi->customFields = $speakcivi->getCustomFields($campaign_id); $language = $speakcivi->getLanguage(); if ($language != '') { $tab = explode('_', $language); if (strlen($tab[0]) == 2) { $country = '/' . $tab[0]; } } } return $country; }
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); }
0 => (object)array( 'email' => '*****@*****.**', ) ), 'addresses' => array( 0 => (object)array( // 'zip' => '[pl] 02-222', // valid 'zip' => null, 'country' => 'uk', ), ), ), 'source' => (object)array( "source" => "generic", "medium" => "web", "campaign" => "tomasz-test-you-PL", ), 'metadata' => (object)array( 'tracking_codes' => (object)array( 'source' => 'member_b34404d7', 'medium' => 'facebook', 'campaign' => '123456qwerty', 'content' => 'b34404d7', ) ), );*/ $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $speakcivi->runParam($param); print_r($speakcivi); print_r($param); exit;
session_start(); $settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php'; define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests: $param = (object) array('action_name' => 'Testowa kampania', 'action_type' => 'petition', 'action_technical_type' => 'act2.wemove.eu:petition', 'external_id' => 49, 'create_dt' => '2016-01-08T11:56:59.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => 'Pietrzkowski [M]', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'boolean_collection' => true, 'comment' => 'Komentarz do petycji'); $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $speakcivi->setDefaults(); $speakcivi->setCountry($param); $speakcivi->campaignObj = new CRM_Speakcivi_Logic_Campaign(); $speakcivi->campaign = $speakcivi->campaignObj->getCampaign($param->external_id); $speakcivi->campaign = $speakcivi->campaignObj->setCampaign($param->external_id, $speakcivi->campaign); if ($speakcivi->campaignObj->isValidCampaign($speakcivi->campaign)) { $speakcivi->campaignId = $speakcivi->campaign['id']; $speakcivi->campaignObj->customFields = $speakcivi->campaignObj->getCustomFields($speakcivi->campaignId); $speakcivi->locale = $speakcivi->campaignObj->getLanguage(); } else { echo 'blad :-['; exit; } $speakcivi->petition($param);
define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests on localhost: // group id = 9 // campaign id = 8 $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); // petition: $param = (object) array('action_name' => 'Nazwa kampanii', 'action_type' => 'petition', 'action_technical_type' => 'act2.wemove.eu:petition', 'external_id' => 23, 'create_dt' => '2015-10-13T13:56:59.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => 'Pietrzkowski [M]', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'boolean_collection' => true, 'comment' => 'Komentarz do petycji'); // share: //$param = (object)array( // 'action_name' => 'Nazwa kampanii', // 'action_type' => 'share', // 'action_technical_type' => 'act2.wemove.eu:share', // 'external_id' => 23, // 'create_dt' => '2015-10-13T13:56:59.617+01:00', // 'cons_hash' => (object)array( // 'firstname' => 'Tomasz', //// 'lastname' => 'Pietrzkowski', // 'lastname' => '', // 'emails' => array( // 0 => (object)array(
define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests on localhost: // group id = 9 // campaign id = 8 $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); // petition: $param = (object) array('action_name' => 'Nazwa kampanii', 'action_type' => 'petition', 'action_technical_type' => 'act2.wemove.eu:petition', 'external_id' => 108, 'create_dt' => '2015-10-13T13:56:59.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz2', 'lastname' => 'Pietrzkowski', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'boolean_collection' => true, 'comment' => 'Komentarz do petycji'); // share: $param = (object) array('action_name' => 'Nazwa kampanii', 'action_type' => 'share', 'action_technical_type' => 'act2.wemove.eu:share', 'external_id' => 108, 'create_dt' => '2015-10-13T13:56:59.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => '', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[de] 48329 Havixbeck'))), 'boolean_collection' => true, 'comment' => 'Komentarz do petycji'); //var_dump($param); $speakcivi->setDefaults(); $speakcivi->setCountry($param); echo '$speakcivi->country: ' . $speakcivi->country . "\n"; echo '$speakcivi->postal_code: ' . $speakcivi->postalCode . "\n\n\n"; $speakcivi->campaign = $speakcivi->getCampaign($param->external_id); $speakcivi->campaign = $speakcivi->setCampaign($param->external_id, $speakcivi->campaign); if ($speakcivi->isValidCampaign($speakcivi->campaign)) { $speakcivi->campaignId = $speakcivi->campaign['id']; } else { echo 'blad :-[';
$error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // old speakout $param = (object) array('action_name' => 'Testowa kampania', 'action_type' => 'petition', 'action_technical_type' => 'act2.wemove.eu:petition', 'external_id' => 49, 'create_dt' => '2016-01-08T11:56:59.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => 'Pietrzkowski [M]', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'boolean_collection' => true, 'comment' => 'Komentarz do petycji'); // new speakout (you.wemove.eu) $param = (object) array('action_type' => 'petition', 'action_technical_type' => 'you.wemove.eu:petition', 'create_dt' => '2016-03-22T12:40:12.531Z', 'action_name' => 'diem25-GR', 'external_id' => 10007, 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => 'Pietrzkowski', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'metadata' => (object) array("sign_boolean" => null, "sign_answer" => null, "sign_comment" => null), 'source' => (object) array("source" => "generic", "medium" => "facebook", "campaign" => "diem25-GR")); $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $speakcivi->setDefaults(); $speakcivi->setCountry($param); $notSendConfirmationToThoseCountries = array('UK', 'GB'); if (in_array($speakcivi->country, $notSendConfirmationToThoseCountries)) { $speakcivi->optIn = 0; } $speakcivi->campaignObj = new CRM_Speakcivi_Logic_Campaign(); $speakcivi->campaign = $speakcivi->campaignObj->getCampaign($param->external_id); $speakcivi->campaign = $speakcivi->campaignObj->setCampaign($param->external_id, $speakcivi->campaign, $param); if ($speakcivi->campaignObj->isValidCampaign($speakcivi->campaign)) { $speakcivi->campaignId = $speakcivi->campaign['id']; $speakcivi->campaignObj->customFields = $speakcivi->campaignObj->getCustomFields($speakcivi->campaignId); $speakcivi->locale = $speakcivi->campaignObj->getLanguage(); } else { echo 'blad :-[';
<?php session_start(); $settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php'; define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests: $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $param = (object) array('external_id' => 9); $campaign = $speakcivi->getCampaign($param->external_id); echo '$campaign GET: '; print_r($campaign); $campaign = $speakcivi->setCampaign($param, $campaign); echo '$campaign NEW: '; print_r($campaign);
$settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php'; define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests on localhost: // group id = 9 // campaign id = 8 $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); // petition: $param = (object) array('action_name' => 'Nazwa kampanii', 'action_type' => 'petition', 'action_technical_type' => 'act2.wemove.eu:petition', 'external_id' => 23, 'create_dt' => '2015-11-09T21:00:00.617+01:00', 'cons_hash' => (object) array('firstname' => 'Tomasz', 'lastname' => 'Pietrzkowski', 'emails' => array(0 => (object) array('email' => '*****@*****.**')), 'addresses' => array(0 => (object) array('zip' => '[pl] 02-222'))), 'comment' => 'Komentarz do petycji'); var_dump($param); $speakcivi->setDefaults(); $speakcivi->setCountry($param); $speakcivi->campaign = $speakcivi->getCampaign($param->external_id); $speakcivi->campaign = $speakcivi->setCampaign($param->external_id, $speakcivi->campaign); if ($speakcivi->isValidCampaign($speakcivi->campaign)) { $speakcivi->campaignId = $speakcivi->campaign['id']; } else { echo 'blad :-['; exit; } $speakcivi->petition($param);
<?php session_start(); $settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php'; define('CIVICRM_SETTINGS_PATH', $settingsFile); $error = @(include_once $settingsFile); if ($error == false) { echo "Could not load the settings file at: {$settingsFile}\n"; exit; } // Load class loader global $civicrm_root; require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); // tests: $params = array('sequential' => 1, 'return' => "custom_3,custom_4", 'id' => 3); var_dump($params); $result = civicrm_api3('Campaign', 'get', $params); print_r($result); $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $campaignId = 3; $speakcivi->customFields = $speakcivi->getCustomFields($campaignId); echo '$speakcivi->customFields: '; print_r($speakcivi->customFields); echo 'template: '; echo $speakcivi->getTemplateId();