First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
112
sites/all/modules/civicrm/CRM/Mailing/ActionTokens.php
Normal file
112
sites/all/modules/civicrm/CRM/Mailing/ActionTokens.php
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_ActionTokens
|
||||
*
|
||||
* Generate "action.*" tokens for mailings.
|
||||
*
|
||||
* To activate these tokens, the TokenProcessor context must specify:
|
||||
* "mailingJobId" (int)
|
||||
* "mailingActionTarget" (array) with keys:
|
||||
* 'id' => int, event queue ID
|
||||
* 'hash' => string, event queue hash code
|
||||
* 'contact_id' => int, contact_id,
|
||||
* 'email' => string, email
|
||||
* 'phone' => string, phone
|
||||
*/
|
||||
class CRM_Mailing_ActionTokens extends \Civi\Token\AbstractTokenSubscriber {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
// TODO: Think about supporting dynamic tokens like "{action.subscribe.\d+}"
|
||||
parent::__construct('action', array(
|
||||
'subscribeUrl' => ts('Subscribe URL (Action)'),
|
||||
'forward' => ts('Forward URL (Action)'),
|
||||
'optOut' => ts('Opt-Out (Action)'),
|
||||
'optOutUrl' => ts('Opt-Out URL (Action)'),
|
||||
'reply' => ts('Reply (Action)'),
|
||||
'unsubscribe' => ts('Unsubscribe (Action)'),
|
||||
'unsubscribeUrl' => ts('Unsubscribe URL (Action)'),
|
||||
'resubscribe' => ts('Resubscribe (Action)'),
|
||||
'resubscribeUrl' => ts('Resubscribe URL (Action)'),
|
||||
'eventQueueId' => ts('Event Queue ID'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function checkActive(\Civi\Token\TokenProcessor $processor) {
|
||||
return !empty($processor->context['mailingId']) || !empty($processor->context['mailing']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function evaluateToken(
|
||||
\Civi\Token\TokenRow $row,
|
||||
$entity,
|
||||
$field,
|
||||
$prefetch = NULL
|
||||
) {
|
||||
// Most CiviMail action tokens were implemented via getActionTokenReplacement().
|
||||
// However, {action.subscribeUrl} has a second implementation via
|
||||
// replaceSubscribeInviteTokens(). The two appear mostly the same.
|
||||
// We use getActionTokenReplacement() since it's more consistent. However,
|
||||
// this doesn't provide the dynamic/parameterized tokens of
|
||||
// replaceSubscribeInviteTokens().
|
||||
|
||||
if (empty($row->context['mailingJobId']) || empty($row->context['mailingActionTarget']['hash'])) {
|
||||
throw new \CRM_Core_Exception("Error: Cannot use action tokens unless context defines mailingJobId and mailingActionTarget.");
|
||||
}
|
||||
|
||||
if ($field === 'eventQueueId') {
|
||||
$row->format('text/plain')->tokens($entity, $field, $row->context['mailingActionTarget']['id']);
|
||||
return;
|
||||
}
|
||||
|
||||
list($verp, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls(
|
||||
$row->context['mailingJobId'],
|
||||
$row->context['mailingActionTarget']['id'],
|
||||
$row->context['mailingActionTarget']['hash'],
|
||||
// Note: Behavior is already undefined for SMS/'phone' mailings...
|
||||
$row->context['mailingActionTarget']['email']
|
||||
);
|
||||
|
||||
$row->format('text/plain')->tokens($entity, $field,
|
||||
CRM_Utils_Token::getActionTokenReplacement(
|
||||
$field, $verp, $urls, FALSE));
|
||||
$row->format('text/html')->tokens($entity, $field,
|
||||
CRM_Utils_Token::getActionTokenReplacement(
|
||||
$field, $verp, $urls, TRUE));
|
||||
}
|
||||
|
||||
}
|
104
sites/all/modules/civicrm/CRM/Mailing/BAO/BouncePattern.php
Normal file
104
sites/all/modules/civicrm/CRM/Mailing/BAO/BouncePattern.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?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_BAO_BouncePattern extends CRM_Mailing_DAO_BouncePattern {
|
||||
|
||||
/**
|
||||
* Pseudo-constant pattern array.
|
||||
*/
|
||||
static $_patterns = NULL;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the static pattern array.
|
||||
*/
|
||||
public static function buildPatterns() {
|
||||
self::$_patterns = array();
|
||||
$bp = new CRM_Mailing_BAO_BouncePattern();
|
||||
$bp->find();
|
||||
|
||||
while ($bp->fetch()) {
|
||||
self::$_patterns[$bp->bounce_type_id][] = $bp->pattern;
|
||||
}
|
||||
|
||||
foreach (self::$_patterns as $type => $patterns) {
|
||||
if (count($patterns) == 1) {
|
||||
self::$_patterns[$type] = '{(' . $patterns[0] . ')}im';
|
||||
}
|
||||
else {
|
||||
self::$_patterns[$type] = '{(' . implode(')|(', $patterns) . ')}im';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to match the string to a bounce type.
|
||||
*
|
||||
* @param string $message
|
||||
* The message to be matched.
|
||||
*
|
||||
* @return array
|
||||
* Tuple (bounce_type, bounce_reason)
|
||||
*/
|
||||
public static function &match(&$message) {
|
||||
// clean up $message and replace all white space by a single space, CRM-4767
|
||||
$message = preg_replace('/\s+/', ' ', $message);
|
||||
|
||||
if (self::$_patterns == NULL) {
|
||||
self::buildPatterns();
|
||||
}
|
||||
|
||||
foreach (self::$_patterns as $type => $re) {
|
||||
if (preg_match($re, $message, $matches)) {
|
||||
$bounce = array(
|
||||
'bounce_type_id' => $type,
|
||||
'bounce_reason' => $message,
|
||||
);
|
||||
return $bounce;
|
||||
}
|
||||
}
|
||||
|
||||
$bounce = array(
|
||||
'bounce_type_id' => NULL,
|
||||
'bounce_reason' => $message,
|
||||
);
|
||||
|
||||
return $bounce;
|
||||
}
|
||||
|
||||
}
|
121
sites/all/modules/civicrm/CRM/Mailing/BAO/Component.php
Normal file
121
sites/all/modules/civicrm/CRM/Mailing/BAO/Component.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?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_BAO_Component extends CRM_Mailing_DAO_Component {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object based on array of properties.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
* @param array $defaults
|
||||
* (reference ) an assoc array to hold the flattened values.
|
||||
*
|
||||
* @return CRM_Core_BAO_LocationType.
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
$component = new CRM_Mailing_DAO_Component();
|
||||
$component->copyValues($params);
|
||||
if ($component->find(TRUE)) {
|
||||
CRM_Core_DAO::storeValues($component, $defaults);
|
||||
return $component;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the is_active flag in the db.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the database record.
|
||||
* @param bool $is_active
|
||||
* Value we want to set the is_active field.
|
||||
*
|
||||
* @return Object
|
||||
* DAO object on success, null otherwise
|
||||
*/
|
||||
public static function setIsActive($id, $is_active) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Component', $id, 'is_active', $is_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and Update mailing component.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
* @param array $ids
|
||||
* (deprecated) the array that holds all the db ids.
|
||||
*
|
||||
* @return CRM_Mailing_BAO_Component
|
||||
*/
|
||||
public static function add(&$params, $ids = array()) {
|
||||
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids));
|
||||
$component = new CRM_Mailing_DAO_Component();
|
||||
if ($id) {
|
||||
$component->id = $id;
|
||||
$component->find(TRUE);
|
||||
}
|
||||
|
||||
$component->copyValues($params);
|
||||
if (empty($id) && empty($params['body_text'])) {
|
||||
$component->body_text = CRM_Utils_String::htmlToText(CRM_Utils_Array::value('body_html', $params));
|
||||
}
|
||||
|
||||
if ($component->is_default) {
|
||||
if (!empty($id)) {
|
||||
$sql = 'UPDATE civicrm_mailing_component SET is_default = 0 WHERE component_type = %1 AND id <> %2';
|
||||
$sqlParams = array(
|
||||
1 => array($component->component_type, 'String'),
|
||||
2 => array($id, 'Positive'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$sql = 'UPDATE civicrm_mailing_component SET is_default = 0 WHERE component_type = %1';
|
||||
$sqlParams = array(
|
||||
1 => array($component->component_type, 'String'),
|
||||
);
|
||||
}
|
||||
CRM_Core_DAO::executeQuery($sql, $sqlParams);
|
||||
}
|
||||
|
||||
$component->save();
|
||||
return $component;
|
||||
}
|
||||
|
||||
}
|
3280
sites/all/modules/civicrm/CRM/Mailing/BAO/Mailing.php
Normal file
3280
sites/all/modules/civicrm/CRM/Mailing/BAO/Mailing.php
Normal file
File diff suppressed because it is too large
Load diff
183
sites/all/modules/civicrm/CRM/Mailing/BAO/MailingAB.php
Normal file
183
sites/all/modules/civicrm/CRM/Mailing/BAO/MailingAB.php
Normal file
|
@ -0,0 +1,183 @@
|
|||
<?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_BAO_MailingAB
|
||||
*/
|
||||
class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB {
|
||||
|
||||
/**
|
||||
* class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new mailingab object.
|
||||
*
|
||||
* @params array $params
|
||||
* Form values.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $ids
|
||||
*
|
||||
* @return object
|
||||
* $mailingab The new mailingab object
|
||||
*/
|
||||
public static function create(&$params, $ids = array()) {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$mailingab = self::add($params, $ids);
|
||||
|
||||
if (is_a($mailingab, 'CRM_Core_Error')) {
|
||||
$transaction->rollback();
|
||||
return $mailingab;
|
||||
}
|
||||
$transaction->commit();
|
||||
return $mailingab;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to add the mailings.
|
||||
*
|
||||
* @param array $params
|
||||
* Reference array contains the values submitted by the form.
|
||||
* @param array $ids
|
||||
* Reference array contains the id.
|
||||
*
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function add(&$params, $ids = array()) {
|
||||
$id = CRM_Utils_Array::value('mailingab_id', $ids, CRM_Utils_Array::value('id', $params));
|
||||
|
||||
if ($id) {
|
||||
CRM_Utils_Hook::pre('edit', 'MailingAB', $id, $params);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::pre('create', 'MailingAB', NULL, $params);
|
||||
}
|
||||
|
||||
$mailingab = new CRM_Mailing_DAO_MailingAB();
|
||||
$mailingab->id = $id;
|
||||
if (!$id) {
|
||||
$mailingab->domain_id = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID());
|
||||
}
|
||||
|
||||
$mailingab->copyValues($params);
|
||||
|
||||
$result = $mailingab->save();
|
||||
|
||||
if ($id) {
|
||||
CRM_Utils_Hook::post('edit', 'MailingAB', $mailingab->id, $mailingab);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::post('create', 'MailingAB', $mailingab->id, $mailingab);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete MailingAB and all its associated records.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the mail to delete.
|
||||
*/
|
||||
public static function del($id) {
|
||||
if (empty($id)) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
CRM_Core_Transaction::create()->run(function () use ($id) {
|
||||
CRM_Utils_Hook::pre('delete', 'MailingAB', $id, CRM_Core_DAO::$_nullArray);
|
||||
|
||||
$dao = new CRM_Mailing_DAO_MailingAB();
|
||||
$dao->id = $id;
|
||||
if ($dao->find(TRUE)) {
|
||||
$mailing_ids = array($dao->mailing_id_a, $dao->mailing_id_b, $dao->mailing_id_c);
|
||||
$dao->delete();
|
||||
foreach ($mailing_ids as $mailing_id) {
|
||||
if ($mailing_id) {
|
||||
CRM_Mailing_BAO_Mailing::del($mailing_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success');
|
||||
|
||||
CRM_Utils_Hook::post('delete', 'MailingAB', $id, $dao);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer recipients from the canonical mailing A to the other mailings.
|
||||
*
|
||||
* @param CRM_Mailing_DAO_MailingAB $dao
|
||||
*/
|
||||
public static function distributeRecipients(CRM_Mailing_DAO_MailingAB $dao) {
|
||||
CRM_Mailing_BAO_Mailing::getRecipients($dao->mailing_id_a, $dao->mailing_id_a, TRUE);
|
||||
|
||||
//calculate total number of random recipients for mail C from group_percentage selected
|
||||
$totalCount = CRM_Mailing_BAO_Recipients::mailingSize($dao->mailing_id_a);
|
||||
$totalSelected = max(1, round(($totalCount * $dao->group_percentage) / 100));
|
||||
|
||||
CRM_Mailing_BAO_Recipients::reassign($dao->mailing_id_a, array(
|
||||
$dao->mailing_id_b => (2 * $totalSelected <= $totalCount) ? $totalSelected : $totalCount - $totalSelected,
|
||||
$dao->mailing_id_c => max(0, $totalCount - $totalSelected - $totalSelected),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get abtest based on Mailing ID
|
||||
*
|
||||
* @param int $mailingID
|
||||
* Mailing ID.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function getABTest($mailingID) {
|
||||
$query = "SELECT * FROM `civicrm_mailing_abtest` ab
|
||||
where (ab.mailing_id_a = %1
|
||||
OR ab.mailing_id_b = %1
|
||||
OR ab.mailing_id_c = %1)
|
||||
GROUP BY ab.id";
|
||||
$params = array(1 => array($mailingID, 'Integer'));
|
||||
$abTest = CRM_Core_DAO::executeQuery($query, $params);
|
||||
$abTest->fetch();
|
||||
return $abTest;
|
||||
}
|
||||
|
||||
}
|
1059
sites/all/modules/civicrm/CRM/Mailing/BAO/MailingJob.php
Normal file
1059
sites/all/modules/civicrm/CRM/Mailing/BAO/MailingJob.php
Normal file
File diff suppressed because it is too large
Load diff
526
sites/all/modules/civicrm/CRM/Mailing/BAO/Query.php
Normal file
526
sites/all/modules/civicrm/CRM/Mailing/BAO/Query.php
Normal file
|
@ -0,0 +1,526 @@
|
|||
<?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_BAO_Query {
|
||||
|
||||
static $_mailingFields = NULL;
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public static function &getFields() {
|
||||
if (!self::$_mailingFields) {
|
||||
self::$_mailingFields = array();
|
||||
$_mailingFields['mailing_id'] = array(
|
||||
'name' => 'mailing_id',
|
||||
'title' => ts('Mailing ID'),
|
||||
'where' => 'civicrm_mailing.id',
|
||||
);
|
||||
}
|
||||
return self::$_mailingFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* If mailings are involved, add the specific Mailing fields
|
||||
*
|
||||
* @param $query
|
||||
*/
|
||||
public static function select(&$query) {
|
||||
// if Mailing mode add mailing id
|
||||
if ($query->_mode & CRM_Contact_BAO_Query::MODE_MAILING) {
|
||||
$query->_select['mailing_id'] = "civicrm_mailing.id as mailing_id";
|
||||
$query->_element['mailing_id'] = 1;
|
||||
|
||||
// base table is contact, so join recipients to it
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients']
|
||||
= " INNER JOIN civicrm_mailing_recipients ON civicrm_mailing_recipients.contact_id = contact_a.id ";
|
||||
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
|
||||
// get mailing name
|
||||
if (!empty($query->_returnProperties['mailing_name'])) {
|
||||
$query->_select['mailing_name'] = "civicrm_mailing.name as mailing_name";
|
||||
$query->_element['mailing_name'] = 1;
|
||||
}
|
||||
|
||||
// get mailing subject
|
||||
if (!empty($query->_returnProperties['mailing_subject'])) {
|
||||
$query->_select['mailing_subject'] = "civicrm_mailing.subject as mailing_subject";
|
||||
$query->_element['mailing_subject'] = 1;
|
||||
}
|
||||
|
||||
// get mailing status
|
||||
if (!empty($query->_returnProperties['mailing_job_status'])) {
|
||||
$query->_tables['civicrm_mailing_job'] = $query->_whereTables['civicrm_mailing_job']
|
||||
= " LEFT JOIN civicrm_mailing_job ON civicrm_mailing_job.mailing_id = civicrm_mailing.id AND civicrm_mailing_job.parent_id IS NULL AND civicrm_mailing_job.is_test != 1 ";
|
||||
$query->_select['mailing_job_status'] = "civicrm_mailing_job.status as mailing_job_status";
|
||||
$query->_element['mailing_job_status'] = 1;
|
||||
}
|
||||
|
||||
// get email on hold
|
||||
if (!empty($query->_returnProperties['email_on_hold'])) {
|
||||
$query->_select['email_on_hold'] = "recipient_email.on_hold as email_on_hold";
|
||||
$query->_element['email_on_hold'] = 1;
|
||||
$query->_tables['recipient_email'] = $query->_whereTables['recipient_email'] = 1;
|
||||
}
|
||||
|
||||
// get recipient email
|
||||
if (!empty($query->_returnProperties['email'])) {
|
||||
$query->_select['email'] = "recipient_email.email as email";
|
||||
$query->_element['email'] = 1;
|
||||
$query->_tables['recipient_email'] = $query->_whereTables['recipient_email'] = 1;
|
||||
}
|
||||
|
||||
// get user opt out
|
||||
if (!empty($query->_returnProperties['contact_opt_out'])) {
|
||||
$query->_select['contact_opt_out'] = "contact_a.is_opt_out as contact_opt_out";
|
||||
$query->_element['contact_opt_out'] = 1;
|
||||
}
|
||||
|
||||
// mailing job end date / completed date
|
||||
if (!empty($query->_returnProperties['mailing_job_end_date'])) {
|
||||
$query->_tables['civicrm_mailing_job'] = $query->_whereTables['civicrm_mailing_job']
|
||||
= " LEFT JOIN civicrm_mailing_job ON civicrm_mailing_job.mailing_id = civicrm_mailing.id AND civicrm_mailing_job.parent_id IS NULL AND civicrm_mailing_job.is_test != 1 ";
|
||||
$query->_select['mailing_job_end_date'] = "civicrm_mailing_job.end_date as mailing_job_end_date";
|
||||
$query->_element['mailing_job_end_date'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['mailing_recipients_id'])) {
|
||||
$query->_select['mailing_recipients_id'] = " civicrm_mailing_recipients.id as mailing_recipients_id";
|
||||
$query->_element['mailing_recipients_id'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (CRM_Utils_Array::value('mailing_campaign_id', $query->_returnProperties)) {
|
||||
$query->_select['mailing_campaign_id'] = 'civicrm_mailing.campaign_id as mailing_campaign_id';
|
||||
$query->_element['mailing_campaign_id'] = 1;
|
||||
$query->_tables['civicrm_campaign'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*/
|
||||
public static function where(&$query) {
|
||||
$grouping = NULL;
|
||||
foreach (array_keys($query->_params) as $id) {
|
||||
if (empty($query->_params[$id][0])) {
|
||||
continue;
|
||||
}
|
||||
if (substr($query->_params[$id][0], 0, 8) == 'mailing_') {
|
||||
if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
|
||||
$query->_useDistinct = TRUE;
|
||||
}
|
||||
$grouping = $query->_params[$id][3];
|
||||
self::whereClauseSingle($query->_params[$id], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $mode
|
||||
* @param $side
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function from($name, $mode, $side) {
|
||||
$from = NULL;
|
||||
|
||||
switch ($name) {
|
||||
case 'civicrm_mailing_recipients':
|
||||
$from = " $side JOIN civicrm_mailing_recipients ON civicrm_mailing_recipients.contact_id = contact_a.id";
|
||||
break;
|
||||
|
||||
case 'civicrm_mailing_event_queue':
|
||||
// this is tightly binded so as to do a check WRT actual job recipients ('child' type jobs)
|
||||
$from = " INNER JOIN civicrm_mailing_event_queue ON
|
||||
civicrm_mailing_event_queue.contact_id = civicrm_mailing_recipients.contact_id
|
||||
AND civicrm_mailing_event_queue.job_id = civicrm_mailing_job.id AND civicrm_mailing_job.job_type = 'child'";
|
||||
break;
|
||||
|
||||
case 'civicrm_mailing':
|
||||
$from = " $side JOIN civicrm_mailing ON civicrm_mailing.id = civicrm_mailing_recipients.mailing_id ";
|
||||
break;
|
||||
|
||||
case 'civicrm_mailing_job':
|
||||
$from = " $side JOIN civicrm_mailing_job ON civicrm_mailing_job.mailing_id = civicrm_mailing.id AND civicrm_mailing_job.is_test != 1 ";
|
||||
break;
|
||||
|
||||
case 'civicrm_mailing_event_bounce':
|
||||
case 'civicrm_mailing_event_delivered':
|
||||
case 'civicrm_mailing_event_opened':
|
||||
case 'civicrm_mailing_event_reply':
|
||||
case 'civicrm_mailing_event_unsubscribe':
|
||||
case 'civicrm_mailing_event_forward':
|
||||
case 'civicrm_mailing_event_trackable_url_open':
|
||||
$from = " $side JOIN $name ON $name.event_queue_id = civicrm_mailing_event_queue.id";
|
||||
break;
|
||||
|
||||
case 'recipient_email':
|
||||
$from = " $side JOIN civicrm_email recipient_email ON recipient_email.id = civicrm_mailing_recipients.email_id";
|
||||
break;
|
||||
|
||||
case 'civicrm_campaign':
|
||||
$from = " $side JOIN civicrm_campaign ON civicrm_campaign.id = civicrm_mailing.campaign_id";
|
||||
break;
|
||||
}
|
||||
|
||||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mode
|
||||
* @param bool $includeCustomFields
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function defaultReturnProperties(
|
||||
$mode,
|
||||
$includeCustomFields = TRUE
|
||||
) {
|
||||
|
||||
$properties = NULL;
|
||||
if ($mode & CRM_Contact_BAO_Query::MODE_MAILING) {
|
||||
$properties = array(
|
||||
'mailing_id' => 1,
|
||||
'mailing_campaign_id' => 1,
|
||||
'mailing_name' => 1,
|
||||
'sort_name' => 1,
|
||||
'email' => 1,
|
||||
'mailing_subject' => 1,
|
||||
'email_on_hold' => 1,
|
||||
'contact_opt_out' => 1,
|
||||
'mailing_job_status' => 1,
|
||||
'mailing_job_end_date' => 1,
|
||||
'contact_type' => 1,
|
||||
'contact_sub_type' => 1,
|
||||
'mailing_recipients_id' => 1,
|
||||
);
|
||||
}
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $values
|
||||
* @param $query
|
||||
*/
|
||||
public static function whereClauseSingle(&$values, &$query) {
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
|
||||
$fields = array();
|
||||
$fields = self::getFields();
|
||||
|
||||
switch ($name) {
|
||||
case 'mailing_id':
|
||||
$selectedMailings = array_flip($value);
|
||||
$value = "(" . implode(',', $value) . ")";
|
||||
$op = 'IN';
|
||||
$query->_where[$grouping][] = "civicrm_mailing.id $op $value";
|
||||
|
||||
$mailings = CRM_Mailing_BAO_Mailing::getMailingsList();
|
||||
foreach ($selectedMailings as $id => $dnc) {
|
||||
$selectedMailings[$id] = $mailings[$id];
|
||||
}
|
||||
$selectedMailings = implode(' or ', $selectedMailings);
|
||||
|
||||
$query->_qill[$grouping][] = "Mailing Name $op \"$selectedMailings\"";
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
return;
|
||||
|
||||
case 'mailing_name':
|
||||
$value = strtolower(addslashes($value));
|
||||
if ($wildcard) {
|
||||
$value = "%$value%";
|
||||
$op = 'LIKE';
|
||||
}
|
||||
|
||||
// LOWER in query below roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
|
||||
$query->_where[$grouping][] = "LOWER(civicrm_mailing.name) $op '$value'";
|
||||
$query->_qill[$grouping][] = "Mailing Namename $op \"$value\"";
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
return;
|
||||
|
||||
case 'mailing_date':
|
||||
case 'mailing_date_low':
|
||||
case 'mailing_date_high':
|
||||
// process to / from date
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_event_queue'] = $query->_whereTables['civicrm_mailing_event_queue'] = 1;
|
||||
$query->_tables['civicrm_mailing_job'] = $query->_whereTables['civicrm_mailing_job'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
$query->dateQueryBuilder($values,
|
||||
'civicrm_mailing_job', 'mailing_date', 'start_date', 'Mailing Delivery Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_delivery_status':
|
||||
$options = CRM_Mailing_PseudoConstant::yesNoOptions('delivered');
|
||||
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
if ($value == 'Y') {
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_delivered',
|
||||
'mailing_delivery_status',
|
||||
ts('Mailing Delivery'),
|
||||
$options
|
||||
);
|
||||
}
|
||||
elseif ($value == 'N') {
|
||||
$options['Y'] = $options['N'];
|
||||
$values = array($name, $op, 'Y', $grouping, $wildcard);
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_bounce',
|
||||
'mailing_delivery_status',
|
||||
ts('Mailing Delivery'),
|
||||
$options
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
case 'mailing_bounce_types':
|
||||
$op = 'IN';
|
||||
$values = array($name, $op, $value, $grouping, $wildcard);
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_bounce',
|
||||
'bounce_type_id',
|
||||
ts('Bounce type(s)'),
|
||||
CRM_Core_PseudoConstant::get('CRM_Mailing_Event_DAO_Bounce', 'bounce_type_id', array(
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'name',
|
||||
))
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_open_status':
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_opened', 'mailing_open_status', ts('Mailing: Trackable Opens'), CRM_Mailing_PseudoConstant::yesNoOptions('open')
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_click_status':
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_trackable_url_open', 'mailing_click_status', ts('Mailing: Trackable URL Clicks'), CRM_Mailing_PseudoConstant::yesNoOptions('click')
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_reply_status':
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_reply', 'mailing_reply_status', ts('Mailing: Trackable Replies'), CRM_Mailing_PseudoConstant::yesNoOptions('reply')
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_optout':
|
||||
$valueTitle = array(1 => ts('Opt-out Requests'));
|
||||
// include opt-out events only
|
||||
$query->_where[$grouping][] = "civicrm_mailing_event_unsubscribe.org_unsubscribe = 1";
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_unsubscribe', 'mailing_unsubscribe',
|
||||
ts('Mailing: '), $valueTitle
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_unsubscribe':
|
||||
$valueTitle = array(1 => ts('Unsubscribe Requests'));
|
||||
// exclude opt-out events
|
||||
$query->_where[$grouping][] = "civicrm_mailing_event_unsubscribe.org_unsubscribe = 0";
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_unsubscribe', 'mailing_unsubscribe',
|
||||
ts('Mailing: '), $valueTitle
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_forward':
|
||||
$valueTitle = array('Y' => ts('Forwards'));
|
||||
// since its a checkbox
|
||||
$values[2] = 'Y';
|
||||
self::mailingEventQueryBuilder($query, $values,
|
||||
'civicrm_mailing_event_forward', 'mailing_forward',
|
||||
ts('Mailing: '), $valueTitle
|
||||
);
|
||||
return;
|
||||
|
||||
case 'mailing_job_status':
|
||||
if (!empty($value)) {
|
||||
if ($value != 'Scheduled' && $value != 'Canceled') {
|
||||
$query->_tables['civicrm_mailing_event_queue'] = $query->_whereTables['civicrm_mailing_event_queue'] = 1;
|
||||
}
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_job'] = $query->_whereTables['civicrm_mailing_job'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
|
||||
$query->_where[$grouping][] = " civicrm_mailing_job.status = '{$value}' ";
|
||||
$query->_qill[$grouping][] = "Mailing Job Status IS \"$value\"";
|
||||
}
|
||||
return;
|
||||
|
||||
case 'mailing_campaign_id':
|
||||
$name = 'campaign_id';
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_mailing.$name", $op, $value, 'Integer');
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Mailing_DAO_Mailing', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts('Campaign %1 %2', array(1 => $op, 2 => $value));
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the elements shared between Mailing search and advnaced search.
|
||||
*
|
||||
*
|
||||
* @param CRM_Core_Form $form
|
||||
*/
|
||||
public static function buildSearchForm(&$form) {
|
||||
// mailing selectors
|
||||
$mailings = CRM_Mailing_BAO_Mailing::getMailingsList();
|
||||
|
||||
if (!empty($mailings)) {
|
||||
$form->add('select', 'mailing_id', ts('Mailing Name(s)'), $mailings, FALSE,
|
||||
array('id' => 'mailing_id', 'multiple' => 'multiple', 'class' => 'crm-select2')
|
||||
);
|
||||
}
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($form, 'mailing_date', 1, '_low', '_high', ts('From'), FALSE);
|
||||
$form->addElement('hidden', 'mailing_date_range_error');
|
||||
$form->addFormRule(array('CRM_Mailing_BAO_Query', 'formRule'), $form);
|
||||
|
||||
$mailingJobStatuses = array(
|
||||
'' => ts('- select -'),
|
||||
'Complete' => 'Complete',
|
||||
'Scheduled' => 'Scheduled',
|
||||
'Running' => 'Running',
|
||||
'Canceled' => 'Canceled',
|
||||
);
|
||||
$form->addElement('select', 'mailing_job_status', ts('Mailing Job Status'), $mailingJobStatuses, FALSE);
|
||||
|
||||
$mailingBounceTypes = CRM_Core_PseudoConstant::get(
|
||||
'CRM_Mailing_Event_DAO_Bounce', 'bounce_type_id',
|
||||
array('keyColumn' => 'id', 'labelColumn' => 'name')
|
||||
);
|
||||
$form->add('select', 'mailing_bounce_types', ts('Bounce Types'), $mailingBounceTypes, FALSE,
|
||||
array('id' => 'mailing_bounce_types', 'multiple' => 'multiple', 'class' => 'crm-select2')
|
||||
);
|
||||
|
||||
// event filters
|
||||
$form->addRadio('mailing_delivery_status', ts('Delivery Status'), CRM_Mailing_PseudoConstant::yesNoOptions('delivered'), array('allowClear' => TRUE));
|
||||
$form->addRadio('mailing_open_status', ts('Trackable Opens'), CRM_Mailing_PseudoConstant::yesNoOptions('open'), array('allowClear' => TRUE));
|
||||
$form->addRadio('mailing_click_status', ts('Trackable URLs'), CRM_Mailing_PseudoConstant::yesNoOptions('click'), array('allowClear' => TRUE));
|
||||
$form->addRadio('mailing_reply_status', ts('Trackable Replies'), CRM_Mailing_PseudoConstant::yesNoOptions('reply'), array('allowClear' => TRUE));
|
||||
|
||||
$form->add('checkbox', 'mailing_unsubscribe', ts('Unsubscribe Requests'));
|
||||
$form->add('checkbox', 'mailing_optout', ts('Opt-out Requests'));
|
||||
$form->add('checkbox', 'mailing_forward', ts('Forwards'));
|
||||
// Campaign select field
|
||||
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'mailing_campaign_id');
|
||||
|
||||
$form->assign('validCiviMailing', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
* @param int $id
|
||||
*/
|
||||
public static function searchAction(&$row, $id) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tables
|
||||
*/
|
||||
public static function tableNames(&$tables) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter query results based on which contacts do (not) have a particular mailing event in their history.
|
||||
*
|
||||
* @param $query
|
||||
* @param $values
|
||||
* @param string $tableName
|
||||
* @param string $fieldName
|
||||
* @param $fieldTitle
|
||||
*
|
||||
* @param $valueTitles
|
||||
*/
|
||||
public static function mailingEventQueryBuilder(&$query, &$values, $tableName, $fieldName, $fieldTitle, &$valueTitles) {
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
|
||||
if (empty($value) || $value == 'A') {
|
||||
// don't do any filtering
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value == 'Y') {
|
||||
$query->_where[$grouping][] = $tableName . ".id is not null ";
|
||||
}
|
||||
elseif ($value == 'N') {
|
||||
$query->_where[$grouping][] = $tableName . ".id is null ";
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$query->_where[$grouping][] = "$tableName.$fieldName $op (" . implode(',', $value) . ")";
|
||||
$query->_qill[$grouping][] = "$fieldTitle $op " . implode(', ', array_intersect_key($valueTitles, array_flip($value)));
|
||||
}
|
||||
else {
|
||||
$query->_qill[$grouping][] = $fieldTitle . ' - ' . $valueTitles[$value];
|
||||
}
|
||||
|
||||
$query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
|
||||
$query->_tables['civicrm_mailing_job'] = $query->_whereTables['civicrm_mailing_job'] = 1;
|
||||
$query->_tables['civicrm_mailing_event_queue'] = $query->_whereTables['civicrm_mailing_event_queue'] = 1;
|
||||
$query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
|
||||
$query->_tables[$tableName] = $query->_whereTables[$tableName] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the values in the date range are in correct chronological order.
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $files
|
||||
* @param CRM_Core_Form $form
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function formRule($fields, $files, $form) {
|
||||
$errors = array();
|
||||
|
||||
if (empty($fields['mailing_date_high']) || empty($fields['mailing_date_low'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CRM_Utils_Rule::validDateRange($fields, 'mailing_date', $errors, ts('Mailing Date'));
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
}
|
140
sites/all/modules/civicrm/CRM/Mailing/BAO/Recipients.php
Normal file
140
sites/all/modules/civicrm/CRM/Mailing/BAO/Recipients.php
Normal file
|
@ -0,0 +1,140 @@
|
|||
<?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_BAO_Recipients extends CRM_Mailing_DAO_Recipients {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $mailingID
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function mailingSize($mailingID) {
|
||||
$sql = "
|
||||
SELECT count(*) as count
|
||||
FROM civicrm_mailing_recipients
|
||||
WHERE mailing_id = %1
|
||||
";
|
||||
$params = array(1 => array($mailingID, 'Integer'));
|
||||
return CRM_Core_DAO::singleValueQuery($sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $mailingID
|
||||
* @param null $offset
|
||||
* @param null $limit
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
public static function mailingQuery(
|
||||
$mailingID,
|
||||
$offset = NULL, $limit = NULL
|
||||
) {
|
||||
$limitString = NULL;
|
||||
if ($limit && $offset !== NULL) {
|
||||
$offset = CRM_Utils_Type::escape($offset, 'Int');
|
||||
$limit = CRM_Utils_Type::escape($limit, 'Int');
|
||||
|
||||
$limitString = "LIMIT $offset, $limit";
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT contact_id, email_id, phone_id
|
||||
FROM civicrm_mailing_recipients
|
||||
WHERE mailing_id = %1
|
||||
$limitString
|
||||
";
|
||||
$params = array(1 => array($mailingID, 'Integer'));
|
||||
|
||||
return CRM_Core_DAO::executeQuery($sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a number of randomly-chosen recipients of one Mailing to another Mailing.
|
||||
*
|
||||
* @param int $sourceMailingId
|
||||
* Source mailing ID
|
||||
* @param int $newMailingID
|
||||
* Destination mailing ID
|
||||
* @param int $totalLimit
|
||||
* Number of recipients to move
|
||||
*/
|
||||
public static function updateRandomRecipients($sourceMailingId, $newMailingID, $totalLimit = NULL) {
|
||||
$limitString = NULL;
|
||||
if ($totalLimit) {
|
||||
$limitString = "LIMIT 0, $totalLimit";
|
||||
}
|
||||
CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS srcMailing_$sourceMailingId");
|
||||
$sql = "
|
||||
CREATE TEMPORARY TABLE srcMailing_$sourceMailingId
|
||||
(mailing_recipient_id int, id int PRIMARY KEY AUTO_INCREMENT, INDEX(mailing_recipient_id))
|
||||
ENGINE=HEAP";
|
||||
CRM_Core_DAO::executeQuery($sql);
|
||||
$sql = "
|
||||
INSERT INTO srcMailing_$sourceMailingId (mailing_recipient_id)
|
||||
SELECT mr.id
|
||||
FROM civicrm_mailing_recipients mr
|
||||
WHERE mr.mailing_id = $sourceMailingId
|
||||
ORDER BY RAND()
|
||||
$limitString
|
||||
";
|
||||
CRM_Core_DAO::executeQuery($sql);
|
||||
$sql = "
|
||||
UPDATE civicrm_mailing_recipients mr
|
||||
INNER JOIN srcMailing_$sourceMailingId temp_mr ON temp_mr.mailing_recipient_id = mr.id
|
||||
SET mr.mailing_id = $newMailingID
|
||||
";
|
||||
CRM_Core_DAO::executeQuery($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redistribute recipients from $sourceMailingId to a series of other mailings.
|
||||
*
|
||||
* @param int $sourceMailingId
|
||||
* @param array $to
|
||||
* (int $targetMailingId => int $count).
|
||||
*/
|
||||
public static function reassign($sourceMailingId, $to) {
|
||||
foreach ($to as $targetMailingId => $count) {
|
||||
if ($count > 0) {
|
||||
CRM_Mailing_BAO_Recipients::updateRandomRecipients($sourceMailingId, $targetMailingId, $count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
135
sites/all/modules/civicrm/CRM/Mailing/BAO/Spool.php
Normal file
135
sites/all/modules/civicrm/CRM/Mailing/BAO/Spool.php
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?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_BAO_Spool extends CRM_Mailing_DAO_Spool {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Mails into Spool table.
|
||||
*
|
||||
* @param string|array $recipient
|
||||
* Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
* @param array $headers
|
||||
* The array of headers to send with the mail.
|
||||
*
|
||||
* @param string $body
|
||||
* The full text of the message body, including any mime parts, etc.
|
||||
*
|
||||
* @param int $job_id
|
||||
*
|
||||
* @return bool|CRM_Core_Error
|
||||
* true if successful
|
||||
*/
|
||||
public function send($recipient, $headers, $body, $job_id = NULL) {
|
||||
$headerStr = array();
|
||||
foreach ($headers as $name => $value) {
|
||||
$headerStr[] = "$name: $value";
|
||||
}
|
||||
$headerStr = implode("\n", $headerStr);
|
||||
|
||||
if (is_null($job_id)) {
|
||||
// This is not a bulk mailing. Create a dummy job for it.
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$params = array();
|
||||
$params['created_id'] = $session->get('userID');
|
||||
$params['created_date'] = date('YmdHis');
|
||||
$params['scheduled_id'] = $params['created_id'];
|
||||
$params['scheduled_date'] = $params['created_date'];
|
||||
$params['is_completed'] = 1;
|
||||
$params['is_archived'] = 1;
|
||||
$params['body_html'] = htmlspecialchars($headerStr) . "\n\n" . $body;
|
||||
$params['subject'] = $headers['Subject'];
|
||||
$params['name'] = $headers['Subject'];
|
||||
$ids = array();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::create($params, $ids);
|
||||
|
||||
if (empty($mailing) || is_a($mailing, 'CRM_Core_Error')) {
|
||||
return PEAR::raiseError('Unable to create spooled mailing.');
|
||||
}
|
||||
|
||||
$job = new CRM_Mailing_BAO_MailingJob();
|
||||
$job->is_test = 0; // if set to 1 it doesn't show in the UI
|
||||
$job->status = 'Complete';
|
||||
$job->scheduled_date = CRM_Utils_Date::processDate(date('Y-m-d'), date('H:i:s'));
|
||||
$job->start_date = $job->scheduled_date;
|
||||
$job->end_date = $job->scheduled_date;
|
||||
$job->mailing_id = $mailing->id;
|
||||
$job->save();
|
||||
$job_id = $job->id; // need this for parent_id below
|
||||
|
||||
$job = new CRM_Mailing_BAO_MailingJob();
|
||||
$job->is_test = 0;
|
||||
$job->status = 'Complete';
|
||||
$job->scheduled_date = CRM_Utils_Date::processDate(date('Y-m-d'), date('H:i:s'));
|
||||
$job->start_date = $job->scheduled_date;
|
||||
$job->end_date = $job->scheduled_date;
|
||||
$job->mailing_id = $mailing->id;
|
||||
$job->parent_id = $job_id;
|
||||
$job->job_type = 'child';
|
||||
$job->save();
|
||||
$job_id = $job->id; // this is the one we want for the spool
|
||||
|
||||
if (is_array($recipient)) {
|
||||
$recipient = implode(';', $recipient);
|
||||
}
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$params = array(
|
||||
'job_id' => $job_id,
|
||||
'recipient_email' => $recipient,
|
||||
'headers' => $headerStr,
|
||||
'body' => $body,
|
||||
'added_at' => date("YmdHis"),
|
||||
'removed_at' => NULL,
|
||||
);
|
||||
|
||||
$spoolMail = new CRM_Mailing_DAO_Spool();
|
||||
$spoolMail->copyValues($params);
|
||||
$spoolMail->save();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
124
sites/all/modules/civicrm/CRM/Mailing/BAO/TrackableURL.php
Normal file
124
sites/all/modules/civicrm/CRM/Mailing/BAO/TrackableURL.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?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_BAO_TrackableURL extends CRM_Mailing_DAO_TrackableURL {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a url, mailing id and queue event id, find or construct a
|
||||
* trackable url and redirect url.
|
||||
*
|
||||
* @param string $url
|
||||
* The target url to track.
|
||||
* @param int $mailing_id
|
||||
* The id of the mailing.
|
||||
* @param int $queue_id
|
||||
* The queue event id (contact clicking through).
|
||||
*
|
||||
* @return string
|
||||
* The redirect/tracking url
|
||||
*/
|
||||
public static function getTrackerURL($url, $mailing_id, $queue_id) {
|
||||
|
||||
static $urlCache = array();
|
||||
|
||||
if (array_key_exists($mailing_id . $url, $urlCache)) {
|
||||
return $urlCache[$mailing_id . $url] . "&qid=$queue_id";
|
||||
}
|
||||
|
||||
// hack for basic CRM-1014 and CRM-1151 and CRM-3492 compliance:
|
||||
// let's not replace possible image URLs and CiviMail ones
|
||||
if (preg_match('/\.(png|jpg|jpeg|gif|css)[\'"]?$/i', $url)
|
||||
or substr_count($url, 'civicrm/extern/')
|
||||
or substr_count($url, 'civicrm/mailing/')
|
||||
) {
|
||||
// let's not cache these, so they don't get &qid= appended to them
|
||||
return $url;
|
||||
}
|
||||
else {
|
||||
|
||||
$hrefExists = FALSE;
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
$tracker = new CRM_Mailing_BAO_TrackableURL();
|
||||
if (preg_match('/^href/i', $url)) {
|
||||
$url = preg_replace('/^href[ ]*=[ ]*[\'"](.*?)[\'"]$/i', '$1', $url);
|
||||
$hrefExists = TRUE;
|
||||
}
|
||||
|
||||
$tracker->url = $url;
|
||||
$tracker->mailing_id = $mailing_id;
|
||||
|
||||
if (!$tracker->find(TRUE)) {
|
||||
$tracker->save();
|
||||
}
|
||||
$id = $tracker->id;
|
||||
$tracker->free();
|
||||
|
||||
$redirect = $config->userFrameworkResourceURL . "extern/url.php?u=$id";
|
||||
$urlCache[$mailing_id . $url] = $redirect;
|
||||
}
|
||||
|
||||
$returnUrl = "{$urlCache[$mailing_id . $url]}&qid={$queue_id}";
|
||||
|
||||
if ($hrefExists) {
|
||||
$returnUrl = "href='{$returnUrl}'";
|
||||
}
|
||||
|
||||
return $returnUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
* @param $mailing_id
|
||||
*
|
||||
* @return int
|
||||
* Url id of the given url and mail
|
||||
*/
|
||||
public static function getTrackerURLId($url, $mailing_id) {
|
||||
$tracker = new CRM_Mailing_BAO_TrackableURL();
|
||||
$tracker->url = $url;
|
||||
$tracker->mailing_id = $mailing_id;
|
||||
if ($tracker->find(TRUE)) {
|
||||
return $tracker->id;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
47
sites/all/modules/civicrm/CRM/Mailing/Config.php
Normal file
47
sites/all/modules/civicrm/CRM/Mailing/Config.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?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_Config {
|
||||
|
||||
const OUTBOUND_OPTION_SMTP = 0;
|
||||
const OUTBOUND_OPTION_SENDMAIL = 1;
|
||||
const OUTBOUND_OPTION_DISABLED = 2;
|
||||
const OUTBOUND_OPTION_MAIL = 3;
|
||||
const OUTBOUND_OPTION_MOCK = 4; // seems to be the same as 2, but also calls Mail's pre/post hooks? - see packages/Mail
|
||||
const OUTBOUND_OPTION_REDIRECT_TO_DB = 5;
|
||||
|
||||
// special value for mail bulk inserts to avoid
|
||||
// potential duplication, assuming a smaller number reduces number of queries
|
||||
// by some factor, so some tradeoff. CRM-8678
|
||||
const BULK_MAIL_INSERT_COUNT = 10;
|
||||
|
||||
}
|
72
sites/all/modules/civicrm/CRM/Mailing/Controller/Send.php
Normal file
72
sites/all/modules/civicrm/CRM/Mailing/Controller/Send.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?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_Controller_Send extends CRM_Core_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param null $title
|
||||
* @param bool|int $action
|
||||
* @param bool $modal
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
|
||||
parent::__construct($title, $modal, NULL, FALSE, TRUE);
|
||||
|
||||
// New: civicrm/mailing/send?reset=1
|
||||
// Re-use: civicrm/mailing/send?reset=1&mid=%%mid%%
|
||||
// Continue: civicrm/mailing/send?reset=1&mid=%%mid%%&continue=true
|
||||
$mid = CRM_Utils_Request::retrieve('mid', 'Positive');
|
||||
$continue = CRM_Utils_Request::retrieve('continue', 'String');
|
||||
if (!$mid) {
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/new'));
|
||||
}
|
||||
if ($mid && $continue) {
|
||||
//CRM-15979 - check if abtest exist for mailing then redirect accordingly
|
||||
$abtest = CRM_Mailing_BAO_MailingAB::getABTest($mid);
|
||||
if (!empty($abtest) && !empty($abtest->id)) {
|
||||
$redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id);
|
||||
}
|
||||
else {
|
||||
$redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mid);
|
||||
}
|
||||
CRM_Utils_System::redirect($redirect);
|
||||
}
|
||||
if ($mid && !$continue) {
|
||||
$clone = civicrm_api3('Mailing', 'clone', array('id' => $mid));
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
195
sites/all/modules/civicrm/CRM/Mailing/DAO/BouncePattern.php
Normal file
195
sites/all/modules/civicrm/CRM/Mailing/DAO/BouncePattern.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/BouncePattern.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:d913b0da4c5cbb03a7d23cc28e3d4dcd)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_BouncePattern constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_bounce_pattern';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Type of bounce
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $bounce_type_id;
|
||||
/**
|
||||
* A regexp to match a message to a bounce type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $pattern;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_bounce_pattern';
|
||||
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() , 'bounce_type_id', 'civicrm_mailing_bounce_type', '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 Pattern ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_bounce_pattern',
|
||||
'entity' => 'BouncePattern',
|
||||
'bao' => 'CRM_Mailing_BAO_BouncePattern',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'bounce_type_id' => array(
|
||||
'name' => 'bounce_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Bounce Type') ,
|
||||
'description' => 'Type of bounce',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_bounce_pattern',
|
||||
'entity' => 'BouncePattern',
|
||||
'bao' => 'CRM_Mailing_BAO_BouncePattern',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_BounceType',
|
||||
) ,
|
||||
'pattern' => array(
|
||||
'name' => 'pattern',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Pattern') ,
|
||||
'description' => 'A regexp to match a message to a bounce type',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_bounce_pattern',
|
||||
'entity' => 'BouncePattern',
|
||||
'bao' => 'CRM_Mailing_BAO_BouncePattern',
|
||||
'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_bounce_pattern', $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_bounce_pattern', $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;
|
||||
}
|
||||
}
|
199
sites/all/modules/civicrm/CRM/Mailing/DAO/BounceType.php
Normal file
199
sites/all/modules/civicrm/CRM/Mailing/DAO/BounceType.php
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?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/BounceType.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:58e082dadf7a5125e5c34d0f9cffb0f1)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_BounceType constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_bounce_type';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Type of bounce
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* A description of this bounce type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description;
|
||||
/**
|
||||
* Number of bounces of this type required before the email address is put on bounce hold
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $hold_threshold;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_bounce_type';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* 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 Type ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_bounce_type',
|
||||
'entity' => 'BounceType',
|
||||
'bao' => 'CRM_Mailing_DAO_BounceType',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Bounce Type Name') ,
|
||||
'description' => 'Type of bounce',
|
||||
'required' => true,
|
||||
'maxlength' => 24,
|
||||
'size' => CRM_Utils_Type::MEDIUM,
|
||||
'table_name' => 'civicrm_mailing_bounce_type',
|
||||
'entity' => 'BounceType',
|
||||
'bao' => 'CRM_Mailing_DAO_BounceType',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'description' => array(
|
||||
'name' => 'description',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Bounce Type Description') ,
|
||||
'description' => 'A description of this bounce type',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_bounce_type',
|
||||
'entity' => 'BounceType',
|
||||
'bao' => 'CRM_Mailing_DAO_BounceType',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'hold_threshold' => array(
|
||||
'name' => 'hold_threshold',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Hold Threshold') ,
|
||||
'description' => 'Number of bounces of this type required before the email address is put on bounce hold',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_bounce_type',
|
||||
'entity' => 'BounceType',
|
||||
'bao' => 'CRM_Mailing_DAO_BounceType',
|
||||
'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_bounce_type', $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_bounce_type', $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;
|
||||
}
|
||||
}
|
277
sites/all/modules/civicrm/CRM/Mailing/DAO/Component.php
Normal file
277
sites/all/modules/civicrm/CRM/Mailing/DAO/Component.php
Normal file
|
@ -0,0 +1,277 @@
|
|||
<?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/Component.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:33742feaa53eaba2c4a543c4e5c673ab)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_Component constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_Component extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_component';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The name of this component
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Type of Component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component_type;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subject;
|
||||
/**
|
||||
* Body of the component in html format.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $body_html;
|
||||
/**
|
||||
* Body of the component in text format.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $body_text;
|
||||
/**
|
||||
* Is this the default component for this component_type?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_default;
|
||||
/**
|
||||
* Is this property active?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_component';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* 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 Component ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Component Name') ,
|
||||
'description' => 'The name of this component',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'component_type' => array(
|
||||
'name' => 'component_type',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Component Type') ,
|
||||
'description' => 'Type of Component.',
|
||||
'maxlength' => 12,
|
||||
'size' => CRM_Utils_Type::TWELVE,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Core_SelectValues::mailingComponents',
|
||||
)
|
||||
) ,
|
||||
'subject' => array(
|
||||
'name' => 'subject',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Subject') ,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'body_html' => array(
|
||||
'name' => 'body_html',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Mailing Component Body HTML') ,
|
||||
'description' => 'Body of the component in html format.',
|
||||
'rows' => 8,
|
||||
'cols' => 80,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'TextArea',
|
||||
) ,
|
||||
) ,
|
||||
'body_text' => array(
|
||||
'name' => 'body_text',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Body Text') ,
|
||||
'description' => 'Body of the component in text format.',
|
||||
'rows' => 8,
|
||||
'cols' => 80,
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'TextArea',
|
||||
) ,
|
||||
) ,
|
||||
'is_default' => array(
|
||||
'name' => 'is_default',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Mailing Component is Default?') ,
|
||||
'description' => 'Is this the default component for this component_type?',
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Mailing Component Is Active?') ,
|
||||
'description' => 'Is this property active?',
|
||||
'table_name' => 'civicrm_mailing_component',
|
||||
'entity' => 'Component',
|
||||
'bao' => 'CRM_Mailing_BAO_Component',
|
||||
'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_component', $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_component', $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;
|
||||
}
|
||||
}
|
1004
sites/all/modules/civicrm/CRM/Mailing/DAO/Mailing.php
Normal file
1004
sites/all/modules/civicrm/CRM/Mailing/DAO/Mailing.php
Normal file
File diff suppressed because it is too large
Load diff
386
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingAB.php
Normal file
386
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingAB.php
Normal file
|
@ -0,0 +1,386 @@
|
|||
<?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/MailingAB.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:12d9514d27712e3d9ad545ca6c2bfe91)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_MailingAB constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_abtest';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Name of the A/B test
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Status
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* The first experimental mailing ("A" condition)
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id_a;
|
||||
/**
|
||||
* The second experimental mailing ("B" condition)
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id_b;
|
||||
/**
|
||||
* The final, general mailing (derived from A or B)
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id_c;
|
||||
/**
|
||||
* Which site is this mailing for
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $domain_id;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $testing_criteria;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $winner_criteria;
|
||||
/**
|
||||
* What specific url to track
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $specific_url;
|
||||
/**
|
||||
* In how much time to declare winner
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
public $declare_winning_time;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $group_percentage;
|
||||
/**
|
||||
* FK to Contact ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $created_id;
|
||||
/**
|
||||
* When was this item created
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $created_date;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_abtest';
|
||||
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() , 'created_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('MailingAB ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Name') ,
|
||||
'description' => 'Name of the A/B test',
|
||||
'maxlength' => 128,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'status' => array(
|
||||
'name' => 'status',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Status') ,
|
||||
'description' => 'Status',
|
||||
'maxlength' => 32,
|
||||
'size' => CRM_Utils_Type::MEDIUM,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Mailing_PseudoConstant::abStatus',
|
||||
)
|
||||
) ,
|
||||
'mailing_id_a' => array(
|
||||
'name' => 'mailing_id_a',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing ID (A)') ,
|
||||
'description' => 'The first experimental mailing ("A" condition)',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id_b' => array(
|
||||
'name' => 'mailing_id_b',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing ID (B)') ,
|
||||
'description' => 'The second experimental mailing ("B" condition)',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id_c' => array(
|
||||
'name' => 'mailing_id_c',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing ID (C)') ,
|
||||
'description' => 'The final, general mailing (derived from A or B)',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'domain_id' => array(
|
||||
'name' => 'domain_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Domain ID') ,
|
||||
'description' => 'Which site is this mailing for',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'testing_criteria' => array(
|
||||
'name' => 'testing_criteria',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Testing Criteria') ,
|
||||
'maxlength' => 32,
|
||||
'size' => CRM_Utils_Type::MEDIUM,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Mailing_PseudoConstant::abTestCriteria',
|
||||
)
|
||||
) ,
|
||||
'winner_criteria' => array(
|
||||
'name' => 'winner_criteria',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Winner Criteria') ,
|
||||
'maxlength' => 32,
|
||||
'size' => CRM_Utils_Type::MEDIUM,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Mailing_PseudoConstant::abWinnerCriteria',
|
||||
)
|
||||
) ,
|
||||
'specific_url' => array(
|
||||
'name' => 'specific_url',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('URL for Winner Criteria') ,
|
||||
'description' => 'What specific url to track',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'declare_winning_time' => array(
|
||||
'name' => 'declare_winning_time',
|
||||
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
|
||||
'title' => ts('Declaration Time') ,
|
||||
'description' => 'In how much time to declare winner',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'group_percentage' => array(
|
||||
'name' => 'group_percentage',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Group Percentage') ,
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'created_id' => array(
|
||||
'name' => 'created_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('AB Test Created By') ,
|
||||
'description' => 'FK to Contact ID',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'created_date' => array(
|
||||
'name' => 'created_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('AB Test Created Date') ,
|
||||
'description' => 'When was this item created',
|
||||
'required' => false,
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_mailing_abtest',
|
||||
'entity' => 'MailingAB',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingAB',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
) ,
|
||||
) ,
|
||||
);
|
||||
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_abtest', $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_abtest', $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;
|
||||
}
|
||||
}
|
273
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingGroup.php
Normal file
273
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingGroup.php
Normal file
|
@ -0,0 +1,273 @@
|
|||
<?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/MailingGroup.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:a96d346551d72b03fa3ca07ac47cff2b)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_MailingGroup constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_group';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The ID of a previous mailing to include/exclude recipients.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id;
|
||||
/**
|
||||
* Are the members of the group included or excluded?.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $group_type;
|
||||
/**
|
||||
* Name of table where item being referenced is stored.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* Foreign key to the referenced item.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* The filtering search. custom search id or -1 for civicrm api search
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $search_id;
|
||||
/**
|
||||
* The arguments to be sent to the search function
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $search_args;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_group';
|
||||
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() , 'mailing_id', 'civicrm_mailing', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
|
||||
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 Group ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id' => array(
|
||||
'name' => 'mailing_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing') ,
|
||||
'description' => 'The ID of a previous mailing to include/exclude recipients.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_Mailing',
|
||||
) ,
|
||||
'group_type' => array(
|
||||
'name' => 'group_type',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Group Type') ,
|
||||
'description' => 'Are the members of the group included or excluded?.',
|
||||
'maxlength' => 8,
|
||||
'size' => CRM_Utils_Type::EIGHT,
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Core_SelectValues::getMailingGroupTypes',
|
||||
)
|
||||
) ,
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Group Entity Table') ,
|
||||
'description' => 'Name of table where item being referenced is stored.',
|
||||
'required' => true,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Mailing_BAO_Mailing::mailingGroupEntityTables',
|
||||
)
|
||||
) ,
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Group Entity') ,
|
||||
'description' => 'Foreign key to the referenced item.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'search_id' => array(
|
||||
'name' => 'search_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Group Search') ,
|
||||
'description' => 'The filtering search. custom search id or -1 for civicrm api search',
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'search_args' => array(
|
||||
'name' => 'search_args',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Mailing Group Search Arguments') ,
|
||||
'description' => 'The arguments to be sent to the search function',
|
||||
'table_name' => 'civicrm_mailing_group',
|
||||
'entity' => 'MailingGroup',
|
||||
'bao' => 'CRM_Mailing_DAO_MailingGroup',
|
||||
'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_group', $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_group', $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;
|
||||
}
|
||||
}
|
340
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingJob.php
Normal file
340
sites/all/modules/civicrm/CRM/Mailing/DAO/MailingJob.php
Normal file
|
@ -0,0 +1,340 @@
|
|||
<?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/MailingJob.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:51449e1b36d9d248712f346f20c9e446)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_MailingJob constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_job';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The ID of the mailing this Job will send.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id;
|
||||
/**
|
||||
* date on which this job was scheduled.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $scheduled_date;
|
||||
/**
|
||||
* date on which this job was started.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $start_date;
|
||||
/**
|
||||
* date on which this job ended.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $end_date;
|
||||
/**
|
||||
* The state of this job
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* Is this job for a test mail?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_test;
|
||||
/**
|
||||
* Type of mailling job: null | child
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $job_type;
|
||||
/**
|
||||
* Parent job id
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $parent_id;
|
||||
/**
|
||||
* Offset of the child job
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $job_offset;
|
||||
/**
|
||||
* Queue size limit for each child job
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $job_limit;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_job';
|
||||
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() , 'mailing_id', 'civicrm_mailing', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_mailing_job', '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 Job ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id' => array(
|
||||
'name' => 'mailing_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing') ,
|
||||
'description' => 'The ID of the mailing this Job will send.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_Mailing',
|
||||
) ,
|
||||
'scheduled_date' => array(
|
||||
'name' => 'scheduled_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Mailing Scheduled Date') ,
|
||||
'description' => 'date on which this job was scheduled.',
|
||||
'required' => false,
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'start_date' => array(
|
||||
'name' => 'start_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Mailing Job Start Date') ,
|
||||
'description' => 'date on which this job was started.',
|
||||
'required' => false,
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'end_date' => array(
|
||||
'name' => 'end_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Mailing Job End Date') ,
|
||||
'description' => 'date on which this job ended.',
|
||||
'required' => false,
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'status' => array(
|
||||
'name' => 'status',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Job Status') ,
|
||||
'description' => 'The state of this job',
|
||||
'maxlength' => 12,
|
||||
'size' => CRM_Utils_Type::TWELVE,
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_Core_SelectValues::getMailingJobStatus',
|
||||
)
|
||||
) ,
|
||||
'is_test' => array(
|
||||
'name' => 'is_test',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Mailing Job Is Test?') ,
|
||||
'description' => 'Is this job for a test mail?',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'job_type' => array(
|
||||
'name' => 'job_type',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Mailing Job Type') ,
|
||||
'description' => 'Type of mailling job: null | child ',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'parent_id' => array(
|
||||
'name' => 'parent_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Job Parent') ,
|
||||
'description' => 'Parent job id',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_MailingJob',
|
||||
) ,
|
||||
'job_offset' => array(
|
||||
'name' => 'job_offset',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Job Offset') ,
|
||||
'description' => 'Offset of the child job',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'job_limit' => array(
|
||||
'name' => 'job_limit',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Job Limit') ,
|
||||
'description' => 'Queue size limit for each child job',
|
||||
'table_name' => 'civicrm_mailing_job',
|
||||
'entity' => 'MailingJob',
|
||||
'bao' => 'CRM_Mailing_BAO_MailingJob',
|
||||
'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_job', $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_job', $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;
|
||||
}
|
||||
}
|
234
sites/all/modules/civicrm/CRM/Mailing/DAO/Recipients.php
Normal file
234
sites/all/modules/civicrm/CRM/Mailing/DAO/Recipients.php
Normal file
|
@ -0,0 +1,234 @@
|
|||
<?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/Recipients.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:c342948a9f69ec474335688029f101e0)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_Recipients constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_recipients';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The ID of the mailing this Job will send.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id;
|
||||
/**
|
||||
* FK to Contact
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* FK to Email
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $email_id;
|
||||
/**
|
||||
* FK to Phone
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $phone_id;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_recipients';
|
||||
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() , 'mailing_id', 'civicrm_mailing', '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() , 'email_id', 'civicrm_email', '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 Recipients ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_recipients',
|
||||
'entity' => 'Recipients',
|
||||
'bao' => 'CRM_Mailing_BAO_Recipients',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id' => array(
|
||||
'name' => 'mailing_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing') ,
|
||||
'description' => 'The ID of the mailing this Job will send.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_recipients',
|
||||
'entity' => 'Recipients',
|
||||
'bao' => 'CRM_Mailing_BAO_Recipients',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_Mailing',
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Recipient') ,
|
||||
'description' => 'FK to Contact',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_recipients',
|
||||
'entity' => 'Recipients',
|
||||
'bao' => 'CRM_Mailing_BAO_Recipients',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'email_id' => array(
|
||||
'name' => 'email_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Recipient Email') ,
|
||||
'description' => 'FK to Email',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_recipients',
|
||||
'entity' => 'Recipients',
|
||||
'bao' => 'CRM_Mailing_BAO_Recipients',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Core_DAO_Email',
|
||||
) ,
|
||||
'phone_id' => array(
|
||||
'name' => 'phone_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Recipient Phone') ,
|
||||
'description' => 'FK to Phone',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_recipients',
|
||||
'entity' => 'Recipients',
|
||||
'bao' => 'CRM_Mailing_BAO_Recipients',
|
||||
'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_recipients', $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_recipients', $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;
|
||||
}
|
||||
}
|
261
sites/all/modules/civicrm/CRM/Mailing/DAO/Spool.php
Normal file
261
sites/all/modules/civicrm/CRM/Mailing/DAO/Spool.php
Normal file
|
@ -0,0 +1,261 @@
|
|||
<?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/Spool.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:8cdc46330195fed32b15c2560dee858d)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_Spool constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_spool';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The ID of the Job .
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $job_id;
|
||||
/**
|
||||
* The email of the receipients this mail is to be sent.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $recipient_email;
|
||||
/**
|
||||
* The header information of this mailing .
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $headers;
|
||||
/**
|
||||
* The body of this mailing.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $body;
|
||||
/**
|
||||
* date on which this job was added.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $added_at;
|
||||
/**
|
||||
* date on which this job was removed.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $removed_at;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_spool';
|
||||
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');
|
||||
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('Spool ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'job_id' => array(
|
||||
'name' => 'job_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing Job') ,
|
||||
'description' => 'The ID of the Job .',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_MailingJob',
|
||||
) ,
|
||||
'recipient_email' => array(
|
||||
'name' => 'recipient_email',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Recipient Email') ,
|
||||
'description' => 'The email of the receipients this mail is to be sent.',
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'headers' => array(
|
||||
'name' => 'headers',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Headers') ,
|
||||
'description' => 'The header information of this mailing .',
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'body' => array(
|
||||
'name' => 'body',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Body') ,
|
||||
'description' => 'The body of this mailing.',
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'added_at' => array(
|
||||
'name' => 'added_at',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Added') ,
|
||||
'description' => 'date on which this job was added.',
|
||||
'required' => false,
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'removed_at' => array(
|
||||
'name' => 'removed_at',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Removed') ,
|
||||
'description' => 'date on which this job was removed.',
|
||||
'required' => false,
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_mailing_spool',
|
||||
'entity' => 'Spool',
|
||||
'bao' => 'CRM_Mailing_BAO_Spool',
|
||||
'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_spool', $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_spool', $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;
|
||||
}
|
||||
}
|
194
sites/all/modules/civicrm/CRM/Mailing/DAO/TrackableURL.php
Normal file
194
sites/all/modules/civicrm/CRM/Mailing/DAO/TrackableURL.php
Normal file
|
@ -0,0 +1,194 @@
|
|||
<?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/TrackableURL.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:13d0c2db9be0713818bda26731896ae6)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Mailing_DAO_TrackableURL constructor.
|
||||
*/
|
||||
class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_mailing_trackable_url';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* The URL to be tracked.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $url;
|
||||
/**
|
||||
* FK to the mailing
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $mailing_id;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_mailing_trackable_url';
|
||||
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() , 'mailing_id', 'civicrm_mailing', '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 ID') ,
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_trackable_url',
|
||||
'entity' => 'TrackableURL',
|
||||
'bao' => 'CRM_Mailing_BAO_TrackableURL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'url' => array(
|
||||
'name' => 'url',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Url') ,
|
||||
'description' => 'The URL to be tracked.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_trackable_url',
|
||||
'entity' => 'TrackableURL',
|
||||
'bao' => 'CRM_Mailing_BAO_TrackableURL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'mailing_id' => array(
|
||||
'name' => 'mailing_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Mailing') ,
|
||||
'description' => 'FK to the mailing',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_mailing_trackable_url',
|
||||
'entity' => 'TrackableURL',
|
||||
'bao' => 'CRM_Mailing_BAO_TrackableURL',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Mailing_DAO_Mailing',
|
||||
) ,
|
||||
);
|
||||
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_trackable_url', $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_trackable_url', $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;
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
238
sites/all/modules/civicrm/CRM/Mailing/Form/Approve.php
Normal file
238
sites/all/modules/civicrm/CRM/Mailing/Form/Approve.php
Normal file
|
@ -0,0 +1,238 @@
|
|||
<?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_Form_Approve extends CRM_Core_Form {
|
||||
|
||||
public function redirectToListing() {
|
||||
$url = CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true');
|
||||
CRM_Utils_System::redirect($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
if (CRM_Mailing_Info::workflowEnabled()) {
|
||||
if (!CRM_Core_Permission::check('approve mailings') && !CRM_Core_Permission::check('access CiviMail')) {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
|
||||
// when user come from search context.
|
||||
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
|
||||
|
||||
//retrieve mid from different wizard and url contexts
|
||||
$this->_mailingID = $this->get('mailing_id');
|
||||
$this->_approveFormOnly = FALSE;
|
||||
if (!$this->_mailingID) {
|
||||
$this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
|
||||
$this->_approveFormOnly = TRUE;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_contactID = $session->get('userID');
|
||||
|
||||
$this->_mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$this->_mailing->id = $this->_mailingID;
|
||||
if (!$this->_mailing->find(TRUE)) {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
if ($this->_mailingID) {
|
||||
$defaults['approval_status_id'] = $this->_mailing->approval_status_id;
|
||||
$defaults['approval_note'] = $this->_mailing->approval_note;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object for the approval/rejection mailing.
|
||||
*/
|
||||
public function buildQuickform() {
|
||||
$title = ts('Approve/Reject Mailing') . " - {$this->_mailing->name}";
|
||||
CRM_Utils_System::setTitle($title);
|
||||
|
||||
$this->addElement('textarea', 'approval_note', ts('Approve/Reject Note'));
|
||||
|
||||
$mailApprovalStatus = CRM_Core_OptionGroup::values('mail_approval_status');
|
||||
|
||||
// eliminate the none option
|
||||
$noneOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status',
|
||||
'None',
|
||||
'name'
|
||||
);
|
||||
if ($noneOptionID) {
|
||||
unset($mailApprovalStatus[$noneOptionID]);
|
||||
}
|
||||
|
||||
$this->addRadio('approval_status_id', ts('Approval Status'), $mailApprovalStatus, array(), NULL, TRUE);
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
|
||||
// add the preview elements
|
||||
$preview = array();
|
||||
|
||||
$preview['subject'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing',
|
||||
$this->_mailingID,
|
||||
'subject'
|
||||
);
|
||||
|
||||
$mailingKey = $this->_mailingID;
|
||||
if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
|
||||
$mailingKey = $hash;
|
||||
}
|
||||
|
||||
$preview['viewURL'] = CRM_Utils_System::url('civicrm/mailing/view', "reset=1&id={$mailingKey}");
|
||||
$preview['type'] = $this->_mailing->body_html ? 'html' : 'text';
|
||||
$preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $this->_mailingID);
|
||||
|
||||
$this->assign_by_ref('preview', $preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the posted form values. Approve /reject a mailing.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// get the submitted form values.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$ids = array();
|
||||
if (isset($this->_mailingID)) {
|
||||
$ids['mailing_id'] = $this->_mailingID;
|
||||
}
|
||||
else {
|
||||
$ids['mailing_id'] = $this->get('mailing_id');
|
||||
}
|
||||
|
||||
if (!$ids['mailing_id']) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
|
||||
$params['approver_id'] = $this->_contactID;
|
||||
$params['approval_date'] = date('YmdHis');
|
||||
|
||||
// if rejected, then we need to reset the scheduled date and scheduled id
|
||||
$rejectOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status',
|
||||
'Rejected',
|
||||
'name'
|
||||
);
|
||||
if ($rejectOptionID &&
|
||||
$params['approval_status_id'] == $rejectOptionID
|
||||
) {
|
||||
$params['scheduled_id'] = 'null';
|
||||
$params['scheduled_date'] = 'null';
|
||||
|
||||
// also delete any jobs associated with this mailing
|
||||
$job = new CRM_Mailing_BAO_MailingJob();
|
||||
$job->mailing_id = $ids['mailing_id'];
|
||||
$job->delete();
|
||||
}
|
||||
else {
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing->id = $ids['mailing_id'];
|
||||
$mailing->find(TRUE);
|
||||
|
||||
$params['scheduled_date'] = CRM_Utils_Date::processDate($mailing->scheduled_date);
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::create($params, $ids);
|
||||
|
||||
//when user perform mailing from search context
|
||||
//redirect it to search result CRM-3711
|
||||
$ssID = $this->get('ssID');
|
||||
if ($ssID && $this->_searchBasedMailing) {
|
||||
if ($this->_action == CRM_Core_Action::BASIC) {
|
||||
$fragment = 'search';
|
||||
}
|
||||
elseif ($this->_action == CRM_Core_Action::PROFILE) {
|
||||
$fragment = 'search/builder';
|
||||
}
|
||||
elseif ($this->_action == CRM_Core_Action::ADVANCED) {
|
||||
$fragment = 'search/advanced';
|
||||
}
|
||||
else {
|
||||
$fragment = 'search/custom';
|
||||
}
|
||||
$context = $this->get('context');
|
||||
if (!CRM_Contact_Form_Search::isSearchContext($context)) {
|
||||
$context = 'search';
|
||||
}
|
||||
$urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
|
||||
return $this->controller->setDestination($url);
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled',
|
||||
'reset=1&scheduled=true'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Name of the form.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Approve/Reject Mailing');
|
||||
}
|
||||
|
||||
}
|
92
sites/all/modules/civicrm/CRM/Mailing/Form/Browse.php
Normal file
92
sites/all/modules/civicrm/CRM/Mailing/Form/Browse.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build the form object for disable mail feature
|
||||
*/
|
||||
class CRM_Mailing_Form_Browse extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Heart of the viewing process. The runner gets all the meta data for
|
||||
* the contact and calls the appropriate type of page to view.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
|
||||
|
||||
// check for action permissions.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing->id = $this->_mailingId;
|
||||
$subject = '';
|
||||
if ($mailing->find(TRUE)) {
|
||||
$subject = $mailing->subject;
|
||||
}
|
||||
$this->assign('subject', $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Confirm'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Mailing_BAO_Mailing::del($this->_mailingId);
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::DISABLE) {
|
||||
CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::RENEW) {
|
||||
//set is_archived to 1
|
||||
CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
207
sites/all/modules/civicrm/CRM/Mailing/Form/Component.php
Normal file
207
sites/all/modules/civicrm/CRM/Mailing/Form/Component.php
Normal file
|
@ -0,0 +1,207 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Location Type.
|
||||
*/
|
||||
class CRM_Mailing_Form_Component extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The id of the object being edited / created
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The name of the BAO object for this form.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_BAOName;
|
||||
|
||||
public function preProcess() {
|
||||
$this->_id = $this->get('id');
|
||||
$this->_BAOName = $this->get('BAOName');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->applyFilter(array('name', 'subject', 'body_html'), 'trim');
|
||||
|
||||
$this->add('text', 'name', ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'name'), TRUE
|
||||
);
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Mailing_DAO_Component',
|
||||
$this->_id,
|
||||
));
|
||||
|
||||
$this->add('select', 'component_type', ts('Component Type'), CRM_Core_SelectValues::mailingComponents());
|
||||
|
||||
$this->add('text', 'subject', ts('Subject'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'subject'),
|
||||
TRUE
|
||||
);
|
||||
$this->add('textarea', 'body_text', ts('Body - TEXT Format'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_text')
|
||||
);
|
||||
$this->add('textarea', 'body_html', ts('Body - HTML Format'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_html')
|
||||
);
|
||||
|
||||
$this->addYesNo('is_default', ts('Default?'));
|
||||
$this->addYesNo('is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Component', 'formRule'));
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Component', 'dataRule'));
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
$params = array();
|
||||
|
||||
if (isset($this->_id)) {
|
||||
$params = array('id' => $this->_id);
|
||||
$baoName = $this->_BAOName;
|
||||
$baoName::retrieve($params, $defaults);
|
||||
}
|
||||
else {
|
||||
$defaults['is_active'] = 1;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
$component = CRM_Mailing_BAO_Component::add($params);
|
||||
CRM_Core_Session::setStatus(ts('The mailing component \'%1\' has been saved.', array(
|
||||
1 => $component->name,
|
||||
)
|
||||
), ts('Saved'), 'success');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation.
|
||||
*
|
||||
* @param array $params
|
||||
* (ref.) an assoc array of name/value pairs.
|
||||
*
|
||||
* @param $files
|
||||
* @param $options
|
||||
*
|
||||
* @return bool|array
|
||||
* mixed true or array of errors
|
||||
*/
|
||||
public static function dataRule($params, $files, $options) {
|
||||
if ($params['component_type'] == 'Header' || $params['component_type'] == 'Footer') {
|
||||
$InvalidTokens = array();
|
||||
}
|
||||
else {
|
||||
$InvalidTokens = array('action.forward' => ts("This token can only be used in send mailing context (body, header, footer).."));
|
||||
}
|
||||
$errors = array();
|
||||
foreach (array(
|
||||
'text',
|
||||
'html',
|
||||
) as $type) {
|
||||
$dataErrors = array();
|
||||
foreach ($InvalidTokens as $token => $desc) {
|
||||
if ($params['body_' . $type]) {
|
||||
if (preg_match('/' . preg_quote('{' . $token . '}') . '/', $params['body_' . $type])) {
|
||||
$dataErrors[] = '<li>' . ts('This message is having a invalid token - %1: %2', array(
|
||||
1 => $token,
|
||||
2 => $desc,
|
||||
)) . '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($dataErrors)) {
|
||||
$errors['body_' . $type] = ts('The following errors were detected in %1 message:', array(
|
||||
1 => $type,
|
||||
)) . '<ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Tokens', TRUE, NULL, NULL, NULL, "wiki") . '">' . ts('More information on tokens...') . '</a>';
|
||||
}
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that either body text or body html is required.
|
||||
* @param array $params
|
||||
* (ref.) an assoc array of name/value pairs.
|
||||
*
|
||||
* @param $files
|
||||
* @param $options
|
||||
*
|
||||
* @return bool|array
|
||||
* mixed true or array of errors
|
||||
*/
|
||||
public static function formRule($params, $files, $options) {
|
||||
$errors = array();
|
||||
if (empty($params['body_text']) && empty($params['body_html'])) {
|
||||
$errors['body_text'] = ts("Please provide either HTML or TEXT format for the Body.");
|
||||
$errors['body_html'] = ts("Please provide either HTML or TEXT format for the Body.");
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
}
|
160
sites/all/modules/civicrm/CRM/Mailing/Form/ForwardMailing.php
Normal file
160
sites/all/modules/civicrm/CRM/Mailing/Form/ForwardMailing.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
|
||||
*/
|
||||
class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form {
|
||||
public function preProcess() {
|
||||
$job_id = CRM_Utils_Request::retrieve('jid', 'Positive',
|
||||
$this, NULL
|
||||
);
|
||||
$queue_id = CRM_Utils_Request::retrieve('qid', 'Positive',
|
||||
$this, NULL
|
||||
);
|
||||
$hash = CRM_Utils_Request::retrieve('h', 'String',
|
||||
$this, NULL
|
||||
);
|
||||
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
|
||||
if ($q == NULL) {
|
||||
|
||||
// ERROR.
|
||||
CRM_Core_Error::fatal(ts('Invalid form parameters.'));
|
||||
CRM_Core_Error::statusBounce(ts('Invalid form parameters.'));
|
||||
}
|
||||
$mailing = &$q->getMailing();
|
||||
|
||||
if ($hash) {
|
||||
$emailId = CRM_Core_DAO::getfieldValue('CRM_Mailing_Event_DAO_Queue', $hash, 'email_id', 'hash');
|
||||
$this->_fromEmail = $fromEmail = CRM_Core_DAO::getfieldValue('CRM_Core_DAO_Email', $emailId, 'email');
|
||||
$this->assign('fromEmail', $fromEmail);
|
||||
}
|
||||
|
||||
// Show the subject instead of the name here, since it's being
|
||||
// displayed to external contacts/users.
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
|
||||
|
||||
$this->set('queue_id', $queue_id);
|
||||
$this->set('job_id', $job_id);
|
||||
$this->set('hash', $hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->add('text', "email_$i", ts('Email %1', array(1 => $i + 1)));
|
||||
$this->addRule("email_$i", ts('Email is not valid.'), 'email');
|
||||
}
|
||||
|
||||
//insert message Text by selecting "Select Template option"
|
||||
$this->add('textarea', 'forward_comment', ts('Comment'), array('cols' => '80', 'rows' => '8'));
|
||||
$this->add('wysiwyg', 'html_comment',
|
||||
ts('HTML Message'),
|
||||
array('cols' => '80', 'rows' => '8')
|
||||
);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Forward'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission of new/edit contact is processed.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$queue_id = $this->get('queue_id');
|
||||
$job_id = $this->get('job_id');
|
||||
$hash = $this->get('hash');
|
||||
$timeStamp = date('YmdHis');
|
||||
|
||||
$formValues = $this->controller->exportValues($this->_name);
|
||||
$params = array();
|
||||
$params['body_text'] = $formValues['forward_comment'];
|
||||
$html_comment = $formValues['html_comment'];
|
||||
$params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment));
|
||||
|
||||
$emails = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$email = $this->controller->exportValue($this->_name, "email_$i");
|
||||
if (!empty($email)) {
|
||||
$emails[] = $email;
|
||||
}
|
||||
}
|
||||
|
||||
$forwarded = NULL;
|
||||
foreach ($emails as $email) {
|
||||
$params = array(
|
||||
'version' => 3,
|
||||
'job_id' => $job_id,
|
||||
'event_queue_id' => $queue_id,
|
||||
'hash' => $hash,
|
||||
'email' => $email,
|
||||
'time_stamp' => $timeStamp,
|
||||
'fromEmail' => $this->_fromEmail,
|
||||
'params' => $params,
|
||||
);
|
||||
$result = civicrm_api('Mailing', 'event_forward', $params);
|
||||
if (!civicrm_error($result)) {
|
||||
$forwarded++;
|
||||
}
|
||||
}
|
||||
|
||||
$status = ts('Mailing is not forwarded to the given email address.', array(
|
||||
'count' => count($emails),
|
||||
'plural' => 'Mailing is not forwarded to the given email addresses.',
|
||||
));
|
||||
if ($forwarded) {
|
||||
$status = ts('Mailing is forwarded successfully to %count email address.', array(
|
||||
'count' => $forwarded,
|
||||
'plural' => 'Mailing is forwarded successfully to %count email addresses.',
|
||||
));
|
||||
}
|
||||
|
||||
CRM_Utils_System::setUFMessage($status);
|
||||
|
||||
// always redirect to front page of url
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$session->pushUserContext($config->userFrameworkBaseURL);
|
||||
}
|
||||
|
||||
}
|
126
sites/all/modules/civicrm/CRM/Mailing/Form/Optout.php
Normal file
126
sites/all/modules/civicrm/CRM/Mailing/Form/Optout.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?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_Form_Optout extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
|
||||
$this->_type = 'optout';
|
||||
|
||||
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
|
||||
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
|
||||
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
|
||||
|
||||
if (!$job_id ||
|
||||
!$queue_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing input parameters"));
|
||||
}
|
||||
|
||||
// verify that the three numbers above match
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
CRM_Core_Error::fatal(ts("There was an error in your request"));
|
||||
}
|
||||
|
||||
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$emailMasked = CRM_Utils_String::maskEmail($email);
|
||||
$this->assign('email_masked', $emailMasked);
|
||||
$this->assign('email', $email);
|
||||
$this->_email = $email;
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
|
||||
CRM_Utils_System::setTitle(ts('Please Confirm Your Opt Out'));
|
||||
|
||||
$this->add('text', 'email_confirm', ts('Verify email address to opt out:'));
|
||||
$this->addRule('email_confirm', ts('Email address is required to opt out.'), 'required');
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Opt Out'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
|
||||
$values = $this->exportValues();
|
||||
|
||||
// check if EmailTyped matches Email address
|
||||
$result = CRM_Utils_String::compareStr($this->_email, $values['email_confirm'], TRUE);
|
||||
|
||||
$job_id = $this->_job_id;
|
||||
$queue_id = $this->_queue_id;
|
||||
$hash = $this->_hash;
|
||||
|
||||
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}", "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1");
|
||||
$this->assign('confirmURL', $confirmURL);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($confirmURL);
|
||||
|
||||
if ($result == TRUE) {
|
||||
// Email address verified
|
||||
if (CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_domain($job_id, $queue_id, $hash)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, NULL, TRUE, $job_id);
|
||||
}
|
||||
|
||||
$statusMsg = ts('Email: %1 has been successfully opted out',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'success');
|
||||
}
|
||||
elseif ($result == FALSE) {
|
||||
// Email address not verified
|
||||
|
||||
$statusMsg = ts('The email address: %1 you have entered does not match the email associated with this opt out request.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
154
sites/all/modules/civicrm/CRM/Mailing/Form/Search.php
Normal file
154
sites/all/modules/civicrm/CRM/Mailing/Form/Search.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?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_Form_Search extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
$parent = $this->controller->getParent();
|
||||
$nameTextLabel = ($parent->_sms) ? ts('SMS Name') : ts('Mailing Name');
|
||||
|
||||
$this->add('text', 'mailing_name', $nameTextLabel,
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'title')
|
||||
);
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($this, 'mailing', 1, '_from', '_to', ts('From'), FALSE);
|
||||
|
||||
$this->add('text', 'sort_name', ts('Created or Sent by'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
|
||||
);
|
||||
|
||||
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
|
||||
|
||||
// CRM-15434 - Fix mailing search by status in non-English languages
|
||||
$statusVals = CRM_Core_SelectValues::getMailingJobStatus();
|
||||
foreach ($statusVals as $statusId => $statusName) {
|
||||
$this->addElement('checkbox', "mailing_status[$statusId]", NULL, $statusName);
|
||||
}
|
||||
$this->addElement('checkbox', 'status_unscheduled', NULL, ts('Draft / Unscheduled'));
|
||||
$this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);
|
||||
|
||||
// Search by language, if multi-lingual
|
||||
$enabledLanguages = CRM_Core_I18n::languages(TRUE);
|
||||
|
||||
if (count($enabledLanguages) > 1) {
|
||||
$this->addElement('select', 'language', ts('Language'), array('' => ts('- all languages -')) + $enabledLanguages, array('class' => 'crm-select2'));
|
||||
}
|
||||
|
||||
if ($parent->_sms) {
|
||||
$this->addElement('hidden', 'sms', $parent->_sms);
|
||||
}
|
||||
$this->add('hidden', 'hidden_find_mailings', 1);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'refresh',
|
||||
'name' => ts('Search'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = $statusVals = array();
|
||||
$parent = $this->controller->getParent();
|
||||
|
||||
if ($parent->get('unscheduled')) {
|
||||
$defaults['status_unscheduled'] = 1;
|
||||
}
|
||||
if ($parent->get('scheduled')) {
|
||||
$statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
|
||||
$defaults['is_archived'] = 0;
|
||||
}
|
||||
if ($parent->get('archived')) {
|
||||
$defaults['is_archived'] = 1;
|
||||
}
|
||||
foreach ($statusVals as $status) {
|
||||
$defaults['mailing_status'][$status] = 1;
|
||||
}
|
||||
|
||||
if ($parent->_sms) {
|
||||
$defaults['sms'] = 1;
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
CRM_Contact_BAO_Query::fixDateValues($params["mailing_relative"], $params['mailing_from'], $params['mailing_to']);
|
||||
|
||||
$parent = $this->controller->getParent();
|
||||
if (!empty($params)) {
|
||||
$fields = array(
|
||||
'mailing_name',
|
||||
'mailing_from',
|
||||
'mailing_to',
|
||||
'sort_name',
|
||||
'campaign_id',
|
||||
'mailing_status',
|
||||
'sms',
|
||||
'status_unscheduled',
|
||||
'is_archived',
|
||||
'language',
|
||||
'hidden_find_mailings',
|
||||
);
|
||||
foreach ($fields as $field) {
|
||||
if (isset($params[$field]) &&
|
||||
!CRM_Utils_System::isNull($params[$field])
|
||||
) {
|
||||
if (in_array($field, array(
|
||||
'mailing_from',
|
||||
'mailing_to',
|
||||
)) && !$params["mailing_relative"]
|
||||
) {
|
||||
$time = ($field == 'mailing_to') ? '235959' : NULL;
|
||||
$parent->set($field, CRM_Utils_Date::processDate($params[$field], $time));
|
||||
}
|
||||
else {
|
||||
$parent->set($field, $params[$field]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$parent->set($field, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
202
sites/all/modules/civicrm/CRM/Mailing/Form/Subscribe.php
Normal file
202
sites/all/modules/civicrm/CRM/Mailing/Form/Subscribe.php
Normal file
|
@ -0,0 +1,202 @@
|
|||
<?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_Form_Subscribe extends CRM_Core_Form {
|
||||
protected $_groupID = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$this->_groupID = CRM_Utils_Request::retrieve('gid', 'Integer', $this,
|
||||
FALSE, NULL, 'REQUEST'
|
||||
);
|
||||
|
||||
// ensure that there is a destination, if not set the destination to the
|
||||
// referrer string
|
||||
if (!$this->controller->getDestination()) {
|
||||
$this->controller->setDestination(NULL, TRUE);
|
||||
}
|
||||
|
||||
if ($this->_groupID) {
|
||||
$groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
|
||||
|
||||
// make sure requested qroup is accessible and exists
|
||||
$query = "
|
||||
SELECT title, description
|
||||
FROM civicrm_group
|
||||
WHERE id={$this->_groupID}
|
||||
AND visibility != 'User and User Admin Only'
|
||||
AND $groupTypeCondition";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
if ($dao->fetch()) {
|
||||
$this->assign('groupName', $dao->title);
|
||||
CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', array(1 => $dao->title)));
|
||||
}
|
||||
else {
|
||||
CRM_Core_Error::statusBounce("The specified group is not configured for this action OR The group doesn't exist.");
|
||||
}
|
||||
|
||||
$this->assign('single', TRUE);
|
||||
}
|
||||
else {
|
||||
$this->assign('single', FALSE);
|
||||
CRM_Utils_System::setTitle(ts('Mailing List Subscription'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add the email address
|
||||
$this->add('text',
|
||||
'email',
|
||||
ts('Email'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email',
|
||||
'email'
|
||||
),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('email', ts("Please enter a valid email address."), 'email');
|
||||
|
||||
if (!$this->_groupID) {
|
||||
// create a selector box of all public groups
|
||||
$groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
|
||||
|
||||
$query = "
|
||||
SELECT id, title, description
|
||||
FROM civicrm_group
|
||||
WHERE ( saved_search_id = 0
|
||||
OR saved_search_id IS NULL )
|
||||
AND visibility != 'User and User Admin Only'
|
||||
AND $groupTypeCondition
|
||||
ORDER BY title";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
$rows = array();
|
||||
while ($dao->fetch()) {
|
||||
$row = array();
|
||||
$row['id'] = $dao->id;
|
||||
$row['title'] = $dao->title;
|
||||
$row['description'] = $dao->description;
|
||||
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $row['id'];
|
||||
$this->addElement('checkbox',
|
||||
$row['checkbox'],
|
||||
NULL, NULL
|
||||
);
|
||||
$rows[] = $row;
|
||||
}
|
||||
if (empty($rows)) {
|
||||
CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.'));
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Subscribe', 'formRule'));
|
||||
}
|
||||
|
||||
$addCaptcha = TRUE;
|
||||
|
||||
// if recaptcha is not configured, then dont add it
|
||||
// CRM-11316 Only enable ReCAPTCHA for anonymous visitors
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$contactID = $session->get('userID');
|
||||
|
||||
if (empty($config->recaptchaPublicKey) ||
|
||||
empty($config->recaptchaPrivateKey) ||
|
||||
$contactID
|
||||
) {
|
||||
$addCaptcha = FALSE;
|
||||
}
|
||||
else {
|
||||
// If this is POST request and came from a block,
|
||||
// lets add recaptcha only if already present.
|
||||
// Gross hack for now.
|
||||
if (!empty($_POST) &&
|
||||
!array_key_exists('recaptcha_challenge_field', $_POST)
|
||||
) {
|
||||
$addCaptcha = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($addCaptcha) {
|
||||
// add captcha
|
||||
$captcha = CRM_Utils_ReCAPTCHA::singleton();
|
||||
$captcha->add($this);
|
||||
$this->assign('isCaptcha', TRUE);
|
||||
}
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Subscribe'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
foreach ($fields as $name => $dontCare) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return array('_qf_default' => 'Please select one or more mailing lists.');
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$groups = array();
|
||||
if ($this->_groupID) {
|
||||
$groups[] = $this->_groupID;
|
||||
}
|
||||
else {
|
||||
foreach ($params as $name => $dontCare) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$groups[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($groups, $params);
|
||||
}
|
||||
|
||||
}
|
153
sites/all/modules/civicrm/CRM/Mailing/Form/Task.php
Normal file
153
sites/all/modules/civicrm/CRM/Mailing/Form/Task.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for relationship
|
||||
*/
|
||||
class CRM_Mailing_Form_Task extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The task being performed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_componentClause = NULL;
|
||||
|
||||
/**
|
||||
* The array that holds all the component ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_componentIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
self::preProcessCommon($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param bool $useTable
|
||||
*/
|
||||
public static function preProcessCommon(&$form, $useTable = FALSE) {
|
||||
$values = $form->controller->exportValues($form->get('searchFormName'));
|
||||
|
||||
$form->_task = CRM_Utils_Array::value('task', $values);
|
||||
$mailingTasks = CRM_Mailing_Task::tasks();
|
||||
$form->assign('taskName', CRM_Utils_Array::value('task', $values));
|
||||
|
||||
// ids are mailing event queue ids
|
||||
$ids = array();
|
||||
if ($values['radio_ts'] == 'ts_sel') {
|
||||
foreach ($values as $name => $value) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams = $form->get('queryParams');
|
||||
$sortOrder = NULL;
|
||||
if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
|
||||
$sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
|
||||
}
|
||||
|
||||
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_MAILING
|
||||
);
|
||||
|
||||
$result = $query->searchQuery(0, 0, $sortOrder);
|
||||
while ($result->fetch()) {
|
||||
$ids[] = $result->mailing_recipients_id;
|
||||
}
|
||||
$form->assign('totalSelectedMailingRecipients', $form->get('rowCount'));
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
$form->_componentClause = ' civicrm_mailing_recipients.id IN ( ' . implode(',', $ids) . ' ) ';
|
||||
}
|
||||
|
||||
// set the context for redirection for any task actions
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$fragment = 'search';
|
||||
if ($form->_action == CRM_Core_Action::ADVANCED) {
|
||||
$fragment .= '/advanced';
|
||||
}
|
||||
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
|
||||
$urlParams = 'force=1';
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->replaceUserContext($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple shell that derived classes can call to add buttons to
|
||||
* the form with a customized title for the main Submit
|
||||
*
|
||||
* @param string $title
|
||||
* Title of the main button.
|
||||
* @param string $nextType
|
||||
* @param string $backType
|
||||
* @param bool $submitOnce
|
||||
*/
|
||||
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => $nextType,
|
||||
'name' => $title,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => $backType,
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Given the selected contacts, prepare a mailing with a hidden group.
|
||||
*/
|
||||
class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task {
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$templateTypes = CRM_Mailing_BAO_Mailing::getTemplateTypes();
|
||||
list ($groupId, $ssId) = $this->createHiddenGroup();
|
||||
$mailing = civicrm_api3('Mailing', 'create', array(
|
||||
'name' => "",
|
||||
'campaign_id' => NULL,
|
||||
'replyto_email' => "",
|
||||
'template_type' => $templateTypes[0]['name'],
|
||||
'template_options' => array('nonce' => 1),
|
||||
'subject' => "",
|
||||
'body_html' => "",
|
||||
'body_text' => "",
|
||||
'groups' => array(
|
||||
'include' => array($groupId),
|
||||
'exclude' => array(),
|
||||
'base' => array(),
|
||||
),
|
||||
'mailings' => array(
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
),
|
||||
));
|
||||
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id']));
|
||||
}
|
||||
|
||||
}
|
95
sites/all/modules/civicrm/CRM/Mailing/Form/Task/Print.php
Normal file
95
sites/all/modules/civicrm/CRM/Mailing/Form/Task/Print.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to print mailing recipient records
|
||||
*/
|
||||
class CRM_Mailing_Form_Task_Print extends CRM_Mailing_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preprocess();
|
||||
|
||||
// set print view, so that print templates are called
|
||||
$this->controller->setPrint(1);
|
||||
|
||||
// get the formatted params
|
||||
$queryParams = $this->get('queryParams');
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Mailing_Selector_Search($queryParams, $this->_action, $this->_componentClause);
|
||||
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object - it consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
//
|
||||
// just need to add a javacript to popup the window for printing
|
||||
//
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Mailing Recipients'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// redirect to the main search page after printing is over
|
||||
}
|
||||
|
||||
}
|
144
sites/all/modules/civicrm/CRM/Mailing/Form/Unsubscribe.php
Normal file
144
sites/all/modules/civicrm/CRM/Mailing/Form/Unsubscribe.php
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?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_Form_Unsubscribe extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
|
||||
$this->_type = 'unsubscribe';
|
||||
|
||||
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
|
||||
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
|
||||
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
|
||||
|
||||
if (!$job_id ||
|
||||
!$queue_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing Parameters"));
|
||||
}
|
||||
|
||||
// verify that the three numbers above match
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
CRM_Core_Error::fatal(ts("There was an error in your request"));
|
||||
}
|
||||
|
||||
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$emailMasked = CRM_Utils_String::maskEmail($email);
|
||||
$this->assign('email_masked', $emailMasked);
|
||||
$this->assign('email', $email);
|
||||
$this->_email = $email;
|
||||
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
|
||||
$this->assign('groups', $groups);
|
||||
$groupExist = NULL;
|
||||
foreach ($groups as $key => $value) {
|
||||
if ($value) {
|
||||
$groupExist = TRUE;
|
||||
}
|
||||
}
|
||||
if (!$groupExist) {
|
||||
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.',
|
||||
array(1 => $email)
|
||||
);
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
}
|
||||
$this->assign('groupExist', $groupExist);
|
||||
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
|
||||
CRM_Utils_System::setTitle(ts('Please Confirm Your Unsubscribe from this Mailing/Group'));
|
||||
|
||||
$this->add('text', 'email_confirm', ts('Verify email address to unsubscribe:'));
|
||||
$this->addRule('email_confirm', ts('Email address is required to unsubscribe.'), 'required');
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Unsubscribe'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$values = $this->exportValues();
|
||||
|
||||
// check if EmailTyped matches Email address
|
||||
$result = CRM_Utils_String::compareStr($this->_email, $values['email_confirm'], TRUE);
|
||||
$job_id = $this->_job_id;
|
||||
$queue_id = $this->_queue_id;
|
||||
$hash = $this->_hash;
|
||||
|
||||
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}", "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1");
|
||||
$this->assign('confirmURL', $confirmURL);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($confirmURL);
|
||||
|
||||
if ($result == TRUE) {
|
||||
// Email address verified
|
||||
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash);
|
||||
if (count($groups)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, $groups, FALSE, $job_id);
|
||||
}
|
||||
|
||||
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'success');
|
||||
}
|
||||
elseif ($result == FALSE) {
|
||||
// Email address not verified
|
||||
|
||||
$statusMsg = ts('The email address: %1 you have entered does not match the email associated with this unsubscribe request.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
303
sites/all/modules/civicrm/CRM/Mailing/Info.php
Normal file
303
sites/all/modules/civicrm/CRM/Mailing/Info.php
Normal file
|
@ -0,0 +1,303 @@
|
|||
<?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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class introduces component to the system and provides all the
|
||||
* information about it. It needs to extend CRM_Core_Component_Info
|
||||
* abstract class.
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Info extends CRM_Core_Component_Info {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $keyword = 'mailing';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo() {
|
||||
return array(
|
||||
'name' => 'CiviMail',
|
||||
'translatedName' => ts('CiviMail'),
|
||||
'title' => ts('CiviCRM Mailing Engine'),
|
||||
'search' => 1,
|
||||
'showActivitiesInCore' => 1,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AngularJS modules and their dependencies.
|
||||
*
|
||||
* @return array
|
||||
* list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
|
||||
* @see CRM_Utils_Hook::angularModules
|
||||
*/
|
||||
public function getAngularModules() {
|
||||
// load angular files only if valid permissions are granted to the user
|
||||
if (!CRM_Core_Permission::check('access CiviMail')
|
||||
&& !CRM_Core_Permission::check('create mailings')
|
||||
&& !CRM_Core_Permission::check('schedule mailings')
|
||||
&& !CRM_Core_Permission::check('approve mailings')
|
||||
) {
|
||||
return array();
|
||||
}
|
||||
global $civicrm_root;
|
||||
|
||||
$reportIds = array();
|
||||
$reportTypes = array('detail', 'opened', 'bounce', 'clicks');
|
||||
foreach ($reportTypes as $report) {
|
||||
$result = civicrm_api3('ReportInstance', 'get', array(
|
||||
'sequential' => 1,
|
||||
'report_id' => 'mailing/' . $report));
|
||||
if (!empty($result['values'])) {
|
||||
$reportIds[$report] = $result['values'][0]['id'];
|
||||
}
|
||||
}
|
||||
$result = array();
|
||||
$result['crmMailing'] = include "$civicrm_root/ang/crmMailing.ang.php";
|
||||
$result['crmMailingAB'] = include "$civicrm_root/ang/crmMailingAB.ang.php";
|
||||
$result['crmD3'] = include "$civicrm_root/ang/crmD3.ang.php";
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$contactID = $session->get('userID');
|
||||
|
||||
// Generic params.
|
||||
$params = array(
|
||||
'options' => array('limit' => 0),
|
||||
'sequential' => 1,
|
||||
);
|
||||
$groupNames = civicrm_api3('Group', 'get', $params + array(
|
||||
'is_active' => 1,
|
||||
'check_permissions' => TRUE,
|
||||
'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
|
||||
));
|
||||
$headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array(
|
||||
'is_active' => 1,
|
||||
'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
|
||||
));
|
||||
|
||||
$emailAdd = civicrm_api3('Email', 'get', array(
|
||||
'sequential' => 1,
|
||||
'return' => "email",
|
||||
'contact_id' => $contactID,
|
||||
));
|
||||
|
||||
$mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array(
|
||||
'sequential' => 1,
|
||||
'is_active' => 1,
|
||||
'return' => array("id", "msg_title"),
|
||||
'workflow_id' => array('IS NULL' => ""),
|
||||
));
|
||||
$mailTokens = civicrm_api3('Mailing', 'gettokens', array(
|
||||
'entity' => array('contact', 'mailing'),
|
||||
'sequential' => 1,
|
||||
));
|
||||
$fromAddress = civicrm_api3('OptionValue', 'get', $params + array(
|
||||
'option_group_id' => "from_email_address",
|
||||
'domain_id' => CRM_Core_Config::domainID(),
|
||||
));
|
||||
$enabledLanguages = CRM_Core_I18n::languages(TRUE);
|
||||
$isMultiLingual = (count($enabledLanguages) > 1);
|
||||
CRM_Core_Resources::singleton()
|
||||
->addSetting(array(
|
||||
'crmMailing' => array(
|
||||
'templateTypes' => CRM_Mailing_BAO_Mailing::getTemplateTypes(),
|
||||
'civiMails' => array(),
|
||||
'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents),
|
||||
'groupNames' => array(),
|
||||
// @todo see if we can remove this by dynamically generating the test group list
|
||||
'testGroupNames' => $groupNames['values'],
|
||||
'headerfooterList' => $headerfooterList['values'],
|
||||
'mesTemplate' => $mesTemplate['values'],
|
||||
'emailAdd' => $emailAdd['values'],
|
||||
'mailTokens' => $mailTokens['values'],
|
||||
'contactid' => $contactID,
|
||||
'requiredTokens' => CRM_Utils_Token::getRequiredTokens(),
|
||||
'enableReplyTo' => (int) Civi::settings()->get('replyTo'),
|
||||
'disableMandatoryTokensCheck' => (int) Civi::settings()->get('disable_mandatory_tokens_check'),
|
||||
'fromAddress' => $fromAddress['values'],
|
||||
'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
|
||||
'id' => 'user_contact_id',
|
||||
'return' => 'email',
|
||||
)),
|
||||
'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()),
|
||||
'workflowEnabled' => CRM_Mailing_Info::workflowEnabled(),
|
||||
'reportIds' => $reportIds,
|
||||
'enabledLanguages' => $enabledLanguages,
|
||||
'isMultiLingual' => $isMultiLingual,
|
||||
),
|
||||
))
|
||||
->addPermissions(array(
|
||||
'view all contacts',
|
||||
'edit all contacts',
|
||||
'access CiviMail',
|
||||
'create mailings',
|
||||
'schedule mailings',
|
||||
'approve mailings',
|
||||
'delete in CiviMail',
|
||||
'edit message templates',
|
||||
));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function workflowEnabled() {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
// early exit, since not true for most
|
||||
if (!$config->userSystem->is_drupal ||
|
||||
!function_exists('module_exists')
|
||||
) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!module_exists('rules')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$enableWorkflow = Civi::settings()->get('civimail_workflow');
|
||||
|
||||
return ($enableWorkflow &&
|
||||
$config->userSystem->is_drupal
|
||||
) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param bool $getAllUnconditionally
|
||||
* @param bool $descriptions
|
||||
* Whether to return permission descriptions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
|
||||
$permissions = array(
|
||||
'access CiviMail' => array(
|
||||
ts('access CiviMail'),
|
||||
),
|
||||
'access CiviMail subscribe/unsubscribe pages' => array(
|
||||
ts('access CiviMail subscribe/unsubscribe pages'),
|
||||
ts('Subscribe/unsubscribe from mailing list group'),
|
||||
),
|
||||
'delete in CiviMail' => array(
|
||||
ts('delete in CiviMail'),
|
||||
ts('Delete Mailing'),
|
||||
),
|
||||
'view public CiviMail content' => array(
|
||||
ts('view public CiviMail content'),
|
||||
),
|
||||
);
|
||||
|
||||
if (self::workflowEnabled() || $getAllUnconditionally) {
|
||||
$permissions['create mailings'] = array(
|
||||
ts('create mailings'),
|
||||
);
|
||||
$permissions['schedule mailings'] = array(
|
||||
ts('schedule mailings'),
|
||||
);
|
||||
$permissions['approve mailings'] = array(
|
||||
ts('approve mailings'),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$descriptions) {
|
||||
foreach ($permissions as $name => $attr) {
|
||||
$permissions[$name] = array_shift($attr);
|
||||
}
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return null
|
||||
*/
|
||||
public function getUserDashboardElement() {
|
||||
// no dashboard element for this component
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getUserDashboardObject() {
|
||||
// no dashboard element for this component
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function registerTab() {
|
||||
return array(
|
||||
'title' => ts('Mailings'),
|
||||
'id' => 'mailing',
|
||||
'url' => 'mailing',
|
||||
'weight' => 45,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
*/
|
||||
public function registerAdvancedSearchPane() {
|
||||
return array(
|
||||
'title' => ts('Mailings'),
|
||||
'weight' => 20,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return null
|
||||
*/
|
||||
public function getActivityTypes() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* add shortcut to Create New.
|
||||
* @param $shortCuts
|
||||
*/
|
||||
public function creatNewShortcut(&$shortCuts) {
|
||||
}
|
||||
|
||||
}
|
172
sites/all/modules/civicrm/CRM/Mailing/MailStore.php
Normal file
172
sites/all/modules/civicrm/CRM/Mailing/MailStore.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?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_MailStore {
|
||||
// flag to decide whether to print debug messages
|
||||
var $_debug = FALSE;
|
||||
|
||||
/**
|
||||
* Return the proper mail store implementation, based on config settings.
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the settings set from civimail_mail_settings to use (null for default).
|
||||
*
|
||||
* @throws Exception
|
||||
* @return object
|
||||
* mail store implementation for processing CiviMail-bound emails
|
||||
*/
|
||||
public static function getStore($name = NULL) {
|
||||
$dao = new CRM_Core_DAO_MailSettings();
|
||||
$dao->domain_id = CRM_Core_Config::domainID();
|
||||
$name ? $dao->name = $name : $dao->is_default = 1;
|
||||
if (!$dao->find(TRUE)) {
|
||||
throw new Exception("Could not find entry named $name in civicrm_mail_settings");
|
||||
}
|
||||
|
||||
$protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol');
|
||||
if (empty($protocols[$dao->protocol])) {
|
||||
throw new Exception("Empty mail protocol");
|
||||
}
|
||||
|
||||
switch ($protocols[$dao->protocol]) {
|
||||
case 'IMAP':
|
||||
return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source);
|
||||
|
||||
case 'POP3':
|
||||
return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl);
|
||||
|
||||
case 'Maildir':
|
||||
return new CRM_Mailing_MailStore_Maildir($dao->source);
|
||||
|
||||
case 'Localdir':
|
||||
return new CRM_Mailing_MailStore_Localdir($dao->source);
|
||||
|
||||
// DO NOT USE the mbox transport for anything other than testing
|
||||
// in particular, it does not clear the mbox afterwards
|
||||
|
||||
case 'mbox':
|
||||
return new CRM_Mailing_MailStore_Mbox($dao->source);
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown protocol {$dao->protocol}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all emails in the mail store.
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function allMails() {
|
||||
return $this->fetchNext(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expunge the messages marked for deletion; stub function to be redefined by IMAP store.
|
||||
*/
|
||||
public function expunge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next X messages from the mail store.
|
||||
*
|
||||
* @param int $count
|
||||
* Number of messages to fetch (0 to fetch all).
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function fetchNext($count = 1) {
|
||||
$offset = 1;
|
||||
if (isset($this->_transport->options->uidReferencing) and $this->_transport->options->uidReferencing) {
|
||||
$offset = $this->_transport->listUniqueIdentifiers();
|
||||
$offset = array_shift($offset);
|
||||
}
|
||||
try {
|
||||
$set = $this->_transport->fetchFromOffset($offset, $count);
|
||||
if ($this->_debug) {
|
||||
print "fetching $count messages\n";
|
||||
}
|
||||
}
|
||||
catch (ezcMailOffsetOutOfRangeException$e) {
|
||||
if ($this->_debug) {
|
||||
print "got to the end of the mailbox\n";
|
||||
}
|
||||
return array();
|
||||
}
|
||||
$mails = array();
|
||||
$parser = new ezcMailParser();
|
||||
//set property text attachment as file CRM-5408
|
||||
$parser->options->parseTextAttachmentsAsFiles = TRUE;
|
||||
|
||||
foreach ($set->getMessageNumbers() as $nr) {
|
||||
if ($this->_debug) {
|
||||
print "retrieving message $nr\n";
|
||||
}
|
||||
$single = $parser->parseMail($this->_transport->fetchByMessageNr($nr));
|
||||
$mails[$nr] = $single[0];
|
||||
}
|
||||
return $mails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Point to (and create if needed) a local Maildir for storing retrieved mail
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the Maildir.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return string
|
||||
* path to the Maildir's cur directory
|
||||
*/
|
||||
public function maildir($name) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$dir = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $name;
|
||||
foreach (array(
|
||||
'cur',
|
||||
'new',
|
||||
'tmp',
|
||||
) as $sub) {
|
||||
if (!file_exists($dir . DIRECTORY_SEPARATOR . $sub)) {
|
||||
if ($this->_debug) {
|
||||
print "creating $dir/$sub\n";
|
||||
}
|
||||
if (!mkdir($dir . DIRECTORY_SEPARATOR . $sub, 0700, TRUE)) {
|
||||
throw new Exception('Could not create ' . $dir . DIRECTORY_SEPARATOR . $sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dir . DIRECTORY_SEPARATOR . 'cur';
|
||||
}
|
||||
|
||||
}
|
126
sites/all/modules/civicrm/CRM/Mailing/MailStore/Imap.php
Normal file
126
sites/all/modules/civicrm/CRM/Mailing/MailStore/Imap.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?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_MailStore_Imap
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Imap extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied IMAP server and make sure the two mailboxes exist.
|
||||
*
|
||||
* @param string $host
|
||||
* Host to connect to.
|
||||
* @param string $username
|
||||
* Authentication username.
|
||||
* @param string $password
|
||||
* Authentication password.
|
||||
* @param bool $ssl
|
||||
* Whether to use IMAP or IMAPS.
|
||||
* @param string $folder
|
||||
* Name of the inbox folder.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Imap
|
||||
*/
|
||||
public function __construct($host, $username, $password, $ssl = TRUE, $folder = 'INBOX') {
|
||||
// default to INBOX if an empty string
|
||||
if (!$folder) {
|
||||
$folder = 'INBOX';
|
||||
}
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "connecting to $host, authenticating as $username and selecting $folder\n";
|
||||
|
||||
}
|
||||
|
||||
$options = array('ssl' => $ssl, 'uidReferencing' => TRUE);
|
||||
$this->_transport = new ezcMailImapTransport($host, NULL, $options);
|
||||
$this->_transport->authenticate($username, $password);
|
||||
$this->_transport->selectMailbox($folder);
|
||||
|
||||
$this->_ignored = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'ignored'));
|
||||
$this->_processed = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'processed'));
|
||||
$boxes = $this->_transport->listMailboxes();
|
||||
|
||||
if ($this->_debug) {
|
||||
print 'mailboxes found: ' . implode(', ', $boxes) . "\n";
|
||||
}
|
||||
|
||||
if (!in_array(strtolower($this->_ignored), array_map('strtolower', $boxes))) {
|
||||
$this->_transport->createMailbox($this->_ignored);
|
||||
}
|
||||
|
||||
if (!in_array(strtolower($this->_processed), array_map('strtolower', $boxes))) {
|
||||
$this->_transport->createMailbox($this->_processed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expunge the messages marked for deletion, CRM-7356
|
||||
*/
|
||||
public function expunge() {
|
||||
$this->_transport->expunge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the specified message to the ignored folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to move.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "setting $nr as seen and moving it to the ignored mailbox\n";
|
||||
}
|
||||
$this->_transport->setFlag($nr, 'SEEN');
|
||||
$this->_transport->copyMessages($nr, $this->_ignored);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the specified message to the processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to move.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "setting $nr as seen and moving it to the processed mailbox\n";
|
||||
}
|
||||
$this->_transport->setFlag($nr, 'SEEN');
|
||||
$this->_transport->copyMessages($nr, $this->_processed);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
}
|
158
sites/all/modules/civicrm/CRM/Mailing/MailStore/Localdir.php
Normal file
158
sites/all/modules/civicrm/CRM/Mailing/MailStore/Localdir.php
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?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_MailStore_Localdir
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied dir and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $dir
|
||||
* Dir to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Localdir
|
||||
*/
|
||||
public function __construct($dir) {
|
||||
$this->_dir = $dir;
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next X messages from the mail store.
|
||||
* FIXME: in CiviCRM 2.2 this always returns all the emails
|
||||
*
|
||||
* @param int $count
|
||||
* Number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all).
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function fetchNext($count = 0) {
|
||||
$mails = array();
|
||||
$path = rtrim($this->_dir, DIRECTORY_SEPARATOR);
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "fetching $count messages\n";
|
||||
|
||||
}
|
||||
|
||||
$directory = new DirectoryIterator($path);
|
||||
foreach ($directory as $entry) {
|
||||
if ($entry->isDot()) {
|
||||
continue;
|
||||
}
|
||||
if (count($mails) >= $count) {
|
||||
break;
|
||||
}
|
||||
|
||||
$file = $path . DIRECTORY_SEPARATOR . $entry->getFilename();
|
||||
if ($this->_debug) {
|
||||
print "retrieving message $file\n";
|
||||
}
|
||||
|
||||
$set = new ezcMailFileSet(array($file));
|
||||
$parser = new ezcMailParser();
|
||||
// set property text attachment as file CRM-5408
|
||||
$parser->options->parseTextAttachmentsAsFiles = TRUE;
|
||||
|
||||
$mail = $parser->parseMail($set);
|
||||
|
||||
if (!$mail) {
|
||||
return CRM_Core_Error::createAPIError(ts('%1 could not be parsed',
|
||||
array(1 => $file)
|
||||
));
|
||||
}
|
||||
$mails[$file] = $mail[0];
|
||||
}
|
||||
|
||||
if ($this->_debug && (count($mails) <= 0)) {
|
||||
|
||||
print "No messages found\n";
|
||||
|
||||
}
|
||||
|
||||
return $mails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markIgnored($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to ignored folder\n";
|
||||
}
|
||||
$target = $this->_ignored . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markProcessed($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to processed folder\n";
|
||||
}
|
||||
$target = $this->_processed . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
141
sites/all/modules/civicrm/CRM/Mailing/MailStore/Maildir.php
Normal file
141
sites/all/modules/civicrm/CRM/Mailing/MailStore/Maildir.php
Normal file
|
@ -0,0 +1,141 @@
|
|||
<?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_MailStore_Maildir
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Maildir extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied dir and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $dir
|
||||
* Dir to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Maildir
|
||||
*/
|
||||
public function __construct($dir) {
|
||||
$this->_dir = $dir;
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next X messages from the mail store.
|
||||
* FIXME: in CiviCRM 2.2 this always returns all the emails
|
||||
*
|
||||
* @param int $count
|
||||
* Number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all).
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function fetchNext($count = 0) {
|
||||
$mails = array();
|
||||
$parser = new ezcMailParser();
|
||||
// set property text attachment as file CRM-5408
|
||||
$parser->options->parseTextAttachmentsAsFiles = TRUE;
|
||||
|
||||
foreach (array(
|
||||
'cur',
|
||||
'new',
|
||||
) as $subdir) {
|
||||
$dir = $this->_dir . DIRECTORY_SEPARATOR . $subdir;
|
||||
foreach (scandir($dir) as $file) {
|
||||
if ($file == '.' or $file == '..') {
|
||||
continue;
|
||||
}
|
||||
$path = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "retrieving message $path\n";
|
||||
|
||||
}
|
||||
|
||||
$set = new ezcMailFileSet(array($path));
|
||||
$single = $parser->parseMail($set);
|
||||
$mails[$path] = $single[0];
|
||||
}
|
||||
}
|
||||
return $mails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markIgnored($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to ignored folder\n";
|
||||
}
|
||||
$target = $this->_ignored . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markProcessed($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to processed folder\n";
|
||||
}
|
||||
$target = $this->_processed . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
113
sites/all/modules/civicrm/CRM/Mailing/MailStore/Mbox.php
Normal file
113
sites/all/modules/civicrm/CRM/Mailing/MailStore/Mbox.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?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_MailStore_Mbox
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Mbox extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to and lock the supplied file and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $file
|
||||
* Mbox to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Mbox
|
||||
*/
|
||||
public function __construct($file) {
|
||||
$this->_transport = new ezcMailMboxTransport($file);
|
||||
flock($this->_transport->fh, LOCK_EX);
|
||||
|
||||
$this->_leftToProcess = count($this->_transport->listMessages());
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the mail source (if it was processed fully) and unlock the file.
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->_leftToProcess === 0) {
|
||||
// FIXME: the ftruncate() call does not work for some reason
|
||||
if ($this->_debug) {
|
||||
print "trying to delete the mailbox\n";
|
||||
}
|
||||
ftruncate($this->_transport->fh, 0);
|
||||
}
|
||||
flock($this->_transport->fh, LOCK_UN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "copying message $nr to ignored folder\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_leftToProcess--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "copying message $nr to processed folder\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_leftToProcess--;
|
||||
}
|
||||
|
||||
}
|
108
sites/all/modules/civicrm/CRM/Mailing/MailStore/Pop3.php
Normal file
108
sites/all/modules/civicrm/CRM/Mailing/MailStore/Pop3.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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_MailStore_Pop3
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied POP3 server and make sure the two mail dirs exist
|
||||
*
|
||||
* @param string $host
|
||||
* Host to connect to.
|
||||
* @param string $username
|
||||
* Authentication username.
|
||||
* @param string $password
|
||||
* Authentication password.
|
||||
* @param bool $ssl
|
||||
* Whether to use POP3 or POP3S.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Pop3
|
||||
*/
|
||||
public function __construct($host, $username, $password, $ssl = TRUE) {
|
||||
if ($this->_debug) {
|
||||
print "connecting to $host and authenticating as $username\n";
|
||||
}
|
||||
|
||||
$options = array('ssl' => $ssl);
|
||||
$this->_transport = new ezcMailPop3Transport($host, NULL, $options);
|
||||
$this->_transport->authenticate($username, $password);
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "fetching message $nr and putting it in the ignored mailbox\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "fetching message $nr and putting it in the processed mailbox\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
}
|
78
sites/all/modules/civicrm/CRM/Mailing/Page/AJAX.php
Normal file
78
sites/all/modules/civicrm/CRM/Mailing/Page/AJAX.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains all the function that are called using AJAX
|
||||
*/
|
||||
class CRM_Mailing_Page_AJAX {
|
||||
|
||||
/**
|
||||
* Fetch the template text/html messages
|
||||
*/
|
||||
public static function template() {
|
||||
$templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer');
|
||||
|
||||
$messageTemplate = new CRM_Core_DAO_MessageTemplate();
|
||||
$messageTemplate->id = $templateId;
|
||||
$messageTemplate->selectAdd();
|
||||
$messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id');
|
||||
$messageTemplate->find(TRUE);
|
||||
$messages = array(
|
||||
'subject' => $messageTemplate->msg_subject,
|
||||
'msg_text' => $messageTemplate->msg_text,
|
||||
'msg_html' => $messageTemplate->msg_html,
|
||||
'pdf_format_id' => $messageTemplate->pdf_format_id,
|
||||
);
|
||||
|
||||
$documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId);
|
||||
foreach ((array) $documentInfo as $info) {
|
||||
list($messages['document_body']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
|
||||
}
|
||||
|
||||
CRM_Utils_JSON::output($messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve contact mailings.
|
||||
*/
|
||||
public static function getContactMailings() {
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
$params += CRM_Core_Page_AJAX::validateParams(array('contact_id' => 'Integer'));
|
||||
|
||||
// get the contact mailings
|
||||
$mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
|
||||
|
||||
CRM_Utils_JSON::output($mailings);
|
||||
}
|
||||
|
||||
}
|
339
sites/all/modules/civicrm/CRM/Mailing/Page/Browse.php
Normal file
339
sites/all/modules/civicrm/CRM/Mailing/Page/Browse.php
Normal file
|
@ -0,0 +1,339 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This implements the profile page for all contacts. It uses a selector
|
||||
* object to do the actual dispay. The fields displayd are controlled by
|
||||
* the admin
|
||||
*/
|
||||
class CRM_Mailing_Page_Browse extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* All the fields that are listings related.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_fields;
|
||||
|
||||
/**
|
||||
* The mailing id of the mailing we're operating on
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_mailingId;
|
||||
|
||||
/**
|
||||
* The action that we are performing (in CRM_Core_Action terms)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_action;
|
||||
|
||||
public $_sortByCharacter;
|
||||
|
||||
public $_unscheduled;
|
||||
public $_archived;
|
||||
|
||||
/**
|
||||
* Scheduled mailing.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_scheduled;
|
||||
|
||||
public $_sms;
|
||||
|
||||
/**
|
||||
* Heart of the viewing process. The runner gets all the meta data for
|
||||
* the contact and calls the appropriate type of page to view.
|
||||
*/
|
||||
public function preProcess() {
|
||||
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
|
||||
|
||||
$this->_unscheduled = $this->_archived = $archiveLinks = FALSE;
|
||||
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
|
||||
$this->_sms = CRM_Utils_Request::retrieve('sms', 'Positive', $this);
|
||||
$this->assign('sms', $this->_sms);
|
||||
// check that the user has permission to access mailing id
|
||||
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingId);
|
||||
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
$showLinks = TRUE;
|
||||
if (CRM_Mailing_Info::workflowEnabled()) {
|
||||
if (CRM_Core_Permission::check('create mailings')) {
|
||||
$archiveLinks = TRUE;
|
||||
}
|
||||
if (!CRM_Core_Permission::check('access CiviMail') &&
|
||||
!CRM_Core_Permission::check('create mailings')
|
||||
) {
|
||||
$showLinks = FALSE;
|
||||
}
|
||||
}
|
||||
$this->assign('showLinks', $showLinks);
|
||||
if (CRM_Core_Permission::check('access CiviMail')) {
|
||||
$archiveLinks = TRUE;
|
||||
}
|
||||
if ($archiveLinks == TRUE) {
|
||||
$this->assign('archiveLinks', $archiveLinks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
|
||||
$newArgs = func_get_args();
|
||||
// since we want only first function argument
|
||||
$newArgs = $newArgs[0];
|
||||
if (isset($_GET['runJobs']) || CRM_Utils_Array::value('2', $newArgs) == 'queue') {
|
||||
$mailerJobSize = Civi::settings()->get('mailerJobSize');
|
||||
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize);
|
||||
CRM_Mailing_BAO_MailingJob::runJobs();
|
||||
CRM_Mailing_BAO_MailingJob::runJobs_post();
|
||||
}
|
||||
|
||||
$this->_sortByCharacter
|
||||
= CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
|
||||
|
||||
// CRM-11920 all should set sortByCharacter to null, not empty string
|
||||
if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) {
|
||||
$this->_sortByCharacter = NULL;
|
||||
$this->set('sortByCharacter', NULL);
|
||||
}
|
||||
|
||||
if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
|
||||
$this->_unscheduled = TRUE;
|
||||
}
|
||||
$this->set('unscheduled', $this->_unscheduled);
|
||||
|
||||
if (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
|
||||
$this->_archived = TRUE;
|
||||
}
|
||||
$this->set('archived', $this->_archived);
|
||||
|
||||
if (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
|
||||
$this->_scheduled = TRUE;
|
||||
}
|
||||
$this->set('scheduled', $this->_scheduled);
|
||||
|
||||
$this->_createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
|
||||
if ($this->_createdId) {
|
||||
$this->set('createdId', $this->_createdId);
|
||||
}
|
||||
|
||||
if ($this->_sms) {
|
||||
$this->set('sms', $this->_sms);
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$context = $session->readUserContext();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DISABLE) {
|
||||
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
|
||||
CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
|
||||
CRM_Utils_System::redirect($context);
|
||||
}
|
||||
else {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse',
|
||||
ts('Cancel Mailing'),
|
||||
$this->_action
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::DELETE) {
|
||||
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
|
||||
|
||||
// check for action permissions.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::del($this->_mailingId);
|
||||
CRM_Utils_System::redirect($context);
|
||||
}
|
||||
else {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse',
|
||||
ts('Delete Mailing'),
|
||||
$this->_action
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::RENEW) {
|
||||
// archive this mailing, CRM-3752.
|
||||
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
|
||||
// set is_archived to 1
|
||||
CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
|
||||
CRM_Utils_System::redirect($context);
|
||||
}
|
||||
else {
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse',
|
||||
ts('Archive Mailing'),
|
||||
$this->_action
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
}
|
||||
|
||||
$selector = new CRM_Mailing_Selector_Browse();
|
||||
$selector->setParent($this);
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller(
|
||||
$selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_ID) . $this->get(CRM_Utils_Sort::SORT_DIRECTION),
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::TEMPLATE
|
||||
);
|
||||
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
|
||||
// hack to display results as per search
|
||||
$rows = $controller->getRows($controller);
|
||||
|
||||
$this->assign('rows', $rows);
|
||||
|
||||
$urlParams = 'reset=1';
|
||||
$urlString = 'civicrm/mailing/browse';
|
||||
if ($this->get('sms')) {
|
||||
$urlParams .= '&sms=1';
|
||||
}
|
||||
if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
|
||||
$urlString .= '/unscheduled';
|
||||
$urlParams .= '&scheduled=false';
|
||||
$this->assign('unscheduled', TRUE);
|
||||
}
|
||||
elseif (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
|
||||
$urlString .= '/archived';
|
||||
$this->assign('archived', TRUE);
|
||||
}
|
||||
elseif (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
|
||||
$urlString .= '/scheduled';
|
||||
$urlParams .= '&scheduled=true';
|
||||
}
|
||||
if ($this->get('sms')) {
|
||||
CRM_Utils_System::setTitle(ts('Find Mass SMS'));
|
||||
}
|
||||
|
||||
$crmRowCount = CRM_Utils_Request::retrieve('crmRowCount', 'Integer');
|
||||
$crmPID = CRM_Utils_Request::retrieve('crmPID', 'Integer');
|
||||
if ($crmRowCount || $crmPID) {
|
||||
$urlParams .= '&force=1';
|
||||
$urlParams .= $crmRowCount ? '&crmRowCount=' . $crmRowCount : '';
|
||||
$urlParams .= $crmPID ? '&crmPID=' . $crmPID : '';
|
||||
}
|
||||
|
||||
$crmSID = CRM_Utils_Request::retrieve('crmSID', 'Integer');
|
||||
if ($crmSID) {
|
||||
$urlParams .= '&crmSID=' . $crmSID;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$url = CRM_Utils_System::url($urlString, $urlParams);
|
||||
$session->pushUserContext($url);
|
||||
|
||||
// CRM-6862 -run form cotroller after
|
||||
// selector, since it erase $_POST
|
||||
$this->search();
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
public function search() {
|
||||
if ($this->_action & (CRM_Core_Action::ADD |
|
||||
CRM_Core_Action::UPDATE
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Search',
|
||||
ts('Search Mailings'),
|
||||
CRM_Core_Action::ADD
|
||||
);
|
||||
$form->setEmbedded(TRUE);
|
||||
$form->setParent($this);
|
||||
$form->process();
|
||||
$form->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param bool $sortBy
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function whereClause(&$params, $sortBy = TRUE) {
|
||||
$values = array();
|
||||
|
||||
$clauses = array();
|
||||
$title = $this->get('mailing_name');
|
||||
// echo " name=$title ";
|
||||
if ($title) {
|
||||
$clauses[] = 'name LIKE %1';
|
||||
if (strpos($title, '%') !== FALSE) {
|
||||
$params[1] = array($title, 'String', FALSE);
|
||||
}
|
||||
else {
|
||||
$params[1] = array($title, 'String', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if ($sortBy &&
|
||||
$this->_sortByCharacter !== NULL
|
||||
) {
|
||||
$clauses[] = "name LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
|
||||
}
|
||||
|
||||
$campainIds = $this->get('campaign_id');
|
||||
if (!CRM_Utils_System::isNull($campainIds)) {
|
||||
if (!is_array($campainIds)) {
|
||||
$campaignIds = array($campaignIds);
|
||||
}
|
||||
$clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )';
|
||||
}
|
||||
|
||||
return implode(' AND ', $clauses);
|
||||
}
|
||||
|
||||
}
|
130
sites/all/modules/civicrm/CRM/Mailing/Page/Common.php
Normal file
130
sites/all/modules/civicrm/CRM/Mailing/Page/Common.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?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_Page_Common extends CRM_Core_Page {
|
||||
protected $_type = NULL;
|
||||
|
||||
/**
|
||||
* Run page.
|
||||
*
|
||||
* This includes assigning smarty variables and other page processing.
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run() {
|
||||
$job_id = CRM_Utils_Request::retrieve('jid', 'Integer');
|
||||
$queue_id = CRM_Utils_Request::retrieve('qid', 'Integer');
|
||||
$hash = CRM_Utils_Request::retrieve('h', 'String');
|
||||
|
||||
if (!$job_id ||
|
||||
!$queue_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing input parameters"));
|
||||
}
|
||||
|
||||
// verify that the three numbers above match
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
CRM_Core_Error::fatal(ts("There was an error in your request"));
|
||||
}
|
||||
|
||||
$cancel = CRM_Utils_Request::retrieve("_qf_{$this->_type}_cancel", 'String', CRM_Core_DAO::$_nullObject,
|
||||
FALSE, NULL, $_REQUEST
|
||||
);
|
||||
if ($cancel) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
CRM_Utils_System::redirect($config->userFrameworkBaseURL);
|
||||
}
|
||||
|
||||
$confirm = CRM_Utils_Request::retrieve('confirm', 'Boolean', CRM_Core_DAO::$_nullObject,
|
||||
FALSE, NULL, $_REQUEST
|
||||
);
|
||||
|
||||
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$this->assign('email', $email);
|
||||
$this->assign('confirm', $confirm);
|
||||
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
|
||||
$this->assign('groups', $groups);
|
||||
$groupExist = NULL;
|
||||
foreach ($groups as $key => $value) {
|
||||
if ($value) {
|
||||
$groupExist = TRUE;
|
||||
}
|
||||
}
|
||||
$this->assign('groupExist', $groupExist);
|
||||
|
||||
if ($confirm) {
|
||||
if ($this->_type == 'unsubscribe') {
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash);
|
||||
if (count($groups)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, $groups, FALSE, $job_id);
|
||||
}
|
||||
else {
|
||||
// should we indicate an error, or just ignore?
|
||||
}
|
||||
}
|
||||
elseif ($this->_type == 'resubscribe') {
|
||||
$groups = CRM_Mailing_Event_BAO_Resubscribe::resub_to_mailing($job_id, $queue_id, $hash);
|
||||
if (count($groups)) {
|
||||
CRM_Mailing_Event_BAO_Resubscribe::send_resub_response($queue_id, $groups, FALSE, $job_id);
|
||||
}
|
||||
else {
|
||||
// should we indicate an error, or just ignore?
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_domain($job_id, $queue_id, $hash)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, NULL, TRUE, $job_id);
|
||||
}
|
||||
else {
|
||||
// should we indicate an error, or just ignore?
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}",
|
||||
"reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1"
|
||||
);
|
||||
$this->assign('confirmURL', $confirmURL);
|
||||
// push context for further process CRM-4431
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($confirmURL);
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
128
sites/all/modules/civicrm/CRM/Mailing/Page/Component.php
Normal file
128
sites/all/modules/civicrm/CRM/Mailing/Page/Component.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page to display / edit the header / footer of a mailing
|
||||
*
|
||||
*/
|
||||
class CRM_Mailing_Page_Component extends CRM_Core_Page_Basic {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Mailing_BAO_Component';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => CRM_Utils_System::currentPath(),
|
||||
'qs' => 'action=update&id=%%id%%',
|
||||
'title' => ts('Edit Mailing Component'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable Mailing Component'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable Mailing Component'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_Mailing_Form_Component';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'Mailing Components';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return CRM_Utils_System::currentPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $args
|
||||
* @param null $pageArgs
|
||||
* @param null $sort
|
||||
*/
|
||||
public function run($args = NULL, $pageArgs = NULL, $sort = NULL) {
|
||||
return parent::run($args, $pageArgs, "component_type, is_default desc, name");
|
||||
}
|
||||
|
||||
}
|
68
sites/all/modules/civicrm/CRM/Mailing/Page/Confirm.php
Normal file
68
sites/all/modules/civicrm/CRM/Mailing/Page/Confirm.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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_Page_Confirm extends CRM_Core_Page {
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run() {
|
||||
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
|
||||
|
||||
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer');
|
||||
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer');
|
||||
$hash = CRM_Utils_Request::retrieve('h', 'String');
|
||||
|
||||
if (!$contact_id ||
|
||||
!$subscribe_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing input parameters"));
|
||||
}
|
||||
|
||||
$result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash);
|
||||
if ($result === FALSE) {
|
||||
$this->assign('success', $result);
|
||||
}
|
||||
else {
|
||||
$this->assign('success', TRUE);
|
||||
$this->assign('group', $result);
|
||||
}
|
||||
|
||||
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$this->assign('email', $email);
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
120
sites/all/modules/civicrm/CRM/Mailing/Page/Event.php
Normal file
120
sites/all/modules/civicrm/CRM/Mailing/Page/Event.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This implements the profile page for all contacts.
|
||||
*
|
||||
* It uses a selector object to do the actual display. The fields displayed are controlled by
|
||||
* the admin
|
||||
*/
|
||||
class CRM_Mailing_Page_Event extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* All the fields that are listings related.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_fields;
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
$selector = new CRM_Mailing_Selector_Event(
|
||||
CRM_Utils_Request::retrieve('event', 'String', $this),
|
||||
CRM_Utils_Request::retrieve('distinct', 'Boolean', $this),
|
||||
CRM_Utils_Request::retrieve('mid', 'Positive', $this),
|
||||
CRM_Utils_Request::retrieve('jid', 'Positive', $this),
|
||||
CRM_Utils_Request::retrieve('uid', 'Positive', $this)
|
||||
);
|
||||
|
||||
$mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
|
||||
|
||||
// check that the user has permission to access mailing id
|
||||
CRM_Mailing_BAO_Mailing::checkPermission($mailing_id);
|
||||
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
|
||||
if ($context == 'activitySelector') {
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
|
||||
$backUrlTitle = ts('Back to Activities');
|
||||
}
|
||||
elseif ($context == 'mailing') {
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
|
||||
$backUrlTitle = ts('Back to Mailing');
|
||||
}
|
||||
elseif ($context == 'angPage') {
|
||||
$angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this);
|
||||
if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) {
|
||||
CRM_Core_Error::fatal('Malformed return URL');
|
||||
}
|
||||
$backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage);
|
||||
$backUrlTitle = ts('Back to Report');
|
||||
}
|
||||
else {
|
||||
$backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}");
|
||||
$backUrlTitle = ts('Back to Report');
|
||||
}
|
||||
|
||||
$this->assign('backUrl', $backUrl);
|
||||
$this->assign('backUrlTitle', $backUrlTitle);
|
||||
|
||||
CRM_Utils_System::setTitle($selector->getTitle());
|
||||
$this->assign('title', $selector->getTitle());
|
||||
$this->assign('mailing_id', $mailing_id);
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller(
|
||||
$selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::TEMPLATE
|
||||
);
|
||||
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
47
sites/all/modules/civicrm/CRM/Mailing/Page/Optout.php
Normal file
47
sites/all/modules/civicrm/CRM/Mailing/Page/Optout.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?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_Page_Optout extends CRM_Mailing_Page_Common {
|
||||
/**
|
||||
* Run page.
|
||||
*
|
||||
* This includes assigning smarty variables and other page processing.
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run() {
|
||||
$this->_type = 'optout';
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
101
sites/all/modules/civicrm/CRM/Mailing/Page/Preview.php
Normal file
101
sites/all/modules/civicrm/CRM/Mailing/Page/Preview.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* a page for mailing preview
|
||||
*/
|
||||
class CRM_Mailing_Page_Preview extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
|
||||
$type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
|
||||
|
||||
$options = array();
|
||||
$session->getVars($options, "CRM_Mailing_Controller_Send_$qfKey");
|
||||
|
||||
// get the options if control come from search context, CRM-3711
|
||||
if (empty($options)) {
|
||||
$session->getVars($options, "CRM_Contact_Controller_Search_$qfKey");
|
||||
}
|
||||
|
||||
// FIXME: the below and CRM_Mailing_Form_Test::testMail()
|
||||
// should be refactored
|
||||
$fromEmail = NULL;
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
if (!empty($options)) {
|
||||
$mailing->id = $options['mailing_id'];
|
||||
$fromEmail = CRM_Utils_Array::value('from_email', $options);
|
||||
}
|
||||
|
||||
$mailing->find(TRUE);
|
||||
|
||||
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
|
||||
|
||||
// get and format attachments
|
||||
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
|
||||
$mailing->id
|
||||
);
|
||||
|
||||
// get details of contact with token value including Custom Field Token Values.CRM-3734
|
||||
$returnProperties = $mailing->getReturnProperties();
|
||||
$params = array('contact_id' => $session->get('userID'));
|
||||
|
||||
$details = CRM_Utils_Token::getTokenDetails($params,
|
||||
$returnProperties,
|
||||
TRUE, TRUE, NULL,
|
||||
$mailing->getFlattenedTokens(),
|
||||
get_class($this)
|
||||
);
|
||||
|
||||
$mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
|
||||
TRUE, $details[0][$session->get('userID')], $attachments
|
||||
);
|
||||
|
||||
if ($type == 'html') {
|
||||
CRM_Utils_System::setHttpHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
print $mime->getHTMLBody();
|
||||
}
|
||||
else {
|
||||
CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
print $mime->getTXTBody();
|
||||
}
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
|
||||
}
|
149
sites/all/modules/civicrm/CRM/Mailing/Page/Report.php
Normal file
149
sites/all/modules/civicrm/CRM/Mailing/Page/Report.php
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page to display / edit the header / footer of a mailing.
|
||||
*/
|
||||
class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
|
||||
public $_mailing_id;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Mailing_BAO_Mailing';
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of action links.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function &links() {
|
||||
return CRM_Core_DAO::$_nullObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function editForm() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function editName() {
|
||||
return 'CiviMail Report';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/mailing/report';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function userContextParams($mode = NULL) {
|
||||
return 'reset=1&mid=' . $this->_mailing_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function run() {
|
||||
$this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
|
||||
//CRM-15979 - check if abtest exist for mailing then redirect accordingly
|
||||
$abtest = CRM_Mailing_BAO_MailingAB::getABTest($this->_mailing_id);
|
||||
if (!empty($abtest) && !empty($abtest->id)) {
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id));
|
||||
}
|
||||
// check that the user has permission to access mailing id
|
||||
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id);
|
||||
|
||||
$report = CRM_Mailing_BAO_Mailing::report($this->_mailing_id);
|
||||
|
||||
// get contents of mailing
|
||||
CRM_Mailing_BAO_Mailing::getMailingContent($report, $this);
|
||||
|
||||
// assign backurl
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
if ($context == 'activitySelector') {
|
||||
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
|
||||
$backUrlTitle = ts('Back to Activities');
|
||||
}
|
||||
elseif ($context == 'activity') {
|
||||
$atype = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
|
||||
$aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this);
|
||||
|
||||
$backUrl = CRM_Utils_System::url('civicrm/activity/view',
|
||||
"atype={$atype}&action=view&reset=1&id={$aid}&cid={$cid}&context=activity"
|
||||
);
|
||||
$backUrlTitle = ts('Back to Activity');
|
||||
}
|
||||
elseif ($context == 'mailing') {
|
||||
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
|
||||
$backUrlTitle = ts('Back to Mailing');
|
||||
}
|
||||
else {
|
||||
$backUrl = CRM_Utils_System::url('civicrm/mailing', 'reset=1');
|
||||
$backUrlTitle = ts('Back to CiviMail');
|
||||
}
|
||||
$this->assign('backUrl', $backUrl);
|
||||
$this->assign('backUrlTitle', $backUrlTitle);
|
||||
|
||||
$this->assign('report', $report);
|
||||
CRM_Utils_System::setTitle(ts('CiviMail Report: %1',
|
||||
array(1 => $report['mailing']['name'])
|
||||
));
|
||||
$this->assign('public_url', CRM_Mailing_BAO_Mailing::getPublicViewUrl($this->_mailing_id));
|
||||
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
}
|
42
sites/all/modules/civicrm/CRM/Mailing/Page/Resubscribe.php
Normal file
42
sites/all/modules/civicrm/CRM/Mailing/Page/Resubscribe.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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_Page_Resubscribe extends CRM_Mailing_Page_Common {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function run() {
|
||||
$this->_type = 'resubscribe';
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
83
sites/all/modules/civicrm/CRM/Mailing/Page/Tab.php
Normal file
83
sites/all/modules/civicrm/CRM/Mailing/Page/Tab.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handle mailing and contact related functions
|
||||
*/
|
||||
class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View {
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
public $_permission = NULL;
|
||||
public $_contactId = NULL;
|
||||
|
||||
/**
|
||||
* Called when action is browse.
|
||||
*/
|
||||
public function browse() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
|
||||
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
|
||||
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
|
||||
|
||||
$this->assign('contactId', $this->_contactId);
|
||||
$this->assign('displayName', $displayName);
|
||||
|
||||
// Check logged in url permission.
|
||||
CRM_Contact_Page_View::checkUserPermission($this);
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Mailings sent to %1', array(1 => $displayName)));
|
||||
}
|
||||
|
||||
/**
|
||||
* The main function that is called when the page loads.
|
||||
*
|
||||
* It decides the which action has to be taken for the page.
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
$this->browse();
|
||||
parent::run();
|
||||
}
|
||||
|
||||
}
|
48
sites/all/modules/civicrm/CRM/Mailing/Page/Unsubscribe.php
Normal file
48
sites/all/modules/civicrm/CRM/Mailing/Page/Unsubscribe.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?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_Page_Unsubscribe extends CRM_Mailing_Page_Common {
|
||||
|
||||
/**
|
||||
* Run page.
|
||||
*
|
||||
* This includes assigning smarty variables and other page processing.
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run() {
|
||||
$this->_type = 'unsubscribe';
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
203
sites/all/modules/civicrm/CRM/Mailing/Page/View.php
Normal file
203
sites/all/modules/civicrm/CRM/Mailing/Page/View.php
Normal file
|
@ -0,0 +1,203 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* A page for mailing preview.
|
||||
*/
|
||||
class CRM_Mailing_Page_View extends CRM_Core_Page {
|
||||
protected $_mailingID;
|
||||
protected $_mailing;
|
||||
protected $_contactID;
|
||||
|
||||
/**
|
||||
* Lets do permission checking here.
|
||||
* First check for valid mailing, if false return fatal.
|
||||
* Second check for visibility.
|
||||
* Call a hook to see if hook wants to override visibility setting.
|
||||
*/
|
||||
public function checkPermission() {
|
||||
if (!$this->_mailing) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// check for visibility, if visibility is Public Pages and they have the permission
|
||||
// return true
|
||||
if ($this->_mailing->visibility == 'Public Pages' &&
|
||||
CRM_Core_Permission::check('view public CiviMail content')
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// if user is an admin, return true
|
||||
if (CRM_Core_Permission::check('administer CiviCRM') ||
|
||||
CRM_Core_Permission::check('approve mailings') ||
|
||||
CRM_Core_Permission::check('access CiviMail')
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $contactID
|
||||
* @param bool $print
|
||||
* @param bool $allowID
|
||||
*
|
||||
* @return null|string
|
||||
* Not really sure if anything should be returned - parent doesn't
|
||||
*/
|
||||
public function run($id = NULL, $contactID = NULL, $print = TRUE, $allowID = FALSE) {
|
||||
if (is_numeric($id)) {
|
||||
$this->_mailingID = $id;
|
||||
}
|
||||
else {
|
||||
$print = TRUE;
|
||||
$this->_mailingID = CRM_Utils_Request::retrieve('id', 'String', CRM_Core_DAO::$_nullObject, TRUE);
|
||||
}
|
||||
|
||||
// # CRM-7651
|
||||
// override contactID from the function level if passed in
|
||||
if (isset($contactID) &&
|
||||
is_numeric($contactID)
|
||||
) {
|
||||
$this->_contactID = $contactID;
|
||||
}
|
||||
else {
|
||||
$this->_contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
|
||||
// mailing key check
|
||||
if (Civi::settings()->get('hash_mailing_url')) {
|
||||
$this->_mailing = new CRM_Mailing_BAO_Mailing();
|
||||
|
||||
if (!is_numeric($this->_mailingID)) {
|
||||
$this->_mailing->hash = $this->_mailingID;
|
||||
}
|
||||
elseif (is_numeric($this->_mailingID)) {
|
||||
$this->_mailing->id = $this->_mailingID;
|
||||
// if mailing is present and associated hash is present
|
||||
// while 'hash' is not been used for mailing view : throw 'permissionDenied'
|
||||
if ($this->_mailing->find() &&
|
||||
CRM_Core_DAO::getFieldValue('CRM_Mailing_BAO_Mailing', $this->_mailingID, 'hash', 'id') &&
|
||||
!$allowID
|
||||
) {
|
||||
CRM_Utils_System::permissionDenied();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$this->_mailing->id = $this->_mailingID;
|
||||
}
|
||||
|
||||
if (!$this->_mailing->find(TRUE) ||
|
||||
!$this->checkPermission()
|
||||
) {
|
||||
CRM_Utils_System::permissionDenied();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::tokenReplace($this->_mailing);
|
||||
|
||||
// get and format attachments
|
||||
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
|
||||
$this->_mailing->id
|
||||
);
|
||||
|
||||
// get contact detail and compose if contact id exists
|
||||
$returnProperties = $this->_mailing->getReturnProperties();
|
||||
if (isset($this->_contactID)) {
|
||||
// get details of contact with token value including Custom Field Token Values.CRM-3734
|
||||
$params = array('contact_id' => $this->_contactID);
|
||||
$details = CRM_Utils_Token::getTokenDetails($params,
|
||||
$returnProperties,
|
||||
FALSE, TRUE, NULL,
|
||||
$this->_mailing->getFlattenedTokens(),
|
||||
get_class($this)
|
||||
);
|
||||
$details = $details[0][$this->_contactID];
|
||||
$contactId = $this->_contactID;
|
||||
}
|
||||
else {
|
||||
// get tokens that are not contact specific resolved
|
||||
$params = array('contact_id' => 0);
|
||||
$details = CRM_Utils_Token::getAnonymousTokenDetails($params,
|
||||
$returnProperties,
|
||||
TRUE, TRUE, NULL,
|
||||
$this->_mailing->getFlattenedTokens(),
|
||||
get_class($this)
|
||||
);
|
||||
|
||||
$details = CRM_Utils_Array::value(0, $details[0]);
|
||||
$contactId = 0;
|
||||
}
|
||||
$mime = $this->_mailing->compose(NULL, NULL, NULL, $contactId,
|
||||
$this->_mailing->from_email,
|
||||
$this->_mailing->from_email,
|
||||
TRUE, $details, $attachments
|
||||
);
|
||||
|
||||
$title = NULL;
|
||||
if (isset($this->_mailing->body_html) && empty($_GET['text'])) {
|
||||
$header = 'text/html; charset=utf-8';
|
||||
$content = $mime->getHTMLBody();
|
||||
if (strpos($content, '<head>') === FALSE && strpos($content, '<title>') === FALSE) {
|
||||
$title = '<head><title>' . $this->_mailing->subject . '</title></head>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$header = 'text/plain; charset=utf-8';
|
||||
$content = $mime->getTXTBody();
|
||||
}
|
||||
CRM_Utils_System::setTitle($this->_mailing->subject);
|
||||
|
||||
if (CRM_Utils_Array::value('snippet', $_GET) === 'json') {
|
||||
CRM_Core_Page_AJAX::returnJsonResponse($content);
|
||||
}
|
||||
if ($print) {
|
||||
CRM_Utils_System::setHttpHeader('Content-Type', $header);
|
||||
print $title;
|
||||
print $content;
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
300
sites/all/modules/civicrm/CRM/Mailing/PseudoConstant.php
Normal file
300
sites/all/modules/civicrm/CRM/Mailing/PseudoConstant.php
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class holds all the Pseudo constants that are specific to Mass mailing. This avoids
|
||||
* polluting the core class and isolates the mass mailer class.
|
||||
*/
|
||||
class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant {
|
||||
|
||||
/**
|
||||
* Status options for A/B tests.
|
||||
* @var array
|
||||
*/
|
||||
private static $abStatus;
|
||||
|
||||
/**
|
||||
* Test criteria for A/B tests.
|
||||
* @var array
|
||||
*/
|
||||
private static $abTestCriteria;
|
||||
|
||||
/**
|
||||
* Winner criteria for A/B tests.
|
||||
* @var array
|
||||
*/
|
||||
private static $abWinnerCriteria;
|
||||
|
||||
/**
|
||||
* Mailing templates
|
||||
* @var array
|
||||
*/
|
||||
private static $template;
|
||||
|
||||
/**
|
||||
* Completed mailings
|
||||
* @var array
|
||||
*/
|
||||
private static $completed;
|
||||
|
||||
/**
|
||||
* Mailing components
|
||||
* @var array
|
||||
*/
|
||||
private static $component;
|
||||
|
||||
/**
|
||||
* Default component id's, indexed by component type
|
||||
*/
|
||||
private static $defaultComponent;
|
||||
|
||||
/**
|
||||
* Mailing Types
|
||||
* @var array
|
||||
*/
|
||||
private static $mailingTypes;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function abStatus() {
|
||||
if (!is_array(self::$abStatus)) {
|
||||
self::$abStatus = array(
|
||||
'Draft' => ts('Draft'),
|
||||
'Testing' => ts('Testing'),
|
||||
'Final' => ts('Final'),
|
||||
);
|
||||
}
|
||||
return self::$abStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function abTestCriteria() {
|
||||
if (!is_array(self::$abTestCriteria)) {
|
||||
self::$abTestCriteria = array(
|
||||
'subject' => ts('Test different "Subject" lines'),
|
||||
'from' => ts('Test different "From" lines'),
|
||||
'full_email' => ts('Test entirely different emails'),
|
||||
);
|
||||
}
|
||||
return self::$abTestCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function abWinnerCriteria() {
|
||||
if (!is_array(self::$abWinnerCriteria)) {
|
||||
self::$abWinnerCriteria = array(
|
||||
'open' => ts('Open'),
|
||||
'unique_click' => ts('Total Unique Clicks'),
|
||||
'link_click' => ts('Total Clicks on a particular link'),
|
||||
);
|
||||
}
|
||||
return self::$abWinnerCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function mailingTypes() {
|
||||
if (!is_array(self::$mailingTypes)) {
|
||||
self::$mailingTypes = array(
|
||||
'standalone' => ts('Standalone'),
|
||||
'experiment' => ts('Experimental'),
|
||||
'winner' => ts('Winner'),
|
||||
);
|
||||
}
|
||||
return self::$mailingTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the mailing components of a particular type.
|
||||
*
|
||||
* @param $type
|
||||
* The type of component needed.
|
||||
*
|
||||
* @return array
|
||||
* array reference of all mailing components
|
||||
*/
|
||||
public static function &component($type = NULL) {
|
||||
$name = $type ? $type : 'ALL';
|
||||
|
||||
if (!self::$component || !array_key_exists($name, self::$component)) {
|
||||
if (!self::$component) {
|
||||
self::$component = array();
|
||||
}
|
||||
if (!$type) {
|
||||
self::$component[$name] = NULL;
|
||||
CRM_Core_PseudoConstant::populate(self::$component[$name], 'CRM_Mailing_DAO_Component');
|
||||
}
|
||||
else {
|
||||
// we need to add an additional filter for $type
|
||||
self::$component[$name] = array();
|
||||
|
||||
$object = new CRM_Mailing_DAO_Component();
|
||||
$object->component_type = $type;
|
||||
$object->selectAdd();
|
||||
$object->selectAdd("id, name");
|
||||
$object->orderBy('component_type, is_default, name');
|
||||
$object->is_active = 1;
|
||||
$object->find();
|
||||
while ($object->fetch()) {
|
||||
self::$component[$name][$object->id] = $object->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$component[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the default mailing component of a given type.
|
||||
*
|
||||
* @param $type
|
||||
* The type of component needed.
|
||||
* @param $undefined
|
||||
* The value to use if no default is defined.
|
||||
*
|
||||
* @return int
|
||||
* The ID of the default mailing component.
|
||||
*/
|
||||
public static function &defaultComponent($type, $undefined = NULL) {
|
||||
if (!self::$defaultComponent) {
|
||||
$queryDefaultComponents = "SELECT id, component_type
|
||||
FROM civicrm_mailing_component
|
||||
WHERE is_active = 1
|
||||
AND is_default = 1
|
||||
GROUP BY component_type, id";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($queryDefaultComponents);
|
||||
|
||||
self::$defaultComponent = array();
|
||||
while ($dao->fetch()) {
|
||||
self::$defaultComponent[$dao->component_type] = $dao->id;
|
||||
}
|
||||
}
|
||||
$value = CRM_Utils_Array::value($type, self::$defaultComponent, $undefined);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the mailing templates.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
* array reference of all mailing templates if any
|
||||
*/
|
||||
public static function &template() {
|
||||
if (!self::$template) {
|
||||
CRM_Core_PseudoConstant::populate(self::$template, 'CRM_Mailing_DAO_Mailing', TRUE, 'name', 'is_template');
|
||||
}
|
||||
return self::$template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the completed mailing.
|
||||
*
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return array
|
||||
* array reference of all mailing templates if any
|
||||
*/
|
||||
public static function &completed($mode = NULL) {
|
||||
if (!self::$completed) {
|
||||
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL();
|
||||
$mailingACL .= $mode == 'sms' ? " AND sms_provider_id IS NOT NULL " : "";
|
||||
|
||||
CRM_Core_PseudoConstant::populate(self::$completed,
|
||||
'CRM_Mailing_DAO_Mailing',
|
||||
FALSE,
|
||||
'name',
|
||||
'is_completed',
|
||||
$mailingACL
|
||||
);
|
||||
}
|
||||
return self::$completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Labels for advanced search against mailing summary.
|
||||
*
|
||||
* @param $field
|
||||
*
|
||||
* @return unknown_type
|
||||
*/
|
||||
public static function &yesNoOptions($field) {
|
||||
static $options;
|
||||
if (!$options) {
|
||||
$options = array(
|
||||
'bounce' => array(
|
||||
'N' => ts('Successful '),
|
||||
'Y' => ts('Bounced '),
|
||||
),
|
||||
'delivered' => array(
|
||||
'Y' => ts('Successful '),
|
||||
'N' => ts('Bounced '),
|
||||
),
|
||||
'open' => array(
|
||||
'Y' => ts('Opened '),
|
||||
'N' => ts('Unopened/Hidden '),
|
||||
),
|
||||
'click' => array(
|
||||
'Y' => ts('Clicked '),
|
||||
'N' => ts('Not Clicked '),
|
||||
),
|
||||
'reply' => array(
|
||||
'Y' => ts('Replied '),
|
||||
'N' => ts('No Reply '),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $options[$field];
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush given pseudoconstant so it can be reread from db
|
||||
* next time it's requested.
|
||||
*
|
||||
*
|
||||
* @param bool|string $name pseudoconstant to be flushed
|
||||
*/
|
||||
public static function flush($name = 'template') {
|
||||
if (isset(self::$$name)) {
|
||||
self::$$name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
654
sites/all/modules/civicrm/CRM/Mailing/Selector/Browse.php
Normal file
654
sites/all/modules/civicrm/CRM/Mailing/Selector/Browse.php
Normal file
|
@ -0,0 +1,654 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to browse past mailings.
|
||||
*/
|
||||
class CRM_Mailing_Selector_Browse extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* Array of supported links, currently null
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_columnHeaders;
|
||||
|
||||
protected $_parent;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
*
|
||||
* @return \CRM_Mailing_Selector_Browse
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the links that are given for each search row.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &links() {
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['csvString'] = NULL;
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
$params['status'] = ts('Mailings %%StatusMessage%%');
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
if (!isset(self::$_columnHeaders)) {
|
||||
$completedOrder = NULL;
|
||||
|
||||
// Set different default sort depending on type of mailings (CRM-7652)
|
||||
$unscheduledOrder = $scheduledOrder = $archivedOrder = CRM_Utils_Sort::DONTCARE;
|
||||
if ($this->_parent->get('unscheduled')) {
|
||||
$unscheduledOrder = CRM_Utils_Sort::DESCENDING;
|
||||
}
|
||||
elseif ($this->_parent->get('scheduled')) {
|
||||
$scheduledOrder = CRM_Utils_Sort::DESCENDING;
|
||||
}
|
||||
else {
|
||||
// sort by completed date for archived and undefined get
|
||||
$completedOrder = CRM_Utils_Sort::DESCENDING;
|
||||
}
|
||||
$nameHeaderLabel = ($this->_parent->get('sms')) ? ts('SMS Name') : ts('Mailing Name');
|
||||
|
||||
self::$_columnHeaders = array(
|
||||
array(
|
||||
'name' => $nameHeaderLabel,
|
||||
'sort' => 'name',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
);
|
||||
|
||||
if (CRM_Core_I18n::isMultilingual()) {
|
||||
self::$_columnHeaders = array_merge(
|
||||
self::$_columnHeaders,
|
||||
array(
|
||||
array(
|
||||
'name' => ts('Language'),
|
||||
'sort' => 'language',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
self::$_columnHeaders = array_merge(
|
||||
self::$_columnHeaders,
|
||||
array(
|
||||
array(
|
||||
'name' => ts('Status'),
|
||||
'sort' => 'status',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Created By'),
|
||||
'sort' => 'created_by',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Created Date'),
|
||||
'sort' => 'created_date',
|
||||
'direction' => $unscheduledOrder,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Sent By'),
|
||||
'sort' => 'scheduled_by',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Scheduled'),
|
||||
'sort' => 'scheduled_date',
|
||||
'direction' => $scheduledOrder,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Started'),
|
||||
'sort' => 'start_date',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Completed'),
|
||||
'sort' => 'end_date',
|
||||
'direction' => $completedOrder,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
|
||||
self::$_columnHeaders[] = array(
|
||||
'name' => ts('Campaign'),
|
||||
'sort' => 'campaign_id',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
);
|
||||
}
|
||||
|
||||
if ($output != CRM_Core_Selector_Controller::EXPORT) {
|
||||
self::$_columnHeaders[] = array('name' => ts('Action'));
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Core_Smarty::singleton()->assign('multilingual', CRM_Core_I18n::isMultilingual());
|
||||
return self::$_columnHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param string $action
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action) {
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL();
|
||||
|
||||
// get the where clause.
|
||||
$params = array();
|
||||
$whereClause = "$mailingACL AND " . $this->whereClause($params);
|
||||
|
||||
// CRM-11919 added addition ON clauses to mailing_job to match getRows
|
||||
$query = "
|
||||
SELECT COUNT( DISTINCT $mailing.id ) as count
|
||||
FROM $mailing
|
||||
LEFT JOIN $job ON ( $mailing.id = $job.mailing_id AND civicrm_mailing_job.is_test = 0 AND civicrm_mailing_job.parent_id IS NULL )
|
||||
LEFT JOIN civicrm_contact createdContact ON ( $mailing.created_id = createdContact.id )
|
||||
LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = scheduledContact.id )
|
||||
WHERE $whereClause";
|
||||
|
||||
return CRM_Core_DAO::singleValueQuery($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount.
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param int $offset
|
||||
* The row number to start from.
|
||||
* @param int $rowCount
|
||||
* The number of rows to return.
|
||||
* @param string $sort
|
||||
* The sql string that describes the sort order.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return int
|
||||
* the total number of rows for this action
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
|
||||
static $actionLinks = NULL;
|
||||
if (empty($actionLinks)) {
|
||||
$cancelExtra = ts('Are you sure you want to cancel this mailing?');
|
||||
$deleteExtra = ts('Are you sure you want to delete this mailing?');
|
||||
$archiveExtra = ts('Are you sure you want to archive this mailing?');
|
||||
|
||||
$actionLinks = array(
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Approve/Reject'),
|
||||
'url' => 'civicrm/mailing/approve',
|
||||
'qs' => 'mid=%%mid%%&reset=1',
|
||||
'title' => ts('Approve/Reject Mailing'),
|
||||
),
|
||||
CRM_Core_Action::VIEW => array(
|
||||
'name' => ts('Report'),
|
||||
'url' => 'civicrm/mailing/report',
|
||||
'qs' => 'mid=%%mid%%&reset=1',
|
||||
'title' => ts('View Mailing Report'),
|
||||
),
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Re-Use'),
|
||||
'url' => 'civicrm/mailing/send',
|
||||
'qs' => 'mid=%%mid%%&reset=1',
|
||||
'title' => ts('Re-Send Mailing'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Cancel'),
|
||||
'url' => 'civicrm/mailing/browse',
|
||||
'qs' => 'action=disable&mid=%%mid%%&reset=1',
|
||||
'extra' => 'onclick="if (confirm(\'' . $cancelExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"',
|
||||
'title' => ts('Cancel Mailing'),
|
||||
),
|
||||
CRM_Core_Action::PREVIEW => array(
|
||||
'name' => ts('Continue'),
|
||||
'url' => 'civicrm/mailing/send',
|
||||
'qs' => 'mid=%%mid%%&continue=true&reset=1',
|
||||
'title' => ts('Continue Mailing'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/mailing/browse',
|
||||
'qs' => 'action=delete&mid=%%mid%%&reset=1',
|
||||
'extra' => 'onclick="if (confirm(\'' . $deleteExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"',
|
||||
'title' => ts('Delete Mailing'),
|
||||
),
|
||||
CRM_Core_Action::RENEW => array(
|
||||
'name' => ts('Archive'),
|
||||
'url' => 'civicrm/mailing/browse/archived',
|
||||
'qs' => 'action=renew&mid=%%mid%%&reset=1',
|
||||
'extra' => 'onclick="if (confirm(\'' . $archiveExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"',
|
||||
'title' => ts('Archive Mailing'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$allAccess = TRUE;
|
||||
$workFlow = $showApprovalLinks = $showScheduleLinks = $showCreateLinks = FALSE;
|
||||
if (CRM_Mailing_Info::workflowEnabled()) {
|
||||
$allAccess = FALSE;
|
||||
$workFlow = TRUE;
|
||||
// supercedes all permission
|
||||
if (CRM_Core_Permission::check('access CiviMail')) {
|
||||
$allAccess = TRUE;
|
||||
}
|
||||
|
||||
if (CRM_Core_Permission::check('approve mailings')) {
|
||||
$showApprovalLinks = TRUE;
|
||||
}
|
||||
|
||||
if (CRM_Core_Permission::check('create mailings')) {
|
||||
$showCreateLinks = TRUE;
|
||||
}
|
||||
|
||||
if (CRM_Core_Permission::check('schedule mailings')) {
|
||||
$showScheduleLinks = TRUE;
|
||||
}
|
||||
}
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
|
||||
$params = array();
|
||||
|
||||
$whereClause = ' AND ' . $this->whereClause($params);
|
||||
|
||||
if (empty($params)) {
|
||||
$this->_parent->assign('isSearch', 0);
|
||||
}
|
||||
else {
|
||||
$this->_parent->assign('isSearch', 1);
|
||||
}
|
||||
$rows = &$mailing->getRows($offset, $rowCount, $sort, $whereClause, $params);
|
||||
|
||||
// get the search base mailing Ids, CRM-3711.
|
||||
$searchMailings = $mailing->searchMailingIDs();
|
||||
|
||||
// check for delete CRM-4418
|
||||
$allowToDelete = CRM_Core_Permission::check('delete in CiviMail');
|
||||
|
||||
if ($output != CRM_Core_Selector_Controller::EXPORT) {
|
||||
|
||||
// create the appropriate $op to use for hook_civicrm_links
|
||||
$pageTypes = array('view', 'mailing', 'browse');
|
||||
if ($this->_parent->_unscheduled) {
|
||||
$pageTypes[] = 'unscheduled';
|
||||
}
|
||||
if ($this->_parent->_scheduled) {
|
||||
$pageTypes[] = 'scheduled';
|
||||
}
|
||||
if ($this->_parent->_archived) {
|
||||
$pageTypes[] = 'archived';
|
||||
}
|
||||
$opString = implode('.', $pageTypes);
|
||||
|
||||
// get languages for later conversion
|
||||
$languages = CRM_Core_I18n::languages();
|
||||
|
||||
foreach ($rows as $key => $row) {
|
||||
$actionMask = NULL;
|
||||
if ($row['sms_provider_id']) {
|
||||
$actionLinks[CRM_Core_Action::PREVIEW]['url'] = 'civicrm/sms/send';
|
||||
}
|
||||
|
||||
if (!($row['status'] == 'Not scheduled') && !$row['sms_provider_id']) {
|
||||
if ($allAccess || $showCreateLinks) {
|
||||
$actionMask = CRM_Core_Action::VIEW;
|
||||
}
|
||||
|
||||
if (!in_array($row['id'], $searchMailings)) {
|
||||
if ($allAccess || $showCreateLinks) {
|
||||
$actionMask |= CRM_Core_Action::UPDATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($allAccess || ($showCreateLinks || $showScheduleLinks)) {
|
||||
$actionMask = CRM_Core_Action::PREVIEW;
|
||||
}
|
||||
}
|
||||
if (in_array($row['status'], array(
|
||||
'Scheduled',
|
||||
'Running',
|
||||
'Paused',
|
||||
))) {
|
||||
if ($allAccess ||
|
||||
($showApprovalLinks && $showCreateLinks && $showScheduleLinks)
|
||||
) {
|
||||
|
||||
$actionMask |= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
if ($row['status'] == 'Scheduled' &&
|
||||
empty($row['approval_status_id'])
|
||||
) {
|
||||
if ($workFlow && ($allAccess || $showApprovalLinks)) {
|
||||
$actionMask |= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($row['status'], array('Complete', 'Canceled')) &&
|
||||
!$row['archived']
|
||||
) {
|
||||
if ($allAccess || $showCreateLinks) {
|
||||
$actionMask |= CRM_Core_Action::RENEW;
|
||||
}
|
||||
}
|
||||
|
||||
// check for delete permission.
|
||||
if ($allowToDelete) {
|
||||
$actionMask |= CRM_Core_Action::DELETE;
|
||||
}
|
||||
|
||||
if ($actionMask == NULL) {
|
||||
$actionMask = CRM_Core_Action::ADD;
|
||||
}
|
||||
// get status strings as per locale settings CRM-4411.
|
||||
$rows[$key]['status'] = CRM_Mailing_BAO_MailingJob::status($row['status']);
|
||||
|
||||
// get language string
|
||||
$rows[$key]['language'] = (isset($row['language']) ? $languages[$row['language']] : NULL);
|
||||
|
||||
$validLinks = $actionLinks;
|
||||
if (($mailingUrl = CRM_Mailing_BAO_Mailing::getPublicViewUrl($row['id'])) != FALSE) {
|
||||
$validLinks[] = array(
|
||||
'name' => ts('Public View'),
|
||||
'url' => 'civicrm/mailing/view',
|
||||
'qs' => 'id=%%mid%%&reset=1',
|
||||
'title' => ts('Public View'),
|
||||
'fe' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
$rows[$key]['action'] = CRM_Core_Action::formLink(
|
||||
$validLinks,
|
||||
$actionMask,
|
||||
array('mid' => $row['id']),
|
||||
"more",
|
||||
FALSE,
|
||||
$opString,
|
||||
"Mailing",
|
||||
$row['id']
|
||||
);
|
||||
|
||||
// unset($rows[$key]['id']);
|
||||
// if the scheduled date is 0, replace it with an empty string
|
||||
if ($rows[$key]['scheduled_iso'] == '0000-00-00 00:00:00') {
|
||||
$rows[$key]['scheduled'] = '';
|
||||
}
|
||||
unset($rows[$key]['scheduled_iso']);
|
||||
}
|
||||
}
|
||||
|
||||
// also initialize the AtoZ pager
|
||||
$this->pagerAtoZ();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return ts('CiviMail Mailings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $parent
|
||||
*/
|
||||
public function setParent($parent) {
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param bool $sortBy
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function whereClause(&$params, $sortBy = TRUE) {
|
||||
$values = $clauses = array();
|
||||
$isFormSubmitted = $this->_parent->get('hidden_find_mailings');
|
||||
|
||||
$title = $this->_parent->get('mailing_name');
|
||||
if ($title) {
|
||||
$clauses[] = 'name LIKE %1';
|
||||
if (strpos($title, '%') !== FALSE) {
|
||||
$params[1] = array($title, 'String', FALSE);
|
||||
}
|
||||
else {
|
||||
$params[1] = array($title, 'String', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
$dateClause1 = $dateClause2 = array();
|
||||
$from = $this->_parent->get('mailing_from');
|
||||
if (!CRM_Utils_System::isNull($from)) {
|
||||
if ($this->_parent->get('unscheduled')) {
|
||||
$dateClause1[] = 'civicrm_mailing.created_date >= %2';
|
||||
}
|
||||
else {
|
||||
$dateClause1[] = 'civicrm_mailing_job.start_date >= %2';
|
||||
$dateClause2[] = 'civicrm_mailing_job.scheduled_date >= %2';
|
||||
}
|
||||
$params[2] = array($from, 'String');
|
||||
}
|
||||
|
||||
$to = $this->_parent->get('mailing_to');
|
||||
if (!CRM_Utils_System::isNull($to)) {
|
||||
if ($this->_parent->get('unscheduled')) {
|
||||
$dateClause1[] = ' civicrm_mailing.created_date <= %3 ';
|
||||
}
|
||||
else {
|
||||
$dateClause1[] = 'civicrm_mailing_job.start_date <= %3';
|
||||
$dateClause2[] = 'civicrm_mailing_job.scheduled_date <= %3';
|
||||
}
|
||||
$params[3] = array($to, 'String');
|
||||
}
|
||||
|
||||
$dateClauses = array();
|
||||
if (!empty($dateClause1)) {
|
||||
$dateClauses[] = implode(' AND ', $dateClause1);
|
||||
}
|
||||
if (!empty($dateClause2)) {
|
||||
$dateClauses[] = implode(' AND ', $dateClause2);
|
||||
}
|
||||
$dateClauses = implode(' OR ', $dateClauses);
|
||||
if (!empty($dateClauses)) {
|
||||
$clauses[] = "({$dateClauses})";
|
||||
}
|
||||
|
||||
if ($this->_parent->get('sms')) {
|
||||
$clauses[] = "civicrm_mailing.sms_provider_id IS NOT NULL";
|
||||
}
|
||||
else {
|
||||
$clauses[] = "civicrm_mailing.sms_provider_id IS NULL";
|
||||
}
|
||||
|
||||
// get values submitted by form
|
||||
$isDraft = $this->_parent->get('status_unscheduled');
|
||||
$isArchived = $this->_parent->get('is_archived');
|
||||
$mailingStatus = $this->_parent->get('mailing_status');
|
||||
|
||||
if (!$isFormSubmitted && $this->_parent->get('scheduled')) {
|
||||
// mimic default behavior for scheduled screen
|
||||
$isArchived = 0;
|
||||
$mailingStatus = array('Scheduled' => 1, 'Complete' => 1, 'Running' => 1, 'Canceled' => 1);
|
||||
}
|
||||
if (!$isFormSubmitted && $this->_parent->get('archived')) {
|
||||
// mimic default behavior for archived screen
|
||||
$isArchived = 1;
|
||||
}
|
||||
if (!$isFormSubmitted && $this->_parent->get('unscheduled')) {
|
||||
// mimic default behavior for draft screen
|
||||
$isDraft = 1;
|
||||
}
|
||||
|
||||
$statusClauses = array();
|
||||
if ($isDraft) {
|
||||
$statusClauses[] = "civicrm_mailing.scheduled_id IS NULL";
|
||||
}
|
||||
if (!empty($mailingStatus)) {
|
||||
$statusClauses[] = "civicrm_mailing_job.status IN ('" . implode("', '", array_keys($mailingStatus)) . "')";
|
||||
}
|
||||
if (!empty($statusClauses)) {
|
||||
$clauses[] = "(" . implode(' OR ', $statusClauses) . ")";
|
||||
}
|
||||
|
||||
if (isset($isArchived)) {
|
||||
if ($isArchived) {
|
||||
$clauses[] = "civicrm_mailing.is_archived = 1";
|
||||
}
|
||||
else {
|
||||
$clauses[] = "(civicrm_mailing.is_archived IS NULL OR civicrm_mailing.is_archived = 0)";
|
||||
}
|
||||
}
|
||||
|
||||
if ($sortBy &&
|
||||
$this->_parent->_sortByCharacter !== NULL
|
||||
) {
|
||||
$clauses[] = "name LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_parent->_sortByCharacter)) . "%'";
|
||||
}
|
||||
|
||||
// dont do a the below assignement when doing a
|
||||
// AtoZ pager clause
|
||||
if ($sortBy) {
|
||||
if (count($clauses) > 1) {
|
||||
$this->_parent->assign('isSearch', 1);
|
||||
}
|
||||
else {
|
||||
$this->_parent->assign('isSearch', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$createOrSentBy = $this->_parent->get('sort_name');
|
||||
if (!CRM_Utils_System::isNull($createOrSentBy)) {
|
||||
$clauses[] = '(createdContact.sort_name LIKE %4 OR scheduledContact.sort_name LIKE %4)';
|
||||
$params[4] = array('%' . $createOrSentBy . '%', 'String');
|
||||
}
|
||||
|
||||
$createdId = $this->_parent->get('createdId');
|
||||
if ($createdId) {
|
||||
$clauses[] = "(created_id = {$createdId})";
|
||||
$params[5] = array($createdId, 'Integer');
|
||||
}
|
||||
|
||||
$campainIds = $this->_parent->get('campaign_id');
|
||||
if (!CRM_Utils_System::isNull($campainIds)) {
|
||||
if (!is_array($campainIds)) {
|
||||
$campaignIds = array($campaignIds);
|
||||
}
|
||||
$clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )';
|
||||
}
|
||||
|
||||
if ($language = $this->_parent->get('language')) {
|
||||
$clauses[] = "civicrm_mailing.language = %6";
|
||||
$params[6] = array($language, 'String');
|
||||
}
|
||||
|
||||
if (empty($clauses)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return implode(' AND ', $clauses);
|
||||
}
|
||||
|
||||
public function pagerAtoZ() {
|
||||
|
||||
$params = array();
|
||||
$whereClause = $this->whereClause($params, FALSE);
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT UPPER(LEFT(name, 1)) as sort_name
|
||||
FROM civicrm_mailing
|
||||
LEFT JOIN civicrm_mailing_job ON (civicrm_mailing_job.mailing_id = civicrm_mailing.id)
|
||||
LEFT JOIN civicrm_contact createdContact ON ( civicrm_mailing.created_id = createdContact.id )
|
||||
LEFT JOIN civicrm_contact scheduledContact ON ( civicrm_mailing.scheduled_id = scheduledContact.id )
|
||||
WHERE $whereClause
|
||||
ORDER BY UPPER(LEFT(name, 1))
|
||||
";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
|
||||
$aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_parent->_sortByCharacter, TRUE);
|
||||
$this->_parent->assign('aToZ', $aToZBar);
|
||||
}
|
||||
|
||||
}
|
475
sites/all/modules/civicrm/CRM/Mailing/Selector/Event.php
Normal file
475
sites/all/modules/civicrm/CRM/Mailing/Selector/Event.php
Normal file
|
@ -0,0 +1,475 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to retrieve and display a range of
|
||||
* contacts that match the given criteria (specifically for
|
||||
* results of advanced search options.
|
||||
*/
|
||||
class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* Array of supported links, currently null
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* What event type are we browsing?
|
||||
*/
|
||||
private $_event;
|
||||
|
||||
/**
|
||||
* Should we only count distinct contacts?
|
||||
*/
|
||||
private $_is_distinct;
|
||||
|
||||
/**
|
||||
* Which mailing are we browsing events from?
|
||||
*/
|
||||
private $_mailing_id;
|
||||
|
||||
/**
|
||||
* Do we want events tied to a specific job?
|
||||
*/
|
||||
private $_job_id;
|
||||
|
||||
/**
|
||||
* For click-through events, do we only want those from a specific url?
|
||||
*/
|
||||
private $_url_id;
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_columnHeaders;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $event
|
||||
* The event type (queue/delivered/open...).
|
||||
* @param bool $distinct
|
||||
* Count only distinct contact events?.
|
||||
* @param int $mailing
|
||||
* ID of the mailing to query.
|
||||
* @param int $job
|
||||
* ID of the job to query. If null, all jobs from $mailing are queried.
|
||||
* @param int $url
|
||||
* If the event type is a click-through, do we want only those from a specific url?.
|
||||
*
|
||||
* @return \CRM_Mailing_Selector_Event
|
||||
*/
|
||||
public function __construct($event, $distinct, $mailing, $job = NULL, $url = NULL) {
|
||||
$this->_event_type = $event;
|
||||
$this->_is_distinct = $distinct;
|
||||
$this->_mailing_id = $mailing;
|
||||
$this->_job_id = $job;
|
||||
$this->_url_id = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the links that are given for each search row.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &links() {
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['csvString'] = NULL;
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
$params['status'] = ts('%1 %%StatusMessage%%', array(1 => $this->eventToTitle()));
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
|
||||
|
||||
$contact = CRM_Contact_BAO_Contact::getTableName();
|
||||
|
||||
$email = CRM_Core_BAO_Email::getTableName();
|
||||
|
||||
$job = CRM_Mailing_BAO_MailingJob::getTableName();
|
||||
if (!isset($this->_columnHeaders)) {
|
||||
|
||||
$this->_columnHeaders = array(
|
||||
'sort_name' => array(
|
||||
'name' => ts('Contact'),
|
||||
'sort' => $contact . '.sort_name',
|
||||
'direction' => CRM_Utils_Sort::ASCENDING,
|
||||
),
|
||||
'email' => array(
|
||||
'name' => ts('Email Address'),
|
||||
'sort' => $email . '.email',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
);
|
||||
|
||||
switch ($this->_event_type) {
|
||||
case 'queue':
|
||||
$dateSort = $job . '.start_date';
|
||||
break;
|
||||
|
||||
case 'delivered':
|
||||
$this->_columnHeaders = array(
|
||||
'contact_id' => array(
|
||||
'name' => ts('Internal Contact ID'),
|
||||
'sort' => $contact . '.id',
|
||||
'direction' => CRM_Utils_Sort::ASCENDING,
|
||||
),
|
||||
) + $this->_columnHeaders;
|
||||
$dateSort = CRM_Mailing_Event_BAO_Delivered::getTableName() . '.time_stamp';
|
||||
break;
|
||||
|
||||
case 'opened':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Opened::getTableName() . '.time_stamp';
|
||||
break;
|
||||
|
||||
case 'bounce':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Bounce::getTableName() . '.time_stamp';
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders,
|
||||
array(
|
||||
array(
|
||||
'name' => ts('Bounce Type'),
|
||||
),
|
||||
array(
|
||||
'name' => ts('Bounce Reason'),
|
||||
),
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'forward':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Forward::getTableName() . '.time_stamp';
|
||||
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders,
|
||||
array(
|
||||
array(
|
||||
'name' => ts('Forwarded Email'),
|
||||
),
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'reply':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Reply::getTableName() . '.time_stamp';
|
||||
break;
|
||||
|
||||
case 'unsubscribe':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp';
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders, array(
|
||||
array(
|
||||
'name' => ts('Unsubscribe'),
|
||||
),
|
||||
));
|
||||
break;
|
||||
|
||||
case 'optout':
|
||||
$dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp';
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders, array(
|
||||
array(
|
||||
'name' => ts('Opt-Out'),
|
||||
),
|
||||
));
|
||||
break;
|
||||
|
||||
case 'click':
|
||||
$dateSort = CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName() . '.time_stamp';
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders, array(
|
||||
array(
|
||||
'name' => ts('URL'),
|
||||
),
|
||||
));
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->_columnHeaders = array_merge($this->_columnHeaders, array(
|
||||
'date' => array(
|
||||
'name' => ts('Date'),
|
||||
'sort' => $dateSort,
|
||||
'direction' => CRM_Utils_Sort::DESCENDING,
|
||||
),
|
||||
));
|
||||
}
|
||||
return $this->_columnHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param string $action
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action) {
|
||||
switch ($this->_event_type) {
|
||||
case 'queue':
|
||||
$event = new CRM_Mailing_Event_BAO_Queue();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'delivered':
|
||||
$event = new CRM_Mailing_Event_BAO_Delivered();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'opened':
|
||||
$event = new CRM_Mailing_Event_BAO_Opened();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'bounce':
|
||||
$event = new CRM_Mailing_Event_BAO_Bounce();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'forward':
|
||||
$event = new CRM_Mailing_Event_BAO_Forward();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'reply':
|
||||
$event = new CRM_Mailing_Event_BAO_Reply();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'unsubscribe':
|
||||
$event = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'optout':
|
||||
$event = new CRM_Mailing_Event_BAO_Unsubscribe();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct,
|
||||
FALSE
|
||||
);
|
||||
return $result;
|
||||
|
||||
case 'click':
|
||||
$event = new CRM_Mailing_Event_BAO_TrackableURLOpen();
|
||||
$result = $event->getTotalCount($this->_mailing_id,
|
||||
$this->_job_id,
|
||||
$this->_is_distinct,
|
||||
$this->_url_id
|
||||
);
|
||||
return $result;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount.
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param int $offset
|
||||
* The row number to start from.
|
||||
* @param int $rowCount
|
||||
* The number of rows to return.
|
||||
* @param string $sort
|
||||
* The sql string that describes the sort order.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return int
|
||||
* the total number of rows for this action
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
|
||||
switch ($this->_event_type) {
|
||||
case 'queue':
|
||||
$rows = CRM_Mailing_Event_BAO_Queue::getRows($this->_mailing_id,
|
||||
$this->_job_id, $offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'delivered':
|
||||
$rows = CRM_Mailing_Event_BAO_Delivered::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'opened':
|
||||
$rows = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'bounce':
|
||||
$rows = CRM_Mailing_Event_BAO_Bounce::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'forward':
|
||||
$rows = CRM_Mailing_Event_BAO_Forward::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'reply':
|
||||
$rows = CRM_Mailing_Event_BAO_Reply::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'unsubscribe':
|
||||
$rows = CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort, TRUE
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'optout':
|
||||
$rows = CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
|
||||
$this->_job_id, $this->_is_distinct,
|
||||
$offset, $rowCount, $sort, FALSE
|
||||
);
|
||||
return $rows;
|
||||
|
||||
case 'click':
|
||||
$rows = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows(
|
||||
$this->_mailing_id, $this->_job_id,
|
||||
$this->_is_distinct, $this->_url_id,
|
||||
$offset, $rowCount, $sort
|
||||
);
|
||||
return $rows;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string|NULL
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title for the mailing event type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function eventToTitle() {
|
||||
static $events = NULL;
|
||||
|
||||
if (empty($events)) {
|
||||
$events = array(
|
||||
'queue' => ts('Intended Recipients'),
|
||||
'delivered' => ts('Successful Deliveries'),
|
||||
'bounce' => ts('Bounces'),
|
||||
'forward' => ts('Forwards'),
|
||||
'reply' => $this->_is_distinct ? ts('Unique Replies') : ts('Replies'),
|
||||
'unsubscribe' => ts('Unsubscribe Requests'),
|
||||
'optout' => ts('Opt-out Requests'),
|
||||
'click' => $this->_is_distinct ? ts('Unique Click-throughs') : ts('Click-throughs'),
|
||||
'opened' => $this->_is_distinct ? ts('Unique Tracked Opens') : ts('Total Tracked Opens'),
|
||||
);
|
||||
}
|
||||
return $events[$this->_event_type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the event.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->eventToTitle();
|
||||
}
|
||||
|
||||
}
|
415
sites/all/modules/civicrm/CRM/Mailing/Selector/Search.php
Normal file
415
sites/all/modules/civicrm/CRM/Mailing/Selector/Search.php
Normal file
|
@ -0,0 +1,415 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to retrieve and display a range of
|
||||
* contacts that match the given criteria (specifically for
|
||||
* results of advanced search options.
|
||||
*/
|
||||
class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* This defines two actions- View and Edit.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_columnHeaders;
|
||||
|
||||
/**
|
||||
* Properties of contact we're interested in displaying
|
||||
* @var array
|
||||
*/
|
||||
static $_properties = array(
|
||||
'contact_id',
|
||||
'mailing_id',
|
||||
'mailing_name',
|
||||
'language',
|
||||
'sort_name',
|
||||
'email',
|
||||
'mailing_subject',
|
||||
'email_on_hold',
|
||||
'contact_opt_out',
|
||||
'mailing_job_status',
|
||||
'mailing_job_end_date',
|
||||
);
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* What context are we being invoked from
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = NULL;
|
||||
|
||||
/**
|
||||
* What component context are we being invoked from
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_compContext = NULL;
|
||||
|
||||
/**
|
||||
* QueryParams is the array returned by exportValues called on
|
||||
* the HTML_QuickForm_Controller for that page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_queryParams;
|
||||
|
||||
/**
|
||||
* Represent the type of selector.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_action;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_mailingClause = NULL;
|
||||
|
||||
/**
|
||||
* The query object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_query;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param array $queryParams
|
||||
* Array of parameters for query.
|
||||
* @param \const|int $action - action of search basic or advanced.
|
||||
* @param string $mailingClause
|
||||
* If the caller wants to further restrict the search.
|
||||
* @param bool $single
|
||||
* Are we dealing only with one contact?.
|
||||
* @param int $limit
|
||||
* How many mailing do we want returned.
|
||||
*
|
||||
* @param string $context
|
||||
* @param null $compContext
|
||||
*
|
||||
* @return \CRM_Mailing_Selector_Search
|
||||
*/
|
||||
public function __construct(
|
||||
&$queryParams,
|
||||
$action = CRM_Core_Action::NONE,
|
||||
$mailingClause = NULL,
|
||||
$single = FALSE,
|
||||
$limit = NULL,
|
||||
$context = 'search',
|
||||
$compContext = NULL
|
||||
) {
|
||||
// submitted form values
|
||||
$this->_queryParams = &$queryParams;
|
||||
|
||||
$this->_single = $single;
|
||||
$this->_limit = $limit;
|
||||
$this->_context = $context;
|
||||
$this->_compContext = $compContext;
|
||||
|
||||
$this->_mailingClause = $mailingClause;
|
||||
|
||||
// type of selector
|
||||
$this->_action = $action;
|
||||
$this->_query = new CRM_Contact_BAO_Query($this->_queryParams,
|
||||
CRM_Mailing_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_MAILING,
|
||||
FALSE
|
||||
),
|
||||
NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_MAILING
|
||||
);
|
||||
|
||||
$this->_query->_distinctComponentClause = " civicrm_mailing_recipients.id ";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the links that are given for each search row.
|
||||
* currently the links added for each row are
|
||||
*
|
||||
* - View
|
||||
* - Edit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &links() {
|
||||
if (!(self::$_links)) {
|
||||
list($context, $key) = func_get_args();
|
||||
$extraParams = ($key) ? "&key={$key}" : NULL;
|
||||
$searchContext = ($context) ? "&context=$context" : NULL;
|
||||
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::VIEW => array(
|
||||
'name' => ts('View'),
|
||||
'url' => 'civicrm/contact/view',
|
||||
'qs' => "reset=1&cid=%%cid%%{$searchContext}{$extraParams}",
|
||||
'title' => ts('View Contact Details'),
|
||||
),
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/contact/add',
|
||||
'qs' => "reset=1&action=update&cid=%%cid%%{$searchContext}{$extraParams}",
|
||||
'title' => ts('Edit Contact Details'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/contact/view/delete',
|
||||
'qs' => "reset=1&delete=1&cid=%%cid%%{$searchContext}{$extraParams}",
|
||||
'title' => ts('Delete Contact'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['status'] = ts('Mailing Recipient') . ' %%StatusMessage%%';
|
||||
$params['csvString'] = NULL;
|
||||
if ($this->_limit) {
|
||||
$params['rowCount'] = $this->_limit;
|
||||
}
|
||||
else {
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
}
|
||||
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param string $action
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action) {
|
||||
return $this->_query->searchQuery(0, 0, NULL,
|
||||
TRUE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_mailingClause
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount.
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param int $offset
|
||||
* The row number to start from.
|
||||
* @param int $rowCount
|
||||
* The number of rows to return.
|
||||
* @param string $sort
|
||||
* The sql string that describes the sort order.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return int
|
||||
* the total number of rows for this action
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
|
||||
$result = $this->_query->searchQuery($offset, $rowCount, $sort,
|
||||
FALSE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_mailingClause
|
||||
);
|
||||
|
||||
// process the result of the query
|
||||
$rows = array();
|
||||
$permissions = array(CRM_Core_Permission::getPermission());
|
||||
if (CRM_Core_Permission::check('delete contacts')) {
|
||||
$permissions[] = CRM_Core_Permission::DELETE;
|
||||
}
|
||||
$mask = CRM_Core_Action::mask($permissions);
|
||||
$qfKey = $this->_key;
|
||||
|
||||
while ($result->fetch()) {
|
||||
$row = array();
|
||||
// the columns we are interested in
|
||||
foreach (self::$_properties as $property) {
|
||||
if (property_exists($result, $property)) {
|
||||
$row[$property] = $result->$property;
|
||||
}
|
||||
}
|
||||
|
||||
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->mailing_recipients_id;
|
||||
|
||||
$actions = array(
|
||||
'cid' => $result->contact_id,
|
||||
'cxt' => $this->_context,
|
||||
);
|
||||
|
||||
$row['action'] = CRM_Core_Action::formLink(
|
||||
self::links($qfKey, $this->_context),
|
||||
$mask,
|
||||
$actions,
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'contact.mailing.row',
|
||||
'Contact',
|
||||
$result->contact_id
|
||||
);
|
||||
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
|
||||
);
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQILL() {
|
||||
return $this->_query->qill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
if (!isset(self::$_columnHeaders)) {
|
||||
self::$_columnHeaders = array(
|
||||
array('desc' => ts('Contact Type')),
|
||||
array(
|
||||
'name' => ts('Name'),
|
||||
'sort' => 'sort_name',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Email'),
|
||||
'sort' => 'email',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Mailing Name'),
|
||||
'sort' => 'mailing_name',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Language'),
|
||||
'sort' => 'language',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Mailing Subject'),
|
||||
'sort' => 'mailing_subject',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Mailing Status'),
|
||||
'sort' => 'mailing_job_status',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Completed Date'),
|
||||
'sort' => 'mailing_job_end_date',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array('desc' => ts('Actions')),
|
||||
);
|
||||
}
|
||||
return self::$_columnHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function alphabetQuery() {
|
||||
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function &getQuery() {
|
||||
return $this->_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return ts('CiviCRM Mailing Search');
|
||||
}
|
||||
|
||||
}
|
124
sites/all/modules/civicrm/CRM/Mailing/Task.php
Normal file
124
sites/all/modules/civicrm/CRM/Mailing/Task.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?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 to represent the actions that can be performed on a group of contacts
|
||||
* used by the search forms.
|
||||
*
|
||||
*/
|
||||
class CRM_Mailing_Task {
|
||||
/**
|
||||
* The task array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_tasks = NULL;
|
||||
|
||||
/**
|
||||
* The optional task array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_optionalTasks = NULL;
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform
|
||||
* on a contact / group of contacts.
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of contacts.
|
||||
*/
|
||||
public static function &tasks() {
|
||||
if (!(self::$_tasks)) {
|
||||
self::$_tasks = array(
|
||||
1 => array(
|
||||
'title' => ts('Print Mailing Recipients'),
|
||||
'class' => 'CRM_Mailing_Form_Task_Print',
|
||||
'result' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
CRM_Utils_Hook::searchTasks('mailing', self::$_tasks);
|
||||
asort(self::$_tasks);
|
||||
}
|
||||
|
||||
return self::$_tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of task titles
|
||||
* on mailing recipients.
|
||||
*
|
||||
* @return array
|
||||
* the set of task titles.
|
||||
*/
|
||||
public static function &taskTitles() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show tasks selectively based on the permission level
|
||||
* of the user.
|
||||
*
|
||||
* @param int $permission
|
||||
*
|
||||
* @return array
|
||||
* set of tasks that are valid for the user
|
||||
*/
|
||||
public static function &permissionedTaskTitles($permission) {
|
||||
$task = array();
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform.
|
||||
* on mailing recipients.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of mailing recipients
|
||||
*/
|
||||
public static function getTask($value) {
|
||||
self::tasks();
|
||||
if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
|
||||
// make the print task by default
|
||||
$value = 1;
|
||||
}
|
||||
return array(
|
||||
self::$_tasks[$value]['class'],
|
||||
self::$_tasks[$value]['result'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
94
sites/all/modules/civicrm/CRM/Mailing/Tokens.php
Normal file
94
sites/all/modules/civicrm/CRM/Mailing/Tokens.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_Tokens
|
||||
*
|
||||
* Generate "mailing.*" tokens.
|
||||
*
|
||||
* To activate these tokens, the TokenProcessor context must specify either
|
||||
* "mailingId" (int) or "mailing" (CRM_Mailing_BAO_Mailing).
|
||||
*/
|
||||
class CRM_Mailing_Tokens extends \Civi\Token\AbstractTokenSubscriber {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct('mailing', array(
|
||||
'id' => ts('Mailing ID'),
|
||||
'name' => ts('Mailing Name'),
|
||||
'group' => ts('Mailing Group(s)'),
|
||||
'subject' => ts('Mailing Subject'),
|
||||
'viewUrl' => ts('Mailing URL (View)'),
|
||||
'editUrl' => ts('Mailing URL (Edit)'),
|
||||
'scheduleUrl' => ts('Mailing URL (Schedule)'),
|
||||
'html' => ts('Mailing HTML'),
|
||||
'approvalStatus' => ts('Mailing Approval Status'),
|
||||
'approvalNote' => ts('Mailing Approval Note'),
|
||||
'approveUrl' => ts('Mailing Approval URL'),
|
||||
'creator' => ts('Mailing Creator (Name)'),
|
||||
'creatorEmail' => ts('Mailing Creator (Email)'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function checkActive(\Civi\Token\TokenProcessor $processor) {
|
||||
return !empty($processor->context['mailingId']) || !empty($processor->context['mailing']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefetch tokens.
|
||||
*
|
||||
* @param \Civi\Token\Event\TokenValueEvent $e
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function prefetch(\Civi\Token\Event\TokenValueEvent $e) {
|
||||
$processor = $e->getTokenProcessor();
|
||||
$mailing = isset($processor->context['mailing'])
|
||||
? $processor->context['mailing']
|
||||
: CRM_Mailing_BAO_Mailing::findById($processor->context['mailingId']);
|
||||
|
||||
return array(
|
||||
'mailing' => $mailing,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) {
|
||||
$row->format('text/plain')->tokens($entity, $field,
|
||||
(string) CRM_Utils_Token::getMailingTokenReplacement($field, $prefetch['mailing']));
|
||||
}
|
||||
|
||||
}
|
209
sites/all/modules/civicrm/CRM/Mailing/xml/Menu/Mailing.xml
Normal file
209
sites/all/modules/civicrm/CRM/Mailing/xml/Menu/Mailing.xml
Normal file
|
@ -0,0 +1,209 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
|
||||
<menu>
|
||||
<item>
|
||||
<path>civicrm/mailing</path>
|
||||
<title>CiviMail</title>
|
||||
<page_callback>CRM_Mailing_Page_Browse</page_callback>
|
||||
<access_arguments>access CiviMail;create mailings</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>600</weight>
|
||||
<component>CiviMail</component>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/admin/mail</path>
|
||||
<title>Mailer Settings</title>
|
||||
<page_callback>CRM_Admin_Form_Setting_Mail</page_callback>
|
||||
<desc>Configure spool period, throttling and other mailer settings.</desc>
|
||||
<access_arguments>access CiviCRM,access CiviMail</access_arguments>
|
||||
<adminGroup>CiviMail</adminGroup>
|
||||
<icon>admin/small/07.png</icon>
|
||||
<weight>400</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/admin/component</path>
|
||||
<title>Headers, Footers, and Automated Messages</title>
|
||||
<page_callback>CRM_Mailing_Page_Component</page_callback>
|
||||
<desc>Configure the header and footer used for mailings. Customize the content of automated Subscribe, Unsubscribe, Resubscribe and Opt-out messages.</desc>
|
||||
<access_arguments>access CiviCRM,access CiviMail</access_arguments>
|
||||
<adminGroup>CiviMail</adminGroup>
|
||||
<icon>admin/small/Profile.png</icon>
|
||||
<weight>410</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/admin/options/from_email_address/civimail</path>
|
||||
<title>From Email Addresses</title>
|
||||
<desc>List of Email Addresses which can be used when sending emails to contacts.</desc>
|
||||
<page_callback>CRM_Admin_Page_Options</page_callback>
|
||||
<adminGroup>CiviMail</adminGroup>
|
||||
<icon>admin/small/title.png</icon>
|
||||
<weight>415</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/admin/mailSettings</path>
|
||||
<title>Mail Accounts</title>
|
||||
<page_callback>CRM_Admin_Page_MailSettings</page_callback>
|
||||
<desc>Configure email account setting.</desc>
|
||||
<access_arguments>access CiviCRM,access CiviMail</access_arguments>
|
||||
<adminGroup>CiviMail</adminGroup>
|
||||
<icon>admin/small/07.png</icon>
|
||||
<weight>420</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/admin/setting/preferences/mailing</path>
|
||||
<title>CiviMail Component Settings</title>
|
||||
<page_callback>CRM_Admin_Form_Preferences_Mailing</page_callback>
|
||||
<desc>Configure global CiviMail behaviors.</desc>
|
||||
<access_arguments>access CiviMail,administer CiviCRM</access_arguments>
|
||||
<adminGroup>CiviMail</adminGroup>
|
||||
<weight>430</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/send</path>
|
||||
<title>New Mailing</title>
|
||||
<page_callback>CRM_Mailing_Controller_Send</page_callback>
|
||||
<access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>610</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/browse/scheduled</path>
|
||||
<title>Find Mailings</title>
|
||||
<path_arguments>scheduled=true</path_arguments>
|
||||
<page_callback>CRM_Mailing_Page_Browse</page_callback>
|
||||
<access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>620</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/browse/unscheduled</path>
|
||||
<title>Find Mailings</title>
|
||||
<path_arguments>scheduled=false</path_arguments>
|
||||
<page_callback>CRM_Mailing_Page_Browse</page_callback>
|
||||
<access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>620</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/browse/archived</path>
|
||||
<title>Find Mailings</title>
|
||||
<page_callback>CRM_Mailing_Page_Browse</page_callback>
|
||||
<access_arguments>access CiviMail;create mailings</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>625</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/component</path>
|
||||
<title>Headers, Footers, and Automated Messages</title>
|
||||
<page_callback>CRM_Mailing_Page_Component</page_callback>
|
||||
<access_arguments>administer CiviCRM</access_arguments>
|
||||
<page_type>1</page_type>
|
||||
<weight>630</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/unsubscribe</path>
|
||||
<title>Unsubscribe</title>
|
||||
<page_callback>CRM_Mailing_Form_Unsubscribe</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>640</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/resubscribe</path>
|
||||
<title>Resubscribe</title>
|
||||
<page_callback>CRM_Mailing_Page_Resubscribe</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>645</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/optout</path>
|
||||
<title>Opt-out</title>
|
||||
<page_callback>CRM_Mailing_Form_Optout</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>650</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/confirm</path>
|
||||
<title>Confirm</title>
|
||||
<page_callback>CRM_Mailing_Page_Confirm</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>660</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/subscribe</path>
|
||||
<title>Subscribe</title>
|
||||
<page_callback>CRM_Mailing_Form_Subscribe</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>660</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/preview</path>
|
||||
<title>Preview Mailing</title>
|
||||
<page_callback>CRM_Mailing_Page_Preview</page_callback>
|
||||
<access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
|
||||
<weight>670</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/report</path>
|
||||
<title>Mailing Report</title>
|
||||
<page_callback>CRM_Mailing_Page_Report</page_callback>
|
||||
<access_arguments>access CiviMail;create mailings</access_arguments>
|
||||
<path_arguments>mid=%%mid%%</path_arguments>
|
||||
<weight>680</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/forward</path>
|
||||
<title>Forward Mailing</title>
|
||||
<page_callback>CRM_Mailing_Form_ForwardMailing</page_callback>
|
||||
<access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>685</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/queue</path>
|
||||
<title>Sending Mail</title>
|
||||
<page_callback>CRM_Mailing_Page_Browse</page_callback>
|
||||
<access_arguments>access CiviMail</access_arguments>
|
||||
<weight>690</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/report/event</path>
|
||||
<title>Mailing Event</title>
|
||||
<page_callback>CRM_Mailing_Page_Event</page_callback>
|
||||
<access_arguments>access CiviMail</access_arguments>
|
||||
<weight>695</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/ajax/template</path>
|
||||
<page_callback>CRM_Mailing_Page_AJAX::template</page_callback>
|
||||
<access_arguments>access CiviCRM</access_arguments>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/view</path>
|
||||
<title>View Mailing</title>
|
||||
<page_callback>CRM_Mailing_Page_View</page_callback>
|
||||
<access_arguments>view public CiviMail content;access CiviMail;approve mailings</access_arguments>
|
||||
<is_public>true</is_public>
|
||||
<weight>800</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/mailing/approve</path>
|
||||
<title>Approve Mailing</title>
|
||||
<page_callback>CRM_Mailing_Form_Approve</page_callback>
|
||||
<access_arguments>access CiviMail;approve mailings</access_arguments>
|
||||
<weight>850</weight>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/contact/view/mailing</path>
|
||||
<page_callback>CRM_Mailing_Page_Tab</page_callback>
|
||||
</item>
|
||||
<item>
|
||||
<path>civicrm/ajax/contactmailing</path>
|
||||
<page_callback>CRM_Mailing_Page_AJAX::getContactMailings</page_callback>
|
||||
<access_arguments>access CiviCRM</access_arguments>
|
||||
</item>
|
||||
</menu>
|
Loading…
Add table
Add a link
Reference in a new issue