3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 (reference ) an assoc array of name/value pairs
41 * @param array $defaults (reference ) an assoc array to hold the flattened values
43 * @return CRM_Contact_BAO_ContactType object on success, null otherwise
47 static function retrieve(&$params, &$defaults) {
48 $contactType = new CRM_Contact_DAO_ContactType();
49 $contactType->copyValues($params);
50 if ($contactType->find(TRUE)) {
51 CRM_Core_DAO
::storeValues($contactType, $defaults);
62 static function isActive($contactType) {
63 $contact = self
::contactTypeInfo(FALSE);
64 $active = array_key_exists($contactType, $contact) ?
TRUE : FALSE;
69 * Retrieve basic contact type information.
73 * @return array of basic contact types information.
76 static function &basicTypeInfo($all = FALSE) {
77 static $_cache = NULL;
79 if ($_cache === NULL) {
83 $argString = $all ?
'CRM_CT_BTI_1' : 'CRM_CT_BTI_0';
84 if (!array_key_exists($argString, $_cache)) {
85 $cache = CRM_Utils_Cache
::singleton();
86 $_cache[$argString] = $cache->get($argString);
87 if (!$_cache[$argString]) {
90 FROM civicrm_contact_type
91 WHERE parent_id IS NULL
94 $sql .= " AND is_active = 1";
97 $dao = CRM_Core_DAO
::executeQuery($sql,
98 CRM_Core_DAO
::$_nullArray,
100 'CRM_Contact_DAO_ContactType'
102 while ($dao->fetch()) {
104 CRM_Core_DAO
::storeValues($dao, $value);
105 $_cache[$argString][$dao->name
] = $value;
108 $cache->set($argString, $_cache[$argString]);
111 return $_cache[$argString];
115 * Retrieve all basic contact types.
119 * @return array of basic contact types
122 static function basicTypes($all = FALSE) {
123 return array_keys(self
::basicTypeInfo($all));
132 static function basicTypePairs($all = FALSE, $key = 'name') {
133 $subtypes = self
::basicTypeInfo($all);
136 foreach ($subtypes as $name => $info) {
137 $index = ($key == 'name') ?
$name : $info[$key];
138 $pairs[$index] = $info['label'];
144 * Retrieve all subtypes Information.
146 * @param array $contactType .
148 * @param bool $ignoreCache
151 * @return array of sub type information
154 static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
155 static $_cache = NULL;
157 if ($reset === TRUE) {
161 if ($_cache === NULL) {
164 if ($contactType && !is_array($contactType)) {
165 $contactType = array($contactType);
168 $argString = $all ?
'CRM_CT_STI_1_' : 'CRM_CT_STI_0_';
169 if (!empty($contactType)) {
170 $argString .= implode('_', $contactType);
173 if ((!array_key_exists($argString, $_cache)) ||
$ignoreCache) {
174 $cache = CRM_Utils_Cache
::singleton();
175 $_cache[$argString] = $cache->get($argString);
176 if (!$_cache[$argString] ||
$ignoreCache) {
177 $_cache[$argString] = array();
180 if (!empty($contactType)) {
181 $ctWHERE = " AND parent.name IN ('" . implode("','", $contactType) . "')";
185 SELECT subtype.*, parent.name as parent, parent.label as parent_label
186 FROM civicrm_contact_type subtype
187 INNER JOIN civicrm_contact_type parent ON subtype.parent_id = parent.id
188 WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE}
190 if ($all === FALSE) {
191 $sql .= " AND subtype.is_active = 1 AND parent.is_active = 1 ORDER BY parent.id";
193 $dao = CRM_Core_DAO
::executeQuery($sql, array(),
194 FALSE, 'CRM_Contact_DAO_ContactType'
196 while ($dao->fetch()) {
198 CRM_Core_DAO
::storeValues($dao, $value);
199 $value['parent'] = $dao->parent
;
200 $value['parent_label'] = $dao->parent_label
;
201 $_cache[$argString][$dao->name
] = $value;
204 $cache->set($argString, $_cache[$argString]);
207 return $_cache[$argString];
212 * retrieve all subtypes
214 * @param array $contactType .
216 * @param string $columnName
217 * @param bool $ignoreCache
219 * @return array of all subtypes OR list of subtypes associated to
220 *a given basic contact type
223 static function subTypes($contactType = NULL, $all = FALSE, $columnName = 'name', $ignoreCache = FALSE) {
224 if ($columnName == 'name') {
225 return array_keys(self
::subTypeInfo($contactType, $all, $ignoreCache));
228 return array_values(self
::subTypePairs($contactType, FALSE, NULL, $ignoreCache));
234 * retrieve subtype pairs with name as 'subtype-name' and 'label' as value
236 * @param array $contactType .
238 * @param string $labelPrefix
239 * @param bool $ignoreCache
241 * @return list of subtypes with name as 'subtype-name' and 'label' as value
244 static function subTypePairs($contactType = NULL, $all = FALSE, $labelPrefix = '- ', $ignoreCache = FALSE) {
245 $subtypes = self
::subTypeInfo($contactType, $all, $ignoreCache);
248 foreach ($subtypes as $name => $info) {
249 $pairs[$name] = $labelPrefix . $info['label'];
256 * retrieve list of all types i.e basic + subtypes.
260 * @return array of basic types + all subtypes.
263 static function contactTypes($all = FALSE) {
264 return array_keys(self
::contactTypeInfo($all));
269 * retrieve info array about all types i.e basic + subtypes.
274 * @return array of basic types + all subtypes.
277 static function contactTypeInfo($all = FALSE, $reset = FALSE) {
278 static $_cache = NULL;
280 if ($reset === TRUE) {
284 if ($_cache === NULL) {
288 $argString = $all ?
'CRM_CT_CTI_1' : 'CRM_CT_CTI_0';
289 if (!array_key_exists($argString, $_cache)) {
290 $cache = CRM_Utils_Cache
::singleton();
291 $_cache[$argString] = $cache->get($argString);
292 if (!$_cache[$argString]) {
293 $_cache[$argString] = array();
296 SELECT type.*, parent.name as parent, parent.label as parent_label
297 FROM civicrm_contact_type type
298 LEFT JOIN civicrm_contact_type parent ON type.parent_id = parent.id
299 WHERE type.name IS NOT NULL
301 if ($all === FALSE) {
302 $sql .= " AND type.is_active = 1";
305 $dao = CRM_Core_DAO
::executeQuery($sql,
306 CRM_Core_DAO
::$_nullArray,
308 'CRM_Contact_DAO_ContactType'
310 while ($dao->fetch()) {
312 CRM_Core_DAO
::storeValues($dao, $value);
313 if (array_key_exists('parent_id', $value)) {
314 $value['parent'] = $dao->parent
;
315 $value['parent_label'] = $dao->parent_label
;
317 $_cache[$argString][$dao->name
] = $value;
320 $cache->set($argString, $_cache[$argString]);
324 return $_cache[$argString];
328 * Retrieve basic type pairs with name as 'built-in name' and 'label' as value
331 * @param null $typeName
332 * @param null $delimiter
334 * @return array of basictypes with name as 'built-in name' and 'label' as value
337 static function contactTypePairs($all = FALSE, $typeName = NULL, $delimiter = NULL) {
338 $types = self
::contactTypeInfo($all);
340 if ($typeName && !is_array($typeName)) {
341 $typeName = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($typeName, CRM_Core_DAO
::VALUE_SEPARATOR
));
346 foreach ($typeName as $type) {
347 if (array_key_exists($type, $types)) {
348 $pairs[$type] = $types[$type]['label'];
353 foreach ($types as $name => $info) {
354 $pairs[$name] = $info['label'];
358 return !$delimiter ?
$pairs : implode($delimiter, $pairs);
362 * Get a list of elements for select box
363 * Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
364 * which was not handled well be anything that loaded & resaved the html (outside core)
365 * The use of this separator is now explicit in the calling functions as a step towards it's removal
368 * @param bool $isSeparator
369 * @param string $separator
373 static function getSelectElements($all = FALSE,
377 static $_cache = NULL;
379 if ($_cache === NULL) {
383 $argString = $all ?
'CRM_CT_GSE_1' : 'CRM_CT_GSE_0';
384 $argString .= $isSeparator ?
'_1' : '_0';
385 if (!array_key_exists($argString, $_cache)) {
386 $cache = CRM_Utils_Cache
::singleton();
387 $_cache[$argString] = $cache->get($argString);
389 if (!$_cache[$argString]) {
390 $_cache[$argString] = array();
393 SELECT c.name as child_name , c.label as child_label , c.id as child_id,
394 p.name as parent_name, p.label as parent_label, p.id as parent_id
395 FROM civicrm_contact_type c
396 LEFT JOIN civicrm_contact_type p ON ( c.parent_id = p.id )
397 WHERE ( c.name IS NOT NULL )
400 if ($all === FALSE) {
403 AND ( p.is_active = 1 OR p.id IS NULL )
406 $sql .= " ORDER BY c.id";
409 $dao = CRM_Core_DAO
::executeQuery($sql);
410 while ($dao->fetch()) {
411 if (!empty($dao->parent_id
)) {
412 $key = $isSeparator ?
$dao->parent_name
. $separator . $dao->child_name
: $dao->child_name
;
413 $label = "- {$dao->child_label}";
414 $pName = $dao->parent_name
;
417 $key = $dao->child_name
;
418 $label = $dao->child_label
;
419 $pName = $dao->child_name
;
422 if (!isset($values[$pName])) {
423 $values[$pName] = array();
425 $values[$pName][] = array('key' => $key, 'label' => $label);
428 $selectElements = array();
429 foreach ($values as $pName => $elements) {
430 foreach ($elements as $element) {
431 $selectElements[$element['key']] = $element['label'];
434 $_cache[$argString] = $selectElements;
436 $cache->set($argString, $_cache[$argString]);
439 return $_cache[$argString];
443 * Check if a given type is a subtype
445 * @param string $subType contact subType.
446 * @param bool $ignoreCache
448 * @return boolean true if subType, false otherwise.
451 static function isaSubType($subType, $ignoreCache = FALSE) {
452 return in_array($subType, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
456 * Retrieve the basic contact type associated with given subType.
458 *@param array/string $subType contact subType.
459 *@return array/string of basicTypes.
463 static function getBasicType($subType) {
464 static $_cache = NULL;
465 if ($_cache === NULL) {
470 if ($subType && !is_array($subType)) {
471 $subType = array($subType);
474 $argString = implode('_', $subType);
476 if (!array_key_exists($argString, $_cache)) {
477 $_cache[$argString] = array();
480 SELECT subtype.name as contact_subtype, type.name as contact_type
481 FROM civicrm_contact_type subtype
482 INNER JOIN civicrm_contact_type type ON ( subtype.parent_id = type.id )
483 WHERE subtype.name IN ('" . implode("','", $subType) . "' )";
484 $dao = CRM_Core_DAO
::executeQuery($sql);
485 while ($dao->fetch()) {
487 $_cache[$argString] = $dao->contact_type
;
490 $_cache[$argString][$dao->contact_subtype
] = $dao->contact_type
;
493 return $_cache[$argString];
497 * Suppress all subtypes present in given array.
499 * @param array $subTypes contact subTypes
500 * @param bool $ignoreCache
502 * @return array of suppressed subTypes.
505 static function suppressSubTypes(&$subTypes, $ignoreCache = FALSE) {
506 $subTypes = array_diff($subTypes, self
::subTypes(NULL, TRUE, 'name', $ignoreCache));
511 * Verify if a given subtype is associated with a given basic contact type.
513 * @param string $subType contact subType
514 * @param string $contactType contact Type
515 * @param bool $ignoreCache
516 * @param string $columnName
518 * @return boolean true if contact extends, false otherwise.
521 static function isExtendsContactType($subType, $contactType, $ignoreCache = FALSE, $columnName = 'name') {
522 if (!is_array($subType)) {
523 $subType = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, trim($subType, CRM_Core_DAO
::VALUE_SEPARATOR
));
525 $subtypeList = self
::subTypes($contactType, TRUE, $columnName, $ignoreCache);
526 $intersection = array_intersect($subType, $subtypeList);
527 return $subType == $intersection;
531 * Create shortcuts menu for contactTypes
533 * @return array of contactTypes
536 static function getCreateNewList() {
537 $shortCuts = array();
538 //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
539 // this is loaded onto then replace with something like '__' & test
540 $separator = CRM_Core_DAO
::VALUE_SEPARATOR
;
541 $contactTypes = self
::getSelectElements(FALSE, TRUE, $separator);
542 foreach ($contactTypes as $key => $value) {
544 $typeValue = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $key);
545 $cType = CRM_Utils_Array
::value('0', $typeValue);
546 $typeUrl = 'ct=' . $cType;
547 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
548 $typeUrl .= "&cst=$csType";
551 'path' => 'civicrm/contact/add',
552 'query' => "$typeUrl&reset=1",
553 'ref' => "new-$value",
556 if ($csType = CRM_Utils_Array
::value('1', $typeValue)) {
557 $shortCuts[$cType]['shortCuts'][] = $shortCut;
560 $shortCuts[$cType] = $shortCut;
568 * Delete Contact SubTypes
570 * @param int $contactTypeId ID of the Contact Subtype to be deleted.
576 static function del($contactTypeId) {
578 if (!$contactTypeId) {
582 $params = array('id' => $contactTypeId);
583 self
::retrieve($params, $typeInfo);
584 $name = $typeInfo['name'];
585 // check if any custom group
586 $custom = new CRM_Core_DAO_CustomGroup();
587 $custom->whereAdd("extends_entity_column_value LIKE '%" .
588 CRM_Core_DAO
::VALUE_SEPARATOR
.
590 CRM_Core_DAO
::VALUE_SEPARATOR
. "%'"
592 if ($custom->find()) {
596 // remove subtype for existing contacts
598 UPDATE civicrm_contact SET contact_sub_type = NULL
599 WHERE contact_sub_type = '$name'";
600 CRM_Core_DAO
::executeQuery($sql);
602 // remove subtype from contact type table
603 $contactType = new CRM_Contact_DAO_ContactType();
604 $contactType->id
= $contactTypeId;
605 $contactType->delete();
607 // remove navigation entry if any
611 FROM civicrm_navigation
613 $params = array(1 => array("New $name", 'String'));
614 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
615 CRM_Core_BAO_Navigation
::resetNavigation();
621 * Add or update Contact SubTypes
623 * @param array $params an assoc array of name/value pairs
629 static function add(&$params) {
632 if (empty($params['id']) && empty($params['label'])) {
635 if (!empty($params['parent_id']) &&
636 !CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])
641 $contactType = new CRM_Contact_DAO_ContactType();
642 $contactType->copyValues($params);
643 $contactType->id
= CRM_Utils_Array
::value('id', $params);
644 $contactType->is_active
= CRM_Utils_Array
::value('is_active', $params, 0);
646 $contactType->save();
647 if ($contactType->find(TRUE)) {
648 $contactName = $contactType->name
;
649 $contact = ucfirst($contactType->label
);
650 $active = $contactType->is_active
;
653 if (!empty($params['id'])) {
654 $params = array('name' => "New $contactName");
656 'label' => "New $contact",
657 'is_active' => $active,
659 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
662 $name = self
::getBasicType($contactName);
666 $value = array('name' => "New $name");
667 CRM_Core_BAO_Navigation
::retrieve($value, $navinfo);
669 'label' => "New $contact",
670 'name' => "New $contactName",
671 'url' => "civicrm/contact/add?ct=$name&cst=$contactName&reset=1",
672 'permission' => 'add contacts',
673 'parent_id' => $navinfo['id'],
674 'is_active' => $active,
676 CRM_Core_BAO_Navigation
::add($navigation);
678 CRM_Core_BAO_Navigation
::resetNavigation();
680 // reset the cache after adding
681 self
::subTypeInfo(NULL, FALSE, FALSE, TRUE);
687 * Update the is_active flag in the db
689 * @param int $id id of the database record
690 * @param boolean $is_active value we want to set the is_active field
692 * @return Object DAO object on success, null otherwise
695 static function setIsActive($id, $is_active) {
696 $params = array('id' => $id);
697 self
::retrieve($params, $contactinfo);
698 $params = array('name' => "New $contactinfo[name]");
699 $newParams = array('is_active' => $is_active);
700 CRM_Core_BAO_Navigation
::processUpdate($params, $newParams);
701 CRM_Core_BAO_Navigation
::resetNavigation();
702 return CRM_Core_DAO
::setFieldValue('CRM_Contact_DAO_ContactType', $id,
703 'is_active', $is_active
708 * @param string $typeName
712 static function getLabel($typeName) {
713 $types = self
::contactTypeInfo(TRUE);
715 if (array_key_exists($typeName, $types)) {
716 return $types[$typeName]['label'];
722 * Check whether allow to change any contact's subtype
723 * on the basis of custom data and relationship of specific subtype
724 * currently used in contact/edit form amd in import validation
726 * @param int $contactId contact id.
727 * @param string $subType subtype.
729 * @return boolean true/false.
732 static function isAllowEdit($contactId, $subType = NULL) {
738 if (empty($subType)) {
739 $subType = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Contact',
745 if (self
::hasCustomData($subType, $contactId) || self
::hasRelationships($contactId, $subType)) {
753 * @param $contactType
754 * @param int $contactId
758 static function hasCustomData($contactType, $contactId = NULL) {
761 if (self
::isaSubType($contactType)) {
762 $subType = $contactType;
763 $contactType = self
::getBasicType($subType);
765 // check for empty custom data which extends subtype
766 $subTypeValue = CRM_Core_DAO
::VALUE_SEPARATOR
. $subType . CRM_Core_DAO
::VALUE_SEPARATOR
;
767 $subTypeClause = " AND extends_entity_column_value LIKE '%{$subTypeValue}%' ";
769 $query = "SELECT table_name FROM civicrm_custom_group WHERE extends = '{$contactType}' {$subTypeClause}";
771 $dao = CRM_Core_DAO
::executeQuery($query);
772 while ($dao->fetch()) {
773 $sql = "SELECT count(id) FROM {$dao->table_name}";
775 $sql .= " WHERE entity_id = {$contactId}";
779 $customDataCount = CRM_Core_DAO
::singleValueQuery($sql);
780 if (!empty($customDataCount)) {
789 * @todo what does this function do?
790 * @param int $contactId
791 * @param $contactType
795 static function hasRelationships($contactId, $contactType) {
796 $subTypeClause = NULL;
797 if (self
::isaSubType($contactType)) {
798 $subType = $contactType;
799 $contactType = self
::getBasicType($subType);
800 $subTypeClause = " AND ( ( crt.contact_type_a = '{$contactType}' AND crt.contact_sub_type_a = '{$subType}') OR
801 ( crt.contact_type_b = '{$contactType}' AND crt.contact_sub_type_b = '{$subType}') ) ";
804 $subTypeClause = " AND ( crt.contact_type_a = '{$contactType}' OR crt.contact_type_b = '{$contactType}' ) ";
807 // check relationships for
808 $relationshipQuery = "
809 SELECT count(cr.id) FROM civicrm_relationship cr
810 INNER JOIN civicrm_relationship_type crt ON
811 ( cr.relationship_type_id = crt.id {$subTypeClause} )
812 WHERE ( cr.contact_id_a = {$contactId} OR cr.contact_id_b = {$contactId} )
815 $relationshipCount = CRM_Core_DAO
::singleValueQuery($relationshipQuery);
817 if (!empty($relationshipCount)) {
825 * @todo what does this function do?
826 * @param $contactType
827 * @param array $subtypeSet
831 static function getSubtypeCustomPair($contactType, $subtypeSet = array()) {
832 if (empty($subtypeSet)) {
836 $customSet = $subTypeClause = array();
837 foreach ($subtypeSet as $subtype) {
838 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
839 $subType = CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
;
840 $subTypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%' ";
842 $query = "SELECT table_name
843 FROM civicrm_custom_group
844 WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
845 $dao = CRM_Core_DAO
::executeQuery($query, array(1 => array($contactType, 'String')));
846 while ($dao->fetch()) {
847 $customSet[] = $dao->table_name
;
849 return array_unique($customSet);
853 * Function that does something
854 * @todo what does this function do?
856 * @param int $contactID
857 * @param $contactType
858 * @param array $oldSubtypeSet
859 * @param array $newSubtypeSet
863 static function deleteCustomSetForSubtypeMigration($contactID,
865 $oldSubtypeSet = array(),
866 $newSubtypeSet = array()
868 $oldCustomSet = self
::getSubtypeCustomPair($contactType, $oldSubtypeSet);
869 $newCustomSet = self
::getSubtypeCustomPair($contactType, $newSubtypeSet);
871 $customToBeRemoved = array_diff($oldCustomSet, $newCustomSet);
872 foreach ($customToBeRemoved as $customTable) {
873 self
::deleteCustomRowsForEntityID($customTable, $contactID);
879 * Delete content / rows of a custom table specific to a subtype for a given custom-group.
880 * This function currently works for contact subtypes only and could be later improved / genralized
881 * to work for other subtypes as well.
883 * @param int $gID - custom group id.
884 * @param array $subtypes - list of subtypes related to which entry is to be removed.
889 public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
890 if (!$gID or empty($subtypes)) {
894 $tableName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup', $gID, 'table_name');
896 // drop triggers CRM-13587
897 CRM_Core_DAO
::dropTriggers($tableName);
899 $subtypeClause = array();
900 foreach ($subtypes as $subtype) {
901 $subtype = CRM_Utils_Type
::escape($subtype, 'String');
902 $subtypeClause[] = "civicrm_contact.contact_sub_type LIKE '%" . CRM_Core_DAO
::VALUE_SEPARATOR
. $subtype . CRM_Core_DAO
::VALUE_SEPARATOR
. "%'";
904 $subtypeClause = implode(' OR ', $subtypeClause);
906 $query = "DELETE custom.*
907 FROM {$tableName} custom
908 INNER JOIN civicrm_contact ON civicrm_contact.id = custom.entity_id
909 WHERE ($subtypeClause)";
911 CRM_Core_DAO
::singleValueQuery($query);
913 // rebuild triggers CRM-13587
914 CRM_Core_DAO
::triggerRebuild($tableName);
918 * Delete content / rows of a custom table specific entity-id for a given custom-group table.
920 * @param int $customTable - custom table name.
921 * @param int $entityID - entity id.
926 function deleteCustomRowsForEntityID($customTable, $entityID) {
927 $customTable = CRM_Utils_Type
::escape($customTable, 'String');
928 $query = "DELETE FROM {$customTable} WHERE entity_id = %1";
929 return CRM_Core_DAO
::singleValueQuery($query, array(1 => array($entityID, 'Integer')));