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|null
46 * 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 * Array of basic contact types information.
77 public static function &basicTypeInfo($all = FALSE) {
78 static $_cache = NULL;
80 if ($_cache === NULL) {
84 $argString = $all ?
'CRM_CT_BTI_1' : 'CRM_CT_BTI_0';
85 if (!array_key_exists($argString, $_cache)) {
86 $cache = CRM_Utils_Cache
::singleton();
87 $_cache[$argString] = $cache->get($argString);
88 if (!$_cache[$argString]) {
91 FROM civicrm_contact_type
92 WHERE parent_id IS NULL
95 $sql .= " AND is_active = 1";
98 $dao = CRM_Core_DAO
::executeQuery($sql,
99 CRM_Core_DAO
::$_nullArray,
101 'CRM_Contact_DAO_ContactType'
103 while ($dao->fetch()) {
105 CRM_Core_DAO
::storeValues($dao, $value);
106 $_cache[$argString][$dao->name
] = $value;
109 $cache->set($argString, $_cache[$argString]);
112 return $_cache[$argString];
116 * Retrieve all basic contact types.
121 * Array of basic contact types
123 public static function basicTypes($all = FALSE) {
124 return array_keys(self
::basicTypeInfo($all));
133 public static function basicTypePairs($all = FALSE, $key = 'name') {
134 $subtypes = self
::basicTypeInfo($all);
137 foreach ($subtypes as $name => $info) {
138 $index = ($key == 'name') ?
$name : $info[$key];
139 $pairs[$index] = $info['label'];
145 * Retrieve all subtypes Information.
147 * @param array $contactType
150 * @param bool $ignoreCache
154 * Array of sub type information
156 public static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
157 static $_cache = NULL;
159 if ($reset === TRUE) {
163 if ($_cache === NULL) {
166 if ($contactType && !is_array($contactType)) {
167 $contactType = array($contactType);
170 $argString = $all ?
'CRM_CT_STI_1_' : 'CRM_CT_STI_0_';
171 if (!empty($contactType)) {
172 $argString .= implode('_', $contactType);
175 if ((!array_key_exists($argString, $_cache)) ||
$ignoreCache) {
176 $cache = CRM_Utils_Cache
::singleton();
177 $_cache[$argString] = $cache->get($argString);
178 if (!$_cache[$argString] ||
$ignoreCache) {
179 $_cache[$argString] = array();
182 if (!empty($contactType)) {
183 $ctWHERE = " AND parent.name IN ('" . implode("','", $contactType) . "')";
187 SELECT subtype.*, parent.name as parent, parent.label as parent_label
188 FROM civicrm_contact_type subtype
189 INNER JOIN civicrm_contact_type parent ON subtype.parent_id = parent.id
190 WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE}
192 if ($all === FALSE) {
193 $sql .= " AND subtype.is_active = 1 AND parent.is_active = 1 ORDER BY parent.id";
195 $dao = CRM_Core_DAO
::executeQuery($sql, array(),
196 FALSE, 'CRM_Contact_DAO_ContactType'
198 while ($dao->fetch()) {
200 CRM_Core_DAO
::storeValues($dao, $value);
201 $value['parent'] = $dao->parent
;
202 $value['parent_label'] = $dao->parent_label
;
203 $_cache[$argString][$dao->name
] = $value;
206 $cache->set($argString, $_cache[$argString]);
209 return $_cache[$argString];
214 * retrieve all subtypes
216 * @param array $contactType
219 * @param string $columnName
220 * @param bool $ignoreCache
223 * all subtypes OR list of subtypes associated to
224 * a given basic contact type
226 public static function subTypes($contactType = NULL, $all = FALSE, $columnName = 'name', $ignoreCache = FALSE) {
227 if ($columnName == 'name') {
228 return array_keys(self
::subTypeInfo($contactType, $all, $ignoreCache));
231 return array_values(self
::subTypePairs($contactType, FALSE, NULL, $ignoreCache));
237 * retrieve subtype pairs with name as 'subtype-name' and 'label' as value
239 * @param array $contactType
241 * @param string $labelPrefix
242 * @param bool $ignoreCache
245 * list of subtypes with name as 'subtype-name' and 'label' as value
247 public static function subTypePairs($contactType = NULL, $all = FALSE, $labelPrefix = '- ', $ignoreCache = FALSE) {
248 $subtypes = self
::subTypeInfo($contactType, $all, $ignoreCache);
251 foreach ($subtypes as $name => $info) {
252 $pairs[$name] = $labelPrefix . $info['label'];
259 * retrieve list of all types i.e basic + subtypes.
264 * Array of basic types + all subtypes.
266 public static function contactTypes($all = FALSE) {
267 return array_keys(self
::contactTypeInfo($all));
272 * retrieve info array about all types i.e basic + subtypes.
278 * Array of basic types + all subtypes.
280 public static function contactTypeInfo($all = FALSE, $reset = FALSE) {
281 static $_cache = NULL;
283 if ($reset === TRUE) {
287 if ($_cache === NULL) {
291 $argString = $all ?
'CRM_CT_CTI_1' : 'CRM_CT_CTI_0';
292 if (!array_key_exists($argString, $_cache)) {
293 $cache = CRM_Utils_Cache
::singleton();
294 $_cache[$argString] = $cache->get($argString);
295 if (!$_cache[$argString]) {
296 $_cache[$argString] = array();
299 SELECT type.*, parent.name as parent, parent.label as parent_label
300 FROM civicrm_contact_type type
301 LEFT JOIN civicrm_contact_type parent ON type.parent_id = parent.id
302 WHERE type.name IS NOT NULL
304 if ($all === FALSE) {
305 $sql .= " AND type.is_active = 1";
308 $dao = CRM_Core_DAO
::executeQuery($sql,
311 'CRM_Contact_DAO_ContactType'
313 while ($dao->fetch()) {
315 CRM_Core_DAO
::storeValues($dao, $value);
316 if (array_key_exists('parent_id', $value)) {
317 $value['parent'] = $dao->parent
;
318 $value['parent_label'] = $dao->parent_label
;
320 $_cache[$argString][$dao->name
] = $value;
323 $cache->set($argString, $_cache[$argString]);
327 return $_cache[$argString];
331 * Retrieve basic type pairs with name as 'built-in name' and 'label' as value
334 * @param null $typeName
335 * @param null $delimiter
338 * Array of basictypes with name as 'built-in name' and 'label' as value
340 public static function contactTypePairs($all = FALSE, $typeName = NULL, $delimiter = NULL) {
341 $types = self
::contactTypeInfo($all);
343 if ($typeName && !is_array($typeName)) {
344 $typeName = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($typeName, CRM_Core_DAO
::VALUE_SEPARATOR
));
349 foreach ($typeName as $type) {
350 if (array_key_exists($type, $types)) {
351 $pairs[$type] = $types[$type]['label'];
356 foreach ($types as $name => $info) {
357 $pairs[$name] = $info['label'];
361 return !$delimiter ?
$pairs : implode($delimiter, $pairs);
365 * Get a list of elements for select box.
366 * Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
367 * which was not handled well be anything that loaded & resaved the html (outside core)
368 * The use of this separator is now explicit in the calling functions as a step towards it's removal
371 * @param bool $isSeparator
372 * @param string $separator
376 public static function getSelectElements(
381 static $_cache = NULL;
383 if ($_cache === NULL) {
387 $argString = $all ?
'CRM_CT_GSE_1' : 'CRM_CT_GSE_0';
388 $argString .= $isSeparator ?
'_1' : '_0';
389 if (!array_key_exists($argString, $_cache)) {
390 $cache = CRM_Utils_Cache
::singleton();
391 $_cache[$argString] = $cache->get($argString);
393 if (!$_cache[$argString]) {
394 $_cache[$argString] = array();
397 SELECT c.name as child_name , c.label as child_label , c.id as child_id,
398 p.name as parent_name, p.label as parent_label, p.id as parent_id
399 FROM civicrm_contact_type c
400 LEFT JOIN civicrm_contact_type p ON ( c.parent_id = p.id )
401 WHERE ( c.name IS NOT NULL )
404 if ($all === FALSE) {
407 AND ( p.is_active = 1 OR p.id IS NULL )
410 $sql .= " ORDER BY c.id";
413 $dao = CRM_Core_DAO
::executeQuery($sql);
414 while ($dao->fetch()) {
415 if (!empty($dao->parent_id
)) {
416 $key = $isSeparator ?
$dao->parent_name
. $separator . $dao->child_name
: $dao->child_name
;
417 $label = "- {$dao->child_label}";
418 $pName = $dao->parent_name
;
421 $key = $dao->child_name
;
422 $label = $dao->child_label
;
423 $pName = $dao->child_name
;
426 if (!isset($values[$pName])) {
427 $values[$pName] = array();
429 $values[$pName][] = array('key' => $key, 'label' => $label);
432 $selectElements = array();
433 foreach ($values as $pName => $elements) {
434 foreach ($elements as $element) {
435 $selectElements[$element['key']] = $element['label'];
438 $_cache[$argString] = $selectElements;
440 $cache->set($argString, $_cache[$argString]);
443 return $_cache[$argString];
447 * Check if a given type is a subtype.
449 * @param string $subType
451 * @param bool $ignoreCache
454 * true if subType, false otherwise.
456 public static function isaSubType($subType, $ignoreCache = FALSE) {
457 return in_array($subType, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
461 * Retrieve the basic contact type associated with given subType.
463 * @param array /string $subType contact subType.
464 * @return array/string of basicTypes.
466 public static function getBasicType($subType) {
467 static $_cache = NULL;
468 if ($_cache === NULL) {
473 if ($subType && !is_array($subType)) {
474 $subType = array($subType);
477 $argString = implode('_', $subType);
479 if (!array_key_exists($argString, $_cache)) {
480 $_cache[$argString] = array();
483 SELECT subtype.name as contact_subtype, type.name as contact_type
484 FROM civicrm_contact_type subtype
485 INNER JOIN civicrm_contact_type type ON ( subtype.parent_id = type.id )
486 WHERE subtype.name IN ('" . implode("','", $subType) . "' )";
487 $dao = CRM_Core_DAO
::executeQuery($sql);
488 while ($dao->fetch()) {
490 $_cache[$argString] = $dao->contact_type
;
493 $_cache[$argString][$dao->contact_subtype
] = $dao->contact_type
;
496 return $_cache[$argString];
500 * Suppress all subtypes present in given array.
502 * @param array $subTypes
504 * @param bool $ignoreCache
507 * Array of suppressed subTypes.
509 public static function suppressSubTypes(&$subTypes, $ignoreCache = FALSE) {
510 $subTypes = array_diff($subTypes, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
515 * Verify if a given subtype is associated with a given basic contact type.
517 * @param string $subType
519 * @param string $contactType
521 * @param bool $ignoreCache
522 * @param string $columnName
525 * true if contact extends, false otherwise.
527 public static function isExtendsContactType($subType, $contactType, $ignoreCache = FALSE, $columnName = 'name') {
528 if (!is_array($subType)) {
529 $subType = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($subType, CRM_Core_DAO
::VALUE_SEPARATOR
));
531 $subtypeList = self
::subTypes($contactType, TRUE, $columnName, $ignoreCache);
532 $intersection = array_intersect($subType, $subtypeList);
533 return $subType == $intersection;
537 * Create shortcuts menu for contactTypes.
542 public static function getCreateNewList() {
543 $shortCuts = array();
544 //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
545 // this is loaded onto then replace with something like '__' & test
546 $separator = CRM_Core_DAO
::VALUE_SEPARATOR
;
547 $contactTypes = self
::getSelectElements(FALSE, TRUE, $separator);
548 foreach ($contactTypes as $key => $value) {
550 $typeValue = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $key);
551 $cType = CRM_Utils_Array
::value('0', $typeValue);
552 $typeUrl = 'ct=' . $cType;
553 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
554 $typeUrl .= "&cst=$csType";
557 'path' => 'civicrm/contact/add',
558 'query' => "$typeUrl&reset=1",
559 'ref' => "new-$value",
562 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
563 $shortCuts[$cType]['shortCuts'][] = $shortCut;
566 $shortCuts[$cType] = $shortCut;
574 * Delete Contact SubTypes.
576 * @param int $contactTypeId
577 * ID of the Contact Subtype to be deleted.
581 public static function del($contactTypeId) {
583 if (!$contactTypeId) {
587 $params = array('id' => $contactTypeId);
588 self
::retrieve($params, $typeInfo);
589 $name = $typeInfo['name'];
590 // check if any custom group
591 $custom = new CRM_Core_DAO_CustomGroup();
592 $custom->whereAdd("extends_entity_column_value LIKE '%" .
593 CRM_Core_DAO
::VALUE_SEPARATOR
.
595 CRM_Core_DAO
::VALUE_SEPARATOR
. "%'"
597 if ($custom->find()) {
601 // remove subtype for existing contacts
603 UPDATE civicrm_contact SET contact_sub_type = NULL
604 WHERE contact_sub_type = '$name'";
605 CRM_Core_DAO
::executeQuery($sql);
607 // remove subtype from contact type table
608 $contactType = new CRM_Contact_DAO_ContactType();
609 $contactType->id
= $contactTypeId;
610 $contactType->delete();
612 // remove navigation entry if any
616 FROM civicrm_navigation
618 $params = array(1 => array("New $name", 'String'));
619 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
620 CRM_Core_BAO_Navigation
::resetNavigation();
626 * Add or update Contact SubTypes.
628 * @param array $params
629 * An assoc array of name/value pairs.
631 * @return object|void
633 public static function add(&$params) {
636 if (empty($params['id']) && empty($params['label'])) {
639 if (!empty($params['parent_id']) &&
640 !CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])
645 $contactType = new CRM_Contact_DAO_ContactType();
646 $contactType->copyValues($params);
647 $contactType->id
= CRM_Utils_Array
::value('id', $params);
648 $contactType->is_active
= CRM_Utils_Array
::value('is_active', $params, 0);
650 $contactType->save();
651 if ($contactType->find(TRUE)) {
652 $contactName = $contactType->name
;
653 $contact = ucfirst($contactType->label
);
654 $active = $contactType->is_active
;
657 if (!empty($params['id'])) {
658 $params = array('name' => "New $contactName");
660 'label' => "New $contact",
661 'is_active' => $active,
663 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
666 $name = self
::getBasicType($contactName);
670 $value = array('name' => "New $name");
671 CRM_Core_BAO_Navigation
::retrieve($value, $navinfo);
673 'label' => "New $contact",
674 'name' => "New $contactName",
675 'url' => "civicrm/contact/add?ct=$name&cst=$contactName&reset=1",
676 'permission' => 'add contacts',
677 'parent_id' => $navinfo['id'],
678 'is_active' => $active,
680 CRM_Core_BAO_Navigation
::add($navigation);
682 CRM_Core_BAO_Navigation
::resetNavigation();
684 // reset the cache after adding
685 self
::subTypeInfo(NULL, FALSE, FALSE, TRUE);
691 * Update the is_active flag in the db.
694 * Id of the database record.
695 * @param bool $is_active
696 * Value we want to set the is_active field.
699 * DAO object on success, null otherwise
701 public static function setIsActive($id, $is_active) {
702 $params = array('id' => $id);
703 self
::retrieve($params, $contactinfo);
704 $params = array('name' => "New $contactinfo[name]");
705 $newParams = array('is_active' => $is_active);
706 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
707 CRM_Core_BAO_Navigation
::resetNavigation();
708 return CRM_Core_DAO
::setFieldValue('CRM_Contact_DAO_ContactType', $id,
709 'is_active', $is_active
714 * @param string $typeName
718 public static function getLabel($typeName) {
719 $types = self
::contactTypeInfo(TRUE);
721 if (array_key_exists($typeName, $types)) {
722 return $types[$typeName]['label'];
728 * Check whether allow to change any contact's subtype
729 * on the basis of custom data and relationship of specific subtype
730 * currently used in contact/edit form amd in import validation
732 * @param int $contactId
734 * @param string $subType
739 public static function isAllowEdit($contactId, $subType = NULL) {
745 if (empty($subType)) {
746 $subType = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Contact',
752 if (self
::hasCustomData($subType, $contactId) || self
::hasRelationships($contactId, $subType)) {
760 * @param $contactType
761 * @param int $contactId
765 public static function hasCustomData($contactType, $contactId = NULL) {
768 if (self
::isaSubType($contactType)) {
769 $subType = $contactType;
770 $contactType = self
::getBasicType($subType);
772 // check for empty custom data which extends subtype
773 $subTypeValue = CRM_Core_DAO
::VALUE_SEPARATOR
. $subType . CRM_Core_DAO
::VALUE_SEPARATOR
;
774 $subTypeClause = " AND extends_entity_column_value LIKE '%{$subTypeValue}%' ";
776 $query = "SELECT table_name FROM civicrm_custom_group WHERE extends = '{$contactType}' {$subTypeClause}";
778 $dao = CRM_Core_DAO
::executeQuery($query);
779 while ($dao->fetch()) {
780 $sql = "SELECT count(id) FROM {$dao->table_name}";
782 $sql .= " WHERE entity_id = {$contactId}";
786 $customDataCount = CRM_Core_DAO
::singleValueQuery($sql);
787 if (!empty($customDataCount)) {
796 * @todo what does this function do?
797 * @param int $contactId
798 * @param $contactType
802 public static function hasRelationships($contactId, $contactType) {
803 $subTypeClause = NULL;
804 if (self
::isaSubType($contactType)) {
805 $subType = $contactType;
806 $contactType = self
::getBasicType($subType);
807 $subTypeClause = " AND ( ( crt.contact_type_a = '{$contactType}' AND crt.contact_sub_type_a = '{$subType}') OR
808 ( crt.contact_type_b = '{$contactType}' AND crt.contact_sub_type_b = '{$subType}') ) ";
811 $subTypeClause = " AND ( crt.contact_type_a = '{$contactType}' OR crt.contact_type_b = '{$contactType}' ) ";
814 // check relationships for
815 $relationshipQuery = "
816 SELECT count(cr.id) FROM civicrm_relationship cr
817 INNER JOIN civicrm_relationship_type crt ON
818 ( cr.relationship_type_id = crt.id {$subTypeClause} )
819 WHERE ( cr.contact_id_a = {$contactId} OR cr.contact_id_b = {$contactId} )
822 $relationshipCount = CRM_Core_DAO
::singleValueQuery($relationshipQuery);
824 if (!empty($relationshipCount)) {
832 * @todo what does this function do?
833 * @param $contactType
834 * @param array $subtypeSet
838 public static function getSubtypeCustomPair($contactType, $subtypeSet = array()) {
839 if (empty($subtypeSet)) {
843 $customSet = $subTypeClause = array();
844 foreach ($subtypeSet as $subtype) {
845 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
846 $subType = CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
;
847 $subTypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%' ";
849 $query = "SELECT table_name
850 FROM civicrm_custom_group
851 WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
852 $dao = CRM_Core_DAO
::executeQuery($query, array(1 => array($contactType, 'String')));
853 while ($dao->fetch()) {
854 $customSet[] = $dao->table_name
;
856 return array_unique($customSet);
860 * Function that does something.
861 * @todo what does this function do?
863 * @param int $contactID
864 * @param $contactType
865 * @param array $oldSubtypeSet
866 * @param array $newSubtypeSet
870 public static function deleteCustomSetForSubtypeMigration(
873 $oldSubtypeSet = array(),
874 $newSubtypeSet = array()
876 $oldCustomSet = self
::getSubtypeCustomPair($contactType, $oldSubtypeSet);
877 $newCustomSet = self
::getSubtypeCustomPair($contactType, $newSubtypeSet);
879 $customToBeRemoved = array_diff($oldCustomSet, $newCustomSet);
880 foreach ($customToBeRemoved as $customTable) {
881 self
::deleteCustomRowsForEntityID($customTable, $contactID);
887 * Delete content / rows of a custom table specific to a subtype for a given custom-group.
888 * This function currently works for contact subtypes only and could be later improved / genralized
889 * to work for other subtypes as well.
893 * @param array $subtypes
894 * List of subtypes related to which entry is to be removed.
898 public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
899 if (!$gID or empty($subtypes)) {
903 $tableName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup', $gID, 'table_name');
905 // drop triggers CRM-13587
906 CRM_Core_DAO
::dropTriggers($tableName);
908 $subtypeClause = array();
909 foreach ($subtypes as $subtype) {
910 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
911 $subtypeClause[] = "civicrm_contact.contact_sub_type LIKE '%" . CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
. "%'";
913 $subtypeClause = implode(' OR ', $subtypeClause);
915 $query = "DELETE custom.*
916 FROM {$tableName} custom
917 INNER JOIN civicrm_contact ON civicrm_contact.id = custom.entity_id
918 WHERE ($subtypeClause)";
920 CRM_Core_DAO
::singleValueQuery($query);
922 // rebuild triggers CRM-13587
923 CRM_Core_DAO
::triggerRebuild($tableName);
927 * Delete content / rows of a custom table specific entity-id for a given custom-group table.
929 * @param int $customTable
931 * @param int $entityID
936 public function deleteCustomRowsForEntityID($customTable, $entityID) {
937 $customTable = CRM_Utils_Type
::escape($customTable, 'String');
938 $query = "DELETE FROM {$customTable} WHERE entity_id = %1";
939 return CRM_Core_DAO
::singleValueQuery($query, array(1 => array($entityID, 'Integer')));