From 2529d1b27971e97075a451ffade6a5e1b9abf4a3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 15 Dec 2015 16:53:13 -0500 Subject: [PATCH 01/74] CRM-17646 - Refactor out CRM_Core_BAO_CustomField::getDisplayValue --- modules/views/civicrm/civicrm_handler_field_custom.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_custom.inc b/modules/views/civicrm/civicrm_handler_field_custom.inc index c0b78f8..b89a8cc 100644 --- a/modules/views/civicrm/civicrm_handler_field_custom.inc +++ b/modules/views/civicrm/civicrm_handler_field_custom.inc @@ -71,8 +71,7 @@ class civicrm_handler_field_custom extends views_handler_field { // get the field id from the db if (!empty($this->definition['title'])) { $customFieldID = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField', $this->definition['title'], 'id', 'label'); - require_once 'CRM/Core/BAO/CustomOption.php'; - return CRM_Core_BAO_CustomOption::getOptionLabel($customFieldID, $value); + return CRM_Core_BAO_CustomField::displayValue($value, $customFieldID); } // could not get custom id, lets just return what we have return $value; From 960ff7ef4c3b06328f5eb2bc869fab3c37018c51 Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Tue, 22 Dec 2015 15:01:31 +0100 Subject: [PATCH 02/74] Added load_generated_data option when installing CiviCRM. --- drush/civicrm.drush.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 1d6017e..cbee13a 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -94,6 +94,7 @@ function civicrm_drush_command() { 'langtarfile' => 'Path to your l10n tar.gz file.', 'site_url' => 'Base Url for your drupal/CiviCRM website without http (e.g. mysite.com)', 'ssl' => 'Using ssl for your drupal/CiviCRM website if set to on (e.g. --ssl=on)', + 'load_generated_data' => 'Loads the demo generated data. Defaults to FALSE.', ), 'aliases' => array('cvi'), ); @@ -328,6 +329,7 @@ function drush_civicrm_install() { $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); $modPath = "$drupalRoot/$crmpath"; $lang = drush_get_option('lang', ''); + $loadGeneratedData = drush_get_option('load_generated_data', FALSE); if (!is_dir("$modPath/civicrm")) { // extract tarfile at right place @@ -351,7 +353,7 @@ function drush_civicrm_install() { } // install database - _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $modPath, $lang); + _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $modPath, $lang, $loadGeneratedData); // generate civicrm.settings.php file _civicrm_generate_settings_file($dbuser, $dbpass, $dbhost, $dbname, $modPath); @@ -370,7 +372,7 @@ function _civicrm_extract_tarfile($destinationPath, $option = 'tarfile') { } function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, - $modPath, $lang + $modPath, $lang, $loadGeneratedData ) { $drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT'); $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); @@ -408,6 +410,9 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, civicrm_source($dsn, $data_file); civicrm_source($dsn, $acl_file); + if ($loadGeneratedData) { + civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_generated.mysql', TRUE); + } drush_log(dt("CiviCRM database loaded successfully."), 'ok'); } From fd4d7e5b541dd8b078219c61ad7f3f2f7d19bb31 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 22 Dec 2015 21:01:01 -0500 Subject: [PATCH 03/74] Update icons --- .../templates/CRM/Contact/Page/Inline/Demographics.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl index 15e52ec..e107800 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl @@ -27,7 +27,7 @@
{if $permission EQ 'edit'}
- {ts}Edit demographics{/ts} + {ts}Edit demographics{/ts}
{/if}
From 5fbb0c7e30ad9ba59beeca39212f2745ef4c5a05 Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Wed, 23 Dec 2015 12:39:12 +0100 Subject: [PATCH 04/74] Return the conf array when calling civicrm-sql-conf so it can be used elsewhere --- drush/civicrm.drush.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 1d6017e..db46f2f 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -1228,6 +1228,10 @@ function drush_civicrm_sqlconf() { if (version_compare(DRUSH_VERSION, 6, '>=')) { drush_print_r($conf); } + + // Return the conf array too, so it can be used as array when called through + // a php function (e.g. drush_invoke_process). + return $conf; } /** From e2daf52615135c9aa0bcda9c133d112396ffa614 Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Tue, 5 Jan 2016 11:56:12 +0000 Subject: [PATCH 05/74] CRM-15768: Correct module version --- civicrm.info | 2 +- modules/civicrm_contact_ref/civicrm_contact_ref.info | 3 +-- modules/civicrm_engage/civicrm_engage.info | 2 +- modules/civicrm_group_roles/civicrm_group_roles.info | 2 +- modules/civicrm_member_roles/civicrm_member_roles.info | 2 +- modules/civicrm_og_sync/civicrm_og_sync.info | 2 +- modules/civicrm_rules/civicrm_rules.info | 2 +- modules/civicrmtheme/civicrmtheme.info | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/civicrm.info b/civicrm.info index 4cd14c2..37cc214 100644 --- a/civicrm.info +++ b/civicrm.info @@ -1,6 +1,6 @@ name = CiviCRM description = Constituent relationship management system. Allows sites to manage contacts, relationships and groups, and track contact activities, contributions, memberships and events. See the CiviCRM website for more information. -version = 4.7 +version = 7.x-4.7 package = CiviCRM core = 7.x project = civicrm diff --git a/modules/civicrm_contact_ref/civicrm_contact_ref.info b/modules/civicrm_contact_ref/civicrm_contact_ref.info index 4ee0b7e..e985b3b 100644 --- a/modules/civicrm_contact_ref/civicrm_contact_ref.info +++ b/modules/civicrm_contact_ref/civicrm_contact_ref.info @@ -1,6 +1,6 @@ name = CiviCRM Contact Reference Field description = Makes a CiviCRM Contact Reference Field. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm @@ -12,4 +12,3 @@ dependencies[] = list files[] = civicrm_contact_ref.install files[] = civicrm_contact_ref.module files[] = civicrm_contact_ref.feeds.inc - diff --git a/modules/civicrm_engage/civicrm_engage.info b/modules/civicrm_engage/civicrm_engage.info index 20f7e61..3fd1235 100755 --- a/modules/civicrm_engage/civicrm_engage.info +++ b/modules/civicrm_engage/civicrm_engage.info @@ -1,6 +1,6 @@ name = CiviEngage description = Walklist and Phone-banking support for CiviCRM. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm diff --git a/modules/civicrm_group_roles/civicrm_group_roles.info b/modules/civicrm_group_roles/civicrm_group_roles.info index 51177b3..6529545 100644 --- a/modules/civicrm_group_roles/civicrm_group_roles.info +++ b/modules/civicrm_group_roles/civicrm_group_roles.info @@ -1,6 +1,6 @@ name = CiviGroup Roles Sync description = Sync Drupal Roles to CiviCRM Groups. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm diff --git a/modules/civicrm_member_roles/civicrm_member_roles.info b/modules/civicrm_member_roles/civicrm_member_roles.info index 5d5f1c2..593cbfc 100644 --- a/modules/civicrm_member_roles/civicrm_member_roles.info +++ b/modules/civicrm_member_roles/civicrm_member_roles.info @@ -1,6 +1,6 @@ name = CiviMember Roles Sync description = Synchronize CiviCRM Contacts with Membership Status to a specified Drupal Role both automatically and manually. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm diff --git a/modules/civicrm_og_sync/civicrm_og_sync.info b/modules/civicrm_og_sync/civicrm_og_sync.info index f888ee8..a8249d0 100644 --- a/modules/civicrm_og_sync/civicrm_og_sync.info +++ b/modules/civicrm_og_sync/civicrm_og_sync.info @@ -1,6 +1,6 @@ name = CiviCRM OG Sync description = Synchronize Organic Groups and CiviCRM Groups and ACL's. More information at: http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+vs.+Organic+Groups -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm diff --git a/modules/civicrm_rules/civicrm_rules.info b/modules/civicrm_rules/civicrm_rules.info index 4aff812..65fd93e 100644 --- a/modules/civicrm_rules/civicrm_rules.info +++ b/modules/civicrm_rules/civicrm_rules.info @@ -1,6 +1,6 @@ name = CiviCRM Rules Integration description = Integrate CiviCRM and Drupal Rules Module. Expose Contact, Contribution and other Objects along with Form / Page Operations. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm diff --git a/modules/civicrmtheme/civicrmtheme.info b/modules/civicrmtheme/civicrmtheme.info index 879d33c..5cd4e15 100644 --- a/modules/civicrmtheme/civicrmtheme.info +++ b/modules/civicrmtheme/civicrmtheme.info @@ -1,6 +1,6 @@ name = CiviCRM Theme description = Define alternate themes for CiviCRM. -version = 4.6 +version = 7.x-4.7 core = 7.x package = CiviCRM project = civicrm From c096bf25445faa52cd93a9158cd4f9c585f499c1 Mon Sep 17 00:00:00 2001 From: Laryn Date: Thu, 7 Jan 2016 13:23:02 -0600 Subject: [PATCH 06/74] Fix syntax error --- .../civicrm/civicrm_handler_relationship_relationship.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_relationship_relationship.inc b/modules/views/civicrm/civicrm_handler_relationship_relationship.inc index ceddd3a..d172f69 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_relationship.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_relationship.inc @@ -53,7 +53,7 @@ class civicrm_handler_relationship_relationship extends views_handler_relationsh '#multiple' => TRUE, '#title' => 'Choose a specific relationship type', '#options' => self::$relationship_types, - '#description' => t('Choose to limit this relationship to one or more specific types of CiviCRM relationship. Hold the Shift key to select or + '#description' => t('Choose to limit this relationship to one or more specific types of CiviCRM relationship.'), '#default_value' => $this->options['relationship_type'], ); $form['relationship_state'] = array( @@ -89,4 +89,4 @@ class civicrm_handler_relationship_relationship extends views_handler_relationsh ); } } -} \ No newline at end of file +} From b19195dce592b32bc99ca47e48f658b6ae85104e Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Mon, 25 Jan 2016 10:46:34 +0000 Subject: [PATCH 07/74] CRM-17871: Improve administration forms, add debug mode --- .../civicrm_group_roles.module | 105 ++++++++++++------ 1 file changed, 69 insertions(+), 36 deletions(-) diff --git a/modules/civicrm_group_roles/civicrm_group_roles.module b/modules/civicrm_group_roles/civicrm_group_roles.module index 27462f0..8c5e9aa 100644 --- a/modules/civicrm_group_roles/civicrm_group_roles.module +++ b/modules/civicrm_group_roles/civicrm_group_roles.module @@ -260,8 +260,8 @@ function civicrm_group_roles_civicrm_post($op, $objectName, $objectId, &$objectR * Helper function to add a role to a given user * Copied from user.module function user_multiple_role_edit() * - * @param $uid The user id of the account to modify - * @param $rid Thedebug_backtrace role id being added + * @param int $uid The user id of the account to modify + * @param int $rid The debug_backtrace role id being added */ function civicrm_group_roles_add_role($uid, $rid, $role_name) { $account = user_load((int)$uid, TRUE); @@ -338,36 +338,43 @@ function civicrm_group_roles_menu() { 'type' => MENU_NORMAL_ITEM, ); $items['admin/config/civicrm/civicrm_group_roles/show_rules'] = array( - 'title' => t('List Association Rules'), + 'title' => t('Association rules'), 'access callback' => 'user_access', 'access arguments' => array('access civicrm group role setting'), 'weight' => -5, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/config/civicrm/civicrm_group_roles/add_rule'] = array( - 'title' => t('Add Association Rule'), + 'title' => t('Add association rule'), 'page callback' => 'drupal_get_form', 'page arguments' => array('civicrm_group_roles_add_rule_form'), 'access callback' => 'user_access', 'access arguments' => array('access civicrm group role setting'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_ACTION, ); $items['admin/config/civicrm/civicrm_group_roles/add_rule/%rule_id'] = array( - 'title' => t('Add Association Rule'), + 'title' => t('Edit association rule'), 'page callback' => 'drupal_get_form', 'page arguments' => array('civicrm_group_roles_add_rule_form', 1), 'access callback' => 'user_access', 'access arguments' => array('access civicrm group role setting'), - 'type' => MENU_LOCAL_TASK, ); $items['admin/config/civicrm/civicrm_group_roles/manual_sync'] = array( - 'title' => t('Manually Synchronize'), + 'title' => t('Manually synchronize'), 'page callback' => 'drupal_get_form', 'page arguments' => array('civicrm_group_roles_manual_sync'), 'access callback' => 'user_access', 'access arguments' => array('access civicrm group role setting'), 'type' => MENU_LOCAL_TASK, ); + $items['admin/config/civicrm/civicrm_group_roles/settings'] = array( + 'title' => t('Settings'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('civicrm_group_roles_settings'), + 'access callback' => 'user_access', + 'access arguments' => array('access civicrm group role setting'), + 'type' => MENU_LOCAL_TASK, + ); return $items; } @@ -413,7 +420,7 @@ function civicrm_group_roles_show_rules($action = NULL, $id = NULL) { $groups = CRM_Utils_Array::value('values', $groups); //Begin building main output table. - $header = array('rid' => t('Rule ID'), 'name' => t('Rule Name (\'CiviCRM Group\' <--> \'Drupal Role\')'), 'op' => t('Operation')); + $header = array('rid' => t('Rule ID'), 'name' => t('Rule Name (\'CiviCRM Group\' <--> \'Drupal Role\')'), 'op' => t('Operations')); $data = array(); $rules = db_query('SELECT * FROM {civicrm_group_roles_rules} ORDER BY id ASC')->fetchAll(); @@ -427,23 +434,23 @@ function civicrm_group_roles_show_rules($action = NULL, $id = NULL) { } if (!empty($data)) { - $output['data'] = array( - '#prefix' => t("Use the 'Add Association Rule' form to add new rules.") . '

', '#theme' => 'table', '#header' => $header, '#rows' => $data, ); } else { - $output = t('There are no rules currently set.') . ' ' . ts('Use the \'Add Association Rule\' form to add one.'); + $output = t('There are no rules currently set.'); } return $output; } /** - * Implements hook_form(). Add/edit association rules. + * Implements hook_form(). + * + * Add/edit association rules. * * @ingroup forms * @see civicrm_group_roles_add_rule_validate() @@ -502,7 +509,7 @@ function civicrm_group_roles_add_rule_form($form, $form_state = array(), $edit_i $form['add_rule']['select_group']['#default_value'] = check_plain($default_values->group_id); $form['add_rule']['select_role']['#default_value'] = check_plain($default_values->role_id); $form['edit_flag'] = array('#type' => 'hidden', '#value' => check_plain($edit_id)); - $form['submit']['#value'] = t('Edit association rule'); + $form['submit']['#value'] = t('Save changes'); } return $form; @@ -549,7 +556,6 @@ function civicrm_group_roles_add_rule_form_submit($form, &$form_state) { } } else { - $add_rule = db_insert('civicrm_group_roles_rules')->fields(array( 'role_id' => (int)$form_state['values']['add_rule']['select_role'], 'group_id' => (int)$form_state['values']['add_rule']['select_group'], @@ -559,6 +565,8 @@ function civicrm_group_roles_add_rule_form_submit($form, &$form_state) { drupal_set_message(t('Your association rule has been added.')); } } + + $form_state['redirect'] = 'admin/config/civicrm/civicrm_group_roles'; } /** @@ -765,9 +773,11 @@ function _civicrm_group_roles_validate_groups(array $groups) { // CRM-11161: Exclude smart groups as we don't want to add contacts statically to a smart group if (CRM_Utils_Array::value('saved_search_id', $group_result['values'][0])) { - $msg = 'Group ID @groupId is a smart group, so the user was not added to it statically.'; - $variables = array('@groupId' => $groupId); - watchdog('civicrm_group_roles', $msg, $variables, WATCHDOG_INFO); + if (variable_get('civicrm_group_roles_debugging', 0)) { + $msg = 'Group ID @groupId is a smart group, so the user was not added to it statically.'; + $variables = array('@groupId' => $groupId); + watchdog('civicrm_group_roles', $msg, $variables, WATCHDOG_INFO); + } unset($groups[$key]); continue; } @@ -819,17 +829,20 @@ function civicrm_group_roles_sync_roles($account) { 'version' => 3, ); $contacts = civicrm_api('contact', 'get', $params); - if ($contacts['count'] > 0) { // The user is in there - $message = 'Role @role (@rid) should be held by user @user (@uid) because they are part of group @group (contactID: @cid)'; - $params = array( - '@role' => $group->name, - '@rid' => $group->role_id, - '@user' => $account->name, - '@uid' => $account->uid, - '@group' => $group->group_id, - '@cid' => $contact, - ); - watchdog('civicrm_group_roles', $message, $params, WATCHDOG_INFO); + // If we found a user + if ($contacts['count'] > 0) { + if (variable_get('civicrm_group_roles_debugging', 0)) { + $message = 'Role @role (@rid) should be held by user @user (@uid) because they are part of group @group (contactID: @cid)'; + $params = array( + '@role' => $group->name, + '@rid' => $group->role_id, + '@user' => $account->name, + '@uid' => $account->uid, + '@group' => $group->group_id, + '@cid' => $contact, + ); + watchdog('civicrm_group_roles', $message, $params, WATCHDOG_INFO); + } $correctSyncedRoles[$group->role_id] = $group->name; } } @@ -839,15 +852,35 @@ function civicrm_group_roles_sync_roles($account) { $finalRoles = $account->roles + $rolesToAdd; $finalRoles = array_diff($finalRoles, $rolesToRemove); - $params = array( - '@initial' => print_r($account->roles, TRUE), - '@add' => print_r($rolesToAdd, TRUE), - '@remove' => print_r($rolesToRemove, TRUE), - '@final' => print_r($finalRoles, TRUE), - ); - watchdog('civicrm_group_roles', 'Initial roles: @initial, roles to add: @add, roles to remove: @remove, final roles: @final', $params, WATCHDOG_INFO); + if (variable_get('civicrm_group_roles_debugging', 0)) { + $params = array( + '@initial' => print_r($account->roles, TRUE), + '@add' => print_r($rolesToAdd, TRUE), + '@remove' => print_r($rolesToRemove, TRUE), + '@final' => print_r($finalRoles, TRUE), + ); + watchdog('civicrm_group_roles', 'Initial roles: @initial, roles to add: @add, roles to remove: @remove, final roles: @final', $params, WATCHDOG_INFO); + } if ($account->roles !== $finalRoles) { user_save($account, array('roles' => $finalRoles)); } } + +/** + * Settings form + * + * @ingroup forms + */ +function civicrm_group_roles_settings($form, &$form_state) { + + $form['civicrm_group_roles_debugging'] = array( + '#type' => 'checkbox', + '#title' => t('Enable detailed database logging'), + '#default_value' => variable_get('civicrm_group_roles_debugging', 0), + '#description' => 'Log the details of roles that are added and removed from users.', + ); + + // Default handler to save form configuration + return system_settings_form($form); +} From 054425397fb395e2b2877c41a9bebeec4de209bf Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Tue, 23 Feb 2016 12:26:03 +0000 Subject: [PATCH 08/74] CRM-18088: Contribution page ID contextual filter --- ...crm_plugin_argument_default_civicrm_id.inc | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/modules/views/plugins/civicrm_plugin_argument_default_civicrm_id.inc b/modules/views/plugins/civicrm_plugin_argument_default_civicrm_id.inc index 0919bb0..e1ac7ca 100644 --- a/modules/views/plugins/civicrm_plugin_argument_default_civicrm_id.inc +++ b/modules/views/plugins/civicrm_plugin_argument_default_civicrm_id.inc @@ -51,6 +51,7 @@ class civicrm_plugin_argument_default_civicrm_id extends views_plugin_argument_d '#description' => t('Select the entity type of the ID to extract from the URL'), '#options' => array( 'Contact' => t('Contact'), + 'Contribution page' => t('Contribution page'), ), '#default_value' => $this->options['id_type'], '#required' => TRUE, @@ -61,17 +62,32 @@ class civicrm_plugin_argument_default_civicrm_id extends views_plugin_argument_d * Get the default argument. */ function get_argument() { - - // Contact ID is set using the URL parameter 'cid' - if ($this->options['id_type'] == 'Contact') { - // Check that we are on a Contact entity - if (!empty($_GET['cid']) ) { - if (is_numeric($_GET['cid'])) { + + switch ($this->options['id_type']) { + + // Contact ID is set using the param 'cid' + case 'Contact': + if (!empty($_GET['cid']) && is_numeric($_GET['cid'])) { return $_GET['cid']; } - } + break; + + // Contribution page ID is set using the param 'id' + case 'Contribution page': + if ( + strpos(current_path(), 'contribute/transact') !== FALSE + && !empty($_GET['id']) + && is_numeric($_GET['id']) + ) { + return $_GET['id']; + } + break; + } + // Return FALSE if we haven't returned yet + return FALSE; + } - + } From e06580406aef62a648e508f59b98ece9b783d11a Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Wed, 2 Mar 2016 11:36:42 +0000 Subject: [PATCH 09/74] CRM-18138: Use contact ID from UF match, not CMS email --- .../civicrm_group_roles.module | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/modules/civicrm_group_roles/civicrm_group_roles.module b/modules/civicrm_group_roles/civicrm_group_roles.module index 8c5e9aa..5fbe588 100644 --- a/modules/civicrm_group_roles/civicrm_group_roles.module +++ b/modules/civicrm_group_roles/civicrm_group_roles.module @@ -571,9 +571,13 @@ function civicrm_group_roles_add_rule_form_submit($form, &$form_state) { /** * Helper function to add and remove users from groups, use after user_save to remove roles $roles = $edit['roles'] for user_save - * @roles list of role to add/remove - * @user Drupal user object - * $op either add or remove + * + * @param array $roles + * list of role to add/remove + * @param object $user + * Drupal user object + * @param string $op + * either add or remove */ function civicrm_group_roles_add_remove_groups($roles, $user, $op) { if (!civicrm_initialize()) { @@ -594,22 +598,16 @@ function civicrm_group_roles_add_remove_groups($roles, $user, $op) { // make sure user has other roles other than authenticated if ($roles) { //find the contact record - $params = array('version' => 3, 'sequential' => 1, 'email' => $user->mail ); - $contact = civicrm_api('contact', 'get', $params); - - if ( empty($contact) || $contact['is_error'] == 1 || $contact['count'] < 1 ) { - $msg = 'CiviCRM contact not found for @mail'; - $variables = array('@mail' => $user->mail); - watchdog('civicrm_group_roles', $msg, $variables, WATCHDOG_ERROR); - if ($debug_mode) { - drupal_set_message(t( 'CiviCRM contact not found for %mail', array('%mail' => $user->mail))); - } - return; - } - - $contact_id = CRM_Utils_Array::value( 'contact_id', $contact['values'][0] ); + $params = array( + 'version' => 3, + 'sequential' => 1, + 'return' => 'contact_id', + 'uf_id' => $user->uid + ); + $contact = civicrm_api('UFMatch', 'get', $params); - if ($contact_id) { + if (!empty($contact['values']) && !CRM_Utils_Array::value('is_error', $contact) && is_numeric($contact['values'][0]['contact_id'])) { + $contact_id = CRM_Utils_Array::value('contact_id', $contact['values'][0]); //loop over user's roles foreach ($roles as $rid => $role) { @@ -644,7 +642,17 @@ function civicrm_group_roles_add_remove_groups($roles, $user, $op) { } //end foreach } //end foreach - } //end if $contact + } //end if contact_id + + else { + $msg = 'CiviCRM contact not found for Drupal user ID @id'; + $variables = array('@id' => $user->uid); + watchdog('civicrm_group_roles', $msg, $variables, WATCHDOG_ERROR); + if ($debug_mode) { + drupal_set_message(t($msg, $variables)); + } + } + } //endif $roles } From c9c8b5766629e3bdcaa6ed1cf0037f928e1fc625 Mon Sep 17 00:00:00 2001 From: Spencer H Brooks Date: Thu, 10 Mar 2016 11:03:37 -0800 Subject: [PATCH 10/74] Updated role sync to support multiple synchronization methods, added configureable sync limit to avoid timeouts. --- .../civicrm_member_roles.module | 53 +++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/modules/civicrm_member_roles/civicrm_member_roles.module b/modules/civicrm_member_roles/civicrm_member_roles.module index 0c30d55..a18c779 100644 --- a/modules/civicrm_member_roles/civicrm_member_roles.module +++ b/modules/civicrm_member_roles/civicrm_member_roles.module @@ -104,7 +104,7 @@ function civicrm_member_roles_sync_user($account) { if (!civicrm_initialize()) { return; } - if (variable_get('civicrm_member_roles_sync_method', 0) == 0) { + if (in_array('login', variable_get('civicrm_member_roles_sync_method', array('login')), TRUE)) { _civicrm_member_roles_sync($account->uid); } } @@ -116,8 +116,8 @@ function civicrm_member_roles_cron() { if (!civicrm_initialize(TRUE)) { return; } - if (variable_get('civicrm_member_roles_sync_method', 0) == 1) { - _civicrm_member_roles_sync(); + if (in_array('cron', variable_get('civicrm_member_roles_sync_method', array('login')), TRUE)) { + _civicrm_member_roles_sync(NULL, NULL, 'cron'); } } @@ -238,17 +238,25 @@ function civicrm_member_roles_configure() { '#title' => t('Settings'), ); $form['settings']['civicrm_member_roles_sync_method'] = array( - '#type' => 'radios', + '#type' => 'checkboxes', '#title' => t('Automatic Synchronization Method'), - '#description' => t('Select which method CiviMember Roles Sync will use to automatically synchronize Memberships and Roles. If you choose user login/logout, you will have to run an initial "Manual Synchronization" after you create a new rule for it to be applied to all users and contacts. Leave the default setting if you are unsure which method to use.'), - '#default_value' => variable_get('civicrm_member_roles_sync_method', 0), + '#description' => t('Select which method CiviMember Roles Sync will use to automatically synchronize Memberships and Roles. If you choose user login/logout, you will have to run an initial "Manual Synchronization" after you create a new rule for it to be applied to all users and contacts. If you do not select an option, automatic synchronization will be disabled. You will have to use the "Manually Synchronize" form to synchronize memberships and roles yourself. Leave the default setting if you are unsure which method to use.'), + '#default_value' => variable_get('civicrm_member_roles_sync_method', array('login')), '#options' => array( - 0 => t('Synchronize whenever a user logs in or logs out. This action is performed only on the user logging in or out.'), - 1 => t('Synchronize when Drupal cron is ran. This action will be performed on all users and contacts.'), - 3 => t('Synchronize when membership is updated.'), - 2 => t('Disable automatic synchronization. You will have to use the "Manually Synchronize" form to synchronize memberships and roles yourself.'), + 'login' => t('Synchronize whenever a user logs in or logs out. This action is performed only on the user logging in or out.'), + 'cron' => t('Synchronize when Drupal cron is ran. This action will be performed on all users and contacts.'), + 'update' => t('Synchronize when membership is updated.'), ), ); + $form['settings']['civicrm_member_roles_membership_count'] = array( + '#type' => 'textfield', + '#title' => t('Memberships Synchronized on Cron'), + '#description' => t('Enter how many Memberships and Roles you would like to synchronize per cron run. This prevents the operation from timing out when too many items are processed at once. If this is empty, all Memberships and Roles will be processed.'), + '#default_value' => variable_get('civicrm_member_roles_membership_count', 150), + '#element_validate' => array('element_validate_integer_positive'), + '#size' => 15, + '#maxlength' => 4, + ); return system_settings_form($form); } @@ -448,8 +456,13 @@ function civicrm_member_roles_add_rule_form_submit($form, &$form_state) { /** * Finds members and applies roles based on the rules defined in the settings page. If the ext_uid param is defined then * this function will only sync one user. + * + * @param string $sync_type + * Whether we are syncing on cron, login, etc. Only cron is handled at this time. + * + * @return bool */ -function _civicrm_member_roles_sync($ext_uid = NULL, $cid = NULL) { +function _civicrm_member_roles_sync($ext_uid = NULL, $cid = NULL, $sync_type = NULL) { if (!civicrm_initialize()) { return; } @@ -468,12 +481,22 @@ function _civicrm_member_roles_sync($ext_uid = NULL, $cid = NULL) { } //Find all contacts that have membership rules (or just use $ext_uid) if (empty($ext_uid) && empty($cid)) { - $sql = "SELECT DISTINCT uf.contact_id FROM civicrm_uf_match uf + // Get the number of contacts to sync at once, if we're syncing on cron. + $contact_count = variable_get('civicrm_member_roles_membership_count', 150); + if ($sync_type == 'cron' && is_numeric($contact_count) && $contact_count > 0) { + $sql = "SELECT DISTINCT uf.contact_id FROM civicrm_uf_match uf + LEFT JOIN civicrm_membership m ON uf.contact_id = m.contact_id + WHERE m.id IS NOT NULL AND m.membership_type_id IN (" . implode(',', array_keys($memberroles)) . ") + ORDER BY RAND() LIMIT " . $contact_count; + } + else { + $sql = "SELECT DISTINCT uf.contact_id FROM civicrm_uf_match uf LEFT JOIN civicrm_membership m ON uf.contact_id = m.contact_id WHERE m.id IS NOT NULL AND m.membership_type_id IN (" . implode(',', array_keys($memberroles)) . ") ORDER BY m.end_date DESC"; - //let's prioritise those ending last as then we are more likely to get relevant ones if it doesn't complete - //obviously a better fix would be for it to chunk & save where it is up to + //let's prioritise those ending last as then we are more likely to get relevant ones if it doesn't complete + //obviously a better fix would be for it to chunk & save where it is up to + } $params = CRM_Core_DAO::$_nullArray; $errorMsg = 'unknown error'; $errorParams = array(); @@ -639,7 +662,7 @@ function _civicrm_member_roles_get_data($type) { function civicrm_member_roles_civicrm_post($op, $objname, $objid, &$objref) { if ($objname == "Membership") { - if (variable_get('civicrm_member_roles_sync_method', 0) == 3) { + if (in_array('update', variable_get('civicrm_member_roles_sync_method', array('login')), TRUE)) { _civicrm_member_roles_sync(NULL, $objref->contact_id); } } From 97ac3eaacb70f0b2731cc4d74cc4ff6685389ca2 Mon Sep 17 00:00:00 2001 From: Spencer H Brooks Date: Thu, 10 Mar 2016 11:15:58 -0800 Subject: [PATCH 11/74] Clarified form description text and a few variable names. --- .../civicrm_member_roles/civicrm_member_roles.module | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/civicrm_member_roles/civicrm_member_roles.module b/modules/civicrm_member_roles/civicrm_member_roles.module index a18c779..299e623 100644 --- a/modules/civicrm_member_roles/civicrm_member_roles.module +++ b/modules/civicrm_member_roles/civicrm_member_roles.module @@ -248,11 +248,11 @@ function civicrm_member_roles_configure() { 'update' => t('Synchronize when membership is updated.'), ), ); - $form['settings']['civicrm_member_roles_membership_count'] = array( + $form['settings']['civicrm_member_roles_cron_limit'] = array( '#type' => 'textfield', '#title' => t('Memberships Synchronized on Cron'), - '#description' => t('Enter how many Memberships and Roles you would like to synchronize per cron run. This prevents the operation from timing out when too many items are processed at once. If this is empty, all Memberships and Roles will be processed.'), - '#default_value' => variable_get('civicrm_member_roles_membership_count', 150), + '#description' => t('Enter how many Memberships and Roles you would like to synchronize per cron run. Synchronization will be performed randomly. This prevents the operation from timing out when too many items are processed at once. If this is empty, all Memberships and Roles will be processed.'), + '#default_value' => variable_get('civicrm_member_roles_cron_limit', 150), '#element_validate' => array('element_validate_integer_positive'), '#size' => 15, '#maxlength' => 4, @@ -482,12 +482,12 @@ function _civicrm_member_roles_sync($ext_uid = NULL, $cid = NULL, $sync_type = N //Find all contacts that have membership rules (or just use $ext_uid) if (empty($ext_uid) && empty($cid)) { // Get the number of contacts to sync at once, if we're syncing on cron. - $contact_count = variable_get('civicrm_member_roles_membership_count', 150); - if ($sync_type == 'cron' && is_numeric($contact_count) && $contact_count > 0) { + $cron_limit = variable_get('civicrm_member_roles_cron_limit', 150); + if ($sync_type == 'cron' && is_numeric($cron_limit) && $cron_limit > 0) { $sql = "SELECT DISTINCT uf.contact_id FROM civicrm_uf_match uf LEFT JOIN civicrm_membership m ON uf.contact_id = m.contact_id WHERE m.id IS NOT NULL AND m.membership_type_id IN (" . implode(',', array_keys($memberroles)) . ") - ORDER BY RAND() LIMIT " . $contact_count; + ORDER BY RAND() LIMIT " . $cron_limit; } else { $sql = "SELECT DISTINCT uf.contact_id FROM civicrm_uf_match uf From c668ca69f3099d5a8587e537120446055426a5cd Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Fri, 18 Mar 2016 12:44:53 +0000 Subject: [PATCH 12/74] CRM-16479: Support for image styles (proof of concept) --- .../civicrm_handler_field_contact_image.inc | 90 +++++++++++++++---- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_contact_image.inc b/modules/views/civicrm/civicrm_handler_field_contact_image.inc index e3a616d..192dbf6 100644 --- a/modules/views/civicrm/civicrm_handler_field_contact_image.inc +++ b/modules/views/civicrm/civicrm_handler_field_contact_image.inc @@ -3,65 +3,108 @@ class civicrm_handler_field_contact_image extends views_handler_field { function option_definition() { $options = parent::option_definition(); - $options['alt'] = array( - 'default' => '', + $options['url_only'] = array( + 'default' => FALSE, + 'boolean' => TRUE, ); $options['title'] = array( 'default' => '', - ); + ); + $options['alt'] = array( + 'default' => '', + ); + if (module_exists('image')) { + $options['image_style'] = array( + 'default' => '', + ); + } $options['width'] = array( 'default' => '', ); $options['height'] = array( 'default' => '', ); - $options['url_only'] = array( - 'default' => FALSE, - 'boolean' => TRUE, - ); - return $options; } function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); + parent::options_form($form, $form_state); + + $form['url_only'] = array( + '#title' => t('Output the image URL only'), + '#description' => t('This option stops the URL being wrapped in an html img tag and ignores the title, alt, width and height settings. This may be useful for rewriting the results.'), + '#type' => 'checkbox', + '#default_value' => $this->options['url_only'], + ); + $form['title'] = array( '#title' => t('Title attribute'), '#description' => t('The text to use as value for the img tag title attribute.'), '#type' => 'textfield', '#default_value' => $this->options['title'], + '#dependency' => array( + 'edit-options-url-only' => array(0), + ), ); + $form['alt'] = array( '#title' => t('Alt attribute'), '#description' => t('The text to use as value for the img tag alt attribute.'), '#type' => 'textfield', '#default_value' => $this->options['alt'], + '#dependency' => array( + 'edit-options-url-only' => array(0), + ), ); + + if (module_exists('image')) { + $styles = image_styles(); + $style_options = array('' => t('None (original image)')); + foreach ($styles as $style) { + $style_options[$style['name']] = $style['name']; + } + $form['image_style'] = array( + '#title' => t('Image style'), + '#description' => t('Display the contact image using an image style'), + '#type' => 'select', + '#options' => $style_options, + '#default_value' => $this->options['image_style'], + '#dependency' => array( + 'edit-options-url-only' => array(0), + ), + ); + } + $form['width'] = array( '#title' => t('Width'), '#description' => t('Resize the image in the browser to this width. If left empty, the width will scale proportionally with the height.'), '#type' => 'textfield', '#default_value' => $this->options['width'], '#element_validate' => array('element_validate_integer_positive'), + '#dependency' => array( + 'edit-options-url-only' => array(0), + 'edit-options-image-style' => array(''), + ), + '#dependency_count' => 2, ); + $form['height'] = array( '#title' => t('Height'), '#description' => t('Resize the image in the browser to this height. If left empty, the height will scale proportionally with the width.'), '#type' => 'textfield', '#default_value' => $this->options['height'], '#element_validate' => array('element_validate_integer_positive'), + '#dependency' => array( + 'edit-options-url-only' => array(0), + 'edit-options-image-style' => array(''), + ), + '#dependency_count' => 2, ); - $form['url_only'] = array( - '#title' => t('Output the image URL only'), - '#description' => t('This option stops the URL being wrapped in an html img tag and ignores the title, alt, width and height settings. This may be useful for rewriting the results.'), - '#type' => 'checkbox', - '#default_value' => $this->options['url_only'], - ); + } function render($values) { $value = $this->get_value($values); - if (empty($value)) { return; } @@ -70,11 +113,20 @@ class civicrm_handler_field_contact_image extends views_handler_field { } $image = array( 'path' => $value, - 'width' => empty($this->options['width']) ? 'auto' : $this->options['width'], - 'height' => empty($this->options['height']) ? 'auto' : $this->options['height'], 'title' => $this->options['title'], 'alt' => $this->options['alt'], ); - return theme('image', $image); + if ($this->options['image_style'] && module_exists('image')) { + $image['style_name'] = empty($this->options['image_style']) ? '' : $this->options['image_style']; + $config = CRM_Core_Config::singleton(); + $split_customFileUploadDir = explode('files', $config->customFileUploadDir); + $image['path'] = str_replace('\\', '/', substr($split_customFileUploadDir[1], 1)) . substr(strstr($value, 'photo='), 6); + return theme('image_style', $image); + } + else { + $image['width'] = empty($this->options['width']) ? 'auto' : $this->options['width']; + $image['height'] = empty($this->options['height']) ? 'auto' : $this->options['height']; + return theme('image', $image); + } } } From 738b08a3dccc0a672d1fb43149d4d81748a029aa Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Fri, 18 Mar 2016 13:54:28 +0000 Subject: [PATCH 13/74] Fix field dependency when image module not enabled --- .../civicrm/civicrm_handler_field_contact_image.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_contact_image.inc b/modules/views/civicrm/civicrm_handler_field_contact_image.inc index 192dbf6..1d1af2e 100644 --- a/modules/views/civicrm/civicrm_handler_field_contact_image.inc +++ b/modules/views/civicrm/civicrm_handler_field_contact_image.inc @@ -83,9 +83,7 @@ class civicrm_handler_field_contact_image extends views_handler_field { '#element_validate' => array('element_validate_integer_positive'), '#dependency' => array( 'edit-options-url-only' => array(0), - 'edit-options-image-style' => array(''), ), - '#dependency_count' => 2, ); $form['height'] = array( @@ -96,11 +94,15 @@ class civicrm_handler_field_contact_image extends views_handler_field { '#element_validate' => array('element_validate_integer_positive'), '#dependency' => array( 'edit-options-url-only' => array(0), - 'edit-options-image-style' => array(''), ), - '#dependency_count' => 2, ); + if (module_exists('image')) { + $form['width']['#dependency']['edit-options-image-style'] = array(''); + $form['width']['#dependency_count'] = 2; + $form['height']['#dependency']['edit-options-image-style'] = array(''); + $form['height']['#dependency_count'] = 2; + } } function render($values) { From f09b84340ef577fecb1f71c8c9474321e8acdb11 Mon Sep 17 00:00:00 2001 From: Spencer H Brooks Date: Tue, 22 Mar 2016 09:45:43 -0700 Subject: [PATCH 14/74] Add update hook for member role sync. --- .../civicrm_member_roles.install | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/civicrm_member_roles/civicrm_member_roles.install b/modules/civicrm_member_roles/civicrm_member_roles.install index e51c4a4..7d825ed 100644 --- a/modules/civicrm_member_roles/civicrm_member_roles.install +++ b/modules/civicrm_member_roles/civicrm_member_roles.install @@ -60,3 +60,28 @@ function civicrm_member_roles_uninstall() { variable_del('civicrm_member_roles_sync_method'); } +/** + * Translate the old integer-based data format for synchronization settings to + * the array-based format which supports multiple sync options. + */ +function civicrm_member_roles_update_7400() { + // Get the current sync method and see if a format update is needed. + $sync_method = variable_get('civicrm_member_roles_sync_method'); + if (is_numeric($sync_method)) { + // Translate the old value to the new. + switch ($sync_method) { + case '0': + variable_set('civicrm_member_roles_sync_method', array('login')); + break; + case '1': + variable_set('civicrm_member_roles_sync_method', array('cron')); + break; + case '2': + variable_set('civicrm_member_roles_sync_method', array()); + break; + case '3': + variable_set('civicrm_member_roles_sync_method', array('update')); + break; + } + } +} From 5e91af93c9897564379acf16b7f2141f6bd6995f Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Thu, 31 Mar 2016 11:27:31 +1300 Subject: [PATCH 15/74] CRM-18326. Support displaying currency amounts without currency formatting through Drupal Views. --- .../civicrm/civicrm_handler_field_money.inc | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_money.inc b/modules/views/civicrm/civicrm_handler_field_money.inc index bc88353..7c0fa6d 100644 --- a/modules/views/civicrm/civicrm_handler_field_money.inc +++ b/modules/views/civicrm/civicrm_handler_field_money.inc @@ -39,8 +39,35 @@ class civicrm_handler_field_money extends views_handler_field { function render($values) { $value = $this->get_value($values); - return CRM_Utils_Money::format($value); + $currency_code = $this->get_value($values, 'currency_code'); + + switch ($this->options ['display_format']) { + case 'formatted': + return CRM_Utils_Money::format($value); + + case 'raw': + return $value; + } } -} + function option_definition() { + $options = parent::option_definition(); + + $options ['display_format'] = array('default' => 'formatted'); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $form ['display_format'] = array( + '#type' => 'select', + '#title' => t('Display format'), + '#options' => array( + 'formatted' => t('Currency formatted amount ($123.45)'), + 'raw' => t('Raw amount (123.45)'), + ), + '#default_value' => $this->options ['display_format'], + ); + } +} From 0bab91f18cb3b94523bdb5cef02057204748d98d Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Thu, 7 Apr 2016 12:44:35 +0100 Subject: [PATCH 16/74] CRM-18377: Fix 'text link' views handlers --- .../civicrm/civicrm_handler_field_link_activity.inc | 8 +++++--- .../civicrm/civicrm_handler_field_link_contact.inc | 10 ++++++---- .../civicrm_handler_field_link_contribution.inc | 10 ++++++---- .../views/civicrm/civicrm_handler_field_link_event.inc | 8 +++++--- .../civicrm/civicrm_handler_field_link_participant.inc | 10 ++++++---- .../civicrm_handler_field_link_relationship.inc | 10 ++++++---- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_link_activity.inc b/modules/views/civicrm/civicrm_handler_field_link_activity.inc index 54bdc9f..b1ffe36 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_activity.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_activity.inc @@ -68,7 +68,8 @@ class civicrm_handler_field_link_activity extends views_handler_field { 'delete' => t('Link to Delete Activity'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_activity']), + '#default_value' => $this->options['link_to_civicrm_activity'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -76,14 +77,15 @@ class civicrm_handler_field_link_activity extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The Activity ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_activity' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-activity' => array('custom')), ); $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } diff --git a/modules/views/civicrm/civicrm_handler_field_link_contact.inc b/modules/views/civicrm/civicrm_handler_field_link_contact.inc index ea974a6..f83983a 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_contact.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_contact.inc @@ -52,7 +52,7 @@ class civicrm_handler_field_link_contact extends views_handler_field { $options = parent::option_definition(); $options['link_to_civicrm_contact'] = array('default' => 'view'); $options['custom_link'] = array('default' => ''); - $options['link_text'] = array('default' => 'View Contact'); + $options['link_text'] = array('default' => ''); return $options; } @@ -67,7 +67,8 @@ class civicrm_handler_field_link_contact extends views_handler_field { 'delete' => t('Link to Delete Contact'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_contact']), + '#default_value' => $this->options['link_to_civicrm_contact'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -75,14 +76,15 @@ class civicrm_handler_field_link_contact extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The Contact ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_contact' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-contact' => array('custom')), ); $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } diff --git a/modules/views/civicrm/civicrm_handler_field_link_contribution.inc b/modules/views/civicrm/civicrm_handler_field_link_contribution.inc index 17a15a6..8a7f8fe 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_contribution.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_contribution.inc @@ -53,7 +53,7 @@ class civicrm_handler_field_link_contribution extends views_handler_field { $options = parent::option_definition(); $options['link_to_civicrm_contribution'] = array('default' => 'view'); $options['custom_link'] = array('default' => ''); - $options['link_text'] = array('default' => 'View Contribution'); + $options['link_text'] = array('default' => ''); return $options; } @@ -68,7 +68,8 @@ class civicrm_handler_field_link_contribution extends views_handler_field { 'delete' => t('Link to Delete Contribution'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_contribution']), + '#default_value' => $this->options['link_to_civicrm_contribution'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -76,14 +77,15 @@ class civicrm_handler_field_link_contribution extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The Contribution ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_contribution' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-contribution' => array('custom')), ); $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } diff --git a/modules/views/civicrm/civicrm_handler_field_link_event.inc b/modules/views/civicrm/civicrm_handler_field_link_event.inc index 6ea7320..71030a6 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_event.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_event.inc @@ -52,7 +52,7 @@ class civicrm_handler_field_link_event extends views_handler_field { $options = parent::option_definition(); $options['link_to_civicrm_event'] = array('default' => 'view'); $options['custom_link'] = array('default' => ''); - $options['link_text'] = array('default' => 'View Event'); + $options['link_text'] = array('default' => ''); return $options; } @@ -70,7 +70,8 @@ class civicrm_handler_field_link_event extends views_handler_field { 'delete' => t('Link to Delete Event'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_event']), + '#default_value' => $this->options['link_to_civicrm_event'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -78,7 +79,7 @@ class civicrm_handler_field_link_event extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The Event ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_event' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-event' => array('custom')), ); $form['link_text'] = array( @@ -86,6 +87,7 @@ class civicrm_handler_field_link_event extends views_handler_field { '#title' => t('Links Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } diff --git a/modules/views/civicrm/civicrm_handler_field_link_participant.inc b/modules/views/civicrm/civicrm_handler_field_link_participant.inc index 365fd63..ad68f3e 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_participant.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_participant.inc @@ -58,7 +58,7 @@ class civicrm_handler_field_link_participant extends views_handler_field { $options = parent::option_definition(); $options['link_to_civicrm_participant'] = array('default' => 'view'); $options['custom_link'] = array('default' => ''); - $options['link_text'] = array('default' => 'View Participant'); + $options['link_text'] = array('default' => ''); return $options; } @@ -73,7 +73,8 @@ class civicrm_handler_field_link_participant extends views_handler_field { 'delete' => t('Link to Delete Participant'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_participant']), + '#default_value' => $this->options['link_to_civicrm_participant'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -81,14 +82,15 @@ class civicrm_handler_field_link_participant extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The Participant ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_participant' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-participant' => array('custom')), ); $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } diff --git a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc index 11a9e8b..2cfdc2c 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc @@ -54,7 +54,7 @@ class civicrm_handler_field_link_relationship extends views_handler_field { $options = parent::option_definition(); $options['link_to_civicrm_relationship'] = array('default' => 'view'); $options['custom_link'] = array('default' => ''); - $options['link_text'] = array('default' => 'View Relationship'); + $options['link_text'] = array('default' => ''); return $options; } @@ -71,7 +71,8 @@ class civicrm_handler_field_link_relationship extends views_handler_field { 'delete' => t('Link to Delete Relationship'), 'custom' => t('Link to a Custom Node'), ), - '#default_value' => !empty($this->options['link_to_civicrm_relationship']), + '#default_value' => $this->options['link_to_civicrm_relationship'], + '#required' => TRUE, ); $form['custom_link'] = array( @@ -79,14 +80,15 @@ class civicrm_handler_field_link_relationship extends views_handler_field { '#title' => t('Custom Link to a Drupal Node'), '#description' => t('Link to a Drupal Node or View, from the base path. The relationship ID will be appended to the end of the link.'), '#default_value' => isset($this->options['custom_link']) ? $this->options['custom_link'] : '', - '#dependency' => array('link_to_civicrm_relationship' => array('custom')), + '#dependency' => array('edit-options-link-to-civicrm-relationship' => array('custom')), ); $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', + '#required' => TRUE, ); } From e5b6bddf594d2f8d1ef7d0bbb90c4eb85ba9a3ce Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Mon, 11 Apr 2016 10:28:34 +0100 Subject: [PATCH 17/74] Don't look for Wordpress in a Drupal installation --- civicrm.config.php.drupal | 3 --- 1 file changed, 3 deletions(-) diff --git a/civicrm.config.php.drupal b/civicrm.config.php.drupal index 2fdc15b..9cdf9cf 100644 --- a/civicrm.config.php.drupal +++ b/civicrm.config.php.drupal @@ -64,9 +64,6 @@ function civicrm_conf_init() { // check to see if this is under sites/all/modules } else if ( strpos( $currentDir, $moduleDir ) !== false ) { $confdir = $currentDir . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'; - } else if ( strpos( $currentDir, 'plugins' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' ) !== false ) { - //if its wordpress - $confdir = $currentDir . DIRECTORY_SEPARATOR . '..'; } else { $confdir = $currentDir . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; } From d871fe4f32dab89076085e54ddd29337b4644cb7 Mon Sep 17 00:00:00 2001 From: Aron Novak Date: Mon, 6 Apr 2015 23:22:28 -0400 Subject: [PATCH 18/74] Adds command to sync users to contacts, useful for thousands of users to avoid PHP timeout Conflicts: drush/civicrm.drush.inc --- drush/civicrm.drush.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 1f8c2fb..37e4901 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -254,6 +254,10 @@ function civicrm_drush_command() { $items['civicrm-member-records'] = array( 'description' => "Run the CiviMember UpdateMembershipRecord cron (civicrm-member-records).", ); + $items['civicrm-sync-users-contacts'] = array( + 'description' => "Synchronize Users to Contacts: CiviCRM will check each user record for a contact record. A new contact record will be created for each user where one does not already exist.", + 'callback' => 'drush_civicrm_sync_users_contacts', + ); return $items; } @@ -1564,3 +1568,12 @@ function drush_civicrm_api() { return drush_set_error('CIVICRM_UNKNOWN_FORMAT', dt('Unknown format: @format', array('@format' => $format))); } } + +/** + * Implementation of command 'civicrm-sync-users-contacts' + */ +function drush_civicrm_sync_users_contacts() { + civicrm_initialize(); + + CRM_Core_BAO_CMSUser::synchronize(FALSE); +} From 338e4d6c95b780cb751ff3efbd9c7ca74120ae46 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 11 Apr 2016 17:24:50 +0530 Subject: [PATCH 19/74] implement user sync from drush --- drush/civicrm.drush.inc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 37e4901..8af7f71 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -256,7 +256,6 @@ function civicrm_drush_command() { ); $items['civicrm-sync-users-contacts'] = array( 'description' => "Synchronize Users to Contacts: CiviCRM will check each user record for a contact record. A new contact record will be created for each user where one does not already exist.", - 'callback' => 'drush_civicrm_sync_users_contacts', ); return $items; @@ -1574,6 +1573,28 @@ function drush_civicrm_api() { */ function drush_civicrm_sync_users_contacts() { civicrm_initialize(); + $result = CRM_Utils_System::synchronizeUsers(); + $status = ts('Checked one user record.', + array( + 'count' => $result['contactCount'], + 'plural' => 'Checked %count user records.', + ) + ); + if ($result['contactMatching']) { + $status .= PHP_EOL . ts('Found one matching contact record.', + array( + 'count' => $result['contactMatching'], + 'plural' => 'Found %count matching contact records.', + ) + ); + } - CRM_Core_BAO_CMSUser::synchronize(FALSE); + $status .= PHP_EOL . ts('Created one new contact record.', + array( + 'count' => $result['contactCreated'], + 'plural' => 'Created %count new contact records.', + ) + ); + drush_print(dt($status)); + return $result; } From ce8b516fa0187324aa6c7f3c346033865b339166 Mon Sep 17 00:00:00 2001 From: Torrance Date: Thu, 14 Apr 2016 18:33:22 +1200 Subject: [PATCH 20/74] Use currency field if available for formatted money display. --- modules/views/civicrm/civicrm_handler_field_money.inc | 8 ++++++-- modules/views/components/civicrm.contribute.inc | 8 ++++++++ modules/views/components/civicrm.event.inc | 1 + modules/views/components/civicrm.grant.inc | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_money.inc b/modules/views/civicrm/civicrm_handler_field_money.inc index 7c0fa6d..32dbb8a 100644 --- a/modules/views/civicrm/civicrm_handler_field_money.inc +++ b/modules/views/civicrm/civicrm_handler_field_money.inc @@ -35,15 +35,19 @@ class civicrm_handler_field_money extends views_handler_field { return; } require_once 'CRM/Utils/Money.php'; + + if ($this->definition['currency field']) { + $this->additional_fields['currency'] = array('field' => $this->definition['currency field']); + } } function render($values) { $value = $this->get_value($values); - $currency_code = $this->get_value($values, 'currency_code'); + $currency = $this->get_value($values, 'currency'); switch ($this->options ['display_format']) { case 'formatted': - return CRM_Utils_Money::format($value); + return CRM_Utils_Money::format($value, $currency); case 'raw': return $value; diff --git a/modules/views/components/civicrm.contribute.inc b/modules/views/components/civicrm.contribute.inc index 1725299..d4fcc3e 100644 --- a/modules/views/components/civicrm.contribute.inc +++ b/modules/views/components/civicrm.contribute.inc @@ -217,6 +217,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -237,6 +238,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -256,6 +258,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -276,6 +279,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -641,6 +645,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument', @@ -766,6 +771,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument', @@ -1149,6 +1155,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -1389,6 +1396,7 @@ function _civicrm_contribute_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', diff --git a/modules/views/components/civicrm.event.inc b/modules/views/components/civicrm.event.inc index 2b3b9b7..87bde5a 100644 --- a/modules/views/components/civicrm.event.inc +++ b/modules/views/components/civicrm.event.inc @@ -629,6 +629,7 @@ function _civicrm_event_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'fee_currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', diff --git a/modules/views/components/civicrm.grant.inc b/modules/views/components/civicrm.grant.inc index cbf3e62..223708f 100644 --- a/modules/views/components/civicrm.grant.inc +++ b/modules/views/components/civicrm.grant.inc @@ -252,6 +252,7 @@ function _civicrm_grant_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', @@ -294,6 +295,7 @@ function _civicrm_grant_data(&$data, $enabled) { 'field' => array( 'handler' => 'civicrm_handler_field_money', 'click sortable' => TRUE, + 'currency field' => 'currency', ), 'argument' => array( 'handler' => 'views_handler_argument_numeric', From b1277a68f173f376ac46ced091a90f40c85b3bfd Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Fri, 15 Apr 2016 14:17:56 +0100 Subject: [PATCH 21/74] Label fix --- modules/views/civicrm/civicrm_handler_field_link_event.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/views/civicrm/civicrm_handler_field_link_event.inc b/modules/views/civicrm/civicrm_handler_field_link_event.inc index 71030a6..765f127 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_event.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_event.inc @@ -84,7 +84,7 @@ class civicrm_handler_field_link_event extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Links Text'), + '#title' => t('Link text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, From 72f8bd5666ade38d64698e5c7bb2dea137e9d97b Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Fri, 15 Apr 2016 14:21:28 +0100 Subject: [PATCH 22/74] Title case labels for consistency --- modules/views/civicrm/civicrm_handler_field_link_activity.inc | 2 +- modules/views/civicrm/civicrm_handler_field_link_contact.inc | 2 +- .../views/civicrm/civicrm_handler_field_link_contribution.inc | 2 +- modules/views/civicrm/civicrm_handler_field_link_event.inc | 2 +- .../views/civicrm/civicrm_handler_field_link_participant.inc | 2 +- .../views/civicrm/civicrm_handler_field_link_relationship.inc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_link_activity.inc b/modules/views/civicrm/civicrm_handler_field_link_activity.inc index b1ffe36..ed23cfe 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_activity.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_activity.inc @@ -82,7 +82,7 @@ class civicrm_handler_field_link_activity extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, diff --git a/modules/views/civicrm/civicrm_handler_field_link_contact.inc b/modules/views/civicrm/civicrm_handler_field_link_contact.inc index f83983a..377b257 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_contact.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_contact.inc @@ -81,7 +81,7 @@ class civicrm_handler_field_link_contact extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, diff --git a/modules/views/civicrm/civicrm_handler_field_link_contribution.inc b/modules/views/civicrm/civicrm_handler_field_link_contribution.inc index 8a7f8fe..421711a 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_contribution.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_contribution.inc @@ -82,7 +82,7 @@ class civicrm_handler_field_link_contribution extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, diff --git a/modules/views/civicrm/civicrm_handler_field_link_event.inc b/modules/views/civicrm/civicrm_handler_field_link_event.inc index 765f127..e96a2fb 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_event.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_event.inc @@ -84,7 +84,7 @@ class civicrm_handler_field_link_event extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, diff --git a/modules/views/civicrm/civicrm_handler_field_link_participant.inc b/modules/views/civicrm/civicrm_handler_field_link_participant.inc index ad68f3e..a434731 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_participant.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_participant.inc @@ -87,7 +87,7 @@ class civicrm_handler_field_link_participant extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, diff --git a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc index 2cfdc2c..644edab 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc @@ -85,7 +85,7 @@ class civicrm_handler_field_link_relationship extends views_handler_field { $form['link_text'] = array( '#type' => 'textfield', - '#title' => t('Link text'), + '#title' => t('Link Text'), '#description' => t('The text that will display in the field with the link.'), '#default_value' => isset($this->options['link_text']) ? $this->options['link_text'] : '', '#required' => TRUE, From ec082282cc03c81447d05ead6765dc493adbc33f Mon Sep 17 00:00:00 2001 From: "Laryn - CEDC.org" Date: Wed, 20 Apr 2016 12:44:31 -0500 Subject: [PATCH 23/74] Fix for CRM-18451 Only use admin theme if user has access to CiviCRM. --- modules/civicrmtheme/civicrmtheme.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/civicrmtheme/civicrmtheme.module b/modules/civicrmtheme/civicrmtheme.module index 17ffcbe..a7e0e93 100644 --- a/modules/civicrmtheme/civicrmtheme.module +++ b/modules/civicrmtheme/civicrmtheme.module @@ -124,7 +124,8 @@ function civicrmtheme_custom_theme() { // Check for public pages // If public page and civicrm public theme is set, apply civicrm public theme - if (CRM_Utils_Array::value('is_public', $item)) { + // 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 ($public_theme) { return $public_theme; } From 8c13f00e8ee9f403e79606b8c22e8c5e36e65e77 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 27 Apr 2016 10:54:11 +1200 Subject: [PATCH 24/74] Remove pass_by_ref & which causes strict error --- modules/civicrm_engage/civicrm_engage.module | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/civicrm_engage/civicrm_engage.module b/modules/civicrm_engage/civicrm_engage.module index cfddd3f..07620d1 100644 --- a/modules/civicrm_engage/civicrm_engage.module +++ b/modules/civicrm_engage/civicrm_engage.module @@ -48,8 +48,8 @@ function civicrm_engage_civicrm_buildForm($formName, &$form) { if (empty($cgID)) { return; } - $groupTree = &CRM_Core_BAO_CustomGroup::getTree('Individual', - $form, + $groupTree = CRM_Core_BAO_CustomGroup::getTree('Individual', + NULL, $form->getVar('_contactId'), $cgID, NULL, NULL @@ -107,8 +107,8 @@ function civicrm_engage_civicrm_postProcess($class, &$form) { if (empty($cgID)) { return; } - $groupTree = &CRM_Core_BAO_CustomGroup::getTree('Individual', - $form, + $groupTree = CRM_Core_BAO_CustomGroup::getTree('Individual', + NULL, $form->getVar('_contactId'), $cgID, NULL, NULL @@ -154,8 +154,8 @@ function civicrm_engage_civicrm_pageRun(&$page) { if(empty($contactId)) { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST); } - $groupTree = &CRM_Core_BAO_CustomGroup::getTree('Individual', - $page, + $groupTree = CRM_Core_BAO_CustomGroup::getTree('Individual', + NULL, $contactId, $cgID, NULL, NULL From bf2c499100ea24939794e08b563dafe4784102ad Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Mon, 9 May 2016 14:31:38 +0100 Subject: [PATCH 25/74] Use Civi::paths and reduce hardcoding --- .../civicrm_handler_field_contact_image.inc | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_contact_image.inc b/modules/views/civicrm/civicrm_handler_field_contact_image.inc index 1d1af2e..5eb412c 100644 --- a/modules/views/civicrm/civicrm_handler_field_contact_image.inc +++ b/modules/views/civicrm/civicrm_handler_field_contact_image.inc @@ -13,7 +13,8 @@ class civicrm_handler_field_contact_image extends views_handler_field { $options['alt'] = array( 'default' => '', ); - if (module_exists('image')) { + $directory = $this->get_civi_relative_upload_path(); + if (module_exists('image') && $directory !== FALSE) { $options['image_style'] = array( 'default' => '', ); @@ -29,6 +30,7 @@ class civicrm_handler_field_contact_image extends views_handler_field { function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); + $directory = $this->get_civi_relative_upload_path(); $form['url_only'] = array( '#title' => t('Output the image URL only'), @@ -57,7 +59,7 @@ class civicrm_handler_field_contact_image extends views_handler_field { ), ); - if (module_exists('image')) { + if (module_exists('image') && $directory !== FALSE) { $styles = image_styles(); $style_options = array('' => t('None (original image)')); foreach ($styles as $style) { @@ -97,7 +99,7 @@ class civicrm_handler_field_contact_image extends views_handler_field { ), ); - if (module_exists('image')) { + if (module_exists('image') && $directory !== FALSE) { $form['width']['#dependency']['edit-options-image-style'] = array(''); $form['width']['#dependency_count'] = 2; $form['height']['#dependency']['edit-options-image-style'] = array(''); @@ -118,11 +120,11 @@ class civicrm_handler_field_contact_image extends views_handler_field { 'title' => $this->options['title'], 'alt' => $this->options['alt'], ); - if ($this->options['image_style'] && module_exists('image')) { + $directory = $this->get_civi_relative_upload_path(); + if ($this->options['image_style'] && module_exists('image') && $directory !== FALSE) { $image['style_name'] = empty($this->options['image_style']) ? '' : $this->options['image_style']; - $config = CRM_Core_Config::singleton(); - $split_customFileUploadDir = explode('files', $config->customFileUploadDir); - $image['path'] = str_replace('\\', '/', substr($split_customFileUploadDir[1], 1)) . substr(strstr($value, 'photo='), 6); + $image_path = $directory . substr(strstr($value, 'photo='), 6); + $image['path'] = str_replace('\\', '/', $image_path); return theme('image_style', $image); } else { @@ -131,4 +133,30 @@ class civicrm_handler_field_contact_image extends views_handler_field { return theme('image', $image); } } + + /** + * Get the CiviCRM upload directory relative to the Drupal public upload + * directory so that we can support image styles. + * + * Returns the relative path if it is supported, otherwise returns FALSE. + * + * @return bool|string + */ + function get_civi_relative_upload_path() { + civicrm_initialize(); + $wrapper = file_stream_wrapper_get_instance_by_uri('public://'); + $drupal_upload_path = $wrapper->getDirectoryPath(); + $civi_upload_path = Civi::paths()->getUrl(Civi::settings()->get('customFileUploadDir')); + $relative_upload_path = explode($drupal_upload_path, $civi_upload_path); + + // If we couldn't explode() then Civi's upload path is not in the public:// + // directory, so we cannot support image styles. + if (count($relative_upload_path) != 2) { + return FALSE; + } + + // Otherwise, return the relative path without the leading slash + return substr($relative_upload_path[1], 1); + } + } From 6a3a9010b8ec9feabe726d8cf4b6b4522d0fe8ed Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 3 Oct 2014 18:43:29 +0100 Subject: [PATCH 26/74] CRM-14707 - Add unit-test for Drupal hook invocation --- phpunit.xml.dist | 24 +++++++++++++++++ tests/phpunit/CiviDrupal/HookTest.php | 38 +++++++++++++++++++++++++++ tests/phpunit/README.md | 5 ++++ tests/phpunit/bootstrap.php | 21 +++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 phpunit.xml.dist create mode 100644 tests/phpunit/CiviDrupal/HookTest.php create mode 100644 tests/phpunit/README.md create mode 100644 tests/phpunit/bootstrap.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..d8d7676 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + ./tests/phpunit + + + + + + ./CiviDrupal + + + diff --git a/tests/phpunit/CiviDrupal/HookTest.php b/tests/phpunit/CiviDrupal/HookTest.php new file mode 100644 index 0000000..684857f --- /dev/null +++ b/tests/phpunit/CiviDrupal/HookTest.php @@ -0,0 +1,38 @@ + 123, + ); + \CRM_Utils_Hook::singleton() + ->invoke( + 2, + $arg1, + $arg2, + \CRM_Utils_Hook::$_nullObject, + \CRM_Utils_Hook::$_nullObject, + \CRM_Utils_Hook::$_nullObject, + \CRM_Utils_Hook::$_nullObject, + 'civicrm_fakeAlterableHook' + ); + + $this->assertEquals($arg2['foo'], 456); + $this->assertEquals($arg2['hook_was_called'], 1); + } + } +} + +namespace { + function civicrm_civicrm_fakeAlterableHook($arg1, &$arg2) { + if ($arg1 != 'hello') { + throw new \Exception("Failed to receive arg1"); + } + if ($arg2['foo'] != 123) { + throw new \Exception("Failed to receive arg2[foo]"); + } + $arg2['foo'] = 456; + $arg2['hook_was_called'] = 1; + } +} diff --git a/tests/phpunit/README.md b/tests/phpunit/README.md new file mode 100644 index 0000000..dde91d3 --- /dev/null +++ b/tests/phpunit/README.md @@ -0,0 +1,5 @@ +This directory contains phpunit tests for the Drupal-CiviCRM integration. + +Note: At time of writing, these tests execute within the context of the +default Drupal database. Consequently, you must be quite careful to write +tests which don't leave a mess in the database. diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php new file mode 100644 index 0000000..a1b850d --- /dev/null +++ b/tests/phpunit/bootstrap.php @@ -0,0 +1,21 @@ + Date: Fri, 10 Oct 2014 12:48:44 +0100 Subject: [PATCH 27/74] Rename tests/phpunit/README.md to TESTING.md --- tests/phpunit/README.md => TESTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/phpunit/README.md => TESTING.md (100%) diff --git a/tests/phpunit/README.md b/TESTING.md similarity index 100% rename from tests/phpunit/README.md rename to TESTING.md From 2c4e0c1a27ce73d90136f0d87790253f1c695a21 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 10 Oct 2014 12:49:03 +0100 Subject: [PATCH 28/74] TESTING.md - Tweak prose --- TESTING.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/TESTING.md b/TESTING.md index dde91d3..5ee0fb4 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,5 +1,7 @@ -This directory contains phpunit tests for the Drupal-CiviCRM integration. +This repository contains the CiviCRM-Drupal integration module. It does NOT +contain tests for core functionality. (For tests of core functionality, see +https://github.com/civicrm/civicrm-core .) -Note: At time of writing, these tests execute within the context of the -default Drupal database. Consequently, you must be quite careful to write -tests which don't leave a mess in the database. +At time of writing, these tests execute within the context of the default +Drupal database. Consequently, you must be quite careful to write tests +which don't leave a mess in the database. From 6ab20c27a546638ed7b4a6710a3f6db489fac6df Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 11 May 2016 15:16:47 -0700 Subject: [PATCH 29/74] CRM-14707 - tests/phpunit/bootstrap.php - Update to use `cv` bootstrap --- tests/phpunit/bootstrap.php | 63 ++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index a1b850d..9f4a9e3 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -1,21 +1,54 @@ array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR); + $oldOutput = getenv('CV_OUTPUT'); + putenv("CV_OUTPUT=json"); + $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__); + putenv("CV_OUTPUT=$oldOutput"); + fclose($pipes[0]); + $result = stream_get_contents($pipes[1]); + fclose($pipes[1]); + if (proc_close($process) !== 0) { + throw new RuntimeException("Command failed ($cmd):\n$result"); + } + switch ($decode) { + case 'raw': + return $result; -// Drupal just usurped PHPUnit's error handler. Kick it off the throne. -restore_error_handler(); + case 'phpcode': + // If the last output is /*PHPCODE*/, then we managed to complete execution. + if (substr(trim($result), 0, 12) !== "/*BEGINPHP*/" || substr(trim($result), -10) !== "/*ENDPHP*/") { + throw new \RuntimeException("Command failed ($cmd):\n$result"); + } + return $result; -civicrm_initialize(); + case 'json': + return json_decode($result, 1); + + default: + throw new RuntimeException("Bad decoder format ($decode)"); + } +} From 1bb8b4176b81e6299213abd3ee2ec35ffff593b6 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 11 May 2016 15:17:14 -0700 Subject: [PATCH 30/74] tests/phpunit/CiviDrupal/HookTest.php - Style --- tests/phpunit/CiviDrupal/HookTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CiviDrupal/HookTest.php b/tests/phpunit/CiviDrupal/HookTest.php index 684857f..a9a15f3 100644 --- a/tests/phpunit/CiviDrupal/HookTest.php +++ b/tests/phpunit/CiviDrupal/HookTest.php @@ -1,11 +1,22 @@ 123, ); + $this->assertNotEquals($arg2['foo'], 456); + $this->assertNotEquals($arg2['hook_was_called'], 1); + \CRM_Utils_Hook::singleton() ->invoke( 2, @@ -21,10 +32,13 @@ function testFoo() { $this->assertEquals($arg2['foo'], 456); $this->assertEquals($arg2['hook_was_called'], 1); } + } + } namespace { + function civicrm_civicrm_fakeAlterableHook($arg1, &$arg2) { if ($arg1 != 'hello') { throw new \Exception("Failed to receive arg1"); @@ -35,4 +49,5 @@ function civicrm_civicrm_fakeAlterableHook($arg1, &$arg2) { $arg2['foo'] = 456; $arg2['hook_was_called'] = 1; } + } From 985c9f54c30c4f760f0625e9c1a0ba918d8b5eb8 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 11 May 2016 18:03:04 -0700 Subject: [PATCH 31/74] CRM-14707, CRM-16000 - Add basic test for member-role sync --- modules/civicrm_member_roles/TESTING.md | 7 + modules/civicrm_member_roles/phpunit.xml.dist | 24 +++ .../CiviDrupalMemberRoles/CronTest.php | 141 ++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 modules/civicrm_member_roles/TESTING.md create mode 100644 modules/civicrm_member_roles/phpunit.xml.dist create mode 100644 modules/civicrm_member_roles/tests/phpunit/CiviDrupalMemberRoles/CronTest.php diff --git a/modules/civicrm_member_roles/TESTING.md b/modules/civicrm_member_roles/TESTING.md new file mode 100644 index 0000000..a02c9dc --- /dev/null +++ b/modules/civicrm_member_roles/TESTING.md @@ -0,0 +1,7 @@ +This folder contains the member/role synchronization module for +CiviCRM-Drupal. It does NOT contain tests for core functionality. (For +tests of core functionality, see https://github.com/civicrm/civicrm-core .) + +At time of writing, these tests execute within the context of the default +Drupal database. Consequently, you must be quite careful to write tests +which don't leave a mess in the database. diff --git a/modules/civicrm_member_roles/phpunit.xml.dist b/modules/civicrm_member_roles/phpunit.xml.dist new file mode 100644 index 0000000..c8461d7 --- /dev/null +++ b/modules/civicrm_member_roles/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + ./tests/phpunit + + + + + + ./CiviDrupalMemberRoles + + + diff --git a/modules/civicrm_member_roles/tests/phpunit/CiviDrupalMemberRoles/CronTest.php b/modules/civicrm_member_roles/tests/phpunit/CiviDrupalMemberRoles/CronTest.php new file mode 100644 index 0000000..7db9dfb --- /dev/null +++ b/modules/civicrm_member_roles/tests/phpunit/CiviDrupalMemberRoles/CronTest.php @@ -0,0 +1,141 @@ +assertTrue(module_exists('civicrm_member_roles'), 'civicrm_member_roles should be enabled'); + parent::setUp(); + $this->cleanup(); + } + + protected function tearDown() { + parent::tearDown(); + $this->cleanup(); + } + + public function testCron() { + $prefix = 'MemberSyncTest' . \CRM_Utils_String::createRandom(8, \CRM_Utils_String::ALPHANUMERIC); + $demoContact = $this->getDemoContact(); + + $role = $this->createRole("{$prefix}Role"); + + $org = civicrm_api3('Contact', 'create', array( + 'sequential' => 1, + 'contact_type' => "Organization", + 'organization_name' => "{$prefix}Org", + )); + + $memType = civicrm_api3('MembershipType', 'create', array( + 'sequential' => 1, + 'domain_id' => \CRM_Core_Config::domainID(), + 'member_of_contact_id' => $org['id'], + 'financial_type_id' => "Donation", + 'duration_unit' => "year", + 'duration_interval' => 1, + 'name' => "{$prefix}MemType", + )); + + // Cron doesn't any do anything yet. We haven't configured memberships or rules. + _civicrm_member_roles_sync(NULL, NULL, 'cron'); + $this->assertFalse($this->checkUserRole($GLOBALS['_CV']['DEMO_USER'], "{$prefix}Role")); + + // We'll setup the membership... but not the rule! + civicrm_api3('Membership', 'create', array( + 'sequential' => 1, + 'membership_type_id' => $memType['id'], + 'contact_id' => $demoContact['id'], + )); + $this->assertFalse($this->checkUserRole($GLOBALS['_CV']['DEMO_USER'], "{$prefix}Role")); + + // Now we get the rule. All conditions are met! + $this->createRule($role->rid, $memType['id']); + _civicrm_member_roles_sync(NULL, NULL, 'cron'); + $this->assertTrue($this->checkUserRole($GLOBALS['_CV']['DEMO_USER'], "{$prefix}Role")); + } + + /** + * @param $roleName + * @return \stdClass + */ + protected function createRole($roleName) { + $role = new \stdClass(); + $role->name = $roleName; + user_role_save($role); + return $role; + } + + /** + * @return array + * @throws \CiviCRM_API3_Exception + */ + protected function getDemoContact() { + $this->assertNotEmpty($GLOBALS['_CV']['DEMO_USER']); + $demoContact = civicrm_api3('Contact', 'getsingle', array( + 'id' => '@user:' . $GLOBALS['_CV']['DEMO_USER'], + )); + return $demoContact; + } + + protected function checkUserRole($userName, $roleName) { + $user = user_load_by_name($userName); + return in_array($roleName, $user->roles); + } + + /** + * @param $roleId + * @param $memTypeId + * @throws \Exception + */ + protected function createRule($roleId, $memTypeId) { + $codes = array( + 0 => 'current', + 1 => 'expired', + 'current' => array( + 0 => '1', + 1 => '2', + ), + 'expired' => array( + 0 => '3', + 1 => '4', + 2 => '5', + 3 => '6', + 4 => '7', + ), + ); + db_insert('civicrm_member_roles_rules')->fields(array( + 'rid' => (int) $roleId, + 'type_id' => (int) $memTypeId, + 'status_codes' => serialize($codes), + ))->execute(); + } + + /** + * Delete any records created with the "MemberSyncTest" prefix. + * @throws \CiviCRM_API3_Exception + */ + protected function cleanup() { + \db_delete('role')->condition('name', 'MemberSyncTest%', 'LIKE')->execute(); + \db_delete('civicrm_member_roles_rules')->execute(); + \civicrm_api3('Membership', 'get', array( + 'contact_id' => '@user:' . $GLOBALS['_CV']['DEMO_USER'], + 'api.Membership.delete' => 1, + )); + \civicrm_api3('MembershipType', 'get', array( + 'name' => array('LIKE' => 'MemberSyncTest%'), + 'api.MembershipType.delete' => 1, + )); + \civicrm_api3('Contact', 'get', array( + 'organization_name' => 'MemberSyncTest%', + 'api.Contact.delete' => 1, + )); + } + +} From d5eb4b88ec38d066c2db47596620d82d710cf6d7 Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Wed, 25 May 2016 21:50:24 +0200 Subject: [PATCH 32/74] Replaced mysql with mysqli. --- drush/civicrm.drush.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 8af7f71..c2cf78d 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -381,15 +381,15 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); $sqlPath = "$modPath/civicrm/sql"; - $conn = @mysql_connect($dbhost, $dbuser, $dbpass); - if (!@mysql_select_db($dbname) && - !@mysql_query("CREATE DATABASE $database") + $conn = @mysqli_connect($dbhost, $dbuser, $dbpass); + if (!@mysqli_select_db($conn, $dbname) && + !@mysqli_query($conn, "CREATE DATABASE $dbname") ) { drush_die(dt('CiviCRM database was not found. Failed to create one.')); } // setup database with civicrm structure and data - $dsn = "mysql://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}?new_link=true"; + $dsn = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}?new_link=true"; drush_log(dt("Loading CiviCRM database structure ..")); civicrm_source($dsn, $sqlPath . '/civicrm.mysql'); drush_log(dt("Loading CiviCRM database with required data ..")); From 8a9bc72b610f1da53111193f7b555398b81b4ef3 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 4 Jun 2016 20:55:20 -0600 Subject: [PATCH 33/74] CRM-18748: Code style cleanup. --- civicrm.module | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/civicrm.module b/civicrm.module index 61a8e26..a6fe61b 100644 --- a/civicrm.module +++ b/civicrm.module @@ -173,7 +173,6 @@ function civicrm_initialize() { if (!defined('CIVICRM_SETTINGS_PATH')) { define('CIVICRM_SETTINGS_PATH', $settingsFile); } - $error = include_once ($settingsFile); // get ready for problems $docLinkInstall = "http://wiki.civicrm.org/confluence/display/CRMDOC/Drupal+Installation+Guide"; @@ -188,7 +187,7 @@ function civicrm_initialize() { ) ); - if ($error == FALSE) { + if (!include_once($settingsFile)) { $failure = TRUE; drupal_set_message("

" . t("Oops! - The CiviCRM settings file (civicrm.settings.php) was not found in the expected location ") . @@ -199,8 +198,7 @@ function civicrm_initialize() { } // this does pretty much all of the civicrm initialization - $error = include_once ('CRM/Core/Config.php'); - if ($error == FALSE) { + if (!include_once('CRM/Core/Config.php')) { $failure = TRUE; drupal_set_message("

" . t("Oops! - The path for including CiviCRM code files is not set properly. Most likely there is an error in the civicrm_root setting in your CiviCRM settings file (!1).", @@ -329,6 +327,7 @@ function _civicrm_registerClassLoader() { require_once $home . $path; CRM_Core_ClassLoader::singleton()->register(); } + /** * Function to get the contact type. * From b7794afd4b856104cf8b605cc22f0db19e37d587 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 4 Jun 2016 20:55:40 -0600 Subject: [PATCH 34/74] CRM-18748: Code style (whitespace only). --- civicrm.module | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/civicrm.module b/civicrm.module index a6fe61b..04550b7 100644 --- a/civicrm.module +++ b/civicrm.module @@ -390,19 +390,14 @@ function civicrm_invoke() { // synchronize the drupal uid with the contacts db global $user; - /* - * FIXME: hack to bypass synchronize if running upgrade to avoid - * any serious non-recoverable error which might hinder the - * upgrade process. - */ - - if (!isset($args[1]) || - $args[1] != 'upgrade' - ) { - - CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Drupal', - civicrm_get_ctype('Individual') - ); + /** + * Bypass synchronize if running upgrade to avoid any serious + * non-recoverable error which might hinder the upgrade process. + * + * @FIXME + */ + if (!isset($args[1]) || $args[1] != 'upgrade') { + CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Drupal', civicrm_get_ctype('Individual')); } // Fix the path for the url alias module. From cc6639c18e4d3de45a765321b9d97e48808279a1 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 10 Jun 2016 15:15:26 +0530 Subject: [PATCH 35/74] revert #282 to fix ajax uploads on forms --- civicrm.module | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/civicrm.module b/civicrm.module index 04550b7..a399814 100644 --- a/civicrm.module +++ b/civicrm.module @@ -850,7 +850,7 @@ function civicrm_add_jquery(&$html) { return $html; } -function civicrm_form_alter(&$form, &$formValues, $formID) { +function civicrm_form_alter(&$form, $formValues, $formID) { switch ($formID) { case 'user_admin_permissions': $form['#submit'][] = 'civicrm_user_admin_permissions_submit'; @@ -872,7 +872,6 @@ function civicrm_form_alter(&$form, &$formValues, $formID) { NULL, TRUE, FALSE ); $form = array_merge($form, $output); - $formValues['no_cache'] = TRUE; break; case 'user_profile_form': @@ -902,7 +901,6 @@ function civicrm_form_alter(&$form, &$formValues, $formID) { $form = array_merge($form, $output); } } - $formValues['no_cache'] = TRUE; break; default: From 4e081f8349b58b5aa29f501ed4116553afa50f2f Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Fri, 30 Oct 2015 19:32:04 +0100 Subject: [PATCH 36/74] Allow civicrm-sql-conf and civicrm-sql-cli command without an installed CiviCRM database. --- drush/civicrm.drush.inc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 8af7f71..b4fadab 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -202,6 +202,7 @@ function civicrm_drush_command() { // explicit callback declaration and non-standard name to avoid collision with "sql-conf" 'callback' => 'drush_civicrm_sqlconf', 'description' => 'Print CiviCRM database connection details.', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION, ); $items['civicrm-sql-connect'] = array( // explicit callback declaration and non-standard name to avoid collision with "sql-connect" @@ -242,6 +243,7 @@ function civicrm_drush_command() { 'callback' => 'drush_civicrm_sqlcli', 'description' => "Open a SQL command-line interface using CiviCRM's credentials.", 'aliases' => array('cvsqlc'), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION, ); $items['civicrm-process-mail-queue'] = array( 'description' => "Process pending CiviMail mailing jobs.", @@ -1490,10 +1492,6 @@ function _civicrm_init($fail = TRUE) { CRM_Core_ClassLoader::singleton()->register(); } - // also initialize config object - require_once 'CRM/Core/Config.php'; - $config = CRM_Core_Config::singleton(); - $init = TRUE; return $init; } From 06a41f0602362044b6b0ab147b40f6c66cd0a69c Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Fri, 8 Jul 2016 15:05:47 +0200 Subject: [PATCH 37/74] Changed _civi_init to make initializing config configurable. --- drush/civicrm.drush.inc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index b4fadab..fdfd412 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -661,7 +661,7 @@ function drush_civicrm_upgrade_db_validate() { } $_GET['q'] = 'civicrm/upgrade'; - if (!_civicrm_init()) { + if (!_civicrm_init(TRUE, TRUE)) { return FALSE; } @@ -772,7 +772,7 @@ function drush_civicrm_update_cfg() { * Implements hook_drush_cache_clear. */ function civicrm_drush_cache_clear(&$types) { - if (_civicrm_init(FALSE)) { + if (_civicrm_init(FALSE, TRUE)) { $types['civicrm'] = 'drush_civicrm_cacheclear'; } } @@ -785,7 +785,7 @@ function civicrm_drush_cache_clear(&$types) { * when "drush cc" is called. */ function drush_civicrm_cacheclear() { - _civicrm_init(); + _civicrm_init(TRUE, TRUE); // Clear the classloader cache variable // Should be done in CiviCRM core so that the system flush always deletes @@ -1444,13 +1444,15 @@ function _civicrm_dsn_close() { * Initializes the CiviCRM environment and configuration. * TODO: document why we can't call civicrm_initialize() directly. * - * @param bool fail + * @param bool $fail * If true, will halt drush. Otherwise, return false but do not interrupt. + * @param bool $load_config + * If true, loads the CiviCRM configuration. * * @return bool * Returns TRUE if CiviCRM was initialized. */ -function _civicrm_init($fail = TRUE) { +function _civicrm_init($fail = TRUE, $load_config = FALSE) { static $init = NULL; // return if already initialized @@ -1492,6 +1494,11 @@ function _civicrm_init($fail = TRUE) { CRM_Core_ClassLoader::singleton()->register(); } + if ($load_config) { + require_once 'CRM/Core/Config.php'; + CRM_Core_Config::singleton(); + } + $init = TRUE; return $init; } From bd9762d8b9b9932c93b7e46eabd79dda5b1fa7a6 Mon Sep 17 00:00:00 2001 From: Mattias Michaux Date: Fri, 8 Jul 2016 15:19:42 +0200 Subject: [PATCH 38/74] Reversed logic of loading config, as most of the commands need a loaded config. --- drush/civicrm.drush.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index fdfd412..956fd3a 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -661,7 +661,7 @@ function drush_civicrm_upgrade_db_validate() { } $_GET['q'] = 'civicrm/upgrade'; - if (!_civicrm_init(TRUE, TRUE)) { + if (!_civicrm_init()) { return FALSE; } @@ -772,7 +772,7 @@ function drush_civicrm_update_cfg() { * Implements hook_drush_cache_clear. */ function civicrm_drush_cache_clear(&$types) { - if (_civicrm_init(FALSE, TRUE)) { + if (_civicrm_init(FALSE)) { $types['civicrm'] = 'drush_civicrm_cacheclear'; } } @@ -785,7 +785,7 @@ function civicrm_drush_cache_clear(&$types) { * when "drush cc" is called. */ function drush_civicrm_cacheclear() { - _civicrm_init(TRUE, TRUE); + _civicrm_init(); // Clear the classloader cache variable // Should be done in CiviCRM core so that the system flush always deletes @@ -1394,7 +1394,7 @@ function drush_civicrm_post_civicrm_sqlcli() { function _civicrm_dsn_init($reset = FALSE) { static $globalDbUrl = NULL; - if (!_civicrm_init()) { + if (!_civicrm_init(TRUE, FALSE)) { return FALSE; } @@ -1452,7 +1452,7 @@ function _civicrm_dsn_close() { * @return bool * Returns TRUE if CiviCRM was initialized. */ -function _civicrm_init($fail = TRUE, $load_config = FALSE) { +function _civicrm_init($fail = TRUE, $load_config = TRUE) { static $init = NULL; // return if already initialized From e96c08c9553c8d2ea5006ff2f5b9d0a8c12208d5 Mon Sep 17 00:00:00 2001 From: yashodha Date: Thu, 14 Jul 2016 14:24:56 +0530 Subject: [PATCH 39/74] fix headers --- civicrm.install | 4 ++-- civicrm.module | 2 +- drush/civicrm.drush.inc | 4 ++-- modules/civicrm_engage/Engage/Report/Form/CallList.php | 4 ++-- modules/civicrm_engage/Engage/Report/Form/List.php | 4 ++-- modules/civicrm_engage/Engage/Report/Form/WalkList.php | 4 ++-- modules/civicrm_engage/civicrm_engage.install | 4 ++-- modules/civicrm_engage/civicrm_engage.module | 4 ++-- .../templates/CRM/Contact/Form/Edit/Demographics.tpl | 2 +- .../templates/CRM/Contact/Form/Inline/Demographics.tpl | 2 +- .../templates/CRM/Contact/Page/Inline/Demographics.tpl | 2 +- modules/civicrm_og_sync/civicrm_og_sync.module | 4 ++-- modules/civicrm_rules/civicrm_rules.contact-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.event-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.mailing-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.module | 4 ++-- modules/civicrm_rules/civicrm_rules.participant-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.rules.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_action.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_condition.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_entity.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_event.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_utils.inc | 4 ++-- modules/civicrmtheme/civicrmtheme.install | 4 ++-- modules/civicrmtheme/civicrmtheme.module | 4 ++-- 25 files changed, 46 insertions(+), 46 deletions(-) diff --git a/civicrm.install b/civicrm.install index 4126483..5c54c77 100644 --- a/civicrm.install +++ b/civicrm.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/civicrm.module b/civicrm.module index a399814..1176916 100644 --- a/civicrm.module +++ b/civicrm.module @@ -26,7 +26,7 @@ * Drupal module file. * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 */ require_once 'civicrm_user.inc'; diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 956fd3a..c320d84 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_engage/Engage/Report/Form/CallList.php b/modules/civicrm_engage/Engage/Report/Form/CallList.php index 921af52..5826a49 100644 --- a/modules/civicrm_engage/Engage/Report/Form/CallList.php +++ b/modules/civicrm_engage/Engage/Report/Form/CallList.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/Engage/Report/Form/List.php b/modules/civicrm_engage/Engage/Report/Form/List.php index e4ad155..abb1d64 100644 --- a/modules/civicrm_engage/Engage/Report/Form/List.php +++ b/modules/civicrm_engage/Engage/Report/Form/List.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/Engage/Report/Form/WalkList.php b/modules/civicrm_engage/Engage/Report/Form/WalkList.php index 171f44a..c6b5944 100644 --- a/modules/civicrm_engage/Engage/Report/Form/WalkList.php +++ b/modules/civicrm_engage/Engage/Report/Form/WalkList.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/civicrm_engage.install b/modules/civicrm_engage/civicrm_engage.install index cce59dc..ab8643c 100644 --- a/modules/civicrm_engage/civicrm_engage.install +++ b/modules/civicrm_engage/civicrm_engage.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_engage/civicrm_engage.module b/modules/civicrm_engage/civicrm_engage.module index 07620d1..1977231 100644 --- a/modules/civicrm_engage/civicrm_engage.module +++ b/modules/civicrm_engage/civicrm_engage.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl index fbf86f6..380c504 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl index 99fb372..f05b645 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl index e107800..4d8a6a5 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_og_sync/civicrm_og_sync.module b/modules/civicrm_og_sync/civicrm_og_sync.module index b8b6eab..0de6bef 100644 --- a/modules/civicrm_og_sync/civicrm_og_sync.module +++ b/modules/civicrm_og_sync/civicrm_og_sync.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.contact-eval.inc b/modules/civicrm_rules/civicrm_rules.contact-eval.inc index b5f923e..ecfe2c3 100644 --- a/modules/civicrm_rules/civicrm_rules.contact-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.contact-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.event-eval.inc b/modules/civicrm_rules/civicrm_rules.event-eval.inc index 4ea9ae0..598768d 100644 --- a/modules/civicrm_rules/civicrm_rules.event-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.event-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.mailing-eval.inc b/modules/civicrm_rules/civicrm_rules.mailing-eval.inc index 72df367..a98e655 100644 --- a/modules/civicrm_rules/civicrm_rules.mailing-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.mailing-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.module b/modules/civicrm_rules/civicrm_rules.module index cb91fe8..a44fb3a 100644 --- a/modules/civicrm_rules/civicrm_rules.module +++ b/modules/civicrm_rules/civicrm_rules.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.participant-eval.inc b/modules/civicrm_rules/civicrm_rules.participant-eval.inc index 2cdca81..88004a1 100644 --- a/modules/civicrm_rules/civicrm_rules.participant-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.participant-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.rules.inc b/modules/civicrm_rules/civicrm_rules.rules.inc index d4b7866..0c5cdc7 100644 --- a/modules/civicrm_rules/civicrm_rules.rules.inc +++ b/modules/civicrm_rules/civicrm_rules.rules.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_action.inc b/modules/civicrm_rules/civicrm_rules_action.inc index 255d3cc..10cf9f1 100644 --- a/modules/civicrm_rules/civicrm_rules_action.inc +++ b/modules/civicrm_rules/civicrm_rules_action.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_condition.inc b/modules/civicrm_rules/civicrm_rules_condition.inc index 9454286..e5cafd8 100644 --- a/modules/civicrm_rules/civicrm_rules_condition.inc +++ b/modules/civicrm_rules/civicrm_rules_condition.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_entity.inc b/modules/civicrm_rules/civicrm_rules_entity.inc index 228af4f..8b63cab 100644 --- a/modules/civicrm_rules/civicrm_rules_entity.inc +++ b/modules/civicrm_rules/civicrm_rules_entity.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_event.inc b/modules/civicrm_rules/civicrm_rules_event.inc index 6c446ef..10a0860 100644 --- a/modules/civicrm_rules/civicrm_rules_event.inc +++ b/modules/civicrm_rules/civicrm_rules_event.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_utils.inc b/modules/civicrm_rules/civicrm_rules_utils.inc index a2e041e..1c08fef 100644 --- a/modules/civicrm_rules/civicrm_rules_utils.inc +++ b/modules/civicrm_rules/civicrm_rules_utils.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrmtheme/civicrmtheme.install b/modules/civicrmtheme/civicrmtheme.install index 7c51693..6acdd74 100644 --- a/modules/civicrmtheme/civicrmtheme.install +++ b/modules/civicrmtheme/civicrmtheme.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ diff --git a/modules/civicrmtheme/civicrmtheme.module b/modules/civicrmtheme/civicrmtheme.module index a7e0e93..33465fd 100644 --- a/modules/civicrmtheme/civicrmtheme.module +++ b/modules/civicrmtheme/civicrmtheme.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ From 772ae6e7191ff2c6dae8359b312d6a84422fd14e Mon Sep 17 00:00:00 2001 From: Ken Williams Date: Mon, 18 Jul 2016 20:40:59 -0500 Subject: [PATCH 40/74] Fix variable name in 'drush' update code Looks like the variable `$tarpath` is mistakenly referred to as `$tarfile` in the `_civicrm_extract_tarfile` function a few places - if so, this function wouldn't have worked properly since early 2013 (which agrees with my experience). In addition, since `.tgz` and `.tar.gz` are both common suffixes for gzipped tar files, the code now properly handles both variants. --- drush/civicrm.drush.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index c320d84..f219ed7 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -370,8 +370,8 @@ function drush_civicrm_install() { function _civicrm_extract_tarfile($destinationPath, $option = 'tarfile') { $tarpath = drush_get_option($option, FALSE); - if (drush_shell_exec("gzip -d " . $tarfile)) { - $tarpath = substr($tarfile, 0, strlen($tarfile) - 3); + if (drush_shell_exec("gzip -d " . $tarpath)) { + $tarpath = preg_replace('/(tar\.gz|tgz)$/', 'tar', $tarpath); } drush_shell_exec("tar -xf $tarpath -C \"$destinationPath\""); } From 660106de9595ce6d43940353340fbaf9f52e0755 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 29 Jul 2016 17:58:54 -0700 Subject: [PATCH 41/74] CRM-17789 - civicrm.drush.inc - _civicrm_install_db() for PHP 7 This patch addresses two issues: 1. The new `mysqli` code wasn't working when `mysqld` was listening to a nonstandard port. It now accepts ports using the same input format as the older `mysql` code. 2. To eliminate races in getting changes merged, this makes a tactical move to support both `mysql` and `mysqli`. --- drush/civicrm.drush.inc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 2459c75..d2b5e3c 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -383,15 +383,25 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); $sqlPath = "$modPath/civicrm/sql"; - $conn = @mysqli_connect($dbhost, $dbuser, $dbpass); - if (!@mysqli_select_db($conn, $dbname) && - !@mysqli_query($conn, "CREATE DATABASE $dbname") - ) { + + if (function_exists('mysqli_connect')) { + $dbhostParts = explode(':', $dbhost); + $conn = @mysqli_connect($dbhostParts[0], $dbuser, $dbpass, '', isset($dbhostParts[1]) ? $dbhostParts[1] : ''); + $dbOK = ($a = @mysqli_select_db($conn, $dbname)) || ($b = @mysqli_query($conn, "CREATE DATABASE $dbname")); + } + elseif (function_exists('mysql_connect')) { + $conn = @mysql_connect($dbhost, $dbuser, $dbpass); + $dbOK = @mysql_select_db($dbname, $conn) || @mysql_query("CREATE DATABASE $dbname", $conn); + } + else { + $dbOK = FALSE; + } + if (!$dbOK) { drush_die(dt('CiviCRM database was not found. Failed to create one.')); } // setup database with civicrm structure and data - $dsn = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}?new_link=true"; + $dsn = "mysql://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}?new_link=true"; drush_log(dt("Loading CiviCRM database structure ..")); civicrm_source($dsn, $sqlPath . '/civicrm.mysql'); drush_log(dt("Loading CiviCRM database with required data ..")); From 42336eaf3a3edec60dc9fa86328f252efaa95b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Tue, 30 Aug 2016 10:30:23 +0200 Subject: [PATCH 42/74] CRM-19274 Access Instant Messaging in Drupal Views --- civicrm.info | 1 + .../civicrm_handler_relationship_im.inc | 104 +++++++++ modules/views/components/civicrm.core.inc | 203 +++++++++++++++++- 3 files changed, 306 insertions(+), 2 deletions(-) create mode 100644 modules/views/civicrm/civicrm_handler_relationship_im.inc diff --git a/civicrm.info b/civicrm.info index 37cc214..2015f74 100644 --- a/civicrm.info +++ b/civicrm.info @@ -90,6 +90,7 @@ files[] = modules/views/civicrm/civicrm_handler_relationship_memberships_contrib files[] = modules/views/civicrm/civicrm_handler_relationship_location.inc files[] = modules/views/civicrm/civicrm_handler_relationship_mail.inc files[] = modules/views/civicrm/civicrm_handler_relationship_phone.inc +files[] = modules/views/civicrm/civicrm_handler_relationship_im.inc files[] = modules/views/civicrm/civicrm_handler_relationship_address.inc ; views plugins diff --git a/modules/views/civicrm/civicrm_handler_relationship_im.inc b/modules/views/civicrm/civicrm_handler_relationship_im.inc new file mode 100644 index 0000000..217bcf1 --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_im.inc @@ -0,0 +1,104 @@ + 0); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $imOptions = array(0 => 'Any'); + foreach (self::$_provider as $id => $type) { + $imOptions[$id] = $type; + } + $form['provider'] = array( + '#type' => 'radios', + '#title' => 'Instant Messaging provider for this relationship', + '#options' => $imOptions, + '#description' => t('Instant Messaging provider to be used for this relationship'), + '#default_value' => $this->options['provider'], + '#fieldset' => 'location_choices', + ); + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr_trace(); + exit; + } + if (isset($this->options['provider']) && $this->options['provider']) { + $join = $this->get_join(); + $extra = parent::location_extras(); + $extra[] = array( + 'value' => $this->options['provider'], + 'numeric' => TRUE, + 'field' => 'provider_id', + 'operator' => '=', + ); + $join->extra = $extra; + $join->extra_type = self::$_locationOps[$this->options['location_op']]; + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } + else { + $join = $this->get_join(); + $join->extra = parent::location_extras(); + $join->extra_type = self::$_locationOps[$this->options['location_op']]; + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } + } + return $this->table_alias; + } + + /** + * Called to implement a relationship in a query. + */ + function query() { + // Just ensure the one table. This is briefer than parent::query(), which + // attempts to create an additional join. + $this->ensure_my_table(); + } +} + diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index 3b1e5af..3ac410c 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -30,6 +30,7 @@ * civicrm_address * civicrm_email * civicrm_website + * civicrm_im * civicrm_phone * civicrm_group * civicrm_tag @@ -1184,7 +1185,7 @@ function _civicrm_core_data(&$data, $enabled) { 'left_field' => 'contact_id', 'field' => 'contact_id', ); - + // EMAIL ADDRESS ID $data['civicrm_email']['id'] = array( 'title' => t('Email Address'), @@ -1519,7 +1520,205 @@ function _civicrm_core_data(&$data, $enabled) { ); - // CHILLING OUT AT THE CIVICRM_WEBSITE TABLE + // CHILLING OUT AT THE CIVICRM_IM TABLE + + $data['civicrm_im']['table']['group'] = t('CiviCRM Instant Messaging'); + + // Explain how this table joins to others. + $data['civicrm_im']['table']['join'] = array( + // Directly links to contact table. + 'civicrm_contact' => array( + 'left_field' => 'id', + 'field' => 'contact_id', + ), + ); + + //CiviCRM Im Using Contacts as a pitstop before going on to Participants + $data['civicrm_im']['table']['join']['civicrm_participant'] = array( + 'left_table' => 'civicrm_contact', + 'left_field' => 'id', + 'field' => 'contact_id', + ); + + //CiviCRM Im Using Contacts as a pitstop before going on to Contributions + $data['civicrm_im']['table']['join']['civicrm_contribution'] = array( + 'left_table' => 'civicrm_contact', + 'left_field' => 'id', + 'field' => 'contact_id', + ); + + //CiviCRM Im Using Contacts as a pitstop before going on to Activities + $data['civicrm_im']['table']['join']['civicrm_activity'] = array( + 'left_table' => 'civicrm_contact', + 'left_field' => 'id', + 'field' => 'contact_id', + ); + + + //CiviCRM Im Using Locations as a pitstop before going on to Events + $data['civicrm_im']['table']['join']['civicrm_event'] = array( + 'left_table' => 'civicrm_loc_block', + 'left_field' => 'im_id', + 'field' => 'id', + ); + //CiviCRM Im Using Contacts as a pitstop before going on to Memberhsips + $data['civicrm_im']['table']['join']['civicrm_membership'] = array( + 'left_table' => 'civicrm_contact', + 'left_field' => 'id', + 'field' => 'contact_id', + ); + + //Display Im Details in User Views + $data['civicrm_im']['table']['join']['users'] = array( + 'left_table' => 'civicrm_uf_match', + 'left_field' => 'contact_id', + 'field' => 'contact_id', + ); + + + //BOOLEAN : IS PRIMARY IM + $data['civicrm_im']['is_primary'] = array( + 'title' => t('Is Primary Instant Messaging'), + 'help' => t('Is this the contact\'s primary Instant Messaging?'), + '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 BILLING IM + $data['civicrm_im']['is_billing'] = array( + 'title' => t('Is Billing Instant Messaging'), + 'help' => t('Is this the contact\'s billing Instant Messaging?'), + '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', + ), + ); + + //IM'S LOCATION TYPE + $data['civicrm_im']['location_type'] = array( + 'title' => t('Location Type'), + 'real field' => 'location_type_id', + 'help' => t('The Location of the Instant Messaging for the Contact'), + 'field' => array( + 'handler' => 'civicrm_handler_field_pseudo_constant', + 'click sortable' => TRUE, + 'pseudo class' => 'CRM_Core_PseudoConstant', + 'pseudo method' => 'get', + 'dao class' => 'CRM_Core_DAO_IM', + ), + 'argument' => array( + 'handler' => 'views_handler_argument', + ), + 'filter' => array( + 'handler' => 'civicrm_handler_filter_pseudo_constant', + 'allow empty' => TRUE, + 'pseudo class' => 'CRM_Core_PseudoConstant', + 'pseudo method' => 'get', + 'dao class' => 'CRM_Core_DAO_IM', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + //NAME + $data['civicrm_im']['name'] = array( + 'title' => t('Name'), + 'help' => t('IM screen name'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + + // IM ID + $data['civicrm_im']['id'] = array( + 'title' => t('Instant Messaging'), + 'help' => t('Contact Instant Messaging'), + 'relationship' => array( + 'base' => 'civicrm_contact', + 'field' => 'id', + 'relationship table' => 'civicrm_im', + 'relationship field' => 'contact_id', + 'handler' => 'civicrm_handler_relationship_im', + 'label' => t('CiviCRM Instant Messaging'), + ), + ); + + //CONTACT ID contact this IM belongs to + $data['civicrm_im']['contact_id'] = array( + 'title' => t('Contact ID'), + 'help' => t('Contact Instant Messaging belongs to '), + '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', + ), + 'relationship' => array( + 'base' => 'civicrm_contact', + 'base field' => 'id', + 'handler' => 'views_handler_relationship', + 'label' => t('Related Instant Messaging'), + ), + ); + + //IM Provider + $data['civicrm_im']['provider'] = array( + 'title' => t('IM Provider'), + 'real field' => 'provider_id', + 'help' => t('Which IM Provider does this screen name belong to'), + 'field' => array( + 'handler' => 'civicrm_handler_field_pseudo_constant', + 'click sortable' => TRUE, + 'pseudo class' => 'CRM_Core_PseudoConstant', + 'pseudo method' => 'get', + 'dao class' => 'CRM_Core_DAO_IM', + ), + 'argument' => array( + 'handler' => 'views_handler_argument', + ), + 'filter' => array( + 'handler' => 'civicrm_handler_filter_pseudo_constant', + 'allow empty' => TRUE, + 'pseudo class' => 'CRM_Core_PseudoConstant', + 'pseudo method' => 'get', + 'dao class' => 'CRM_Core_DAO_IM', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + +// CHILLING OUT AT THE CIVICRM_WEBSITE TABLE $data['civicrm_website']['table']['group'] = t('CiviCRM Website'); From d348cfdf636447e22b2f7d8bf8c4abbcf8669dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Tue, 6 Sep 2016 09:48:26 +0200 Subject: [PATCH 43/74] CRM-19274 - Drupal Views Integration Location-related relationships and fields fixes relationships issues to be able to display phone of the household of the contact best practices : moving the location related code to the location objects adding the possibility to choose location and type in field for Instant Messaging and Website --- .../civicrm/civicrm_handler_field_address.inc | 58 +++++---- .../civicrm/civicrm_handler_field_im.inc | 103 +++++++++++++++ .../civicrm_handler_field_location.inc | 37 +++--- .../civicrm/civicrm_handler_field_phone.inc | 47 ++++--- .../civicrm/civicrm_handler_field_website.inc | 103 +++++++++++++++ .../civicrm_handler_relationship_address.inc | 89 ++++++++----- .../civicrm_handler_relationship_im.inc | 57 +++++---- .../civicrm_handler_relationship_location.inc | 36 +++++- .../civicrm_handler_relationship_mail.inc | 28 ++--- .../civicrm_handler_relationship_phone.inc | 63 ++++++---- .../civicrm_handler_relationship_website.inc | 119 ++++++++++++++++++ 11 files changed, 585 insertions(+), 155 deletions(-) create mode 100644 modules/views/civicrm/civicrm_handler_field_im.inc create mode 100644 modules/views/civicrm/civicrm_handler_field_website.inc create mode 100644 modules/views/civicrm/civicrm_handler_relationship_website.inc diff --git a/modules/views/civicrm/civicrm_handler_field_address.inc b/modules/views/civicrm/civicrm_handler_field_address.inc index 006771b..9983a07 100644 --- a/modules/views/civicrm/civicrm_handler_field_address.inc +++ b/modules/views/civicrm/civicrm_handler_field_address.inc @@ -29,20 +29,10 @@ * @ingroup civicrm_field_handlers */ class civicrm_handler_field_address extends civicrm_handler_field_location { - static $_locationOps; - function construct() { - parent::construct(); - if (!self::$_locationOps) { - if (!civicrm_initialize()) { - return; - } - self::$_locationOps = array(0 => 'AND', 1 => 'OR'); - } - } function option_definition() { $options = parent::option_definition(); - $options['is_billing'] = array('default' => ''); + $options['is_billing'] = array('default' => 0); return $options; } @@ -58,31 +48,39 @@ class civicrm_handler_field_address extends civicrm_handler_field_location { ); } + function join_address($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['is_billing']) && $this->options['is_billing']) { + $extra[] = array( + 'value' => $this->options['is_billing'], + 'numeric' => TRUE, + 'field' => 'is_billing', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_address($join); + return $join; + } + function ensure_my_table() { if (!isset($this->table_alias)) { if (!method_exists($this->query, 'ensure_table')) { vpr_trace(); exit; } - $extra = array(); - $extra = parent::location_extras(); - if (isset($this->options['is_billing']) && $this->options['is_billing']) { - $extra[] = array( - 'value' => $this->options['is_billing'], - 'numeric' => TRUE, - 'field' => 'is_billing', - 'operator' => '=', - ); - } - if (isset($extra) && !empty($extra)) { - $join = $this->get_join(); - $join->extra = $extra; - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship); - } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_im.inc b/modules/views/civicrm/civicrm_handler_field_im.inc new file mode 100644 index 0000000..c8e9aa6 --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_field_im.inc @@ -0,0 +1,103 @@ + 0); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $imOptions = array(0 => 'Any'); + foreach (self::$_provider as $id => $type) { + $imOptions[$id] = $type; + } + $form['provider'] = array( + '#type' => 'radios', + '#title' => 'Instant Messaging provider for this field', + '#options' => $imOptions, + '#description' => t('Instant Messaging provider to be displayed for this field'), + '#default_value' => $this->options['provider'], + '#fieldset' => 'location_choices', + ); + } + + function join_im($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['provider']) && $this->options['provider']) { + $extra[] = array( + 'value' => $this->options['provider'], + 'numeric' => TRUE, + 'field' => 'provider_id', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_im($join); + return $join; + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr_trace(); + exit; + } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } + return $this->table_alias; + } +} + diff --git a/modules/views/civicrm/civicrm_handler_field_location.inc b/modules/views/civicrm/civicrm_handler_field_location.inc index 7230c70..cb6abd3 100644 --- a/modules/views/civicrm/civicrm_handler_field_location.inc +++ b/modules/views/civicrm/civicrm_handler_field_location.inc @@ -32,6 +32,7 @@ class civicrm_handler_field_location extends civicrm_handler_field { static $_locationTypes; static $_locationOps; static $location_op; + function construct() { parent::construct(); if (!self::$_locationTypes) { @@ -109,19 +110,8 @@ class civicrm_handler_field_location extends civicrm_handler_field { vpr_trace(); exit; } - if ($this->options['location_type'] > 0 || - (isset($this->options['is_primary']) && $this->options['is_primary']) - ) { - $join = $this->get_join(); - $extra = $this->location_extras(); - $join->extra = $extra; - // Decide between And/Or - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship); - } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } @@ -146,8 +136,23 @@ class civicrm_handler_field_location extends civicrm_handler_field { } return $extra; } -} - - + function join_location($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + $extra = array_merge($extra, $this->location_extras()); + if (!empty($extra)) { + $join->extra = $extra; + $join->extra_type = self::$_locationOps[$this->options['location_op']]; + } + return $join; + } + function get_join() { + $join = parent::get_join(); + $join = $this->join_location($join); + return $join; + } +} diff --git a/modules/views/civicrm/civicrm_handler_field_phone.inc b/modules/views/civicrm/civicrm_handler_field_phone.inc index aee3d1d..64b1572 100644 --- a/modules/views/civicrm/civicrm_handler_field_phone.inc +++ b/modules/views/civicrm/civicrm_handler_field_phone.inc @@ -30,6 +30,7 @@ */ class civicrm_handler_field_phone extends civicrm_handler_field_location { static $_phoneType; + function construct() { parent::construct(); if (!self::$_phoneType) { @@ -62,31 +63,39 @@ class civicrm_handler_field_phone extends civicrm_handler_field_location { ); } + function join_phone($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['phone_type']) && $this->options['phone_type']) { + $extra[] = array( + 'value' => $this->options['phone_type'], + 'numeric' => TRUE, + 'field' => 'phone_type_id', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_phone($join); + return $join; + } + function ensure_my_table() { if (!isset($this->table_alias)) { if (!method_exists($this->query, 'ensure_table')) { vpr_trace(); exit; } - if (isset($this->options['phone_type']) && $this->options['phone_type']) { - $join = $this->get_join(); - $extra = parent::location_extras(); - $extra[] = array( - 'value' => $this->options['phone_type'], - 'numeric' => TRUE, - 'field' => 'phone_type_id', - 'operator' => '=', - ); - $join->extra = $extra; - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $join = $this->get_join(); - $join->extra = parent::location_extras(); - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_website.inc b/modules/views/civicrm/civicrm_handler_field_website.inc new file mode 100644 index 0000000..7d8a83e --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_field_website.inc @@ -0,0 +1,103 @@ + 0); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $websiteOptions = array(0 => 'Any'); + foreach (self::$_websiteType as $id => $type) { + $websiteOptions[$id] = $type; + } + $form['website_type'] = array( + '#type' => 'radios', + '#title' => 'Website type for this field', + '#options' => $websiteOptions, + '#description' => t('Website type to be displayed for this field'), + '#default_value' => $this->options['website_type'], + '#fieldset' => 'location_choices', + ); + } + + function join_website($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['website_type']) && $this->options['website_type']) { + $extra[] = array( + 'value' => $this->options['website_type'], + 'numeric' => TRUE, + 'field' => 'website_type_id', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_website($join); + return $join; + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr_trace(); + exit; + } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } + return $this->table_alias; + } +} + diff --git a/modules/views/civicrm/civicrm_handler_relationship_address.inc b/modules/views/civicrm/civicrm_handler_relationship_address.inc index 75d3305..f370b08 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_address.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_address.inc @@ -29,36 +29,14 @@ * @ingroup civicrm_relationship_handlers */ class civicrm_handler_relationship_address extends civicrm_handler_relationship_location { - - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr_trace(); - exit; - } - $extra = $this->location_extras(); - if (isset($this->options['is_billing']) && $this->options['is_billing']) { - $extra[] = array( - 'value' => $this->options['is_billing'], - 'numeric' => TRUE, - 'field' => 'is_billing', - 'operator' => '=', - ); - } - if (isset($extra) && !empty($extra)) { - $join = $this->get_join(); - $join->extra = $extra; - // Decide between And/Or - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } else { - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship); - } - } - return $this->table_alias; + + function option_definition() { + $options = parent::option_definition(); + $options['is_billing'] = array('default' => 0); + return $options; } - function options_form(&$form, &$form_state) { + function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['is_billing'] = array( '#type' => 'checkbox', @@ -69,5 +47,60 @@ class civicrm_handler_relationship_address extends civicrm_handler_relationship_ '#fieldset' => 'location_choices', ); } + + function join_address($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['is_billing']) && $this->options['is_billing']) { + $extra[] = array( + 'value' => $this->options['is_billing'], + 'numeric' => TRUE, + 'field' => 'is_billing', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_address($join); + return $join; + } + + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; + } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } + return $this->table_alias; + } + + /** + * Called to implement a relationship in a query. + */ + function query() { + // Just ensure the one table. This is briefer than parent::query(), which + // attempts to create an additional join. + $this->alias = $this->ensure_my_table(); + + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = array( + '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 217bcf1..3f92149 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_im.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_im.inc @@ -63,31 +63,39 @@ class civicrm_handler_relationship_im extends civicrm_handler_relationship_locat ); } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr_trace(); - exit; - } - if (isset($this->options['provider']) && $this->options['provider']) { - $join = $this->get_join(); - $extra = parent::location_extras(); - $extra[] = array( + function join_im($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['provider']) && $this->options['provider']) { + $extra[] = array( 'value' => $this->options['provider'], 'numeric' => TRUE, 'field' => 'provider_id', 'operator' => '=', - ); - $join->extra = $extra; - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $join = $this->get_join(); - $join->extra = parent::location_extras(); - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_im($join); + return $join; + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } @@ -98,7 +106,14 @@ class civicrm_handler_relationship_im extends civicrm_handler_relationship_locat function query() { // Just ensure the one table. This is briefer than parent::query(), which // attempts to create an additional join. - $this->ensure_my_table(); + $this->alias = $this->ensure_my_table(); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = array( + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, + ); } } diff --git a/modules/views/civicrm/civicrm_handler_relationship_location.inc b/modules/views/civicrm/civicrm_handler_relationship_location.inc index b536b96..77438fe 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_location.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_location.inc @@ -105,7 +105,6 @@ class civicrm_handler_relationship_location extends views_handler_relationship { ); } - function location_extras() { $extra = array(); if (!empty($this->options['location_type'])) { @@ -127,6 +126,37 @@ class civicrm_handler_relationship_location extends views_handler_relationship { return $extra; } + function join_location($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + $extra = array_merge($extra, $this::location_extras()); + if (!empty($extra)) { + $join->extra = $extra; + } + $join->extra_type = self::$_locationOps[$this->options['location_op']]; + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_location($join); + return $join; + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; + } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } + return $this->table_alias; + } + /** * Called to implement a relationship in a query. */ @@ -134,6 +164,8 @@ class civicrm_handler_relationship_location extends views_handler_relationship { // Just ensure the one table. This is briefer than parent::query(), which // attempts to create an additional join. $this->ensure_my_table(); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->alias = $this->table_alias; } } - diff --git a/modules/views/civicrm/civicrm_handler_relationship_mail.inc b/modules/views/civicrm/civicrm_handler_relationship_mail.inc index 67b9de4..30046a1 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_mail.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_mail.inc @@ -29,24 +29,15 @@ * @ingroup civicrm_relationship_handlers */ class civicrm_handler_relationship_mail extends civicrm_handler_relationship_location { - + function ensure_my_table() { if (!isset($this->table_alias)) { if (!method_exists($this->query, 'ensure_table')) { - vpr_trace(); - exit; - } - $extra = $this->location_extras(); - if (isset($extra) && !empty($extra)) { - $join = $this->get_join(); - $join->extra = $extra; - // Decide between And/Or - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship); + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } @@ -57,7 +48,14 @@ class civicrm_handler_relationship_mail extends civicrm_handler_relationship_loc function query() { // Just ensure the one table. This is briefer than parent::query(), which // attempts to create an additional join. - $this->ensure_my_table(); + $this->alias = $this->ensure_my_table(); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = array( + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, + ); } } diff --git a/modules/views/civicrm/civicrm_handler_relationship_phone.inc b/modules/views/civicrm/civicrm_handler_relationship_phone.inc index ce09516..6c56413 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_phone.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_phone.inc @@ -29,7 +29,7 @@ * @ingroup civicrm_relationship_handlers */ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_location { - + static $_phoneType; function construct() { parent::construct(); @@ -63,31 +63,40 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo ); } + + function join_phone($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['phone_type']) && $this->options['phone_type']) { + $extra[] = array( + 'value' => $this->options['phone_type'], + 'numeric' => TRUE, + 'field' => 'phone_type_id', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_phone($join); + return $join; + } + function ensure_my_table() { if (!isset($this->table_alias)) { if (!method_exists($this->query, 'ensure_table')) { - vpr_trace(); - exit; - } - if (isset($this->options['phone_type']) && $this->options['phone_type']) { - $join = $this->get_join(); - $extra = parent::location_extras(); - $extra[] = array( - 'value' => $this->options['phone_type'], - 'numeric' => TRUE, - 'field' => 'phone_type_id', - 'operator' => '=', - ); - $join->extra = $extra; - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); - } - else { - $join = $this->get_join(); - $join->extra = parent::location_extras(); - $join->extra_type = self::$_locationOps[$this->options['location_op']]; - $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); } return $this->table_alias; } @@ -98,7 +107,13 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo function query() { // Just ensure the one table. This is briefer than parent::query(), which // attempts to create an additional join. - $this->ensure_my_table(); + $this->alias = $this->ensure_my_table(); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = array( + '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 new file mode 100644 index 0000000..00489e2 --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_website.inc @@ -0,0 +1,119 @@ + 0); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $websiteOptions = array(0 => 'Any'); + foreach (self::$_websiteType as $id => $type) { + $websiteOptions[$id] = $type; + } + $form['website_type'] = array( + '#type' => 'radios', + '#title' => 'Website type for this relationship', + '#options' => $websiteOptions, + '#description' => t('Website type to be used for this relationship'), + '#default_value' => $this->options['website_type'], + '#fieldset' => 'location_choices', + ); + } + + function join_website($join = array()) { + $extra = array(); + if (isset($join->extra)) { + $extra = $join->extra; + } + if (isset($this->options['website_type']) && $this->options['website_type']) { + $extra[] = array( + 'value' => $this->options['website_type'], + 'numeric' => TRUE, + 'field' => 'website_type_id', + 'operator' => '=', + ); + } + if (!empty($extra)) { + $join->extra = $extra; + } + return $join; + } + + function get_join() { + $join = parent::get_join(); + $join = $this->join_website($join); + return $join; + } + + function ensure_my_table() { + if (!isset($this->table_alias)) { + if (!method_exists($this->query, 'ensure_table')) { + vpr(t('Ensure my table called but query has no ensure_table method.')); + return; + } + $join = $this->get_join(); + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } + return $this->table_alias; + } + + /** + * Called to implement a relationship in a query. + */ + function query() { + // Just ensure the one table. This is briefer than parent::query(), which + // attempts to create an additional join. + $this->alias = $this->ensure_my_table(); + //register relationship + $this->view->relationship[$this->options['id']]->alias = $this->alias; + $this->query->relationships[$this->alias] = array( + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, + ); + } +} + From 9882f033e9c2bfb670b5af9791c690d78c9d6a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20J=2E=20G=C3=B3mez?= Date: Wed, 7 Sep 2016 16:22:45 -0400 Subject: [PATCH 44/74] Remove error-suppression arroba which keeps errors out of the log as well as the off the screen and which just cost me an hour of my life. --- civicrm.config.php.drupal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/civicrm.config.php.drupal b/civicrm.config.php.drupal index 9cdf9cf..2250906 100644 --- a/civicrm.config.php.drupal +++ b/civicrm.config.php.drupal @@ -112,7 +112,7 @@ function civicrm_conf_init() { $settingsFile = civicrm_conf_init( ) . '/civicrm.settings.php'; define('CIVICRM_SETTINGS_PATH', $settingsFile); -$error = @include_once( $settingsFile ); +$error = include_once( $settingsFile ); if ( $error == false ) { echo "Could not load the settings file at: {$settingsFile}\n"; exit( ); From 19d3630eefe83c9c8904bf9f8545e8420add91bb Mon Sep 17 00:00:00 2001 From: nielosz Date: Mon, 19 Sep 2016 11:47:25 +0200 Subject: [PATCH 45/74] Use translated labels instead of names --- .../civicrm/civicrm_handler_filter_relationship_type.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc b/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc index 44bb678..adffc27 100644 --- a/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc +++ b/modules/views/civicrm/civicrm_handler_filter_relationship_type.inc @@ -41,7 +41,7 @@ class civicrm_handler_filter_relationship_type extends views_handler_filter_in_o return; } require_once 'CRM/Core/PseudoConstant.php'; - $relationshipType_array = CRM_Core_PseudoConstant::relationshipType($columnName = 'name'); + $relationshipType_array = CRM_Core_PseudoConstant::relationshipType($columnName = 'label'); // relationshipType() returns information about relations as array with fields // 'label_a_b', 'label_b_a', 'contact_type_a' and 'contact_type_b'. @@ -49,7 +49,7 @@ class civicrm_handler_filter_relationship_type extends views_handler_filter_in_o $options = array(); foreach ($relationshipType_array as $id => $value_array) { - $options[$id] = $value_array['name_a_b']; + $options[$id] = $value_array['label_a_b']; } self::$_relationshipType = $options; From 7ccb9993503134314bb9a898408351e15a3b51aa Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Fri, 23 Sep 2016 16:14:05 -0400 Subject: [PATCH 46/74] CRM-19407: cannot install with mysqli if using default port. --- drush/civicrm.drush.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index aac24fe..7226f85 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -386,7 +386,7 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, if (function_exists('mysqli_connect')) { $dbhostParts = explode(':', $dbhost); - $conn = @mysqli_connect($dbhostParts[0], $dbuser, $dbpass, '', isset($dbhostParts[1]) ? $dbhostParts[1] : ''); + $conn = @mysqli_connect($dbhostParts[0], $dbuser, $dbpass, '', isset($dbhostParts[1]) ? $dbhostParts[1] : NULL); $dbOK = ($a = @mysqli_select_db($conn, $dbname)) || ($b = @mysqli_query($conn, "CREATE DATABASE $dbname")); } elseif (function_exists('mysql_connect')) { From 96d55a50a451339e9bd93c604e92e30e11d5cfa2 Mon Sep 17 00:00:00 2001 From: David Reedy Jr Date: Thu, 29 Sep 2016 09:44:59 -0500 Subject: [PATCH 47/74] CRM-19430 Use label for relation type field --- .../civicrm/civicrm_handler_field_relationship_type.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_relationship_type.inc b/modules/views/civicrm/civicrm_handler_field_relationship_type.inc index dd7cb4e..5ad71f2 100644 --- a/modules/views/civicrm/civicrm_handler_field_relationship_type.inc +++ b/modules/views/civicrm/civicrm_handler_field_relationship_type.inc @@ -39,15 +39,15 @@ class civicrm_handler_field_relationship_type extends views_handler_field { return; } require_once 'CRM/Core/PseudoConstant.php'; - $relationshipType_array = CRM_Core_PseudoConstant::relationshipType('name'); + $relationshipType_array = CRM_Core_PseudoConstant::relationshipType('label'); // relationshipType() returns information about relations as array with fields // 'name_a_b', 'name_b_a', 'contact_type_a' and 'contact_type_b'. - // We keep just 'name_a_b' for simplicity. + // We keep just 'label_a_b' for simplicity. $options = array(); foreach ($relationshipType_array as $id => $value_array) { - $options[$id] = $value_array['name_a_b']; + $options[$id] = $value_array['label_a_b']; } self::$_relationshipType = $options; From 55417fbeb13bfc1e3e45a263d68687b4597c3f7e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 3 Oct 2016 16:16:11 -0400 Subject: [PATCH 48/74] CRM-14280 - Fix check of nonexistant permission --- .../civicrm/civicrm_handler_field_link_relationship.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc index 644edab..9183cb9 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_relationship.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_relationship.inc @@ -117,7 +117,7 @@ class civicrm_handler_field_link_relationship extends views_handler_field { // LINKING TO RELATIONSHIP EDIT PAGE case 'edit_A_B': - if (user_access('edit relationships') && $link_text !== NULL && $link_text !== '') { + if (user_access('edit all contacts') && $link_text !== NULL && $link_text !== '') { return civicrm_views_href($link_text, 'civicrm/contact/view/rel', "reset=1&action=update&id={$values->id}&cid={$values->civicrm_relationship_contact_id_a}&rtype=a_b" @@ -134,7 +134,7 @@ class civicrm_handler_field_link_relationship extends views_handler_field { // LINKING TO RELATIONSHIP EDIT PAGE case 'edit_B_A': - if (user_access('edit relationships') && $link_text !== NULL && $link_text !== '') { + if (user_access('edit all contacts') && $link_text !== NULL && $link_text !== '') { return civicrm_views_href($link_text, 'civicrm/contact/view/rel', "reset=1&action=update&id={$values->id}&cid={$values->civicrm_relationship_contact_id_b}&rtype=b_a" @@ -143,7 +143,7 @@ class civicrm_handler_field_link_relationship extends views_handler_field { // LINKING TO RELATIONSHIP DELETE PAGE case 'delete': - if (user_access('edit relationships') && $link_text !== NULL && $link_text !== '') { + if (user_access('edit all contacts') && $link_text !== NULL && $link_text !== '') { return civicrm_views_href($link_text, 'civicrm/contact/view/rel', "reset=1&action=delete&id={$values->id}&cid={$values->civicrm_relationship_contact_id_a}&rtype=a_b" From e9eca96138966352162a5ab0bc2f873172854591 Mon Sep 17 00:00:00 2001 From: Alan Dixon Date: Wed, 12 Oct 2016 17:52:04 -0400 Subject: [PATCH 49/74] Updated call to civicrm_views_custom_data_cache as per CRM-18776 (#386) * Updated call to civicrm_views_custom_data_cache as per CRM-18776 * More readable version, thanks GinkoFJG --- modules/views/components/civicrm.core.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index 3ac410c..af55f59 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -2910,9 +2910,11 @@ function _civicrm_core_data(&$data, $enabled) { while ($dao->fetch()) { - // call getTree using $dao->id as groupID and $dao->extends as entityType - - $data = civicrm_views_custom_data_cache($data, $dao->extends, $dao->id, $dao->extends_entity_column_value); + // call getTree using $dao->id as groupID, $dao->extends as entityType, with possible subtypes in $dao->extends_entity_column_value + $extendsContactSubtype = (('Contact' === $dao->extends) && !empty($dao->extends_entity_column_value)); + $contactSubtypes = !$extendsContactSubtype ? NULL : array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->extends_entity_column_value)); + $contactSubtypes = empty($contactSubtypes) ? NULL : $contactSubtypes; + $data = civicrm_views_custom_data_cache($data, $dao->extends, $dao->id, $contactSubtypes); } } From c0e1623de3eb768cf9e171ce80b1bac436c7d419 Mon Sep 17 00:00:00 2001 From: David Reedy Jr Date: Wed, 26 Oct 2016 09:51:29 -0500 Subject: [PATCH 50/74] CRM-19568 Expose processor ID to views --- .../views/components/civicrm.contribute.inc | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/views/components/civicrm.contribute.inc b/modules/views/components/civicrm.contribute.inc index d4fcc3e..e1ecf39 100644 --- a/modules/views/components/civicrm.contribute.inc +++ b/modules/views/components/civicrm.contribute.inc @@ -943,6 +943,26 @@ function _civicrm_contribute_data(&$data, $enabled) { 'title' => 'Recurring Contribution End Date', 'name' => 'end_date', )); + //Prcocessor ID + $data['civicrm_contribution_recur']['processor_id'] = array( + 'title' => t('Processor ID'), + 'help' => t('The Processor ID of the Recurring Contribution'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + 'numeric' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); //Unique Transaction ID $data['civicrm_contribution_recur']['trxn_id'] = array( 'title' => t('Unique Transaction ID'), From 4805a823bfaadbf6d7b405a1e78ace546fba194d Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Mon, 7 Nov 2016 13:33:03 -0500 Subject: [PATCH 51/74] CRM-19611 - remove custom fields that are now duplicated in core. --- modules/civicrm_engage/CustomGroupData.xml | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/modules/civicrm_engage/CustomGroupData.xml b/modules/civicrm_engage/CustomGroupData.xml index 9c4a650..232d4c8 100644 --- a/modules/civicrm_engage/CustomGroupData.xml +++ b/modules/civicrm_engage/CustomGroupData.xml @@ -91,20 +91,6 @@ 0 0 - - Event_Details - Event Details - Event - - 1 - - - 14 - 1 - civicrm_value_event_details - 0 - 0 - Communication_Details Communication Details @@ -729,25 +715,6 @@ invitation_response_options Participant_Info - - - event_contact_person - ContactReference - Autocomplete-Select - action=lookup&group=2 - 0 - 1 - 0 - 8 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - event_contact_person - Event_Details - String From f130fcd4086848cf117a98e0f1322cdc422f3219 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Wed, 9 Nov 2016 09:19:48 -0500 Subject: [PATCH 52/74] CRM-19604: civicrm-ext-list: avoid default API limit of 25 results --- drush/civicrm.drush.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 7226f85..414ecd5 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -576,7 +576,11 @@ function civicrm_drush_help($section) { function drush_civicrm_ext_list() { civicrm_initialize(); try{ - $result = civicrm_api('extension', 'get', array('version' => 3)); + $result = civicrm_api3('extension', 'get', array( + 'options' => array( + 'limit' => 0, + ), + )); $rows = array(array(dt('App name'), dt('Status'))); foreach ($result['values'] as $k => $extension_data) { $rows[] = array( From 33a0da9260a9683169929dca1e5da1d3d361a065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Tue, 29 Nov 2016 16:59:36 +0100 Subject: [PATCH 53/74] missing files in previous commit --- civicrm.info | 3 ++ modules/views/components/civicrm.core.inc | 37 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/civicrm.info b/civicrm.info index 2015f74..93dbd93 100644 --- a/civicrm.info +++ b/civicrm.info @@ -47,6 +47,8 @@ files[] = modules/views/civicrm/civicrm_handler_field_money.inc files[] = modules/views/civicrm/civicrm_handler_field_option.inc files[] = modules/views/civicrm/civicrm_handler_field_pcp_raised_amount.inc files[] = modules/views/civicrm/civicrm_handler_field_phone.inc +files[] = modules/views/civicrm/civicrm_handler_field_im.inc +files[] = modules/views/civicrm/civicrm_handler_field_website.inc files[] = modules/views/civicrm/civicrm_handler_field_relationship_type.inc files[] = modules/views/civicrm/civicrm_handler_field_state.inc files[] = modules/views/civicrm/civicrm_handler_field_custom_file.inc @@ -91,6 +93,7 @@ files[] = modules/views/civicrm/civicrm_handler_relationship_location.inc files[] = modules/views/civicrm/civicrm_handler_relationship_mail.inc files[] = modules/views/civicrm/civicrm_handler_relationship_phone.inc files[] = modules/views/civicrm/civicrm_handler_relationship_im.inc +files[] = modules/views/civicrm/civicrm_handler_relationship_website.inc files[] = modules/views/civicrm/civicrm_handler_relationship_address.inc ; views plugins diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index af55f59..ebd2c31 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -711,6 +711,11 @@ function _civicrm_core_data(&$data, $enabled) { 'field' => 'contact_id', ), ); + //CiviCRM Address + $data['civicrm_address']['table']['join']['civicrm_address'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); //CiviCRM Address Using Contacts as a pitstop before going on to Participants $data['civicrm_address']['table']['join']['civicrm_participant'] = array( @@ -1145,6 +1150,12 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //CiviCRM Email + $data['civicrm_email']['table']['join']['civicrm_email'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); + //CiviCRM Email Using Contacts as a pitstop before going on to Participants $data['civicrm_email']['table']['join']['civicrm_participant'] = array( 'left_table' => 'civicrm_contact', @@ -1301,6 +1312,12 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //CiviCRM Phone + $data['civicrm_phone']['table']['join']['civicrm_phone'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); + //CiviCRM Phone Using Contacts as a pitstop before going on to Participants $data['civicrm_phone']['table']['join']['civicrm_participant'] = array( 'left_table' => 'civicrm_contact', @@ -1533,6 +1550,12 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //CiviCRM Im + $data['civicrm_im']['table']['join']['civicrm_im'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); + //CiviCRM Im Using Contacts as a pitstop before going on to Participants $data['civicrm_im']['table']['join']['civicrm_participant'] = array( 'left_table' => 'civicrm_contact', @@ -1646,7 +1669,7 @@ function _civicrm_core_data(&$data, $enabled) { 'title' => t('Name'), 'help' => t('IM screen name'), 'field' => array( - 'handler' => 'views_handler_field', + 'handler' => 'civicrm_handler_field_im', 'click sortable' => TRUE, ), ); @@ -1731,6 +1754,12 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //CiviCRM Website + $data['civicrm_website']['table']['join']['civicrm_website'] = array( + 'left_field' => 'id', + 'field' => 'id', + ); + //CiviCRM Website Using Contacts as a pitstop before going on to Participants $data['civicrm_website']['table']['join']['civicrm_participant'] = array( 'left_table' => 'civicrm_contact', @@ -1800,7 +1829,7 @@ function _civicrm_core_data(&$data, $enabled) { 'title' => t('Website URL'), 'help' => t('Website URL'), 'field' => array( - 'handler' => 'views_handler_field', + 'handler' => 'civicrm_handler_field_website', 'click sortable' => TRUE, ), 'argument' => array( @@ -1816,8 +1845,8 @@ function _civicrm_core_data(&$data, $enabled) { 'relationship' => array( 'base' => 'civicrm_contact', 'base field' => 'id', - 'handler' => 'views_handler_relationship', - 'label' => t('Related Phone'), + 'handler' => 'civicrm_handler_relationship_website', + 'label' => t('Related Website'), ), ); // CIVICRM Activities are here with all the activeness they can muster, base tabling it up. From 62584a10323f344a700cca1142e2e6138c61a2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Thu, 8 Dec 2016 09:23:38 +0100 Subject: [PATCH 54/74] CRM-19759 handles the 'require this relationship' checkbox --- .../civicrm/civicrm_handler_relationship_location.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/views/civicrm/civicrm_handler_relationship_location.inc b/modules/views/civicrm/civicrm_handler_relationship_location.inc index 77438fe..2a2ac76 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_location.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_location.inc @@ -126,6 +126,14 @@ class civicrm_handler_relationship_location extends views_handler_relationship { return $extra; } + + function join_required($join = array()) { + if (!empty($this->options['required'])) { + $join->type = 'INNER'; + } + return $join; + } + function join_location($join = array()) { $extra = array(); if (isset($join->extra)) { @@ -141,6 +149,7 @@ class civicrm_handler_relationship_location extends views_handler_relationship { function get_join() { $join = parent::get_join(); + $join = $this->join_required($join); $join = $this->join_location($join); return $join; } From d63a3472b4bb03790b9144475722fdd6da97db05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Thu, 8 Dec 2016 15:00:44 +0100 Subject: [PATCH 55/74] CRM-19760 : allow multiple relationships of the same element --- .../civicrm_handler_relationship_address.inc | 66 ++++---- .../civicrm_handler_relationship_im.inc | 75 ++++------ .../civicrm_handler_relationship_location.inc | 141 ++++++++---------- .../civicrm_handler_relationship_mail.inc | 63 ++++---- .../civicrm_handler_relationship_phone.inc | 89 +++++------ .../civicrm_handler_relationship_website.inc | 75 ++++------ 6 files changed, 215 insertions(+), 294 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_relationship_address.inc b/modules/views/civicrm/civicrm_handler_relationship_address.inc index f370b08..aed784f 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_address.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_address.inc @@ -1,33 +1,33 @@ 'checkbox', @@ -74,26 +74,12 @@ class civicrm_handler_relationship_address extends civicrm_handler_relationship_ } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->alias = $this->ensure_my_table(); - + $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] = array( diff --git a/modules/views/civicrm/civicrm_handler_relationship_im.inc b/modules/views/civicrm/civicrm_handler_relationship_im.inc index 3f92149..ac0a438 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_im.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_im.inc @@ -1,33 +1,33 @@ 'radios', - '#title' => 'Instant Messaging provider for this relationship', - '#options' => $imOptions, - '#description' => t('Instant Messaging provider to be used for this relationship'), - '#default_value' => $this->options['provider'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Instant Messaging provider for this relationship', + '#options' => $imOptions, + '#description' => t('Instant Messaging provider to be used for this relationship'), + '#default_value' => $this->options['provider'], + '#fieldset' => 'location_choices', ); } @@ -88,25 +88,12 @@ class civicrm_handler_relationship_im extends civicrm_handler_relationship_locat return $join; } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->alias = $this->ensure_my_table(); + $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] = array( diff --git a/modules/views/civicrm/civicrm_handler_relationship_location.inc b/modules/views/civicrm/civicrm_handler_relationship_location.inc index 2a2ac76..c72506b 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_location.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_location.inc @@ -1,33 +1,33 @@ definition['title']; $form['label'] = array( - '#type' => 'textfield', - '#title' => t('Label'), - '#default_value' => $label, - '#dependency' => array( - 'edit-options-custom-label' => array(1), - ), - '#weight' => -102, + '#type' => 'textfield', + '#title' => t('Label'), + '#default_value' => $label, + '#dependency' => array( + 'edit-options-custom-label' => array(1), + ), + '#weight' => -102, ); $form['location_choices'] = array( - '#type' => 'fieldset', - '#title' => t('CiviCRM Location Relationship Options'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#description' => 'Note: it is possible to choose relationship options that result in no rows being displayed', - '#weight' => 1, + '#type' => 'fieldset', + '#title' => t('CiviCRM Location Relationship Options'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => 'Note: it is possible to choose relationship options that result in no rows being displayed', + '#weight' => 1, ); $form['location_op'] = array( - '#type' => 'select', - '#title' => 'And/Or', - '#options' => self::$_locationOps, - '#description' => t('Relationship option are joined by And/Or?'), - '#default_value' => $this->options['location_op'], - '#fieldset' => 'location_choices', + '#type' => 'select', + '#title' => 'And/Or', + '#options' => self::$_locationOps, + '#description' => t('Relationship option are joined by And/Or?'), + '#default_value' => $this->options['location_op'], + '#fieldset' => 'location_choices', ); $form['location_type'] = array( - '#type' => 'radios', - '#title' => 'Location type for this relationship', - '#options' => $locationOptions, - '#description' => t('Location type to be used for this relationship'), - '#default_value' => $this->options['location_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Location type for this relationship', + '#options' => $locationOptions, + '#description' => t('Location type to be used for this relationship'), + '#default_value' => $this->options['location_type'], + '#fieldset' => 'location_choices', ); $form['is_primary'] = array( - '#type' => 'checkbox', - '#title' => 'Use only Primary record?', - '#options' => array(0 => 'No', 1 => 'Yes'), - '#description' => t('Check above box if you want only the Primary record used in this relationship.'), - '#default_value' => $this->options['is_primary'], - '#fieldset' => 'location_choices', + '#type' => 'checkbox', + '#title' => 'Use only Primary record?', + '#options' => array(0 => 'No', 1 => 'Yes'), + '#description' => t('Check above box if you want only the Primary record used in this relationship.'), + '#default_value' => $this->options['is_primary'], + '#fieldset' => 'location_choices', ); } @@ -109,18 +109,18 @@ class civicrm_handler_relationship_location extends views_handler_relationship { $extra = array(); if (!empty($this->options['location_type'])) { $extra[] = array( - 'value' => $this->options['location_type'], - 'numeric' => TRUE, - 'field' => 'location_type_id', - 'operator' => '=', + 'value' => $this->options['location_type'], + 'numeric' => TRUE, + 'field' => 'location_type_id', + 'operator' => '=', ); } if (!empty($this->options['is_primary'])) { $extra[] = array( - 'value' => $this->options['is_primary'], - 'numeric' => TRUE, - 'field' => 'is_primary', - 'operator' => '=', + 'value' => $this->options['is_primary'], + 'numeric' => TRUE, + 'field' => 'is_primary', + 'operator' => '=', ); } return $extra; @@ -154,25 +154,12 @@ class civicrm_handler_relationship_location extends views_handler_relationship { return $join; } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->ensure_my_table(); + $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->alias = $this->table_alias; diff --git a/modules/views/civicrm/civicrm_handler_relationship_mail.inc b/modules/views/civicrm/civicrm_handler_relationship_mail.inc index 30046a1..ba7341c 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_mail.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_mail.inc @@ -1,54 +1,41 @@ table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->alias = $this->ensure_my_table(); + $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] = array( diff --git a/modules/views/civicrm/civicrm_handler_relationship_phone.inc b/modules/views/civicrm/civicrm_handler_relationship_phone.inc index 6c56413..699f58d 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_phone.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_phone.inc @@ -1,33 +1,33 @@ 'radios', - '#title' => 'Phone type for this relationship', - '#options' => $phoneOptions, - '#description' => t('Phone type to be used for this relationship'), - '#default_value' => $this->options['phone_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Phone type for this relationship', + '#options' => $phoneOptions, + '#description' => t('Phone type to be used for this relationship'), + '#default_value' => $this->options['phone_type'], + '#fieldset' => 'location_choices', ); } @@ -71,10 +71,10 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo } if (isset($this->options['phone_type']) && $this->options['phone_type']) { $extra[] = array( - 'value' => $this->options['phone_type'], - 'numeric' => TRUE, - 'field' => 'phone_type_id', - 'operator' => '=', + 'value' => $this->options['phone_type'], + 'numeric' => TRUE, + 'field' => 'phone_type_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -89,31 +89,18 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo return $join; } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->alias = $this->ensure_my_table(); + $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] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + '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 00489e2..8542953 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_website.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_website.inc @@ -1,33 +1,33 @@ 'radios', - '#title' => 'Website type for this relationship', - '#options' => $websiteOptions, - '#description' => t('Website type to be used for this relationship'), - '#default_value' => $this->options['website_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Website type for this relationship', + '#options' => $websiteOptions, + '#description' => t('Website type to be used for this relationship'), + '#default_value' => $this->options['website_type'], + '#fieldset' => 'location_choices', ); } @@ -88,25 +88,12 @@ class civicrm_handler_relationship_website extends civicrm_handler_relationship_ return $join; } - function ensure_my_table() { - if (!isset($this->table_alias)) { - if (!method_exists($this->query, 'ensure_table')) { - vpr(t('Ensure my table called but query has no ensure_table method.')); - return; - } - $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); - } - return $this->table_alias; - } - /** * Called to implement a relationship in a query. */ function query() { - // Just ensure the one table. This is briefer than parent::query(), which - // attempts to create an additional join. - $this->alias = $this->ensure_my_table(); + $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] = array( From 27e6f7d7cfd9d6c8ef5a6a7830bbce8619ed66f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A9ronique=20Gratioulet?= Date: Fri, 9 Dec 2016 19:07:10 +0100 Subject: [PATCH 56/74] CRM-19740 Regression in phone number Drupal views integration now able again to select different phone numbers without having to specify a relationship same issue for address, location, im and website it is a workaround a views issue //https://www.drupal.org/node/2617032 --- .../civicrm/civicrm_handler_field_address.inc | 14 +- .../civicrm/civicrm_handler_field_im.inc | 16 ++- .../civicrm_handler_field_location.inc | 8 +- .../civicrm/civicrm_handler_field_phone.inc | 14 +- .../civicrm/civicrm_handler_field_website.inc | 14 +- .../civicrm_handler_relationship_address.inc | 66 +++++----- .../civicrm_handler_relationship_im.inc | 72 +++++----- .../civicrm_handler_relationship_location.inc | 124 +++++++++--------- .../civicrm_handler_relationship_mail.inc | 52 ++++---- .../civicrm_handler_relationship_phone.inc | 66 +++++----- .../civicrm_handler_relationship_website.inc | 72 +++++----- 11 files changed, 269 insertions(+), 249 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_address.inc b/modules/views/civicrm/civicrm_handler_field_address.inc index 9983a07..8151740 100644 --- a/modules/views/civicrm/civicrm_handler_field_address.inc +++ b/modules/views/civicrm/civicrm_handler_field_address.inc @@ -55,10 +55,10 @@ class civicrm_handler_field_address extends civicrm_handler_field_location { } if (isset($this->options['is_billing']) && $this->options['is_billing']) { $extra[] = array( - 'value' => $this->options['is_billing'], - 'numeric' => TRUE, - 'field' => 'is_billing', - 'operator' => '=', + 'value' => $this->options['is_billing'], + 'numeric' => TRUE, + 'field' => 'is_billing', + 'operator' => '=', ); } if (!empty($extra)) { @@ -80,7 +80,11 @@ class civicrm_handler_field_address extends civicrm_handler_field_location { exit; } $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + if (empty($this->relationship)) { //https://www.drupal.org/node/2617032 + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } else { + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_im.inc b/modules/views/civicrm/civicrm_handler_field_im.inc index c8e9aa6..64fca06 100644 --- a/modules/views/civicrm/civicrm_handler_field_im.inc +++ b/modules/views/civicrm/civicrm_handler_field_im.inc @@ -1,7 +1,7 @@ options['provider']) && $this->options['provider']) { $extra[] = array( - 'value' => $this->options['provider'], - 'numeric' => TRUE, - 'field' => 'provider_id', - 'operator' => '=', + 'value' => $this->options['provider'], + 'numeric' => TRUE, + 'field' => 'provider_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -95,7 +95,11 @@ class civicrm_handler_field_im extends civicrm_handler_field_location { exit; } $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + if (empty($this->relationship)) { //https://www.drupal.org/node/2617032 + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } else { + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_location.inc b/modules/views/civicrm/civicrm_handler_field_location.inc index cb6abd3..e497c42 100644 --- a/modules/views/civicrm/civicrm_handler_field_location.inc +++ b/modules/views/civicrm/civicrm_handler_field_location.inc @@ -66,7 +66,7 @@ class civicrm_handler_field_location extends civicrm_handler_field { '#title' => t('Label'), '#default_value' => $label, '#dependency' => array( - 'edit-options-custom-label' => array(1), + 'edit-options-custom-label' => array(1), ), '#weight' => -102, ); @@ -111,7 +111,11 @@ class civicrm_handler_field_location extends civicrm_handler_field { exit; } $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + if (empty($this->relationship)) { //https://www.drupal.org/node/2617032 + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } else { + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_phone.inc b/modules/views/civicrm/civicrm_handler_field_phone.inc index 64b1572..22aeb13 100644 --- a/modules/views/civicrm/civicrm_handler_field_phone.inc +++ b/modules/views/civicrm/civicrm_handler_field_phone.inc @@ -70,10 +70,10 @@ class civicrm_handler_field_phone extends civicrm_handler_field_location { } if (isset($this->options['phone_type']) && $this->options['phone_type']) { $extra[] = array( - 'value' => $this->options['phone_type'], - 'numeric' => TRUE, - 'field' => 'phone_type_id', - 'operator' => '=', + 'value' => $this->options['phone_type'], + 'numeric' => TRUE, + 'field' => 'phone_type_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -95,7 +95,11 @@ class civicrm_handler_field_phone extends civicrm_handler_field_location { exit; } $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + if (empty($this->relationship)) { //https://www.drupal.org/node/2617032 + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } else { + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_field_website.inc b/modules/views/civicrm/civicrm_handler_field_website.inc index 7d8a83e..3950ed2 100644 --- a/modules/views/civicrm/civicrm_handler_field_website.inc +++ b/modules/views/civicrm/civicrm_handler_field_website.inc @@ -70,10 +70,10 @@ class civicrm_handler_field_website extends civicrm_handler_field_location { } if (isset($this->options['website_type']) && $this->options['website_type']) { $extra[] = array( - 'value' => $this->options['website_type'], - 'numeric' => TRUE, - 'field' => 'website_type_id', - 'operator' => '=', + 'value' => $this->options['website_type'], + 'numeric' => TRUE, + 'field' => 'website_type_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -95,7 +95,11 @@ class civicrm_handler_field_website extends civicrm_handler_field_location { exit; } $join = $this->get_join(); - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + if (empty($this->relationship)) { //https://www.drupal.org/node/2617032 + $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join); + } else { + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); + } } return $this->table_alias; } diff --git a/modules/views/civicrm/civicrm_handler_relationship_address.inc b/modules/views/civicrm/civicrm_handler_relationship_address.inc index aed784f..b2e280b 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_address.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_address.inc @@ -1,26 +1,26 @@ 'checkbox', - '#title' => 'Use only Billing Address record?', - '#options' => array(0 => 'No', 1 => 'Yes'), - '#description' => t('Check above box if you want only the Billing Address record used in this relationship.'), - '#default_value' => $this->options['is_billing'], - '#fieldset' => 'location_choices', + '#type' => 'checkbox', + '#title' => 'Use only Billing Address record?', + '#options' => array(0 => 'No', 1 => 'Yes'), + '#description' => t('Check above box if you want only the Billing Address record used in this relationship.'), + '#default_value' => $this->options['is_billing'], + '#fieldset' => 'location_choices', ); } @@ -55,10 +55,10 @@ class civicrm_handler_relationship_address extends civicrm_handler_relationship_ } if (isset($this->options['is_billing']) && $this->options['is_billing']) { $extra[] = array( - 'value' => $this->options['is_billing'], - 'numeric' => TRUE, - 'field' => 'is_billing', - 'operator' => '=', + 'value' => $this->options['is_billing'], + 'numeric' => TRUE, + 'field' => 'is_billing', + 'operator' => '=', ); } if (!empty($extra)) { @@ -83,9 +83,9 @@ class civicrm_handler_relationship_address extends civicrm_handler_relationship_ //register relationship $this->view->relationship[$this->options['id']]->alias = $this->alias; $this->query->relationships[$this->alias] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + '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 ac0a438..f53f082 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_im.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_im.inc @@ -1,33 +1,33 @@ 'radios', - '#title' => 'Instant Messaging provider for this relationship', - '#options' => $imOptions, - '#description' => t('Instant Messaging provider to be used for this relationship'), - '#default_value' => $this->options['provider'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Instant Messaging provider for this relationship', + '#options' => $imOptions, + '#description' => t('Instant Messaging provider to be used for this relationship'), + '#default_value' => $this->options['provider'], + '#fieldset' => 'location_choices', ); } @@ -70,10 +70,10 @@ class civicrm_handler_relationship_im extends civicrm_handler_relationship_locat } if (isset($this->options['provider']) && $this->options['provider']) { $extra[] = array( - 'value' => $this->options['provider'], - 'numeric' => TRUE, - 'field' => 'provider_id', - 'operator' => '=', + 'value' => $this->options['provider'], + 'numeric' => TRUE, + 'field' => 'provider_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -97,9 +97,9 @@ class civicrm_handler_relationship_im extends civicrm_handler_relationship_locat //register relationship $this->view->relationship[$this->options['id']]->alias = $this->alias; $this->query->relationships[$this->alias] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, ); } } diff --git a/modules/views/civicrm/civicrm_handler_relationship_location.inc b/modules/views/civicrm/civicrm_handler_relationship_location.inc index c72506b..ae452bc 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_location.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_location.inc @@ -1,33 +1,33 @@ definition['title']; $form['label'] = array( - '#type' => 'textfield', - '#title' => t('Label'), - '#default_value' => $label, - '#dependency' => array( - 'edit-options-custom-label' => array(1), - ), - '#weight' => -102, + '#type' => 'textfield', + '#title' => t('Label'), + '#default_value' => $label, + '#dependency' => array( + 'edit-options-custom-label' => array(1), + ), + '#weight' => -102, ); $form['location_choices'] = array( - '#type' => 'fieldset', - '#title' => t('CiviCRM Location Relationship Options'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#description' => 'Note: it is possible to choose relationship options that result in no rows being displayed', - '#weight' => 1, + '#type' => 'fieldset', + '#title' => t('CiviCRM Location Relationship Options'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => 'Note: it is possible to choose relationship options that result in no rows being displayed', + '#weight' => 1, ); $form['location_op'] = array( - '#type' => 'select', - '#title' => 'And/Or', - '#options' => self::$_locationOps, - '#description' => t('Relationship option are joined by And/Or?'), - '#default_value' => $this->options['location_op'], - '#fieldset' => 'location_choices', + '#type' => 'select', + '#title' => 'And/Or', + '#options' => self::$_locationOps, + '#description' => t('Relationship option are joined by And/Or?'), + '#default_value' => $this->options['location_op'], + '#fieldset' => 'location_choices', ); $form['location_type'] = array( - '#type' => 'radios', - '#title' => 'Location type for this relationship', - '#options' => $locationOptions, - '#description' => t('Location type to be used for this relationship'), - '#default_value' => $this->options['location_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Location type for this relationship', + '#options' => $locationOptions, + '#description' => t('Location type to be used for this relationship'), + '#default_value' => $this->options['location_type'], + '#fieldset' => 'location_choices', ); $form['is_primary'] = array( - '#type' => 'checkbox', - '#title' => 'Use only Primary record?', - '#options' => array(0 => 'No', 1 => 'Yes'), - '#description' => t('Check above box if you want only the Primary record used in this relationship.'), - '#default_value' => $this->options['is_primary'], - '#fieldset' => 'location_choices', + '#type' => 'checkbox', + '#title' => 'Use only Primary record?', + '#options' => array(0 => 'No', 1 => 'Yes'), + '#description' => t('Check above box if you want only the Primary record used in this relationship.'), + '#default_value' => $this->options['is_primary'], + '#fieldset' => 'location_choices', ); } @@ -109,18 +109,18 @@ class civicrm_handler_relationship_location extends views_handler_relationship { $extra = array(); if (!empty($this->options['location_type'])) { $extra[] = array( - 'value' => $this->options['location_type'], - 'numeric' => TRUE, - 'field' => 'location_type_id', - 'operator' => '=', + 'value' => $this->options['location_type'], + 'numeric' => TRUE, + 'field' => 'location_type_id', + 'operator' => '=', ); } if (!empty($this->options['is_primary'])) { $extra[] = array( - 'value' => $this->options['is_primary'], - 'numeric' => TRUE, - 'field' => 'is_primary', - 'operator' => '=', + 'value' => $this->options['is_primary'], + 'numeric' => TRUE, + 'field' => 'is_primary', + 'operator' => '=', ); } return $extra; diff --git a/modules/views/civicrm/civicrm_handler_relationship_mail.inc b/modules/views/civicrm/civicrm_handler_relationship_mail.inc index ba7341c..2ad12df 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_mail.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_mail.inc @@ -1,33 +1,33 @@ view->relationship[$this->options['id']]->alias = $this->alias; $this->query->relationships[$this->alias] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, ); } } diff --git a/modules/views/civicrm/civicrm_handler_relationship_phone.inc b/modules/views/civicrm/civicrm_handler_relationship_phone.inc index 699f58d..f841e28 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_phone.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_phone.inc @@ -1,26 +1,26 @@ 'radios', - '#title' => 'Phone type for this relationship', - '#options' => $phoneOptions, - '#description' => t('Phone type to be used for this relationship'), - '#default_value' => $this->options['phone_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Phone type for this relationship', + '#options' => $phoneOptions, + '#description' => t('Phone type to be used for this relationship'), + '#default_value' => $this->options['phone_type'], + '#fieldset' => 'location_choices', ); } @@ -71,10 +71,10 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo } if (isset($this->options['phone_type']) && $this->options['phone_type']) { $extra[] = array( - 'value' => $this->options['phone_type'], - 'numeric' => TRUE, - 'field' => 'phone_type_id', - 'operator' => '=', + 'value' => $this->options['phone_type'], + 'numeric' => TRUE, + 'field' => 'phone_type_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -98,9 +98,9 @@ class civicrm_handler_relationship_phone extends civicrm_handler_relationship_lo //register relationship $this->view->relationship[$this->options['id']]->alias = $this->alias; $this->query->relationships[$this->alias] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + '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 8542953..cb808d3 100644 --- a/modules/views/civicrm/civicrm_handler_relationship_website.inc +++ b/modules/views/civicrm/civicrm_handler_relationship_website.inc @@ -1,33 +1,33 @@ 'radios', - '#title' => 'Website type for this relationship', - '#options' => $websiteOptions, - '#description' => t('Website type to be used for this relationship'), - '#default_value' => $this->options['website_type'], - '#fieldset' => 'location_choices', + '#type' => 'radios', + '#title' => 'Website type for this relationship', + '#options' => $websiteOptions, + '#description' => t('Website type to be used for this relationship'), + '#default_value' => $this->options['website_type'], + '#fieldset' => 'location_choices', ); } @@ -70,10 +70,10 @@ class civicrm_handler_relationship_website extends civicrm_handler_relationship_ } if (isset($this->options['website_type']) && $this->options['website_type']) { $extra[] = array( - 'value' => $this->options['website_type'], - 'numeric' => TRUE, - 'field' => 'website_type_id', - 'operator' => '=', + 'value' => $this->options['website_type'], + 'numeric' => TRUE, + 'field' => 'website_type_id', + 'operator' => '=', ); } if (!empty($extra)) { @@ -97,9 +97,9 @@ class civicrm_handler_relationship_website extends civicrm_handler_relationship_ //register relationship $this->view->relationship[$this->options['id']]->alias = $this->alias; $this->query->relationships[$this->alias] = array( - 'link' => $this->relationship, - 'table' => $this->table, - 'base' => $this->table, + 'link' => $this->relationship, + 'table' => $this->table, + 'base' => $this->table, ); } } From b40430781786aa2102a2fa0aa289c1f55a64911d Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Thu, 22 Dec 2016 08:45:16 +0000 Subject: [PATCH 57/74] CRM-19545: Revert CRM-18776 to get back missing custom fields --- modules/views/components/civicrm.core.inc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index ebd2c31..fa0ba11 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -2931,19 +2931,13 @@ function _civicrm_core_data(&$data, $enabled) { ), ); - // Pull in all the Custom fields $query = "select id, extends, extends_entity_column_value, style from civicrm_custom_group where is_active = 1"; $dao = CRM_Core_DAO::executeQuery($query); - while ($dao->fetch()) { - // call getTree using $dao->id as groupID, $dao->extends as entityType, with possible subtypes in $dao->extends_entity_column_value - $extendsContactSubtype = (('Contact' === $dao->extends) && !empty($dao->extends_entity_column_value)); - $contactSubtypes = !$extendsContactSubtype ? NULL : array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->extends_entity_column_value)); - $contactSubtypes = empty($contactSubtypes) ? NULL : $contactSubtypes; - $data = civicrm_views_custom_data_cache($data, $dao->extends, $dao->id, $contactSubtypes); + // Call getTree using $dao->id as groupID, $dao->extends as entityType, with possible subtypes in $dao->extends_entity_column_value + $data = civicrm_views_custom_data_cache($data, $dao->extends, $dao->id, $dao->extends_entity_column_value); } } - From e17d279661eaacd5445528b2fef6a6779ecfd406 Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 9 Jan 2017 10:13:55 +0530 Subject: [PATCH 58/74] fix headers --- civicrm.install | 4 ++-- civicrm.module | 2 +- drush/civicrm.drush.inc | 14 ++++---------- .../civicrm_engage/Engage/Report/Form/CallList.php | 4 ++-- modules/civicrm_engage/Engage/Report/Form/List.php | 4 ++-- .../civicrm_engage/Engage/Report/Form/WalkList.php | 4 ++-- modules/civicrm_engage/civicrm_engage.install | 4 ++-- modules/civicrm_engage/civicrm_engage.module | 4 ++-- .../CRM/Contact/Form/Edit/Demographics.tpl | 2 +- .../CRM/Contact/Form/Inline/Demographics.tpl | 2 +- .../CRM/Contact/Page/Inline/Demographics.tpl | 2 +- modules/civicrm_og_sync/civicrm_og_sync.module | 4 ++-- .../civicrm_rules/civicrm_rules.contact-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.event-eval.inc | 4 ++-- .../civicrm_rules/civicrm_rules.mailing-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.module | 4 ++-- .../civicrm_rules.participant-eval.inc | 4 ++-- modules/civicrm_rules/civicrm_rules.rules.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_action.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_condition.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_entity.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_event.inc | 4 ++-- modules/civicrm_rules/civicrm_rules_utils.inc | 4 ++-- modules/civicrmtheme/civicrmtheme.install | 4 ++-- modules/civicrmtheme/civicrmtheme.module | 4 ++-- 25 files changed, 48 insertions(+), 54 deletions(-) diff --git a/civicrm.install b/civicrm.install index 5c54c77..b718ed6 100644 --- a/civicrm.install +++ b/civicrm.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/civicrm.module b/civicrm.module index 1176916..82f1af5 100644 --- a/civicrm.module +++ b/civicrm.module @@ -26,7 +26,7 @@ * Drupal module file. * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 */ require_once 'civicrm_user.inc'; diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 414ecd5..02e9f20 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ @@ -70,7 +70,7 @@ function civicrm_drush_command() { $items['civicrm-api'] = array( 'description' => 'CLI access to CiviCRM APIs. It can return pretty-printor json formatted data.', 'examples' => - array( + array(drush civicrm-api contact.create first_name=John last_name=Doe contact_type=Individual 'drush civicrm-api contact.create first_name=John last_name=Doe contact_type=Individual' => 'Create a new contact named John Doe', 'drush civicrm-api contact.create id=1 --out=json' => 'Find/display a contact in JSON format', ), @@ -383,13 +383,7 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); $sqlPath = "$modPath/civicrm/sql"; - - if (function_exists('mysqli_connect')) { - $dbhostParts = explode(':', $dbhost); - $conn = @mysqli_connect($dbhostParts[0], $dbuser, $dbpass, '', isset($dbhostParts[1]) ? $dbhostParts[1] : NULL); - $dbOK = ($a = @mysqli_select_db($conn, $dbname)) || ($b = @mysqli_query($conn, "CREATE DATABASE $dbname")); - } - elseif (function_exists('mysql_connect')) { +connect')) { $conn = @mysql_connect($dbhost, $dbuser, $dbpass); $dbOK = @mysql_select_db($dbname, $conn) || @mysql_query("CREATE DATABASE $dbname", $conn); } diff --git a/modules/civicrm_engage/Engage/Report/Form/CallList.php b/modules/civicrm_engage/Engage/Report/Form/CallList.php index 5826a49..dd56c84 100644 --- a/modules/civicrm_engage/Engage/Report/Form/CallList.php +++ b/modules/civicrm_engage/Engage/Report/Form/CallList.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/Engage/Report/Form/List.php b/modules/civicrm_engage/Engage/Report/Form/List.php index abb1d64..6c33ead 100644 --- a/modules/civicrm_engage/Engage/Report/Form/List.php +++ b/modules/civicrm_engage/Engage/Report/Form/List.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/Engage/Report/Form/WalkList.php b/modules/civicrm_engage/Engage/Report/Form/WalkList.php index c6b5944..d237f77 100644 --- a/modules/civicrm_engage/Engage/Report/Form/WalkList.php +++ b/modules/civicrm_engage/Engage/Report/Form/WalkList.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * @copyright DharmaTech (c) 2009 * $Id$ * diff --git a/modules/civicrm_engage/civicrm_engage.install b/modules/civicrm_engage/civicrm_engage.install index ab8643c..c4144dd 100644 --- a/modules/civicrm_engage/civicrm_engage.install +++ b/modules/civicrm_engage/civicrm_engage.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_engage/civicrm_engage.module b/modules/civicrm_engage/civicrm_engage.module index 1977231..5dff3a4 100644 --- a/modules/civicrm_engage/civicrm_engage.module +++ b/modules/civicrm_engage/civicrm_engage.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl index 380c504..ab14a0d 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Form/Edit/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl index f05b645..cc3110a 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Form/Inline/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl index 4d8a6a5..e631cd4 100644 --- a/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl +++ b/modules/civicrm_engage/templates/CRM/Contact/Page/Inline/Demographics.tpl @@ -2,7 +2,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | diff --git a/modules/civicrm_og_sync/civicrm_og_sync.module b/modules/civicrm_og_sync/civicrm_og_sync.module index 0de6bef..9b1abcb 100644 --- a/modules/civicrm_og_sync/civicrm_og_sync.module +++ b/modules/civicrm_og_sync/civicrm_og_sync.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.contact-eval.inc b/modules/civicrm_rules/civicrm_rules.contact-eval.inc index ecfe2c3..1281518 100644 --- a/modules/civicrm_rules/civicrm_rules.contact-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.contact-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.event-eval.inc b/modules/civicrm_rules/civicrm_rules.event-eval.inc index 598768d..6ed5e9b 100644 --- a/modules/civicrm_rules/civicrm_rules.event-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.event-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.mailing-eval.inc b/modules/civicrm_rules/civicrm_rules.mailing-eval.inc index a98e655..9043b67 100644 --- a/modules/civicrm_rules/civicrm_rules.mailing-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.mailing-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.module b/modules/civicrm_rules/civicrm_rules.module index a44fb3a..cf3d09f 100644 --- a/modules/civicrm_rules/civicrm_rules.module +++ b/modules/civicrm_rules/civicrm_rules.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.participant-eval.inc b/modules/civicrm_rules/civicrm_rules.participant-eval.inc index 88004a1..abe6ea0 100644 --- a/modules/civicrm_rules/civicrm_rules.participant-eval.inc +++ b/modules/civicrm_rules/civicrm_rules.participant-eval.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules.rules.inc b/modules/civicrm_rules/civicrm_rules.rules.inc index 0c5cdc7..1e3e31e 100644 --- a/modules/civicrm_rules/civicrm_rules.rules.inc +++ b/modules/civicrm_rules/civicrm_rules.rules.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_action.inc b/modules/civicrm_rules/civicrm_rules_action.inc index 10cf9f1..05bea5a 100644 --- a/modules/civicrm_rules/civicrm_rules_action.inc +++ b/modules/civicrm_rules/civicrm_rules_action.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_condition.inc b/modules/civicrm_rules/civicrm_rules_condition.inc index e5cafd8..3e44e65 100644 --- a/modules/civicrm_rules/civicrm_rules_condition.inc +++ b/modules/civicrm_rules/civicrm_rules_condition.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_entity.inc b/modules/civicrm_rules/civicrm_rules_entity.inc index 8b63cab..91cba2c 100644 --- a/modules/civicrm_rules/civicrm_rules_entity.inc +++ b/modules/civicrm_rules/civicrm_rules_entity.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_event.inc b/modules/civicrm_rules/civicrm_rules_event.inc index 10a0860..8b27127 100644 --- a/modules/civicrm_rules/civicrm_rules_event.inc +++ b/modules/civicrm_rules/civicrm_rules_event.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrm_rules/civicrm_rules_utils.inc b/modules/civicrm_rules/civicrm_rules_utils.inc index 1c08fef..e5c1973 100644 --- a/modules/civicrm_rules/civicrm_rules_utils.inc +++ b/modules/civicrm_rules/civicrm_rules_utils.inc @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrmtheme/civicrmtheme.install b/modules/civicrmtheme/civicrmtheme.install index 6acdd74..fdb3235 100644 --- a/modules/civicrmtheme/civicrmtheme.install +++ b/modules/civicrmtheme/civicrmtheme.install @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ diff --git a/modules/civicrmtheme/civicrmtheme.module b/modules/civicrmtheme/civicrmtheme.module index 33465fd..1c0e386 100644 --- a/modules/civicrmtheme/civicrmtheme.module +++ b/modules/civicrmtheme/civicrmtheme.module @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 * $Id$ * */ From 8975372bdef09d9d1ffe5c2b6c454e57650b55dc Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 9 Jan 2017 14:17:39 +0530 Subject: [PATCH 59/74] fix --- drush/civicrm.drush.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drush/civicrm.drush.inc b/drush/civicrm.drush.inc index 02e9f20..c9a73ca 100644 --- a/drush/civicrm.drush.inc +++ b/drush/civicrm.drush.inc @@ -70,7 +70,7 @@ function civicrm_drush_command() { $items['civicrm-api'] = array( 'description' => 'CLI access to CiviCRM APIs. It can return pretty-printor json formatted data.', 'examples' => - array(drush civicrm-api contact.create first_name=John last_name=Doe contact_type=Individual + array( 'drush civicrm-api contact.create first_name=John last_name=Doe contact_type=Individual' => 'Create a new contact named John Doe', 'drush civicrm-api contact.create id=1 --out=json' => 'Find/display a contact in JSON format', ), @@ -383,7 +383,13 @@ function _civicrm_install_db($dbuser, $dbpass, $dbhost, $dbname, $siteRoot = drush_get_context('DRUSH_DRUPAL_SITE_ROOT', FALSE); $sqlPath = "$modPath/civicrm/sql"; -connect')) { + + if (function_exists('mysqli_connect')) { + $dbhostParts = explode(':', $dbhost); + $conn = @mysqli_connect($dbhostParts[0], $dbuser, $dbpass, '', isset($dbhostParts[1]) ? $dbhostParts[1] : NULL); + $dbOK = ($a = @mysqli_select_db($conn, $dbname)) || ($b = @mysqli_query($conn, "CREATE DATABASE $dbname")); + } + elseif (function_exists('mysql_connect')) { $conn = @mysql_connect($dbhost, $dbuser, $dbpass); $dbOK = @mysql_select_db($dbname, $conn) || @mysql_query("CREATE DATABASE $dbname", $conn); } From 3869bfb4553de7ec1f880413a559fed55f67c86d Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 24 Jan 2017 11:26:52 +0530 Subject: [PATCH 60/74] CRM-19910: modify sub type filter handler --- .../civicrm_handler_filter_custom_option.inc | 31 ++++++++++++------- modules/views/components/civicrm.core.inc | 4 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_filter_custom_option.inc b/modules/views/civicrm/civicrm_handler_filter_custom_option.inc index 0d8fb9a..98a83ab 100644 --- a/modules/views/civicrm/civicrm_handler_filter_custom_option.inc +++ b/modules/views/civicrm/civicrm_handler_filter_custom_option.inc @@ -21,9 +21,10 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ - + ** - * @file Provides Views integration for custom CiviCRM custom field option groups + * @file Provides Views integration for multi valued fields like + * contact subtype and CiviCRM custom field option groups * * @author Matt Chapman */ @@ -37,14 +38,20 @@ class civicrm_handler_filter_custom_option extends views_handler_filter_in_opera function get_value_options() { if (!isset($this->value_options)) { - // extract the field id from the name - if (preg_match('/_(\d+)$/', $this->real_field, $match)) { - require_once 'CRM/Core/BAO/CustomOption.php'; - $options = CRM_Core_BAO_CustomOption::getCustomOption($match[1]); + if ($this->real_field == 'contact_sub_type') { + require_once 'CRM/Contact/BAO/ContactType.php'; + $this->value_options = CRM_Contact_BAO_ContactType::subTypePairs(); } - if (is_array($options)) { - foreach ($options as $id => $opt) { - $this->value_options[$opt['value']] = strip_tags($opt['label']); + else { + // extract the field id from the name + if (preg_match('/_(\d+)$/', $this->real_field, $match)) { + require_once 'CRM/Core/BAO/CustomOption.php'; + $options = CRM_Core_BAO_CustomOption::getCustomOption($match[1]); + } + if (is_array($options)) { + foreach ($options as $id => $opt) { + $this->value_options[$opt['value']] = strip_tags($opt['label']); + } } } } @@ -58,9 +65,9 @@ class civicrm_handler_filter_custom_option extends views_handler_filter_in_opera 'short' => t('all'), 'method' => 'op_simple', 'values' => 1, - ), - ); - + ), + ); + return $operators; } diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index ebd2c31..6cedafd 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -609,9 +609,7 @@ function _civicrm_core_data(&$data, $enabled) { 'pseudo method' => 'subTypePairs', ), 'filter' => array( - 'handler' => 'civicrm_handler_filter_pseudo_constant', - 'pseudo class' => 'CRM_Contact_BAO_ContactType', - 'pseudo method' => 'subTypePairs', + 'handler' => 'civicrm_handler_filter_custom_option', ), 'sort' => array( 'handler' => 'views_handler_sort', From ea90be2b430dcbc1d43548b94f2868c0562f8beb Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 27 Feb 2017 08:35:07 +0530 Subject: [PATCH 61/74] CRM-20186 - Expose legal name in views --- modules/views/components/civicrm.core.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index feb27a0..03c63fb 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -218,6 +218,26 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //LEGAL Name for the Contact + $data['civicrm_contact']['legal_name'] = array( + 'title' => t('Legal Name'), + 'help' => t('Legal Name of the Contact'), + 'field' => array( + 'handler' => 'civicrm_handler_field_contact_link', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + //Gender $data['civicrm_contact']['gender'] = array( 'title' => t('Gender'), From 87f944be3f9e3d51fc59bb3f357ddfcd2b23e161 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 7 Mar 2017 10:10:09 +0530 Subject: [PATCH 62/74] CRM-20205 - Expose current employer id to views --- modules/views/components/civicrm.core.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index 03c63fb..83d2d54 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -198,6 +198,26 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + //Current Employer ID + $data['civicrm_contact']['employer_id'] = array( + 'title' => t('Current Employer Id'), + 'help' => t('Current Employer Id'), + 'field' => array( + 'handler' => 'civicrm_handler_field_contact_link', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + //DISPLAY Name for the Contact (Full Name with Prefixes and Suffixes) $data['civicrm_contact']['display_name'] = array( 'title' => t('Display Name'), From 79b60a45a088b3510e31e01d2963d05bc6397ef3 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 22 Mar 2017 11:50:15 +0530 Subject: [PATCH 63/74] CRM-20319 - Expose relationship permission to views --- modules/views/components/civicrm.core.inc | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index 03c63fb..b41c593 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -2555,6 +2555,44 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + $data['civicrm_relationship']['is_permission_a_b'] = array( + 'title' => t('Contact A has Permission Over Contact B?'), + 'help' => t('Contact A has Permission Over Contact B?'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + $data['civicrm_relationship']['is_permission_b_a'] = array( + 'title' => t('Contact B has Permission Over Contact A?'), + 'help' => t('Contact B has Permission Over Contact A?'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + //Relationship start date $data['civicrm_relationship']['start_date'] = array( 'title' => t('Start Date'), From 09e8734f19cf58acf530dfb6dead8a4445b73593 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 22 Mar 2017 12:42:22 +0530 Subject: [PATCH 64/74] minor fix --- modules/views/components/civicrm.core.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index b41c593..73a653c 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -2555,7 +2555,7 @@ function _civicrm_core_data(&$data, $enabled) { ), ); - $data['civicrm_relationship']['is_permission_a_b'] = array( + $data['civicrm_relationship']['is_permission_a_b'] = array( 'title' => t('Contact A has Permission Over Contact B?'), 'help' => t('Contact A has Permission Over Contact B?'), 'field' => array( @@ -2574,7 +2574,7 @@ function _civicrm_core_data(&$data, $enabled) { ), ); - $data['civicrm_relationship']['is_permission_b_a'] = array( + $data['civicrm_relationship']['is_permission_b_a'] = array( 'title' => t('Contact B has Permission Over Contact A?'), 'help' => t('Contact B has Permission Over Contact A?'), 'field' => array( From 8b5f67278658acc3d70d8afe85c75991db929bb3 Mon Sep 17 00:00:00 2001 From: Torrance Date: Tue, 18 Apr 2017 14:15:09 +1200 Subject: [PATCH 65/74] Silence warnings arising from missing "current field" definitions. --- modules/views/civicrm/civicrm_handler_field_money.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/views/civicrm/civicrm_handler_field_money.inc b/modules/views/civicrm/civicrm_handler_field_money.inc index 32dbb8a..34d18f6 100644 --- a/modules/views/civicrm/civicrm_handler_field_money.inc +++ b/modules/views/civicrm/civicrm_handler_field_money.inc @@ -36,7 +36,7 @@ class civicrm_handler_field_money extends views_handler_field { } require_once 'CRM/Utils/Money.php'; - if ($this->definition['currency field']) { + if (!empty($this->definition['currency field'])) { $this->additional_fields['currency'] = array('field' => $this->definition['currency field']); } } From 35bdd675e49b71eae7d0cd82a303af807a817a10 Mon Sep 17 00:00:00 2001 From: yashodha Date: Fri, 21 Apr 2017 16:53:57 +0530 Subject: [PATCH 66/74] CRM-20462 - Add filter for current employer in views --- modules/views/components/civicrm.core.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index 73a653c..41eb615 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -591,6 +591,10 @@ function _civicrm_core_data(&$data, $enabled) { 'sort' => array( 'handler' => 'views_handler_sort', ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + 'allow empty' => TRUE, + ), 'argument' => array( 'handler' => 'views_handler_argument_string', ), From 05d79177073d86c8b7dea8ddc1edb8ea0b5abdcd Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 29 Apr 2017 12:45:38 +1000 Subject: [PATCH 67/74] Do not get custom group tree into cache if we are upgrading --- modules/views/civicrm.views.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index 549d014..90581d5 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -304,6 +304,9 @@ function civicrm_views_add_date_arguments(&$data, $value) { * Array with the new custom field appended */ function civicrm_views_custom_data_cache(&$data, $entity_type, $group_id, $sub_type) { + if (!CRM_Core_Config::isUpgradeMode()) { + return; + } // From http://forum.civicrm.org/index.php/topic,17658.msg73901.html#msg73901, CRM-7860. $tree = CRM_Core_BAO_CustomGroup::getTree($entity_type, CRM_Core_DAO::$_nullObject, NULL, $group_id, $sub_type, NULL); From 1d3ac6fd1ac95780ebf4cf1c16d7a18ba8f0c24f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 30 Apr 2017 11:43:25 +1000 Subject: [PATCH 68/74] Only return if we are in upgrade mode --- modules/views/civicrm.views.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index 90581d5..2e5e1f6 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -304,7 +304,7 @@ function civicrm_views_add_date_arguments(&$data, $value) { * Array with the new custom field appended */ function civicrm_views_custom_data_cache(&$data, $entity_type, $group_id, $sub_type) { - if (!CRM_Core_Config::isUpgradeMode()) { + if (CRM_Core_Config::isUpgradeMode()) { return; } // From http://forum.civicrm.org/index.php/topic,17658.msg73901.html#msg73901, CRM-7860. From 4f7a04b279025240ed8a6523aec30ec37ad2b9d6 Mon Sep 17 00:00:00 2001 From: Dave Jenkins Date: Fri, 26 May 2017 17:28:05 +0100 Subject: [PATCH 69/74] Improve Views checkbox value handling --- modules/views/civicrm/civicrm_handler_filter_custom_option.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/views/civicrm/civicrm_handler_filter_custom_option.inc b/modules/views/civicrm/civicrm_handler_filter_custom_option.inc index 98a83ab..1891229 100644 --- a/modules/views/civicrm/civicrm_handler_filter_custom_option.inc +++ b/modules/views/civicrm/civicrm_handler_filter_custom_option.inc @@ -84,7 +84,7 @@ class civicrm_handler_filter_custom_option extends views_handler_filter_in_opera $op = ($this->operator == 'in' || $this->operator == 'all') ? 'LIKE' : 'NOT LIKE'; $glue = ($this->operator == 'in') ? 'OR ' : 'AND '; foreach ($this->value as $value) { - $clauses[] = "$this->table_alias.$this->real_field " . $op . " '%" . $sep . $value . $sep . "%' "; + $clauses[] = "$this->table_alias.$this->real_field " . $op . " '%" . $sep . CRM_Core_DAO::escapeString($value) . $sep . "%' "; } $clause = implode($glue, $clauses); $this->query->add_where_expression($this->options['group'], $clause); From 8200e6c4b8e70adbe3d4de5e89ed88a74bb1c53a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 2 Jun 2017 16:23:16 -0400 Subject: [PATCH 70/74] Fix passing null object --- modules/views/civicrm.views.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index 2e5e1f6..de5fbc0 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -308,7 +308,7 @@ function civicrm_views_custom_data_cache(&$data, $entity_type, $group_id, $sub_t return; } // From http://forum.civicrm.org/index.php/topic,17658.msg73901.html#msg73901, CRM-7860. - $tree = CRM_Core_BAO_CustomGroup::getTree($entity_type, CRM_Core_DAO::$_nullObject, NULL, $group_id, $sub_type, NULL); + $tree = CRM_Core_BAO_CustomGroup::getTree($entity_type, NULL, NULL, $group_id, $sub_type, NULL); $join_table = civicrm_views_get_join_table($entity_type); foreach ($tree as $groupkey => $current_group) { From 00406a5b4ea12535c4cd28646128a2d61a193c92 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Tue, 20 Jun 2017 14:39:00 -0500 Subject: [PATCH 71/74] CRM-20751: Support Drupal aliases for event links in Views --- .../civicrm_handler_field_event_link.inc | 38 +++++++---------- .../civicrm_handler_field_link_event.inc | 41 +++++++------------ 2 files changed, 28 insertions(+), 51 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_event_link.inc b/modules/views/civicrm/civicrm_handler_field_event_link.inc index f9f900f..007e5de 100644 --- a/modules/views/civicrm/civicrm_handler_field_event_link.inc +++ b/modules/views/civicrm/civicrm_handler_field_event_link.inc @@ -21,7 +21,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /* * Heavily based on anonymous code contribution. No claim. @@ -93,55 +93,45 @@ class civicrm_handler_field_event_link extends views_handler_field { $custom_link = $this->options['custom_link']; } - switch ($link_choice) { // LINKING TO EVENT PAGE (PUBLICLY ACCESSIBLE) case 'page': if (user_access('view event info') && $data !== NULL && $data !== '') { - return civicrm_views_href($data, - 'civicrm/event/info', - "reset=1&id={$values->{$this->aliases['id']}}" - ); + $path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}"; + return civicrm_views_href($data, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT REGISTRATION PAGE case 'registration': if (user_access('register for events') && $data !== NULL && $data !== '') { - require_once 'CRM/Core/Config.php'; - $config = CRM_Core_Config::singleton(); - if ($enable_cart = - CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) { + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) { require_once 'CRM/Event/Cart/BAO/EventInCart.php'; //TODO don't call for every row $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($values->{$this->aliases['id']}); - return civicrm_views_href($link['label'], $link['path'], $link['query']); + $label = $link['label']; + $path = "{$link['path']}?{$link['query']}"; } else { - return civicrm_views_href($data, - 'civicrm/event/register', - "reset=1&id={$values->{$this->aliases['id']}}" - ); + $label = $data; + $path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}"; } + return civicrm_views_href($label, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT CONFIG PAGE case 'config': if (user_access('access CiviEvent') && $data !== NULL && $data !== '') { - return civicrm_views_href($data, - 'civicrm/event/manage/eventInfo', - "action=update&id={$values->{$this->aliases['id']}}&reset=1" - ); + $path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1"; + return civicrm_views_href($data, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT PARTICIPANTS LIST case 'participants': if (user_access('access CiviEvent') && $data !== NULL && $data !== '') { - return civicrm_views_href($data, - 'civicrm/event/search', - "reset=1&force=1&event={$values->{$this->aliases['id']}}" - ); + $path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}"; + return civicrm_views_href($data, drupal_get_path_alias($path), NULL); } // CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT @@ -159,5 +149,5 @@ class civicrm_handler_field_event_link extends views_handler_field { function render($values) { return $this->render_link(check_plain($values->{$this->field_alias}), $values); } -} +} diff --git a/modules/views/civicrm/civicrm_handler_field_link_event.inc b/modules/views/civicrm/civicrm_handler_field_link_event.inc index e96a2fb..a26a849 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_event.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_event.inc @@ -21,7 +21,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /* * Copyright (C) 2009 James Rakich @@ -100,62 +100,49 @@ class civicrm_handler_field_link_event extends views_handler_field { $custom_link = $this->options['custom_link']; } - switch ($link_choice) { // LINKING TO EVENT INFO case 'page': if (user_access('view event info') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/info', - "id={$values->id}&reset=1" - ); + $path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT REGISTRATION case 'register': if (user_access('register for events') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/register', - "id={$values->id}&reset=1" - ); + $path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT CONFIG case 'config': if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/manage', - "action=update&id={$values->id}&reset=1" - ); + $path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT PARTICIPANT LISTING case 'listing': if (user_access('view event participants') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/participant', - "reset=1&id={$values->id}" - ); + $path = "civicrm/event/participant?reset=1&id={$values->id}"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT PARTICIPANTS case 'participants': if (user_access('edit event participants') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/search', - "reset=1&force=1&event={$values->id}" - ); + $path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT DELETION case 'delete': if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') { - return civicrm_views_href($link_text, - 'civicrm/event/manage', - "action=delete&id={$values->id}" - ); + $path = "civicrm/event/manage?action=delete&id={$values->id}"; + return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); } // CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT @@ -178,5 +165,5 @@ class civicrm_handler_field_link_event extends views_handler_field { function render($values) { return $this->render_link(NULL, $values); } -} +} From cc24159f23ed56b1a6b6c26ff52f605548095cf6 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Wed, 21 Jun 2017 16:02:16 -0500 Subject: [PATCH 72/74] Revert "CRM-20751: Support Drupal aliases for event links in Views" This reverts commit 00406a5b4ea12535c4cd28646128a2d61a193c92. --- .../civicrm_handler_field_event_link.inc | 38 ++++++++++------- .../civicrm_handler_field_link_event.inc | 41 ++++++++++++------- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/modules/views/civicrm/civicrm_handler_field_event_link.inc b/modules/views/civicrm/civicrm_handler_field_event_link.inc index 007e5de..f9f900f 100644 --- a/modules/views/civicrm/civicrm_handler_field_event_link.inc +++ b/modules/views/civicrm/civicrm_handler_field_event_link.inc @@ -21,7 +21,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ - */ +*/ /* * Heavily based on anonymous code contribution. No claim. @@ -93,45 +93,55 @@ class civicrm_handler_field_event_link extends views_handler_field { $custom_link = $this->options['custom_link']; } + switch ($link_choice) { // LINKING TO EVENT PAGE (PUBLICLY ACCESSIBLE) case 'page': if (user_access('view event info') && $data !== NULL && $data !== '') { - $path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}"; - return civicrm_views_href($data, drupal_get_path_alias($path), NULL); + return civicrm_views_href($data, + 'civicrm/event/info', + "reset=1&id={$values->{$this->aliases['id']}}" + ); } // LINKING TO EVENT REGISTRATION PAGE case 'registration': if (user_access('register for events') && $data !== NULL && $data !== '') { - if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) { + require_once 'CRM/Core/Config.php'; + $config = CRM_Core_Config::singleton(); + if ($enable_cart = + CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) { require_once 'CRM/Event/Cart/BAO/EventInCart.php'; //TODO don't call for every row $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($values->{$this->aliases['id']}); - $label = $link['label']; - $path = "{$link['path']}?{$link['query']}"; + return civicrm_views_href($link['label'], $link['path'], $link['query']); } else { - $label = $data; - $path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}"; + return civicrm_views_href($data, + 'civicrm/event/register', + "reset=1&id={$values->{$this->aliases['id']}}" + ); } - return civicrm_views_href($label, drupal_get_path_alias($path), NULL); } // LINKING TO EVENT CONFIG PAGE case 'config': if (user_access('access CiviEvent') && $data !== NULL && $data !== '') { - $path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1"; - return civicrm_views_href($data, drupal_get_path_alias($path), NULL); + return civicrm_views_href($data, + 'civicrm/event/manage/eventInfo', + "action=update&id={$values->{$this->aliases['id']}}&reset=1" + ); } // LINKING TO EVENT PARTICIPANTS LIST case 'participants': if (user_access('access CiviEvent') && $data !== NULL && $data !== '') { - $path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}"; - return civicrm_views_href($data, drupal_get_path_alias($path), NULL); + return civicrm_views_href($data, + 'civicrm/event/search', + "reset=1&force=1&event={$values->{$this->aliases['id']}}" + ); } // CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT @@ -149,5 +159,5 @@ class civicrm_handler_field_event_link extends views_handler_field { function render($values) { return $this->render_link(check_plain($values->{$this->field_alias}), $values); } - } + diff --git a/modules/views/civicrm/civicrm_handler_field_link_event.inc b/modules/views/civicrm/civicrm_handler_field_link_event.inc index a26a849..e96a2fb 100644 --- a/modules/views/civicrm/civicrm_handler_field_link_event.inc +++ b/modules/views/civicrm/civicrm_handler_field_link_event.inc @@ -21,7 +21,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ - */ +*/ /* * Copyright (C) 2009 James Rakich @@ -100,49 +100,62 @@ class civicrm_handler_field_link_event extends views_handler_field { $custom_link = $this->options['custom_link']; } + switch ($link_choice) { // LINKING TO EVENT INFO case 'page': if (user_access('view event info') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/info', + "id={$values->id}&reset=1" + ); } // LINKING TO EVENT REGISTRATION case 'register': if (user_access('register for events') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/register', + "id={$values->id}&reset=1" + ); } // LINKING TO EVENT CONFIG case 'config': if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/manage', + "action=update&id={$values->id}&reset=1" + ); } // LINKING TO EVENT PARTICIPANT LISTING case 'listing': if (user_access('view event participants') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/participant?reset=1&id={$values->id}"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/participant', + "reset=1&id={$values->id}" + ); } // LINKING TO EVENT PARTICIPANTS case 'participants': if (user_access('edit event participants') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/search', + "reset=1&force=1&event={$values->id}" + ); } // LINKING TO EVENT DELETION case 'delete': if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') { - $path = "civicrm/event/manage?action=delete&id={$values->id}"; - return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL); + return civicrm_views_href($link_text, + 'civicrm/event/manage', + "action=delete&id={$values->id}" + ); } // CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT @@ -165,5 +178,5 @@ class civicrm_handler_field_link_event extends views_handler_field { function render($values) { return $this->render_link(NULL, $values); } - } + From b7d7ee8add1261dbd74dbd9234585af4b4d5ce1d Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Wed, 21 Jun 2017 16:03:57 -0500 Subject: [PATCH 73/74] Fix CRM-20751: Add Drupal alias support for all Views links. --- modules/views/civicrm.views.inc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index de5fbc0..e8f6b41 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -142,9 +142,8 @@ function civicrm_views_data_alter(&$data) { * @return String path to CiviCRM */ function civicrm_views_href($text, $path, $query) { - civicrm_initialize(); - require_once 'CRM/Utils/System.php'; - return CRM_Utils_System::href($text, $path, $query); + $url = civicrm_views_url($path, $query); + return "$text"; } /** @@ -159,9 +158,24 @@ function civicrm_views_href($text, $path, $query) { * @return string an HTML string containing a link to the given path. */ function civicrm_views_url($path, $query, $absolute = FALSE) { - civicrm_initialize(); - require_once 'CRM/Utils/System.php'; - return CRM_Utils_System::url($path, $query, $absolute); + // Force alphabetical order of query params, for consistent support + // of Drupal aliases. This is required because $query is a string that may + // be coming to us in any order; but query parameter order matters when + // passing that query string as part of $path in url($path). Admittedly it's + // not common to passt the query string as part of $path in url($path) (you + // would normally pass it as $options['query'] in url($path, $options)), but + // doing so is required for Drupal alias support. + if (!empty($query)) { + parse_str($query, $query_data); + ksort($query_data); + $query = http_build_query($query_data); + $path .= "?{$query}"; + } + $options = array( + 'absolute' => $absolute, + ); + $url = url($path, $options); + return $url; } /** From 0da39291aca4c5dd2e0ccfcd89730a70840afdeb Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 21 Jun 2017 17:25:18 -0400 Subject: [PATCH 74/74] CRM-20751 - Handle array query data in civicrm_views_url --- modules/views/civicrm.views.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/views/civicrm.views.inc b/modules/views/civicrm.views.inc index e8f6b41..4fa0275 100644 --- a/modules/views/civicrm.views.inc +++ b/modules/views/civicrm.views.inc @@ -166,7 +166,12 @@ function civicrm_views_url($path, $query, $absolute = FALSE) { // would normally pass it as $options['query'] in url($path, $options)), but // doing so is required for Drupal alias support. if (!empty($query)) { - parse_str($query, $query_data); + if (is_array($query)) { + $query_data = $query; + } + else { + parse_str($query, $query_data); + } ksort($query_data); $query = http_build_query($query_data); $path .= "?{$query}";