First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View 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));
}
}
}

View 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");
}
}
}

View 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');
}
}
}

View 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;
}
}

View 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");
}
}

View 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);
}
}

View 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');
}
}

View 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'),
),
));
}
}

View file

@ -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));
}
}
}

View 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;
}
}

View file

@ -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,
),
));
}
}