<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
- * This class contains all the function that are called using AJAX
+ * This class contains all the function that are called using AJAX.
*/
class CRM_Admin_Page_AJAX {
/**
- * CRM-12337 Output navigation menu as executable javascript
+ * CRM-12337 Output navigation menu as executable javascript.
+ *
* @see smarty_function_crmNavigationMenu
*/
public static function getNavigationMenu() {
}
/**
- * Process drag/move action for menu tree
+ * Process drag/move action for menu tree.
*/
public static function menuTree() {
CRM_Core_BAO_Navigation::processNavigation($_GET);
}
/**
- * Build status message while.
- * enabling/ disabling various objects
+ * Build status message while enabling/ disabling various objects.
*/
public static function getStatusMsg() {
require_once 'api/v3/utils.php';
public static function mergeTagList() {
$name = CRM_Utils_Type::escape($_GET['term'], 'String');
$fromId = CRM_Utils_Type::escape($_GET['fromId'], 'Integer');
- $limit = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10);
+ $limit = Civi::settings()->get('search_autocomplete_count');
// build used-for clause to be used in main query
$usedForTagA = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $fromId, 'used_for');
// query to list mergable tags
$query = "
-SELECT t1.name, t1.id, t1.used_for, t2.name as parent
+SELECT t1.name, t1.id, t1.used_for, t1.color, t2.name as parent
FROM civicrm_tag t1
LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
WHERE t1.id <> {$fromId} AND
$row = array(
'id' => $dao->id,
'text' => ($dao->parent ? "{$dao->parent} :: " : '') . $dao->name,
+ 'color' => isset($dao->color) ? $dao->color : NULL,
);
// Add warning about used_for types
if (!empty($dao->used_for)) {
CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}
- $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($_GET['mappingID'], $_GET['isLimit']);
+ $mapping = CRM_Core_BAO_ActionSchedule::getMapping($_GET['mappingID']);
+ $dateFieldLabels = $mapping ? $mapping->getDateFields() : array();
+
+ // The UX here is quirky -- for "Activity" types, there's a simple drop "Recipients"
+ // dropdown which is always displayed. For other types, the "Recipients" drop down is
+ // conditional upon the weird isLimit ('Limit To / Also Include / Neither') dropdown.
+ $noThanksJustKidding = !$_GET['isLimit'];
+ if ($mapping instanceof CRM_Activity_ActionMapping || !$noThanksJustKidding) {
+ $entityRecipientLabels = $mapping ? ($mapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients()) : array();
+ }
+ else {
+ $entityRecipientLabels = CRM_Core_BAO_ActionSchedule::getAdditionalRecipients();
+ }
+ $recipientMapping = array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels));
$output = array(
- 'sel4' => array(),
- 'sel5' => array(),
- 'recipientMapping' => $selectionOptions['recipientMapping'],
+ 'sel4' => CRM_Utils_Array::toKeyValueRows($dateFieldLabels),
+ 'sel5' => CRM_Utils_Array::toKeyValueRows($entityRecipientLabels),
+ 'recipientMapping' => $recipientMapping,
);
- foreach (array(4, 5) as $sel) {
- foreach ($selectionOptions["sel$sel"] as $id => $name) {
- $output["sel$sel"][] = array(
- 'value' => $name,
- 'key' => $id,
- );
- }
- }
CRM_Utils_JSON::output($output);
}
+ /**
+ * (Scheduled Reminders) Get the list of possible recipient filters.
+ *
+ * Ex: GET /civicrm/ajax/recipientListing?mappingID=contribpage&recipientType=
+ */
+ public static function recipientListing() {
+ $mappingID = filter_input(INPUT_GET, 'mappingID', FILTER_VALIDATE_REGEXP, array(
+ 'options' => array(
+ 'regexp' => '/^[a-zA-Z0-9_\-]+$/',
+ ),
+ ));
+ $recipientType = filter_input(INPUT_GET, 'recipientType', FILTER_VALIDATE_REGEXP, array(
+ 'options' => array(
+ 'regexp' => '/^[a-zA-Z0-9_\-]+$/',
+ ),
+ ));
+
+ CRM_Utils_JSON::output(array(
+ 'recipients' => CRM_Utils_Array::toKeyValueRows(CRM_Core_BAO_ActionSchedule::getRecipientListing($mappingID, $recipientType)),
+ ));
+ }
+
public static function mergeTags() {
$tagAId = CRM_Utils_Type::escape($_POST['fromId'], 'Integer');
$tagBId = CRM_Utils_Type::escape($_POST['toId'], 'Integer');