<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
*/
public static function &create(&$params) {
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
}
else {
// form the name only if missing: CRM-627
$nameParam = CRM_Utils_Array::value('name', $params, NULL);
- if (!$nameParam &&
- !CRM_Utils_Array::value('id', $params)
- ) {
+ if (!$nameParam && empty($params['id'])) {
$params['name'] = CRM_Utils_String::titleToVar($params['title']);
}
array_keys($group->parents)
) . CRM_Core_DAO::VALUE_SEPARATOR;
}
- if (!CRM_Utils_Array::value('id', $params) &&
+ if (empty($params['id']) &&
!$nameParam
) {
$group->name .= "_tmp";
return NULL;
}
- if (!CRM_Utils_Array::value('id', $params) &&
+ if (empty($params['id']) &&
!$nameParam
) {
$group->name = substr($group->name, 0, -4) . "_{$group->id}";
$group->save();
// add custom field values
- if (CRM_Utils_Array::value('custom', $params)) {
+ if (!empty($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
}
}
}
- if (CRM_Utils_Array::value('organization_id', $params)) {
+ if (!empty($params['organization_id'])) {
$groupOrg = array();
$groupOrg = $params;
$groupOrg['group_id'] = $group->id;
CRM_Contact_BAO_GroupContactCache::add($group->id);
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
}
else {
* @static
*/
public static function createSmartGroup(&$params) {
- if (CRM_Utils_Array::value('formValues', $params)) {
+ if (!empty($params['formValues'])) {
$ssParams = $params;
unset($ssParams['id']);
if (isset($ssParams['saved_search_id'])) {
}
$smartGroupId = NULL;
- if (CRM_Utils_Array::value('saved_search_id', $params)) {
+ if (!empty($params['saved_search_id'])) {
$smartGroupId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $ssId, 'id', 'saved_search_id');
}
else {
* @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
*/
- public function getGroupListSelector(&$params) {
+ static public function getGroupListSelector(&$params) {
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$groups = CRM_Contact_BAO_Group::getGroupList($params);
//skip total if we are making call to show only children
- if ( !CRM_Utils_Array::value('parent_id', $params) ) {
+ if (empty($params['parent_id'])) {
// add total
$params['total'] = CRM_Contact_BAO_Group::getGroupCount($params);
$groupList[$id]['class'] = implode(' ', $value['class']);
// append parent names if in search mode
- if ( !CRM_Utils_Array::value('parent_id', $params) &&
- CRM_Utils_Array::value( 'parents', $value ) ) {
+ if (empty($params['parent_id']) && !empty($value['parents'])) {
$groupIds = explode(',', $value['parents']);
$title = array();
foreach($groupIds as $gId) {
}
$groupList[$id]['group_description'] = CRM_Utils_Array::value('description', $value);
- if ( CRM_Utils_Array::value('group_type', $value) ) {
+ if (!empty($value['group_type'])) {
$groupList[$id]['group_type'] = $value['group_type'];
}
else {
$allTypes = CRM_Core_OptionGroup::values('group_type');
$values = array();
+ $visibility = CRM_Core_SelectValues::ufVisibility();
+
while ($object->fetch()) {
$permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title);
//@todo CRM-12209 introduced an ACL check in the whereClause function
$action = $action & CRM_Core_Action::mask($groupPermissions);
- $values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility',
- $values[$object->id]['visibility']
- );
+ $values[$object->id]['visibility'] = $visibility[$values[$object->id]['visibility']];
+
if (isset($values[$object->id]['group_type'])) {
$groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR,
substr($values[$object->id]['group_type'], 1, -1)
$whereClause = self::whereClause($params, FALSE);
$query = "SELECT COUNT(*) FROM civicrm_group groups";
- if (CRM_Utils_Array::value('created_by', $params)) {
+ if (!empty($params['created_by'])) {
$query .= "
INNER JOIN civicrm_contact createdBy
ON createdBy.id = groups.created_id";
return CRM_Core_DAO::singleValueQuery($query, $params);
}
- function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) {
+ static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) {
$values = array();
$clauses = array();