diff --git a/civicrm.module b/civicrm.module index 123feb3..71d40b7 100644 --- a/civicrm.module +++ b/civicrm.module @@ -41,9 +41,9 @@ define('CIVICRM_UF_HEAD', TRUE); * on PHP 5.x.) * * @see CRM_Upgrade_Form::MINIMUM_PHP_VERSION - * @see CiviDrupal\PhpVersionTest::testConstantMatch() + * @see CiviBackdrop\PhpVersionTest::testConstantMatch() */ -define('CIVICRM_DRUPAL_PHP_MINIMUM', '7.0.0'); +define('CIVICRM_BACKDROP_PHP_MINIMUM', '7.0.0'); /** * Adds CiviCRM CSS and JS resources into the header. @@ -163,7 +163,7 @@ function civicrm_menu_alter(&$items) { * Display profile form in tabs on user account */ function civicrm_profile_form($form, &$form_state, $account, $profile_name) { - $output = civicrm_form_data($account, $profile_name, TRUE); + $output = civicrm_form_data($form, $account, $profile_name, TRUE); if (!empty($output)) { $form['#attributes']['enctype'] = 'multipart/form-data'; $form = array_merge($form, $output); @@ -229,8 +229,8 @@ function civicrm_profile_form_validate($form, &$form_state) { */ function civicrm_initialize() { // Check for php version and ensure its greater than minPhpVersion - if (version_compare(PHP_VERSION, CIVICRM_DRUPAL_PHP_MINIMUM) < 0) { - echo "CiviCRM requires PHP " . CIVICRM_DRUPAL_PHP_MINIMUM . "+. The web server is running PHP " . PHP_VERSION . ".

"; + if (version_compare(PHP_VERSION, CIVICRM_BACKDROP_PHP_MINIMUM) < 0) { + echo "CiviCRM requires PHP " . CIVICRM_BACKDROP_PHP_MINIMUM . "+. The web server is running PHP " . PHP_VERSION . ".

"; exit(); } _civicrm_registerClassLoader(); @@ -601,7 +601,7 @@ function civicrm_user_form_validate($form, &$form_state) { // lets suppress key generation for all validation also civicrm_key_disable(); - static $validated = FALSE; + $validated = &backdrop_static(__FUNCTION__, FALSE); if ($validated) { return; @@ -610,10 +610,9 @@ function civicrm_user_form_validate($form, &$form_state) { $validated = TRUE; // check for either user/register or admin/people/create - $register - = ((arg(0) == 'user' && arg(1) == 'register') || - (arg(0) == 'admin' && arg(1) == 'people' && arg(2) == 'create') - ) ? TRUE : FALSE; + $register = ((arg(0) == 'user' && arg(1) == 'register') || + (arg(0) == 'admin' && arg(1) == 'people' && arg(2) == 'create') + ) ? TRUE : FALSE; $userID = NULL; if (!empty($form['#user'])) { $userID = CRM_Core_BAO_UFMatch::getContactId($form['#user']->uid); @@ -631,6 +630,8 @@ function civicrm_user_form_validate($form, &$form_state) { /** * Retrieve the CiviCRM profile forms * + * @param $edit + * Form array. * @param $account * @param $profile * @param $reset @@ -638,7 +639,7 @@ function civicrm_user_form_validate($form, &$form_state) { * * @return array $output */ -function civicrm_form_data($account, $profile, $reset, $doNotProcess = FALSE) { +function civicrm_form_data($edit, $account, $profile, $reset, $doNotProcess = FALSE) { // lets suppress key generation for all CMS forms civicrm_key_disable(); @@ -667,10 +668,10 @@ function civicrm_form_data($account, $profile, $reset, $doNotProcess = FALSE) { // do not allow edit for anon users in joomla frontend, CRM-4668, unless u have checksum CRM-5228 $config = CRM_Core_Config::singleton(); if ($config->userFrameworkFrontend) { - CRM_Contact_BAO_Contact_Permission::validateOnlyChecksum($userID, $this); + CRM_Contact_BAO_Contact_Permission::validateOnlyChecksum($userID, $edit); } else { - CRM_Contact_BAO_Contact_Permission::validateChecksumContact($userID, $this); + CRM_Contact_BAO_Contact_Permission::validateChecksumContact($userID, $edit); } } $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'contact_type'); @@ -873,6 +874,7 @@ function civicrm_autoload_info() { 'civicrm_handler_filter_datetime' => 'modules/views/civicrm/civicrm_handler_filter_datetime.inc', 'civicrm_handler_filter_domain' => 'modules/views/civicrm/civicrm_handler_filter_domain.inc', 'civicrm_handler_filter_encounter_medium' => 'modules/views/civicrm/civicrm_handler_filter_encounter_medium.inc', + 'civicrm_handler_filter_group_name' => 'modules/views/civicrm/civicrm_handler_filter_group_name.inc', 'civicrm_handler_filter_group_status' => 'modules/views/civicrm/civicrm_handler_filter_group_status.inc', 'civicrm_handler_filter_option' => 'modules/views/civicrm/civicrm_handler_filter_option.inc', 'civicrm_handler_filter_pseudo_constant' => 'modules/views/civicrm/civicrm_handler_filter_pseudo_constant.inc', @@ -884,14 +886,17 @@ function civicrm_autoload_info() { 'civicrm_handler_relationship' => 'modules/views/civicrm/civicrm_handler_relationship.inc', 'civicrm_handler_relationship_address' => 'modules/views/civicrm/civicrm_handler_relationship_address.inc', 'civicrm_handler_relationship_contact2users' => 'modules/views/civicrm/civicrm_handler_relationship_contact2users.inc', + 'civicrm_handler_relationship_group' => 'modules/views/civicrm/civicrm_handler_relationship_group.inc', 'civicrm_handler_relationship_im' => 'modules/views/civicrm/civicrm_handler_relationship_im.inc', 'civicrm_handler_relationship_location' => 'modules/views/civicrm/civicrm_handler_relationship_location.inc', 'civicrm_handler_relationship_mail' => 'modules/views/civicrm/civicrm_handler_relationship_mail.inc', 'civicrm_handler_relationship_memberships_contributions' => 'modules/views/civicrm/civicrm_handler_relationship_memberships_contributions.inc', + 'civicrm_handler_relationship_participant' => 'modules/views/civicrm/civicrm_handler_relationship_participant.inc', 'civicrm_handler_relationship_phone' => 'modules/views/civicrm/civicrm_handler_relationship_phone.inc', 'civicrm_handler_relationship_relationship' => 'modules/views/civicrm/civicrm_handler_relationship_relationship.inc', + 'civicrm_handler_relationship_standard_group_contact' => 'modules/views/civicrm/civicrm_handler_relationship_standard_group_contact.inc', + 'civicrm_handler_relationship_standard_group' => 'modules/views/civicrm/civicrm_handler_relationship_standard_group.inc', 'civicrm_handler_relationship_website' => 'modules/views/civicrm/civicrm_handler_relationship_website.inc', - 'civicrm_handler_relationship_participant' => 'modules/views/civicrm/civicrm_handler_relationship_participant.inc', // sort handlers 'civicrm_handler_sort_address_pseudoconstant' => 'modules/views/civicrm/civicrm_handler_sort_address_pseudoconstant.inc', diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index e4abac1..f2ab1fb 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -1426,10 +1426,10 @@ function _civicrm_init($fail = TRUE, $load_config = TRUE) { return $init; } - if (!version_compare(phpversion(), CIVICRM_DRUPAL_PHP_MINIMUM, '>=')) { + if (!version_compare(phpversion(), CIVICRM_BACKDROP_PHP_MINIMUM, '>=')) { return drush_set_error('CIVICRM_PHP_MINIMUM', dt('CiviCRM requires PHP @required+. Drush is running PHP @current.', [ '@current' => phpversion(), - '@required' => CIVICRM_DRUPAL_PHP_MINIMUM, + '@required' => CIVICRM_BACKDROP_PHP_MINIMUM, ])); } diff --git a/modules/civicrm_engage/Engage/Report/Form/List.php b/modules/civicrm_engage/Engage/Report/Form/List.php index 758dc91..9a72d2e 100644 --- a/modules/civicrm_engage/Engage/Report/Form/List.php +++ b/modules/civicrm_engage/Engage/Report/Form/List.php @@ -13,6 +13,7 @@ * * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing + * @copyright DharmaTech (c) 2009 * $Id$ * */ @@ -36,19 +37,19 @@ class Engage_Report_Form_List extends CRM_Report_Form { /** * Address information needed in output - * @var boolean + * @var bool */ protected $_addressField = FALSE; /** * Email address needed in output - * @var boolean + * @var bool */ protected $_emailField = FALSE; /** * Demographic information needed in output - * @var boolean + * @var bool */ protected $_demoField = FALSE; @@ -56,19 +57,19 @@ class Engage_Report_Form_List extends CRM_Report_Form { /** * Phone number needed in output - * @var boolean + * @var bool */ protected $_phoneField = FALSE; /** * Group membership information needed in output - * @var boolean + * @var bool */ protected $_groupField = FALSE; /** * Voter Info information needed in output - * @var boolean + * @var bool */ protected $_voterInfoField = FALSE; diff --git a/modules/civicrm_engage/civicrm_engage.info b/modules/civicrm_engage/civicrm_engage.info index 140c679..e54816e 100755 --- a/modules/civicrm_engage/civicrm_engage.info +++ b/modules/civicrm_engage/civicrm_engage.info @@ -1,5 +1,5 @@ name = CiviEngage -description = Walklist and Phone-banking support for CiviCRM. +description = DEPRECATED Walklist and Phone-banking support for CiviCRM. Please see: https://civicrm.org/blog/jamie/civicrmengage-is-dead-long-live-civicrmengage version = 1.x-4.7 backdrop = 1.x type = module diff --git a/modules/civicrm_group_roles/civicrm_group_roles.module b/modules/civicrm_group_roles/civicrm_group_roles.module index ade507a..3ac7c59 100644 --- a/modules/civicrm_group_roles/civicrm_group_roles.module +++ b/modules/civicrm_group_roles/civicrm_group_roles.module @@ -651,9 +651,9 @@ function civicrm_group_roles_add_remove_groups($account, $roles, $op) { //end if contact_id else { - watchdog('civicrm_group_roles', 'CiviCRM contact not found for Backdrop user ID @id', array('@id' => $user->uid), WATCHDOG_ERROR); + watchdog('civicrm_group_roles', 'CiviCRM contact not found for Backdrop user ID @id', array('@id' => $account->uid), WATCHDOG_ERROR); if ($debug_mode) { - backdrop_set_message(t('CiviCRM contact not found for Backdrop user ID @id', array('@id' => $user->uid))); + backdrop_set_message(t('CiviCRM contact not found for Backdrop user ID @id', array('@id' => $account->uid))); } } diff --git a/modules/civicrm_rules/civicrm_rules.contact-eval.inc b/modules/civicrm_rules/civicrm_rules.contact-eval.inc index 6cf7ce6..99a4f27 100644 --- a/modules/civicrm_rules/civicrm_rules.contact-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.contact-eval.inc @@ -130,3 +130,24 @@ function civicrm_rules_options_list() { $settings['groups'] = _civicrm_get_groups(); return $settings; } + +/** + * Options list callback for listing of CiviCRM Tags + */ +function civicrm_rules_tags_list() { + if (!civicrm_initialize()) { + return array(); + } + $result = civicrm_api3('tag', 'get', array( + 'used_for' => 'civicrm_contact', + 'options' => array( + 'limit' => 0, + 'sort' => 'name ASC', + ), + )); + $values = array(); + foreach ($result['values'] as $tag) { + $values[$tag['id']] = $tag['name']; + } + return $values; +} diff --git a/modules/civicrm_rules/civicrm_rules_action.inc b/modules/civicrm_rules/civicrm_rules_action.inc index 3df1473..63ac7b6 100644 --- a/modules/civicrm_rules/civicrm_rules_action.inc +++ b/modules/civicrm_rules/civicrm_rules_action.inc @@ -80,7 +80,7 @@ The content of the email is: 'civicrm_tags' => array( 'type' => 'list', 'label' => t('CiviCRM Tags'), - 'options list' => 'civicrm_rules_options_list', + 'options list' => 'civicrm_rules_tags_list', ), ), 'group' => t('CiviCRM Contact'), diff --git a/modules/civicrmtheme/civicrmtheme.module b/modules/civicrmtheme/civicrmtheme.module index 3e3402e..a3bd0da 100644 --- a/modules/civicrmtheme/civicrmtheme.module +++ b/modules/civicrmtheme/civicrmtheme.module @@ -137,17 +137,10 @@ function civicrmtheme_custom_theme() { return; } - // Get the menu items. - $args = explode('?', $_GET['q']); - $path = $args[0]; - - // Get the menu for above URL. - $item = CRM_Core_Menu::get($path); - // Check for public pages // If public page and civicrm public theme is set, apply civicrm public theme // If user does not have access to CiviCRM use the public page for the error message - if (!user_access('access CiviCRM') || CRM_Utils_Array::value('is_public', $item)) { + if (!user_access('access CiviCRM') || CRM_Core_Config::singleton()->userSystem->isFrontEndPage()) { if ($public_theme) { return $public_theme; } diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index bfa1aef..90c1f5e 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -368,6 +368,19 @@ function civicrm_views_custom_data_cache(&$data, $entity_type, $group_id, $sub_t 'field' => 'entity_id', ); } + + // Expose group custom data to group relationship. + if ($join_table == 'civicrm_group') { + $data[$current_group['table_name']]['table']['join']['civicrm_group'] = array( + 'left_field' => 'id', + 'field' => 'entity_id', + ); + $data[$current_group['table_name']]['table']['join']['civicrm_group_contact'] = array( + 'left_table' => $join_table, + 'left_field' => 'id', + 'field' => 'entity_id', + ); + } } foreach ($current_group['fields'] as $key => $current_field) { diff --git a/modules/views/civicrm/civicrm_handler_field_activity.inc b/modules/views/civicrm/civicrm_handler_field_activity.inc index 0cddcbd..6cd4aeb 100644 --- a/modules/views/civicrm/civicrm_handler_field_activity.inc +++ b/modules/views/civicrm/civicrm_handler_field_activity.inc @@ -29,8 +29,7 @@ * @ingroup civicrm_field_handlers */ class civicrm_handler_field_activity extends civicrm_handler_field { - - static $_recordType; + public static $_recordType; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_country.inc b/modules/views/civicrm/civicrm_handler_field_country.inc index c7968a6..d70ae52 100644 --- a/modules/views/civicrm/civicrm_handler_field_country.inc +++ b/modules/views/civicrm/civicrm_handler_field_country.inc @@ -32,9 +32,8 @@ * */ class civicrm_handler_field_country extends civicrm_handler_field_address { - - static $_countries; - static $_countries_full; + public static $_countries; + public static $_countries_full; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_county.inc b/modules/views/civicrm/civicrm_handler_field_county.inc index 64e5a71..2958952 100644 --- a/modules/views/civicrm/civicrm_handler_field_county.inc +++ b/modules/views/civicrm/civicrm_handler_field_county.inc @@ -30,8 +30,7 @@ * */ class civicrm_handler_field_county extends civicrm_handler_field_address { - - static $_counties; + public static $_counties; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_email.inc b/modules/views/civicrm/civicrm_handler_field_email.inc index 18d7ccb..aef8434 100644 --- a/modules/views/civicrm/civicrm_handler_field_email.inc +++ b/modules/views/civicrm/civicrm_handler_field_email.inc @@ -58,7 +58,7 @@ class civicrm_handler_field_email extends civicrm_handler_field_location { } public function render($values) { - if ($this->options['link_to_user'] == 'mailto') { + if ($this->options['link_to_user'] == 'mailto' && !empty($values->{$this->field_alias})) { return l($values->{$this->field_alias}, "mailto:" . $values->{$this->field_alias}); } return check_plain($values->{$this->field_alias}); diff --git a/modules/views/civicrm/civicrm_handler_field_encounter_medium.inc b/modules/views/civicrm/civicrm_handler_field_encounter_medium.inc index bcb7292..05f522c 100644 --- a/modules/views/civicrm/civicrm_handler_field_encounter_medium.inc +++ b/modules/views/civicrm/civicrm_handler_field_encounter_medium.inc @@ -31,8 +31,7 @@ * */ class civicrm_handler_field_encounter_medium extends views_handler_field { - - static $_encounter_medium; + public static $_encounter_medium; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_file.inc b/modules/views/civicrm/civicrm_handler_field_file.inc index 95bdf17..9832b7b 100644 --- a/modules/views/civicrm/civicrm_handler_field_file.inc +++ b/modules/views/civicrm/civicrm_handler_field_file.inc @@ -66,6 +66,11 @@ class civicrm_handler_field_file extends views_handler_field { $path = sprintf('%s/imagefile', $path); } + //Reset session params as we send only id and eid to retrieve the file. + $file = new CRM_Core_Page_File(); + $file->set('filename', NULL); + $file->set('mime-type', NULL); + $fileHash = CRM_Core_BAO_File::generateFileHash($value, $fileId); return CRM_Utils_System::url($path, "id={$fileId}&eid={$value}&fcs={$fileHash}", diff --git a/modules/views/civicrm/civicrm_handler_field_option.inc b/modules/views/civicrm/civicrm_handler_field_option.inc index d96330c..530f852 100644 --- a/modules/views/civicrm/civicrm_handler_field_option.inc +++ b/modules/views/civicrm/civicrm_handler_field_option.inc @@ -29,8 +29,7 @@ * @ingroup civicrm_field_handlers */ class civicrm_handler_field_option extends civicrm_handler_field { - - static $_options; + public static $_options; public function render($values) { $this->initialize(); diff --git a/modules/views/civicrm/civicrm_handler_field_relationship_type.inc b/modules/views/civicrm/civicrm_handler_field_relationship_type.inc index dad7451..28f5b3f 100644 --- a/modules/views/civicrm/civicrm_handler_field_relationship_type.inc +++ b/modules/views/civicrm/civicrm_handler_field_relationship_type.inc @@ -31,8 +31,7 @@ * */ class civicrm_handler_field_relationship_type extends views_handler_field { - - static $_relationshipType; + public static $_relationshipType; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_state.inc b/modules/views/civicrm/civicrm_handler_field_state.inc index c425aa3..7868ccc 100644 --- a/modules/views/civicrm/civicrm_handler_field_state.inc +++ b/modules/views/civicrm/civicrm_handler_field_state.inc @@ -29,9 +29,8 @@ * @ingroup civicrm_field_handlers */ class civicrm_handler_field_state extends civicrm_handler_field_address { - - static $_states; - static $_states_full; + public static $_states; + public static $_states_full; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_field_website.inc b/modules/views/civicrm/civicrm_handler_field_website.inc index 31bfc6b..5097c09 100644 --- a/modules/views/civicrm/civicrm_handler_field_website.inc +++ b/modules/views/civicrm/civicrm_handler_field_website.inc @@ -29,8 +29,7 @@ * @ingroup civicrm_field_handlers */ class civicrm_handler_field_website extends civicrm_handler_field { - - static $_websiteType; + public static $_websiteType; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_filter_encounter_medium.inc b/modules/views/civicrm/civicrm_handler_filter_encounter_medium.inc index e5147c9..59c64ba 100644 --- a/modules/views/civicrm/civicrm_handler_filter_encounter_medium.inc +++ b/modules/views/civicrm/civicrm_handler_filter_encounter_medium.inc @@ -33,8 +33,7 @@ * */ class civicrm_handler_filter_encounter_medium extends views_handler_filter_in_operator { - - static $_encounter_medium; + public static $_encounter_medium; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_filter_group_name.inc b/modules/views/civicrm/civicrm_handler_filter_group_name.inc new file mode 100644 index 0000000..03a53ec --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_filter_group_name.inc @@ -0,0 +1,69 @@ +civi_groups)) { + if (!civicrm_initialize()) { + return; + } + $standard_or_smart = ($this->is_standard ? 'IS NULL' : 'IS NOT NULL'); + $result = civicrm_api3('Group', 'get', [ + 'return' => ["name", "title"], + 'is_hidden' => 0, + 'is_active' => 1, + 'saved_search_id' => [$standard_or_smart => 1], + 'options' => ['limit' => 0, 'sort' => "title"], + ]); + $this->civi_groups = []; + foreach ($result['values'] as $group) { + if (isset($group['name'])) { + $this->civi_groups[$group['name']] = $group['title']; + } + } + } + } + + public function get_value_options() { + if (!isset($this->value_options)) { + $this->value_title = t('Contact Group Title'); + $options = []; + foreach ($this->civi_groups as $name => $title) { + $options[$name] = $title; + } + $this->value_options = $options; + } + } + +} diff --git a/modules/views/civicrm/civicrm_handler_filter_group_status.inc b/modules/views/civicrm/civicrm_handler_filter_group_status.inc index 0e3aa12..6ca323e 100644 --- a/modules/views/civicrm/civicrm_handler_filter_group_status.inc +++ b/modules/views/civicrm/civicrm_handler_filter_group_status.inc @@ -30,7 +30,7 @@ */ class civicrm_handler_filter_group_status extends views_handler_filter_in_operator { - static $groupContactStatus = NULL; + public static $groupContactStatus = NULL; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_filter_option.inc b/modules/views/civicrm/civicrm_handler_filter_option.inc index ac772a1..d408415 100644 --- a/modules/views/civicrm/civicrm_handler_filter_option.inc +++ b/modules/views/civicrm/civicrm_handler_filter_option.inc @@ -27,8 +27,7 @@ * CiviCRM handler for options with the in operator. */ class civicrm_handler_filter_option extends views_handler_filter_in_operator { - - static $_options; + public static $_options; public function get_value_options() { $this->initialize(); diff --git a/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc b/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc index 4e74bc6..821bf81 100644 --- a/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc +++ b/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc @@ -32,8 +32,7 @@ * */ class civicrm_handler_filter_relationship_type extends views_handler_filter_in_operator { - - static $_relationshipType; + public static $_relationshipType; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_relationship_group.inc b/modules/views/civicrm/civicrm_handler_relationship_group.inc new file mode 100644 index 0000000..a84956c --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_group.inc @@ -0,0 +1,181 @@ +is_standard ? 'IS NULL' : 'IS NOT NULL'); + $result = civicrm_api3('Group', 'get', [ + 'return' => ["name", "title", "group_type"], + 'is_hidden' => 0, + 'is_active' => 1, + 'saved_search_id' => [$standard_or_smart => 1], + 'options' => ['limit' => 0, 'sort' => "title"], + ]); + $this->civi_groups = []; + foreach ($result['values'] as $group) { + $group_types = []; + if (!empty($group['group_type'])) { + foreach ((array) $group['group_type'] as $type) { + if (!empty($type)) { + $group_types[] = (isset(self::$civi_group_types[$type]) ? self::$civi_group_types[$type] : $type); + } + } + } + + if (isset($group['name'])) { + $group_type = ''; + if (!empty($group_types)) { + $group_type = implode(', ', $group_types); + } + $this->civi_groups[$group['name']] = $group['title'] . ' | ' . $group_type; + } + } + } + + /** + * Add additional options + * to the view. By defining these here, Views will take care of saving the + * values submitted from the options form. + */ + public function option_definition() { + $options = parent::option_definition(); + $options['civi_group_type'] = ['default' => NULL]; + $options['civi_group_name'] = ['default' => NULL]; + return $options; + } + + /** + * Relationship configuration form. + */ + public function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + $form['civi_group_type'] = [ + '#type' => 'select', + '#multiple' => TRUE, + '#title' => 'Choose a specific group type', + '#options' => self::$civi_group_types, + '#description' => t('Choose to limit this relationship to one or more specific types of CiviCRM group.'), + '#default_value' => $this->options['civi_group_type'], + ]; + $form['civi_group_name'] = [ + '#type' => 'select', + '#multiple' => TRUE, + '#title' => 'Choose a specific group', + '#options' => $this->civi_groups, + '#description' => t('Choose to limit this relationship to one or more specific CiviCRM groups.'), + '#default_value' => $this->options['civi_group_name'], + ]; + } + + public function join_required($join = []) { + if (!empty($this->options['required'])) { + $join->type = 'INNER'; + } + return $join; + } + + public function join_group_type($join = []) { + $extra = []; + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['civi_group_type']) && $this->options['civi_group_type']) { + $sep = CRM_Core_DAO::VALUE_SEPARATOR; + + $extra[] = [ + 'value' => "($sep" . implode("$sep|$sep", $this->options['civi_group_type']) . "$sep)", + 'numeric' => FALSE, + 'field' => 'group_type', + 'operator' => 'RLIKE', + ]; + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + public function join_group_name($join = []) { + $extra = []; + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['civi_group_name']) && $this->options['civi_group_name']) { + $extra[] = [ + 'value' => $this->options['civi_group_name'], + 'numeric' => FALSE, + 'field' => 'name', + ]; + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + public function join_group_active_not_hidden($join = []) { + $extra = []; + if (isset($join->extra)) { + $extra = $join->extra; + } + $extra[] = [ + 'value' => 1, + 'numeric' => TRUE, + 'field' => 'is_active', + ]; + $extra[] = [ + 'value' => 0, + 'numeric' => TRUE, + 'field' => 'is_hidden', + ]; + + $join->extra = $extra; + return $join; + } + + public function get_join() { + $join = parent::get_join(); + $join = $this->join_group_active_not_hidden($join); + $join = $this->join_required($join); + $join = $this->join_group_type($join); + $join = $this->join_group_name($join); + return $join; + } + + /** + * Called to implement a relationship in a query. + */ + public function query() { + $join = $this->get_join(); + $this->alias = $this->query->add_table($this->table, $this->relationship, $join); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = [ + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, + ]; + + } + +} diff --git a/modules/views/civicrm/civicrm_handler_relationship_im.inc b/modules/views/civicrm/civicrm_handler_relationship_im.inc index ad2ace4..66e52bf 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_im.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_im.inc @@ -30,7 +30,7 @@ */ class civicrm_handler_relationship_im extends civicrm_handler_relationship_location { - static $_provider; + public static $_provider; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_relationship_participant.inc b/modules/views/civicrm/civicrm_handler_relationship_participant.inc index 31e90a0..cfe5c40 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_participant.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_participant.inc @@ -6,8 +6,7 @@ * to the join clause based on relationship_type_id and is_active. */ class civicrm_handler_relationship_participant extends views_handler_relationship { - - static $participant_types; + public static $participant_types; /** * Preload the list of participant roles and store in the static variable diff --git a/modules/views/civicrm/civicrm_handler_relationship_phone.inc b/modules/views/civicrm/civicrm_handler_relationship_phone.inc index 38b6ffc..a5e70dc 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_phone.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_phone.inc @@ -30,7 +30,7 @@ */ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_location { - static $_phoneType; + public static $_phoneType; public function construct() { parent::construct(); diff --git a/modules/views/civicrm/civicrm_handler_relationship_standard_group.inc b/modules/views/civicrm/civicrm_handler_relationship_standard_group.inc new file mode 100644 index 0000000..801b286 --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_standard_group.inc @@ -0,0 +1,15 @@ +is_standard = TRUE; + parent::construct(); + } + +} diff --git a/modules/views/civicrm/civicrm_handler_relationship_standard_group_contact.inc b/modules/views/civicrm/civicrm_handler_relationship_standard_group_contact.inc new file mode 100644 index 0000000..47005ae --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_standard_group_contact.inc @@ -0,0 +1,136 @@ + ["name", "title"], + 'is_hidden' => 0, + 'is_active' => 1, + 'saved_search_id' => ['IS NULL' => 1], + 'options' => ['limit' => 0, 'sort' => "title"], + ]); + foreach ($result['values'] as $group) { + if (isset($group['name'])) { + $this->group_ids[$group['name']] = $group['id']; + $this->group_titles[$group['name']] = $group['title']; + } + } + } + + /** + * Add additional options + * to the view. By defining these here, Views will take care of saving the + * values submitted from the options form. + */ + public function option_definition() { + $options = parent::option_definition(); + $options['group_status'] = ['default' => 'Added']; + $options['group_names'] = ['default' => NULL]; + return $options; + } + + /** + * Relationship configuration form. + */ + public function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + $form['group_status'] = [ + '#type' => 'select', + '#multiple' => TRUE, + '#title' => 'Choose a specific group status', + '#options' => self::$group_status, + '#description' => t('Choose to limit this relationship to one or more specific status of CiviCRM group.'), + '#default_value' => $this->options['group_status'], + ]; + $form['group_names'] = [ + '#type' => 'select', + '#multiple' => TRUE, + '#title' => 'Choose a specific group', + '#options' => $this->group_titles, + '#description' => t('Choose to limit this relationship to one or more specific CiviCRM groups.'), + '#default_value' => $this->options['group_names'], + ]; + } + + public function join_required($join = []) { + if (!empty($this->options['required'])) { + $join->type = 'INNER'; + } + return $join; + } + + public function join_group_contact($join = []) { + $extra = []; + if (isset($join->extra)) { + $extra = $join->extra; + } + if (!empty($this->options['group_status'])) { + $extra[] = [ + 'value' => $this->options['group_status'], + 'numeric' => FALSE, + 'field' => 'status', + ]; + } + if (!empty($this->options['group_names'])) { + $values = []; + foreach (array_keys($this->options['group_names']) as $name) { + $values[] = $this->group_ids[$name]; + } + $extra[] = [ + 'value' => $values, + 'numeric' => TRUE, + 'field' => 'group_id', + ]; + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + public function get_join() { + $join = parent::get_join(); + $join = $this->join_required($join); + $join = $this->join_group_contact($join); + return $join; + } + + /** + * Called to implement a relationship in a query. + */ + public function query() { + $join = $this->get_join(); + $this->alias = $this->query->add_table($this->table, $this->relationship, $join); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = [ + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, + ]; + } + +} diff --git a/modules/views/civicrm/civicrm_handler_relationship_website.inc b/modules/views/civicrm/civicrm_handler_relationship_website.inc index 26162f5..c118b9f 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_website.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_website.inc @@ -30,7 +30,7 @@ */ class civicrm_handler_relationship_website extends civicrm_handler_relationship_location { - static $_websiteType; + public static $_websiteType; public function construct() { parent::construct(); diff --git a/modules/views/components/civicrm.contribute.inc b/modules/views/components/civicrm.contribute.inc index 9fba647..7116aae 100644 --- a/modules/views/components/civicrm.contribute.inc +++ b/modules/views/components/civicrm.contribute.inc @@ -404,6 +404,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'filter' => array( 'handler' => 'civicrm_handler_filter_datetime', 'is date' => TRUE, + 'allow empty' => TRUE, ), 'sort' => array( 'handler' => 'civicrm_handler_sort_date', @@ -425,6 +426,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'filter' => array( 'handler' => 'civicrm_handler_filter_datetime', 'is date' => TRUE, + 'allow empty' => TRUE, ), 'sort' => array( 'handler' => 'civicrm_handler_sort_date', diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index df5e4a3..66c3fd1 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -972,6 +972,27 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //FULL STREET ADDRESS SUPPLEMENTAL 3 + $data['civicrm_address']['supplemental_address_3'] = array( + 'title' => t('3rd Supplemental Street Address'), + 'help' => t('3rd Supplemental Street Address such as Apartment or Suite Number or Department'), + 'field' => array( + 'handler' => 'civicrm_handler_field_address', + 'click sortable' => TRUE, + 'dao class' => 'CRM_Core_DAO_Address', + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + //CITY OR SUBURB THE ADDRESS IS AT $data['civicrm_address']['city'] = array( 'title' => t('City / Suburb'), @@ -2791,6 +2812,22 @@ function _civicrm_core_data(&$data, $enabled) { } // Add support for CivicRM groups table + $data['civicrm_group_contact']['table']['group'] = t('CiviCRM Groups'); + + $data['civicrm_group_contact']['table']['join']['civicrm_contact'] = array( + 'left_field' => 'id', + 'field' => 'contact_id', + ); + + $data['civicrm_contact']['table']['join']['civicrm_group_contact'] = array( + 'left_field' => 'contact_id', + 'field' => 'id', + ); + + $data['civicrm_group_contact']['table']['join']['civicrm_group_contact'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); $data['civicrm_group']['table']['group'] = t('CiviCRM Groups'); @@ -2800,43 +2837,52 @@ function _civicrm_core_data(&$data, $enabled) { 'help' => t("View displays CiviCRM Groups."), ); - $data['civicrm_group']['table']['join']['civicrm_contact'] = array( - 'left_table' => 'civicrm_group_contact', + $data['civicrm_group']['table']['join']['civicrm_contact_contact'] = array( 'left_field' => 'group_id', 'field' => 'id', ); - $data['civicrm_group_contact']['table']['join']['civicrm_contact'] = array( + $data['civicrm_group_contact']['table']['join']['civicrm_group'] = array( // Directly links to group table 'left_field' => 'id', - 'field' => 'contact_id', + 'field' => 'group_id', ); - $data['civicrm_group_contact']['table']['group'] = t('CiviCRM Groups'); - $data['civicrm_group_status']['table']['group'] = t('Contact Group Status'); + $data['civicrm_group']['table']['join']['civicrm_group'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); - $data['civicrm_group_contact']['status'] = array( - 'title' => t('Contact Status'), - 'help' => t('The group status of the contact'), - 'field' => array( - 'handler' => 'civicrm_handler_filter_group_status', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'civicrm_handler_filter_group_status', - 'allow empty' => TRUE, - ), + $data['civicrm_group']['table']['join']['civicrm_contact'] = array( + 'left_table' => 'civicrm_group_contact', + 'left_field' => 'group_id', + 'field' => 'id', ); // CiviCRM Groups - FIELDS - - // Numeric Group ID + //Group Contact ID + $data['civicrm_group_contact']['id'] = array( + 'title' => t('Contact in Standard Group'), + 'help' => t('The contact is part of a standard group'), + 'relationship' => array( + 'base' => 'civicrm_contact', + 'base field' => 'id', + 'relationship table' => 'civicrm_group_contact', + 'relationship field' => 'contact_id', + 'handler' => 'civicrm_handler_relationship_standard_group_contact', + 'label' => t('CiviCRM Standard Group Contact'), + ), + ); + // Group Status $data['civicrm_group_contact']['status'] = array( 'title' => t('Contact Status'), 'help' => t('The group status of the contact'), 'field' => array( - 'handler' => 'civicrm_handler_filter_group_status', + 'handler' => 'civicrm_handler_field_pseudo_constant', 'click sortable' => TRUE, + 'pseudo class' => 'CRM_Contact_BAO_GroupContact', + 'pseudo method' => 'buildOptions', + 'pseudo args' => array('status'), ), 'filter' => array( 'handler' => 'civicrm_handler_filter_group_status', @@ -2844,8 +2890,6 @@ function _civicrm_core_data(&$data, $enabled) { ), ); - //CiviCRM Groups - FIELDS - //Numeric Group ID $data['civicrm_group']['id'] = array( 'title' => t('Group ID'), @@ -2865,7 +2909,16 @@ function _civicrm_core_data(&$data, $enabled) { 'sort' => array( 'handler' => 'views_handler_sort', ), + 'relationship' => array( + 'base' => 'civicrm_group_contact', + 'base field' => 'group_id', + 'relationship table' => 'civicrm_group', + 'relationship field' => 'id', + 'handler' => 'civicrm_handler_relationship_standard_group', + 'label' => t('CiviCRM Group'), + ), ); + //Is Group Active? $data['civicrm_group']['is_active'] = array( 'title' => t('Is Active'), @@ -2885,8 +2938,23 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + $data['civicrm_group']['name'] = array( + 'title' => t('Machine Name'), + 'help' => t('Group Machine Name'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument', + ), + 'filter' => array( + 'handler' => 'civicrm_handler_filter_group_name', + ), + ); + $data['civicrm_group']['title'] = array( - 'title' => t('Title'), + 'title' => t('Title [Deprecated - Use Name or new Title]'), 'help' => t('Group Title'), 'real field' => 'id', 'field' => array( @@ -2907,6 +2975,27 @@ function _civicrm_core_data(&$data, $enabled) { 'handler' => 'views_handler_sort', ), ); + + $data['civicrm_group']['title_'] = array( + 'title' => t('Title'), + 'help' => t('Group Title'), + 'real field' => 'title', + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + $data['civicrm_group']['description'] = array( 'title' => t('Description'), 'help' => t('Description of the Group'), diff --git a/modules/views/components/civicrm.event.inc b/modules/views/components/civicrm.event.inc index 2c8fc69..035a841 100644 --- a/modules/views/components/civicrm.event.inc +++ b/modules/views/components/civicrm.event.inc @@ -579,6 +579,25 @@ function _civicrm_event_data(&$data, $enabled) { 'name' => 'register_date', )); + //BOOLEAN : IS test registration + $data['civicrm_participant']['is_test'] = array( + 'title' => t('Test Registration?'), + 'help' => t('Is this a test registration?'), + 'field' => array( + 'handler' => 'views_handler_field_boolean', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_boolean_operator', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + //BOOLEAN : IS SET TO PAY LATER $data['civicrm_participant']['is_pay_later'] = array( 'title' => t('Is Pay Later'), diff --git a/tests/phpunit/CiviBackdrop/PHPVersionTest.php b/tests/phpunit/CiviBackdrop/PhpVersionTest.php similarity index 72% rename from tests/phpunit/CiviBackdrop/PHPVersionTest.php rename to tests/phpunit/CiviBackdrop/PhpVersionTest.php index 00e116a..e8ee10c 100644 --- a/tests/phpunit/CiviBackdrop/PHPVersionTest.php +++ b/tests/phpunit/CiviBackdrop/PhpVersionTest.php @@ -7,17 +7,17 @@ class PhpVersionTest extends \PHPUnit\Framework\TestCase implements EndToEndInterface { /** - * CIVICRM_DRUPAL_PHP_MINIMUM (civicrm.module) should match MINIMUM_PHP_VERSION (CRM/Upgrade/Form.php). + * CIVICRM_BACKDROP_PHP_MINIMUM (civicrm.module) should match MINIMUM_PHP_VERSION (CRM/Upgrade/Form.php). */ public function testConstantMatch() { $constantFile = $this->getBackdropModulePath() . '/civicrm.module'; $this->assertFileExists($constantFile); $content = file_get_contents($constantFile); - if (preg_match(";define\\('CIVICRM_DRUPAL_PHP_MINIMUM', '(.*)'\\);", $content, $m)) { + if (preg_match(";define\\('CIVICRM_BACKDROP_PHP_MINIMUM', '(.*)'\\);", $content, $m)) { $this->assertEquals(\CRM_Upgrade_Form::MINIMUM_PHP_VERSION, $m[1]); } else { - $this->fail('Failed to find CIVICRM_DRUPAL_PHP_MINIMUM in ' . $constantFile); + $this->fail('Failed to find CIVICRM_BACKDROP_PHP_MINIMUM in ' . $constantFile); } } @@ -27,14 +27,14 @@ public function testConstantMatch() { public function testInfoMatch() { $infoFile = $this->getBackdropModulePath() . '/civicrm.info'; $this->assertFileExists($infoFile); - $info = drupal_parse_info_file($infoFile); + $info = backdrop_parse_info_file($infoFile); $expectMajorMinor = preg_replace(';^(\d+\.\d+)\..*$;', '\1', \CRM_Upgrade_Form::MINIMUM_PHP_VERSION); $this->assertEquals($expectMajorMinor, $info['php']); } /** * @return string - * Ex: '/var/www/sites/all/modules/civicrm/drupal' + * Ex: '/var/www/sites/all/modules/civicrm/backdrop' */ protected function getBackdropModulePath() { return dirname(dirname(dirname(__DIR__)));