<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
/**
* The _fields var can be used by sub class to set/unset/edit the
* form fields based on their requirement
- *
*/
- function setFields() {
+ public function setFields() {
$this->_fields = array(
'subject' => array(
'type' => 'text',
'type' => 'text',
'label' => ts('Location'),
'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'),
- 'required' => FALSE
+ 'required' => FALSE,
),
'details' => array(
'type' => 'wysiwyg',
'label' => ts('Details'),
// forces a smaller edit window
'attributes' => array('rows' => 4, 'cols' => 60),
- 'required' => FALSE
+ 'required' => FALSE,
),
'status_id' => array(
'type' => 'select',
'source_contact_id' => array(
'type' => 'entityRef',
'label' => ts('Added By'),
- 'required' => FALSE
+ 'required' => FALSE,
),
'target_contact_id' => array(
'type' => 'entityRef',
'label' => ts('With Contact'),
- 'attributes' => array('multiple' => TRUE, 'create' => TRUE)
+ 'attributes' => array('multiple' => TRUE, 'create' => TRUE),
),
'assignee_contact_id' => array(
'type' => 'entityRef',
'label' => ts('Assigned to'),
- 'attributes' => array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0))),
+ 'attributes' => array(
+ 'multiple' => TRUE,
+ 'create' => TRUE,
+ 'api' => array('params' => array('is_deceased' => 0)),
+ ),
),
'followup_assignee_contact_id' => array(
'type' => 'entityRef',
'label' => ts('Assigned to'),
- 'attributes' => array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0))),
+ 'attributes' => array(
+ 'multiple' => TRUE,
+ 'create' => TRUE,
+ 'api' => array('params' => array('is_deceased' => 0)),
+ ),
),
'followup_activity_type_id' => array(
'type' => 'select',
'label' => ts('Subject'),
'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity',
'subject'
- )
- )
+ ),
+ ),
);
if (($this->_context == 'standalone') &&
* Build the form object
*
* @return void
- * @access public
*/
- function preProcess() {
+ public function preProcess() {
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
if ($this->_cdType) {
if ($this->_activityId &&
in_array($this->_action, array(
CRM_Core_Action::UPDATE,
- CRM_Core_Action::VIEW
+ CRM_Core_Action::VIEW,
)) &&
!CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)
) {
// Set title
if (isset($activityTName)) {
$activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
- $this->assign('pageTitle', ts('%1 Activity', array( 1 => $activityName)));
+ $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
if ($this->_currentlyViewedContactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
}
else {
- CRM_Utils_System::setTitle(ts('%1 Activity', array( 1 => $activityName)));
+ CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
}
}
'standalone',
'home',
'dashlet',
- 'dashletFullscreen'
+ 'dashletFullscreen',
))
) {
$urlParams = 'reset=1';
$urlParams .= "&qfKey=$qfKey";
}
$path = CRM_Utils_System::currentPath();
- if ($this->_compContext == 'advanced' ) {
+ if ($this->_compContext == 'advanced') {
$urlString = 'civicrm/contact/search/advanced';
}
elseif ($path == 'civicrm/group/search'
- || $path == 'civicrm/contact/search'
+ || $path == 'civicrm/contact/search'
|| $path == 'civicrm/contact/search/advanced'
|| $path == 'civicrm/contact/search/custom'
- || $path == 'civicrm/group/search') {
+ || $path == 'civicrm/group/search'
+ ) {
$urlString = $path;
}
else {
// figure out the file name for activity type, if any
if ($this->_activityTypeId &&
- $this->_activityTypeFile =
- CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir)
+ $this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir)
) {
$this->assign('activityTypeFile', $this->_activityTypeFile);
$this->assign('crmDir', $this->_crmDir);
* Set default values for the form. For edit/view mode
* the default values are retrieved from the database
*
- * @access public
*
* @return void
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults['source_contact_id'] = $this->_sourceContactId;
$defaults['target_contact_id'] = $this->_targetContactId;
- list($defaults['activity_date_time'], $defaults['activity_date_time_time']) =
- CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
+ list($defaults['activity_date_time'], $defaults['activity_date_time_time'])
+ = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
}
if ($this->_activityTypeId) {
'type' => 'next',
'name' => $button,
'spacing' => ' ',
- 'isDefault' => TRUE
+ 'isDefault' => TRUE,
),
array(
'type' => 'cancel',
- 'name' => ts('Cancel')
- )
+ 'name' => ts('Cancel'),
+ ),
));
return;
}
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
- $element = & $this->add('select', 'activity_type_id', ts('Activity Type'),
+ $element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
$this->_fields['followup_activity_type_id']['attributes'],
FALSE, array(
'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
CRM_Campaign_BAO_Campaign::accessCampaign()
) {
$buildEngagementLevel = TRUE;
- $this->addSelect('engagement_level',array('entity' => 'activity'));
+ $this->addSelect('engagement_level', array('entity' => 'activity'));
$this->addRule('engagement_level',
ts('Please enter the engagement index as a number (integers only).'),
'positiveInteger'
$buttons = array();
$buttons[] = array(
'type' => 'cancel',
- 'name' => ts('Done')
+ 'name' => ts('Done'),
);
$this->addButtons($buttons);
}
'type' => 'upload',
'name' => ts('Save'),
'js' => $js,
- 'isDefault' => TRUE
+ 'isDefault' => TRUE,
),
array(
'type' => 'cancel',
- 'name' => ts('Cancel')
- )
+ 'name' => ts('Cancel'),
+ ),
)
);
}
/**
* Global form rule
*
- * @param array $fields the input form values
- * @param array $files the uploaded files if any
+ * @param array $fields
+ * The input form values.
+ * @param array $files
+ * The uploaded files if any.
* @param $self
*
- * @return true if no errors, else array of errors
- * @access public
- * @static
+ * @return bool|array
+ * true if no errors, else array of errors
*/
- static function formRule($fields, $files, $self) {
+ public static function formRule($fields, $files, $self) {
// skip form rule if deleting
if (CRM_Utils_Array::value('_qf_Activity_next_', $fields) == 'Delete') {
return TRUE;
/**
* Process the form submission
*
- * @access public
*
* @param array $params
* @return array|null
// delete tags for the entity
$tagParams = array(
'entity_table' => 'civicrm_activity',
- 'entity_id' => $this->_activityId
+ 'entity_id' => $this->_activityId,
);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."), ts('Record Deleted'), 'success');
- return;
+ return NULL;
}
// store the submitted values in an array
$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']);
- }
- if (property_exists($scheduleReminderDetails, 'id')) {
- $params['schedule_reminder_id'] = $scheduleReminderDetails->id;
+ $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';
+ $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']);
+ }
+ if (property_exists($scheduleReminderDetails, 'id')) {
+ $params['schedule_reminder_id'] = $scheduleReminderDetails->id;
+ }
}
- }
- $params['dateColumns'] = array('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
*
- * @param array $params associated array of submitted values
+ * @param array $params
+ * Associated array of submitted values.
*
- * @return $this|null|object
- * @access protected
+ * @return self|null|object
*/
protected function processActivity(&$params) {
$activityAssigned = array();
$mailStatus = '';
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'activity_assignee_notification')) {
+ 'activity_assignee_notification')
+ ) {
$activityIDs = array($activity->id);
if ($followupActivity) {
$activityIDs = array_merge($activityIDs, array($followupActivity->id));
array(
1 => $subject,
2 => $followupStatus,
- 3 => $mailStatus
+ 3 => $mailStatus,
)
), ts('Saved'), 'success');
/**
* Shorthand for getting id by display name (makes code more readable)
- *
- * @access protected
+ * @param $displayName
+ * @return null|string
*/
protected function _getIdByDisplayName($displayName) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
/**
* Shorthand for getting display name by id (makes code more readable)
- *
- * @access protected
+ * @param $id
+ * @return null|string
*/
protected function _getDisplayNameById($id) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
*
* @param array $params
*/
- function beginPostProcess(&$params) {
+ public function beginPostProcess(&$params) {
if ($this->_activityTypeFile) {
$className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
$className::beginPostProcess($this, $params);
* @param array $params
* @param $activity
*/
- function endPostProcess(&$params, &$activity) {
+ public function endPostProcess(&$params, &$activity) {
if ($this->_activityTypeFile) {
$className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
$className::endPostProcess($this, $params, $activity);
}
}
-}
+}