$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
- CRM_Core_Error::fatal('ufGroupId is missing');
+ throw new CRM_Core_Exception('The profile id is missing');
}
$this->_title = ts('Update multiple activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
- if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
+ if (CRM_Core_BAO_CustomField::getKeyID($name) &&
in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
) {
$suppressFields = TRUE;
}
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
+ // It is possible to have fields that are required in CiviCRM not be required in the
+ // profile. Overriding that here. Perhaps a better approach would be to
+ // make them required in the schema & read that up through getFields functionality.
+ $requiredFields = array('activity_date_time');
foreach ($this->_activityHolderIds as $activityId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
}
else {
// Handle non custom fields.
+ if (in_array($field['name'], $requiredFields)) {
+ $field['is_required'] = TRUE;
+ }
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
}
);
$value['id'] = $key;
- if (!empty($value['activity_date_time'])) {
- $value['activity_date_time'] = CRM_Utils_Date::processDate($value['activity_date_time'], $value['activity_date_time_time']);
- }
-
if (!empty($value['activity_status_id'])) {
$value['status_id'] = $value['activity_status_id'];
}
$value['details'] = $value['activity_details'];
}
- if (!empty($value['activity_duration'])) {
- $value['duration'] = $value['activity_duration'];
- }
-
if (!empty($value['activity_location'])) {
$value['location'] = $value['activity_location'];
}
$value['subject'] = $value['activity_subject'];
}
- $query = "
-SELECT a.activity_type_id, ac.contact_id
-FROM civicrm_activity a
-JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id
-AND ac.record_type_id = %2 )
-WHERE a.id = %1 ";
- $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
- $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
- $params = array(1 => array($key, 'Integer'), 2 => array($sourceID, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $dao->fetch();
-
- // Get Activity Type ID
- $value['activity_type_id'] = $dao->activity_type_id;
-
- // Get Conatct ID
- $value['source_contact_id'] = $dao->contact_id;
-
- // make call use API 3
- $value['version'] = 3;
-
- $activityId = civicrm_api('activity', 'update', $value);
+ $activityId = civicrm_api3('activity', 'create', $value);
- // add custom field values
+ // @todo this would be done by the api call above if the parames were passed through.
if (!empty($value['custom']) &&
is_array($value['custom'])
) {
'activity_subject' => 'Test Meeting',
'activity_details' => 'a test activity details',
'activity_duration' => '100',
- 'activity_date_time' => '03/08/2010',
+ 'activity_date_time' => '2010-03-08 00:00:00',
'activity_status_id' => '2',
);
$profileParams = array_merge($params, $updateParams);
'assignee_contact_id' => $contactId,
'activity_type_id' => '1',
'subject' => 'Make-it-Happen Meeting',
- 'activity_date_time' => '20110316',
+ 'activity_date_time' => '2011-03-16 00:00:00',
'duration' => '120',
'location' => 'Pensulvania',
'details' => 'a test activity',
'activity_subject' => 'Make-it-Happen Meeting',
'activity_details' => 'a test activity',
'activity_duration' => '120',
- 'activity_date_time_time' => '12:00AM',
- 'activity_date_time' => '03/16/2011',
+ 'activity_date_time' => '2011-03-16 00:00:00',
'activity_status_id' => '1',
);