X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FUFGroup.php;h=cd7a474c1250eb3b34c83bcf9fc657cb0ca2b53f;hb=50bf705c3ad6f591a0e375713b7daf2e98f919b7;hp=6a4bbdf61c8e331a54dde95041cf875b9f00c774;hpb=2356bb8512ca31ab2a2ce124a4d1eda7be4f9c54;p=civicrm-core.git diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 6a4bbdf61c..cd7a474c12 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -128,8 +128,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * get all the registration fields * - * @param int $action what action are we doing - * @param int $mode mode + * @param int $action what action are we doing + * @param int $mode mode + * + * @param null $ctype * * @return array the fields that are needed for registration * @static @@ -181,12 +183,15 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * get all the listing fields * - * @param int $action what action are we doing - * @param int $visibility visibility of fields we are interested in - * @param bool $considerSelector whether to consider the in_selector parameter - * @param array $ufGroupIds + * @param int $action what action are we doing + * @param int $visibility visibility of fields we are interested in + * @param bool $considerSelector whether to consider the in_selector parameter + * @param array $ufGroupIds * @param boolean $searchable * + * @param null $restrict + * @param bool $skipPermission + * @param int $permissionType * @return array the fields that are listings related * @static * @access public @@ -248,14 +253,21 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * and format for use with buildProfile. This is the SQL analog of * formatUFFields(). * - * @param mix $id the id of the UF group or ids of ufgroup - * @param int $register are we interested in registration fields - * @param int $action what action are we doing - * @param int $visibility visibility of fields we are interested in + * @param mix $id the id of the UF group or ids of ufgroup + * @param bool|int $register are we interested in registration fields + * @param int $action what action are we doing + * @param int $visibility visibility of fields we are interested in * @param $searchable - * @param boolean $showall - * @param string $restrict should we restrict based on a specified profile type + * @param bool $showAll + * @param string $restrict should we restrict based on a specified profile type + * + * @param bool $skipPermission + * @param null $ctype + * @param int $permissionType + * @param string $orderBy + * @param null $orderProfiles * + * @internal param bool $showall * @return array the fields that belong to this ufgroup(s) * @static * @access public @@ -285,10 +297,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $gids = implode(',', $profileIds); $params = array(); if ($restrict) { - $query = "SELECT g.* from civicrm_uf_group g, civicrm_uf_join j + $query = "SELECT g.* from civicrm_uf_group g + LEFT JOIN civicrm_uf_join j ON (j.uf_group_id = g.id) WHERE g.id IN ( {$gids} ) - AND j.uf_group_id IN ( {$gids} ) - AND j.module = %1 + AND ((j.uf_group_id IN ( {$gids} ) AND j.module = %1) OR g.is_reserved = 1 ) "; $params = array(1 => array($restrict, 'String')); } @@ -350,9 +362,13 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * * @param array $groupArr (mimic CRM_UF_DAO_UFGroup) * @param array $fieldArrs list of fields (each mimics CRM_UF_DAO_UFField) - * @param bool $visibility visibility of fields we are interested in + * @param bool $visibility visibility of fields we are interested in * @param bool $searchable - * @param bool $showall + * @param bool $showAll + * @param null $ctype + * @param int $permissionType + * + * @internal param bool $showall * @return array * @see getFields */ @@ -596,6 +612,13 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { return TRUE; } + /** + * @param $showAll + * @param $profileType + * @param $contactActivityProfile + * + * @return array + */ protected static function getImportableFields($showAll, $profileType, $contactActivityProfile) { if (!$showAll) { $importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, FALSE, FALSE, TRUE, TRUE); @@ -643,6 +666,11 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { return $locationFields; } + /** + * @param $ctype + * + * @return mixed + */ protected static function getCustomFields($ctype) { static $customFieldCache = array(); if (!isset($customFieldCache[$ctype])) { @@ -663,11 +691,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * check the data validity * - * @param int $userID the user id that we are actually editing - * @param string $title the title of the group we are interested in - * @pram boolean $register is this the registrtion form - * @param int $action the action of the form + * @param int $userID the user id that we are actually editing + * @param string $title the title of the group we are interested in + * @param bool $register + * @param int $action the action of the form * + * @pram boolean $register is this the registrtion form * @return boolean true if form is valid * @static * @access public @@ -704,12 +733,15 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * get the html for the form that represents this particular group * - * @param int $userID the user id that we are actually editing - * @param string $title the title of the group we are interested in - * @param int $action the action of the form - * @param boolean $register is this the registration form - * @param boolean $reset should we reset the form? - * @param int $profileID do we have the profile ID? + * @param int $userID the user id that we are actually editing + * @param string $title the title of the group we are interested in + * @param int $action the action of the form + * @param boolean $register is this the registration form + * @param boolean $reset should we reset the form? + * @param int $profileID do we have the profile ID? + * + * @param bool $doNotProcess + * @param null $ctype * * @return string the html for the form on success, otherwise empty string * @static @@ -854,8 +886,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * searches for a contact in the db with similar attributes * * @param array $params the list of values to be used in the where clause - * @param int $id the current contact id (hence excluded from matching) - * @param boolean $flatten should we flatten the input params + * @param int $id the current contact id (hence excluded from matching) + * @param string $contactType + * + * @internal param bool $flatten should we flatten the input params * * @return contact_id if found, null otherwise * @access public @@ -877,13 +911,16 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * Given a contact id and a field set, return the values from the db * for this contact * - * @param int $id the contact id - * @param array $fields the profile fields of interest - * @param array $values the values for the above fields - * @param boolean $searchable searchable or not - * @param array $componentWhere component condition - * @param boolean $absolute return urls in absolute form (useful when sending an email) + * @param $cid + * @param array $fields the profile fields of interest + * @param array $values the values for the above fields + * @param boolean $searchable searchable or not + * @param array $componentWhere component condition + * @param boolean $absolute return urls in absolute form (useful when sending an email) * + * @param null $additionalWhereClause + * + * @internal param int $id the contact id * @return void * @access public * @static @@ -921,7 +958,6 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $multipleFields = array('url'); - $nullIndex = $nullValueIndex = ' '; //start of code to set the default values foreach ($fields as $name => $field) { @@ -935,18 +971,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { continue; } + // Create a unique, non-empty index for each field. $index = $field['title']; - //handle for the label not set for the field - if (empty($field['title'])) { - $index = $nullIndex; - $nullIndex .= $nullIndex; - } + if ($index === '') $index = ' '; + while (array_key_exists($index, $values)) + $index .= ' '; - //handle the case to avoid re-write where the profile field labels are the same - if (array_key_exists($index, $values)) { - $index .= $nullValueIndex; - $nullValueIndex .= $nullValueIndex; - } $params[$index] = $values[$index] = ''; $customFieldName = NULL; // hack for CRM-665 @@ -1470,6 +1500,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params int $displayName if set return display name in array * @params int $status if set return module other than default modules (User Account/User registration/Profile) * + * @param null $ufGroupId + * @param null $displayName + * @param null $status + * * @return array $ufGroupJoinRecords * * @access public @@ -1576,11 +1610,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * Function to get the uf group for a module * * @param string $moduleName module name - * @param int $count no to increment the weight - * @param bool $skipPermision - whether to add permission clause - * @param int $op - which operation (view, edit, create, etc) to check permission for + * @param int $count no to increment the weight + * @param bool $skipPermission + * @param int $op - which operation (view, edit, create, etc) to check permission for * @param array|NULL $returnFields list of UFGroup fields to return; NULL for default * + * @internal param bool $skipPermision - whether to add permission clause * @return array $ufGroups array of ufgroups for a module * @access public * @static @@ -1653,6 +1688,9 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * * @params int $ufGroupId uf group id (profile id) * + * @param $ufGroupId + * @param null $contactID + * * @return boolean true or false * @static * @access public @@ -1698,6 +1736,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params int $contactID contact id * @params string $usedFor for building up prefixed fieldname for special cases (e.g. onBehalf, Honor) * + * @param $form + * @param $field + * @param $mode + * @param null $contactId + * @param bool $online + * @param null $usedFor + * @param null $rowNumber + * @param string $prefix + * * @return null * @static * @access public @@ -2211,6 +2258,13 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params boolean $singleProfile true for single profile else false(batch update) * @params int $componentId id for specific components like contribute, event etc * + * @param $contactId + * @param $fields + * @param $defaults + * @param bool $singleProfile + * @param null $componentId + * @param null $component + * * @return null * @static * @access public @@ -2420,8 +2474,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } else { if (is_array($details)) { - if ($fieldName === 'url' - && !empty($details['website']) + if ($fieldName === 'url' + && !empty($details['website']) && !empty($details['website'][$locTypeId])) { $defaults[$fldName] = CRM_Utils_Array::value('url', $details['website'][$locTypeId]); } @@ -2557,8 +2611,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * Function to get default value for Register. * - * @return $defaults - * @static + * @param $fields + * @param $defaults + * + * @return mixed $defaults@static * @access public */ static function setRegisterDefaults(&$fields, &$defaults) { @@ -2642,6 +2698,9 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params int $contactId contact id * @params array $values associative array of name/value pair * + * @param $contactID + * @param $values + * * @return void * @access public */ @@ -2702,6 +2761,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params $cid contact id * @params $params associative array * + * @param $gid + * @param $cid + * @param $params + * @param bool $skipCheck + * * @return array * @access public */ @@ -2735,6 +2799,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @params int $gid group id * @params array $values associative array of fields * + * @param $gid + * @param $values + * @param $template + * * @return void * @access public */ @@ -2751,6 +2819,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * * @param array $params associated array * + * @param null $contactId + * * @return array $data assoicated formatted array * @access public * @static @@ -2882,9 +2952,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * calculate the profile type 'group_type' as per profile fields. * - * @param int $gid profile id + * @param $gId + * @param bool $includeTypeValues * @param int $ignoreFieldId ignore particular profile field * + * @internal param int $gid profile id * @return array list of calculated group type */ static function calculateGroupType($gId, $includeTypeValues = FALSE, $ignoreFieldId = NULL) { @@ -2896,9 +2968,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * calculate the profile type 'group_type' as per profile fields. * - * @param int $gid profile id + * @param $ufFields + * @param bool $includeTypeValues * @param int $ignoreFieldId ignore perticular profile field * + * @internal param int $gid profile id * @return array list of calculated group type */ static function _calculateGroupType($ufFields, $includeTypeValues = FALSE, $ignoreFieldId = NULL) { @@ -2964,9 +3038,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * BirthDate + SurveyOrPhoneField + SurveyOnlyField Individual,Activity\0ActivityType:2:28 * BirthDate + StudentField + Subject + SurveyOnlyField Individual,Activity,Student\0ActivityType:28 * - * @param Integer $gid profile id - * @param Array $groupTypes With key having group type names + * @param $gId + * @param Array $groupTypes With key having group type names * + * @internal param int $gid profile id * @return Boolean */ static function updateGroupTypes($gId, $groupTypes = array( @@ -3032,6 +3107,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * @param array $coreTypes e.g. array('Individual','Contact','Student') * @param array $subTypes e.g. array('ActivityType' => array(7, 11)) * @param string $delim + * + * @return string * @throws CRM_Core_Exception */ static function encodeGroupType($coreTypes, $subTypes, $delim = CRM_Core_DAO::VALUE_SEPARATOR) { @@ -3053,10 +3130,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * This function is used to setDefault componet specific profile fields. * - * @param array $fields profile fields. - * @param int $componentId componetID - * @param string $component component name - * @param array $defaults an array of default values. + * @param array $fields profile fields. + * @param int $componentId componetID + * @param string $component component name + * @param array $defaults an array of default values. + * + * @param bool $isStandalone * * @return void. */ @@ -3186,6 +3265,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * @param array|string $profiles - name of profile(s) to create links for * @param array $appendProfiles - name of profile(s) to append to each link + * + * @return array */ static function getCreateLinks($profiles = '', $appendProfiles = array()) { // Default to contact profiles @@ -3368,7 +3449,7 @@ SELECT group_id } /** - * Funtion to determine of we show overlay profile or not + * Function to determine of we show overlay profile or not * * @return boolean true if profile should be shown else false * @static @@ -3398,6 +3479,9 @@ SELECT group_id * @params Integer $profileId Profile Id * @params String $groupType Group Type * + * @param $profileId + * @param null $groupType + * * @return Array group type values * @static * @access public @@ -3441,6 +3525,9 @@ SELECT group_id return $groupTypeValue; } + /** + * @return bool|object + */ static function isProfileDoubleOptin() { // check for double optin $config = CRM_Core_Config::singleton(); @@ -3452,6 +3539,9 @@ SELECT group_id return FALSE; } + /** + * @return bool|object + */ static function isProfileAddToGroupDoubleOptin() { // check for add to group double optin $config = CRM_Core_Config::singleton(); @@ -3481,6 +3571,14 @@ SELECT group_id return $profileIds; } + /** + * @todo what do I do? + * @param $source + * @param $destination + * @param bool $returnMultiSummaryFields + * + * @return array|null + */ static function shiftMultiRecordFields(&$source, &$destination, $returnMultiSummaryFields = FALSE) { $multiSummaryFields = $returnMultiSummaryFields ? array( ) : NULL; foreach ($source as $field => $properties) {