else {
$defaults['target_contact_value'] = ts('(recipients)');
}
-
+
$sourceContactId = self::getActivityContact($activity->id, $sourceID);
if ($sourceContactId &&
}
}
else {
- $assignmentParams['assignee_contact_id'] = $params['assignee_contact_id'];
+ $assignmentParams['contact_id'] = $params['assignee_contact_id'];
$assignmentParams['record_type_id'] = $assigneeID;
if (CRM_Utils_Array::value('id', $params)) {
$assignment = new CRM_Activity_BAO_ActivityAssignment();
$assignment->record_type_id = $assigneeID;
$assignment->find(TRUE);
- if ($assignment->assignee_contact_id != $params['assignee_contact_id']) {
+ if ($assignment->contact_id != $params['assignee_contact_id']) {
$assignmentParams['id'] = $assignment->id;
$resultAssignment = CRM_Activity_BAO_ActivityContact::create($assignmentParams);
}
}
}
else {
- $targetParams['target_contact_id'] = $params['target_contact_id'];
+ $targetParams['contact_id'] = $params['target_contact_id'];
$targetParams['record_type_id'] = $targetID;
if (CRM_Utils_Array::value('id', $params)) {
$target = new CRM_Activity_BAO_ActivityContact();
$target->record_type_id = $targetID;
$target->find(TRUE);
- if ($target->target_contact_id != $params['target_contact_id']) {
+ if ($target->contact_id != $params['target_contact_id']) {
$targetParams['id'] = $target->id;
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
}
INNER JOIN {$activityTempTable} ON ( ac.activity_id = {$activityTempTable}.activity_id {$notbulkActivityClause} )
INNER JOIN civicrm_contact c ON c.id = ac.contact_id
WHERE c.is_deleted = 0
-
+
";
CRM_Core_DAO::executeQuery($query);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
-
+
while ($dao->fetch()) {
$activityID = $dao->activity_id;
$activityContacts = CRM_Core_PseudoConstant::activityContacts('name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
-
+
// add activity target record for every sms that is send
$activityTargetParams = array(
$activityTargetParams = array(
'activity_id' => $activityID,
'contact_id' => $toID,
- 'record_type_id' => $targetID
+ 'record_type_id' => $targetID
);
CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
return TRUE;
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
-
+
// First look for activities where contactId is one of the targets
$query = "
$activityContact->record_type_id = $recordTypeID;
}
if ($activityContact->find(TRUE)) {
- return $activityContact->$column;
+ return $activityContact->$column;
}
}
}
$activityParams = array(
'subject' => $actionSchedule->title,
'details' => $actionSchedule->body_html,
- 'source_contact_id' => $session->get('userID') ?
- $session->get('userID') : $dao->contact_id,
+ 'source_contact_id' =>
+ $session->get('userID') ? $session->get('userID') : $dao->contact_id,
'target_contact_id' => $dao->contact_id,
'activity_date_time' => date('YmdHis'),
'status_id' => $activityStatusID,
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
-
+
switch (CRM_Utils_Array::value($actionSchedule->recipient, $recipientOptions)) {
case 'Activity Assignees':
$join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$assigneeID}";
break;
case 'Activity Source':
- $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$sourceID}";
+ $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$sourceID}";
break;
default:
$where[] = "e.is_override IS NULL OR e.is_override = 0";
$dateField = str_replace('membership_', 'e.', $actionSchedule->start_action_date);
$notINClause = self::permissionedRelationships($contactField);
-
+
$memershipStatus = CRM_Member_PseudoConstant::membershipStatus(NULL, "is_current_member = 1", 'id');
$mStatus = implode (',', $memershipStatus);
$where[] = "e.status_id IN ({$mStatus})";
{$joinClause}
LEFT JOIN {$reminderJoinClause}
{$whereClause} AND {$dateClause} {$notINClause}";
-
+
CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
// if repeat is turned ON:
function tearDown() {
// truncate a few tables
- $tablesToTruncate = array('civicrm_contact', 'civicrm_activity', 'civicrm_activity_target', 'civicrm_activity_assignment');
+ $tablesToTruncate = array('civicrm_contact', 'civicrm_activity', 'civicrm_activity_contact');
$this->quickCleanup($tablesToTruncate);
}
activity_type_id="1"
status_id="2"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="1"
- assignee_contact_id="2"
+ contact_id="2"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="1"
- assignee_contact_id="3"
+ contact_id="3"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="2"
- assignee_contact_id="4"
+ contact_id="4"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="2"
- assignee_contact_id="5"
+ contact_id="5"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="3"
- assignee_contact_id="6"
+ contact_id="6"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="3"
- assignee_contact_id="7"
+ contact_id="7"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="4"
- assignee_contact_id="8"
+ contact_id="8"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="4"
- assignee_contact_id="9"
+ contact_id="9"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="5"
- assignee_contact_id="10"
+ contact_id="10"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="5"
- assignee_contact_id="11"
+ contact_id="11"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="6"
- assignee_contact_id="12"
+ contact_id="12"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="6"
- assignee_contact_id="13"
+ contact_id="13"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="7"
- assignee_contact_id="14"
+ contact_id="14"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="7"
- assignee_contact_id="15"
+ contact_id="15"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="8"
- assignee_contact_id="16"
+ contact_id="16"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="8"
- assignee_contact_id="1"
- />
- <civicrm_activity_assignment
+ contact_id="1"
+ record_type_id="1"
+ />
+ <civicrm_activity_contact
activity_id="9"
- assignee_contact_id="2"
+ contact_id="2"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="9"
- assignee_contact_id="3"
- />
- <civicrm_activity_assignment
+ contact_id="3"
+ record_type_id="1"
+ />
+ <civicrm_activity_contact
activity_id="10"
- assignee_contact_id="4"
+ contact_id="4"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="10"
- assignee_contact_id="5"
+ contact_id="5"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="11"
- assignee_contact_id="6"
+ contact_id="6"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="11"
- assignee_contact_id="7"
- />
- <civicrm_activity_assignment
+ contact_id="7"
+ record_type_id="1"
+ />
+ <civicrm_activity_contact
activity_id="12"
- assignee_contact_id="8"
+ contact_id="8"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="12"
- assignee_contact_id="9"
- />
- <civicrm_activity_assignment
+ contact_id="9"
+ record_type_id="1"
+ />
+ <civicrm_activity_contact
activity_id="13"
- assignee_contact_id="10"
+ contact_id="10"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="13"
- assignee_contact_id="11"
+ contact_id="11"
+ record_type_id="1"
/>
- <civicrm_activity_assignment
+ <civicrm_activity_contact
activity_id="15"
- assignee_contact_id="13"
+ contact_id="13"
+ record_type_id="1"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="1"
- target_contact_id="4"
+ contact_id="4"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="1"
- target_contact_id="5"
+ contact_id="5"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="2"
- target_contact_id="6"
+ contact_id="6"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="2"
- target_contact_id="7"
+ contact_id="7"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="3"
- target_contact_id="8"
+ contact_id="8"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="3"
- target_contact_id="9"
+ contact_id="9"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="4"
- target_contact_id="10"
+ contact_id="10"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="4"
- target_contact_id="11"
+ contact_id="11"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="5"
- target_contact_id="12"
+ contact_id="12"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="5"
- target_contact_id="13"
+ contact_id="13"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="6"
- target_contact_id="14"
+ contact_id="14"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="6"
- target_contact_id="15"
+ contact_id="15"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="7"
- target_contact_id="16"
+ contact_id="16"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="7"
- target_contact_id="1"
+ contact_id="1"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="8"
- target_contact_id="2"
+ contact_id="2"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="8"
- target_contact_id="3"
- />
- <civicrm_activity_target
+ contact_id="3"
+ record_type_id="3"
+ />
+ <civicrm_activity_contact
activity_id="9"
- target_contact_id="4"
+ contact_id="4"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="9"
- target_contact_id="5"
- />
- <civicrm_activity_target
+ contact_id="5"
+ record_type_id="3"
+ />
+ <civicrm_activity_contact
activity_id="10"
- target_contact_id="6"
+ contact_id="6"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="10"
- target_contact_id="7"
+ contact_id="7"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="11"
- target_contact_id="8"
+ contact_id="8"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="11"
- target_contact_id="9"
- />
- <civicrm_activity_target
+ contact_id="9"
+ record_type_id="3"
+ />
+ <civicrm_activity_contact
activity_id="12"
- target_contact_id="10"
+ contact_id="10"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="12"
- target_contact_id="11"
- />
- <civicrm_activity_target
+ contact_id="11"
+ record_type_id="3"
+ />
+ <civicrm_activity_contact
activity_id="14"
- target_contact_id="12"
+ contact_id="12"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="14"
- target_contact_id="13"
+ contact_id="13"
+ record_type_id="3"
/>
- <civicrm_activity_target
+ <civicrm_activity_contact
activity_id="15"
- target_contact_id="14"
+ contact_id="14"
+ record_type_id="3"
/>
</dataset>
'civicrm_contribution_page',
'civicrm_contribution_widget',
'civicrm_activity',
- 'civicrm_activity_assignment',
- 'civicrm_activity_target',
+ 'civicrm_activity_contact',
'civicrm_case_activity',
'civicrm_pledge',
'civicrm_price_field',
$tablesToTruncate = array(
'civicrm_contact',
'civicrm_activity',
- 'civicrm_activity_target',
- 'civicrm_activity_assignment',
+ 'civicrm_activity_contact',
);
$this->quickCleanup($tablesToTruncate, TRUE);
civicrm_api('option_value', 'delete', array('version' => 3, 'id' => $this->test_activity_type_id));
'civicrm_case',
'civicrm_case_contact',
'civicrm_case_activity',
- 'civicrm_activity_target',
- 'civicrm_activity_assignment',
+ 'civicrm_activity_contact',
'civicrm_relationship',
'civicrm_relationship_type',
);
'civicrm_case',
'civicrm_case_contact',
'civicrm_case_activity',
- 'civicrm_activity_target',
- 'civicrm_activity_assignment',
+ 'civicrm_activity_contact',
'civicrm_relationship',
'civicrm_relationship_type',
);
$this->assertEquals($dao->find(), 1, 'case_activity table not populated correctly in line ' . __LINE__);
$dao->free();
- require_once 'CRM/Activity/DAO/ActivityTarget.php';
- $dao = new CRM_Activity_DAO_ActivityTarget();
+ require_once 'CRM/Activity/DAO/ActivityContact.php';
+ $dao = new CRM_Activity_DAO_ActivityContact();
$dao->activity_id = $this->_caseActivityId;
- $dao->target_contact_id = $this->_params['contact_id'];
- $this->assertEquals($dao->find(), 1, 'activity_target table not populated correctly in line ' . __LINE__);
+ $dao->contact_id = $this->_params['contact_id'];
+ $dao->record_type_id = 3;
+ $this->assertEquals($dao->find(), 1, 'activity_contact table not populated correctly in line ' . __LINE__);
$dao->free();
// TODO: There's more things we could check
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Id: activity_target_1_emailed.xml 23352 2009-08-19 21:52:45Z walt $ -->
+<!-- $Id: activity_contact_1_emailed.xml 23352 2009-08-19 21:52:45Z walt $ -->
<dataset>
- <table name="civicrm_activity_target">
+ <table name="civicrm_activity_contact">
<column>id</column>
<column>activity_id</column>
- <column>target_contact_id</column>
+ <column>contact_id</column>
+ <column>record_type_id</column>
<row>
<value>1</value> <!-- id -->
<value>1</value> <!-- activity_id -->
<value>17</value> <!-- target_contact_id -->
+ <value>3</value> <!-- record_type_id -->
</row>
</table>
</dataset>