X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FUFGroup.php;h=e1178aea75455bc4fada2c14b1ad8c7b0a20abd0;hb=a13f3d8c01e114b11c381b6ac3e64becae9380b1;hp=4e2662488e91e79033b1f82d16742f2609f56d0f;hpb=8b372a1767d5eac436f2243cfaf1068105639455;p=civicrm-core.git diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 4e2662488e..e1178aea75 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1,7 +1,7 @@ $field) { - if (!$field['in_selector'])unset($subset[$name]); + if (!$field['in_selector']) { unset($subset[$name]); + } } } $fields = array_merge($fields, $subset); @@ -253,37 +257,38 @@ 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 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 int $action + * What action are we doing. + * @param int $visibility + * Visibility of fields we are interested in. + * @param $searchable * @param bool $showAll - * @param string $restrict should we restrict based on a specified profile type - * + * @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 */ static function getFields( $id, $register = FALSE, $action = NULL, - $visibility = NULL, + $visibility = NULL, $searchable = NULL, - $showAll = FALSE, + $showAll = FALSE, $restrict = NULL, $skipPermission = FALSE, - $ctype = NULL, + $ctype = NULL, $permissionType = CRM_Core_Permission::CREATE, - $orderBy = 'field_name', + $orderBy = 'field_name', $orderProfiles = NULL ) { if (!is_array($id)) { @@ -321,8 +326,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { if ($orderProfiles AND count($profileIds) > 1) { $query .= " ORDER BY FIELD( g.id, {$gids} )"; } - $group = CRM_Core_DAO::executeQuery($query, $params); - $fields = array(); + $group = CRM_Core_DAO::executeQuery($query, $params); + $fields = array(); $validGroup = FALSE; while ($group->fetch()) { @@ -346,8 +351,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { if (empty($fields) && !$validGroup) { CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.', - array(1 => implode(',', $profileIds)) - )); + array(1 => implode(',', $profileIds)) + )); } else { self::reformatProfileFields($fields); @@ -360,17 +365,19 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * Format a list of UFFields for use with buildProfile. This is the in-memory analog * of getFields(). * - * @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 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 $searchable * @param bool $showAll * @param null $ctype * @param int $permissionType * - * @internal param bool $showall * @return array - * @see getFields + * @see self::getFields */ public static function formatUFFields( $groupArr, @@ -389,8 +396,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { // used by calculateGroupType, but I don't think the missing fields matter, and -- if // they did -- the obvious fix would produce mutual recursion. $ufGroupType = self::_calculateGroupType($fieldArrs); - $profileType = CRM_Core_BAO_UFField::calculateProfileType(implode(',',$ufGroupType)); - $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileTypeByGroupType(implode(',',$ufGroupType)); + $profileType = CRM_Core_BAO_UFField::calculateProfileType(implode(',', $ufGroupType)); + $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileTypeByGroupType(implode(',', $ufGroupType)); $importableFields = self::getImportableFields($showAll, $profileType, $contactActivityProfile); list($customFields, $addressCustomFields) = self::getCustomFields($ctype); @@ -417,7 +424,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * @param array $addressCustomFields * @param array $importableFields * @param array $customFields - * @param int $permissionType eg CRM_Core_Permission::CREATE + * @param int $permissionType + * Eg CRM_Core_Permission::CREATE. * @return array */ protected static function formatUFField( @@ -433,9 +441,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $addressCustom = FALSE; if (in_array($permissionType, array( - CRM_Core_Permission::CREATE, - CRM_Core_Permission::EDIT, - )) && + CRM_Core_Permission::CREATE, + CRM_Core_Permission::EDIT, + )) && in_array($field->field_name, array_keys($addressCustomFields)) ) { $addressCustom = TRUE; @@ -463,7 +471,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $formattedField = array( 'name' => $name, 'groupTitle' => $group->title, - 'groupName' => $group->name, + 'groupName' => $group->name, 'groupHelpPre' => empty($group->help_pre) ? '' : $group->help_pre, 'groupHelpPost' => empty($group->help_post) ? '' : $group->help_post, 'title' => $title, @@ -534,7 +542,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * @param bool $searchable * @param bool $showAll * @param int $visibility - * @param string $orderBy comma-delimited list of SQL columns + * @param string $orderBy + * Comma-delimited list of SQL columns. * @return string */ protected static function createUFFieldQuery($groupId, $searchable, $showAll, $visibility, $orderBy) { @@ -689,19 +698,21 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } /** - * check the data validity + * 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 + * @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 + * @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 */ - static function isValid($userID, $title, $register = FALSE, $action = NULL) { + public static function isValid($userID, $title, $register = FALSE, $action = NULL) { if ($register) { $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), @@ -731,30 +742,36 @@ 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? + * 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 bool $register + * Is this the registration form. + * @param bool $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 - * @access public */ - static function getEditHTML($userID, + static function getEditHTML( + $userID, $title, - $action = NULL, - $register = FALSE, - $reset = FALSE, - $profileID = NULL, + $action = NULL, + $register = FALSE, + $reset = FALSE, + $profileID = NULL, $doNotProcess = FALSE, - $ctype = NULL + $ctype = NULL ) { if ($register) { @@ -883,16 +900,15 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } /** - * searches for a contact in the db with similar attributes + * 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 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 string $contactType * - * @internal param bool $flatten should we flatten the input params - * - * @return contact_id if found, null otherwise - * @access public + * @return int|null contact_id if found, null otherwise * @static */ public static function findContact(&$params, $id = NULL, $contactType = 'Individual') { @@ -911,21 +927,24 @@ 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 $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 int $cid + * @param array $fields + * The profile fields of interest. + * @param array $values + * The values for the above fields. + * @param bool $searchable + * Searchable or not. + * @param array $componentWhere + * Component condition. + * @param bool $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 */ - public static function getValues($cid, &$fields, &$values, + public static function getValues( + $cid, &$fields, &$values, $searchable = TRUE, $componentWhere = NULL, $absolute = FALSE, $additionalWhereClause = NULL ) { @@ -945,7 +964,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields); $options = &$query->_options; - $details = $query->searchQuery( 0, 0, NULL, FALSE, FALSE, + $details = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $additionalWhereClause); if (!$details->fetch()) { return; @@ -954,8 +973,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $config = CRM_Core_Config::singleton(); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); - $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $multipleFields = array('url'); @@ -973,9 +992,11 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { // Create a unique, non-empty index for each field. $index = $field['title']; - if ($index === '') $index = ' '; - while (array_key_exists($index, $values)) + if ($index === '') { $index = ' '; + } + while (array_key_exists($index, $values)) { $index .= ' '; + } $params[$index] = $values[$index] = ''; $customFieldName = NULL; @@ -987,21 +1008,24 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $values[$index] = $details->$name; } elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) { - $dname = $name . '_display'; + $dname = $name . '_display'; $values[$index] = $details->$dname; - $name = $name . '_id'; + $name = $name . '_id'; $params[$index] = $details->$name; } elseif (in_array($name, array( - 'state_province', 'country', 'county'))) { + 'state_province', + 'country', + 'county' + ))) { $values[$index] = $details->$name; - $idx = $name . '_id'; + $idx = $name . '_id'; $params[$index] = $details->$idx; } elseif ($name === 'preferred_communication_method') { $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); $compref = array(); - $pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name); + $pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name); foreach ($pref as $k) { if ($k) { @@ -1038,8 +1062,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } elseif ($name == 'tag') { $entityTags = CRM_Core_BAO_EntityTag::getTag($cid); - $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); - $title = array(); + $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $title = array(); foreach ($entityTags as $tagId) { $title[] = $allTags[$tagId]; } @@ -1062,7 +1086,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { // get all contact subtypes $allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo(); // build contact subtype labels array - foreach( $contactSubTypeNames as $cstName ) { + foreach ($contactSubTypeNames as $cstName) { if ($cstName) { $contactSubTypeLabels[] = $allContactSubTypes[$cstName]['label']; } @@ -1090,7 +1114,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { if ($htmlType == 'File') { $entityId = $cid; if (!$cid && - $fieldType == 'Activity' && !empty($componentWhere[0][2])) { + $fieldType == 'Activity' && !empty($componentWhere[0][2]) + ) { $entityId = $componentWhere[0][2]; } @@ -1109,16 +1134,17 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $dao->data_type == 'Boolean' ) ) { - $customVal = (int )($details->{$name}); + $customVal = (int ) ($details->{$name}); } elseif (isset($dao) && property_exists($dao, 'data_type') && $dao->data_type == 'Float' ) { - $customVal = (float )($details->{$name}); + $customVal = (float ) ($details->{$name}); } elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, - $details->{$name} - ))) { + $details->{$name} + )) + ) { $customVal = $details->{$name}; } @@ -1136,8 +1162,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $params[$index] = $values[$index]; } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', - $cfID, 'is_search_range' - )) { + $cfID, 'is_search_range' + ) + ) { $customFieldName = "{$name}_from"; } } @@ -1150,7 +1177,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $values[$index] = "{$image_URL}"; } elseif (in_array($name, array( - 'birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) { + 'birth_date', + 'deceased_date', + 'membership_start_date', + 'membership_end_date', + 'join_date' + ))) { $values[$index] = CRM_Utils_Date::customFormat($details->$name); $params[$index] = CRM_Utils_Date::isoToMysql($details->$name); } @@ -1196,16 +1228,23 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $detailName = str_replace(' ', '_', $detailName); if (in_array($fieldName, array( - 'phone', 'im', 'email', 'openid'))) { + 'phone', + 'im', + 'email', + 'openid' + ))) { if ($type) { $detailName .= "-{$type}"; } } if (in_array($fieldName, array( - 'state_province', 'country', 'county'))) { + 'state_province', + 'country', + 'county' + ))) { $values[$index] = $details->$detailName; - $idx = $detailName . '_id'; + $idx = $detailName . '_id'; $params[$index] = $details->$idx; } elseif ($fieldName == 'im') { @@ -1236,8 +1275,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $detailName = "website-{$id}-{$fieldName}"; $url = CRM_Utils_System::fixURL($details->$detailName); if ($details->$detailName) { - $websiteTypeId = "website-{$id}-website_type_id"; - $websiteType = $websiteTypes[$details->$websiteTypeId]; + $websiteTypeId = "website-{$id}-website_type_id"; + $websiteType = $websiteTypes[$details->$websiteTypeId]; $values[$index] = "{$details->$detailName} ( {$websiteType} )"; } else { @@ -1270,9 +1309,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $url = $params[$index]; } elseif (in_array($htmlType, array( - 'CheckBox', 'Multi-Select', 'AdvMulti-Select', - 'Multi-Select State/Province', 'Multi-Select Country', - ))) { + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + 'Multi-Select State/Province', + 'Multi-Select Country', + ))) { $valSeperator = CRM_Core_DAO::VALUE_SEPARATOR; $selectedOptions = explode($valSeperator, $params[$index]); @@ -1329,11 +1371,11 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * Check if profile Group used by any module. * - * @param int $id profile Id + * @param int $id + * Profile Id. * * @return boolean * - * @access public * @static * */ @@ -1356,11 +1398,11 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { /** * Delete the profile Group. * - * @param int $id profile Id + * @param int $id + * Profile Id. * * @return boolean * - * @access public * @static * */ @@ -1386,18 +1428,27 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } /** - * function to add the UF Group + * Add the UF Group * - * @param array $params reference array contains the values submitted by the form - * @param array $ids reference array contains the id + * @param array $params + * Reference array contains the values submitted by the form. + * @param array $ids + * Reference array contains the id. * - * @access public * @static * * @return object */ - static function add(&$params, $ids = array()) { - $fields = array('is_active', 'add_captcha', 'is_map', 'is_update_dupe', 'is_edit_link', 'is_uf_link', 'is_cms_user'); + public static function add(&$params, $ids = array()) { + $fields = array( + 'is_active', + 'add_captcha', + 'is_map', + 'is_update_dupe', + 'is_edit_link', + 'is_uf_link', + 'is_cms_user' + ); foreach ($fields as $field) { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); } @@ -1405,6 +1456,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $params['limit_listings_group_id'] = CRM_Utils_Array::value('group', $params); $params['add_to_group_id'] = CRM_Utils_Array::value('add_contact_to_group', $params); + //CRM-15427 + if (!empty($params['group_type']) && is_array($params['group_type'])) { + $params['group_type'] = implode(',', $params['group_type']); + } $ufGroup = new CRM_Core_DAO_UFGroup(); $ufGroup->copyValues($params); @@ -1425,16 +1480,17 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { } /** - * Function to make uf join entries for an uf group + * Make uf join entries for an uf group * - * @param array $params (reference) an assoc array of name/value pairs - * @param int $ufGroupId ufgroup id + * @param array $params + * (reference) an assoc array of name/value pairs. + * @param int $ufGroupId + * Ufgroup id. * * @return void - * @access public * @static */ - static function createUFJoin(&$params, $ufGroupId) { + public static function createUFJoin(&$params, $ufGroupId) { $groupTypes = CRM_Utils_Array::value('uf_group_type', $params); // get ufjoin records for uf group @@ -1479,7 +1535,8 @@ SET weight = %1 WHERE uf_group_id = %2 AND ( entity_id IS NULL OR entity_id <= 0 ) "; - $p = array(1 => array($params['weight'], 'Integer'), + $p = array( + 1 => array($params['weight'], 'Integer'), 2 => array($ufGroupId, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $p); @@ -1495,19 +1552,17 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to get the UF Join records for an ufgroup id + * Get the UF Join records for an ufgroup id * - * @params int $ufGroupId uf group id - * @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 + * @param int $ufGroupId + * Uf group id. + * @param int $displayName + * If set return display name in array. + * @param int $status + * If set return module other than default modules (User Account/User registration/Profile). * * @return array $ufGroupJoinRecords * - * @access public * @static */ public static function getUFJoinRecord($ufGroupId = NULL, $displayName = NULL, $status = NULL) { @@ -1549,13 +1604,13 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * Function takes an associative array and creates a ufjoin record for ufgroup * - * @param array $params (reference) an assoc array of name/value pairs + * @param array $params + * (reference) an assoc array of name/value pairs. * - * @return object CRM_Core_BAO_UFJoin object - * @access public + * @return CRM_Core_BAO_UFJoin object * @static */ - static function addUFJoin(&$params) { + public static function addUFJoin(&$params) { $ufJoin = new CRM_Core_DAO_UFJoin(); $ufJoin->copyValues($params); $ufJoin->save(); @@ -1563,30 +1618,30 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to delete the uf join record for an uf group + * Delete the uf join record for an uf group * - * @param array $params (reference) an assoc array of name/value pairs + * @param array $params + * (reference) an assoc array of name/value pairs. * * @return void - * @access public * @static */ - static function delUFJoin(&$params) { + public static function delUFJoin(&$params) { $ufJoin = new CRM_Core_DAO_UFJoin(); $ufJoin->copyValues($params); $ufJoin->delete(); } /** - * Function to get the weight for ufjoin record + * Get the weight for ufjoin record * - * @param int $ufGroupId if $ufGroupId get update weight or add weight + * @param int $ufGroupId + * If $ufGroupId get update weight or add weight. * * @return int weight of the UFGroup - * @access public * @static */ - static function getWeight($ufGroupId = NULL) { + public static function getWeight($ufGroupId = NULL) { //calculate the weight $p = array(); if (!$ufGroupId) { @@ -1608,17 +1663,18 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to get the uf group for a module + * Get the uf group for a module * - * @param string $moduleName module name - * @param int $count no to increment the weight + * @param string $moduleName + * Module name. + * @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 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 */ public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) { @@ -1643,7 +1699,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $p[2] = array($moduleName, 'String'); } - // add permissioning for profiles only if not registration if (!$skipPermission) { $permissionClause = CRM_Core_Permission::ufGroupClause($op, 'civicrm_uf_group.'); @@ -1667,7 +1722,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) continue; } foreach ($selectFields as $key => $field) { - if($field == 'id') { + if ($field == 'id') { continue; } elseif ($field == 'name') { @@ -1685,18 +1740,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to filter ufgroups based on logged in user contact type - * - * @params int $ufGroupId uf group id (profile id) + * Filter ufgroups based on logged in user contact type * - * @param $ufGroupId - * @param null $contactID + * @param int $ufGroupId + * Uf group id (profile id). + * @param int $contactID * * @return boolean true or false * @static - * @access public */ - static function filterUFGroups($ufGroupId, $contactID = NULL) { + public static function filterUFGroups($ufGroupId, $contactID = NULL) { if (!$contactID) { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); @@ -1729,20 +1782,22 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to add profile field to a form + * Add profile field to a form * * @param CRM_Core_Form $form - * @param array $field properties - * @param int $mode profile mode + * @param array $field + * Properties. + * @param int $mode + * Profile mode. * @param int $contactId * @param bool $online - * @param string $usedFor for building up prefixed fieldname for special cases (e.g. onBehalf, Honor) + * @param string $usedFor + * For building up prefixed fieldname for special cases (e.g. onBehalf, Honor). * @param int $rowNumber * @param string $prefix * * @return null * @static - * @access public */ static function buildProfile( &$form, @@ -1751,7 +1806,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $contactId = NULL, $online = FALSE, $usedFor = NULL, - $rowNumber = NULL , + $rowNumber = NULL, $prefix = '' ) { $defaultValues = array(); @@ -1783,7 +1838,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $name = "field[$rowNumber][$fieldName]"; } elseif (!empty($prefix)) { - $name = $prefix ."[$fieldName]"; + $name = $prefix . "[$fieldName]"; } else { $name = $fieldName; @@ -1795,17 +1850,18 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $deleteExtra = ts('Are you sure you want to delete contact image.'); $deleteURL = array( CRM_Core_Action::DELETE => - array( - 'name' => ts('Delete Contact Image'), - 'url' => 'civicrm/contact/image', - 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%&action=delete', - 'extra' => - 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"', - ), + array( + 'name' => ts('Delete Contact Image'), + 'url' => 'civicrm/contact/image', + 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%&action=delete', + 'extra' => + 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"', + ), ); $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, - array('id' => $form->get('id'), + array( + 'id' => $form->get('id'), 'gid' => $form->get('gid'), ), ts('more'), @@ -1824,7 +1880,9 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $form->addChainSelect($name, array('label' => $title, 'required' => $required)); $config = CRM_Core_Config::singleton(); if (!in_array($mode, array( - CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH)) && + CRM_Profile_Form::MODE_EDIT, + CRM_Profile_Form::MODE_SEARCH + )) && $config->defaultContactStateProvince ) { $defaultValues[$name] = $config->defaultContactStateProvince; @@ -1835,7 +1893,9 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required, $selectAttributes); $config = CRM_Core_Config::singleton(); if (!in_array($mode, array( - CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH)) && + CRM_Profile_Form::MODE_EDIT, + CRM_Profile_Form::MODE_SEARCH + )) && $config->defaultContactCountry ) { $defaultValues[$name] = $config->defaultContactCountry; @@ -1860,13 +1920,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $form->add('select', $providerName, NULL, array( - '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required + '' => ts('- select -') + ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required ); } else { $form->add('select', $name . '-provider_id', $title, array( - '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required + '' => ts('- select -') + ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required ); } @@ -1879,18 +1941,21 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $form->addDate($name, $title, $required, array('formatType' => 'birth')); } elseif (in_array($fieldName, array( - 'membership_start_date', 'membership_end_date', 'join_date'))) { + 'membership_start_date', + 'membership_end_date', + 'join_date' + ))) { $form->addDate($name, $title, $required, array('formatType' => 'custom')); } - elseif (CRM_Utils_Array::value('name',$field) == 'membership_type') { + elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') { list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo(); $sel = &$form->addElement('hierselect', $name, $title); - $select = array('' => ts('- select -') ); - if(count($orgInfo) == 1 && $field['is_required']) { + $select = array('' => ts('- select -')); + if (count($orgInfo) == 1 && $field['is_required']) { // we only have one org - so we should default to it. Not sure about defaulting to first type // as it could be missed - so adding a select // however, possibly that is more similar to the membership form - if(count($types[1]) > 1) { + if (count($types[1]) > 1) { $types[1] = $select + $types[1]; } } @@ -1899,19 +1964,20 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $sel->setOptions(array($orgInfo, $types)); } - elseif (CRM_Utils_Array::value('name',$field) == 'membership_status') { + elseif (CRM_Utils_Array::value('name', $field) == 'membership_status') { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required + '' => ts('- select -') + ) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required ); } - elseif ($fieldName === 'gender_id') { - $genderOptions = array(); - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - foreach ($gender as $key => $var) { - $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key); + elseif (in_array($fieldName, array('gender_id', 'communication_style_id'))) { + $options = array(); + $pseudoValues = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $fieldName); + foreach ($pseudoValues as $key => $var) { + $options[$key] = $form->createElement('radio', NULL, ts($title), $var, $key); } - $group = $form->addGroup($genderOptions, $name, $title); + $group = $form->addGroup($options, $name, $title); if ($required) { $form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required'); } @@ -1968,7 +2034,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE); if (empty($profileType) || in_array($profileType, array( - 'Contact', 'Contribution', 'Participant', 'Membership'))) { + 'Contact', + 'Contribution', + 'Participant', + 'Membership' + )) + ) { $profileType = 'Individual'; } if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) { @@ -1980,7 +2051,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($greeting), $required + '' => ts('- select -') + ) + CRM_Core_PseudoConstant::greeting($greeting), $required ); // add custom greeting element $form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))), @@ -2036,7 +2108,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) 'onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false", ) - ), $required + ), $required ); $form->addRule($name, ts('Enter a valid Website.'), 'url'); @@ -2059,7 +2131,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } } elseif (in_array($fieldName, array( - 'receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) { + 'receive_date', + 'receipt_date', + 'thankyou_date', + 'cancel_date' + ))) { $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime')); } elseif ($fieldName == 'send_receipt') { @@ -2073,17 +2149,19 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo(); $sel = &$form->addElement('hierselect', $name, $title); $products = array( - '0' => ts('- select -')) + $products; + '0' => ts('- select -') + ) + $products; $sel->setOptions(array($products, $options)); } elseif ($fieldName == 'payment_instrument') { $form->add('select', $name, $title, - array(''=>ts( '- select -' )) + CRM_Contribute_PseudoConstant::paymentInstrument( ), $required ); + array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required); } - else if ($fieldName == 'financial_type' ) { + else if ($fieldName == 'financial_type') { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required + '' => ts('- select -') + ) + CRM_Contribute_PseudoConstant::financialType(), $required ); } elseif ($fieldName == 'contribution_status_id') { @@ -2099,14 +2177,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $form->add('select', $name, $title, array( - '' => ts('- select -')) + $contributionStatuses, $required + '' => ts('- select -') + ) + $contributionStatuses, $required ); } elseif ($fieldName == 'soft_credit_type') { $name = "soft_credit_type[$rowNumber]"; $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type") + '' => ts('- select -') + ) + CRM_Core_OptionGroup::values("soft_credit_type") ); //CRM-15350: choose SCT field default value as 'Gift' for membership use //else (for contribution), use configured SCT default value @@ -2122,7 +2202,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) elseif ($fieldName == 'contribution_page_id') { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"' + '' => ts('- select -') + ) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"' ); } elseif ($fieldName == 'participant_register_date') { @@ -2131,13 +2212,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) elseif ($fieldName == 'activity_status_id') { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required + '' => ts('- select -') + ) + CRM_Core_PseudoConstant::activityStatus(), $required ); } elseif ($fieldName == 'activity_engagement_level') { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required + '' => ts('- select -') + ) + CRM_Campaign_PseudoConstant::engagementLevel(), $required ); } elseif ($fieldName == 'activity_date_time') { @@ -2150,7 +2233,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required + '' => ts('- select -') + ) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required ); } elseif ($fieldName == 'participant_role') { @@ -2160,7 +2244,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) else { $form->add('select', $name, $title, array( - '' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required + '' => ts('- select -') + ) + CRM_Event_PseudoConstant::participantRole(), $required ); } } @@ -2180,7 +2265,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) )); $form->add('select', $name, $title, array( - '' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"' + '' => ts('- select -') + ) + $campaigns, $required, 'class="crm-select2 big"' ); } } @@ -2223,7 +2309,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) //add the rules if (in_array($fieldName, array( - 'non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) { + 'non_deductible_amount', + 'total_amount', + 'fee_amount', + 'net_amount' + ))) { $form->addRule($name, ts('Please enter a valid amount.'), 'money'); } if ($rule) { @@ -2234,27 +2324,25 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to set profile defaults + * Set profile defaults * - * @params int $contactId contact id - * @params array $fields associative array of fields - * @params array $defaults defaults array - * @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 int $contactId + * Contact id. + * @param array $fields + * Associative array of fields. + * @param array $defaults + * Defaults array. * @param bool $singleProfile - * @param null $componentId + * True for single profile else false(batch update). + * @param int $componentId + * Id for specific components like contribute, event etc. * @param null $component * * @return null * @static - * @access public */ static function setProfileDefaults($contactId, &$fields, &$defaults, - $singleProfile = TRUE, $componentId = NULL, $component = NULL + $singleProfile = TRUE, $componentId = NULL, $component = NULL ) { if (!$componentId) { //get the contact details @@ -2386,12 +2474,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) // type as per loc field and removed below code. $primaryLocationType = FALSE; if ($locTypeId == 'Primary') { - if (is_array($value) && array_key_exists($fieldName, $value)){ + if (is_array($value) && array_key_exists($fieldName, $value)) { $primaryLocationType = TRUE; - if (in_array($fieldName, $blocks)){ + if (in_array($fieldName, $blocks)) { $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, $fieldName); } - else{ + else { $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, 'address'); } } @@ -2463,7 +2551,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if (is_array($details)) { if ($fieldName === 'url' && !empty($details['website']) - && !empty($details['website'][$locTypeId])) { + && !empty($details['website'][$locTypeId]) + ) { $defaults[$fldName] = CRM_Utils_Array::value('url', $details['website'][$locTypeId]); } } @@ -2494,16 +2583,17 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to get profiles by type eg: pure Individual etc + * Get profiles by type eg: pure Individual etc * - * @param array $types associative array of types eg: types('Individual') - * @param boolean $onlyPure true if only pure profiles are required + * @param array $types + * Associative array of types eg: types('Individual'). + * @param bool $onlyPure + * True if only pure profiles are required. * * @return array $profiles associative array of profiles * @static - * @access public */ - static function getProfiles($types, $onlyPure = FALSE) { + public static function getProfiles($types, $onlyPure = FALSE) { $profiles = array(); $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); @@ -2522,17 +2612,18 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to check whether a profile is valid combination of + * Check whether a profile is valid combination of * required and/or optional profile types * - * @param array $required array of types those are required - * @param array $optional array of types those are optional + * @param array $required + * Array of types those are required. + * @param array $optional + * Array of types those are optional. * * @return array $profiles associative array of profiles * @static - * @access public */ - static function getValidProfiles($required, $optional = NULL) { + public static function getValidProfiles($required, $optional = NULL) { if (!is_array($required) || empty($required)) { return; } @@ -2553,17 +2644,18 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to check whether a profile is valid combination of + * Check whether a profile is valid combination of * required profile fields * - * @param array $ufId integer id of the profile - * @param array $required array of fields those are required in the profile + * @param array $ufId + * Integer id of the profile. + * @param array $required + * Array of fields those are required in the profile. * * @return array $profiles associative array of profiles * @static - * @access public */ - static function checkValidProfile($ufId, $required = NULL) { + public static function checkValidProfile($ufId, $required = NULL) { $validProfile = FALSE; if (!$ufId) { return $validProfile; @@ -2596,15 +2688,14 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to get default value for Register. + * Get default value for Register. * * @param $fields * @param $defaults * * @return mixed $defaults@static - * @access public */ - static function setRegisterDefaults(&$fields, &$defaults) { + public static function setRegisterDefaults(&$fields, &$defaults) { $config = CRM_Core_Config::singleton(); foreach ($fields as $name => $field) { if (substr($name, 0, 8) == 'country-') { @@ -2625,12 +2716,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * This function is to make a copy of a profile, including * all the fields in the profile * - * @param int $id the profile id to copy + * @param int $id + * The profile id to copy. * * @return void - * @access public */ - static function copy($id) { + public static function copy($id) { $fieldsFix = array('prefix' => array('title' => ts('Copy of '))); $copy = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFGroup', array('id' => $id), @@ -2665,7 +2756,8 @@ SET weight = %1 WHERE uf_group_id = %2 AND ( entity_id IS NULL OR entity_id <= 0 ) "; - $p = array(1 => array($maxWeight + 1, 'Integer'), + $p = array( + 1 => array($maxWeight + 1, 'Integer'), 2 => array($copy->id, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $p); @@ -2682,17 +2774,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * Process that send notification e-mails * - * @params int $contactId contact id - * @params array $values associative array of name/value pair - * - * @param $contactID - * @param $values + * @param int $contactID + * Contact id. + * @param array $values + * Associative array of name/value pair. * * @return void - * @access public */ - static function commonSendMail($contactID, &$values) { + public static function commonSendMail($contactID, &$values) { if (!$contactID || !$values) { return; @@ -2709,7 +2799,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $contactLink = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=$contactID", - TRUE, NULL, FALSE, FALSE, TRUE + TRUE, NULL, FALSE, FALSE, TRUE ); //get the default domain email address. @@ -2744,19 +2834,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) * for this group and notify email only if group's notify field is * set and field values are not empty * - * @params $gid group id - * @params $cid contact id - * @params $params associative array - * - * @param $gid - * @param $cid - * @param $params + * @param int $gid + * Group id. + * @param int $cid + * Contact id. + * @param array $params * @param bool $skipCheck * * @return array - * @access public */ - function checkFieldsEmptyValues($gid, $cid, $params, $skipCheck = FALSE) { + public function checkFieldsEmptyValues($gid, $cid, $params, $skipCheck = FALSE) { if ($gid) { if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid) || $skipCheck) { $values = array(); @@ -2781,19 +2868,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to assign uf fields to template - * - * @params int $gid group id - * @params array $values associative array of fields + * Assign uf fields to template * - * @param $gid - * @param $values - * @param $template + * @param int $gid + * Group id. + * @param array $values + * @param CRM_Core_Smarty $template * * @return void - * @access public */ - function profileDisplay($gid, $values, $template) { + public function profileDisplay($gid, $values, $template) { $groupTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'title'); $template->assign('grouptitle', $groupTitle); if (count($values)) { @@ -2804,15 +2888,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * Format fields for dupe Contact Matching * - * @param array $params associated array + * @param array $params + * Associated array. * - * @param null $contactId + * @param int $contactId * * @return array $data assoicated formatted array - * @access public * @static */ - static function formatFields($params, $contactId = NULL) { + public static function formatFields($params, $contactId = NULL) { if ($contactId) { // get the primary location type id and email list($name, $primaryEmail, $primaryLocationType) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId); @@ -2822,9 +2906,9 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $primaryLocationType = $defaultLocationType->id; } - $data = array(); - $locationType = array(); - $count = 1; + $data = array(); + $locationType = array(); + $count = 1; $primaryLocation = 0; foreach ($params as $key => $value) { list($fieldName, $locTypeId, $phoneTypeId) = explode('-', $key); @@ -2932,37 +3016,37 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $data['location'][$loc]['email'][$loc]['email'] = $primaryEmail; } - return $data; } /** - * calculate the profile type 'group_type' as per profile fields. + * Calculate the profile type 'group_type' as per profile fields. * - * @param $gId + * @param int $gId + * Profile id. * @param bool $includeTypeValues - * @param int $ignoreFieldId ignore particular profile field + * @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) { + public static function calculateGroupType($gId, $includeTypeValues = FALSE, $ignoreFieldId = NULL) { //get the profile fields. $ufFields = self::getFields($gId, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE); return self::_calculateGroupType($ufFields, $includeTypeValues, $ignoreFieldId); } /** - * calculate the profile type 'group_type' as per profile fields. + * Calculate the profile type 'group_type' as per profile fields. * * @param $ufFields * @param bool $includeTypeValues - * @param int $ignoreFieldId ignore perticular profile field + * @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) { + public static function _calculateGroupType($ufFields, $includeTypeValues = FALSE, $ignoreFieldId = NULL) { $groupType = $groupTypeValues = $customFieldIds = array(); if (!empty($ufFields)) { foreach ($ufFields as $fieldName => $fieldValue) { @@ -3025,14 +3109,13 @@ 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 $gId - * @param Array $groupTypes With key having group type names + * @param int $gId + * @param array $groupTypes + * With key having group type names. * - * @internal param int $gid profile id * @return Boolean */ - static function updateGroupTypes($gId, $groupTypes = array( - )) { + public static function updateGroupTypes($gId, $groupTypes = array()) { if (!is_array($groupTypes) || !$gId) { return FALSE; } @@ -3043,7 +3126,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $componentGroupTypes = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case'); - $validGroupTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes()); + $validGroupTypes = array_merge(array( + 'Contact', + 'Individual', + 'Organization', + 'Household' + ), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes()); $gTypes = $gTypeValues = array(); @@ -3091,14 +3179,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) /** * Create a "group_type" string * - * @param array $coreTypes e.g. array('Individual','Contact','Student') - * @param array $subTypes e.g. array('ActivityType' => array(7, 11)) + * @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) { + public static function encodeGroupType($coreTypes, $subTypes, $delim = CRM_Core_DAO::VALUE_SEPARATOR) { $groupTypeExpr = ''; if ($coreTypes) { $groupTypeExpr .= implode(',', $coreTypes); @@ -3106,7 +3196,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if ($subTypes) { //CRM-15427 Allow Multiple subtype filtering //if (count($subTypes) > 1) { - //throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget."); + //throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget."); //} foreach ($subTypes as $subType => $subTypeIds) { $groupTypeExpr .= $delim . $subType . ':' . implode(':', $subTypeIds); @@ -3118,10 +3208,14 @@ 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 * @@ -3137,25 +3231,25 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $componentBAO = $componentSubType = NULL; switch ($component) { case 'Membership': - $componentBAO = 'CRM_Member_BAO_Membership'; + $componentBAO = 'CRM_Member_BAO_Membership'; $componentBAOName = 'Membership'; $componentSubType = array('membership_type_id'); break; case 'Contribute': - $componentBAO = 'CRM_Contribute_BAO_Contribution'; + $componentBAO = 'CRM_Contribute_BAO_Contribution'; $componentBAOName = 'Contribution'; - $componentSubType = array( 'financial_type_id' ); + $componentSubType = array('financial_type_id'); break; case 'Event': - $componentBAO = 'CRM_Event_BAO_Participant'; + $componentBAO = 'CRM_Event_BAO_Participant'; $componentBAOName = 'Participant'; $componentSubType = array('role_id', 'event_id', 'event_type_id'); break; case 'Activity': - $componentBAO = 'CRM_Activity_BAO_Activity'; + $componentBAO = 'CRM_Activity_BAO_Activity'; $componentBAOName = 'Activity'; $componentSubType = array('activity_type_id'); break; @@ -3171,7 +3265,17 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $formattedGroupTree = array(); - $dateTimeFields = array('participant_register_date', 'activity_date_time', 'receive_date', 'receipt_date', 'cancel_date', 'thankyou_date', 'membership_start_date', 'membership_end_date', 'join_date'); + $dateTimeFields = array( + 'participant_register_date', + 'activity_date_time', + 'receive_date', + 'receipt_date', + 'cancel_date', + 'thankyou_date', + 'membership_start_date', + 'membership_end_date', + 'join_date' + ); foreach ($fields as $name => $field) { $fldName = $isStandalone ? $name : "field[$componentId][$name]"; if (in_array($name, $dateTimeFields)) { @@ -3184,17 +3288,21 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $defaults[$fldName] = $values[$name]; } elseif ($name == 'participant_note') { - $noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant'); + $noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant'); $defaults[$fldName] = array_pop($noteDetails); } elseif (in_array($name, array( - 'financial_type', 'payment_instrument', 'participant_status', 'participant_role'))) { + 'financial_type', + 'payment_instrument', + 'participant_status', + 'participant_role' + ))) { $defaults[$fldName] = $values["{$name}_id"]; } elseif ($name == 'membership_type') { // since membership_type field is a hierselect - $defaults[$fldName][0] = - CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',$values['membership_type_id'],'member_of_contact_id','id'); + CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'member_of_contact_id', 'id'); $defaults[$fldName][1] = $values['membership_type_id']; } elseif ($name == 'membership_status') { @@ -3257,11 +3365,12 @@ 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 + * @param array $appendProfiles + * Name of profile(s) to append to each link. * * @return array */ - static function getCreateLinks($profiles = '', $appendProfiles = array()) { + public static function getCreateLinks($profiles = '', $appendProfiles = array()) { // Default to contact profiles if (!$profiles) { $profiles = array('new_individual', 'new_organization', 'new_household'); @@ -3274,12 +3383,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) )); $links = $append = array(); if (!empty($retrieved['values'])) { - foreach($retrieved['values'] as $id => $profile) { + foreach ($retrieved['values'] as $id => $profile) { if (in_array($profile['name'], $profiles)) { $links[] = array( 'label' => $profile['title'], 'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id", - NULL, NULL, FALSE, FALSE, TRUE) , + NULL, NULL, FALSE, FALSE, TRUE), 'type' => ucfirst(str_replace('new_', '', $profile['name'])), ); } @@ -3297,14 +3406,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to retrieve groups of profiles + * Retrieve groups of profiles * - * @param integer $profileID id of the profile + * @param int $profileID + * Id of the profile. * * @return array returns array * @static */ - static function profileGroups($profileID) { + public static function profileGroups($profileID) { $groupTypes = array(); $profileTypes = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'group_type'); if ($profileTypes) { @@ -3315,15 +3425,17 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } /** - * Function to alter contact params by filtering existing subscribed groups and returns + * Alter contact params by filtering existing subscribed groups and returns * unsubscribed groups array for subscription. * - * @param array $params contact params - * @param int $contactId user contact id + * @param array $params + * Contact params. + * @param int $contactId + * User contact id. * * @return array $subscribeGroupIds This contains array of groups for subscription */ - static function getDoubleOptInGroupIds(&$params, $contactId = NULL) { + public static function getDoubleOptInGroupIds(&$params, $contactId = NULL) { $config = CRM_Core_Config::singleton(); $subscribeGroupIds = array(); @@ -3389,15 +3501,15 @@ SELECT group_id } /** - * Function to check if we are rendering mixed profiles + * Check if we are rendering mixed profiles * - * @param array $profileIds associated array of profile ids + * @param array $profileIds + * Associated array of profile ids. * * @return boolean $mixProfile true if profile is mixed * @static - * @access public */ - static function checkForMixProfiles($profileIds) { + public static function checkForMixProfiles($profileIds) { $mixProfile = FALSE; $contactTypes = array('Individual', 'Household', 'Organization'); @@ -3442,13 +3554,12 @@ SELECT group_id } /** - * Function to determine of we show overlay profile or not + * Determine of we show overlay profile or not * * @return boolean true if profile should be shown else false * @static - * @access public */ - static function showOverlayProfile() { + public static function showOverlayProfile() { $showOverlay = TRUE; // get the id of overlay profile @@ -3467,19 +3578,15 @@ SELECT group_id } /** - * function to get group type values of the profile - * - * @params Integer $profileId Profile Id - * @params String $groupType Group Type + * Get group type values of the profile * - * @param $profileId - * @param null $groupType + * @param int $profileId + * @param string $groupType * * @return Array group type values * @static - * @access public */ - static function groupTypeValues($profileId, $groupType = NULL) { + public static function groupTypeValues($profileId, $groupType = NULL) { $groupTypeValue = array(); $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileId, 'group_type'); @@ -3521,7 +3628,7 @@ SELECT group_id /** * @return bool|object */ - static function isProfileDoubleOptin() { + public static function isProfileDoubleOptin() { // check for double optin $config = CRM_Core_Config::singleton(); if (in_array('CiviMail', $config->enableComponents)) { @@ -3535,7 +3642,7 @@ SELECT group_id /** * @return bool|object */ - static function isProfileAddToGroupDoubleOptin() { + public static function isProfileAddToGroupDoubleOptin() { // check for add to group double optin $config = CRM_Core_Config::singleton(); if (in_array('CiviMail', $config->enableComponents)) { @@ -3547,18 +3654,18 @@ SELECT group_id } /** - * get profiles used for batch entry + * Get profiles used for batch entry * * @return array profileIds profile ids * @static */ - static function getBatchProfiles() { + public static function getBatchProfiles() { $query = "SELECT id FROM civicrm_uf_group WHERE name IN ('contribution_batch_entry', 'membership_batch_entry')"; - $dao = CRM_Core_DAO::executeQuery( $query ); + $dao = CRM_Core_DAO::executeQuery($query); $profileIds = array(); - while( $dao->fetch() ) { + while ($dao->fetch()) { $profileIds[$dao->id] = $dao->id; } return $profileIds; @@ -3572,8 +3679,8 @@ SELECT group_id * * @return array|null */ - static function shiftMultiRecordFields(&$source, &$destination, $returnMultiSummaryFields = FALSE) { - $multiSummaryFields = $returnMultiSummaryFields ? array( ) : NULL; + public static function shiftMultiRecordFields(&$source, &$destination, $returnMultiSummaryFields = FALSE) { + $multiSummaryFields = $returnMultiSummaryFields ? array() : NULL; foreach ($source as $field => $properties) { if (!CRM_Core_BAO_CustomField::getKeyID($field)) { continue; @@ -3594,15 +3701,16 @@ SELECT group_id /** * This is function is used to format pseudo fields * - * @param array $fields associated array of profile fields + * @param array $fields + * Associated array of profile fields. * * @static */ - static function reformatProfileFields(&$fields) { + public static function reformatProfileFields(&$fields) { //reformat fields array foreach ($fields as $name => $field) { //reformat phone and extension field - if ( substr($field['name'], 0, 13) == 'phone_and_ext') { + if (substr($field['name'], 0, 13) == 'phone_and_ext') { $fieldSuffix = str_replace('phone_and_ext-', '', $field['name']); // retain existing element properties and just update and replace key @@ -3612,7 +3720,7 @@ SELECT group_id // add additional phone extension field $fields["phone_ext-{$fieldSuffix}"] = $field; - $fields["phone_ext-{$fieldSuffix}"]['title'] = $field['title'] .' - '.ts('Ext.'); + $fields["phone_ext-{$fieldSuffix}"]['title'] = $field['title'] . ' - ' . ts('Ext.'); $fields["phone_ext-{$fieldSuffix}"]['name'] = "phone_ext-{$fieldSuffix}"; $fields["phone_ext-{$fieldSuffix}"]['where'] = 'civicrm_phone.phone_ext'; $fields["phone_ext-{$fieldSuffix}"]['skipDisplay'] = 1;