+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
public $_activityId;
/**
- * Store activity ids when multiple activities are created
+ * Store activity ids when multiple activities are created.
*
* @var int
*/
public $_activityIds = array();
/**
- * The id of activity type
+ * The id of activity type.
*
* @var int
*/
public $_activityTypeId;
/**
- * The name of activity type
+ * The name of activity type.
*
* @var string
*/
public $_activityTypeName;
/**
- * The id of currently viewed contact
+ * The id of currently viewed contact.
*
* @var int
*/
public $_currentlyViewedContactId;
/**
- * The id of source contact and target contact
+ * The id of source contact and target contact.
*
* @var int
*/
public $_currentUserId;
/**
- * The array of form field attributes
+ * The array of form field attributes.
*
* @var array
*/
protected $_crmDir = 'Activity';
/**
- * Survey activity
+ * Survey activity.
*
* @var boolean
*/
protected $unsavedWarn = TRUE;
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'Activity';
+ }
+
/**
* The _fields var can be used by sub class to set/unset/edit the
* form fields based on their requirement
}
/**
- * Build the form object
+ * Build the form object.
*
* @return void
*/
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
- $defaults = $this->_values;
+ $defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues();
// if we're editing...
if (isset($this->_activityId)) {
if (empty($defaults['activity_date_time'])) {
$defaults['activity_date_time_time']
) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
- $recurringEntityDefaults = array();
- $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
- $defaults = array_merge($defaults, $recurringEntityDefaults);
}
if ($this->_context != 'standalone') {
$this->assign('suppressForm', FALSE);
$element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
- $this->_fields['followup_activity_type_id']['attributes'],
+ array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'],
FALSE, array(
'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
- 'class' => 'crm-select2',
+ 'class' => 'crm-select2 required',
)
);
}
/**
- * Global form rule
+ * Global form rule.
*
* @param array $fields
* The input form values.
return TRUE;
}
$errors = array();
- if (!$self->_single && !$fields['activity_type_id']) {
+ if ((array_key_exists('activity_type_id', $fields) || !$self->_single) && empty($fields['activity_type_id'])) {
$errors['activity_type_id'] = ts('Activity Type is a required field');
}
- //Activity type is mandatory if creating new activity, CRM-4515
- if (array_key_exists('activity_type_id', $fields) && empty($fields['activity_type_id'])) {
- $errors['activity_type_id'] = ts('Activity Type is required field.');
- }
-
if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
CRM_Utils_Array::value('status_id', $fields) == 1
) {
}
/**
- * Process the form submission
+ * Process the form submission.
*
*
* @param array $params
$activity = $this->processActivity($params);
}
- //Set for repeat configuration in create mode
- $params['entity_id'] = $this->_activityId;
- $params['entity_table'] = 'civicrm_activity';
- $scheduleReminderDetails = array();
- if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
- $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
- if ($checkParentExistsForThisId) {
- $params['parent_entity_id'] = $checkParentExistsForThisId;
- $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']);
- }
- else {
- $params['parent_entity_id'] = $params['entity_id'];
- $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']);
+ $activityIds = empty($this->_activityIds) ? array($this->_activityId) : $this->_activityIds;
+ foreach ($activityIds as $activityId) {
+ // set params for repeat configuration in create mode
+ $params['entity_id'] = $activityId;
+ $params['entity_table'] = 'civicrm_activity';
+ if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
+ $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
+ if ($checkParentExistsForThisId) {
+ $params['parent_entity_id'] = $checkParentExistsForThisId;
+ $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']);
+ }
+ else {
+ $params['parent_entity_id'] = $params['entity_id'];
+ $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']);
+ }
+ if (property_exists($scheduleReminderDetails, 'id')) {
+ $params['schedule_reminder_id'] = $scheduleReminderDetails->id;
+ }
}
- if (property_exists($scheduleReminderDetails, 'id')) {
- $params['schedule_reminder_id'] = $scheduleReminderDetails->id;
+ $params['dateColumns'] = array('activity_date_time');
+
+ // Set default repetition start if it was not provided.
+ if (empty($params['repetition_start_date'])) {
+ $params['repetition_start_date'] = $params['activity_date_time'];
}
- }
- $params['dateColumns'] = array('activity_date_time');
- //Unset activity id
- unset($params['id']);
- $linkedEntities = array(
- array(
- 'table' => 'civicrm_activity_contact',
- 'findCriteria' => array(
- 'activity_id' => $this->_activityId,
+ // unset activity id
+ unset($params['id']);
+ $linkedEntities = array(
+ array(
+ 'table' => 'civicrm_activity_contact',
+ 'findCriteria' => array(
+ 'activity_id' => $activityId,
+ ),
+ 'linkedColumns' => array('activity_id'),
+ 'isRecurringEntityRecord' => FALSE,
),
- 'linkedColumns' => array('activity_id'),
- 'isRecurringEntityRecord' => FALSE,
- ),
- );
- CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities);
+ );
+ CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities);
+ }
return array('activity' => $activity);
}
/**
- * Process activity creation
+ * Process activity creation.
*
* @param array $params
* Associated array of submitted values.
}
/**
- * Let injecting activity type file do any processing
+ * Let injecting activity type file do any processing.
* needed, before the activity is added/updated
*
* @param array $params