/**
* Function to delete the activity
*
- * @param array $params associated array
+ * @param array $params associated array
+ *
+ * @param bool $moveToTrash
*
* @return void
* @access public
- *
*/
public static function deleteActivity(&$params, $moveToTrash = FALSE) {
// CRM-9137
/**
* Delete activity assignment record
*
- * @param int $id activity id
+ * @param $activityId
+ * @param null $recordTypeID
+ *
+ * @internal param int $id activity id
*
* @return null
* @access public
*
* @param array $params associated array of the submitted values
*
+ * @throws CRM_Core_Exception
* @internal param object $form form object
* @internal param array $ids array of ids
* @internal param string $activityType activity Type
);
}
else {
- $q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home";
+ $q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home";
if ($activity->activity_type_id != CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name')) {
$url = CRM_Utils_System::url('civicrm/activity', $q);
if ($activity->activity_type_id == CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name')) {
}
else {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/add',
- "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home"
+ "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
);
}
if (CRM_Core_Permission::check("delete activities")) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity',
- "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home"
+ "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
);
}
}
$url = CRM_Utils_System::url('civicrm/activity/view', $q);
if (CRM_Core_Permission::check('delete activities')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity',
- "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home"
+ "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
);
}
}
return $result;
}
+ /**
+ * @param $activity
+ * @param null $logMessage
+ *
+ * @return bool
+ */
public static function logActivityAction($activity, $logMessage = NULL) {
$session = CRM_Core_Session::singleton();
$id = $session->get('userID');
'name'
);
+ $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
+ $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
+ $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
+ $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
+
$config = CRM_Core_Config::singleton();
$randomNum = md5(uniqid());
}
$input['count'] = FALSE;
-
- // skip bulk activities in activity tab
- $input['activity_type_exclude_id'][$bulkActivityTypeID] = $bulkActivityTypeID;
list($sqlClause, $params) = self::getActivitySQLClause($input);
$query = "{$insertSQL}
$activityContactTempTable = "civicrm_temp_activity_contact_{$randomNum}";
$query = "CREATE TEMPORARY TABLE {$activityContactTempTable} (
activity_id int unsigned, contact_id int unsigned, record_type_id varchar(16),
- contact_name varchar(255), is_deleted int unsigned, INDEX index_activity_id( activity_id ) )
+ contact_name varchar(255), is_deleted int unsigned, counter int unsigned, INDEX index_activity_id( activity_id ) )
ENGINE=MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($query);
c.sort_name,
c.is_deleted
FROM {$activityTempTable}
-INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id )
+INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id )
INNER JOIN civicrm_activity_contact ac ON ( ac.activity_id = {$activityTempTable}.activity_id )
INNER JOIN civicrm_contact c ON c.id = ac.contact_id
+WHERE ac.record_type_id != %1
";
- CRM_Core_DAO::executeQuery($query);
+ $params = array(1 => array($targetID, 'Integer'));
+ CRM_Core_DAO::executeQuery($query, $params);
+
+ // for each activity insert one target contact
+ // if we load all target contacts the performance will suffer a lot for mass-activities;
+ $query = "
+INSERT INTO {$activityContactTempTable} ( activity_id, contact_id, record_type_id, contact_name, is_deleted, counter )
+SELECT ac.activity_id,
+ ac.contact_id,
+ ac.record_type_id,
+ c.sort_name,
+ c.is_deleted,
+ count(ac.contact_id)
+FROM {$activityTempTable}
+INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id )
+INNER JOIN civicrm_activity_contact ac ON ( ac.activity_id = {$activityTempTable}.activity_id )
+INNER JOIN civicrm_contact c ON c.id = ac.contact_id
+WHERE ac.record_type_id = %1
+GROUP BY ac.activity_id
+";
+
+ CRM_Core_DAO::executeQuery($query, $params);
// step 3: Combine all temp tables to get final query for activity selector
// sort by the original sort order, stored in fixed_sort_order
{$activityContactTempTable}.contact_id,
{$activityContactTempTable}.record_type_id,
{$activityContactTempTable}.contact_name,
- {$activityContactTempTable}.is_deleted
+ {$activityContactTempTable}.is_deleted,
+ {$activityContactTempTable}.counter
FROM {$activityTempTable}
INNER JOIN {$activityContactTempTable} on {$activityTempTable}.activity_id = {$activityContactTempTable}.activity_id
ORDER BY fixed_sort_order
";
-
$dao = CRM_Core_DAO::executeQuery($query);
//CRM-3553, need to check user has access to target groups.
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-
$values = array();
- $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
- $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;
$values[$activityID]['activity_id'] = $dao->activity_id;
if (empty($values[$activityID]['target_contact_name'])) {
$values[$activityID]['target_contact_name'] = array();
+ $values[$activityID]['target_contact_counter'] = $dao->counter;
}
// if deleted, wrap in <del>
$values[$activityID]['case_subject'] = $dao->case_subject;
}
else {
- $values[$activityID]['recipients'] = ts('(recipients)');
+ $values[$activityID]['recipients'] = ts('(%1 recipients)', array(1 => $dao->counter));
$values[$activityID]['mailingId'] = false;
if (
$accessCiviMail &&
* @static
*/
static function &getActivitiesCount($input) {
- // skip bulk activities in activity tab
- $bulkActivityTypeID = CRM_Core_OptionGroup::getValue(
- 'activity_type',
- 'Bulk Email',
- 'name'
- );
- $input['activity_type_exclude_id'][$bulkActivityTypeID] = $bulkActivityTypeID;
-
$input['count'] = TRUE;
list($sqlClause, $params) = self::getActivitySQLClause($input);
* send the message to all the contacts and also insert a
* contact activity in each contacts record
*
- * @param array $contactDetails the array of contact details to send the email
- * @param string $subject the subject of the message
- * @param string $message the message contents
+ * @param array $contactDetails the array of contact details to send the email
+ * @param string $subject the subject of the message
+ * @param $text
+ * @param $html
* @param string $emailAddress use this 'to' email address instead of the default Primary address
- * @param int $userID use this userID if set
+ * @param int $userID use this userID if set
* @param string $from
- * @param array $attachments the array of attachments if any
- * @param string $cc cc recipient
- * @param string $bcc bcc recipient
- * @param array $contactIds contact ids
+ * @param array $attachments the array of attachments if any
+ * @param string $cc cc recipient
+ * @param string $bcc bcc recipient
+ * @param array $contactIds contact ids
* @param string $additionalDetails the additional information of CC and BCC appended to the activity Details
*
+ * @internal param string $message the message contents
* @return array ( sent, activityId) if any email is sent and activityId
* @access public
* @static
return array($sent, $activity->id);
}
+ /**
+ * @param $contactDetails
+ * @param $activityParams
+ * @param array $smsParams
+ * @param $contactIds
+ * @param null $userID
+ *
+ * @return array
+ * @throws CRM_Core_Exception
+ */
static function sendSMS(&$contactDetails,
&$activityParams,
&$smsParams = array(),
/**
* send the sms message to a specific contact
*
- * @param int $toID the contact id of the recipient
- * @param int $activityID the activity ID that tracks the message
- * @param array $smsParams the params used for sending sms
+ * @param int $toID the contact id of the recipient
+ * @param $tokenText
+ * @param $tokenHtml
+ * @param array $smsParams the params used for sending sms
+ *
+ * @param int $activityID the activity ID that tracks the message
+ * @param null $userID
*
* @return mixed true on success or PEAR_Error object
* @access public
/**
* send the message to a specific contact
*
- * @param string $from the name and email of the sender
- * @param int $toID the contact id of the recipient
- * @param string $subject the subject of the message
- * @param string $message the message contents
+ * @param string $from the name and email of the sender
+ * @param $fromID
+ * @param int $toID the contact id of the recipient
+ * @param string $subject the subject of the message
+ * @param $text_message
+ * @param $html_message
* @param string $emailAddress use this 'to' email address instead of the default Primary address
- * @param int $activityID the activity ID that tracks the message
+ * @param int $activityID the activity ID that tracks the message
*
+ * @param null $attachments
+ * @param null $cc
+ * @param null $bcc
+ *
+ * @internal param string $message the message contents
* @return boolean true if successfull else false.
* @access public
* @static
* scheme. Adding weight is super important and should be done in the
* next week or so, before this can be called complete.
*
- * @param NULL
+ * @param bool $status
+ *
+ * @internal param $NULL
*
* @return array array of importable Fields
* @access public
$activityParams['target_contact_id'][] = $activity->contact_id;
}
+ // CRM-14945
+ if (property_exists($activity, 'details')) {
+ $activityParams['details'] = $activity->details;
+ }
//CRM-4027
if ($targetContactID) {
$activityParams['target_contact_id'][] = $targetContactID;
/**
* Function to get total count of prior revision of currently viewd activity
*
- * @param int $activityId current activity id
+ * @param $activityID
+ *
+ * @internal param int $activityId current activity id
*
* @return int $params count of prior activities otherwise false.
* @access public
* Function to get all prior activities of currently viewe
* d activity
*
- * @param int $activityId current activity id
+ * @param $activityID
+ * @param bool $onlyPriorRevisions
+ *
+ * @internal param int $activityId current activity id
*
* @return array $result prior activities info.
* @access public
/**
* Function to find the latest revision of a given activity
*
- * @param int $activityId prior activity id
+ * @param $activityID
+ *
+ * @internal param int $activityId prior activity id
*
* @return int $params current activity id.
* @access public
*
* @activityId int activity id of parent activity
*
- * @param array $activity details
+ * @param $activityId
+ * @param $params
+ *
+ * @return $this|null|object
+ * @internal param array $activity details
*
* @access public
*/
/**
* Function to get Activity specific File according activity type Id.
*
- * @param int $activityTypeId activity id
+ * @param int $activityTypeId activity id
+ *
+ * @param string $crmDir
*
* @return if file exists returns $activityTypeFile activity filename otherwise false.
*
elseif (!empty($values['recipients'])) {
$contactActivities[$activityId]['target_contact'] = $values['recipients'];
}
- elseif (!$values['target_contact_name']) {
- $contactActivities[$activityId]['target_contact'] = '<em>n/a</em>';
- }
- elseif (!empty($values['target_contact_name'])) {
- $count = 0;
- $contactActivities[$activityId]['target_contact'] = '';
+ elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
foreach ($values['target_contact_name'] as $tcID => $tcName) {
- if ($tcID && $count < 5) {
- $contactActivities[$activityId]['target_contact'] .= CRM_Utils_System::href($tcName,
- 'civicrm/contact/view', "reset=1&cid={$tcID}");
- $count++;
- if ($count) {
- $contactActivities[$activityId]['target_contact'] .= "; ";
- }
+ $contactActivities[$activityId]['target_contact'] .= CRM_Utils_System::href($tcName,
+ 'civicrm/contact/view', "reset=1&cid={$tcID}");
+ }
- if ($count == 4) {
- $contactActivities[$activityId]['target_contact'] .= "(" . ts('more') . ")";
- break;
- }
- }
+ if ($extraCount = $values['target_contact_counter'] - 1) {
+ $contactActivities[$activityId]['target_contact'] .= ";<br />" . "(" . ts('%1 more', array(1 => $extraCount)) . ")";
}
}
+ elseif (!$values['target_contact_name']) {
+ $contactActivities[$activityId]['target_contact'] = '<em>n/a</em>';
+ }
if (empty($values['assignee_contact_name'])) {
$contactActivities[$activityId]['assignee_contact'] = '<em>n/a</em>';
* Used to copy custom fields and attachments from an existing activity to another.
* see CRM_Case_Page_AJAX::_convertToCaseActivity() for example
*/
+ /**
+ * @param $params
+ */
static function copyExtendedActivityData($params) {
// attach custom data to the new activity
$customParams = $htmlType = array();
CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $params['activityID'], 'civicrm_activity', $params['mainActivityId']);
}
+ /**
+ * @param $activityId
+ * @param null $recordTypeID
+ * @param string $column
+ *
+ * @return null
+ */
public static function getActivityContact($activityId, $recordTypeID = NULL, $column = 'contact_id') {
$activityContact = new CRM_Activity_BAO_ActivityContact();
$activityContact->activity_id = $activityId;
return NULL;
}
+ /**
+ * @param $activityId
+ *
+ * @return null
+ */
public static function getSourceContactID($activityId) {
static $sourceID = NULL;
if (!$sourceID) {
return self::getActivityContact($activityId, $sourceID);
}
+ /**
+ * @param $params
+ */
function setApiFilter(&$params) {
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$this->selectAdd();