First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
292
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Bounce.php
Normal file
292
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Bounce.php
Normal file
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new bounce event, update the email address if necessary
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($params['job_id'],
|
||||
$params['event_queue_id'],
|
||||
$params['hash']
|
||||
);
|
||||
$success = NULL;
|
||||
|
||||
if (!$q) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
$bounce = new CRM_Mailing_Event_BAO_Bounce();
|
||||
$bounce->time_stamp = date('YmdHis');
|
||||
|
||||
// if we dont have a valid bounce type, we should set it
|
||||
// to bounce_type_id 11 which is Syntax error. this allows such email
|
||||
// addresses to be bounce a few more time before being put on hold
|
||||
// CRM-4814
|
||||
// we changed this behavior since this bounce type might be due to some issue
|
||||
// with the connection or smtp server etc
|
||||
if (empty($params['bounce_type_id'])) {
|
||||
$params['bounce_type_id'] = 11;
|
||||
if (empty($params['bounce_reason'])) {
|
||||
$params['bounce_reason'] = ts('Unknown bounce type: Could not parse bounce email');
|
||||
}
|
||||
}
|
||||
|
||||
// CRM-11989
|
||||
$params['bounce_reason'] = mb_strcut($params['bounce_reason'], 0, 254);
|
||||
|
||||
$bounce->copyValues($params);
|
||||
$bounce->save();
|
||||
|
||||
if ($q->email_id) {
|
||||
self::putEmailOnHold($q->email_id);
|
||||
}
|
||||
$transaction->commit();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
*
|
||||
* @param string|null $toDate
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount($mailing_id, $job_id = NULL, $is_distinct = FALSE, $toDate = NULL) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$bounce = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($bounce.id) as bounce
|
||||
FROM $bounce
|
||||
INNER JOIN $queue
|
||||
ON $bounce.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($toDate)) {
|
||||
$query .= " AND $bounce.time_stamp <= $toDate";
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
// query was missing
|
||||
$dao->query($query);
|
||||
|
||||
if ($dao->fetch()) {
|
||||
return $dao->bounce;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$bounce = self::getTableName();
|
||||
$bounceType = CRM_Mailing_DAO_BounceType::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$bounce.time_stamp as date,
|
||||
$bounce.bounce_reason as reason,
|
||||
$bounceType.name as bounce_type
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $bounce
|
||||
ON $bounce.event_queue_id = $queue.id
|
||||
LEFT JOIN $bounceType
|
||||
ON $bounce.bounce_type_id = $bounceType.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, $bounce.time_stamp, $bounce.bounce_reason, $bounceType.name ";
|
||||
}
|
||||
|
||||
$orderBy = "sort_name ASC, {$bounce}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
// FIXME: translate this
|
||||
'type' => (empty($dao->bounce_type) ? ts('Unknown') : $dao->bounce_type
|
||||
),
|
||||
'reason' => $dao->reason,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the email on hold if it has met the threshold.
|
||||
*
|
||||
* @param int $email_id
|
||||
*/
|
||||
protected static function putEmailOnHold($email_id) {
|
||||
|
||||
$bounceTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
|
||||
$bounceType = CRM_Mailing_DAO_BounceType::getTableName();
|
||||
$emailTable = CRM_Core_BAO_Email::getTableName();
|
||||
$queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
|
||||
// might want to put distinct inside the count
|
||||
$query = "SELECT count($bounceTable.id) as bounces,
|
||||
$bounceType.hold_threshold as threshold
|
||||
FROM $bounceTable
|
||||
INNER JOIN $bounceType
|
||||
ON $bounceTable.bounce_type_id = $bounceType.id
|
||||
INNER JOIN $queueTable
|
||||
ON $bounceTable.event_queue_id = $queueTable.id
|
||||
INNER JOIN $emailTable
|
||||
ON $queueTable.email_id = $emailTable.id
|
||||
WHERE $emailTable.id = $email_id
|
||||
AND ($emailTable.reset_date IS NULL
|
||||
OR $bounceTable.time_stamp >= $emailTable.reset_date)
|
||||
GROUP BY $bounceTable.bounce_type_id
|
||||
ORDER BY threshold, bounces desc";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
if ($dao->bounces >= $dao->threshold) {
|
||||
$email = new CRM_Core_BAO_Email();
|
||||
$email->id = $email_id;
|
||||
$email->on_hold = TRUE;
|
||||
$email->hold_date = date('YmdHis');
|
||||
$email->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
160
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Confirm.php
Normal file
160
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Confirm.php
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
require_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Event_BAO_Confirm
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Confirm extends CRM_Mailing_Event_DAO_Confirm {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm a pending subscription.
|
||||
*
|
||||
* @param int $contact_id
|
||||
* The id of the contact.
|
||||
* @param int $subscribe_id
|
||||
* The id of the subscription event.
|
||||
* @param string $hash
|
||||
* The hash.
|
||||
*
|
||||
* @return bool
|
||||
* True on success
|
||||
*/
|
||||
public static function confirm($contact_id, $subscribe_id, $hash) {
|
||||
$se = &CRM_Mailing_Event_BAO_Subscribe::verify(
|
||||
$contact_id,
|
||||
$subscribe_id,
|
||||
$hash
|
||||
);
|
||||
|
||||
if (!$se) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// before we proceed lets just check if this contact is already 'Added'
|
||||
// if so, we should ignore this request and hence avoid sending multiple
|
||||
// emails - CRM-11157
|
||||
$details = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact_id, $se->group_id);
|
||||
if ($details && $details->status == 'Added') {
|
||||
// This contact is already subscribed
|
||||
// lets return the group title
|
||||
return CRM_Core_DAO::getFieldValue(
|
||||
'CRM_Contact_DAO_Group',
|
||||
$se->group_id,
|
||||
'title'
|
||||
);
|
||||
}
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$ce = new CRM_Mailing_Event_BAO_Confirm();
|
||||
$ce->event_subscribe_id = $se->id;
|
||||
$ce->time_stamp = date('YmdHis');
|
||||
$ce->save();
|
||||
|
||||
CRM_Contact_BAO_GroupContact::addContactsToGroup(
|
||||
array($contact_id),
|
||||
$se->group_id,
|
||||
'Email',
|
||||
'Added',
|
||||
$ce->id
|
||||
);
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
|
||||
|
||||
$group = new CRM_Contact_DAO_Group();
|
||||
$group->id = $se->group_id;
|
||||
$group->find(TRUE);
|
||||
|
||||
$component = new CRM_Mailing_BAO_Component();
|
||||
$component->is_default = 1;
|
||||
$component->is_active = 1;
|
||||
$component->component_type = 'Welcome';
|
||||
|
||||
$component->find(TRUE);
|
||||
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
$html = $component->body_html;
|
||||
|
||||
if ($component->body_text) {
|
||||
$text = $component->body_text;
|
||||
}
|
||||
else {
|
||||
$text = CRM_Utils_String::htmlToText($component->body_html);
|
||||
}
|
||||
|
||||
$bao = new CRM_Mailing_BAO_Mailing();
|
||||
$bao->body_text = $text;
|
||||
$bao->body_html = $html;
|
||||
$tokens = $bao->getTokens();
|
||||
|
||||
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, TRUE);
|
||||
|
||||
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE);
|
||||
|
||||
$mailParams = array(
|
||||
'groupName' => 'Mailing Event ' . $component->component_type,
|
||||
'subject' => $component->subject,
|
||||
'from' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
|
||||
'toEmail' => $email,
|
||||
'toName' => $display_name,
|
||||
'replyTo' => "do-not-reply@$emailDomain",
|
||||
'returnPath' => "do-not-reply@$emailDomain",
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
);
|
||||
// send - ignore errors because the desired status change has already been successful
|
||||
$unused_result = CRM_Utils_Mail::send($mailParams);
|
||||
|
||||
return $group->title;
|
||||
}
|
||||
|
||||
}
|
321
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Delivered.php
Normal file
321
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Delivered.php
Normal file
|
@ -0,0 +1,321 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new delivery event.
|
||||
*
|
||||
* @param array $params
|
||||
* Associative array of delivery event values.
|
||||
*
|
||||
* @return \CRM_Mailing_Event_BAO_Delivered
|
||||
*/
|
||||
public static function &create(&$params) {
|
||||
$q = &CRM_Mailing_Event_BAO_Queue::verify($params['job_id'],
|
||||
$params['event_queue_id'],
|
||||
$params['hash']
|
||||
);
|
||||
|
||||
if (!$q) {
|
||||
return NULL;
|
||||
}
|
||||
$q->free();
|
||||
|
||||
$delivered = new CRM_Mailing_Event_BAO_Delivered();
|
||||
$delivered->time_stamp = date('YmdHis');
|
||||
$delivered->copyValues($params);
|
||||
$delivered->save();
|
||||
|
||||
$queue = new CRM_Mailing_Event_BAO_Queue();
|
||||
$queue->id = $params['event_queue_id'];
|
||||
$queue->find(TRUE);
|
||||
|
||||
while ($queue->fetch()) {
|
||||
$email = new CRM_Core_BAO_Email();
|
||||
$email->id = $queue->email_id;
|
||||
$email->hold_date = '';
|
||||
$email->reset_date = date('YmdHis');
|
||||
$email->save();
|
||||
}
|
||||
|
||||
return $delivered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
* @param string $toDate
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount($mailing_id, $job_id = NULL, $is_distinct = FALSE, $toDate = NULL) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$delivered = self::getTableName();
|
||||
$bounce = CRM_Mailing_Event_BAO_Bounce::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($delivered.id) as delivered
|
||||
FROM $delivered
|
||||
INNER JOIN $queue
|
||||
ON $delivered.event_queue_id = $queue.id
|
||||
LEFT JOIN $bounce
|
||||
ON $delivered.event_queue_id = $bounce.event_queue_id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
WHERE $bounce.id IS null
|
||||
AND $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($toDate)) {
|
||||
$query .= " AND $delivered.time_stamp <= $toDate";
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
// query was missing
|
||||
$dao->query($query);
|
||||
|
||||
if ($dao->fetch()) {
|
||||
return $dao->delivered;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @param int $is_test
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $is_test = 0
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$delivered = self::getTableName();
|
||||
$bounce = CRM_Mailing_Event_BAO_Bounce::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $delivered.id as id,
|
||||
$contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$delivered.time_stamp as date
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $delivered
|
||||
ON $delivered.event_queue_id = $queue.id
|
||||
LEFT JOIN $bounce
|
||||
ON $bounce.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = $is_test
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
WHERE $bounce.id IS null
|
||||
AND $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, $delivered.id";
|
||||
}
|
||||
|
||||
$orderBy = "sort_name ASC, {$delivered}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[$dao->id] = array(
|
||||
'contact_id' => $dao->contact_id,
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $eventQueueIDs
|
||||
* @param null $time
|
||||
*/
|
||||
public static function bulkCreate($eventQueueIDs, $time = NULL) {
|
||||
if (!$time) {
|
||||
$time = date('YmdHis');
|
||||
}
|
||||
|
||||
// construct a bulk insert statement
|
||||
$values = array();
|
||||
foreach ($eventQueueIDs as $eqID) {
|
||||
$values[] = "( $eqID, '{$time}' )";
|
||||
}
|
||||
|
||||
while (!empty($values)) {
|
||||
$input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
|
||||
$str = implode(',', $input);
|
||||
$sql = "INSERT INTO civicrm_mailing_event_delivered ( event_queue_id, time_stamp ) VALUES $str;";
|
||||
CRM_Core_DAO::executeQuery($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since we never know when a mailing really bounces (hard bounce == NOW, soft bounce == NOW to NOW + 3 days?)
|
||||
* we cannot decide when an email address last got an email.
|
||||
*
|
||||
* We want to avoid putting on hold an email address which had a few bounces (mbox full) and then got quite a few
|
||||
* successful deliveries before starting the bounce again. The current code does not set the resetDate and hence
|
||||
* the above scenario results in the email being put on hold
|
||||
*
|
||||
* This function rectifies that by considering all non-test mailing jobs which have completed between $minDays and $maxDays
|
||||
* and setting the resetDate to the date that an email was delivered
|
||||
*
|
||||
* @param int $minDays
|
||||
* Consider mailings that were completed at least $minDays ago.
|
||||
* @param int $maxDays
|
||||
* Consider mailings that were completed not more than $maxDays ago.
|
||||
*/
|
||||
public static function updateEmailResetDate($minDays = 3, $maxDays = 7) {
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$query = "
|
||||
CREATE TEMPORARY TABLE civicrm_email_temp_values (
|
||||
id int primary key,
|
||||
reset_date datetime
|
||||
) ENGINE = HEAP;
|
||||
";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$query = "
|
||||
INSERT INTO civicrm_email_temp_values (id, reset_date)
|
||||
SELECT civicrm_email.id as email_id,
|
||||
max(civicrm_mailing_event_delivered.time_stamp) as reset_date
|
||||
FROM civicrm_mailing_event_queue
|
||||
INNER JOIN civicrm_email ON civicrm_mailing_event_queue.email_id = civicrm_email.id
|
||||
INNER JOIN civicrm_mailing_event_delivered ON civicrm_mailing_event_delivered.event_queue_id = civicrm_mailing_event_queue.id
|
||||
LEFT JOIN civicrm_mailing_event_bounce ON civicrm_mailing_event_bounce.event_queue_id = civicrm_mailing_event_queue.id
|
||||
INNER JOIN civicrm_mailing_job ON civicrm_mailing_event_queue.job_id = civicrm_mailing_job.id AND civicrm_mailing_job.is_test = 0
|
||||
WHERE civicrm_mailing_event_bounce.id IS NULL
|
||||
AND civicrm_mailing_job.status = 'Complete'
|
||||
AND civicrm_mailing_job.end_date BETWEEN DATE_SUB(NOW(), INTERVAL $maxDays day) AND DATE_SUB(NOW(), INTERVAL $minDays day)
|
||||
AND (civicrm_email.reset_date IS NULL OR civicrm_email.reset_date < civicrm_mailing_job.start_date)
|
||||
GROUP BY civicrm_email.id
|
||||
";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$query = "
|
||||
UPDATE civicrm_email e
|
||||
INNER JOIN civicrm_email_temp_values et ON e.id = et.id
|
||||
SET e.on_hold = 0,
|
||||
e.hold_date = NULL,
|
||||
e.reset_date = et.reset_date
|
||||
";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
}
|
||||
|
||||
}
|
384
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Forward.php
Normal file
384
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Forward.php
Normal file
|
@ -0,0 +1,384 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new forward event, create a new contact if necessary
|
||||
*
|
||||
* @param $job_id
|
||||
* @param $queue_id
|
||||
* @param $hash
|
||||
* @param $forward_email
|
||||
* @param null $fromEmail
|
||||
* @param null $comment
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function &forward($job_id, $queue_id, $hash, $forward_email, $fromEmail = NULL, $comment = NULL) {
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
|
||||
$successfulForward = FALSE;
|
||||
$contact_id = NULL;
|
||||
if (!$q) {
|
||||
return $successfulForward;
|
||||
}
|
||||
|
||||
// Find the email address/contact, if it exists.
|
||||
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$location = CRM_Core_BAO_Location::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
$queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$forward = self::getTableName();
|
||||
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
$dao->query("
|
||||
SELECT $contact.id as contact_id,
|
||||
$email.id as email_id,
|
||||
$contact.do_not_email as do_not_email,
|
||||
$queueTable.id as queue_id
|
||||
FROM ($email, $job as temp_job)
|
||||
INNER JOIN $contact
|
||||
ON $email.contact_id = $contact.id
|
||||
LEFT JOIN $queueTable
|
||||
ON $email.id = $queueTable.email_id
|
||||
LEFT JOIN $job
|
||||
ON $queueTable.job_id = $job.id
|
||||
AND temp_job.mailing_id = $job.mailing_id
|
||||
WHERE $queueTable.job_id = $job_id
|
||||
AND $email.email = '" .
|
||||
CRM_Utils_Type::escape($forward_email, 'String') . "'"
|
||||
);
|
||||
|
||||
$dao->fetch();
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
if (isset($dao->queue_id) ||
|
||||
(isset($dao->do_not_email) && $dao->do_not_email == 1)
|
||||
) {
|
||||
// We already sent this mailing to $forward_email, or we should
|
||||
// never email this contact. Give up.
|
||||
|
||||
return $successfulForward;
|
||||
}
|
||||
|
||||
require_once 'api/api.php';
|
||||
$contactParams = array(
|
||||
'email' => $forward_email,
|
||||
'version' => 3,
|
||||
);
|
||||
$contactValues = civicrm_api('contact', 'get', $contactParams);
|
||||
$count = $contactValues['count'];
|
||||
|
||||
if ($count == 0) {
|
||||
// If the contact does not exist, create one.
|
||||
|
||||
$formatted = array(
|
||||
'contact_type' => 'Individual',
|
||||
'version' => 3,
|
||||
);
|
||||
$locationType = CRM_Core_BAO_LocationType::getDefault();
|
||||
$value = array(
|
||||
'email' => $forward_email,
|
||||
'location_type_id' => $locationType->id,
|
||||
);
|
||||
require_once 'CRM/Utils/DeprecatedUtils.php';
|
||||
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
|
||||
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
|
||||
$formatted['fixAddress'] = TRUE;
|
||||
$contact = civicrm_api('contact', 'create', $formatted);
|
||||
if (civicrm_error($contact)) {
|
||||
return $successfulForward;
|
||||
}
|
||||
$contact_id = $contact['id'];
|
||||
}
|
||||
$email = new CRM_Core_DAO_Email();
|
||||
$email->email = $forward_email;
|
||||
$email->find(TRUE);
|
||||
$email_id = $email->id;
|
||||
if (!$contact_id) {
|
||||
$contact_id = $email->contact_id;
|
||||
}
|
||||
|
||||
// Create a new queue event.
|
||||
|
||||
$queue_params = array(
|
||||
'email_id' => $email_id,
|
||||
'contact_id' => $contact_id,
|
||||
'job_id' => $job_id,
|
||||
);
|
||||
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::create($queue_params);
|
||||
|
||||
$forward = new CRM_Mailing_Event_BAO_Forward();
|
||||
$forward->time_stamp = date('YmdHis');
|
||||
$forward->event_queue_id = $queue_id;
|
||||
$forward->dest_queue_id = $queue->id;
|
||||
$forward->save();
|
||||
|
||||
$dao->reset();
|
||||
$dao->query(" SELECT $job.mailing_id as mailing_id
|
||||
FROM $job
|
||||
WHERE $job.id = " .
|
||||
CRM_Utils_Type::escape($job_id, 'Integer')
|
||||
);
|
||||
$dao->fetch();
|
||||
$mailing_obj = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing_obj->id = $dao->mailing_id;
|
||||
$mailing_obj->find(TRUE);
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
|
||||
$recipient = NULL;
|
||||
$attachments = NULL;
|
||||
$message = $mailing_obj->compose($job_id, $queue->id, $queue->hash,
|
||||
$queue->contact_id, $forward_email, $recipient, FALSE, NULL, $attachments, TRUE, $fromEmail
|
||||
);
|
||||
//append comment if added while forwarding.
|
||||
if (count($comment)) {
|
||||
$message->_txtbody = CRM_Utils_Array::value('body_text', $comment) . $message->_txtbody;
|
||||
if (!empty($comment['body_html'])) {
|
||||
$message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
|
||||
}
|
||||
}
|
||||
|
||||
$body = $message->get();
|
||||
$headers = $message->headers();
|
||||
|
||||
$result = NULL;
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$result = $mailer->send($recipient, $headers, $body);
|
||||
unset($errorScope);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'event_queue_id' => $queue->id,
|
||||
'job_id' => $job_id,
|
||||
'hash' => $queue->hash,
|
||||
);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
// Register the bounce event.
|
||||
|
||||
$params = array_merge($params,
|
||||
CRM_Mailing_BAO_BouncePattern::match($result->getMessage())
|
||||
);
|
||||
CRM_Mailing_Event_BAO_Bounce::create($params);
|
||||
}
|
||||
else {
|
||||
$successfulForward = TRUE;
|
||||
// Register the delivery event.
|
||||
|
||||
CRM_Mailing_Event_BAO_Delivered::create($params);
|
||||
}
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
return $successfulForward;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE
|
||||
) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$forward = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($forward.id) as forward
|
||||
FROM $forward
|
||||
INNER JOIN $queue
|
||||
ON $forward.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
// query was missing
|
||||
$dao->query($query);
|
||||
|
||||
if ($dao->fetch()) {
|
||||
return $dao->forward;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$forward = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $contact.display_name as from_name,
|
||||
$contact.id as from_id,
|
||||
$email.email as from_email,
|
||||
dest_contact.id as dest_id,
|
||||
dest_email.email as dest_email,
|
||||
$forward.time_stamp as date
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $forward
|
||||
ON $forward.event_queue_id = $queue.id
|
||||
INNER JOIN $queue as dest_queue
|
||||
ON $forward.dest_queue_id = dest_queue.id
|
||||
INNER JOIN $contact as dest_contact
|
||||
ON dest_queue.contact_id = dest_contact.id
|
||||
INNER JOIN $email as dest_email
|
||||
ON dest_queue.email_id = dest_email.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, dest_contact.id, dest_email.email, $forward.time_stamp ";
|
||||
}
|
||||
|
||||
$orderBy = "$contact.sort_name ASC, {$forward}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$from_url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->from_id}"
|
||||
);
|
||||
$dest_url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->dest_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'from_name' => "<a href=\"$from_url\">{$dao->from_name}</a>",
|
||||
'from_email' => $dao->from_email,
|
||||
'dest_email' => "<a href=\"$dest_url\">{$dao->dest_email}</a>",
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
324
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Opened.php
Normal file
324
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Opened.php
Normal file
|
@ -0,0 +1,324 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an open event.
|
||||
*
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID of the recipient.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function open($queue_id) {
|
||||
// First make sure there's a matching queue event.
|
||||
|
||||
$success = FALSE;
|
||||
|
||||
$q = new CRM_Mailing_Event_BAO_Queue();
|
||||
$q->id = $queue_id;
|
||||
if ($q->find(TRUE)) {
|
||||
$oe = new CRM_Mailing_Event_BAO_Opened();
|
||||
$oe->event_queue_id = $queue_id;
|
||||
$oe->time_stamp = date('YmdHis');
|
||||
$oe->save();
|
||||
$success = TRUE;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
*
|
||||
* @param string $toDate
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount(
|
||||
$mailing_id,
|
||||
$job_id = NULL,
|
||||
$is_distinct = FALSE,
|
||||
$toDate = NULL
|
||||
) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$open = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($open.id) as opened
|
||||
FROM $open
|
||||
INNER JOIN $queue
|
||||
ON $open.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($toDate)) {
|
||||
$query .= " AND $open.time_stamp <= $toDate";
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
$dao->fetch();
|
||||
if ($is_distinct) {
|
||||
return $dao->N;
|
||||
}
|
||||
else {
|
||||
return $dao->opened ? $dao->opened : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CRM-12814
|
||||
* Get opened count for each mailing for a given set of mailing IDs
|
||||
*
|
||||
* @param $mailingIDs
|
||||
*
|
||||
* @return array
|
||||
* Opened count per mailing ID
|
||||
*/
|
||||
public static function getMailingTotalCount($mailingIDs) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
$openedCount = array();
|
||||
|
||||
$open = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailingIDs = implode(',', $mailingIDs);
|
||||
|
||||
$query = "
|
||||
SELECT $job.mailing_id as mailingID, COUNT($open.id) as opened
|
||||
FROM $open
|
||||
INNER JOIN $queue
|
||||
ON $open.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $job.mailing_id IN ({$mailingIDs})
|
||||
GROUP BY civicrm_mailing_job.mailing_id
|
||||
";
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$openedCount[$dao->mailingID] = $dao->opened;
|
||||
}
|
||||
return $openedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opened count for each mailing for a given set of mailing IDs and a specific contact.
|
||||
*
|
||||
* @param int $mailingIDs
|
||||
* IDs of the mailing (comma separated).
|
||||
* @param int $contactID
|
||||
* ID of the contact.
|
||||
*
|
||||
* @return array
|
||||
* Count per mailing ID
|
||||
*/
|
||||
public static function getMailingContactCount($mailingIDs, $contactID) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
$openedCount = array();
|
||||
|
||||
$open = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailingIDs = implode(',', $mailingIDs);
|
||||
|
||||
$query = "
|
||||
SELECT $job.mailing_id as mailingID, COUNT($open.id) as opened
|
||||
FROM $open
|
||||
INNER JOIN $queue
|
||||
ON $open.event_queue_id = $queue.id
|
||||
AND $queue.contact_id = $contactID
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $job.mailing_id IN ({$mailingIDs})
|
||||
GROUP BY civicrm_mailing_job.mailing_id
|
||||
";
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$openedCount[$dao->mailingID] = $dao->opened;
|
||||
}
|
||||
|
||||
return $openedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @param int $contact_id
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $contact_id = NULL
|
||||
) {
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$open = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$selectClauses = array(
|
||||
"$contact.display_name as display_name",
|
||||
"$contact.id as contact_id",
|
||||
"$email.email as email",
|
||||
($is_distinct) ? "MIN({$open}.time_stamp) as date" : "{$open}.time_stamp as date",
|
||||
);
|
||||
|
||||
if ($is_distinct) {
|
||||
$groupBy = " GROUP BY $queue.id ";
|
||||
$select = CRM_Contact_BAO_Query::appendAnyValueToSelect($selectClauses, "$queue.id");
|
||||
}
|
||||
else {
|
||||
$groupBy = '';
|
||||
$select = " SELECT " . implode(', ', $selectClauses);
|
||||
}
|
||||
|
||||
$query = "
|
||||
$select
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $open
|
||||
ON $open.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if (!empty($contact_id)) {
|
||||
$query .= " AND $contact.id = " . CRM_Utils_Type::escape($contact_id, 'Integer');
|
||||
}
|
||||
|
||||
$query .= $groupBy;
|
||||
|
||||
$orderBy = "sort_name ASC";
|
||||
if (!$is_distinct) {
|
||||
$orderBy .= ", {$open}.time_stamp DESC";
|
||||
}
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
334
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Queue.php
Normal file
334
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Queue.php
Normal file
|
@ -0,0 +1,334 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Queue extends CRM_Mailing_Event_DAO_Queue {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue a new recipient.
|
||||
*
|
||||
* @param array $params
|
||||
* Values of the new EventQueue.
|
||||
*
|
||||
* @return CRM_Mailing_Event_BAO_Queue
|
||||
* The new EventQueue
|
||||
*/
|
||||
public static function create($params) {
|
||||
$eq = new CRM_Mailing_Event_BAO_Queue();
|
||||
$eq->copyValues($params);
|
||||
if (empty($params['id']) && empty($params['hash'])) {
|
||||
$eq->hash = self::hash($params);
|
||||
}
|
||||
$eq->save();
|
||||
return $eq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a security hash from the job, email and contact ids.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return int
|
||||
* The hash
|
||||
*/
|
||||
public static function hash($params) {
|
||||
$jobId = $params['job_id'];
|
||||
$emailId = CRM_Utils_Array::value('email_id', $params, '');
|
||||
$contactId = $params['contact_id'];
|
||||
|
||||
return substr(sha1("{$jobId}:{$emailId}:{$contactId}:" . time()),
|
||||
0, 16
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that a queue event exists with the specified id/job id/hash.
|
||||
*
|
||||
* @param int $job_id
|
||||
* The job ID of the event to find.
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID to find.
|
||||
* @param string $hash
|
||||
* The hash to validate against.
|
||||
*
|
||||
* @return object|null
|
||||
* The queue event if verified, or null
|
||||
*/
|
||||
public static function &verify($job_id, $queue_id, $hash) {
|
||||
$success = NULL;
|
||||
$q = new CRM_Mailing_Event_BAO_Queue();
|
||||
if (!empty($job_id) && !empty($queue_id) && !empty($hash)) {
|
||||
$q->id = $queue_id;
|
||||
$q->job_id = $job_id;
|
||||
$q->hash = $hash;
|
||||
if ($q->find(TRUE)) {
|
||||
$success = $q;
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a queue event ID, find the corresponding email address.
|
||||
*
|
||||
* @param int $queue_id
|
||||
* The queue event ID.
|
||||
*
|
||||
* @return string
|
||||
* The email address
|
||||
*/
|
||||
public static function getEmailAddress($queue_id) {
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
$eq = self::getTableName();
|
||||
$query = " SELECT $email.email as email
|
||||
FROM $email
|
||||
INNER JOIN $eq
|
||||
ON $eq.email_id = $email.id
|
||||
WHERE $eq.id = " . CRM_Utils_Type::rule($queue_id, 'Integer');
|
||||
|
||||
$q = new CRM_Mailing_Event_BAO_Queue();
|
||||
$q->query($query);
|
||||
if (!$q->fetch()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $q->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count up events given a mailing id and optional job id.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing to count.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to limit results.
|
||||
*
|
||||
* @return int
|
||||
* Number of matching events
|
||||
*/
|
||||
public static function getTotalCount($mailing_id, $job_id = NULL) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$queue = self::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$dao->query("
|
||||
SELECT COUNT(*) as queued
|
||||
FROM $queue
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer') . ($job_id ? " AND $job.id = " . CRM_Utils_Type::escape($job_id,
|
||||
'Integer'
|
||||
) : '')
|
||||
);
|
||||
|
||||
$dao->fetch();
|
||||
return $dao->queued;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL, $offset = NULL,
|
||||
$rowCount = NULL, $sort = NULL
|
||||
) {
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$queue = self::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$orderBy = "sort_name ASC, {$job}.start_date DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT $queue.id as queue_id,
|
||||
$contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$job.start_date as date
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[$dao->queue_id] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mailing object for this queue event instance.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return object
|
||||
* Mailing BAO
|
||||
*/
|
||||
public function &getMailing() {
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$jobs = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailings = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$queue = self::getTableName();
|
||||
|
||||
$mailing->query("
|
||||
SELECT $mailings.*
|
||||
FROM $mailings
|
||||
INNER JOIN $jobs
|
||||
ON $jobs.mailing_id = $mailings.id
|
||||
INNER JOIN $queue
|
||||
ON $queue.job_id = $jobs.id
|
||||
WHERE $queue.id = {$this->id}");
|
||||
$mailing->fetch();
|
||||
return $mailing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $queueID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getContactInfo($queueID) {
|
||||
$query = "
|
||||
SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id,
|
||||
civicrm_contact.display_name as display_name,
|
||||
civicrm_email.email as email
|
||||
FROM civicrm_mailing_event_queue,
|
||||
civicrm_contact,
|
||||
civicrm_email
|
||||
WHERE civicrm_mailing_event_queue.contact_id = civicrm_contact.id
|
||||
AND civicrm_mailing_event_queue.email_id = civicrm_email.id
|
||||
AND civicrm_mailing_event_queue.id = " . CRM_Utils_Type::escape($queueID, 'Integer');
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$displayName = 'Unknown';
|
||||
$email = 'Unknown';
|
||||
if ($dao->fetch()) {
|
||||
$displayName = $dao->display_name;
|
||||
$email = $dao->email;
|
||||
}
|
||||
|
||||
return array($displayName, $email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param null $now
|
||||
*/
|
||||
public static function bulkCreate($params, $now = NULL) {
|
||||
if (!$now) {
|
||||
$now = time();
|
||||
}
|
||||
|
||||
// construct a bulk insert statement
|
||||
$values = array();
|
||||
foreach ($params as $param) {
|
||||
$values[] = "( {$param[0]}, {$param[1]}, {$param[2]}, {$param[3]}, '" . substr(sha1("{$param[0]}:{$param[1]}:{$param[2]}:{$param[3]}:{$now}"),
|
||||
0, 16
|
||||
) . "' )";
|
||||
}
|
||||
|
||||
while (!empty($values)) {
|
||||
$input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
|
||||
$str = implode(',', $input);
|
||||
$sql = "INSERT INTO civicrm_mailing_event_queue ( job_id, email_id, contact_id, phone_id, hash ) VALUES $str;";
|
||||
CRM_Core_DAO::executeQuery($sql);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
452
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Reply.php
Normal file
452
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Reply.php
Normal file
|
@ -0,0 +1,452 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
require_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Event_BAO_Reply
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a reply event.
|
||||
*
|
||||
* @param int $job_id
|
||||
* The job ID of the reply.
|
||||
* @param int $queue_id
|
||||
* The queue event id.
|
||||
* @param string $hash
|
||||
* The hash.
|
||||
*
|
||||
* @param null $replyto
|
||||
*
|
||||
* @return object|null
|
||||
* The mailing object, or null on failure
|
||||
*/
|
||||
public static function &reply($job_id, $queue_id, $hash, $replyto = NULL) {
|
||||
// First make sure there's a matching queue event.
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
|
||||
$success = NULL;
|
||||
|
||||
if (!$q) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$mailings = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$jobs = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailing->query(
|
||||
"SELECT * FROM $mailings
|
||||
INNER JOIN $jobs
|
||||
ON $jobs.mailing_id = $mailings.id
|
||||
WHERE $jobs.id = {$q->job_id}"
|
||||
);
|
||||
$mailing->fetch();
|
||||
if ($mailing->auto_responder) {
|
||||
self::autoRespond($mailing, $queue_id, $replyto);
|
||||
}
|
||||
|
||||
$re = new CRM_Mailing_Event_BAO_Reply();
|
||||
$re->event_queue_id = $queue_id;
|
||||
$re->time_stamp = date('YmdHis');
|
||||
$re->save();
|
||||
|
||||
if (!$mailing->forward_replies || empty($mailing->replyto_email)) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
return $mailing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward a mailing reply.
|
||||
*
|
||||
* @param int $queue_id
|
||||
* Queue event ID of the sender.
|
||||
* @param string $mailing
|
||||
* The mailing object.
|
||||
* @param string $bodyTxt
|
||||
* Text part of the body (ignored if $fullEmail provided).
|
||||
* @param string $replyto
|
||||
* Reply-to of the incoming message.
|
||||
* @param string $bodyHTML
|
||||
* HTML part of the body (ignored if $fullEmail provided).
|
||||
* @param string $fullEmail
|
||||
* Whole email to forward in one string.
|
||||
*/
|
||||
public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTML = NULL, &$fullEmail = NULL) {
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
$emails = CRM_Core_BAO_Email::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$contacts = CRM_Contact_BAO_Contact::getTableName();
|
||||
$domain_id = CRM_Core_Config::domainID();
|
||||
$domainValues = civicrm_api3('Domain', 'get', array('sequential' => 1, 'id' => $domain_id));
|
||||
|
||||
$eq = new CRM_Core_DAO();
|
||||
$eq->query("SELECT $contacts.display_name as display_name,
|
||||
$emails.email as email,
|
||||
$queue.job_id as job_id,
|
||||
$queue.hash as hash
|
||||
FROM $queue
|
||||
INNER JOIN $contacts
|
||||
ON $queue.contact_id = $contacts.id
|
||||
INNER JOIN $emails
|
||||
ON $queue.email_id = $emails.id
|
||||
WHERE $queue.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')
|
||||
);
|
||||
$eq->fetch();
|
||||
|
||||
if ($fullEmail) {
|
||||
// parse the email and set a new destination
|
||||
$parser = new ezcMailParser();
|
||||
$set = new ezcMailVariableSet($fullEmail);
|
||||
$parsed = array_shift($parser->parseMail($set));
|
||||
$parsed->to = array(new ezcMailAddress($mailing->replyto_email));
|
||||
|
||||
// CRM-5567: we need to set Reply-To: so that any response
|
||||
// to the forward goes to the sender of the reply
|
||||
$parsed->setHeader('Reply-To', $replyto instanceof ezcMailAddress ? $replyto : $parsed->from->__toString());
|
||||
|
||||
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
|
||||
$domainEmail = $domainValues['values'][0]['from_email'];
|
||||
$parsed->setHeader('Resent-From', $domainEmail);
|
||||
$parsed->setHeader('Resent-Date', date('r'));
|
||||
|
||||
// $h must be an array, so we can't use generateHeaders()'s result,
|
||||
// but we have to regenerate the headers because we changed To
|
||||
$parsed->generateHeaders();
|
||||
$h = $parsed->headers->getCaseSensitiveArray();
|
||||
$b = $parsed->generateBody();
|
||||
|
||||
// strip Return-Path of possible bounding brackets, CRM-4502
|
||||
if (!empty($h['Return-Path'])) {
|
||||
$h['Return-Path'] = trim($h['Return-Path'], '<>');
|
||||
}
|
||||
|
||||
// FIXME: ugly hack - find the first MIME boundary in
|
||||
// the body and make the boundary in the header match it
|
||||
$ct = $h['Content-Type'];
|
||||
if (substr_count($ct, 'boundary=')) {
|
||||
$matches = array();
|
||||
preg_match('/^--(.*)$/m', $b, $matches);
|
||||
$boundary = rtrim($matches[1]);
|
||||
$parts = explode('boundary=', $ct);
|
||||
$ct = "{$parts[0]} boundary=\"$boundary\"";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
if (empty($eq->display_name)) {
|
||||
$from = $eq->email;
|
||||
}
|
||||
else {
|
||||
$from = "\"{$eq->display_name}\" <{$eq->email}>";
|
||||
}
|
||||
|
||||
$message = new Mail_mime("\n");
|
||||
|
||||
$headers = array(
|
||||
'Subject' => "Re: {$mailing->subject}",
|
||||
'To' => $mailing->replyto_email,
|
||||
'From' => $from,
|
||||
'Reply-To' => empty($replyto) ? $eq->email : $replyto,
|
||||
'Return-Path' => "do-not-reply@{$emailDomain}",
|
||||
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
|
||||
'Resent-From' => $domainValues['values'][0]['from_email'],
|
||||
'Resent-Date' => date('r'),
|
||||
);
|
||||
|
||||
$message->setTxtBody($bodyTxt);
|
||||
$message->setHTMLBody($bodyHTML);
|
||||
$b = CRM_Utils_Mail::setMimeParams($message);
|
||||
$h = $message->headers($headers);
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'r', $eq->job_id, $queue_id, $eq->hash);
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$mailer->send($mailing->replyto_email, $h, $b);
|
||||
unset($errorScope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an automated response.
|
||||
*
|
||||
* @param object $mailing
|
||||
* The mailing object.
|
||||
* @param int $queue_id
|
||||
* The queue ID.
|
||||
* @param string $replyto
|
||||
* Optional reply-to from the reply.
|
||||
*/
|
||||
private static function autoRespond(&$mailing, $queue_id, $replyto) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
$contacts = CRM_Contact_DAO_Contact::getTableName();
|
||||
$email = CRM_Core_DAO_Email::getTableName();
|
||||
$queue = CRM_Mailing_Event_DAO_Queue::getTableName();
|
||||
|
||||
$eq = new CRM_Core_DAO();
|
||||
$eq->query(
|
||||
"SELECT $contacts.preferred_mail_format as format,
|
||||
$email.email as email,
|
||||
$queue.job_id as job_id,
|
||||
$queue.hash as hash
|
||||
FROM $contacts
|
||||
INNER JOIN $queue ON $queue.contact_id = $contacts.id
|
||||
INNER JOIN $email ON $queue.email_id = $email.id
|
||||
WHERE $queue.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')
|
||||
);
|
||||
$eq->fetch();
|
||||
|
||||
$to = empty($replyto) ? $eq->email : $replyto;
|
||||
|
||||
$component = new CRM_Mailing_BAO_Component();
|
||||
$component->id = $mailing->reply_id;
|
||||
$component->find(TRUE);
|
||||
|
||||
$message = new Mail_Mime("\n");
|
||||
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
$headers = array(
|
||||
'Subject' => $component->subject,
|
||||
'To' => $to,
|
||||
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
|
||||
'Reply-To' => "do-not-reply@$emailDomain",
|
||||
'Return-Path' => "do-not-reply@$emailDomain",
|
||||
);
|
||||
|
||||
// TODO: do we need reply tokens?
|
||||
$html = $component->body_html;
|
||||
if ($component->body_text) {
|
||||
$text = $component->body_text;
|
||||
}
|
||||
else {
|
||||
$text = CRM_Utils_String::htmlToText($component->body_html);
|
||||
}
|
||||
|
||||
$bao = new CRM_Mailing_BAO_Mailing();
|
||||
$bao->body_text = $text;
|
||||
$bao->body_html = $html;
|
||||
$tokens = $bao->getTokens();
|
||||
|
||||
if ($eq->format == 'HTML' || $eq->format == 'Both') {
|
||||
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceMailingTokens($html, $mailing, NULL, $tokens['html']);
|
||||
$message->setHTMLBody($html);
|
||||
}
|
||||
if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
|
||||
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceMailingTokens($text, $mailing, NULL, $tokens['text']);
|
||||
$message->setTxtBody($text);
|
||||
}
|
||||
|
||||
$b = CRM_Utils_Mail::setMimeParams($message);
|
||||
$h = $message->headers($headers);
|
||||
CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'a', $eq->job_id, queue_id, $eq->hash);
|
||||
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$mailer->send($to, $h, $b);
|
||||
unset($errorScope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE
|
||||
) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$reply = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($reply.id) as reply
|
||||
FROM $reply
|
||||
INNER JOIN $queue
|
||||
ON $reply.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
// query was missing
|
||||
$dao->query($query);
|
||||
|
||||
if ($dao->fetch()) {
|
||||
return $dao->reply;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$reply = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$reply.time_stamp as date
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $reply
|
||||
ON $reply.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, $contact.id, $reply.time_stamp ";
|
||||
}
|
||||
|
||||
$orderBy = "sort_name ASC, {$reply}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
292
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Resubscribe.php
Normal file
292
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Resubscribe.php
Normal file
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
require_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Event_BAO_Resubscribe
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Resubscribe {
|
||||
|
||||
/**
|
||||
* Resubscribe a contact to the groups, he/she was unsubscribed from.
|
||||
*
|
||||
* @param int $job_id
|
||||
* The job ID.
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID of the recipient.
|
||||
* @param string $hash
|
||||
* The hash.
|
||||
*
|
||||
* @return array|null
|
||||
* $groups Array of all groups to which the contact was added, or null if the queue event could not be found.
|
||||
*/
|
||||
public static function &resub_to_mailing($job_id, $queue_id, $hash) {
|
||||
// First make sure there's a matching queue event.
|
||||
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
$success = NULL;
|
||||
if (!$q) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
// check if this queue_id was actually unsubscribed
|
||||
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$ue->event_queue_id = $queue_id;
|
||||
$ue->org_unsubscribe = 0;
|
||||
if (!$ue->find(TRUE)) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
$contact_id = $q->contact_id;
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$do = new CRM_Core_DAO();
|
||||
$mg = CRM_Mailing_DAO_MailingGroup::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$group = CRM_Contact_BAO_Group::getTableName();
|
||||
$gc = CRM_Contact_BAO_GroupContact::getTableName();
|
||||
|
||||
// We Need the mailing Id for the hook...
|
||||
$do->query("SELECT $job.mailing_id as mailing_id
|
||||
FROM $job
|
||||
WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
|
||||
$do->fetch();
|
||||
$mailing_id = $do->mailing_id;
|
||||
|
||||
$do->query("
|
||||
SELECT $mg.entity_table as entity_table,
|
||||
$mg.entity_id as entity_id
|
||||
FROM $mg
|
||||
INNER JOIN $job
|
||||
ON $job.mailing_id = $mg.mailing_id
|
||||
INNER JOIN $group
|
||||
ON $mg.entity_id = $group.id
|
||||
WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer') . "
|
||||
AND $mg.group_type IN ( 'Include', 'Base' )
|
||||
AND $group.is_hidden = 0"
|
||||
);
|
||||
|
||||
// Make a list of groups and a list of prior mailings that received
|
||||
// this mailing.
|
||||
$groups = array();
|
||||
$mailings = array();
|
||||
|
||||
while ($do->fetch()) {
|
||||
if ($do->entity_table == $group) {
|
||||
$groups[$do->entity_id] = NULL;
|
||||
}
|
||||
elseif ($do->entity_table == $mailing) {
|
||||
$mailings[] = $do->entity_id;
|
||||
}
|
||||
}
|
||||
|
||||
// As long as we have prior mailings, find their groups and add to the
|
||||
// list.
|
||||
while (!empty($mailings)) {
|
||||
$do->query("
|
||||
SELECT $mg.entity_table as entity_table,
|
||||
$mg.entity_id as entity_id
|
||||
FROM $mg
|
||||
WHERE $mg.mailing_id IN (" . implode(', ', $mailings) . ")
|
||||
AND $mg.group_type = 'Include'");
|
||||
|
||||
$mailings = array();
|
||||
|
||||
while ($do->fetch()) {
|
||||
if ($do->entity_table == $group) {
|
||||
$groups[$do->entity_id] = TRUE;
|
||||
}
|
||||
elseif ($do->entity_table == $mailing) {
|
||||
$mailings[] = $do->entity_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$group_ids = array_keys($groups);
|
||||
$base_groups = NULL;
|
||||
CRM_Utils_Hook::unsubscribeGroups('resubscribe', $mailing_id, $contact_id, $group_ids, $base_groups);
|
||||
|
||||
// Now we have a complete list of recipient groups. Filter out all
|
||||
// those except smart groups and those that the contact belongs to.
|
||||
$do->query("
|
||||
SELECT $group.id as group_id,
|
||||
$group.title as title
|
||||
FROM $group
|
||||
LEFT JOIN $gc
|
||||
ON $gc.group_id = $group.id
|
||||
WHERE $group.id IN (" . implode(', ', $group_ids) . ")
|
||||
AND ($group.saved_search_id is not null
|
||||
OR ($gc.contact_id = $contact_id
|
||||
AND $gc.status = 'Removed')
|
||||
)");
|
||||
|
||||
while ($do->fetch()) {
|
||||
$groups[$do->group_id] = $do->title;
|
||||
}
|
||||
|
||||
$contacts = array($contact_id);
|
||||
foreach ($groups as $group_id => $group_name) {
|
||||
$notadded = 0;
|
||||
if ($group_name) {
|
||||
list($total, $added, $notadded) = CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email');
|
||||
}
|
||||
if ($notadded) {
|
||||
unset($groups[$group_id]);
|
||||
}
|
||||
}
|
||||
|
||||
// remove entry from Unsubscribe table.
|
||||
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$ue->event_queue_id = $queue_id;
|
||||
$ue->org_resubscribe = 0;
|
||||
if ($ue->find(TRUE)) {
|
||||
$ue->delete();
|
||||
}
|
||||
|
||||
$transaction->commit();
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a response email informing the contact of the groups to which he/she
|
||||
* has been resubscribed.
|
||||
*
|
||||
* @param string $queue_id
|
||||
* The queue event ID.
|
||||
* @param array $groups
|
||||
* List of group IDs.
|
||||
* @param bool $is_domain
|
||||
* Is this domain-level?.
|
||||
* @param int $job
|
||||
* The job ID.
|
||||
*/
|
||||
public static function send_resub_response($queue_id, $groups, $is_domain = FALSE, $job) {
|
||||
// param is_domain is not supported as of now.
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
|
||||
$jobTable = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
|
||||
$contacts = CRM_Contact_DAO_Contact::getTableName();
|
||||
$email = CRM_Core_DAO_Email::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
|
||||
//get the default domain email address.
|
||||
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
$dao = new CRM_Mailing_BAO_Mailing();
|
||||
$dao->query(" SELECT * FROM $mailingTable
|
||||
INNER JOIN $jobTable ON
|
||||
$jobTable.mailing_id = $mailingTable.id
|
||||
WHERE $jobTable.id = $job");
|
||||
$dao->fetch();
|
||||
|
||||
$component = new CRM_Mailing_BAO_Component();
|
||||
$component->id = $dao->resubscribe_id;
|
||||
$component->find(TRUE);
|
||||
|
||||
$html = $component->body_html;
|
||||
if ($component->body_text) {
|
||||
$text = $component->body_text;
|
||||
}
|
||||
else {
|
||||
$text = CRM_Utils_String::htmlToText($component->body_html);
|
||||
}
|
||||
|
||||
$eq = new CRM_Core_DAO();
|
||||
$eq->query(
|
||||
"SELECT $contacts.preferred_mail_format as format,
|
||||
$contacts.id as contact_id,
|
||||
$email.email as email,
|
||||
$queue.hash as hash
|
||||
FROM $contacts
|
||||
INNER JOIN $queue ON $queue.contact_id = $contacts.id
|
||||
INNER JOIN $email ON $queue.email_id = $email.id
|
||||
WHERE $queue.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')
|
||||
);
|
||||
$eq->fetch();
|
||||
foreach ($groups as $key => $value) {
|
||||
if (!$value) {
|
||||
unset($groups[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$message = new Mail_mime("\n");
|
||||
|
||||
list($addresses, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls($job, $queue_id, $eq->hash, $eq->email);
|
||||
$bao = new CRM_Mailing_BAO_Mailing();
|
||||
$bao->body_text = $text;
|
||||
$bao->body_html = $html;
|
||||
$tokens = $bao->getTokens();
|
||||
if ($eq->format == 'HTML' || $eq->format == 'Both') {
|
||||
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceResubscribeTokens($html, $domain, $groups, TRUE, $eq->contact_id, $eq->hash);
|
||||
$html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']);
|
||||
$message->setHTMLBody($html);
|
||||
}
|
||||
if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
|
||||
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, TRUE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceResubscribeTokens($text, $domain, $groups, FALSE, $eq->contact_id, $eq->hash);
|
||||
$text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']);
|
||||
$message->setTxtBody($text);
|
||||
}
|
||||
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
$headers = array(
|
||||
'Subject' => $component->subject,
|
||||
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
|
||||
'To' => $eq->email,
|
||||
'Reply-To' => "do-not-reply@$emailDomain",
|
||||
'Return-Path' => "do-not-reply@$emailDomain",
|
||||
);
|
||||
CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'e', $job, $queue_id, $eq->hash);
|
||||
$b = CRM_Utils_Mail::setMimeParams($message);
|
||||
$h = $message->headers($headers);
|
||||
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$mailer->send($eq->email, $h, $b);
|
||||
unset($errorScope);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
406
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Subscribe.php
Normal file
406
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Subscribe.php
Normal file
|
@ -0,0 +1,406 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Event_BAO_Subscribe
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Subscribe extends CRM_Mailing_Event_DAO_Subscribe {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a subscription event. Create a new contact if one does not
|
||||
* already exist.
|
||||
*
|
||||
* @param int $group_id
|
||||
* The group id to subscribe to.
|
||||
* @param string $email
|
||||
* The email address of the (new) contact.
|
||||
* @param int $contactId
|
||||
* Currently used during event registration/contribution.
|
||||
* Specifically to avoid linking group to wrong duplicate contact
|
||||
* during event registration.
|
||||
* @param string $context
|
||||
*
|
||||
* @return int|null
|
||||
* $se_id The id of the subscription event, null on failure
|
||||
*/
|
||||
public static function &subscribe($group_id, $email, $contactId = NULL, $context = NULL) {
|
||||
// CRM-1797 - allow subscription only to public groups
|
||||
$params = array('id' => (int) $group_id);
|
||||
$defaults = array();
|
||||
$contact_id = NULL;
|
||||
$success = NULL;
|
||||
|
||||
$bao = CRM_Contact_BAO_Group::retrieve($params, $defaults);
|
||||
if ($bao && substr($bao->visibility, 0, 6) != 'Public' && $context != 'profile') {
|
||||
return $success;
|
||||
}
|
||||
|
||||
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
|
||||
$email = $strtolower($email);
|
||||
|
||||
// process the query only if no contactId
|
||||
if ($contactId) {
|
||||
$contact_id = $contactId;
|
||||
}
|
||||
else {
|
||||
// First, find out if the contact already exists.
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT contact_a.id as contact_id
|
||||
FROM civicrm_contact contact_a
|
||||
LEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id
|
||||
WHERE civicrm_email.email = %1 AND contact_a.is_deleted = 0";
|
||||
|
||||
$params = array(1 => array($email, 'String'));
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
// lets just use the first contact id we got
|
||||
if ($dao->fetch()) {
|
||||
$contact_id = $dao->contact_id;
|
||||
}
|
||||
$dao->free();
|
||||
}
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
if (!$contact_id) {
|
||||
$locationType = CRM_Core_BAO_LocationType::getDefault();
|
||||
$formatted = array(
|
||||
'contact_type' => 'Individual',
|
||||
'email' => $email,
|
||||
'location_type_id' => $locationType->id,
|
||||
);
|
||||
|
||||
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
|
||||
$formatted['fixAddress'] = TRUE;
|
||||
$contact = civicrm_api3('contact', 'create', $formatted);
|
||||
if (civicrm_error($contact)) {
|
||||
return $success;
|
||||
}
|
||||
$contact_id = $contact['id'];
|
||||
}
|
||||
elseif (!is_numeric($contact_id) &&
|
||||
(int ) $contact_id > 0
|
||||
) {
|
||||
// make sure contact_id is numeric
|
||||
return $success;
|
||||
}
|
||||
|
||||
// Get the primary email id from the contact to use as a hash input.
|
||||
$query = "
|
||||
SELECT civicrm_email.id as email_id
|
||||
FROM civicrm_email
|
||||
WHERE civicrm_email.email = %1
|
||||
AND civicrm_email.contact_id = %2";
|
||||
$params = array(
|
||||
1 => array($email, 'String'),
|
||||
2 => array($contact_id, 'Integer'),
|
||||
);
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
|
||||
if (!$dao->fetch()) {
|
||||
CRM_Core_Error::fatal('Please file an issue with the backtrace');
|
||||
return $success;
|
||||
}
|
||||
|
||||
$se = new CRM_Mailing_Event_BAO_Subscribe();
|
||||
$se->group_id = $group_id;
|
||||
$se->contact_id = $contact_id;
|
||||
$se->time_stamp = date('YmdHis');
|
||||
$se->hash = substr(sha1("{$group_id}:{$contact_id}:{$dao->email_id}:" . time()),
|
||||
0, 16
|
||||
);
|
||||
$se->save();
|
||||
|
||||
$contacts = array($contact_id);
|
||||
CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id,
|
||||
'Email', 'Pending', $se->id
|
||||
);
|
||||
|
||||
$transaction->commit();
|
||||
return $se;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the hash of a subscription event.
|
||||
*
|
||||
* @param int $contact_id
|
||||
* ID of the contact.
|
||||
* @param int $subscribe_id
|
||||
* ID of the subscription event.
|
||||
* @param string $hash
|
||||
* Hash to verify.
|
||||
*
|
||||
* @return object|null
|
||||
* The subscribe event object, or null on failure
|
||||
*/
|
||||
public static function &verify($contact_id, $subscribe_id, $hash) {
|
||||
$success = NULL;
|
||||
$se = new CRM_Mailing_Event_BAO_Subscribe();
|
||||
$se->contact_id = $contact_id;
|
||||
$se->id = $subscribe_id;
|
||||
$se->hash = $hash;
|
||||
if ($se->find(TRUE)) {
|
||||
$success = $se;
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask a contact for subscription confirmation (opt-in)
|
||||
*
|
||||
* @param string $email
|
||||
* The email address.
|
||||
*/
|
||||
public function send_confirm_request($email) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
|
||||
//get the default domain email address.
|
||||
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
$localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
$confirm = implode($config->verpSeparator,
|
||||
array(
|
||||
$localpart . 'c',
|
||||
$this->contact_id,
|
||||
$this->id,
|
||||
$this->hash,
|
||||
)
|
||||
) . "@$emailDomain";
|
||||
|
||||
$group = new CRM_Contact_BAO_Group();
|
||||
$group->id = $this->group_id;
|
||||
$group->find(TRUE);
|
||||
|
||||
$component = new CRM_Mailing_BAO_Component();
|
||||
$component->is_default = 1;
|
||||
$component->is_active = 1;
|
||||
$component->component_type = 'Subscribe';
|
||||
|
||||
$component->find(TRUE);
|
||||
|
||||
$headers = array(
|
||||
'Subject' => $component->subject,
|
||||
'From' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
|
||||
'To' => $email,
|
||||
'Reply-To' => $confirm,
|
||||
'Return-Path' => "do-not-reply@$emailDomain",
|
||||
);
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/mailing/confirm',
|
||||
"reset=1&cid={$this->contact_id}&sid={$this->id}&h={$this->hash}",
|
||||
TRUE
|
||||
);
|
||||
|
||||
$html = $component->body_html;
|
||||
|
||||
if ($component->body_text) {
|
||||
$text = $component->body_text;
|
||||
}
|
||||
else {
|
||||
$text = CRM_Utils_String::htmlToText($component->body_html);
|
||||
}
|
||||
|
||||
$bao = new CRM_Mailing_BAO_Mailing();
|
||||
$bao->body_text = $text;
|
||||
$bao->body_html = $html;
|
||||
$tokens = $bao->getTokens();
|
||||
|
||||
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceSubscribeTokens($html,
|
||||
$group->title,
|
||||
$url, TRUE
|
||||
);
|
||||
|
||||
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceSubscribeTokens($text,
|
||||
$group->title,
|
||||
$url, FALSE
|
||||
);
|
||||
// render the & entities in text mode, so that the links work
|
||||
$text = str_replace('&', '&', $text);
|
||||
|
||||
$message = new Mail_mime("\n");
|
||||
|
||||
$message->setHTMLBody($html);
|
||||
$message->setTxtBody($text);
|
||||
$b = CRM_Utils_Mail::setMimeParams($message);
|
||||
$h = $message->headers($headers);
|
||||
CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 's',
|
||||
$this->contact_id,
|
||||
$this->id,
|
||||
$this->hash
|
||||
);
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$mailer->send($email, $h, $b);
|
||||
unset($errorScope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the domain object given a subscribe event.
|
||||
*
|
||||
* @param int $subscribe_id
|
||||
* ID of the subscribe event.
|
||||
*
|
||||
* @return object
|
||||
* $domain The domain owning the event
|
||||
*/
|
||||
public static function &getDomain($subscribe_id) {
|
||||
return CRM_Core_BAO_Domain::getDomain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group details to which given email belongs.
|
||||
*
|
||||
* @param string $email
|
||||
* Email of the contact.
|
||||
* @param int $contactID
|
||||
* ContactID if we want an exact match.
|
||||
*
|
||||
* @return array
|
||||
* array of group ids
|
||||
*/
|
||||
public static function getContactGroups($email, $contactID = NULL) {
|
||||
if ($contactID) {
|
||||
$query = "
|
||||
SELECT DISTINCT group_a.group_id, group_a.status, civicrm_group.title
|
||||
FROM civicrm_group_contact group_a
|
||||
LEFT JOIN civicrm_group ON civicrm_group.id = group_a.group_id
|
||||
LEFT JOIN civicrm_contact ON ( group_a.contact_id = civicrm_contact.id )
|
||||
WHERE civicrm_contact.id = %1";
|
||||
|
||||
$params = array(1 => array($contactID, 'Integer'));
|
||||
}
|
||||
else {
|
||||
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
|
||||
$email = $strtolower($email);
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT group_a.group_id, group_a.status, civicrm_group.title
|
||||
FROM civicrm_group_contact group_a
|
||||
LEFT JOIN civicrm_group ON civicrm_group.id = group_a.group_id
|
||||
LEFT JOIN civicrm_contact ON ( group_a.contact_id = civicrm_contact.id ) AND civicrm_contact.is_deleted = 0
|
||||
LEFT JOIN civicrm_email ON civicrm_contact.id = civicrm_email.contact_id
|
||||
WHERE civicrm_email.email = %1";
|
||||
|
||||
$params = array(1 => array($email, 'String'));
|
||||
}
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
$groups = array();
|
||||
while ($dao->fetch()) {
|
||||
$groups[$dao->group_id] = array(
|
||||
'id' => $dao->group_id,
|
||||
'title' => $dao->title,
|
||||
'status' => $dao->status,
|
||||
);
|
||||
}
|
||||
|
||||
$dao->free();
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send subscribe mail.
|
||||
*
|
||||
* @param array $groups
|
||||
* The list of group ids for subscribe.
|
||||
* @param array $params
|
||||
* The list of email.
|
||||
* @param int $contactId
|
||||
* Currently used during event registration/contribution.
|
||||
* Specifically to avoid linking group to wrong duplicate contact
|
||||
* during event registration.
|
||||
* @param string $context
|
||||
*/
|
||||
public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $context = NULL) {
|
||||
$contactGroups = CRM_Mailing_Event_BAO_Subscribe::getContactGroups($params['email'], $contactId);
|
||||
$group = array();
|
||||
$success = NULL;
|
||||
foreach ($groups as $groupID) {
|
||||
$title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $groupID, 'title');
|
||||
if (array_key_exists($groupID, $contactGroups) && $contactGroups[$groupID]['status'] != 'Removed') {
|
||||
$group[$groupID]['title'] = $contactGroups[$groupID]['title'];
|
||||
|
||||
$group[$groupID]['status'] = $contactGroups[$groupID]['status'];
|
||||
$status = ts('You are already subscribed in %1, your subscription is %2.', array(
|
||||
1 => $group[$groupID]['title'],
|
||||
2 => ts($group[$groupID]['status']),
|
||||
));
|
||||
CRM_Utils_System::setUFMessage($status);
|
||||
continue;
|
||||
}
|
||||
|
||||
$se = self::subscribe($groupID,
|
||||
$params['email'], $contactId, $context
|
||||
);
|
||||
if ($se !== NULL) {
|
||||
$success = TRUE;
|
||||
$groupAdded[] = $title;
|
||||
|
||||
// Ask the contact for confirmation
|
||||
$se->send_confirm_request($params['email']);
|
||||
}
|
||||
else {
|
||||
$success = FALSE;
|
||||
$groupFailed[] = $title;
|
||||
}
|
||||
}
|
||||
if ($success) {
|
||||
$groupTitle = implode(', ', $groupAdded);
|
||||
CRM_Utils_System::setUFMessage(ts('Your subscription request has been submitted for %1. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder.', array(1 => $groupTitle)));
|
||||
}
|
||||
elseif ($success === FALSE) {
|
||||
$groupTitle = implode(',', $groupFailed);
|
||||
CRM_Utils_System::setUFMessage(ts('We had a problem processing your subscription request for %1. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator.', array(1 => $groupTitle)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,379 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_TrackableURLOpen {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Track a click-through and return the URL to redirect.
|
||||
*
|
||||
* If the numbers don't match up, return the base url.
|
||||
*
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID of the clicker.
|
||||
* @param int $url_id
|
||||
* The ID of the trackable URL.
|
||||
*
|
||||
* @return string
|
||||
* The redirection url, or base url on failure.
|
||||
*/
|
||||
public static function track($queue_id, $url_id) {
|
||||
// To find the url, we also join on the queue and job tables. This
|
||||
// prevents foreign key violations.
|
||||
$job = CRM_Utils_Type::escape(CRM_Mailing_BAO_MailingJob::getTableName(), 'MysqlColumnNameOrAlias');
|
||||
$eq = CRM_Utils_Type::escape(CRM_Mailing_Event_BAO_Queue::getTableName(), 'MysqlColumnNameOrAlias');
|
||||
$turl = CRM_Utils_Type::escape(CRM_Mailing_BAO_TrackableURL::getTableName(), 'MysqlColumnNameOrAlias');
|
||||
|
||||
if (!$queue_id) {
|
||||
$search = CRM_Core_DAO::executeQuery(
|
||||
"SELECT url
|
||||
FROM $turl
|
||||
WHERE $turl.id = %1",
|
||||
array(
|
||||
1 => array($url_id, 'Integer'),
|
||||
)
|
||||
);
|
||||
|
||||
if (!$search->fetch()) {
|
||||
return CRM_Utils_System::baseURL();
|
||||
}
|
||||
|
||||
return $search->url;
|
||||
}
|
||||
|
||||
$search = CRM_Core_DAO::executeQuery(
|
||||
"SELECT $turl.url as url
|
||||
FROM $turl
|
||||
INNER JOIN $job ON $turl.mailing_id = $job.mailing_id
|
||||
INNER JOIN $eq ON $job.id = $eq.job_id
|
||||
WHERE $eq.id = %1 AND $turl.id = %2",
|
||||
array(
|
||||
1 => array($queue_id, 'Integer'),
|
||||
2 => array($url_id, 'Integer'),
|
||||
)
|
||||
);
|
||||
|
||||
if (!$search->fetch()) {
|
||||
// Can't find either the URL or the queue. If we can find the URL then
|
||||
// return the URL without tracking. Otherwise return the base URL.
|
||||
$search = CRM_Core_DAO::executeQuery(
|
||||
"SELECT $turl.url as url
|
||||
FROM $turl
|
||||
WHERE $turl.id = %1",
|
||||
array(
|
||||
1 => array($url_id, 'Integer'),
|
||||
)
|
||||
);
|
||||
|
||||
if (!$search->fetch()) {
|
||||
return CRM_Utils_System::baseURL();
|
||||
}
|
||||
|
||||
return $search->url;
|
||||
}
|
||||
|
||||
$open = new CRM_Mailing_Event_BAO_TrackableURLOpen();
|
||||
$open->event_queue_id = $queue_id;
|
||||
$open->trackable_url_id = $url_id;
|
||||
$open->time_stamp = date('YmdHis');
|
||||
$open->save();
|
||||
|
||||
return $search->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
* @param int $url_id
|
||||
* Optional ID of a url to filter on.
|
||||
*
|
||||
* @param string $toDate
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $url_id = NULL, $toDate = NULL
|
||||
) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$click = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($click.id) as opened
|
||||
FROM $click
|
||||
INNER JOIN $queue
|
||||
ON $click.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($toDate)) {
|
||||
$query .= " AND $click.time_stamp <= $toDate";
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if (!empty($url_id)) {
|
||||
$query .= " AND $click.trackable_url_id = " . CRM_Utils_Type::escape($url_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
// query was missing
|
||||
$dao->query($query);
|
||||
|
||||
if ($dao->fetch()) {
|
||||
return $dao->opened;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tracked url count for each mailing for a given set of mailing IDs.
|
||||
*
|
||||
* CRM-12814
|
||||
*
|
||||
* @param array $mailingIDs
|
||||
*
|
||||
* @return array
|
||||
* trackable url count per mailing ID
|
||||
*/
|
||||
public static function getMailingTotalCount($mailingIDs) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
$clickCount = array();
|
||||
|
||||
$click = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailingIDs = implode(',', $mailingIDs);
|
||||
|
||||
$query = "
|
||||
SELECT $job.mailing_id as mailingID, COUNT($click.id) as opened
|
||||
FROM $click
|
||||
INNER JOIN $queue
|
||||
ON $click.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $job.mailing_id IN ({$mailingIDs})
|
||||
GROUP BY civicrm_mailing_job.mailing_id
|
||||
";
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$clickCount[$dao->mailingID] = $dao->opened;
|
||||
}
|
||||
return $clickCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tracked url count for each mailing for a given set of mailing IDs.
|
||||
*
|
||||
* @param int $mailingIDs
|
||||
* IDs of the mailing (comma separated).
|
||||
* @param int $contactID
|
||||
* ID of the contact.
|
||||
*
|
||||
* @return array
|
||||
* Count per mailing ID
|
||||
*/
|
||||
public static function getMailingContactCount($mailingIDs, $contactID) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
$clickCount = array();
|
||||
|
||||
$click = self::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailingIDs = implode(',', $mailingIDs);
|
||||
|
||||
$query = "
|
||||
SELECT $job.mailing_id as mailingID, COUNT($click.id) as opened
|
||||
FROM $click
|
||||
INNER JOIN $queue
|
||||
ON $click.event_queue_id = $queue.id
|
||||
AND $queue.contact_id = $contactID
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $job.mailing_id IN ({$mailingIDs})
|
||||
GROUP BY civicrm_mailing_job.mailing_id
|
||||
";
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$clickCount[$dao->mailingID] = $dao->opened;
|
||||
}
|
||||
|
||||
return $clickCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $url_id
|
||||
* Optional ID of a trackable URL to filter on.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
* @param int $contact_id
|
||||
* Optional contact ID.
|
||||
*
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $url_id,
|
||||
$offset = NULL, $rowCount = NULL, $sort = NULL, $contact_id = NULL
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$click = self::getTableName();
|
||||
$url = CRM_Mailing_BAO_TrackableURL::getTableName();
|
||||
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$click.time_stamp as date,
|
||||
$url.url as url
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $click
|
||||
ON $click.event_queue_id = $queue.id
|
||||
INNER JOIN $url
|
||||
ON $click.trackable_url_id = $url.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($contact_id)) {
|
||||
$query .= " AND $contact.id = " . CRM_Utils_Type::escape($contact_id, 'Integer');
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if (!empty($url_id)) {
|
||||
$query .= " AND $url.id = " . CRM_Utils_Type::escape($url_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, $click.time_stamp, $url.url ";
|
||||
}
|
||||
|
||||
$orderBy = "sort_name ASC, {$click}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
'url' => $dao->url,
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
647
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php
Normal file
647
sites/all/modules/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php
Normal file
|
@ -0,0 +1,647 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
require_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Event_BAO_Unsubscribe
|
||||
*/
|
||||
class CRM_Mailing_Event_BAO_Unsubscribe extends CRM_Mailing_Event_DAO_Unsubscribe {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe a contact from the domain.
|
||||
*
|
||||
* @param int $job_id
|
||||
* The job ID.
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID of the recipient.
|
||||
* @param string $hash
|
||||
* The hash.
|
||||
*
|
||||
* @return bool
|
||||
* Was the contact successfully unsubscribed?
|
||||
*/
|
||||
public static function unsub_from_domain($job_id, $queue_id, $hash) {
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$now = date('YmdHis');
|
||||
if (CRM_Core_BAO_Email::isMultipleBulkMail()) {
|
||||
$email = new CRM_Core_BAO_Email();
|
||||
$email->id = $q->email_id;
|
||||
if ($email->find(TRUE)) {
|
||||
$sql = "
|
||||
UPDATE civicrm_email
|
||||
SET on_hold = 2,
|
||||
hold_date = %1
|
||||
WHERE email = %2
|
||||
";
|
||||
$sqlParams = array(
|
||||
1 => array($now, 'Timestamp'),
|
||||
2 => array($email->email, 'String'),
|
||||
);
|
||||
CRM_Core_DAO::executeQuery($sql, $sqlParams);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$contact = new CRM_Contact_BAO_Contact();
|
||||
$contact->id = $q->contact_id;
|
||||
$contact->is_opt_out = TRUE;
|
||||
$contact->save();
|
||||
}
|
||||
|
||||
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$ue->event_queue_id = $queue_id;
|
||||
$ue->org_unsubscribe = 1;
|
||||
$ue->time_stamp = $now;
|
||||
$ue->save();
|
||||
|
||||
$shParams = array(
|
||||
'contact_id' => $q->contact_id,
|
||||
'group_id' => NULL,
|
||||
'status' => 'Removed',
|
||||
'method' => 'Email',
|
||||
'tracking' => $ue->id,
|
||||
);
|
||||
CRM_Contact_BAO_SubscriptionHistory::create($shParams);
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe a contact from all groups that received this mailing.
|
||||
*
|
||||
* @param int $job_id
|
||||
* The job ID.
|
||||
* @param int $queue_id
|
||||
* The Queue Event ID of the recipient.
|
||||
* @param string $hash
|
||||
* The hash.
|
||||
* @param bool $return
|
||||
* If true return the list of groups.
|
||||
*
|
||||
* @return array|null
|
||||
* $groups Array of all groups from which the contact was removed, or null if the queue event could not be found.
|
||||
*/
|
||||
public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = FALSE) {
|
||||
// First make sure there's a matching queue event.
|
||||
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
$success = NULL;
|
||||
if (!$q) {
|
||||
return $success;
|
||||
}
|
||||
|
||||
$contact_id = $q->contact_id;
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$do = new CRM_Core_DAO();
|
||||
$mgObject = new CRM_Mailing_DAO_MailingGroup();
|
||||
$mg = $mgObject->getTableName();
|
||||
$jobObject = new CRM_Mailing_BAO_MailingJob();
|
||||
$job = $jobObject->getTableName();
|
||||
$mailingObject = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing = $mailingObject->getTableName();
|
||||
$groupObject = new CRM_Contact_BAO_Group();
|
||||
$group = $groupObject->getTableName();
|
||||
$gcObject = new CRM_Contact_BAO_GroupContact();
|
||||
$gc = $gcObject->getTableName();
|
||||
$abObject = new CRM_Mailing_DAO_MailingAB();
|
||||
$ab = $abObject->getTableName();
|
||||
|
||||
//We Need the mailing Id for the hook...
|
||||
$do->query("SELECT $job.mailing_id as mailing_id
|
||||
FROM $job
|
||||
WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
|
||||
$do->fetch();
|
||||
$mailing_id = $do->mailing_id;
|
||||
$mailing_type = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailing_id, 'mailing_type', 'id');
|
||||
$entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $mailing_id, 'entity_table', 'mailing_id');
|
||||
|
||||
// If $entity is null and $mailing_Type is either winner or experiment then we are deailing with an AB test
|
||||
$abtest_types = array('experiment', 'winner');
|
||||
if (empty($entity) && in_array($mailing_type, $abtest_types)) {
|
||||
$mailing_id_a = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingAB', $mailing_id, 'mailing_id_a', 'mailing_id_b');
|
||||
$field = 'mailing_id_b';
|
||||
if (empty($mailing_id_a)) {
|
||||
$mailing_id_a = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingAB', $mailing_id, 'mailing_id_a', 'mailing_id_c');
|
||||
$field = 'mailing_id_c';
|
||||
}
|
||||
$jobJoin = "INNER JOIN $ab ON $ab.mailing_id_a = $mg.mailing_id
|
||||
INNER JOIN $job ON $job.mailing_id = $ab.$field";
|
||||
$entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $mailing_id_a, 'entity_table', 'mailing_id');
|
||||
}
|
||||
else {
|
||||
$jobJoin = "INNER JOIN $job ON $job.mailing_id = $mg.mailing_id";
|
||||
}
|
||||
|
||||
$groupClause = '';
|
||||
if ($entity == $group) {
|
||||
$groupClause = "AND $group.is_hidden = 0";
|
||||
}
|
||||
|
||||
$do->query("
|
||||
SELECT $mg.entity_table as entity_table,
|
||||
$mg.entity_id as entity_id,
|
||||
$mg.group_type as group_type
|
||||
FROM $mg
|
||||
$jobJoin
|
||||
INNER JOIN $entity
|
||||
ON $mg.entity_id = $entity.id
|
||||
WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer') . "
|
||||
AND $mg.group_type IN ('Include', 'Base') $groupClause"
|
||||
);
|
||||
|
||||
// Make a list of groups and a list of prior mailings that received
|
||||
// this mailing.
|
||||
|
||||
$groups = array();
|
||||
$base_groups = array();
|
||||
$mailings = array();
|
||||
|
||||
while ($do->fetch()) {
|
||||
if ($do->entity_table == $group) {
|
||||
if ($do->group_type == 'Base') {
|
||||
$base_groups[$do->entity_id] = NULL;
|
||||
}
|
||||
else {
|
||||
$groups[$do->entity_id] = NULL;
|
||||
}
|
||||
}
|
||||
elseif ($do->entity_table == $mailing) {
|
||||
$mailings[] = $do->entity_id;
|
||||
}
|
||||
}
|
||||
|
||||
// As long as we have prior mailings, find their groups and add to the
|
||||
// list.
|
||||
|
||||
while (!empty($mailings)) {
|
||||
$do->query("
|
||||
SELECT $mg.entity_table as entity_table,
|
||||
$mg.entity_id as entity_id
|
||||
FROM $mg
|
||||
WHERE $mg.mailing_id IN (" . implode(', ', $mailings) . ")
|
||||
AND $mg.group_type = 'Include'");
|
||||
|
||||
$mailings = array();
|
||||
|
||||
while ($do->fetch()) {
|
||||
if ($do->entity_table == $group) {
|
||||
$groups[$do->entity_id] = TRUE;
|
||||
}
|
||||
elseif ($do->entity_table == $mailing) {
|
||||
$mailings[] = $do->entity_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Pass the groups to be unsubscribed from through a hook.
|
||||
$groupIds = array_keys($groups);
|
||||
//include child groups if any
|
||||
$groupIds = array_merge($groupIds, CRM_Contact_BAO_Group::getChildGroupIds($groupIds));
|
||||
|
||||
$baseGroupIds = array_keys($base_groups);
|
||||
CRM_Utils_Hook::unsubscribeGroups('unsubscribe', $mailing_id, $contact_id, $groupIds, $baseGroupIds);
|
||||
|
||||
// Now we have a complete list of recipient groups. Filter out all
|
||||
// those except smart groups, those that the contact belongs to and
|
||||
// base groups from search based mailings.
|
||||
$baseGroupClause = '';
|
||||
if (!empty($baseGroupIds)) {
|
||||
$baseGroupClause = "OR $group.id IN(" . implode(', ', $baseGroupIds) . ")";
|
||||
}
|
||||
$groupIdClause = '';
|
||||
if ($groupIds || $baseGroupIds) {
|
||||
$groupIdClause = "AND $group.id IN (" . implode(', ', array_merge($groupIds, $baseGroupIds)) . ")";
|
||||
}
|
||||
$do->query("
|
||||
SELECT $group.id as group_id,
|
||||
$group.title as title,
|
||||
$group.description as description
|
||||
FROM $group
|
||||
LEFT JOIN $gc
|
||||
ON $gc.group_id = $group.id
|
||||
WHERE $group.is_hidden = 0
|
||||
$groupIdClause
|
||||
AND ($group.saved_search_id is not null
|
||||
OR ($gc.contact_id = $contact_id
|
||||
AND $gc.status = 'Added')
|
||||
$baseGroupClause
|
||||
)");
|
||||
|
||||
if ($return) {
|
||||
$returnGroups = array();
|
||||
while ($do->fetch()) {
|
||||
$returnGroups[$do->group_id] = array(
|
||||
'title' => $do->title,
|
||||
'description' => $do->description,
|
||||
);
|
||||
}
|
||||
return $returnGroups;
|
||||
}
|
||||
else {
|
||||
while ($do->fetch()) {
|
||||
$groups[$do->group_id] = $do->title;
|
||||
}
|
||||
}
|
||||
|
||||
$contacts = array($contact_id);
|
||||
foreach ($groups as $group_id => $group_name) {
|
||||
$notremoved = FALSE;
|
||||
if ($group_name) {
|
||||
if (in_array($group_id, $baseGroupIds)) {
|
||||
list($total, $removed, $notremoved) = CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Removed');
|
||||
}
|
||||
else {
|
||||
list($total, $removed, $notremoved) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contacts, $group_id, 'Email');
|
||||
}
|
||||
}
|
||||
if ($notremoved) {
|
||||
unset($groups[$group_id]);
|
||||
}
|
||||
}
|
||||
|
||||
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$ue->event_queue_id = $queue_id;
|
||||
$ue->org_unsubscribe = 0;
|
||||
$ue->time_stamp = date('YmdHis');
|
||||
$ue->save();
|
||||
|
||||
$transaction->commit();
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a response email informing the contact of the groups from which he.
|
||||
* has been unsubscribed.
|
||||
*
|
||||
* @param string $queue_id
|
||||
* The queue event ID.
|
||||
* @param array $groups
|
||||
* List of group IDs.
|
||||
* @param bool $is_domain
|
||||
* Is this domain-level?.
|
||||
* @param int $job
|
||||
* The job ID.
|
||||
*/
|
||||
public static function send_unsub_response($queue_id, $groups, $is_domain = FALSE, $job) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$domain = CRM_Core_BAO_Domain::getDomain();
|
||||
|
||||
$jobObject = new CRM_Mailing_BAO_MailingJob();
|
||||
$jobTable = $jobObject->getTableName();
|
||||
$mailingObject = new CRM_Mailing_DAO_Mailing();
|
||||
$mailingTable = $mailingObject->getTableName();
|
||||
$contactsObject = new CRM_Contact_DAO_Contact();
|
||||
$contacts = $contactsObject->getTableName();
|
||||
$emailObject = new CRM_Core_DAO_Email();
|
||||
$email = $emailObject->getTableName();
|
||||
$queueObject = new CRM_Mailing_Event_BAO_Queue();
|
||||
$queue = $queueObject->getTableName();
|
||||
|
||||
//get the default domain email address.
|
||||
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
$dao = new CRM_Mailing_BAO_Mailing();
|
||||
$dao->query(" SELECT * FROM $mailingTable
|
||||
INNER JOIN $jobTable ON
|
||||
$jobTable.mailing_id = $mailingTable.id
|
||||
WHERE $jobTable.id = $job");
|
||||
$dao->fetch();
|
||||
|
||||
$component = new CRM_Mailing_BAO_Component();
|
||||
|
||||
if ($is_domain) {
|
||||
$component->id = $dao->optout_id;
|
||||
}
|
||||
else {
|
||||
$component->id = $dao->unsubscribe_id;
|
||||
}
|
||||
$component->find(TRUE);
|
||||
|
||||
$html = $component->body_html;
|
||||
if ($component->body_text) {
|
||||
$text = $component->body_text;
|
||||
}
|
||||
else {
|
||||
$text = CRM_Utils_String::htmlToText($component->body_html);
|
||||
}
|
||||
|
||||
$eq = new CRM_Core_DAO();
|
||||
$eq->query(
|
||||
"SELECT $contacts.preferred_mail_format as format,
|
||||
$contacts.id as contact_id,
|
||||
$email.email as email,
|
||||
$queue.hash as hash
|
||||
FROM $contacts
|
||||
INNER JOIN $queue ON $queue.contact_id = $contacts.id
|
||||
INNER JOIN $email ON $queue.email_id = $email.id
|
||||
WHERE $queue.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')
|
||||
);
|
||||
$eq->fetch();
|
||||
|
||||
if ($groups) {
|
||||
foreach ($groups as $key => $value) {
|
||||
if (!$value) {
|
||||
unset($groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$message = new Mail_mime("\n");
|
||||
|
||||
list($addresses, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls($job, $queue_id, $eq->hash, $eq->email);
|
||||
$bao = new CRM_Mailing_BAO_Mailing();
|
||||
$bao->body_text = $text;
|
||||
$bao->body_html = $html;
|
||||
$tokens = $bao->getTokens();
|
||||
if ($eq->format == 'HTML' || $eq->format == 'Both') {
|
||||
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceUnsubscribeTokens($html, $domain, $groups, TRUE, $eq->contact_id, $eq->hash);
|
||||
$html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']);
|
||||
$html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']);
|
||||
$message->setHTMLBody($html);
|
||||
}
|
||||
if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
|
||||
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceUnsubscribeTokens($text, $domain, $groups, FALSE, $eq->contact_id, $eq->hash);
|
||||
$text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']);
|
||||
$text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']);
|
||||
$message->setTxtBody($text);
|
||||
}
|
||||
|
||||
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
|
||||
|
||||
$headers = array(
|
||||
'Subject' => $component->subject,
|
||||
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
|
||||
'To' => $eq->email,
|
||||
'Reply-To' => "do-not-reply@$emailDomain",
|
||||
'Return-Path' => "do-not-reply@$emailDomain",
|
||||
);
|
||||
CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'u', $job, $queue_id, $eq->hash);
|
||||
|
||||
$b = CRM_Utils_Mail::setMimeParams($message);
|
||||
$h = $message->headers($headers);
|
||||
|
||||
$mailer = \Civi::service('pear_mail');
|
||||
|
||||
if (is_object($mailer)) {
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$mailer->send($eq->email, $h, $b);
|
||||
unset($errorScope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row count for the event selector.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of a job to filter on.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue ID?.
|
||||
*
|
||||
* @param string $org_unsubscribe
|
||||
*
|
||||
* @param string $toDate
|
||||
*
|
||||
* @return int
|
||||
* Number of rows in result set
|
||||
*/
|
||||
public static function getTotalCount(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $org_unsubscribe = NULL, $toDate = NULL
|
||||
) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
|
||||
$unsub = self::$_tableName;
|
||||
$queueObject = new CRM_Mailing_Event_BAO_Queue();
|
||||
$queue = $queueObject->getTableName();
|
||||
$mailingObject = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing = $mailingObject->getTableName();
|
||||
$jobObject = new CRM_Mailing_BAO_MailingJob();
|
||||
$job = $jobObject->getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT COUNT($unsub.id) as unsubs
|
||||
FROM $unsub
|
||||
INNER JOIN $queue
|
||||
ON $unsub.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($toDate)) {
|
||||
$query .= " AND $unsub.time_stamp <= $toDate";
|
||||
}
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($org_unsubscribe !== NULL) {
|
||||
$query .= " AND $unsub.org_unsubscribe = " . ($org_unsubscribe ? 0 : 1);
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id ";
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
$dao->fetch();
|
||||
if ($is_distinct) {
|
||||
return $dao->N;
|
||||
}
|
||||
else {
|
||||
return $dao->unsubs ? $dao->unsubs : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows for the event browser.
|
||||
*
|
||||
* @param int $mailing_id
|
||||
* ID of the mailing.
|
||||
* @param int $job_id
|
||||
* Optional ID of the job.
|
||||
* @param bool $is_distinct
|
||||
* Group by queue id?.
|
||||
* @param int $offset
|
||||
* Offset.
|
||||
* @param int $rowCount
|
||||
* Number of rows.
|
||||
* @param array $sort
|
||||
* Sort array.
|
||||
*
|
||||
* @param null $org_unsubscribe
|
||||
* @return array
|
||||
* Result set
|
||||
*/
|
||||
public static function &getRows(
|
||||
$mailing_id, $job_id = NULL,
|
||||
$is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL,
|
||||
$org_unsubscribe = NULL
|
||||
) {
|
||||
|
||||
$dao = new CRM_Core_Dao();
|
||||
|
||||
$unsub = self::$_tableName;
|
||||
$queueObject = new CRM_Mailing_Event_BAO_Queue();
|
||||
$queue = $queueObject->getTableName();
|
||||
$mailingObject = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing = $mailingObject->getTableName();
|
||||
$jobObject = new CRM_Mailing_BAO_MailingJob();
|
||||
$job = $jobObject->getTableName();
|
||||
$contactObject = new CRM_Contact_BAO_Contact();
|
||||
$contact = $contactObject->getTableName();
|
||||
$emailObject = new CRM_Core_BAO_Email();
|
||||
$email = $emailObject->getTableName();
|
||||
|
||||
$query = "
|
||||
SELECT $contact.display_name as display_name,
|
||||
$contact.id as contact_id,
|
||||
$email.email as email,
|
||||
$unsub.time_stamp as date,
|
||||
$unsub.org_unsubscribe as org_unsubscribe
|
||||
FROM $contact
|
||||
INNER JOIN $queue
|
||||
ON $queue.contact_id = $contact.id
|
||||
INNER JOIN $email
|
||||
ON $queue.email_id = $email.id
|
||||
INNER JOIN $unsub
|
||||
ON $unsub.event_queue_id = $queue.id
|
||||
INNER JOIN $job
|
||||
ON $queue.job_id = $job.id
|
||||
INNER JOIN $mailing
|
||||
ON $job.mailing_id = $mailing.id
|
||||
AND $job.is_test = 0
|
||||
WHERE $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
|
||||
|
||||
if (!empty($job_id)) {
|
||||
$query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
|
||||
}
|
||||
|
||||
if ($org_unsubscribe !== NULL) {
|
||||
$query .= " AND $unsub.org_unsubscribe = " . ($org_unsubscribe ? 0 : 1);
|
||||
}
|
||||
|
||||
if ($is_distinct) {
|
||||
$query .= " GROUP BY $queue.id, $unsub.time_stamp, $unsub.org_unsubscribe";
|
||||
}
|
||||
|
||||
$orderBy = "sort_name ASC, {$unsub}.time_stamp DESC";
|
||||
if ($sort) {
|
||||
if (is_string($sort)) {
|
||||
$sort = CRM_Utils_Type::escape($sort, 'String');
|
||||
$orderBy = $sort;
|
||||
}
|
||||
else {
|
||||
$orderBy = trim($sort->orderBy());
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " ORDER BY {$orderBy} ";
|
||||
|
||||
if ($offset || $rowCount) {
|
||||
//Added "||$rowCount" to avoid displaying all records on first page
|
||||
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
|
||||
}
|
||||
|
||||
$dao->query($query);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&cid={$dao->contact_id}"
|
||||
);
|
||||
$results[] = array(
|
||||
'name' => "<a href=\"$url\">{$dao->display_name}</a>",
|
||||
'email' => $dao->email,
|
||||
// Next value displays in selector under either Unsubscribe OR Optout column header, so always s/b Yes.
|
||||
'unsubOrOptout' => ts('Yes'),
|
||||
'date' => CRM_Utils_Date::customFormat($dao->date),
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $queueID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getContactInfo($queueID) {
|
||||
$query = "
|
||||
SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id,
|
||||
civicrm_contact.display_name as display_name
|
||||
civicrm_email.email as email
|
||||
FROM civicrm_mailing_event_queue,
|
||||
civicrm_contact,
|
||||
civicrm_email
|
||||
WHERE civicrm_mailing_event_queue.contact_id = civicrm_contact.id
|
||||
AND civicrm_mailing_event_queue.email_id = civicrm_email.id
|
||||
AND civicrm_mailing_event_queue.id = " . CRM_Utils_Type::escape($queueID, 'Integer');
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$displayName = 'Unknown';
|
||||
$email = 'Unknown';
|
||||
if ($dao->fetch()) {
|
||||
$displayName = $dao->display_name;
|
||||
$email = $dao->email;
|
||||
}
|
||||
|
||||
return array($displayName, $email);
|
||||
}
|
||||
|
||||
}
|
237
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Bounce.php
Normal file
237
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Bounce.php
Normal file
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Bounce.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:c63363ca2be2a2fb9eb090786bdf0fa3)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Bounce constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_bounce';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* What type of bounce was it?
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $bounce_type_id;
|
||||
/**
|
||||
* The reason the email bounced.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $bounce_reason;
|
||||
/**
|
||||
* When this bounce event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_bounce';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Bounce ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_bounce',
|
||||
'entity' => 'Bounce',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Bounce',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_bounce',
|
||||
'entity' => 'Bounce',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Bounce',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'bounce_type_id' => array(
|
||||
'name' => 'bounce_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Bounce Type') ,
|
||||
'description' => 'What type of bounce was it?',
|
||||
'table_name' => 'civicrm_mailing_event_bounce',
|
||||
'entity' => 'Bounce',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Bounce',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_mailing_bounce_type',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'name',
|
||||
)
|
||||
) ,
|
||||
'bounce_reason' => array(
|
||||
'name' => 'bounce_reason',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Bounce Reason') ,
|
||||
'description' => 'The reason the email bounced.',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_event_bounce',
|
||||
'entity' => 'Bounce',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Bounce',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Timestamp') ,
|
||||
'description' => 'When this bounce event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_bounce',
|
||||
'entity' => 'Bounce',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Bounce',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_bounce', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_bounce', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Confirm.php
Normal file
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Confirm.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Confirm.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f4259bbb8f00037fd48b242a332dcbc0)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Confirm constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_confirm';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to civicrm_mailing_event_subscribe
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_subscribe_id;
|
||||
/**
|
||||
* When this confirmation event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_confirm';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_subscribe_id', 'civicrm_mailing_event_subscribe', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Confirmation ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_confirm',
|
||||
'entity' => 'Confirm',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Confirm',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_subscribe_id' => array(
|
||||
'name' => 'event_subscribe_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Subscribe ID') ,
|
||||
'description' => 'FK to civicrm_mailing_event_subscribe',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_confirm',
|
||||
'entity' => 'Confirm',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Confirm',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Subscribe',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Confirm Timestamp') ,
|
||||
'description' => 'When this confirmation event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_confirm',
|
||||
'entity' => 'Confirm',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Confirm',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_confirm', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_confirm', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Delivered.php
Normal file
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Delivered.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Delivered.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f5c02a90e7ec94814797559e9080c96a)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Delivered constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_delivered';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* When this delivery event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_delivered';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Delivered ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_delivered',
|
||||
'entity' => 'Delivered',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Delivered',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_delivered',
|
||||
'entity' => 'Delivered',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Delivered',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Timestamp') ,
|
||||
'description' => 'When this delivery event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_delivered',
|
||||
'entity' => 'Delivered',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Delivered',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_delivered', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_delivered', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
213
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Forward.php
Normal file
213
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Forward.php
Normal file
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Forward.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:c187b9e7dd1d6f2a9a9fd19180acd98f)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Forward constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_forward';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* FK to EventQueue for destination
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $dest_queue_id;
|
||||
/**
|
||||
* When this forward event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_forward';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'dest_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Forward ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_forward',
|
||||
'entity' => 'Forward',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Forward',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_forward',
|
||||
'entity' => 'Forward',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Forward',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'dest_queue_id' => array(
|
||||
'name' => 'dest_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Destination Queue') ,
|
||||
'description' => 'FK to EventQueue for destination',
|
||||
'table_name' => 'civicrm_mailing_event_forward',
|
||||
'entity' => 'Forward',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Forward',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Timestamp') ,
|
||||
'description' => 'When this forward event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_forward',
|
||||
'entity' => 'Forward',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Forward',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_forward', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_forward', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Opened.php
Normal file
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Opened.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Opened.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:8f5b5d87a40bd9589541faf9cd3bd4e4)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Opened constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_opened';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* When this open event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_opened';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Opened ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_opened',
|
||||
'entity' => 'Opened',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Opened',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_opened',
|
||||
'entity' => 'Opened',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Opened',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Timestamp') ,
|
||||
'description' => 'When this open event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_opened',
|
||||
'entity' => 'Opened',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Opened',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_opened', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_opened', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
262
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Queue.php
Normal file
262
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Queue.php
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Queue.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:61df95ab05407c3c8fcd677a03e32b99)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Queue constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_queue';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to Job
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $job_id;
|
||||
/**
|
||||
* FK to Email
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $email_id;
|
||||
/**
|
||||
* FK to Contact
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Security hash
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $hash;
|
||||
/**
|
||||
* FK to Phone
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $phone_id;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_queue';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'job_id', 'civicrm_mailing_job', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'email_id', 'civicrm_email', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'phone_id', 'civicrm_phone', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Event Queue ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'job_id' => array(
|
||||
'name' => 'job_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Job ID') ,
|
||||
'description' => 'FK to Job',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_MailingJob',
|
||||
) ,
|
||||
'email_id' => array(
|
||||
'name' => 'email_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Email ID') ,
|
||||
'description' => 'FK to Email',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Core_DAO_Email',
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Contact ID') ,
|
||||
'description' => 'FK to Contact',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'hash' => array(
|
||||
'name' => 'hash',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Security Hash') ,
|
||||
'description' => 'Security hash',
|
||||
'required' => true,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'phone_id' => array(
|
||||
'name' => 'phone_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Phone ID') ,
|
||||
'description' => 'FK to Phone',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_event_queue',
|
||||
'entity' => 'Queue',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Queue',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Core_DAO_Phone',
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_queue', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_queue', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_hash' => array(
|
||||
'name' => 'index_hash',
|
||||
'field' => array(
|
||||
0 => 'hash',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_mailing_event_queue::0::hash',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Reply.php
Normal file
195
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Reply.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Reply.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:c820f3b64d2152014b47a738c32f1f84)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Reply constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_reply';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* When this reply event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_reply';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Reply ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_reply',
|
||||
'entity' => 'Reply',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Reply',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_reply',
|
||||
'entity' => 'Reply',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Reply',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Reply Timestamp') ,
|
||||
'description' => 'When this reply event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_reply',
|
||||
'entity' => 'Reply',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Reply',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_reply', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_reply', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
241
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Subscribe.php
Normal file
241
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Subscribe.php
Normal file
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Subscribe.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:7d7961401e033cc63575a58821bfa5c7)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Subscribe constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_subscribe';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to Group
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $group_id;
|
||||
/**
|
||||
* FK to Contact
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Security hash
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $hash;
|
||||
/**
|
||||
* When this subscription event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_subscribe';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'group_id', 'civicrm_group', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Subscribe ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_subscribe',
|
||||
'entity' => 'Subscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'group_id' => array(
|
||||
'name' => 'group_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Subscribe Group') ,
|
||||
'description' => 'FK to Group',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_subscribe',
|
||||
'entity' => 'Subscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Group',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_group',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'title',
|
||||
)
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Subscribe Contact') ,
|
||||
'description' => 'FK to Contact',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_subscribe',
|
||||
'entity' => 'Subscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'hash' => array(
|
||||
'name' => 'hash',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Subscribe Hash') ,
|
||||
'description' => 'Security hash',
|
||||
'required' => true,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_event_subscribe',
|
||||
'entity' => 'Subscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Mailing Subscribe Timestamp') ,
|
||||
'description' => 'When this subscription event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_subscribe',
|
||||
'entity' => 'Subscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_subscribe', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_subscribe', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/TrackableURLOpen.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:fc2a3b22d6de10cd6b46ee649df9e471)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_TrackableURLOpen constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_trackable_url_open';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* FK to TrackableURL
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $trackable_url_id;
|
||||
/**
|
||||
* When this trackable URL open occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_trackable_url_open';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'trackable_url_id', 'civicrm_mailing_trackable_url', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Trackable URL Open ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_trackable_url_open',
|
||||
'entity' => 'TrackableURLOpen',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_trackable_url_open',
|
||||
'entity' => 'TrackableURLOpen',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'trackable_url_id' => array(
|
||||
'name' => 'trackable_url_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Trackable Url') ,
|
||||
'description' => 'FK to TrackableURL',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_trackable_url_open',
|
||||
'entity' => 'TrackableURLOpen',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_TrackableURL',
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Timestamp') ,
|
||||
'description' => 'When this trackable URL open occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_trackable_url_open',
|
||||
'entity' => 'TrackableURLOpen',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_trackable_url_open', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_trackable_url_open', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
212
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php
Normal file
212
sites/all/modules/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php
Normal file
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Mailing/Event/Unsubscribe.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:a44ecc4ce8b1a8ecdca57fff8d053392)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_Event_DAO_Unsubscribe constructor.
|
||||
*/
|
||||
class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_event_unsubscribe';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to EventQueue
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $event_queue_id;
|
||||
/**
|
||||
* Unsubscribe at org- or group-level
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $org_unsubscribe;
|
||||
/**
|
||||
* When this delivery event occurred.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $time_stamp;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_event_unsubscribe';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Unsubscribe ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_unsubscribe',
|
||||
'entity' => 'Unsubscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'event_queue_id' => array(
|
||||
'name' => 'event_queue_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Event Queue') ,
|
||||
'description' => 'FK to EventQueue',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_unsubscribe',
|
||||
'entity' => 'Unsubscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_Event_DAO_Queue',
|
||||
) ,
|
||||
'org_unsubscribe' => array(
|
||||
'name' => 'org_unsubscribe',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Unsubscribe is for Organization?') ,
|
||||
'description' => 'Unsubscribe at org- or group-level',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_event_unsubscribe',
|
||||
'entity' => 'Unsubscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'time_stamp' => array(
|
||||
'name' => 'time_stamp',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Unsubscribe Timestamp') ,
|
||||
'description' => 'When this delivery event occurred.',
|
||||
'required' => true,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_event_unsubscribe',
|
||||
'entity' => 'Unsubscribe',
|
||||
'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_unsubscribe', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_unsubscribe', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array();
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue