if (isset($params['source_contact_id'])) {
$acParams = array(
'activity_id' => $activityId,
- 'contact_id' => $params['source_contact_id'],
+ 'contact_id' => $params['source_contact_id'],
'record_type_id' => $sourceID
);
self::deleteActivityContact($activityId, $sourceID);
}
while (!empty($values)) {
$input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
- $str = implode(',', $input);
- $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;";
+ $str = implode(',', $input);
+ $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;";
CRM_Core_DAO::executeQuery($sql);
}
}
if (is_array($params['target_contact_id'])) {
if (CRM_Utils_Array::value('deleteActivityTarget', $params, TRUE)) {
// first delete existing targets if any
- self::deleteActivityContact($activityId, $targetID );
+ self::deleteActivityContact($activityId, $targetID);
}
$values = array();
while (!empty($values)) {
$input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
- $str = implode(',', $input);
- $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;";
+ $str = implode(',', $input);
+ $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;";
CRM_Core_DAO::executeQuery($sql);
}
}
}
else {
if (CRM_Utils_Array::value('deleteActivityTarget', $params, TRUE)) {
- self::deleteActivityContact($activityId, $targetID );
+ self::deleteActivityContact($activityId, $targetID);
}
}
}
else {
// at worst, take source for recently viewed display
- $recentContactId = CRM_Utils_Array::value('source_contact_id',$params);
+ $recentContactId = CRM_Utils_Array::value('source_contact_id', $params);
}
if (isset($params['assignee_contact_id'])) {
// if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916)
$matches = array();
if (preg_match('/\[case #([0-9a-h]{7})\]/', CRM_Utils_Array::value('subject', $params), $matches)) {
- $key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY);
- $hash = $matches[1];
- $query = "SELECT id FROM civicrm_case WHERE SUBSTR(SHA1(CONCAT('$key', id)), 1, 7) = '$hash'";
+ $key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY);
+ $hash = $matches[1];
+ $query = "SELECT id FROM civicrm_case WHERE SUBSTR(SHA1(CONCAT('$key', id)), 1, 7) = '$hash'";
$caseParams = array(
'activity_id' => $activity->id,
'case_id' => CRM_Core_DAO::singleValueQuery($query),
if (!$id) {
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
- $id = self::getActivityContact($activity->id. $sourceID);
+ $id = self::getActivityContact($activity->id . $sourceID);
}
$logParams = array(
'entity_table' => 'civicrm_activity',
}
// if deleted, wrap in <del>
- if ( $dao->is_deleted ) {
+ if ($dao->is_deleted) {
$dao->contact_name = "<del>{$dao->contact_name}</dao>";
}
- if ($dao->record_type_id == $sourceID && $dao->contact_id) {
+ if ($dao->record_type_id == $sourceID && $dao->contact_id) {
$values[$activityID]['source_contact_id'] = $dao->contact_id;
$values[$activityID]['source_contact_name'] = $dao->contact_name;
}
$values[$activityID]['case_subject'] = $dao->case_subject;
}
else {
- $values[$activityID]['recipients'] = ts('(%1 recipients)', array(1 => $dao->counter));
- $values[$activityID]['mailingId'] = false;
+ $values[$activityID]['recipients'] = ts('(%1 recipients)', array(1 => $dao->counter));
+ $values[$activityID]['mailingId'] = FALSE;
if (
$accessCiviMail &&
($mailingIDs === TRUE || in_array($dao->source_record_id, $mailingIDs))
) {
- $values[$activityID]['mailingId'] = true;
+ $values[$activityID]['mailingId'] = TRUE;
}
}
}
$config = CRM_Core_Config::singleton();
if (!CRM_Utils_Array::value('admin', $input, FALSE)) {
- $sourceWhere = ' ac.contact_id = %1 ';
- $caseWhere = ' civicrm_case_contact.contact_id = %1 ';
+ $sourceWhere = ' ac.contact_id = %1 ';
+ $caseWhere = ' civicrm_case_contact.contact_id = %1 ';
$params = array(1 => array($input['contact_id'], 'Integer'));
}
&$text,
&$html,
$emailAddress,
- $userID = NULL,
- $from = NULL,
+ $userID = NULL,
+ $from = NULL,
$attachments = NULL,
- $cc = NULL,
- $bcc = NULL,
+ $cc = NULL,
+ $bcc = NULL,
$contactIds, // FIXME a param with no default shouldn't be last
$additionalDetails = NULL
) {
$smarty->assign_by_ref('contact', $values);
$tokenSubject = $smarty->fetch("string:$tokenSubject");
- $tokenText = $smarty->fetch("string:$tokenText");
- $tokenHtml = $smarty->fetch("string:$tokenHtml");
+ $tokenText = $smarty->fetch("string:$tokenText");
+ $tokenHtml = $smarty->fetch("string:$tokenHtml");
}
$sent = FALSE;
if (self::sendMessage(
- $from,
- $userID,
- $contactId,
- $tokenSubject,
- $tokenText,
- $tokenHtml,
- $emailAddress,
- $activity->id,
- $attachments,
- $cc,
- $bcc
- )) {
+ $from,
+ $userID,
+ $contactId,
+ $tokenSubject,
+ $tokenText,
+ $tokenHtml,
+ $emailAddress,
+ $activity->id,
+ $attachments,
+ $cc,
+ $bcc
+ )
+ ) {
$sent = TRUE;
}
}
* @return array
* @throws CRM_Core_Exception
*/
- static function sendSMS(&$contactDetails,
+ static function sendSMS(
+ &$contactDetails,
&$activityParams,
&$smsParams = array(),
&$contactIds,
if (PEAR::isError($sendResult)) {
// Collect all of the PEAR_Error objects
$errMsgs[] = $sendResult;
- } else {
+ }
+ else {
$success++;
}
}
$sent = FALSE;
if ($success > 0 && count($errMsgs) == 0) {
$sent = TRUE;
- } elseif (count($errMsgs) > 0) {
+ }
+ elseif (count($errMsgs) > 0) {
$sent = $errMsgs;
}
* @return mixed true on success or PEAR_Error object
* @static
*/
- static function sendSMSMessage($toID,
+ static function sendSMSMessage(
+ $toID,
&$tokenText,
$smsParams = array(),
$activityID,
- $userID = null
+ $userID = NULL
) {
$toDoNotSms = "";
$toPhoneNumber = "";
if (empty($toPhoneNumber) or $toDoNotSms) {
return PEAR::raiseError(
'Recipient phone number is invalid or recipient does not want to receive SMS',
- null,
+ NULL,
PEAR_ERROR_RETURN
);
}
// add activity target record for every sms that is send
$activityTargetParams = array(
'activity_id' => $activityID,
- 'contact_id' => $toID,
+ 'contact_id' => $toID,
'record_type_id' => $targetID
);
CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
* @return boolean true if successfull else false.
* @static
*/
- static function sendMessage($from,
+ static function sendMessage(
+ $from,
$fromID,
$toID,
&$subject,
$emailAddress,
$activityID,
$attachments = NULL,
- $cc = NULL,
- $bcc = NULL
+ $cc = NULL,
+ $bcc = NULL
) {
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($toID);
if ($emailAddress) {
// Using new Dedupe rule.
$ruleParams = array(
'contact_type' => 'Individual',
- 'used' => 'Unsupervised',
+ 'used' => 'Unsupervised',
);
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
- if ($dao->record_type_id == $targetID ) {
+ if ($dao->record_type_id == $targetID) {
$activities[$dao->activity_id]['targets'][$contactId] = $contactId;
}
else if ($dao->record_type_id == $assigneeID) {
* @return bool
* @static
*/
- static function addActivity(&$activity,
+ static function addActivity(
+ &$activity,
$activityType = 'Membership Signup',
$targetContactID = NULL
) {
'case_activity_subject' => array('title' => ts('Activity Subject'), 'type' => CRM_Utils_Type::T_STRING),
'case_source_contact_id' => array('title' => ts('Activity Reporter'), 'type' => CRM_Utils_Type::T_STRING),
'case_recent_activity_date' => array('title' => ts('Activity Actual Date'), 'type' => CRM_Utils_Type::T_DATE),
- 'case_scheduled_activity_date' => array('title' => ts('Activity Scheduled Date'), 'type' => CRM_Utils_Type::T_DATE),
+ 'case_scheduled_activity_date' => array(
+ 'title' => ts('Activity Scheduled Date'),
+ 'type' => CRM_Utils_Type::T_DATE
+ ),
'case_recent_activity_type' => array('title' => ts('Activity Type'), 'type' => CRM_Utils_Type::T_STRING),
'case_activity_status' => array('title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_STRING),
'case_activity_duration' => array('title' => ts('Activity Duration'), 'type' => CRM_Utils_Type::T_INT),
'case_activity_medium_id' => array('title' => ts('Activity Medium'), 'type' => CRM_Utils_Type::T_INT),
'case_activity_details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT),
- 'case_activity_is_auto' => array('title' => ts('Activity Auto-generated?'), 'type' => CRM_Utils_Type::T_BOOLEAN),
+ 'case_activity_is_auto' => array(
+ 'title' => ts('Activity Auto-generated?'),
+ 'type' => CRM_Utils_Type::T_BOOLEAN
+ ),
);
// add custom data for cases
$activityContactOther->activity_id = $activityContact->activity_id;
// delete activity only if no other contacts connected
- if ( ! $activityContactOther->find(TRUE) ) {
+ if (!$activityContactOther->find(TRUE)) {
$activityParams = array('id' => $activityContact->activity_id);
$result = self::deleteActivity($activityParams);
}
//component related permissions.
$compPermissions = array(
- 'CiviCase' => array('administer CiviCase',
+ 'CiviCase' => array(
+ 'administer CiviCase',
'access my cases and activities',
'access all cases and activities',
),
FROM civicrm_option_value val
INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.name = %1 )
WHERE val.value = %2";
- $params = array(1 => array('activity_type', 'String'),
+ $params = array(
+ 1 => array('activity_type', 'String'),
2 => array($activity->activity_type_id, 'Integer'),
);
$componentId = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$componentId || $allow) {
$sourceContactId = self::getActivityContact($activity->id, $sourceID);
//account for possibility of activity not having a source contact (as it may have been deleted)
- if ( $sourceContactId ) {
+ if ($sourceContactId) {
$allow = CRM_Contact_BAO_Contact_Permission::allow($sourceContactId, $permission);
}
}
*/
public static function getContactActivitySelector(&$params) {
// format the params
- $params['offset'] = ($params['page'] - 1) * $params['rp'];
+ $params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
- $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
- $params['caseId'] = NULL;
- $context = CRM_Utils_Array::value('context', $params);
+ $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
+ $params['caseId'] = NULL;
+ $context = CRM_Utils_Array::value('context', $params);
// get contact activities
$activities = CRM_Activity_BAO_Activity::getActivities($params);
if (!empty($customValues)) {
$fieldIds = implode(', ', array_keys($customValues));
- $sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )";
- $result = CRM_Core_DAO::executeQuery($sql);
+ $sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )";
+ $result = CRM_Core_DAO::executeQuery($sql);
while ($result->fetch()) {
$htmlType[] = $result->id;