X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FActivity%2FBAO%2FActivity.php;h=efb8f57d1e37de28458c5c98b7d895c8a91c8a8c;hb=a335f6b228626e3e1b2f1549c8ddcbb9232b3c6b;hp=bb82e6eecd6f3f17f9fe64f5dbeb821cfcb4aa06;hpb=694db87e53f020b73e782f66fed8f7e51eea369b;p=civicrm-core.git diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index bb82e6eecd..efb8f57d1e 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -40,7 +40,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { /** - * static field for all the activity information that we can potentially export + * Static field for all the activity information that we can potentially export * * @var array * @static @@ -48,7 +48,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { static $_exportableFields = NULL; /** - * static field for all the activity information that we can potentially import + * Static field for all the activity information that we can potentially import * * @var array * @static @@ -71,18 +71,12 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } /** - * Takes a bunch of params that are needed to match certain criteria and - * retrieves the relevant objects. Typically the valid params are only - * contact_id. We'll tweak this function to be more full featured over a period - * of time. This is the inverse function of create. It also stores all the retrieved - * values in the default array + * 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 * - * @internal param string $activityType activity type - * - * @return object CRM_Core_BAO_Meeting object + * @return CRM_Activity_DAO_Activity object * @access public */ public static function retrieve(&$params, &$defaults) { @@ -146,10 +140,9 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } /** - * Function to delete the activity + * Delete the activity * * @param array $params associated array - * * @param bool $moveToTrash * * @return void @@ -256,10 +249,8 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { /** * Delete activity assignment record * - * @param $activityId - * @param null $recordTypeID - * - * @internal param int $id activity id + * @param int $activityId + * @param int $recordTypeID * * @return null * @access public @@ -274,15 +265,11 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } /** - * Function to process the activities + * Process the activities * * @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 - * @internal param bool $record true if it is Record Activity * @access public * * @return $this|null|object @@ -656,7 +643,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } /** - * function to get the list Activities + * Get the list Activities * * @param array $input array of parameters * Keys include @@ -794,12 +781,13 @@ SELECT ac.activity_id, c.sort_name, c.is_deleted FROM {$activityTempTable} -INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id AND a.activity_type_id != {$bulkActivityTypeID} ) +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; @@ -812,13 +800,13 @@ SELECT ac.activity_id, c.is_deleted, count(ac.contact_id) FROM {$activityTempTable} -INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id AND a.activity_type_id = {$bulkActivityTypeID} ) +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 "; - $params = array(1 => array($targetID, 'Integer')); + CRM_Core_DAO::executeQuery($query, $params); // step 3: Combine all temp tables to get final query for activity selector @@ -829,9 +817,11 @@ SELECT {$activityTempTable}.*, {$activityContactTempTable}.record_type_id, {$activityContactTempTable}.contact_name, {$activityContactTempTable}.is_deleted, - {$activityContactTempTable}.counter + {$activityContactTempTable}.counter, + re.parent_id as is_recurring_activity FROM {$activityTempTable} INNER JOIN {$activityContactTempTable} on {$activityTempTable}.activity_id = {$activityContactTempTable}.activity_id +LEFT JOIN civicrm_recurring_entity re on {$activityContactTempTable}.activity_id = re.entity_id ORDER BY fixed_sort_order "; @@ -858,6 +848,7 @@ ORDER BY fixed_sort_order $values[$activityID]['status_id'] = $dao->status_id; $values[$activityID]['subject'] = $dao->subject; $values[$activityID]['campaign_id'] = $dao->campaign_id; + $values[$activityID]['is_recurring_activity'] = $dao->is_recurring_activity; if ($dao->campaign_id) { $values[$activityID]['campaign'] = $allCampaigns[$dao->campaign_id]; @@ -869,6 +860,7 @@ ORDER BY fixed_sort_order if (empty($values[$activityID]['target_contact_name'])) { $values[$activityID]['target_contact_name'] = array(); + $values[$activityID]['target_contact_counter'] = $dao->counter; } // if deleted, wrap in @@ -914,7 +906,7 @@ ORDER BY fixed_sort_order * user has permission. To decide whether we are going to include * component related activities w/ core activity retrieve process. * - * return an array of component id and name. + * @return array of component id and name. * @static **/ static function activityComponents() { @@ -943,7 +935,7 @@ ORDER BY fixed_sort_order } /** - * function to get the activity Count + * Get the activity Count * * @param array $input array of parameters * Keys include @@ -979,7 +971,7 @@ LEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.a } /** - * function to get the activity sql clause to pick activities + * Get the activity sql clause to pick activities * * @param array $input array of parameters * Keys include @@ -1159,7 +1151,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND } /** - * send the message to all the contacts and also insert a + * 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 @@ -1175,7 +1167,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND * @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 @@ -1364,11 +1355,11 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND } /** - * @param $contactDetails - * @param $activityParams + * @param array $contactDetails + * @param array $activityParams * @param array $smsParams * @param $contactIds - * @param null $userID + * @param int $userID * * @return array * @throws CRM_Core_Exception @@ -1384,16 +1375,12 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $userID = $session->get('userID'); } - $text = &$activityParams['text_message']; - $html = &$activityParams['html_message']; + $text = &$activityParams['sms_text_message']; // CRM-4575 // token replacement of addressee/email/postal greetings // get the tokens added in subject and message $messageToken = CRM_Utils_Token::getTokens($text); - $messageToken = array_merge($messageToken, - CRM_Utils_Token::getTokens($html) - ); //create the meta level record first ( sms activity ) $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', @@ -1401,13 +1388,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND 'name' ); - // CRM-6265: save both text and HTML parts in details (if present) - if ($html and $text) { - $details = "-ALTERNATIVE ITEM 0-\n$html\n-ALTERNATIVE ITEM 1-\n$text\n-ALTERNATIVE END-\n"; - } - else { - $details = $html ? $html : $text; - } + $details = $text; $activitySubject = $activityParams['activity_subject']; $activityParams = array( @@ -1463,9 +1444,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $tokenText = CRM_Utils_Token::replaceContactTokens($text, $values, FALSE, $messageToken, FALSE, $escapeSmarty); $tokenText = CRM_Utils_Token::replaceHookTokens($tokenText, $values, $categories, FALSE, $escapeSmarty); - $tokenHtml = CRM_Utils_Token::replaceContactTokens($html, $values, TRUE, $messageToken, FALSE, $escapeSmarty); - $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $values, $categories, TRUE, $escapeSmarty); - // Only send if the phone is of type mobile $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name'); if ($values['phone_type_id'] == CRM_Utils_Array::value('Mobile', $phoneTypes)) { @@ -1478,7 +1456,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $sendResult = self::sendSMSMessage( $contactId, $tokenText, - $tokenHtml, $smsParams, $activityID, $userID @@ -1507,15 +1484,14 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND } /** - * send the sms message to a specific contact + * Send the sms message to a specific contact * * @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 + * @param int $userID * * @return mixed true on success or PEAR_Error object * @access public @@ -1523,7 +1499,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND */ static function sendSMSMessage($toID, &$tokenText, - &$tokenHtml, $smsParams = array(), $activityID, $userID = null @@ -1556,13 +1531,12 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND ); } - $message = $tokenHtml ? $tokenHtml : $tokenText; $recipient = $smsParams['To']; $smsParams['contact_id'] = $toID; $smsParams['parent_activity_id'] = $activityID; $providerObj = CRM_SMS_Provider::singleton(array('provider_id' => $smsParams['provider_id'])); - $sendResult = $providerObj->send($recipient, $smsParams, $message, NULL, $userID); + $sendResult = $providerObj->send($recipient, $smsParams, $tokenText, NULL, $userID); if (PEAR::isError($sendResult)) { return $sendResult; } @@ -1583,22 +1557,20 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND } /** - * send the message to a specific contact + * Send the message to a specific contact * * @param string $from the name and email of the sender - * @param $fromID + * @param int $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 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 @@ -1663,7 +1635,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND } /** - * combine all the importable fields from the lower levels object + * Combine all the importable fields from the lower levels object * * The ordering is important, since currently we do not have a weight * scheme. Adding weight is super important and should be done in the @@ -1671,8 +1643,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND * * @param bool $status * - * @internal param $NULL - * * @return array array of importable Fields * @access public * @static @@ -1725,8 +1695,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND /** * To get the Activities of a target contact * - * @param $contactId Integer ContactId of the contact whose activities - * need to find + * @param int $contactId Id of the contact whose activities need to find * * @return array array of activity fields * @access public @@ -1797,13 +1766,11 @@ WHERE activity.id IN ($activityIds)"; } /** - * Function to add activity for Membership/Event/Contribution + * Add activity for Membership/Event/Contribution * * @param object $activity (reference) particular component object * @param string $activityType for Membership Signup or Renewal - * - * - * @param null $targetContactID + * @param int $targetContactID * * @return bool * @static @@ -1837,7 +1804,7 @@ SELECT display_name $subject .= " (by {$displayName})"; } - $subject .= " - Status: " . CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $activity->status_id); + $subject .= " - Status: " . CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $activity->status_id, 'label'); // CRM-72097 changed from start date to today $date = date('YmdHis'); $component = 'Membership'; @@ -1917,7 +1884,7 @@ SELECT display_name } /** - * Function to get Parent activity for currently viewed activity + * Get Parent activity for currently viewed activity * * @param int $activityId current activity id * @@ -1944,11 +1911,9 @@ SELECT display_name } /** - * Function to get total count of prior revision of currently viewd activity - * - * @param $activityID + * Get total count of prior revision of currently viewd activity * - * @internal param int $activityId current activity id + * @param $activityID current activity id * * @return int $params count of prior activities otherwise false. * @access public @@ -1983,14 +1948,11 @@ AND id < {$activityID} } /** - * Function to get all prior activities of currently viewe - * d activity + * Get all prior activities of currently viewed activity * - * @param $activityID + * @param $activityID current activity id * @param bool $onlyPriorRevisions * - * @internal param int $activityId current activity id - * * @return array $result prior activities info. * @access public */ @@ -2036,13 +1998,11 @@ AND cl.modified_id = c.id } /** - * Function to find the latest revision of a given activity + * Find the latest revision of a given activity * - * @param $activityID + * @param int $activityID prior activity id * - * @internal param int $activityId prior activity id - * - * @return int $params current activity id. + * @return int current activity id. * @access public */ static function getLatestActivityId($activityID) { @@ -2070,15 +2030,12 @@ AND cl.modified_id = c.id } /** - * Function to create a follow up a given activity - * - * @activityId int activity id of parent activity + * Create a follow up a given activity * - * @param $activityId - * @param $params + * @param $activityId int activity id of parent activity + * @param array $params * * @return $this|null|object - * @internal param array $activity details * * @access public */ @@ -2113,13 +2070,12 @@ AND cl.modified_id = c.id } /** - * Function to get Activity specific File according activity type Id. + * Get Activity specific File according activity type Id. * * @param int $activityTypeId activity id - * * @param string $crmDir * - * @return if file exists returns $activityTypeFile activity filename otherwise false. + * @return string|bool if file exists returns $activityTypeFile activity filename otherwise false. * * @static */ @@ -2148,7 +2104,7 @@ AND cl.modified_id = c.id } /** - * Function to restore the activity + * Restore the activity * * @param array $params associated array * @@ -2308,7 +2264,7 @@ AND cl.modified_id = c.id } /** - * Does user has sufficient permission for view/edit activity record. + * Does user has sufficient permission for view/edit activity record? * * @param int $activityId activity record id. * @param int $action edit/view @@ -2516,28 +2472,19 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n elseif (!empty($values['recipients'])) { $contactActivities[$activityId]['target_contact'] = $values['recipients']; } - elseif (!$values['target_contact_name']) { - $contactActivities[$activityId]['target_contact'] = 'n/a'; - } - 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'] .= ";
" . "(" . ts('%1 more', array(1 => $extraCount)) . ")"; } } + elseif (!$values['target_contact_name']) { + $contactActivities[$activityId]['target_contact'] = 'n/a'; + } if (empty($values['assignee_contact_name'])) { $contactActivities[$activityId]['assignee_contact'] = 'n/a'; @@ -2605,18 +2552,19 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n 'Activity', $values['activity_id'] ); + + $contactActivities[$activityId]['is_recurring_activity'] = $values['is_recurring_activity']; } } return $contactActivities; } - /* - * Used to copy custom fields and attachments from an existing activity to another. - * see CRM_Case_Page_AJAX::_convertToCaseActivity() for example - */ /** - * @param $params + * Used to copy custom fields and attachments from an existing activity to another. + * @see CRM_Case_Page_AJAX::_convertToCaseActivity() for example + * + * @param array $params */ static function copyExtendedActivityData($params) { // attach custom data to the new activity @@ -2656,8 +2604,8 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n } /** - * @param $activityId - * @param null $recordTypeID + * @param int $activityId + * @param int $recordTypeID * @param string $column * * @return null @@ -2675,7 +2623,7 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n } /** - * @param $activityId + * @param int $activityId * * @return null */ @@ -2690,7 +2638,7 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n } /** - * @param $params + * @param array $params */ function setApiFilter(&$params) { if (CRM_Utils_Array::value('target_contact_id', $params)) {