From d0d9e460c41e3c99ca6ff841d7311dfeca73783a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 28 Feb 2014 22:19:36 -0500 Subject: [PATCH] CRM-13966 - Remove CRM_Contact_Form_NewContact and related functions --- CRM/Contact/BAO/Relationship.php | 30 ---- CRM/Contact/Form/NewContact.php | 84 ------------ CRM/Core/BAO/UFGroup.php | 43 ------ templates/CRM/Contact/Form/NewContact.tpl | 159 ---------------------- 4 files changed, 316 deletions(-) delete mode 100644 CRM/Contact/Form/NewContact.php delete mode 100644 templates/CRM/Contact/Form/NewContact.tpl diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 68bb10fcd8..a707f5f41d 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -1496,36 +1496,6 @@ AND cc.sort_name LIKE '%$name%'"; return $contacts; } - static function getValidContactTypeList($relType) { - // string looks like 4_a_b - $rel_parts = explode('_', $relType); - $allRelationshipType = CRM_Core_PseudoConstant::relationshipType('label'); - $contactProfiles = CRM_Core_BAO_UFGroup::getReservedProfiles('Contact', NULL); - - if ($rel_parts[1] == 'a') { - $leftType = $allRelationshipType[$rel_parts[0]]['contact_type_b']; - } - else { - $leftType = $allRelationshipType[$rel_parts[0]]['contact_type_a']; - } - - // Handle 'All Contacts' contact type for left side of relationship ($leftType is empty in this case) - // In this case all reserved profiles are available - if ($leftType == '') { - $contactTypes = $contactProfiles; - } else { - $contactTypes = array(); - foreach ($contactProfiles as $key => $value) { - $groupTypes = CRM_Core_BAO_UFGroup::profileGroups($key); - if (in_array($leftType, $groupTypes)) { - $contactTypes = array($key => $value); - } - } - } - - return $contactTypes; - } - /** * Merge relationships from otherContact to mainContact * Called during contact merge operation diff --git a/CRM/Contact/Form/NewContact.php b/CRM/Contact/Form/NewContact.php deleted file mode 100644 index 14c8edb552..0000000000 --- a/CRM/Contact/Form/NewContact.php +++ /dev/null @@ -1,84 +0,0 @@ - '200px'); - - if (!$label) { - $label = ts('Select Contact'); - } - - $selectContacts = $form->add('text', "{$prefix}contact[{$blockNo}]", $label, $attributes, $required); - - // use submitted values to set default if form submit fails dues to form rules - if ($selectContacts->getValue()) { - $form->assign("selectedContacts", $selectContacts->getValue()); - } - - $form->addElement('hidden', "{$prefix}contact_select_id[{$blockNo}]"); - - if (CRM_Core_Permission::check('edit all contacts') || CRM_Core_Permission::check('add contacts')) { - // build select for new contact - $contactProfiles = CRM_Core_BAO_UFGroup::getReservedProfiles('Contact', $extraProfiles); - $form->add('select', "{$prefix}profiles[{$blockNo}]", ts('Create New Contact'), array( - '' => ts('- create new contact -'), - ) + $contactProfiles, FALSE, array( - 'onChange' => "if (this.value) { newContact{$prefix}{$blockNo}( this.value, {$blockNo}, '{$prefix}' );}", - )); - } - - $form->assign('blockNo', $blockNo); - $form->assign('prefix', $prefix); - } -} - diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index b4cde4ed54..4da2bb6c56 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -3208,49 +3208,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } } - /** - * Function to retrieve reserved profiles - * - * @param string $name name if the reserve profile - * @param array $extraProfiles associated array of profile id's that needs to merge - * - * @return array $reservedProfiles returns associated array - * @static - */ - static function getReservedProfiles($type = 'Contact', $extraProfiles = NULL) { - $reservedProfiles = array(); - $profileNames = array(); - if ($type == 'Contact') { - if (CRM_Contact_BAO_ContactType::isActive('Individual')) { - $profileNames[] = '"new_individual"'; - } - if (CRM_Contact_BAO_ContactType::isActive('Household')) { - $profileNames[] = '"new_household"'; - } - if (CRM_Contact_BAO_ContactType::isActive('Organization')) { - $profileNames[] = '"new_organization"'; - } - } - if (!empty($profileNames)) { - $whereClause = 'name IN ( ' . implode(',', $profileNames) . ' ) AND is_reserved = 1'; - } - else { - $whereClause = 'is_reserved = 1'; - } - - $query = "SELECT id, title FROM civicrm_uf_group WHERE {$whereClause}"; - - $dao = CRM_Core_DAO::executeQuery($query); - while ($dao->fetch()) { - $key = $dao->id; - if ($extraProfiles) { - $key .= ',' . implode(',', $extraProfiles); - } - $reservedProfiles[$key] = $dao->title; - } - return $reservedProfiles; - } - /** * @param array|string $profiles - name of profile(s) to create links for * @param array $appendProfiles - name of profile(s) to append to each link diff --git a/templates/CRM/Contact/Form/NewContact.tpl b/templates/CRM/Contact/Form/NewContact.tpl deleted file mode 100644 index d8f541ce31..0000000000 --- a/templates/CRM/Contact/Form/NewContact.tpl +++ /dev/null @@ -1,159 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2013 | - +--------------------------------------------------------------------+ - | This file is a part of CiviCRM. | - | | - | CiviCRM is free software; you can copy, modify, and distribute it | - | under the terms of the GNU Affero General Public License | - | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | - | | - | CiviCRM is distributed in the hope that it will be useful, but | - | WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | - | See the GNU Affero General Public License for more details. | - | | - | You should have received a copy of the GNU Affero General Public | - | License and the CiviCRM Licensing Exception along | - | with this program; if not, contact CiviCRM LLC | - | at info[AT]civicrm[DOT]org. If you have questions about the | - | GNU Affero General Public License or the licensing of CiviCRM, | - | see the CiviCRM license FAQ at http://civicrm.org/licensing | - +--------------------------------------------------------------------+ -*} -{* template for adding form elements for selecting existing or creating new contact*} -{if !in_array($context, array('search','advanced', 'builder')) || $parent eq 'activity'} - {assign var='fldName' value=$prefix|cat:'contact'} - {assign var='profSelect' value=$prefix|cat:'profiles'} - {* Focus on select contact element unless focus=false is passed in. *} - {assign var='focus' value=$focus|default:true} - - {if $noLabel} -
- {if !$skipBreak} - {$form.$fldName.$blockNo.html}
- {if $form.$profSelect} - {ts}OR{/ts}
{$form.$profSelect.$blockNo.html}
- {/if} - {else} - {$form.$fldName.$blockNo.html} - {if $form.$profSelect and $showNewSelect} -   {ts}OR{/ts}  {$form.$profSelect.$blockNo.html}
- {/if} - {/if} -
- {else} - - {$form.$fldName.$blockNo.label} - {$form.$fldName.$blockNo.html} - {if $form.$profSelect} -   {ts}OR{/ts}  {$form.$profSelect.$blockNo.html}
- {/if} - - - {/if} - -{literal} - -{/literal} -{/if}{* end of search if *} -- 2.25.1