本文整理汇总了PHP中CRM_Mailing_BAO_Mailing::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_BAO_Mailing::getTableName方法的具体用法?PHP CRM_Mailing_BAO_Mailing::getTableName怎么用?PHP CRM_Mailing_BAO_Mailing::getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Mailing_BAO_Mailing
的用法示例。
在下文中一共展示了CRM_Mailing_BAO_Mailing::getTableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CRM_Core_Dao
/**
* Get rows for the event browser
*
* @param int $mailing_id ID of the mailing
* @param int $job_id optional ID of the job
* @param boolean $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
* @access public
* @static
*/
public static function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
{
$dao =& new CRM_Core_Dao();
$unsub = self::getTableName();
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$job = CRM_Mailing_BAO_Job::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$query = "\n SELECT {$contact}.display_name as display_name,\n {$contact}.id as contact_id,\n {$email}.email as email,\n {$unsub}.time_stamp as date,\n {$unsub}.org_unsubscribe as org_unsubscribe\n FROM {$contact}\n INNER JOIN {$queue}\n ON {$queue}.contact_id = {$contact}.id\n INNER JOIN {$email}\n ON {$queue}.email_id = {$email}.id\n INNER JOIN {$unsub}\n ON {$unsub}.event_queue_id = {$queue}.id\n INNER JOIN {$job}\n ON {$queue}.job_id = {$job}.id\n INNER JOIN {$mailing}\n ON {$job}.mailing_id = {$mailing}.id\n AND {$job}.is_test = 0\n 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 .= " ORDER BY {$contact}.sort_name, {$unsub}.time_stamp DESC ";
if ($offset) {
$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, 'org' => $dao->org_unsubscribe ? ts('Yes') : ts('No'), 'date' => CRM_Utils_Date::customFormat($dao->date));
}
return $results;
}
示例2: array
/**
* returns the column headers as an array of tuples:
* (name, sortName (key to the sort array))
*
* @param string $action the action being performed
* @param enum $output what should the result set include (web/email/csv)
*
* @return array the column headers that need to be displayed
* @access 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(array('name' => ts('Contact'), 'sort' => $contact . '.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING), 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':
$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(array('name' => ts('Date'), 'sort' => $dateSort, 'direction' => CRM_Utils_Sort::DESCENDING)));
}
return $this->_columnHeaders;
}
示例3: CRM_Core_Dao
/**
* Get rows for the event browser
*
* @param int $mailing_id ID of the mailing
* @param int $job_id optional ID of the job
* @param boolean $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
* @access public
* @static
*/
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_Job::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$query = "\n SELECT {$contact}.display_name as from_name,\n {$contact}.id as from_id,\n {$email}.email as from_email,\n dest_contact.id as dest_id,\n dest_email.email as dest_email,\n {$forward}.time_stamp as date\n FROM {$contact}\n INNER JOIN {$queue}\n ON {$queue}.contact_id = {$contact}.id\n INNER JOIN {$email}\n ON {$queue}.email_id = {$email}.id\n INNER JOIN {$forward}\n ON {$forward}.event_queue_id = {$queue}.id\n INNER JOIN {$queue} as dest_queue\n ON {$forward}.dest_queue_id = dest_queue.id\n INNER JOIN {$contact} as dest_contact\n ON dest_queue.contact_id = dest_contact.id\n INNER JOIN {$email} as dest_email\n ON dest_queue.email_id = dest_email.id\n INNER JOIN {$job}\n ON {$queue}.job_id = {$job}.id\n INNER JOIN {$mailing}\n ON {$job}.mailing_id = {$mailing}.id\n AND {$job}.is_test = 0\n 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 .= " ORDER BY {$contact}.sort_name, {$forward}.time_stamp DESC ";
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;
}
示例4: MIN
/**
* Get the rows for a browse operation
*
* @param int $offset The row number to start from
* @param int $rowCount The nmber of rows to return
* @param string $sort The sql string that describes the sort order
*
* @return array The rows
* @access public
*/
function &getRows($offset, $rowCount, $sort)
{
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$job = CRM_Mailing_BAO_Job::getTableName();
$session =& CRM_Core_Session::singleton();
$domain_id = $session->get('domainID');
$query = "\n SELECT {$mailing}.id,\n {$mailing}.name, \n {$job}.status, \n MIN({$job}.scheduled_date) as scheduled_date, \n MIN({$job}.start_date) as start_date,\n MAX({$job}.end_date) as end_date\n FROM {$mailing}\n INNER JOIN {$job}\n ON {$job}.mailing_id = {$mailing}.id\n WHERE {$mailing}.domain_id = {$domain_id}\n GROUP BY {$mailing}.id\n ORDER BY {$mailing}.id, {$job}.end_date";
if ($rowCount) {
$query .= " LIMIT {$offset}, {$rowCount} ";
}
$this->query($query);
$rows = array();
while ($this->fetch()) {
$rows[] = array('id' => $this->id, 'name' => $this->name, 'status' => CRM_Mailing_BAO_Job::status($this->status), 'scheduled' => CRM_Utils_Date::customFormat($this->scheduled_date), 'scheduled_iso' => $this->scheduled_date, 'start' => CRM_Utils_Date::customFormat($this->start_date), 'end' => CRM_Utils_Date::customFormat($this->end_date));
}
return $rows;
}
示例5: replaceGroups
/**
* Replace the list of recipients on a given mailing.
*
* @param int $mailingId
* @param string $type
* 'include' or 'exclude'.
* @param string $entity
* 'groups' or 'mailings'.
* @param array <int> $entityIds
* @throws CiviCRM_API3_Exception
*/
public static function replaceGroups($mailingId, $type, $entity, $entityIds)
{
$values = array();
foreach ($entityIds as $entityId) {
$values[] = array('entity_id' => $entityId);
}
civicrm_api3('mailing_group', 'replace', array('mailing_id' => $mailingId, 'group_type' => $type, 'entity_table' => $entity == 'groups' ? CRM_Contact_BAO_Group::getTableName() : CRM_Mailing_BAO_Mailing::getTableName(), 'values' => $values));
}
示例6: postProcess
public function postProcess()
{
$values = $this->controller->exportValues($this->_name);
//build hidden smart group. when user want to send mailing
//through search contact-> more action -> send Mailing. CRM-3711
$groups = array();
if ($this->_searchBasedMailing && $this->_contactIds) {
$session = CRM_Core_Session::singleton();
if ($this->_resultSelectOption == 'ts_sel') {
// create a static grp if only a subset of result set was selected:
$randID = md5(time());
$grpTitle = "Hidden Group {$randID}";
$grpID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $grpTitle, 'id', 'title');
if (!$grpID) {
$groupParams = array('title' => $grpTitle, 'is_active' => 1, 'is_hidden' => 1, 'group_type' => array('2' => 1));
$group = CRM_Contact_BAO_Group::create($groupParams);
$grpID = $group->id;
CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $group->id);
$newGroupTitle = "Hidden Group {$grpID}";
$groupParams = array('id' => $grpID, 'name' => CRM_Utils_String::titleToVar($newGroupTitle), 'title' => $newGroupTitle);
$group = CRM_Contact_BAO_Group::create($groupParams);
}
// note at this point its a static group
$smartGroupId = $grpID;
} else {
//get the hidden smart group id.
$ssId = $this->get('ssID');
$hiddenSmartParams = array('group_type' => array('2' => 1), 'form_values' => $this->get('formValues'), 'saved_search_id' => $ssId, 'search_custom_id' => $this->get('customSearchID'), 'search_context' => $this->get('context'));
list($smartGroupId, $savedSearchId) = CRM_Contact_BAO_Group::createHiddenSmartGroup($hiddenSmartParams);
//set the saved search id.
if (!$ssId) {
if ($savedSearchId) {
$this->set('ssID', $savedSearchId);
} else {
CRM_Core_Error::fatal();
}
}
}
//get the base group for this mailing, CRM-3711
$groups['base'] = array($values['baseGroup']);
$values['includeGroups'][] = $smartGroupId;
}
foreach (array('name', 'group_id', 'search_id', 'search_args', 'campaign_id', 'dedupe_email') as $n) {
if (CRM_Utils_Array::value($n, $values)) {
$params[$n] = $values[$n];
}
}
$qf_Group_submit = $this->controller->exportValue($this->_name, '_qf_Group_submit');
$this->set('name', $params['name']);
$inGroups = $values['includeGroups'];
$outGroups = $values['excludeGroups'];
$inMailings = $values['includeMailings'];
$outMailings = $values['excludeMailings'];
if (is_array($inGroups)) {
foreach ($inGroups as $key => $id) {
if ($id) {
$groups['include'][] = $id;
}
}
}
if (is_array($outGroups)) {
foreach ($outGroups as $key => $id) {
if ($id) {
$groups['exclude'][] = $id;
}
}
}
$mailings = array();
if (is_array($inMailings)) {
foreach ($inMailings as $key => $id) {
if ($id) {
$mailings['include'][] = $id;
}
}
}
if (is_array($outMailings)) {
foreach ($outMailings as $key => $id) {
if ($id) {
$mailings['exclude'][] = $id;
}
}
}
$session = CRM_Core_Session::singleton();
$params['groups'] = $groups;
$params['mailings'] = $mailings;
if ($this->get('mailing_id')) {
$ids = array();
// don't create a new mailing if already exists
$ids['mailing_id'] = $this->get('mailing_id');
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
// delete previous includes/excludes, if mailing already existed
foreach (array('groups', 'mailings') as $entity) {
$mg = new CRM_Mailing_DAO_Group();
$mg->mailing_id = $ids['mailing_id'];
$mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
$mg->find();
while ($mg->fetch()) {
$mg->delete();
}
//.........这里部分代码省略.........
示例7: CRM_Mailing_BAO_Mailing
/**
* Get the mailing object for this queue event instance
*
* @param
* @return object Mailing BAO
* @access public
*/
function &getMailing()
{
$mailing =& new CRM_Mailing_BAO_Mailing();
$jobs = CRM_Mailing_BAO_Job::getTableName();
$mailings = CRM_Mailing_BAO_Mailing::getTableName();
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
$mailing->query("\n SELECT {$mailings}.*\n FROM {$mailings}\n INNER JOIN {$jobs}\n ON {$jobs}.mailing_id = {$mailings}.id\n INNER JOIN {$queue}\n ON {$queue}.job_id = {$jobs}.id\n WHERE {$queue}.id = {$this->id}");
$mailing->fetch();
return $mailing;
}
示例8: getTotalCount
/**
* Returns total number of rows for the query.
*
* @param
*
* @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 = "\n SELECT COUNT( DISTINCT {$mailing}.id ) as count\n FROM {$mailing}\nLEFT JOIN {$job} ON ( {$mailing}.id = {$job}.mailing_id AND civicrm_mailing_job.is_test = 0 AND civicrm_mailing_job.parent_id IS NULL )\nLEFT JOIN civicrm_contact createdContact ON ( {$mailing}.created_id = createdContact.id )\nLEFT JOIN civicrm_contact scheduledContact ON ( {$mailing}.scheduled_id = scheduledContact.id )\n WHERE {$whereClause}";
return CRM_Core_DAO::singleValueQuery($query, $params);
}
示例9: CRM_Mailing_Event_BAO_Unsubscribe
/**
* 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.
* @access public
* @static
*/
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;
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$do = new CRM_Core_DAO();
$mg = CRM_Mailing_DAO_Group::getTableName();
$job = CRM_Mailing_BAO_Job::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
$gc = CRM_Contact_BAO_GroupContact::getTableName();
$do->query("\n SELECT {$mg}.entity_table as entity_table,\n {$mg}.entity_id as entity_id\n FROM {$mg}\n INNER JOIN {$job}\n ON {$job}.mailing_id = {$mg}.mailing_id\n WHERE {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer') . "\n AND {$mg}.group_type = 'Include'");
/* 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;
} else {
if ($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("\n SELECT {$mg}.entity_table as entity_table,\n {$mg}.entity_id as entity_id\n FROM {$mg}\n WHERE {$mg}.mailing_id IN (" . implode(', ', $mailings) . ")\n AND {$mg}.group_type = 'Include'");
$mailings = array();
while ($do->fetch()) {
if ($do->entity_table == $group) {
$groups[$do->entity_id] = true;
} else {
if ($do->entity_table == $mailing) {
$mailings[] = $do->entity_id;
}
}
}
}
/* 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("\n SELECT {$group}.id as group_id,\n {$group}.title as title\n FROM {$group}\n LEFT JOIN {$gc}\n ON {$gc}.group_id = {$group}.id\n WHERE {$group}.id IN (" . implode(', ', array_keys($groups)) . ")\n AND ({$group}.saved_search_id is not null\n OR ({$gc}.contact_id = {$contact_id}\n AND {$gc}.status = 'Removed')\n )");
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;
}
示例10: CRM_Mailing_Event_BAO_Unsubscribe
/**
* 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\n FROM {$job}\n WHERE {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
$do->fetch();
$mailing_id = $do->mailing_id;
$do->query("\n SELECT {$mg}.entity_table as entity_table,\n {$mg}.entity_id as entity_id\n FROM {$mg}\n INNER JOIN {$job}\n ON {$job}.mailing_id = {$mg}.mailing_id\n INNER JOIN {$group}\n ON {$mg}.entity_id = {$group}.id\n WHERE {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer') . "\n AND {$mg}.group_type IN ( 'Include', 'Base' )\n 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("\n SELECT {$mg}.entity_table as entity_table,\n {$mg}.entity_id as entity_id\n FROM {$mg}\n WHERE {$mg}.mailing_id IN (" . implode(', ', $mailings) . ")\n 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("\n SELECT {$group}.id as group_id,\n {$group}.title as title\n FROM {$group}\n LEFT JOIN {$gc}\n ON {$gc}.group_id = {$group}.id\n WHERE {$group}.id IN (" . implode(', ', $group_ids) . ")\n AND ({$group}.saved_search_id is not null\n OR ({$gc}.contact_id = {$contact_id}\n AND {$gc}.status = 'Removed')\n )");
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;
}
示例11: array
/**
* returns the column headers as an array of tuples:
* (name, sortName (key to the sort array))
*
* @param string $action the action being performed
* @param enum $output what should the result set include (web/email/csv)
*
* @return array the column headers that need to be displayed
* @access public
*/
function &getColumnHeaders($action = null, $output = null)
{
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
require_once 'CRM/Mailing/BAO/Job.php';
$job = CRM_Mailing_BAO_Job::getTableName();
if (!isset($this->_columnHeaders)) {
$this->_columnHeaders = array(array('name' => ts('Contact')), array('name' => ts('Email Address')));
if ($this->_event_type == 'bounce') {
$this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Bounce Type')), array('name' => ts('Bounce Reason'))));
} elseif ($this->_event_type == 'unsubscribe') {
$this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Opt-Out'))));
} elseif ($this->_event_type == 'click') {
$this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('URL'))));
} elseif ($this->_event_type == 'forward') {
$this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Forwarded Email'))));
}
$this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Date'))));
}
return $this->_columnHeaders;
}
示例12: create
/**
* Construct a new mailing object, along with job and mailing_group
* objects, from the form values of the create mailing wizard.
*
* @params array $params Form values
*
* @return object $mailing The new mailing object
* @access public
* @static
*/
public static function create(&$params, &$ids)
{
$transaction = new CRM_Core_Transaction();
$mailing = self::add($params, $ids);
if (is_a($mailing, 'CRM_Core_Error')) {
$transaction->rollback();
return $mailing;
}
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
/* Create the mailing group record */
$mg = new CRM_Mailing_DAO_Group();
foreach (array('groups', 'mailings') as $entity) {
foreach (array('include', 'exclude', 'base') as $type) {
if (isset($params[$entity]) && CRM_Utils_Array::value($type, $params[$entity]) && is_array($params[$entity][$type])) {
foreach ($params[$entity][$type] as $entityId) {
$mg->reset();
$mg->mailing_id = $mailing->id;
$mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
$mg->entity_id = $entityId;
$mg->group_type = $type;
$mg->save();
}
}
}
}
if (!empty($params['search_id']) && !empty($params['group_id'])) {
$mg->reset();
$mg->mailing_id = $mailing->id;
$mg->entity_table = $groupTableName;
$mg->entity_id = $params['group_id'];
$mg->search_id = $params['search_id'];
$mg->search_args = $params['search_args'];
$mg->group_type = 'Include';
$mg->save();
}
// check and attach and files as needed
CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
$transaction->commit();
return $mailing;
}
示例13: mailingGroupEntityTables
/**
* Whitelist of possible values for the entity_table field
* @return array
*/
public static function mailingGroupEntityTables()
{
$tables = array(CRM_Contact_BAO_Group::getTableName(), CRM_Mailing_BAO_Mailing::getTableName());
// Identical keys & values
return array_combine($tables, $tables);
}
示例14: getTotalCount
/**
* Returns total number of rows for the query.
*
* @param
* @return int Total number of rows
* @access public
*/
function getTotalCount($action)
{
require_once 'CRM/Mailing/BAO/Job.php';
require_once 'CRM/Mailing/BAO/Mailing.php';
$job = CRM_Mailing_BAO_Job::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);
$query = "\n SELECT COUNT( DISTINCT {$mailing}.id ) as count\n FROM {$mailing}\nLEFT JOIN {$job} ON ( {$mailing}.id = {$job}.mailing_id) \nLEFT JOIN civicrm_contact createdContact ON ( {$mailing}.created_id = createdContact.id )\nLEFT JOIN civicrm_contact scheduledContact ON ( {$mailing}.scheduled_id = scheduledContact.id ) \n WHERE {$whereClause}";
return CRM_Core_DAO::singleValueQuery($query, $params);
}
示例15: CRM_Core_Dao
/**
* Get rows for the event browser
*
* @param int $mailing_id ID of the mailing
* @param int $job_id optional ID of the job
* @param boolean $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
* @access public
* @static
*/
function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
{
$dao =& new CRM_Core_Dao();
$bounce = CRM_Mailing_Event_BAO_Bounce::getTableName();
$bounceType = CRM_Mailing_DAO_BounceType::getTableName();
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$job = CRM_Mailing_BAO_Job::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$query = "\n SELECT {$contact}.display_name as display_name,\n {$contact}.id as contact_id,\n {$email}.email as email,\n {$bounce}.time_stamp as date,\n {$bounce}.bounce_reason as reason,\n {$bounceType}.name as bounce_type\n FROM {$contact}\n INNER JOIN {$queue}\n ON {$queue}.contact_id = {$contact}.id\n INNER JOIN {$email}\n ON {$queue}.email_id = {$email}.id\n INNER JOIN {$bounce}\n ON {$bounce}.event_queue_id = {$queue}.id\n LEFT JOIN {$bounceType}\n ON {$bounce}.bounce_type_id = {$bounceType}.id\n INNER JOIN {$job}\n ON {$queue}.job_id = {$job}.id\n INNER JOIN {$mailing}\n ON {$job}.mailing_id = {$mailing}.id\n 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 .= " ORDER BY {$contact}.sort_name, {$bounce}.time_stamp ";
if ($offset) {
$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, 'type' => empty($dao->bounce_type) ? ts('Unknown') : $dao->bounce_type, 'reason' => $dao->reason, 'date' => CRM_Utils_Date::customFormat($dao->date));
}
return $results;
}