First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
1159
sites/all/modules/civicrm/CRM/Activity/Form/Activity.php
Normal file
1159
sites/all/modules/civicrm/CRM/Activity/Form/Activity.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,82 @@
|
|||
<?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 generates form components for Activity Filter.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form {
|
||||
public function buildQuickForm() {
|
||||
// add activity search filter
|
||||
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
|
||||
asort($activityOptions);
|
||||
|
||||
$this->add('select', 'activity_type_filter_id', ts('Include'), array('' => ts('- all activity type(s) -')) + $activityOptions);
|
||||
$this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), array('' => ts('- select activity type -')) + $activityOptions);
|
||||
CRM_Core_Form_Date::buildDateRange(
|
||||
$this, 'activity_date', 1,
|
||||
'_low', '_high', ts('From:'),
|
||||
FALSE, array(), 'searchDate',
|
||||
FALSE, array('class' => 'crm-select2 medium')
|
||||
);
|
||||
$this->addSelect('status_id',
|
||||
array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
|
||||
);
|
||||
|
||||
$this->assign('suppressForm', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* This virtual function is used to set the default values of
|
||||
* various form elements
|
||||
*
|
||||
* access public
|
||||
*
|
||||
* @return array
|
||||
* reference to the array of default values
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
// CRM-11761 retrieve user's activity filter preferences
|
||||
$defaults = array();
|
||||
if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) {
|
||||
$defaults = Civi::service('settings_manager')
|
||||
->getBagByContact(NULL, $userID)
|
||||
->get('activity_tab_filter');
|
||||
}
|
||||
// set Activity status 'Scheduled' by default only for dashlet
|
||||
elseif (strstr(CRM_Utils_Array::value('q', $_GET), 'dashlet')) {
|
||||
$defaults['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled');
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
}
|
107
sites/all/modules/civicrm/CRM/Activity/Form/ActivityLinks.php
Normal file
107
sites/all/modules/civicrm/CRM/Activity/Form/ActivityLinks.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?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 generates form components for Activity Links.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form {
|
||||
public function buildQuickForm() {
|
||||
self::commonBuildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $self
|
||||
*/
|
||||
public static function commonBuildQuickForm($self) {
|
||||
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $self);
|
||||
if (!$contactId) {
|
||||
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
|
||||
}
|
||||
$urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
|
||||
|
||||
$allTypes = CRM_Utils_Array::value('values', civicrm_api3('OptionValue', 'get', array(
|
||||
'option_group_id' => 'activity_type',
|
||||
'is_active' => 1,
|
||||
'options' => array('limit' => 0, 'sort' => 'weight'),
|
||||
)));
|
||||
|
||||
$activityTypes = array();
|
||||
|
||||
foreach ($allTypes as $act) {
|
||||
$url = 'civicrm/activity/add';
|
||||
if ($act['name'] == 'Email') {
|
||||
if (!CRM_Utils_Mail::validOutBoundMail() || !$contactId) {
|
||||
continue;
|
||||
}
|
||||
list($name, $email, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
|
||||
if (!$doNotEmail && $email && !$isDeceased) {
|
||||
$url = 'civicrm/activity/email/add';
|
||||
$act['label'] = ts('Send an Email');
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elseif ($act['name'] == 'SMS') {
|
||||
if (!$contactId || !CRM_SMS_BAO_Provider::activeProviderCount()) {
|
||||
continue;
|
||||
}
|
||||
// Check for existence of a mobile phone and ! do not SMS privacy setting
|
||||
$mobileTypeID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile');
|
||||
list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID);
|
||||
if (!$doNotSMS && $phone) {
|
||||
$url = 'civicrm/activity/sms/add';
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elseif ($act['name'] == 'Print PDF Letter') {
|
||||
$url = 'civicrm/activity/pdf/add';
|
||||
}
|
||||
elseif (!empty($act['filter']) || (!empty($act['component_id']) && $act['component_id'] != '1')) {
|
||||
continue;
|
||||
}
|
||||
$act['url'] = CRM_Utils_System::url($url,
|
||||
"{$urlParams}{$act['value']}", FALSE, NULL, FALSE
|
||||
);
|
||||
$act += array('icon' => 'fa-plus-square-o');
|
||||
$activityTypes[$act['value']] = $act;
|
||||
}
|
||||
|
||||
$self->assign('activityTypes', $activityTypes);
|
||||
|
||||
$self->assign('suppressForm', TRUE);
|
||||
}
|
||||
|
||||
}
|
128
sites/all/modules/civicrm/CRM/Activity/Form/ActivityView.php
Normal file
128
sites/all/modules/civicrm/CRM/Activity/Form/ActivityView.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?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 handle activity view mode.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityView extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
// Get the activity values.
|
||||
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
// Check for required permissions, CRM-6264.
|
||||
if ($activityId &&
|
||||
!CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
if (!in_array($context, array(
|
||||
'home',
|
||||
'dashlet',
|
||||
'dashletFullscreen',
|
||||
))
|
||||
) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
|
||||
}
|
||||
else {
|
||||
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
|
||||
}
|
||||
|
||||
$session->pushUserContext($url);
|
||||
$defaults = array();
|
||||
$params = array('id' => $activityId);
|
||||
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
|
||||
|
||||
// Set activity type name and description to template.
|
||||
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
|
||||
|
||||
$this->assign('activityTypeName', $activityTypeName);
|
||||
$this->assign('activityTypeDescription', $activityTypeDescription);
|
||||
|
||||
if (!empty($defaults['mailingId'])) {
|
||||
$this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
|
||||
$mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
|
||||
CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
|
||||
$this->assign('mailingReport', $mailingReport);
|
||||
|
||||
$full_open_report = CRM_Mailing_Event_BAO_Opened::getRows(
|
||||
$this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
|
||||
$this->assign('openreport', $full_open_report);
|
||||
|
||||
$click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
|
||||
$this->assign('clickreport', $click_thru_report);
|
||||
}
|
||||
|
||||
foreach ($defaults as $key => $value) {
|
||||
if (substr($key, -3) != '_id') {
|
||||
$values[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the campaign.
|
||||
if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
|
||||
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
|
||||
$values['campaign'] = $campaigns[$campaignId];
|
||||
}
|
||||
if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
|
||||
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
|
||||
$values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
|
||||
}
|
||||
|
||||
$values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
|
||||
$this->assign('values', $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Done'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
417
sites/all/modules/civicrm/CRM/Activity/Form/Search.php
Normal file
417
sites/all/modules/civicrm/CRM/Activity/Form/Search.php
Normal file
|
@ -0,0 +1,417 @@
|
|||
<?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 file is for activity search.
|
||||
*/
|
||||
class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
|
||||
|
||||
/**
|
||||
* The params that are sent to the query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_queryParams;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* Prefix for the controller.
|
||||
*/
|
||||
protected $_prefix = "activity_";
|
||||
|
||||
/**
|
||||
* The saved search ID retrieved from the GET vars.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_ssID;
|
||||
|
||||
/**
|
||||
* Processing needed for buildForm and later.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->set('searchFormName', 'Search');
|
||||
|
||||
// set the button names
|
||||
$this->_searchButtonName = $this->getButtonName('refresh');
|
||||
$this->_actionButtonName = $this->getButtonName('next', 'action');
|
||||
|
||||
$this->_done = FALSE;
|
||||
$this->defaults = array();
|
||||
|
||||
// we allow the controller to set force/reset externally, useful when we are being
|
||||
// driven by the wizard framework
|
||||
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
|
||||
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
|
||||
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
|
||||
|
||||
$this->assign("context", $this->_context);
|
||||
|
||||
// get user submitted values
|
||||
// get it from controller only if form has been submitted, else preProcess has set this
|
||||
if (!empty($_POST) && !$this->controller->isModal()) {
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
}
|
||||
else {
|
||||
$this->_formValues = $this->get('formValues');
|
||||
|
||||
if ($this->_force) {
|
||||
// If we force the search then merge form values with url values
|
||||
// and set submit values to form values.
|
||||
$this->_formValues = array_merge((array) $this->_formValues, CRM_Utils_Request::exportValues());
|
||||
$this->_submitValues = $this->_formValues;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->_formValues)) {
|
||||
if (isset($this->_ssID)) {
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_force) {
|
||||
$this->postProcess();
|
||||
$this->set('force', 0);
|
||||
}
|
||||
|
||||
$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)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
$selector = new CRM_Activity_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$this->assign("{$prefix}limit", $this->_limit);
|
||||
$this->assign("{$prefix}single", $this->_single);
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::TRANSFER,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->moveFromSessionToTemplate();
|
||||
|
||||
$this->assign('summary', $this->get('summary'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->addSortNameField();
|
||||
|
||||
CRM_Activity_BAO_Query::buildSearchForm($this);
|
||||
|
||||
$rows = $this->get('rows');
|
||||
if (is_array($rows)) {
|
||||
if (!$this->_single) {
|
||||
$this->addRowSelectors($rows);
|
||||
}
|
||||
|
||||
$permission = CRM_Core_Permission::getPermission();
|
||||
|
||||
$this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The post processing of the form gets done here.
|
||||
*
|
||||
* Key things done during post processing are
|
||||
* - check for reset or next request. if present, skip post procesing.
|
||||
* - now check if user requested running a saved search, if so, then
|
||||
* the form values associated with the saved search are used for searching.
|
||||
* - if user has done a submit with new values the regular post submissing is
|
||||
* done.
|
||||
*
|
||||
* The processing consists of using a Selector / Controller framework for getting the
|
||||
* search results.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_done = TRUE;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
$specialParams = array(
|
||||
'activity_type_id',
|
||||
'status_id',
|
||||
'priority_id',
|
||||
'activity_text',
|
||||
);
|
||||
$changeNames = array(
|
||||
'status_id' => 'activity_status_id',
|
||||
'priority_id' => 'activity_priority_id',
|
||||
);
|
||||
|
||||
CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames);
|
||||
}
|
||||
|
||||
$this->fixFormValues();
|
||||
|
||||
if (isset($this->_ssID) && empty($_POST)) {
|
||||
// if we are editing / running a saved search and the form has not been posted
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
|
||||
// We don't show test records in summaries or dashboards
|
||||
if (empty($this->_formValues['activity_test']) && $this->_force) {
|
||||
$this->_formValues["activity_test"] = 0;
|
||||
}
|
||||
|
||||
CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
|
||||
$this->set('formValues', $this->_formValues);
|
||||
$this->set('queryParams', $this->_queryParams);
|
||||
|
||||
$buttonName = $this->controller->getButtonName();
|
||||
if ($buttonName == $this->_actionButtonName) {
|
||||
// check actionName and if next, then do not repeat a search, since we are going to the next page
|
||||
// hack, make sure we reset the task values
|
||||
$stateMachine = $this->controller->getStateMachine();
|
||||
$formName = $stateMachine->getTaskFormName();
|
||||
$this->controller->resetPage($formName);
|
||||
return;
|
||||
}
|
||||
|
||||
$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)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
|
||||
$selector = new CRM_Activity_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$selector->setKey($this->controller->_key);
|
||||
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'basic' || $this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::SESSION,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$query = &$selector->getQuery();
|
||||
|
||||
if ($this->_context == 'user') {
|
||||
$query->setSkipPermission(TRUE);
|
||||
}
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
public function fixFormValues() {
|
||||
if (!$this->_force) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = CRM_Utils_Request::retrieve('status', 'String', $this);
|
||||
if ($status) {
|
||||
$this->_formValues['activity_status_id'] = $status;
|
||||
$this->_defaults['activity_status_id'] = $status;
|
||||
}
|
||||
|
||||
$survey = CRM_Utils_Request::retrieve('survey', 'Positive');
|
||||
|
||||
if ($survey) {
|
||||
$this->_formValues['activity_survey_id'] = $this->_defaults['activity_survey_id'] = $survey;
|
||||
$sid = CRM_Utils_Array::value('activity_survey_id', $this->_formValues);
|
||||
$activity_type_id = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $sid, 'activity_type_id');
|
||||
|
||||
// since checkbox are replaced by multiple select option
|
||||
$this->_formValues['activity_type_id'] = $activity_type_id;
|
||||
$this->_defaults['activity_type_id'] = $activity_type_id;
|
||||
}
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
if ($cid) {
|
||||
$cid = CRM_Utils_Type::escape($cid, 'Integer');
|
||||
if ($cid > 0) {
|
||||
$this->_formValues['contact_id'] = $cid;
|
||||
|
||||
$activity_role = CRM_Utils_Request::retrieve('activity_role', 'Positive', $this);
|
||||
|
||||
if ($activity_role) {
|
||||
$this->_formValues['activity_role'] = $activity_role;
|
||||
}
|
||||
else {
|
||||
$this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
|
||||
}
|
||||
// also assign individual mode to the template
|
||||
$this->_single = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Added for membership search
|
||||
|
||||
$signupType = CRM_Utils_Request::retrieve('signupType', 'Positive');
|
||||
|
||||
if ($signupType) {
|
||||
$this->_formValues['activity_role'] = 1;
|
||||
$this->_defaults['activity_role'] = 1;
|
||||
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
|
||||
|
||||
$renew = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
|
||||
$signup = CRM_Utils_Array::key('Membership Signup', $activityTypes);
|
||||
|
||||
switch ($signupType) {
|
||||
case 3: // signups and renewals
|
||||
$this->_formValues['activity_type_id'][$renew] = 1;
|
||||
$this->_defaults['activity_type_id'][$renew] = 1;
|
||||
case 1: // signups only
|
||||
$this->_formValues['activity_type_id'][$signup] = 1;
|
||||
$this->_defaults['activity_type_id'][$signup] = 1;
|
||||
break;
|
||||
|
||||
case 2: // renewals only
|
||||
$this->_formValues['activity_type_id'][$renew] = 1;
|
||||
$this->_defaults['activity_type_id'][$renew] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$dateLow = CRM_Utils_Request::retrieve('dateLow', 'String');
|
||||
|
||||
if ($dateLow) {
|
||||
$dateLow = date('m/d/Y', strtotime($dateLow));
|
||||
$this->_formValues['activity_date_relative'] = 0;
|
||||
$this->_defaults['activity_date_relative'] = 0;
|
||||
$this->_formValues['activity_date_low'] = $dateLow;
|
||||
$this->_defaults['activity_date_low'] = $dateLow;
|
||||
}
|
||||
|
||||
$dateHigh = CRM_Utils_Request::retrieve('dateHigh', 'String');
|
||||
|
||||
if ($dateHigh) {
|
||||
// Activity date time assumes midnight at the beginning of the date
|
||||
// This sets it to almost midnight at the end of the date
|
||||
/* if ($dateHigh <= 99999999) {
|
||||
$dateHigh = 1000000 * $dateHigh + 235959;
|
||||
} */
|
||||
$dateHigh = date('m/d/Y', strtotime($dateHigh));
|
||||
$this->_formValues['activity_date_relative'] = 0;
|
||||
$this->_defaults['activity_date_relative'] = 0;
|
||||
$this->_formValues['activity_date_high'] = $dateHigh;
|
||||
$this->_defaults['activity_date_high'] = $dateHigh;
|
||||
}
|
||||
|
||||
// Enable search activity by custom value
|
||||
$requestParams = CRM_Utils_Request::exportValues();
|
||||
foreach (array_keys($requestParams) as $key) {
|
||||
if (substr($key, 0, 7) != 'custom_') {
|
||||
continue;
|
||||
}
|
||||
elseif (empty($requestParams[$key])) {
|
||||
continue;
|
||||
}
|
||||
$customValue = CRM_Utils_Request::retrieve($key, 'String', $this);
|
||||
if ($customValue) {
|
||||
$this->_formValues[$key] = $customValue;
|
||||
$this->_defaults[$key] = $customValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->_defaults)) {
|
||||
$this->setDefaults($this->_defaults);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getFormValues() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a descriptive name for the page, used in wizard header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Find Activities');
|
||||
}
|
||||
|
||||
}
|
207
sites/all/modules/civicrm/CRM/Activity/Form/Task.php
Normal file
207
sites/all/modules/civicrm/CRM/Activity/Form/Task.php
Normal file
|
@ -0,0 +1,207 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for activity task actions.
|
||||
*/
|
||||
class CRM_Activity_Form_Task extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The task being performed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_componentClause = NULL;
|
||||
|
||||
/**
|
||||
* The array that holds all the component ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_componentIds;
|
||||
|
||||
/**
|
||||
* The array that holds all the contact ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_contactIds;
|
||||
|
||||
/**
|
||||
* The array that holds all the member ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_activityHolderIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
self::preProcessCommon($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common pre-process function.
|
||||
*
|
||||
* @param CRM_Core_Form $form
|
||||
* @param bool $useTable
|
||||
*/
|
||||
public static function preProcessCommon(&$form, $useTable = FALSE) {
|
||||
$form->_activityHolderIds = array();
|
||||
|
||||
$values = $form->controller->exportValues($form->get('searchFormName'));
|
||||
|
||||
$form->_task = $values['task'];
|
||||
$activityTasks = CRM_Activity_Task::tasks();
|
||||
$form->assign('taskName', $activityTasks[$form->_task]);
|
||||
|
||||
$ids = array();
|
||||
if ($values['radio_ts'] == 'ts_sel') {
|
||||
foreach ($values as $name => $value) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams = $form->get('queryParams');
|
||||
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_ACTIVITY
|
||||
);
|
||||
$query->_distinctComponentClause = '( civicrm_activity.id )';
|
||||
$query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
|
||||
|
||||
// CRM-12675
|
||||
$activityClause = NULL;
|
||||
|
||||
$components = CRM_Core_Component::getNames();
|
||||
$componentClause = array();
|
||||
foreach ($components as $componentID => $componentName) {
|
||||
if ($componentName != 'CiviCase' && !CRM_Core_Permission::check("access $componentName")) {
|
||||
$componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
|
||||
}
|
||||
}
|
||||
if (!empty($componentClause)) {
|
||||
$activityClause = implode(' AND ', $componentClause);
|
||||
}
|
||||
$result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
|
||||
|
||||
while ($result->fetch()) {
|
||||
if (!empty($result->activity_id)) {
|
||||
$ids[] = $result->activity_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
$form->_componentClause = ' civicrm_activity.id IN ( ' . implode(',', $ids) . ' ) ';
|
||||
$form->assign('totalSelectedActivities', count($ids));
|
||||
}
|
||||
|
||||
$form->_activityHolderIds = $form->_componentIds = $ids;
|
||||
|
||||
// Set the context for redirection for any task actions.
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
|
||||
$urlParams = 'force=1';
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$searchFormName = strtolower($form->get('searchFormName'));
|
||||
if ($searchFormName == 'search') {
|
||||
$session->replaceUserContext(CRM_Utils_System::url('civicrm/activity/search', $urlParams));
|
||||
}
|
||||
else {
|
||||
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName",
|
||||
$urlParams
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the membership id, compute the contact id
|
||||
* since it's used for things like send email.
|
||||
*/
|
||||
public function setContactIDs() {
|
||||
$IDs = implode(',', $this->_activityHolderIds);
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$query = "
|
||||
SELECT contact_id
|
||||
FROM civicrm_activity_contact
|
||||
WHERE activity_id IN ( $IDs ) AND
|
||||
record_type_id = {$sourceID}";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
while ($dao->fetch()) {
|
||||
$contactIDs[] = $dao->contact_id;
|
||||
}
|
||||
$this->_contactIds = $contactIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple shell that derived classes can call to add buttons to
|
||||
* the form with a customized title for the main Submit
|
||||
*
|
||||
* @param string $title
|
||||
* Title of the main button.
|
||||
* @param string $nextType
|
||||
* Button type for the form after processing.
|
||||
* @param string $backType
|
||||
* @param bool $submitOnce
|
||||
*/
|
||||
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => $nextType,
|
||||
'name' => $title,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => $backType,
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
154
sites/all/modules/civicrm/CRM/Activity/Form/Task/AddToTag.php
Normal file
154
sites/all/modules/civicrm/CRM/Activity/Form/Task/AddToTag.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?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 provides the functionality to delete a group of
|
||||
* contacts. This class provides functionality for the actual
|
||||
* addition of contacts to groups.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Name of the tag.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* All the tags in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_tags;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add select for tag
|
||||
$this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
|
||||
|
||||
foreach ($this->_tags as $tagID => $tagName) {
|
||||
$this->_tagElement = &$this->addElement('checkbox', "tag[$tagID]", NULL, $tagName);
|
||||
}
|
||||
|
||||
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
|
||||
|
||||
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity');
|
||||
|
||||
$this->addDefaultButtons(ts('Tag Activities'));
|
||||
}
|
||||
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_AddToTag', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function formRule($form, $rule) {
|
||||
$errors = array();
|
||||
if (empty($form['tag']) && empty($form['activity_taglist'])) {
|
||||
$errors['_qf_default'] = ts("Please select at least one tag.");
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// Get the submitted values in an array.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
$activityTags = $tagList = array();
|
||||
|
||||
// check if contact tags exists
|
||||
if (!empty($params['tag'])) {
|
||||
$activityTags = $params['tag'];
|
||||
}
|
||||
|
||||
// check if tags are selected from taglists
|
||||
if (!empty($params['activity_taglist'])) {
|
||||
foreach ($params['activity_taglist'] as $val) {
|
||||
if ($val) {
|
||||
if (is_numeric($val)) {
|
||||
$tagList[$val] = 1;
|
||||
}
|
||||
else {
|
||||
$tagIDs = explode(',', $val);
|
||||
if (!empty($tagIDs)) {
|
||||
foreach ($tagIDs as $tagID) {
|
||||
if (is_numeric($tagID)) {
|
||||
$tagList[$tagID] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tagSets = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_activity', FALSE, TRUE);
|
||||
|
||||
foreach ($tagSets as $key => $value) {
|
||||
$this->_tags[$key] = $value['name'];
|
||||
}
|
||||
|
||||
// merge activity and taglist tags
|
||||
$allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList);
|
||||
|
||||
$this->_name = array();
|
||||
foreach ($allTags as $key => $dnc) {
|
||||
$this->_name[] = $this->_tags[$key];
|
||||
|
||||
list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key,
|
||||
'civicrm_activity', FALSE);
|
||||
|
||||
$status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged')));
|
||||
if ($notAdded) {
|
||||
$status[] = ts('1 activity already had this tag', array(
|
||||
'count' => $notAdded,
|
||||
'plural' => '%count activities already had this tag',
|
||||
));
|
||||
}
|
||||
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
|
||||
CRM_Core_Session::setStatus($status, ts("Added Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
258
sites/all/modules/civicrm/CRM/Activity/Form/Task/Batch.php
Normal file
258
sites/all/modules/civicrm/CRM/Activity/Form/Task/Batch.php
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?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 provides the functionality for batch profile update for Activities
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Batch extends CRM_Activity_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;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
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('Added By'), 'target_sort_name' => ts('With Contact')),
|
||||
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->_activityHolderIds,
|
||||
'Activity', $returnProperties
|
||||
);
|
||||
$readOnlyFields['assignee_display_name'] = ts('Assigned to');
|
||||
if (!empty($contactDetails)) {
|
||||
foreach ($contactDetails as $key => $value) {
|
||||
$assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
|
||||
foreach ($assignee as $values) {
|
||||
$assigneeContact[] = CRM_Contact_BAO_Contact::displayName($values);
|
||||
}
|
||||
$contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
|
||||
}
|
||||
}
|
||||
$this->assign('contactDetails', $contactDetails);
|
||||
$this->assign('readOnlyFields', $readOnlyFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$ufGroupId = $this->get('ufGroupId');
|
||||
|
||||
if (!$ufGroupId) {
|
||||
throw new CRM_Core_Exception('The profile id is missing');
|
||||
}
|
||||
$this->_title = ts('Update multiple activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
|
||||
CRM_Utils_System::setTitle($this->_title);
|
||||
|
||||
$this->addDefaultButtons(ts('Save'));
|
||||
$this->_fields = array();
|
||||
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
|
||||
|
||||
// remove file type field and then limit fields
|
||||
$suppressFields = FALSE;
|
||||
$removehtmlTypes = array('File', 'Autocomplete-Select');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if (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']) && !empty($this->_fields[$name]['attributes']['size']) && $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 Activities'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
|
||||
$this->assign('profileTitle', $this->_title);
|
||||
$this->assign('componentIds', $this->_activityHolderIds);
|
||||
|
||||
// Load all campaigns.
|
||||
if (array_key_exists('activity_campaign_id', $this->_fields)) {
|
||||
$this->_componentCampaigns = array();
|
||||
CRM_Core_PseudoConstant::populate($this->_componentCampaigns,
|
||||
'CRM_Activity_DAO_Activity',
|
||||
TRUE, 'campaign_id', 'id',
|
||||
' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) '
|
||||
);
|
||||
}
|
||||
|
||||
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
|
||||
// It is possible to have fields that are required in CiviCRM not be required in the
|
||||
// profile. Overriding that here. Perhaps a better approach would be to
|
||||
// make them required in the schema & read that up through getFields functionality.
|
||||
$requiredFields = array('activity_date_time');
|
||||
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
|
||||
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
|
||||
if (!empty($customValue['extends_entity_column_value'])) {
|
||||
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
$customValue['extends_entity_column_value']
|
||||
);
|
||||
}
|
||||
if (!empty($entityColumnValue[$typeId]) ||
|
||||
CRM_Utils_System::isNull($entityColumnValue[$typeId])
|
||||
) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Handle non custom fields.
|
||||
if (in_array($field['name'], $requiredFields)) {
|
||||
$field['is_required'] = TRUE;
|
||||
}
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('fields', $this->_fields);
|
||||
|
||||
// Don't set the status message when form is submitted.
|
||||
// $buttonName = $this->controller->getButtonName('submit');
|
||||
|
||||
if ($suppressFields) {
|
||||
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple activities."), ts('Some Fields Excluded'), 'info');
|
||||
}
|
||||
|
||||
$this->addDefaultButtons(ts('Update Activities'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if (empty($this->_fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $activityId, 'Activity');
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
|
||||
if (isset($params['field'])) {
|
||||
foreach ($params['field'] as $key => $value) {
|
||||
|
||||
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($value,
|
||||
$key, 'Activity'
|
||||
);
|
||||
$value['id'] = $key;
|
||||
|
||||
if (!empty($value['activity_status_id'])) {
|
||||
$value['status_id'] = $value['activity_status_id'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_details'])) {
|
||||
$value['details'] = $value['activity_details'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_location'])) {
|
||||
$value['location'] = $value['activity_location'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_subject'])) {
|
||||
$value['subject'] = $value['activity_subject'];
|
||||
}
|
||||
|
||||
$activityId = civicrm_api3('activity', 'create', $value);
|
||||
|
||||
// @todo this would be done by the api call above if the parames were passed through.
|
||||
if (!empty($value['custom']) &&
|
||||
is_array($value['custom'])
|
||||
) {
|
||||
CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_activity', $activityId['id']);
|
||||
}
|
||||
}
|
||||
CRM_Core_Session::setStatus("", ts("Updates Saved"), "success");
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus("", ts("No Updates Saved"), "info");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Delete.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Delete.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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 provides the functionality to delete a group of
|
||||
* Activities. This class provides functionality for the actual
|
||||
* deletion.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Delete extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. deleting one
|
||||
* specific Activity?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addDefaultButtons(ts('Delete Activities'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$deleted = $failed = 0;
|
||||
foreach ($this->_activityHolderIds as $activityId['id']) {
|
||||
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
|
||||
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
|
||||
$deleted++;
|
||||
}
|
||||
else {
|
||||
$failed++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
$msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted));
|
||||
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
96
sites/all/modules/civicrm/CRM/Activity/Form/Task/Email.php
Normal file
96
sites/all/modules/civicrm/CRM/Activity/Form/Task/Email.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?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 provides the functionality to email a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending email to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
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 contribution 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;
|
||||
}
|
||||
|
||||
}
|
124
sites/all/modules/civicrm/CRM/Activity/Form/Task/FileOnCase.php
Normal file
124
sites/all/modules/civicrm/CRM/Activity/Form/Task/FileOnCase.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?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 provides the functionality to email a group of contacts
|
||||
*/
|
||||
class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Variable to store contact Ids.
|
||||
*/
|
||||
public $_contacts;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('File on Case'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addEntityRef('unclosed_case_id', ts('Select Case'), array('entity' => 'Case'), TRUE);
|
||||
$this->addDefaultButtons(ts('Save'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$formparams = $this->exportValues();
|
||||
$caseId = $formparams['unclosed_case_id'];
|
||||
$filedActivities = 0;
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$targetContactValues = $defaults = array();
|
||||
$params = array('id' => $id);
|
||||
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
|
||||
if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
|
||||
|
||||
if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
|
||||
$targetContactValues = array_combine(array_unique($defaults['target_contact']),
|
||||
explode(';', trim($defaults['target_contact_value']))
|
||||
);
|
||||
$targetContactValues = implode(',', array_keys($targetContactValues));
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'caseID' => $caseId,
|
||||
'activityID' => $id,
|
||||
'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'],
|
||||
'targetContactIds' => $targetContactValues,
|
||||
'mode' => 'file',
|
||||
);
|
||||
|
||||
$error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params);
|
||||
if (empty($error_msg['error_msg'])) {
|
||||
$filedActivities++;
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus($error_msg['error_msg'], ts("Error"), "error");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array(
|
||||
1 => empty($defaults['subject']) ? '' : $defaults['subject'],
|
||||
2 => $defaults['activity_date_time'],
|
||||
)),
|
||||
ts("Error"), "error");
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success");
|
||||
CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
|
||||
}
|
||||
|
||||
}
|
173
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickOption.php
Normal file
173
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickOption.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?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 provides the functionality to email a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum Activities that should be allowed to update.
|
||||
*/
|
||||
protected $_maxActivities = 100;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Variable to store contact Ids.
|
||||
*/
|
||||
public $_contacts;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
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('Send Email to Contacts'));
|
||||
|
||||
$validate = FALSE;
|
||||
//validations
|
||||
if (count($this->_activityHolderIds) > $this->_maxActivities) {
|
||||
CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select to send an email is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
|
||||
1 => $this->_maxActivities,
|
||||
2 => count($this->_activityHolderIds),
|
||||
)), ts("Maximum Exceeded"), "error");
|
||||
$validate = TRUE;
|
||||
}
|
||||
// then redirect
|
||||
if ($validate) {
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addElement('checkbox', 'with_contact', ts('With Contact'));
|
||||
$this->addElement('checkbox', 'assigned_to', ts('Assigned to Contact'));
|
||||
$this->addElement('checkbox', 'created_by', ts('Created by'));
|
||||
$this->setDefaults(array('with_contact' => 1));
|
||||
$this->addDefaultButtons(ts('Continue'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_PickOption', '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) {
|
||||
if (!isset($fields['with_contact']) &&
|
||||
!isset($fields['assigned_to']) &&
|
||||
!isset($fields['created_by'])
|
||||
) {
|
||||
return array('with_contact' => ts('You must select at least one email recipient type.'));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// Clear any formRule errors from Email form in case they came back here via Cancel button
|
||||
$this->controller->resetPage('Email');
|
||||
$params = $this->exportValues();
|
||||
$this->_contacts = array();
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
// Get assignee contacts.
|
||||
if (!empty($params['assigned_to'])) {
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID));
|
||||
$this->_contacts = array_merge($this->_contacts, $ids);
|
||||
}
|
||||
}
|
||||
// Get target contacts.
|
||||
if (!empty($params['with_contact'])) {
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
|
||||
$this->_contacts = array_merge($this->_contacts, $ids);
|
||||
}
|
||||
}
|
||||
// Get 'Added by' contacts.
|
||||
if (!empty($params['created_by'])) {
|
||||
parent::setContactIDs();
|
||||
if (!empty($this->_contactIds)) {
|
||||
$this->_contacts = array_merge($this->_contacts, $this->_contactIds);
|
||||
}
|
||||
}
|
||||
$this->_contacts = array_unique($this->_contacts);
|
||||
|
||||
// Bounce to pick option if no contacts to send to.
|
||||
if (empty($this->_contacts)) {
|
||||
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
|
||||
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
|
||||
CRM_Core_Error::statusBounce(
|
||||
ts('It appears you have no contacts with email addresses from the selected recipients.'),
|
||||
$urlRedirect
|
||||
);
|
||||
}
|
||||
|
||||
$this->set('contacts', $this->_contacts);
|
||||
}
|
||||
|
||||
}
|
161
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickProfile.php
Normal file
161
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickProfile.php
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?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 provides the functionality for batch profile update for Activity.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum Activities that should be allowed to update.
|
||||
*/
|
||||
protected $_maxActivities = 100;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
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 activities'));
|
||||
|
||||
$validate = FALSE;
|
||||
// Validations.
|
||||
if (count($this->_activityHolderIds) > $this->_maxActivities) {
|
||||
CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
|
||||
1 => $this->_maxActivities,
|
||||
2 => count($this->_activityHolderIds),
|
||||
)), ts('Maximum Exceeded'), 'error');
|
||||
$validate = TRUE;
|
||||
}
|
||||
|
||||
// Then redirect.
|
||||
if ($validate) {
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$types = array('Activity');
|
||||
$profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE);
|
||||
|
||||
$activityTypeIds = array_flip(CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name'));
|
||||
$nonEditableActivityTypeIds = array(
|
||||
$activityTypeIds['Email'],
|
||||
$activityTypeIds['Bulk Email'],
|
||||
$activityTypeIds['Contribution'],
|
||||
$activityTypeIds['Inbound Email'],
|
||||
$activityTypeIds['Pledge Reminder'],
|
||||
$activityTypeIds['Membership Signup'],
|
||||
$activityTypeIds['Membership Renewal'],
|
||||
$activityTypeIds['Event Registration'],
|
||||
$activityTypeIds['Pledge Acknowledgment'],
|
||||
);
|
||||
$notEditable = FALSE;
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
|
||||
if (in_array($typeId, $nonEditableActivityTypeIds)) {
|
||||
$notEditable = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($profiles)) {
|
||||
CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple activities. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert");
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
elseif ($notEditable) {
|
||||
CRM_Core_Session::setStatus("", ts("Some of the selected activities are not editable."), "alert");
|
||||
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.
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_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.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Print.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Print.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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 provides the functionality to print activity records.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Print extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
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_Activity_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.
|
||||
*
|
||||
* Consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
// just need to add a javacript to popup the window for printing
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Activities'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
<?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 provides the functionality to remove tags of contact(s).
|
||||
*/
|
||||
class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Name of the tag
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* All the tags in the system
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_tags;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add select for tag
|
||||
$this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
|
||||
foreach ($this->_tags as $tagID => $tagName) {
|
||||
$this->_tagElement = &$this->addElement('checkbox', "tag[$tagID]", NULL, $tagName);
|
||||
}
|
||||
|
||||
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
|
||||
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE);
|
||||
|
||||
$this->addDefaultButtons(ts('Remove Tags from activities'));
|
||||
}
|
||||
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_RemoveFromTag', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function formRule($form, $rule) {
|
||||
$errors = array();
|
||||
if (empty($form['tag']) && empty($form['activity_taglist'])) {
|
||||
$errors['_qf_default'] = "Please select atleast one tag.";
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
//get the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$activityTags = $tagList = array();
|
||||
|
||||
// check if contact tags exists
|
||||
if (!empty($params['tag'])) {
|
||||
$activityTags = $params['tag'];
|
||||
}
|
||||
|
||||
// check if tags are selected from taglists
|
||||
if (!empty($params['activity_taglist'])) {
|
||||
foreach ($params['activity_taglist'] as $val) {
|
||||
if ($val) {
|
||||
if (is_numeric($val)) {
|
||||
$tagList[$val] = 1;
|
||||
}
|
||||
else {
|
||||
list($label, $tagID) = explode(',', $val);
|
||||
$tagList[$tagID] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tagSets = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_activity', FALSE, TRUE);
|
||||
|
||||
foreach ($tagSets as $key => $value) {
|
||||
$this->_tags[$key] = $value['name'];
|
||||
}
|
||||
// merge contact and taglist tags
|
||||
$allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList);
|
||||
|
||||
$this->_name = array();
|
||||
foreach ($allTags as $key => $dnc) {
|
||||
$this->_name[] = $this->_tags[$key];
|
||||
|
||||
list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_activityHolderIds,
|
||||
$key, 'civicrm_activity', FALSE);
|
||||
|
||||
$status = array(
|
||||
ts('%count activity un-tagged', array(
|
||||
'count' => $removed,
|
||||
'plural' => '%count activities un-tagged',
|
||||
)),
|
||||
);
|
||||
if ($notRemoved) {
|
||||
$status[] = ts('1 activity already did not have this tag', array(
|
||||
'count' => $notRemoved,
|
||||
'plural' => '%count activities already did not have this tag',
|
||||
));
|
||||
}
|
||||
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
|
||||
CRM_Core_Session::setStatus($status, ts("Removed Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/SMS.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/SMS.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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 provides the functionality to sms a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_SMS extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending sms to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = 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() {
|
||||
parent::preProcess();
|
||||
CRM_Contact_Form_Task_SMSCommon::preProcessProvider($this);
|
||||
$this->assign('single', $this->_single);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// Enable form element.
|
||||
$this->assign('SMSTask', TRUE);
|
||||
CRM_Contact_Form_Task_SMSCommon::buildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Contact_Form_Task_SMSCommon::postProcess($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?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 provides the functionality to save a search
|
||||
* Saved Searches are used for saving frequently used queries
|
||||
*/
|
||||
class CRM_Activity_Form_Task_SearchTaskHookSample extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$rows = array();
|
||||
// display name and activity details of all selected contacts
|
||||
$activityIDs = implode(',', $this->_activityHolderIds);
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$query = "
|
||||
SELECT at.subject as subject,
|
||||
ov.label as activity_type,
|
||||
at.activity_date_time as activity_date,
|
||||
ct.display_name as display_name
|
||||
FROM civicrm_activity at
|
||||
LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = at.id AND ac.record_type_id = {$sourceID} )
|
||||
INNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id )
|
||||
LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' )
|
||||
LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id )
|
||||
WHERE at.id IN ( $activityIDs )";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$rows[] = array(
|
||||
'subject' => $dao->subject,
|
||||
'activity_type' => $dao->activity_type,
|
||||
'activity_date' => $dao->activity_date,
|
||||
'display_name' => $dao->display_name,
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
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