First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
256
sites/all/modules/civicrm/CRM/Event/Form/Task/AddToGroup.php
Normal file
256
sites/all/modules/civicrm/CRM/Event/Form/Task/AddToGroup.php
Normal file
|
@ -0,0 +1,256 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to group
|
||||
* contacts. This class provides functionality for the actual
|
||||
* addition of contacts to groups.
|
||||
*/
|
||||
class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* The context that we are working on.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context;
|
||||
|
||||
/**
|
||||
* The groupId retrieved from the GET vars.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
// initialize the task and row fields
|
||||
parent::preProcess();
|
||||
|
||||
parent::setContactIDs();
|
||||
$this->_context = $this->get('context');
|
||||
$this->_id = $this->get('amtgID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
//create radio buttons to select existing group or add a new group
|
||||
$options = array(ts('Add Contact To Existing Group'), ts('Create New Group'));
|
||||
|
||||
if (!$this->_id) {
|
||||
$this->addRadio('group_option', ts('Group Options'), $options, array('onclick' => "return showElements();"));
|
||||
|
||||
$this->add('text', 'title', ts('Group Name:') . ' ',
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title')
|
||||
);
|
||||
$this->addRule('title', ts('Name already exists in Database.'),
|
||||
'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title')
|
||||
);
|
||||
|
||||
$this->add('textarea', 'description', ts('Description:') . ' ',
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')
|
||||
);
|
||||
|
||||
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
|
||||
if (!CRM_Core_Permission::access('CiviMail')) {
|
||||
$isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
|
||||
if ($isWorkFlowEnabled &&
|
||||
!CRM_Core_Permission::check('create mailings') &&
|
||||
!CRM_Core_Permission::check('schedule mailings') &&
|
||||
!CRM_Core_Permission::check('approve mailings')
|
||||
) {
|
||||
unset($groupTypes['Mailing List']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($groupTypes)) {
|
||||
$this->addCheckBox('group_type',
|
||||
ts('Group Type'),
|
||||
$groupTypes,
|
||||
NULL, NULL, NULL, NULL, ' '
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// add select for groups
|
||||
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::group();
|
||||
|
||||
$groupElement = $this->add('select', 'group_id', ts('Select Group'), $group);
|
||||
|
||||
$this->_title = $group[$this->_id];
|
||||
|
||||
if ($this->_context === 'amtg') {
|
||||
$groupElement->freeze();
|
||||
|
||||
// also set the group title
|
||||
$groupValues = array('id' => $this->_id, 'title' => $this->_title);
|
||||
$this->assign_by_ref('group', $groupValues);
|
||||
}
|
||||
|
||||
// Set dynamic page title for 'Add Members Group (confirm)'
|
||||
if ($this->_id) {
|
||||
CRM_Utils_System::setTitle(ts('Add Contacts: %1', array(1 => $this->_title)));
|
||||
}
|
||||
else {
|
||||
CRM_Utils_System::setTitle(ts('Add Contacts to A Group'));
|
||||
}
|
||||
|
||||
$this->addDefaultButtons(ts('Add to Group'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default form values.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
* the default array reference
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if ($this->_context === 'amtg') {
|
||||
$defaults['group_id'] = $this->_id;
|
||||
}
|
||||
|
||||
$defaults['group_option'] = 0;
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Event_Form_Task_AddToGroup', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $params
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($params) {
|
||||
$errors = array();
|
||||
|
||||
if (!empty($params['group_option']) && empty($params['title'])) {
|
||||
$errors['title'] = "Group Name is a required field";
|
||||
}
|
||||
elseif (empty($params['group_option']) && empty($params['group_id'])) {
|
||||
$errors['group_id'] = "Select Group is a required field.";
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues();
|
||||
$groupOption = CRM_Utils_Array::value('group_option', $params, NULL);
|
||||
if ($groupOption) {
|
||||
$groupParams = array();
|
||||
$groupParams['title'] = $params['title'];
|
||||
$groupParams['description'] = $params['description'];
|
||||
$groupParams['visibility'] = "User and User Admin Only";
|
||||
if (array_key_exists('group_type', $params) && is_array($params['group_type'])) {
|
||||
$groupParams['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
array_keys($params['group_type'])
|
||||
) . CRM_Core_DAO::VALUE_SEPARATOR;
|
||||
}
|
||||
else {
|
||||
$groupParams['group_type'] = '';
|
||||
}
|
||||
$groupParams['is_active'] = 1;
|
||||
|
||||
$createdGroup = CRM_Contact_BAO_Group::create($groupParams);
|
||||
$groupID = $createdGroup->id;
|
||||
$groupName = $groupParams['title'];
|
||||
}
|
||||
else {
|
||||
$groupID = $params['group_id'];
|
||||
$group = CRM_Core_PseudoConstant::group();
|
||||
$groupName = $group[$groupID];
|
||||
}
|
||||
|
||||
list($total, $added, $notAdded) = CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $groupID);
|
||||
|
||||
$status = array(
|
||||
ts('%count contact added to group', array(
|
||||
'count' => $added,
|
||||
'plural' => '%count contacts added to group',
|
||||
)),
|
||||
);
|
||||
if ($notAdded) {
|
||||
$status[] = ts('%count contact was already in group', array(
|
||||
'count' => $notAdded,
|
||||
'plural' => '%count contacts were already in group',
|
||||
));
|
||||
}
|
||||
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
|
||||
CRM_Core_Session::setStatus($status, ts('Added Contact to %1', array(
|
||||
1 => $groupName,
|
||||
'count' => $added,
|
||||
'plural' => 'Added Contacts to %1',
|
||||
)), 'success', array('expires' => 0));
|
||||
}
|
||||
|
||||
}
|
114
sites/all/modules/civicrm/CRM/Event/Form/Task/Badge.php
Normal file
114
sites/all/modules/civicrm/CRM/Event/Form/Task/Badge.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class helps to print the labels for contacts.
|
||||
*/
|
||||
class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending email to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Component clause.
|
||||
*/
|
||||
public $_componentClause;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
if ($this->_context == 'view') {
|
||||
$this->_single = TRUE;
|
||||
|
||||
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
|
||||
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
|
||||
$this->_participantIds = array($participantID);
|
||||
$this->_componentClause = " civicrm_participant.id = $participantID ";
|
||||
$this->assign('totalSelectedParticipants', 1);
|
||||
|
||||
// also set the user context to send back to view page
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant',
|
||||
"reset=1&action=view&id={$participantID}&cid={$contactID}"
|
||||
));
|
||||
}
|
||||
else {
|
||||
parent::preProcess();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Make Name Badges'));
|
||||
|
||||
// Ajax submit would interfere with file download
|
||||
$this->preventAjaxSubmit();
|
||||
|
||||
//add select for label
|
||||
$label = CRM_Badge_BAO_Layout::getList();
|
||||
|
||||
$this->add('select',
|
||||
'badge_id',
|
||||
ts('Name Badge Format'),
|
||||
array(
|
||||
'' => ts('- select -'),
|
||||
) + $label, TRUE
|
||||
);
|
||||
|
||||
$next = 'next';
|
||||
$back = $this->_single ? 'cancel' : 'back';
|
||||
$this->addDefaultButtons(ts('Make Name Badges'), $next, $back);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
CRM_Badge_BAO_Badge::buildBadges($params, $this);
|
||||
}
|
||||
|
||||
}
|
522
sites/all/modules/civicrm/CRM/Event/Form/Task/Batch.php
Normal file
522
sites/all/modules/civicrm/CRM/Event/Form/Task/Batch.php
Normal file
|
@ -0,0 +1,522 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality for batch profile update for events
|
||||
*/
|
||||
class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum profile fields that will be displayed.
|
||||
*/
|
||||
protected $_maxFields = 9;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Variable to store previous status id.
|
||||
*/
|
||||
protected $_fromStatusIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
/*
|
||||
* initialize the task and row fields
|
||||
*/
|
||||
parent::preProcess();
|
||||
|
||||
//get the contact read only fields to display.
|
||||
$readOnlyFields = array_merge(array('sort_name' => ts('Name')),
|
||||
CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_autocomplete_options',
|
||||
TRUE, NULL, FALSE, 'name', TRUE
|
||||
)
|
||||
);
|
||||
//get the read only field data.
|
||||
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
|
||||
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_participantIds,
|
||||
'CiviEvent', $returnProperties
|
||||
);
|
||||
$this->assign('contactDetails', $contactDetails);
|
||||
$this->assign('readOnlyFields', $readOnlyFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$ufGroupId = $this->get('ufGroupId');
|
||||
if (!$ufGroupId) {
|
||||
CRM_Core_Error::fatal('ufGroupId is missing');
|
||||
}
|
||||
|
||||
$this->_title = ts('Update multiple participants') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
|
||||
CRM_Utils_System::setTitle($this->_title);
|
||||
$this->addDefaultButtons(ts('Save'));
|
||||
$this->_fields = array();
|
||||
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
|
||||
if (array_key_exists('participant_status', $this->_fields)) {
|
||||
$this->assign('statusProfile', 1);
|
||||
$this->assignToTemplate();
|
||||
}
|
||||
|
||||
// remove file type field and then limit fields
|
||||
$suppressFields = FALSE;
|
||||
$removehtmlTypes = array('File', 'Autocomplete-Select');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
|
||||
in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
|
||||
) {
|
||||
$suppressFields = TRUE;
|
||||
unset($this->_fields[$name]);
|
||||
}
|
||||
|
||||
//fix to reduce size as we are using this field in grid
|
||||
if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
|
||||
//shrink class to "form-text-medium"
|
||||
$this->_fields[$name]['attributes']['size'] = 19;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'name' => ts('Update Participant(s)'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assign('profileTitle', $this->_title);
|
||||
$this->assign('componentIds', $this->_participantIds);
|
||||
$fileFieldExists = FALSE;
|
||||
|
||||
//load all campaigns.
|
||||
if (array_key_exists('participant_campaign_id', $this->_fields)) {
|
||||
$this->_componentCampaigns = array();
|
||||
CRM_Core_PseudoConstant::populate($this->_componentCampaigns,
|
||||
'CRM_Event_DAO_Participant',
|
||||
TRUE, 'campaign_id', 'id',
|
||||
' id IN (' . implode(' , ', array_values($this->_participantIds)) . ' ) '
|
||||
);
|
||||
}
|
||||
|
||||
//fix for CRM-2752
|
||||
// get the option value for custom data type
|
||||
$customDataType = CRM_Core_OptionGroup::values('custom_data_type', FALSE, FALSE, FALSE, NULL, 'name');
|
||||
$this->_roleCustomDataTypeID = array_search('ParticipantRole', $customDataType);
|
||||
$this->_eventNameCustomDataTypeID = array_search('ParticipantEventName', $customDataType);
|
||||
$this->_eventTypeCustomDataTypeID = array_search('ParticipantEventType', $customDataType);
|
||||
|
||||
// build custom data getFields array
|
||||
$customFieldsRole = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_roleCustomDataTypeID);
|
||||
|
||||
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_eventNameCustomDataTypeID);
|
||||
$customFieldsEventType = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_eventTypeCustomDataTypeID);
|
||||
|
||||
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole,
|
||||
CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE)
|
||||
);
|
||||
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEventType, $customFields);
|
||||
$this->_customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
|
||||
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
$roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'role_id');
|
||||
$eventId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'event_id');
|
||||
$eventTypeId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $eventId, 'event_type_id');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
|
||||
$customValue = CRM_Utils_Array::value($customFieldID, $this->_customFields);
|
||||
$entityColumnValue = array();
|
||||
if (!empty($customValue['extends_entity_column_value'])) {
|
||||
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
$customValue['extends_entity_column_value']
|
||||
);
|
||||
}
|
||||
$entityColumnValueRole = CRM_Utils_Array::value($roleId, $entityColumnValue);
|
||||
$entityColumnValueEventType = in_array($eventTypeId, $entityColumnValue) ? $eventTypeId : NULL;
|
||||
if (($this->_roleCustomDataTypeID == $customValue['extends_entity_column_id']) &&
|
||||
($entityColumnValueRole)
|
||||
) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
|
||||
}
|
||||
elseif (($this->_eventNameCustomDataTypeID == $customValue['extends_entity_column_id']) &&
|
||||
($eventId == $entityColumnValueRole)
|
||||
) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
|
||||
}
|
||||
elseif ($this->_eventTypeCustomDataTypeID == $customValue['extends_entity_column_id'] &&
|
||||
($entityColumnValueEventType == $eventTypeId)
|
||||
) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
|
||||
}
|
||||
elseif (CRM_Utils_System::isNull($entityColumnValueRole)) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($field['name'] == 'participant_role') {
|
||||
$field['is_multiple'] = TRUE;
|
||||
}
|
||||
// handle non custom fields
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('fields', $this->_fields);
|
||||
|
||||
// don't set the status message when form is submitted.
|
||||
$buttonName = $this->controller->getButtonName('submit');
|
||||
|
||||
if ($suppressFields && $buttonName != '_qf_Batch_next') {
|
||||
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple participants."), ts('Unsupported Field Type'), 'info');
|
||||
}
|
||||
|
||||
$this->addDefaultButtons(ts('Update Participant(s)'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if (empty($this->_fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
$details[$participantId] = array();
|
||||
|
||||
$details[$participantId] = CRM_Event_BAO_Participant::participantDetails($participantId);
|
||||
CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $participantId, 'Event');
|
||||
|
||||
//get the from status ids, CRM-4323
|
||||
if (array_key_exists('participant_status', $this->_fields)) {
|
||||
$this->_fromStatusIds[$participantId] = CRM_Utils_Array::value("field[$participantId][participant_status]", $defaults);
|
||||
}
|
||||
if (array_key_exists('participant_role', $this->_fields)) {
|
||||
if ($defaults["field[{$participantId}][participant_role]"]) {
|
||||
$roles = $defaults["field[{$participantId}][participant_role]"];
|
||||
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $roles) as $k => $v) {
|
||||
$defaults["field[$participantId][participant_role][{$v}]"] = 1;
|
||||
}
|
||||
unset($defaults["field[{$participantId}][participant_role]"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('details', $details);
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
$statusClasses = CRM_Event_PseudoConstant::participantStatusClass();
|
||||
if (isset($params['field'])) {
|
||||
foreach ($params['field'] as $key => $value) {
|
||||
|
||||
//check for custom data
|
||||
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($value,
|
||||
$key,
|
||||
'Participant'
|
||||
);
|
||||
|
||||
$value['id'] = $key;
|
||||
|
||||
if (!empty($value['participant_role'])) {
|
||||
if (is_array($value['participant_role'])) {
|
||||
$value['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value['participant_role']));
|
||||
}
|
||||
else {
|
||||
$value['role_id'] = $value['participant_role'];
|
||||
}
|
||||
}
|
||||
|
||||
//need to send mail when status change
|
||||
$statusChange = FALSE;
|
||||
$relatedStatusChange = FALSE;
|
||||
if (!empty($value['participant_status'])) {
|
||||
$value['status_id'] = $value['participant_status'];
|
||||
$fromStatusId = CRM_Utils_Array::value($key, $this->_fromStatusIds);
|
||||
if (!$fromStatusId) {
|
||||
$fromStatusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $key, 'status_id');
|
||||
}
|
||||
|
||||
if ($fromStatusId != $value['status_id']) {
|
||||
$relatedStatusChange = TRUE;
|
||||
}
|
||||
if ($statusClasses[$fromStatusId] != $statusClasses[$value['status_id']]) {
|
||||
$statusChange = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
unset($value['participant_status']);
|
||||
|
||||
civicrm_api3('Participant', 'create', $value);
|
||||
|
||||
//need to trigger mails when we change status
|
||||
if ($statusChange) {
|
||||
CRM_Event_BAO_Participant::transitionParticipants(array($key), $value['status_id'], $fromStatusId);
|
||||
}
|
||||
if ($relatedStatusChange) {
|
||||
//update related contribution status, CRM-4395
|
||||
self::updatePendingOnlineContribution($key, $value['status_id']);
|
||||
}
|
||||
}
|
||||
CRM_Core_Session::setStatus(ts('The updates have been saved.'), ts('Saved'), 'success');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('No updates have been saved.'), ts('Not Saved'), 'alert');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $participantId
|
||||
* @param int $statusId
|
||||
*
|
||||
* @return Ambigous|void
|
||||
*/
|
||||
public static function updatePendingOnlineContribution($participantId, $statusId) {
|
||||
if (!$participantId || !$statusId) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId,
|
||||
'Event'
|
||||
);
|
||||
if (!$contributionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
//status rules.
|
||||
//1. participant - positive => contribution - completed.
|
||||
//2. participant - negative => contribution - cancelled.
|
||||
|
||||
$positiveStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Positive'");
|
||||
$negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
|
||||
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
|
||||
|
||||
$contributionStatusId = NULL;
|
||||
if (array_key_exists($statusId, $positiveStatuses)) {
|
||||
$contributionStatusId = array_search('Completed', $contributionStatuses);
|
||||
}
|
||||
if (array_key_exists($statusId, $negativeStatuses)) {
|
||||
$contributionStatusId = array_search('Cancelled', $contributionStatuses);
|
||||
}
|
||||
|
||||
if (!$contributionStatusId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'component_id' => $participantId,
|
||||
'componentName' => 'Event',
|
||||
'contribution_id' => $contributionId,
|
||||
'contribution_status_id' => $contributionStatusId,
|
||||
'IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved' => 1,
|
||||
);
|
||||
|
||||
//change related contribution status.
|
||||
$updatedStatusId = self::updateContributionStatus($params);
|
||||
|
||||
return $updatedStatusId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update contribution status.
|
||||
*
|
||||
* @deprecated
|
||||
* This is only called from one place in the code &
|
||||
* it is unclear whether it is a function on the way in or on the way out
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return NULL|int
|
||||
*/
|
||||
public static function updateContributionStatus($params) {
|
||||
// get minimum required values.
|
||||
$statusId = CRM_Utils_Array::value('contribution_status_id', $params);
|
||||
$componentId = CRM_Utils_Array::value('component_id', $params);
|
||||
$componentName = CRM_Utils_Array::value('componentName', $params);
|
||||
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
|
||||
|
||||
if (!$contributionId || !$componentId || !$componentName || !$statusId) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$input = $ids = $objects = array();
|
||||
|
||||
//get the required ids.
|
||||
$ids['contribution'] = $contributionId;
|
||||
|
||||
if (!$ids['contact'] = CRM_Utils_Array::value('contact_id', $params)) {
|
||||
$ids['contact'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution',
|
||||
$contributionId,
|
||||
'contact_id'
|
||||
);
|
||||
}
|
||||
|
||||
if ($componentName == 'Event') {
|
||||
$name = 'event';
|
||||
$ids['participant'] = $componentId;
|
||||
|
||||
if (!$ids['event'] = CRM_Utils_Array::value('event_id', $params)) {
|
||||
$ids['event'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant',
|
||||
$componentId,
|
||||
'event_id'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($componentName == 'Membership') {
|
||||
$name = 'contribute';
|
||||
$ids['membership'] = $componentId;
|
||||
}
|
||||
$ids['contributionPage'] = NULL;
|
||||
$ids['contributionRecur'] = NULL;
|
||||
$input['component'] = $name;
|
||||
|
||||
$baseIPN = new CRM_Core_Payment_BaseIPN();
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
// reset template values.
|
||||
$template = CRM_Core_Smarty::singleton();
|
||||
$template->clearTemplateVars();
|
||||
|
||||
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
|
||||
$contribution = &$objects['contribution'];
|
||||
|
||||
$contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array(
|
||||
'labelColumn' => 'name',
|
||||
'flip' => 1,
|
||||
));
|
||||
$input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = CRM_Utils_Array::value('IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved', $params);
|
||||
if ($statusId == $contributionStatuses['Cancelled']) {
|
||||
$baseIPN->cancelled($objects, $transaction, $input);
|
||||
$transaction->commit();
|
||||
return $statusId;
|
||||
}
|
||||
elseif ($statusId == $contributionStatuses['Failed']) {
|
||||
$baseIPN->failed($objects, $transaction, $input);
|
||||
$transaction->commit();
|
||||
return $statusId;
|
||||
}
|
||||
|
||||
// status is not pending
|
||||
if ($contribution->contribution_status_id != $contributionStatuses['Pending']) {
|
||||
$transaction->commit();
|
||||
return;
|
||||
}
|
||||
|
||||
//set values for ipn code.
|
||||
foreach (array(
|
||||
'fee_amount',
|
||||
'check_number',
|
||||
'payment_instrument_id',
|
||||
) as $field) {
|
||||
if (!$input[$field] = CRM_Utils_Array::value($field, $params)) {
|
||||
$input[$field] = $contribution->$field;
|
||||
}
|
||||
}
|
||||
if (!$input['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params)) {
|
||||
$input['trxn_id'] = $contribution->invoice_id;
|
||||
}
|
||||
if (!$input['amount'] = CRM_Utils_Array::value('total_amount', $params)) {
|
||||
$input['amount'] = $contribution->total_amount;
|
||||
}
|
||||
$input['is_test'] = $contribution->is_test;
|
||||
$input['net_amount'] = $contribution->net_amount;
|
||||
if (!empty($input['fee_amount']) && !empty($input['amount'])) {
|
||||
$input['net_amount'] = $input['amount'] - $input['fee_amount'];
|
||||
}
|
||||
|
||||
//complete the contribution.
|
||||
// @todo use the api - ie civicrm_api3('Contribution', 'completetransaction', $input);
|
||||
// as this method is not preferred / supported.
|
||||
$baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
|
||||
|
||||
// reset template values before processing next transactions
|
||||
$template->clearTemplateVars();
|
||||
|
||||
return $statusId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign the minimal set of variables to the template.
|
||||
*/
|
||||
public function assignToTemplate() {
|
||||
$notifyingStatuses = array('Pending from waitlist', 'Pending from approval', 'Expired', 'Cancelled');
|
||||
$notifyingStatuses = array_intersect($notifyingStatuses, CRM_Event_PseudoConstant::participantStatus());
|
||||
$this->assign('status', TRUE);
|
||||
if (!empty($notifyingStatuses)) {
|
||||
$s = '<em>' . implode('</em>, <em>', $notifyingStatuses) . '</em>';
|
||||
$this->assign('notifyingStatuses', $s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
90
sites/all/modules/civicrm/CRM/Event/Form/Task/Cancel.php
Normal file
90
sites/all/modules/civicrm/CRM/Event/Form/Task/Cancel.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality for cancel registration for event participations
|
||||
*/
|
||||
class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
// initialize the task and row fields
|
||||
parent::preProcess();
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Cancel Registration for Event Participation'));
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->addDefaultButtons(ts('Continue'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
$value = array();
|
||||
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
$value['id'] = $participantId;
|
||||
|
||||
// Cancelled status id = 4
|
||||
$value['status_id'] = 4;
|
||||
CRM_Event_BAO_Participant::create($value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
143
sites/all/modules/civicrm/CRM/Event/Form/Task/Delete.php
Normal file
143
sites/all/modules/civicrm/CRM/Event/Form/Task/Delete.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to delete a group of
|
||||
* participations. This class provides functionality for the actual
|
||||
* deletion.
|
||||
*/
|
||||
class CRM_Event_Form_Task_Delete extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. deleting one
|
||||
* specific participation?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
|
||||
//check for delete
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::DELETE)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
parent::preProcess();
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) {
|
||||
$this->assign('additionalParticipants', TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$deleteParticipants = array(
|
||||
1 => ts('Delete this participant record along with associated participant record(s).'),
|
||||
2 => ts('Delete only this participant record.'),
|
||||
);
|
||||
|
||||
$this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
|
||||
$this->setDefaults(array('delete_participant' => 1));
|
||||
|
||||
$this->addDefaultButtons(ts('Delete Participations'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$participantLinks = NULL;
|
||||
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
|
||||
$links = array();
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
$additionalId = (CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId));
|
||||
$participantLinks = (CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId));
|
||||
}
|
||||
}
|
||||
$deletedParticipants = $additionalCount = 0;
|
||||
foreach ($this->_participantIds as $participantId) {
|
||||
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
|
||||
$primaryParticipantId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'registered_by_id', 'id');
|
||||
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) {
|
||||
$additionalIds = (CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId));
|
||||
$additionalCount += count($additionalIds);
|
||||
foreach ($additionalIds as $value) {
|
||||
CRM_Event_BAO_Participant::deleteParticipant($value);
|
||||
}
|
||||
CRM_Event_BAO_Participant::deleteParticipant($participantId);
|
||||
$deletedParticipants++;
|
||||
}
|
||||
// delete participant only if it is not an additional participant
|
||||
// or if it is additional and its primary participant is not selected in $this->_participantIds.
|
||||
elseif (empty($primaryParticipantId) || (!in_array($primaryParticipantId, $this->_participantIds))) {
|
||||
CRM_Event_BAO_Participant::deleteParticipant($participantId);
|
||||
$deletedParticipants++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
CRM_Event_BAO_Participant::deleteParticipant($participantId);
|
||||
$deletedParticipants++;
|
||||
}
|
||||
}
|
||||
if ($additionalCount) {
|
||||
$deletedParticipants += $additionalCount;
|
||||
}
|
||||
|
||||
$status = ts('%count participant deleted.', array('plural' => '%count participants deleted.', 'count' => $deletedParticipants));
|
||||
|
||||
if ($participantLinks) {
|
||||
$status .= '<p>' . ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:')
|
||||
. '</p>' . $participantLinks;
|
||||
}
|
||||
CRM_Core_Session::setStatus($status, ts('Removed'), 'info');
|
||||
}
|
||||
|
||||
}
|
104
sites/all/modules/civicrm/CRM/Event/Form/Task/Email.php
Normal file
104
sites/all/modules/civicrm/CRM/Event/Form/Task/Email.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to email a group of
|
||||
* contacts.
|
||||
*/
|
||||
class CRM_Event_Form_Task_Email extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending email to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending email to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_noEmails = FALSE;
|
||||
|
||||
/**
|
||||
* All the existing templates in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_templates = NULL;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
|
||||
parent::preProcess();
|
||||
|
||||
// we have all the participant ids, so now we get the contact ids
|
||||
parent::setContactIDs();
|
||||
|
||||
$this->assign('single', $this->_single);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
//enable form element
|
||||
$this->assign('emailTask', TRUE);
|
||||
|
||||
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
105
sites/all/modules/civicrm/CRM/Event/Form/Task/PDF.php
Normal file
105
sites/all/modules/civicrm/CRM/Event/Form/Task/PDF.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: PDF.php 45499 2013-02-08 12:31:05Z kurund $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to create PDF letter for a group of
|
||||
* participants or a single participant.
|
||||
*/
|
||||
class CRM_Event_Form_Task_PDF extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. printing letter to one
|
||||
* specific participant?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
/**
|
||||
* All the existing templates in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_templates = NULL;
|
||||
public $_cid = NULL;
|
||||
public $_activityId = NULL;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
|
||||
parent::preProcess();
|
||||
|
||||
// we have all the participant ids, so now we get the contact ids
|
||||
parent::setContactIDs();
|
||||
|
||||
$this->assign('single', $this->_single);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Event_Form_Task_ParticipantStatus extends CRM_Event_Form_Task_Batch {
|
||||
public function buildQuickForm() {
|
||||
// CRM_Event_Form_Task_Batch::buildQuickForm() gets ufGroupId
|
||||
// from the form, so set it here to the id of the reserved profile
|
||||
$dao = new CRM_Core_DAO_UFGroup();
|
||||
$dao->name = 'participant_status';
|
||||
$dao->find(TRUE);
|
||||
$this->set('ufGroupId', $dao->id);
|
||||
|
||||
$statuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
|
||||
asort($statuses, SORT_STRING);
|
||||
$this->add('select', 'status_change', ts('Change All Statuses'),
|
||||
array(
|
||||
'' => ts('- select status -'),
|
||||
) + $statuses
|
||||
);
|
||||
|
||||
$this->assign('context', 'statusChange');
|
||||
# CRM-4321: display info on users being notified if any of the below statuses is enabled
|
||||
parent::assignToTemplate();
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
}
|
146
sites/all/modules/civicrm/CRM/Event/Form/Task/PickProfile.php
Normal file
146
sites/all/modules/civicrm/CRM/Event/Form/Task/PickProfile.php
Normal file
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality for batch profile update for event participations
|
||||
*/
|
||||
class CRM_Event_Form_Task_PickProfile extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum event participations that should be allowed to update.
|
||||
*/
|
||||
protected $_maxParticipations = 100;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
// initialize the task and row fields
|
||||
parent::preProcess();
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Update multiple participants'));
|
||||
|
||||
$validate = FALSE;
|
||||
//validations
|
||||
if (count($this->_participantIds) > $this->_maxParticipations) {
|
||||
CRM_Core_Session::setStatus("The maximum number of records you can select for Update multiple participants is {$this->_maxParticipations}. You have selected " . count($this->_participantIds) . ". Please select fewer participantions from your search results and try again.");
|
||||
$validate = TRUE;
|
||||
}
|
||||
|
||||
// then redirect
|
||||
if ($validate) {
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$types = array('Participant');
|
||||
$profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE);
|
||||
|
||||
if (empty($profiles)) {
|
||||
CRM_Core_Session::setStatus("To use Update multiple participants, you need to configure a profile containing only Participant fields (e.g. Participant Status, Participant Role, etc.). Configure a profile at 'Administer CiviCRM >> Customize >> CiviCRM Profile'.");
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
|
||||
$ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
|
||||
array(
|
||||
'' => ts('- select profile -'),
|
||||
) + $profiles, TRUE
|
||||
);
|
||||
$this->addDefaultButtons(ts('Continue'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Event_Form_Task_PickProfile', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
|
||||
$this->set('ufGroupId', $params['uf_group_id']);
|
||||
|
||||
// also reset the batch page so it gets new values from the db
|
||||
$this->controller->resetPage('Batch');
|
||||
}
|
||||
|
||||
}
|
105
sites/all/modules/civicrm/CRM/Event/Form/Task/Print.php
Normal file
105
sites/all/modules/civicrm/CRM/Event/Form/Task/Print.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to participant records
|
||||
*/
|
||||
class CRM_Event_Form_Task_Print extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preprocess();
|
||||
|
||||
// set print view, so that print templates are called
|
||||
$this->controller->setPrint(1);
|
||||
|
||||
// get the formatted params
|
||||
$queryParams = $this->get('queryParams');
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Event_Selector_Search($queryParams, $this->_action, $this->_componentClause);
|
||||
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object - it consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
//
|
||||
// just need to add a javacript to popup the window for printing
|
||||
//
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Participant List'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
// redirect to the main search page after printing is over
|
||||
}
|
||||
|
||||
}
|
70
sites/all/modules/civicrm/CRM/Event/Form/Task/Result.php
Normal file
70
sites/all/modules/civicrm/CRM/Event/Form/Task/Result.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used for displaying results
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CRM_Event_Form_Task_Result extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
//this is done to unset searchRows variable assign during AddToHousehold and AddToOrganization
|
||||
$this->set('searchRows', '');
|
||||
|
||||
$ssID = $this->get('ssID');
|
||||
|
||||
$path = 'force=1';
|
||||
if (isset($ssID)) {
|
||||
$path .= "&reset=1&ssID={$ssID}";
|
||||
}
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$path .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/event/search', $path);
|
||||
$session->replaceUserContext($url);
|
||||
CRM_Utils_System::redirect($url);
|
||||
}
|
||||
|
||||
}
|
142
sites/all/modules/civicrm/CRM/Event/Form/Task/SaveSearch.php
Normal file
142
sites/all/modules/civicrm/CRM/Event/Form/Task/SaveSearch.php
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to save a search
|
||||
* Saved Searches are used for saving frequently used queries
|
||||
* regarding the event participations
|
||||
*/
|
||||
class CRM_Event_Form_Task_SaveSearch extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Saved search id if any.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$this->_id = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object - it consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Smart Group'));
|
||||
// get the qill
|
||||
$query = new CRM_Event_BAO_Query($this->get('formValues'));
|
||||
$qill = $query->qill();
|
||||
|
||||
// Values from the search form
|
||||
$formValues = $this->controller->exportValues();
|
||||
|
||||
// need to save qill for the smarty template
|
||||
$this->assign('qill', $qill);
|
||||
|
||||
// the name and description are actually stored with the group and not the saved search
|
||||
$this->add('text', 'title', ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE
|
||||
);
|
||||
|
||||
$this->addElement('text', 'description', ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')
|
||||
);
|
||||
|
||||
// get the group id for the saved search
|
||||
$groupId = NULL;
|
||||
if (isset($this->_id)) {
|
||||
$params = array('saved_search_id' => $this->_id);
|
||||
CRM_Contact_BAO_Group::retrieve($params, $values);
|
||||
$groupId = $values['id'];
|
||||
|
||||
$this->addDefaultButtons(ts('Update Smart Group'));
|
||||
}
|
||||
else {
|
||||
$this->addDefaultButtons(ts('Save Smart Group'));
|
||||
$this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all');
|
||||
}
|
||||
|
||||
$this->addRule('title', ts('Name already exists in Database.'),
|
||||
'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
// saved search form values
|
||||
$formValues = $this->controller->exportValues();
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
//save the search
|
||||
$savedSearch = new CRM_Contact_BAO_SavedSearch();
|
||||
$savedSearch->id = $this->_id;
|
||||
$savedSearch->form_values = serialize($this->get('formValues'));
|
||||
$savedSearch->save();
|
||||
$this->set('ssID', $savedSearch->id);
|
||||
CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Saved'), 'success');
|
||||
|
||||
// also create a group that is associated with this saved search only if new saved search
|
||||
$params = array();
|
||||
$params['title'] = $formValues['title'];
|
||||
$params['description'] = $formValues['description'];
|
||||
$params['visibility'] = 'User and User Admin Only';
|
||||
$params['saved_search_id'] = $savedSearch->id;
|
||||
$params['is_active'] = 1;
|
||||
|
||||
if ($this->_id) {
|
||||
$params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
|
||||
}
|
||||
$group = CRM_Contact_BAO_Group::create($params);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to update a saved search
|
||||
*
|
||||
*/
|
||||
class CRM_Event_Form_Task_SaveSearch_Update extends CRM_Event_Form_Task_SaveSearch {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
$this->_id = $this->get('ssID');
|
||||
if (!$this->_id) {
|
||||
// fetch the value from the group id gid
|
||||
$gid = $this->get('gid');
|
||||
$this->_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gid, 'saved_search_id');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
* the default values are retrieved from the database
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
|
||||
$defaults = array();
|
||||
$params = array();
|
||||
|
||||
$params = array('saved_search_id' => $this->_id);
|
||||
CRM_Contact_BAO_Group::retrieve($params, $defaults);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to save a search
|
||||
* Saved Searches are used for saving frequently used queries
|
||||
*/
|
||||
class CRM_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$rows = array();
|
||||
// display name and participation details of participants
|
||||
$participantIDs = implode(',', $this->_participantIds);
|
||||
|
||||
$query = "
|
||||
SELECT p.fee_amount as amount,
|
||||
p.register_date as register_date,
|
||||
p.source as source,
|
||||
ct.display_name as display_name
|
||||
FROM civicrm_participant p
|
||||
INNER JOIN civicrm_contact ct ON ( p.contact_id = ct.id )
|
||||
WHERE p.id IN ( $participantIDs )";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
while ($dao->fetch()) {
|
||||
$rows[] = array(
|
||||
'display_name' => $dao->display_name,
|
||||
'amount' => $dao->amount,
|
||||
'register_date' => CRM_Utils_Date::customFormat($dao->register_date),
|
||||
'source' => $dao->source,
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'done',
|
||||
'name' => ts('Done'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue