3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Contact_BAO_ContactType
extends CRM_Contact_DAO_ContactType
{
38 * Fetch object based on array of properties
40 * @param array $params
41 * (reference ) an assoc array of name/value pairs.
42 * @param array $defaults
43 * (reference ) an assoc array to hold the flattened values.
45 * @return CRM_Contact_BAO_ContactType object on success, null otherwise
48 public static function retrieve(&$params, &$defaults) {
49 $contactType = new CRM_Contact_DAO_ContactType();
50 $contactType->copyValues($params);
51 if ($contactType->find(TRUE)) {
52 CRM_Core_DAO
::storeValues($contactType, $defaults);
63 public static function isActive($contactType) {
64 $contact = self
::contactTypeInfo(FALSE);
65 $active = array_key_exists($contactType, $contact) ?
TRUE : FALSE;
70 * Retrieve basic contact type information.
75 * of basic contact types information.
78 public static function &basicTypeInfo($all = FALSE) {
79 static $_cache = NULL;
81 if ($_cache === NULL) {
85 $argString = $all ?
'CRM_CT_BTI_1' : 'CRM_CT_BTI_0';
86 if (!array_key_exists($argString, $_cache)) {
87 $cache = CRM_Utils_Cache
::singleton();
88 $_cache[$argString] = $cache->get($argString);
89 if (!$_cache[$argString]) {
92 FROM civicrm_contact_type
93 WHERE parent_id IS NULL
96 $sql .= " AND is_active = 1";
99 $dao = CRM_Core_DAO
::executeQuery($sql,
100 CRM_Core_DAO
::$_nullArray,
102 'CRM_Contact_DAO_ContactType'
104 while ($dao->fetch()) {
106 CRM_Core_DAO
::storeValues($dao, $value);
107 $_cache[$argString][$dao->name
] = $value;
110 $cache->set($argString, $_cache[$argString]);
113 return $_cache[$argString];
117 * Retrieve all basic contact types.
122 * of basic contact types
125 public static function basicTypes($all = FALSE) {
126 return array_keys(self
::basicTypeInfo($all));
135 public static function basicTypePairs($all = FALSE, $key = 'name') {
136 $subtypes = self
::basicTypeInfo($all);
139 foreach ($subtypes as $name => $info) {
140 $index = ($key == 'name') ?
$name : $info[$key];
141 $pairs[$index] = $info['label'];
147 * Retrieve all subtypes Information.
149 * @param array $contactType
152 * @param bool $ignoreCache
156 * of sub type information
159 public static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
160 static $_cache = NULL;
162 if ($reset === TRUE) {
166 if ($_cache === NULL) {
169 if ($contactType && !is_array($contactType)) {
170 $contactType = array($contactType);
173 $argString = $all ?
'CRM_CT_STI_1_' : 'CRM_CT_STI_0_';
174 if (!empty($contactType)) {
175 $argString .= implode('_', $contactType);
178 if ((!array_key_exists($argString, $_cache)) ||
$ignoreCache) {
179 $cache = CRM_Utils_Cache
::singleton();
180 $_cache[$argString] = $cache->get($argString);
181 if (!$_cache[$argString] ||
$ignoreCache) {
182 $_cache[$argString] = array();
185 if (!empty($contactType)) {
186 $ctWHERE = " AND parent.name IN ('" . implode("','", $contactType) . "')";
190 SELECT subtype.*, parent.name as parent, parent.label as parent_label
191 FROM civicrm_contact_type subtype
192 INNER JOIN civicrm_contact_type parent ON subtype.parent_id = parent.id
193 WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE}
195 if ($all === FALSE) {
196 $sql .= " AND subtype.is_active = 1 AND parent.is_active = 1 ORDER BY parent.id";
198 $dao = CRM_Core_DAO
::executeQuery($sql, array(),
199 FALSE, 'CRM_Contact_DAO_ContactType'
201 while ($dao->fetch()) {
203 CRM_Core_DAO
::storeValues($dao, $value);
204 $value['parent'] = $dao->parent
;
205 $value['parent_label'] = $dao->parent_label
;
206 $_cache[$argString][$dao->name
] = $value;
209 $cache->set($argString, $_cache[$argString]);
212 return $_cache[$argString];
217 * retrieve all subtypes
219 * @param array $contactType
222 * @param string $columnName
223 * @param bool $ignoreCache
226 * of all subtypes OR list of subtypes associated to
227 * a given basic contact type
230 public static function subTypes($contactType = NULL, $all = FALSE, $columnName = 'name', $ignoreCache = FALSE) {
231 if ($columnName == 'name') {
232 return array_keys(self
::subTypeInfo($contactType, $all, $ignoreCache));
235 return array_values(self
::subTypePairs($contactType, FALSE, NULL, $ignoreCache));
241 * retrieve subtype pairs with name as 'subtype-name' and 'label' as value
243 * @param array $contactType
246 * @param string $labelPrefix
247 * @param bool $ignoreCache
249 * @return list of subtypes with name as 'subtype-name' and 'label' as value
252 public static function subTypePairs($contactType = NULL, $all = FALSE, $labelPrefix = '- ', $ignoreCache = FALSE) {
253 $subtypes = self
::subTypeInfo($contactType, $all, $ignoreCache);
256 foreach ($subtypes as $name => $info) {
257 $pairs[$name] = $labelPrefix . $info['label'];
264 * retrieve list of all types i.e basic + subtypes.
269 * of basic types + all subtypes.
272 public static function contactTypes($all = FALSE) {
273 return array_keys(self
::contactTypeInfo($all));
278 * retrieve info array about all types i.e basic + subtypes.
284 * of basic types + all subtypes.
287 public static function contactTypeInfo($all = FALSE, $reset = FALSE) {
288 static $_cache = NULL;
290 if ($reset === TRUE) {
294 if ($_cache === NULL) {
298 $argString = $all ?
'CRM_CT_CTI_1' : 'CRM_CT_CTI_0';
299 if (!array_key_exists($argString, $_cache)) {
300 $cache = CRM_Utils_Cache
::singleton();
301 $_cache[$argString] = $cache->get($argString);
302 if (!$_cache[$argString]) {
303 $_cache[$argString] = array();
306 SELECT type.*, parent.name as parent, parent.label as parent_label
307 FROM civicrm_contact_type type
308 LEFT JOIN civicrm_contact_type parent ON type.parent_id = parent.id
309 WHERE type.name IS NOT NULL
311 if ($all === FALSE) {
312 $sql .= " AND type.is_active = 1";
315 $dao = CRM_Core_DAO
::executeQuery($sql,
316 CRM_Core_DAO
::$_nullArray,
318 'CRM_Contact_DAO_ContactType'
320 while ($dao->fetch()) {
322 CRM_Core_DAO
::storeValues($dao, $value);
323 if (array_key_exists('parent_id', $value)) {
324 $value['parent'] = $dao->parent
;
325 $value['parent_label'] = $dao->parent_label
;
327 $_cache[$argString][$dao->name
] = $value;
330 $cache->set($argString, $_cache[$argString]);
334 return $_cache[$argString];
338 * Retrieve basic type pairs with name as 'built-in name' and 'label' as value
341 * @param null $typeName
342 * @param null $delimiter
345 * of basictypes with name as 'built-in name' and 'label' as value
348 public static function contactTypePairs($all = FALSE, $typeName = NULL, $delimiter = NULL) {
349 $types = self
::contactTypeInfo($all);
351 if ($typeName && !is_array($typeName)) {
352 $typeName = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($typeName, CRM_Core_DAO
::VALUE_SEPARATOR
));
357 foreach ($typeName as $type) {
358 if (array_key_exists($type, $types)) {
359 $pairs[$type] = $types[$type]['label'];
364 foreach ($types as $name => $info) {
365 $pairs[$name] = $info['label'];
369 return !$delimiter ?
$pairs : implode($delimiter, $pairs);
373 * Get a list of elements for select box
374 * Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
375 * which was not handled well be anything that loaded & resaved the html (outside core)
376 * The use of this separator is now explicit in the calling functions as a step towards it's removal
379 * @param bool $isSeparator
380 * @param string $separator
384 static function getSelectElements(
389 static $_cache = NULL;
391 if ($_cache === NULL) {
395 $argString = $all ?
'CRM_CT_GSE_1' : 'CRM_CT_GSE_0';
396 $argString .= $isSeparator ?
'_1' : '_0';
397 if (!array_key_exists($argString, $_cache)) {
398 $cache = CRM_Utils_Cache
::singleton();
399 $_cache[$argString] = $cache->get($argString);
401 if (!$_cache[$argString]) {
402 $_cache[$argString] = array();
405 SELECT c.name as child_name , c.label as child_label , c.id as child_id,
406 p.name as parent_name, p.label as parent_label, p.id as parent_id
407 FROM civicrm_contact_type c
408 LEFT JOIN civicrm_contact_type p ON ( c.parent_id = p.id )
409 WHERE ( c.name IS NOT NULL )
412 if ($all === FALSE) {
415 AND ( p.is_active = 1 OR p.id IS NULL )
418 $sql .= " ORDER BY c.id";
421 $dao = CRM_Core_DAO
::executeQuery($sql);
422 while ($dao->fetch()) {
423 if (!empty($dao->parent_id
)) {
424 $key = $isSeparator ?
$dao->parent_name
. $separator . $dao->child_name
: $dao->child_name
;
425 $label = "- {$dao->child_label}";
426 $pName = $dao->parent_name
;
429 $key = $dao->child_name
;
430 $label = $dao->child_label
;
431 $pName = $dao->child_name
;
434 if (!isset($values[$pName])) {
435 $values[$pName] = array();
437 $values[$pName][] = array('key' => $key, 'label' => $label);
440 $selectElements = array();
441 foreach ($values as $pName => $elements) {
442 foreach ($elements as $element) {
443 $selectElements[$element['key']] = $element['label'];
446 $_cache[$argString] = $selectElements;
448 $cache->set($argString, $_cache[$argString]);
451 return $_cache[$argString];
455 * Check if a given type is a subtype
457 * @param string $subType
459 * @param bool $ignoreCache
462 * true if subType, false otherwise.
465 public static function isaSubType($subType, $ignoreCache = FALSE) {
466 return in_array($subType, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
470 * Retrieve the basic contact type associated with given subType.
472 * @param array/string $subType contact subType.
473 * @return array/string of basicTypes.
476 public static function getBasicType($subType) {
477 static $_cache = NULL;
478 if ($_cache === NULL) {
483 if ($subType && !is_array($subType)) {
484 $subType = array($subType);
487 $argString = implode('_', $subType);
489 if (!array_key_exists($argString, $_cache)) {
490 $_cache[$argString] = array();
493 SELECT subtype.name as contact_subtype, type.name as contact_type
494 FROM civicrm_contact_type subtype
495 INNER JOIN civicrm_contact_type type ON ( subtype.parent_id = type.id )
496 WHERE subtype.name IN ('" . implode("','", $subType) . "' )";
497 $dao = CRM_Core_DAO
::executeQuery($sql);
498 while ($dao->fetch()) {
500 $_cache[$argString] = $dao->contact_type
;
503 $_cache[$argString][$dao->contact_subtype
] = $dao->contact_type
;
506 return $_cache[$argString];
510 * Suppress all subtypes present in given array.
512 * @param array $subTypes
514 * @param bool $ignoreCache
517 * of suppressed subTypes.
520 public static function suppressSubTypes(&$subTypes, $ignoreCache = FALSE) {
521 $subTypes = array_diff($subTypes, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
526 * Verify if a given subtype is associated with a given basic contact type.
528 * @param string $subType
530 * @param string $contactType
532 * @param bool $ignoreCache
533 * @param string $columnName
536 * true if contact extends, false otherwise.
539 public static function isExtendsContactType($subType, $contactType, $ignoreCache = FALSE, $columnName = 'name') {
540 if (!is_array($subType)) {
541 $subType = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($subType, CRM_Core_DAO
::VALUE_SEPARATOR
));
543 $subtypeList = self
::subTypes($contactType, TRUE, $columnName, $ignoreCache);
544 $intersection = array_intersect($subType, $subtypeList);
545 return $subType == $intersection;
549 * Create shortcuts menu for contactTypes
555 public static function getCreateNewList() {
556 $shortCuts = array();
557 //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
558 // this is loaded onto then replace with something like '__' & test
559 $separator = CRM_Core_DAO
::VALUE_SEPARATOR
;
560 $contactTypes = self
::getSelectElements(FALSE, TRUE, $separator);
561 foreach ($contactTypes as $key => $value) {
563 $typeValue = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $key);
564 $cType = CRM_Utils_Array
::value('0', $typeValue);
565 $typeUrl = 'ct=' . $cType;
566 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
567 $typeUrl .= "&cst=$csType";
570 'path' => 'civicrm/contact/add',
571 'query' => "$typeUrl&reset=1",
572 'ref' => "new-$value",
575 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
576 $shortCuts[$cType]['shortCuts'][] = $shortCut;
579 $shortCuts[$cType] = $shortCut;
587 * Delete Contact SubTypes
589 * @param int $contactTypeId
590 * ID of the Contact Subtype to be deleted.
595 public static function del($contactTypeId) {
597 if (!$contactTypeId) {
601 $params = array('id' => $contactTypeId);
602 self
::retrieve($params, $typeInfo);
603 $name = $typeInfo['name'];
604 // check if any custom group
605 $custom = new CRM_Core_DAO_CustomGroup();
606 $custom->whereAdd("extends_entity_column_value LIKE '%" .
607 CRM_Core_DAO
::VALUE_SEPARATOR
.
609 CRM_Core_DAO
::VALUE_SEPARATOR
. "%'"
611 if ($custom->find()) {
615 // remove subtype for existing contacts
617 UPDATE civicrm_contact SET contact_sub_type = NULL
618 WHERE contact_sub_type = '$name'";
619 CRM_Core_DAO
::executeQuery($sql);
621 // remove subtype from contact type table
622 $contactType = new CRM_Contact_DAO_ContactType();
623 $contactType->id
= $contactTypeId;
624 $contactType->delete();
626 // remove navigation entry if any
630 FROM civicrm_navigation
632 $params = array(1 => array("New $name", 'String'));
633 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
634 CRM_Core_BAO_Navigation
::resetNavigation();
640 * Add or update Contact SubTypes
642 * @param array $params
643 * An assoc array of name/value pairs.
648 public static function add(&$params) {
651 if (empty($params['id']) && empty($params['label'])) {
654 if (!empty($params['parent_id']) &&
655 !CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])
660 $contactType = new CRM_Contact_DAO_ContactType();
661 $contactType->copyValues($params);
662 $contactType->id
= CRM_Utils_Array
::value('id', $params);
663 $contactType->is_active
= CRM_Utils_Array
::value('is_active', $params, 0);
665 $contactType->save();
666 if ($contactType->find(TRUE)) {
667 $contactName = $contactType->name
;
668 $contact = ucfirst($contactType->label
);
669 $active = $contactType->is_active
;
672 if (!empty($params['id'])) {
673 $params = array('name' => "New $contactName");
675 'label' => "New $contact",
676 'is_active' => $active,
678 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
681 $name = self
::getBasicType($contactName);
685 $value = array('name' => "New $name");
686 CRM_Core_BAO_Navigation
::retrieve($value, $navinfo);
688 'label' => "New $contact",
689 'name' => "New $contactName",
690 'url' => "civicrm/contact/add?ct=$name&cst=$contactName&reset=1",
691 'permission' => 'add contacts',
692 'parent_id' => $navinfo['id'],
693 'is_active' => $active,
695 CRM_Core_BAO_Navigation
::add($navigation);
697 CRM_Core_BAO_Navigation
::resetNavigation();
699 // reset the cache after adding
700 self
::subTypeInfo(NULL, FALSE, FALSE, TRUE);
706 * Update the is_active flag in the db
709 * Id of the database record.
710 * @param bool $is_active
711 * Value we want to set the is_active field.
714 * DAO object on success, null otherwise
717 public static function setIsActive($id, $is_active) {
718 $params = array('id' => $id);
719 self
::retrieve($params, $contactinfo);
720 $params = array('name' => "New $contactinfo[name]");
721 $newParams = array('is_active' => $is_active);
722 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
723 CRM_Core_BAO_Navigation
::resetNavigation();
724 return CRM_Core_DAO
::setFieldValue('CRM_Contact_DAO_ContactType', $id,
725 'is_active', $is_active
730 * @param string $typeName
734 public static function getLabel($typeName) {
735 $types = self
::contactTypeInfo(TRUE);
737 if (array_key_exists($typeName, $types)) {
738 return $types[$typeName]['label'];
744 * Check whether allow to change any contact's subtype
745 * on the basis of custom data and relationship of specific subtype
746 * currently used in contact/edit form amd in import validation
748 * @param int $contactId
750 * @param string $subType
756 public static function isAllowEdit($contactId, $subType = NULL) {
762 if (empty($subType)) {
763 $subType = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Contact',
769 if (self
::hasCustomData($subType, $contactId) || self
::hasRelationships($contactId, $subType)) {
777 * @param $contactType
778 * @param int $contactId
782 public static function hasCustomData($contactType, $contactId = NULL) {
785 if (self
::isaSubType($contactType)) {
786 $subType = $contactType;
787 $contactType = self
::getBasicType($subType);
789 // check for empty custom data which extends subtype
790 $subTypeValue = CRM_Core_DAO
::VALUE_SEPARATOR
. $subType . CRM_Core_DAO
::VALUE_SEPARATOR
;
791 $subTypeClause = " AND extends_entity_column_value LIKE '%{$subTypeValue}%' ";
793 $query = "SELECT table_name FROM civicrm_custom_group WHERE extends = '{$contactType}' {$subTypeClause}";
795 $dao = CRM_Core_DAO
::executeQuery($query);
796 while ($dao->fetch()) {
797 $sql = "SELECT count(id) FROM {$dao->table_name}";
799 $sql .= " WHERE entity_id = {$contactId}";
803 $customDataCount = CRM_Core_DAO
::singleValueQuery($sql);
804 if (!empty($customDataCount)) {
813 * @todo what does this function do?
814 * @param int $contactId
815 * @param $contactType
819 public static function hasRelationships($contactId, $contactType) {
820 $subTypeClause = NULL;
821 if (self
::isaSubType($contactType)) {
822 $subType = $contactType;
823 $contactType = self
::getBasicType($subType);
824 $subTypeClause = " AND ( ( crt.contact_type_a = '{$contactType}' AND crt.contact_sub_type_a = '{$subType}') OR
825 ( crt.contact_type_b = '{$contactType}' AND crt.contact_sub_type_b = '{$subType}') ) ";
828 $subTypeClause = " AND ( crt.contact_type_a = '{$contactType}' OR crt.contact_type_b = '{$contactType}' ) ";
831 // check relationships for
832 $relationshipQuery = "
833 SELECT count(cr.id) FROM civicrm_relationship cr
834 INNER JOIN civicrm_relationship_type crt ON
835 ( cr.relationship_type_id = crt.id {$subTypeClause} )
836 WHERE ( cr.contact_id_a = {$contactId} OR cr.contact_id_b = {$contactId} )
839 $relationshipCount = CRM_Core_DAO
::singleValueQuery($relationshipQuery);
841 if (!empty($relationshipCount)) {
849 * @todo what does this function do?
850 * @param $contactType
851 * @param array $subtypeSet
855 public static function getSubtypeCustomPair($contactType, $subtypeSet = array()) {
856 if (empty($subtypeSet)) {
860 $customSet = $subTypeClause = array();
861 foreach ($subtypeSet as $subtype) {
862 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
863 $subType = CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
;
864 $subTypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%' ";
866 $query = "SELECT table_name
867 FROM civicrm_custom_group
868 WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
869 $dao = CRM_Core_DAO
::executeQuery($query, array(1 => array($contactType, 'String')));
870 while ($dao->fetch()) {
871 $customSet[] = $dao->table_name
;
873 return array_unique($customSet);
877 * Function that does something
878 * @todo what does this function do?
880 * @param int $contactID
881 * @param $contactType
882 * @param array $oldSubtypeSet
883 * @param array $newSubtypeSet
887 static function deleteCustomSetForSubtypeMigration(
890 $oldSubtypeSet = array(),
891 $newSubtypeSet = array()
893 $oldCustomSet = self
::getSubtypeCustomPair($contactType, $oldSubtypeSet);
894 $newCustomSet = self
::getSubtypeCustomPair($contactType, $newSubtypeSet);
896 $customToBeRemoved = array_diff($oldCustomSet, $newCustomSet);
897 foreach ($customToBeRemoved as $customTable) {
898 self
::deleteCustomRowsForEntityID($customTable, $contactID);
904 * Delete content / rows of a custom table specific to a subtype for a given custom-group.
905 * This function currently works for contact subtypes only and could be later improved / genralized
906 * to work for other subtypes as well.
910 * @param array $subtypes
911 * List of subtypes related to which entry is to be removed.
915 public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
916 if (!$gID or empty($subtypes)) {
920 $tableName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup', $gID, 'table_name');
922 // drop triggers CRM-13587
923 CRM_Core_DAO
::dropTriggers($tableName);
925 $subtypeClause = array();
926 foreach ($subtypes as $subtype) {
927 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
928 $subtypeClause[] = "civicrm_contact.contact_sub_type LIKE '%" . CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
. "%'";
930 $subtypeClause = implode(' OR ', $subtypeClause);
932 $query = "DELETE custom.*
933 FROM {$tableName} custom
934 INNER JOIN civicrm_contact ON civicrm_contact.id = custom.entity_id
935 WHERE ($subtypeClause)";
937 CRM_Core_DAO
::singleValueQuery($query);
939 // rebuild triggers CRM-13587
940 CRM_Core_DAO
::triggerRebuild($tableName);
944 * Delete content / rows of a custom table specific entity-id for a given custom-group table.
946 * @param int $customTable
948 * @param int $entityID
953 public function deleteCustomRowsForEntityID($customTable, $entityID) {
954 $customTable = CRM_Utils_Type
::escape($customTable, 'String');
955 $query = "DELETE FROM {$customTable} WHERE entity_id = %1";
956 return CRM_Core_DAO
::singleValueQuery($query, array(1 => array($entityID, 'Integer')));