CRM-13966 - Remove CRM_Contact_Form_NewContact and related functions
authorColeman Watts <coleman@civicrm.org>
Sat, 1 Mar 2014 03:19:36 +0000 (22:19 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 1 Mar 2014 03:25:48 +0000 (22:25 -0500)
CRM/Contact/BAO/Relationship.php
CRM/Contact/Form/NewContact.php [deleted file]
CRM/Core/BAO/UFGroup.php
templates/CRM/Contact/Form/NewContact.tpl [deleted file]

index 68bb10fcd8ee1587c57136ab67718e93810f0af2..a707f5f41d84ea98c71bd41b15bb4e7e2f389f4f 100644 (file)
@@ -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 (file)
index 14c8edb..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | 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        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
- * $Id$
- *
- */
-
-/**
- * This class build form elements for select exitsing or create new contact widget
- */
-class CRM_Contact_Form_NewContact {
-
-  /**
-   * Function used to build form element for new contact or select contact widget
-   *
-   * @param object   $form form object
-   * @param int      $blocNo by default it is one, except for address block where it is
-   * build for each block
-   * @param array    $extrProfiles extra profiles that should be included besides reserved
-   *
-   * @access public
-   *
-   * @return void
-   */
-  static function buildQuickForm(&$form, $blockNo = 1, $extraProfiles = NULL, $required = FALSE, $prefix = '', $label = NULL) {
-    // call to build contact autocomplete
-    $attributes = array('width' => '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);
-  }
-}
-
index b4cde4ed545faf813cccf13e5b60c65dce76ccf7..4da2bb6c5616781b9e73cf84e66174251a804ad2 100644 (file)
@@ -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 (file)
index d8f541c..0000000
+++ /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}
-    <div>
-      {if !$skipBreak}
-        {$form.$fldName.$blockNo.html} <br/>
-        {if $form.$profSelect}
-          {ts}OR{/ts}<br/>{$form.$profSelect.$blockNo.html}<div id="contact-dialog-{$prefix}{$blockNo}" class="hiddenElement"></div>
-        {/if}
-      {else}
-        {$form.$fldName.$blockNo.html}
-        {if $form.$profSelect and $showNewSelect}
-          &nbsp;&nbsp;{ts}OR{/ts}&nbsp;&nbsp;{$form.$profSelect.$blockNo.html}<div id="contact-dialog-{$prefix}{$blockNo}" class="hiddenElement"></div>
-        {/if}
-      {/if}
-    </div>
-  {else}
-    <tr class="crm-new-contact-form-block-contact crm-new-contact-form-block-contact-{$blockNo}">
-      <td class="label">{$form.$fldName.$blockNo.label}</td>
-      <td>{$form.$fldName.$blockNo.html}
-        {if $form.$profSelect}
-          &nbsp;&nbsp;{ts}OR{/ts}&nbsp;&nbsp;{$form.$profSelect.$blockNo.html}<div id="contact-dialog-{$prefix}{$blockNo}" class="hiddenElement"></div>
-        {/if}
-      </td>
-    </tr>
-  {/if}
-
-{literal}
-<script type="text/javascript">
-  var allowMultiClient = Boolean({/literal}{if !empty($multiClient)}1{else}0{/if}{literal});
-
-  {/literal}
-  var prePopulateData = '';
-  {if $prePopulateData}
-      prePopulateData = {$prePopulateData};
-  {/if}
-  {literal}
-
-  var existingTokens = '';
-  cj( function( ) {
-    // add multiple client option if configured
-    if ( allowMultiClient ) {
-      addMultiClientOption{/literal}{$prefix}{$blockNo}{literal}( prePopulateData, {/literal}{$blockNo},"{$prefix}"{literal} );
-    } else {
-      addSingleClientOption{/literal}{$prefix}{$blockNo}{literal}( {/literal}{$blockNo},"{$prefix}"{literal} );
-    }
-  });
-
-  function newContact{/literal}{$prefix}{$blockNo}{literal}( gid, blockNo, prefix ) {
-    var dataURL = {/literal}"{crmURL p='civicrm/profile/create' q="reset=1&snippet=5&context=dialog&blockNo=$blockNo&prefix=$prefix" h=0 }"{literal};
-    dataURL = dataURL + '&gid=' + gid;
-    {/literal}{if $profileCreateCallback}{literal}
-    dataURL = dataURL + '&createCallback=1';
-    {/literal}{/if}{literal}
-    cj.ajax({
-      url: dataURL,
-      success: function( content ) {
-        cj( '#contact-dialog-'+ prefix + blockNo ).show( ).html( content ).dialog({
-          title: "{/literal}{ts escape='js'}Create New Contact{/ts}{literal}",
-          modal: true,
-          width: 680,
-          overlay: {
-            opacity: 0.5,
-            background: "black"
-          },
-
-          close: function(event, ui) {
-            cj('#' + prefix + 'profiles_' + blockNo).val('');
-            {/literal}
-            {if $newContactCallback}
-              eval("{$newContactCallback}");
-            {/if}
-            {literal}
-          }
-        });
-      }
-    });
-  }
-
-  function addMultiClientOption{/literal}{$prefix}{$blockNo}{literal}( prePopulateData, blockNo, prefix ) {
-    var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing contact.{/ts}{literal}";
-    var contactUrl = {/literal}"{crmURL p='civicrm/ajax/checkemail' q='id=1&noemail=1' h=0 }"{literal};
-
-    // setdefaults incase of formRule
-    {/literal}
-    {if $selectedContacts}
-      {literal}
-        var prePopulateData = cj.ajax({ url: contactUrl + "&cid={/literal}{$selectedContacts}{literal}", async: false }).responseText;
-        prePopulateData = cj.parseJSON(prePopulateData);
-      {/literal}
-    {/if}
-    {literal}
-
-    cj('#' + prefix + 'contact_' + blockNo).tokenInput( contactUrl, { prePopulate:prePopulateData, theme: 'facebook', hintText: hintText });
-    cj('ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px');
-  }
-
-  function addSingleClientOption{/literal}{$prefix}{$blockNo}{literal}( blockNo, prefix ) {
-    var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=newcontact' h=0 }"{literal};
-    {/literal}{if $action eq 2}{literal}
-    contactUrl = contactUrl + '&cid=' + {/literal}{$contactId}{literal};
-    {/literal}{/if}{literal}
-
-    var contactElement = '#' + prefix + 'contact_' + blockNo;
-    var contactHiddenElement = 'input[name="{/literal}{$prefix}{literal}contact_select_id[' + blockNo +']"]';
-    cj( contactElement ).autocomplete( contactUrl, {
-      selectFirst : false, matchContains: true, minChars: 1, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
-    }).result( function(event, data, formatted) {
-      cj( contactHiddenElement ).val(data[1]);
-      {/literal}
-      {if $newContactCallback}
-        eval("{$newContactCallback}");
-      {/if}
-      {literal}
-    }){/literal}{if $focus}.focus( ){/if}{literal};
-
-    cj( contactElement ).click( function( ) {
-      cj( contactHiddenElement ).val('');
-    });
-
-    cj( contactElement ).bind("keypress keyup", function(e) {
-      if ( e.keyCode == 13 ) {
-        return false;
-      }
-    });
-  }
-</script>
-{/literal}
-{/if}{* end of search if *}