* (reference) an assoc array of name/value pairs.
*
* @return CRM_Core_DAO_CustomGroup
+ * @throws \Exception
*/
public static function create(&$params) {
// create custom group dao, populate fields and then save.
$group->extends_entity_column_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $extendsEntity, 'value', 'name');
}
- //this is format when form get submit.
+ // this is format when form get submit.
$extendsChildType = CRM_Utils_Array::value(1, $extends);
- //lets allow user to pass direct child type value, CRM-6893
+ // lets allow user to pass direct child type value, CRM-6893
if (!empty($params['extends_entity_column_value'])) {
$extendsChildType = $params['extends_entity_column_value'];
}
$group->id = $params['id'];
if (isset($params['is_multiple'])) {
- //check whether custom group was changed from single-valued to multiple-valued
+ // check whether custom group was changed from single-valued to multiple-valued
$isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup',
$params['id'],
'is_multiple'
* @todo - review this - It also returns an array called 'info' with tables, select, from, where keys
* The reason for the info array in unclear and it could be determined from parsing the group tree after creation
* With caching the performance impact would be small & the function would be cleaner
+ *
+ * @throws \CRM_Core_Exception
*/
public static function getTree(
$entityType,
}
// create a new tree
- $strWhere = $orderBy = '';
// legacy hardcoded list of data to return
$tableData = array(
$cacheKey = "CRM_Core_DAO_CustomGroup_Query " . md5($cacheString);
$multipleFieldGroupCacheKey = "CRM_Core_DAO_CustomGroup_QueryMultipleFields " . md5($cacheString);
$cache = CRM_Utils_Cache::singleton();
- $tablesWithEntityData = array();
if ($fromCache) {
$groupTree = $cache->get($cacheKey);
$multipleFieldGroups = $cache->get($multipleFieldGroupCacheKey);
$cache->set($cacheKey, $groupTree);
$cache->set($multipleFieldGroupCacheKey, $multipleFieldGroups);
}
- //entitySelectClauses is an array of select clauses for custom value tables which are not multiple
+ // entitySelectClauses is an array of select clauses for custom value tables which are not multiple
// and have data for the given entities. $entityMultipleSelectClauses is the same for ones with multiple
$entitySingleSelectClauses = $entityMultipleSelectClauses = $groupTree['info']['select'] = array();
$singleFieldTables = array();
*
* @return string
* @throws \CRM_Core_Exception
- * @throws \CiviCRM_API3_Exception
*/
protected static function validateSubTypeByEntity($entityType, $subType) {
$subType = trim($subType, CRM_Core_DAO::VALUE_SEPARATOR);
/**
* Check whether the custom group has any data for the given entity.
*
- *
* @param int $entityID
* Id of entity for whom we are checking data for.
* @param string $table
* Array of select clauses relevant to the entity.
* @param array $multipleFieldTablesWithEntityData
* Array of tables in which this entity has data.
- * @param varchar $singleRecord
+ * @param string|int $singleRecord
* holds 'new' or id if view/edit/copy form for a single record is being loaded.
*/
static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData, $singleRecord = NULL) {
* @param array $includedTables
* Tables to include - required because the function (for historical reasons).
* iterates through the group tree
- * @param varchar $singleRecord
+ * @param string|int $singleRecord
* holds 'new' OR id if view/edit/copy form for a single record is being loaded.
*/
static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables, $singleRecord = NULL) {
* Custom group ID.
* @param int $fieldID
* Custom field ID.
- * @param varchar $singleRecord
+ * @param string|int $singleRecord
* holds 'new' or id if loading view/edit/copy for a single record.
*/
static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID, $singleRecord = NULL) {
* @param array $extends
* Which table does it extend if any.
*
- * @param null $inSelector
+ * @param bool $inSelector
*
* @return array
* array consisting of all group and field details
public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$extends = NULL, $inSelector = NULL) {
// create a new tree
$groupTree = array();
- $select = $from = $where = $orderBy = '';
-
- $tableData = array();
// using tableData to build the queryString
$tableData = array(
switch ($groupTree[$groupID]['fields'][$fieldId]['html_type']) {
- //added for CheckBox
-
+ // added for CheckBox
case 'CheckBox':
if (!empty($v)) {
$customValue = array_keys($v);
break;
}
- //store the file in d/b
+ // store the file in d/b
$entityId = explode('=', $groupTree['info']['where'][0]);
$fileParams = array('upload_date' => date('YmdHis'));
* Return inactive custom groups.
* @param string $prefix
* Prefix for custom grouptree assigned to template.
+ *
+ * @throws \CiviCRM_API3_Exception
*/
public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '') {
$form->assign_by_ref("{$prefix}groupTree", $groupTree);
* The type of custom group we are using.
*
* @return array
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public static function extractGetParams(&$form, $type) {
if (empty($_GET)) {
/**
* @param $group
+ *
+ * @throws \Exception
*/
public static function createTable($group) {
$params = array(
}
/**
- * Function returns formatted groupTree, sothat form can be easily build in template
+ * Function returns formatted groupTree, so that form can be easily built in template
*
* @param array $groupTree
* @param int $groupCount
- * Group count by default 1, but can varry for multiple value custom data.
- * @param object $form
+ * Group count by default 1, but can vary for multiple value custom data.
+ * @param \CRM_Core_Form $form
*
* @return array
+ * @throws \CRM_Core_Exception
*/
public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NULL) {
$formattedGroupTree = array();
}
if ($returnCount) {
- //return a single value count if group id is passed to function
- //else return a groupId and count mapped array
+ // return a single value count if group id is passed to function
+ // else return a groupId and count mapped array
if (!empty($gID)) {
return count($details[$gID]);
}
*
* @return array
* Array of types.
+ * @throws \Exception
*/
public static function getExtendedObjectTypes(&$types = array()) {
static $flag = FALSE, $objTypes = array();
}
list($className) = explode('::', $callback);
- require_once str_replace('_', DIRECTORY_SEPARATOR, $className) .
- '.php';
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$objTypes[$ovValues['value']] = call_user_func_array($callback, $args);
}
* @return bool
*/
public static function hasReachedMaxLimit($customGroupId, $entityId) {
- //check whether the group is multiple
+ // check whether the group is multiple
$isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'is_multiple');
$isMultiple = ($isMultiple) ? TRUE : FALSE;
$hasReachedMax = FALSE;
}
else {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
- //count the number of entries for a entity
+ // count the number of entries for a entity
$sql = "SELECT COUNT(id) FROM {$tableName} WHERE entity_id = %1";
$params = array(1 => array($entityId, 'Integer'));
$count = CRM_Core_DAO::singleValueQuery($sql, $params);