Esempio n. 1
0
/**
 * Handle a click event.
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_api3_mailing_event_click($params)
{
    civicrm_api3_verify_mandatory($params, 'CRM_Mailing_Event_DAO_TrackableURLOpen', array('event_queue_id', 'url_id'), FALSE);
    $url_id = $params['url_id'];
    $queue = $params['event_queue_id'];
    $url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($queue, $url_id);
    $values = array();
    $values['url'] = $url;
    $values['is_error'] = 0;
    return civicrm_api3_create_success($values);
}
Esempio n. 2
0
 /**
  * Test Trackable URL with unicode character
  */
 public function testTrackableURLWithUnicodeSign()
 {
     $unicodeURL = "https://civińcrm.org";
     $this->_params['body_text'] = str_replace("https://civicrm.org", $unicodeURL, $this->_params['body_text']);
     $this->_params['body_html'] = str_replace("https://civicrm.org", $unicodeURL, $this->_params['body_html']);
     $mail = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
     $params = array('mailing_id' => $mail['id'], 'test_email' => '*****@*****.**', 'test_group' => NULL);
     $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params);
     $sql = "SELECT turl.id as url_id, turl.url, q.id as queue_id\n      FROM civicrm_mailing_trackable_url as turl\n      INNER JOIN civicrm_mailing_job as j ON turl.mailing_id = j.mailing_id\n      INNER JOIN civicrm_mailing_event_queue q ON j.id = q.job_id\n      ORDER BY turl.id DESC LIMIT 1";
     $dao = CRM_Core_DAO::executeQuery($sql);
     $this->assertTrue($dao->fetch());
     $url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($dao->queue_id, $dao->url_id);
     $this->assertContains($unicodeURL, $url);
     // Now delete the event queue hashes and see if the tracking still works.
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_mailing_event_queue');
     $url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($dao->queue_id, $dao->url_id);
     $this->assertContains($unicodeURL, $url);
 }
Esempio n. 3
0
File: url.php Progetto: kidaa30/yes
require_once 'CRM/Utils/Array.php';
$config = CRM_Core_Config::singleton();
// To keep backward compatibility for URLs generated
// by CiviCRM < 1.7, we check for the q variable as well.
if (isset($_GET['qid'])) {
    $queue_id = CRM_Utils_Array::value('qid', $_GET);
} else {
    $queue_id = CRM_Utils_Array::value('q', $_GET);
}
$url_id = CRM_Utils_Array::value('u', $_GET);
if (!$url_id) {
    echo "Missing input parameters\n";
    exit;
}
require_once 'CRM/Mailing/Event/BAO/TrackableURLOpen.php';
$url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($queue_id, $url_id);
// CRM-7103
// Looking for additional query variables and append them when redirecting.
$query_param = $_GET;
unset($query_param['q'], $query_param['qid'], $query_param['u']);
$query_string = http_build_query($query_param);
if (strlen($query_string) > 0) {
    // Parse the url to preserve the fragment.
    $pieces = parse_url($url);
    if (isset($pieces['fragment'])) {
        $url = str_replace('#' . $pieces['fragment'], '', $url);
    }
    // Handle additional query string params.
    if ($query_string) {
        if (stristr($url, '?')) {
            $url .= '&' . $query_string;
/**
 * Handle a click event
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_mailer_event_click($params)
{
    $errors = _civicrm_mailer_check_params($params, array('event_queue_id', 'url_id'));
    if (!empty($errors)) {
        return $errors;
    }
    $url_id = $params['url_id'];
    $queue = $params['event_queue_id'];
    $url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($queue, $url_id);
    $values = array();
    $values['url'] = $url;
    $values['is_error'] = 0;
    return $values;
}