X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FGroup.php;h=843fca7c4d34ba04bba63fbc480051f386b2bfb5;hb=e60f24ebb67f474bcc8437003b9c91d9853b3819;hp=c33a9319a24f5358a70531b9de9bfe3cf2ed4ab2;hpb=e612dc821894de0df124892584a5f52d44f5297a;p=civicrm-core.git diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index c33a9319a2..843fca7c4d 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1,7 +1,7 @@ copyValues($params); if ($group->find(TRUE)) { @@ -67,17 +68,17 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * Function to delete the group and all the object that connect to + * Delete the group and all the object that connect to * this group. Incredibly destructive * - * @param int $id group id + * @param int $id + * Group id. * - * @return null - * @access public + * @return NULL * @static * */ - static function discard($id) { + public static function discard($id) { CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray); $transaction = new CRM_Core_Transaction(); @@ -145,7 +146,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { * Returns an array of the contacts in the given group. * */ - static function getGroupContacts($id) { + public static function getGroupContacts($id) { $params = array(array('group', 'IN', array($id => 1), 0, 0)); list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id')); return $contacts; @@ -154,15 +155,15 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * Get the count of a members in a group with the specific status * - * @param int $id group id + * @param int $id + * Group id. * @param enum|string $status status of members in group * * @param bool $countChildGroups * * @return int count of members in the group with above status - * @access public */ - static function memberCount($id, $status = 'Added', $countChildGroups = FALSE) { + public static function memberCount($id, $status = 'Added', $countChildGroups = FALSE) { $groupContact = new CRM_Contact_DAO_GroupContact(); $groupIds = array($id); if ($countChildGroups) { @@ -201,16 +202,13 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * Get the list of member for a group id * - * @param $groupID + * @param int $groupID * @param bool $useCache * - * @internal param int $lngGroupId this is group id - * - * @return array $aMembers this arrray contains the list of members for this group id - * @access public + * @return array $aMembers this array contains the list of members for this group id * @static */ - static function &getMember($groupID, $useCache = TRUE) { + public static function &getMember($groupID, $useCache = TRUE) { $params = array(array('group', 'IN', array($groupID => 1), 0, 0)); $returnProperties = array('contact_id'); list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, 0, $useCache); @@ -226,19 +224,18 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * Returns array of group object(s) matching a set of one or Group properties. * - * @param null $params - * @param array $returnProperties Which properties should be included in the returned group objects. + * @param array $params + * Limits the set of groups returned. + * @param array $returnProperties + * Which properties should be included in the returned group objects. * (member_count should be last element.) * - * @param null $sort - * @param null $offset - * @param null $rowCount + * @param NULL $sort + * @param NULL $offset + * @param NULL $rowCount * - * @internal param array $param Array of one or more valid property_name=>value pairs. - * Limits the set of groups returned. - * @return An array of group objects. + * @return array of group objects. * - * @access public * * @todo other BAO functions that use returnProperties (e.g. Query Objects) receive the array flipped & filled with 1s and * add in essential fields (e.g. id). This should follow a regular pattern like the others @@ -307,15 +304,15 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * make sure that the user has permission to access this group + * Make sure that the user has permission to access this group * - * @param int $id the id of the object + * @param int $id + * The id of the object. * - * @return string the permission that the user has (or null) - * @access public + * @return string the permission that the user has (or NULL) * @static */ - static function checkPermission($id) { + public static function checkPermission($id) { $allGroups = CRM_Core_PseudoConstant::allGroup(); $permissions = NULL; @@ -348,10 +345,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * Create a new group * - * @param array $params Associative array of parameters + * @param array $params + * Associative array of parameters. * - * @return object|null The new group BAO (if created) - * @access public + * @return object|NULL The new group BAO (if created) * @static */ public static function &create(&$params) { @@ -381,7 +378,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $params['group_type'] = ''; } - $session = CRM_Core_Session::singleton( ); + $session = CRM_Core_Session::singleton(); $cid = $session->get('userID'); // this action is add if ($cid && empty($params['id'])) { @@ -399,7 +396,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { // use metadata to translate the array to the appropriate DB type or altering the param in the api layer, // or at least altering the param in same section as 'group_type' rather than repeating here. However, further down // we need the $params one to be in it's original form & we are not sure what test coverage we have on that - if(isset($group->parents) && is_array($group->parents)) { + if (isset($group->parents) && is_array($group->parents)) { $group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($group->parents) ) . CRM_Core_DAO::VALUE_SEPARATOR; @@ -507,10 +504,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * given a saved search compute the clause and the tables + * Given a saved search compute the clause and the tables * and store it for future use */ - function buildClause() { + public function buildClause() { $params = array(array('group', 'IN', array($this->id => 1), 0, 0)); if (!empty($params)) { @@ -530,10 +527,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * Defines a new smart group * - * @param array $params Associative array of parameters + * @param array $params + * Associative array of parameters. * - * @return object|null The new group BAO (if created) - * @access public + * @return object|NULL The new group BAO (if created) * @static */ public static function createSmartGroup(&$params) { @@ -556,28 +553,31 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * update the is_active flag in the db + * Update the is_active flag in the db * - * @param int $id id of the database record - * @param boolean $isActive value we want to set the is_active field + * @param int $id + * Id of the database record. + * @param bool $isActive + * Value we want to set the is_active field. * - * @return Object DAO object on sucess, null otherwise + * @return Object DAO object on sucess, NULL otherwise * @static */ - static function setIsActive($id, $isActive) { + public static function setIsActive($id, $isActive) { return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $id, 'is_active', $isActive); } /** - * build the condition to retrieve groups. + * Build the condition to retrieve groups. * - * @param string $groupType type of group(Access/Mailing) OR the key of the group + * @param string $groupType + * Type of group(Access/Mailing) OR the key of the group. * @param bool|\boolen $excludeHidden exclude hidden groups. * * @return string $condition * @static */ - static function groupTypeCondition($groupType = NULL, $excludeHidden = TRUE) { + public static function groupTypeCondition($groupType = NULL, $excludeHidden = TRUE) { $value = NULL; if ($groupType == 'Mailing') { $value = CRM_Core_DAO::VALUE_SEPARATOR . '2' . CRM_Core_DAO::VALUE_SEPARATOR; @@ -585,7 +585,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { elseif ($groupType == 'Access') { $value = CRM_Core_DAO::VALUE_SEPARATOR . '1' . CRM_Core_DAO::VALUE_SEPARATOR; } - elseif (!empty($groupType)){ + elseif (!empty($groupType)) { // ie we have been given the group key $value = CRM_Core_DAO::VALUE_SEPARATOR . $groupType . CRM_Core_DAO::VALUE_SEPARATOR; } @@ -608,13 +608,9 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * get permission relevant clauses + * Get permission relevant clauses * CRM-12209 * - * @internal param $existingClauses - * - * @internal param $clauses - * * @param bool $force * * @return array @@ -622,7 +618,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { public static function getPermissionClause($force = FALSE) { static $clause = 1; static $retrieved = FALSE; - if ((!$retrieved || $force ) && !CRM_Core_Permission::check('view all contacts') && !CRM_Core_Permission::check('edit all contacts')) { + if ((!$retrieved || $force) && !CRM_Core_Permission::check('view all contacts') && !CRM_Core_Permission::check('edit all contacts')) { //get the allowed groups for the current user $groups = CRM_ACL_API::group(CRM_ACL_API::VIEW); if (!empty($groups)) { @@ -648,13 +644,13 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { * This function create the hidden smart group when user perform * contact seach and want to send mailing to search contacts. * - * @param array $params ( reference ) an assoc array of name/value pairs + * @param array $params + * ( reference ) an assoc array of name/value pairs. * * @return array ( smartGroupId, ssId ) smart group id and saved search id - * @access public * @static */ - static function createHiddenSmartGroup($params) { + public static function createHiddenSmartGroup($params) { $ssId = CRM_Utils_Array::value('saved_search_id', $params); //add mapping record only for search builder saved search @@ -718,14 +714,14 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * This function is a wrapper for ajax group selector * - * @param array $params associated array for params record id. + * @param array $params + * Associated array for params record id. * * @return array $groupList associated array of group list * -rp = rowcount * -page= offset * @todo there seems little reason for the small number of functions that call this to pass in * params that then need to be translated in this function since they are coding them when calling - * @access public */ static public function getGroupListSelector(&$params) { // format the params @@ -757,10 +753,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { if (empty($params['parent_id']) && !empty($value['parents'])) { $groupIds = explode(',', $value['parents']); $title = array(); - foreach($groupIds as $gId) { + foreach ($groupIds as $gId) { $title[] = $allGroups[$gId]; } - $groupList[$id]['group_name'] .= '
'.ts('Child of').': ' . implode(', ', $title) . '
'; + $groupList[$id]['group_name'] .= '
' . ts('Child of') . ': ' . implode(', ', $title) . '
'; $value['class'] = array_diff($value['class'], array('crm-row-parent')); } $value['class'][] = 'crm-entity'; @@ -787,12 +783,12 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * This function to get list of groups * - * @param array $params associated array for params + * @param array $params + * Associated array for params. * * @return array - * @access public */ - static function getGroupList(&$params) { + public static function getGroupList(&$params) { $config = CRM_Core_Config::singleton(); $whereClause = self::whereClause($params, FALSE); @@ -979,7 +975,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $where .= " AND status = 'Added'"; } $dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE $where GROUP BY group_id"); - while($dao->fetch()) { + while ($dao->fetch()) { $values[$dao->group_id]['count'] = $dao->count; } } @@ -990,14 +986,14 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** * This function to get hierarchical list of groups (parent followed by children) * - * @param array $groupIDs array of group ids + * @param array $groupIDs + * Array of group ids. * - * @param null $parents + * @param NULL $parents * @param string $spacer * @param bool $titleOnly * * @return array - * @access public */ static function getGroupsHierarchy( $groupIDs, @@ -1043,14 +1039,14 @@ WHERE id IN $groupIdString $allGroups[$dao->id] = array( 'title' => $dao->title, 'visibility' => $dao->visibility, - 'description' => $dao->description + 'description' => $dao->description, ); if ($dao->parents == $parents) { $roots[] = array( 'id' => $dao->id, 'prefix' => '', - 'title' => $dao->title + 'title' => $dao->title, ); } else { @@ -1061,7 +1057,7 @@ WHERE id IN $groupIdString 'id' => $dao->id, 'prefix' => '', 'title' => $dao->title, - 'parents' => $parent + 'parents' => $parent, ); } } @@ -1086,7 +1082,7 @@ WHERE id IN $groupIdString $new_roots[] = array( 'id' => $row['id'], 'prefix' => $groups[$root['id']][0] . $spacer, - 'title' => $row['title'] + 'title' => $row['title'], ); unset($rows[$key]); } @@ -1123,11 +1119,11 @@ WHERE id IN $groupIdString } /** - * @param $params + * @param array $params * - * @return null|string + * @return NULL|string */ - static function getGroupCount(&$params) { + public static function getGroupCount(&$params) { $whereClause = self::whereClause($params, FALSE); $query = "SELECT COUNT(*) FROM civicrm_group groups"; @@ -1143,13 +1139,13 @@ WHERE {$whereClause}"; /** * Generate permissioned where clause for group search - * @param $params + * @param array $params * @param bool $sortBy * @param bool $excludeHidden * * @return string */ - static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) { + public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) { $values = array(); $title = CRM_Utils_Array::value('title', $params); if ($title) { @@ -1234,12 +1230,11 @@ WHERE {$whereClause}"; } /** - * Function to define action links + * Define action links * * @return array $links array of action links - * @access public */ - static function actionLinks() { + public static function actionLinks() { $links = array( CRM_Core_Action::VIEW => array( 'name' => ts('Contacts'), @@ -1276,11 +1271,11 @@ WHERE {$whereClause}"; /** * @param $whereClause - * @param $whereParams + * @param array $whereParams * * @return string */ - function pagerAtoZ($whereClause, $whereParams) { + public function pagerAtoZ($whereClause, $whereParams) { $query = " SELECT DISTINCT UPPER(LEFT(groups.title, 1)) as sort_name FROM civicrm_group groups @@ -1292,4 +1287,3 @@ WHERE {$whereClause}"; return CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE); } } -