Пример #1
0
 /**
  * Create a new group.
  *
  * @param array $params
  *
  * @return CRM_Contact_BAO_Group|NULL
  *   The new group BAO (if created)
  */
 public static function &create(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
     }
     // form the name only if missing: CRM-627
     $nameParam = CRM_Utils_Array::value('name', $params, NULL);
     if (!$nameParam && empty($params['id'])) {
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $session = CRM_Core_Session::singleton();
     $cid = $session->get('userID');
     // this action is add
     if ($cid && empty($params['id'])) {
         $params['created_id'] = $cid;
     }
     // this action is update
     if ($cid && !empty($params['id'])) {
         $params['modified_id'] = $cid;
     }
     $group = new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     //@todo very hacky fix for the fact this function wants to receive 'parents' as an array further down but
     // needs it as a separated string for the DB. Preferred approaches are having the copyParams or save fn
     // 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)) {
         $group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($group->parents)) . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     if (empty($params['id']) && !$nameParam) {
         $group->name .= "_tmp";
     }
     $group->save();
     if (!$group->id) {
         return NULL;
     }
     if (empty($params['id']) && !$nameParam) {
         $group->name = substr($group->name, 0, -4) . "_{$group->id}";
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (!empty($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (empty($params['parents']) && $domainGroupID != $group->id && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled') && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } elseif (array_key_exists('parents', $params) && !is_array($params['parents'])) {
             $params['parents'] = array($params['parents'] => 1);
         }
         if (!empty($params['parents'])) {
             foreach ($params['parents'] as $parentId => $dnc) {
                 if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                     CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
                 }
             }
         }
         // clear any descendant groups cache if exists
         $finalGroups = CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (!empty($params['organization_id'])) {
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
     } else {
         CRM_Utils_Hook::post('create', 'Group', $group->id, $group);
     }
     $recentOther = array();
     if (CRM_Core_Permission::check('edit groups')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=update&id=' . $group->id);
         // currently same permission we are using for delete a group
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=delete&id=' . $group->id);
     }
     // add the recently added group (unless hidden: CRM-6432)
     if (!$group->is_hidden) {
         CRM_Utils_Recent::add($group->title, CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id), $group->id, 'Group', NULL, NULL, $recentOther);
     }
     return $group;
 }
Пример #2
0
 /**
  * Create a new group
  *
  * @param array $params     Associative array of parameters
  * @return object|null      The new group BAO (if created)
  * @access public
  * @static
  */
 public static function &create(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', null, $params);
     }
     // form the name only if missing: CRM-627
     if (!CRM_Utils_Array::value('name', $params)) {
         require_once 'CRM/Utils/String.php';
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $group =& new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     $group->save();
     if (!$group->id) {
         return null;
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         require_once 'CRM/Core/BAO/CustomValueTable.php';
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     require_once 'CRM/Core/BAO/Domain.php';
     require_once 'CRM/Contact/BAO/GroupNesting.php';
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && empty($params['parents']) && $domainGroupID != $group->id && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } else {
             if (!is_array($params['parents'])) {
                 $params['parents'] = array($params['parents'] => 1);
             }
         }
         foreach ($params['parents'] as $parentId => $dnc) {
             if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                 CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
             }
         }
         // clear any descendant groups cache if exists
         require_once 'CRM/Core/BAO/Cache.php';
         $finalGroups =& CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         require_once 'CRM/Contact/BAO/GroupNestingCache.php';
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (CRM_Utils_Array::value('organization_id', $params)) {
         require_once 'CRM/Contact/BAO/GroupOrganization.php';
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
     } else {
         CRM_Utils_Hook::post('create', 'Group', $group->id, $group);
     }
     return $group;
 }
Пример #3
0
 /**
  * Process the form when submitted.
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Group');
     $updateNestingCache = FALSE;
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Group::discard($this->_id);
         CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", array(1 => $this->_title)), ts('Group Deleted'), 'success');
         $updateNestingCache = TRUE;
     } else {
         // store the submitted values in an array
         $params = $this->controller->exportValues($this->_name);
         $params['is_active'] = CRM_Utils_Array::value('is_active', $this->_groupValues, 1);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $params['id'] = $this->_id;
         }
         if ($this->_action & CRM_Core_Action::UPDATE && isset($this->_groupOrganizationID)) {
             $params['group_organization'] = $this->_groupOrganizationID;
         }
         $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
         $groupTypeIds = array();
         $groupType = CRM_Utils_Array::value('group_type', $params);
         if (is_array($groupType)) {
             foreach ($groupType as $type => $selected) {
                 if ($selected) {
                     $groupTypeIds[] = $type;
                 }
             }
         }
         $params['group_type'] = $groupTypeIds;
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Group');
         $group = CRM_Contact_BAO_Group::create($params);
         //Remove any parent groups requested to be removed
         if (!empty($this->_groupValues['parents'])) {
             $parentGroupIds = explode(',', $this->_groupValues['parents']);
             foreach ($parentGroupIds as $parentGroupId) {
                 if (isset($params["remove_parent_group_{$parentGroupId}"])) {
                     CRM_Contact_BAO_GroupNesting::remove($parentGroupId, $group->id);
                     $updateNestingCache = TRUE;
                 }
             }
         }
         CRM_Core_Session::setStatus(ts('The Group \'%1\' has been saved.', array(1 => $group->title)), ts('Group Saved'), 'success');
         // Add context to the session, in case we are adding members to the group
         if ($this->_action & CRM_Core_Action::ADD) {
             $this->set('context', 'amtg');
             $this->set('amtgID', $group->id);
             $session = CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id));
         }
     }
     // update the nesting cache
     if ($updateNestingCache) {
         CRM_Contact_BAO_GroupNestingCache::update();
     }
 }
Пример #4
0
 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     // saved search form values
     // get form values of all the forms in this controller
     $formValues = $this->controller->exportValues();
     $isAdvanced = $this->get('isAdvanced');
     $isSearchBuilder = $this->get('isSearchBuilder');
     // add mapping record only for search builder saved search
     $mappingId = NULL;
     if ($isAdvanced == '2' && $isSearchBuilder == '1') {
         //save the mapping for search builder
         if (!$this->_id) {
             //save record in mapping table
             $mappingParams = array('mapping_type' => 'Search Builder');
             $temp = array();
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             $savedSearch = new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $this->_id;
             $savedSearch->find(TRUE);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId);
     }
     //save the search
     $savedSearch = new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $this->_id;
     $savedSearch->form_values = serialize($this->get('formValues'));
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
     CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success');
     // also create a group that is associated with this saved search only if new saved search
     $params = array();
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (isset($formValues['group_type']) && is_array($formValues['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
     } else {
         $params['group_type'] = '';
     }
     $params['visibility'] = 'User and User Admin Only';
     $params['saved_search_id'] = $savedSearch->id;
     $params['is_active'] = 1;
     //CRM-14190
     $params['parents'] = $formValues['parents'];
     if ($this->_id) {
         $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
     }
     $group = CRM_Contact_BAO_Group::create($params);
     // CRM-9464
     $this->_id = $savedSearch->id;
     //CRM-14190
     if (!empty($formValues['parents'])) {
         CRM_Contact_BAO_GroupNestingCache::update();
     }
 }
Пример #5
0
 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     // saved search form values
     // get form values of all the forms in this controller
     $formValues = $this->controller->exportValues();
     $isAdvanced = $this->get('isAdvanced');
     $isSearchBuilder = $this->get('isSearchBuilder');
     // add mapping record only for search builder saved search
     $mappingId = NULL;
     if ($isAdvanced == '2' && $isSearchBuilder == '1') {
         //save the mapping for search builder
         if (!$this->_id) {
             //save record in mapping table
             $mappingParams = array('mapping_type' => 'Search Builder');
             $temp = array();
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             $savedSearch = new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $this->_id;
             $savedSearch->find(TRUE);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId);
     }
     //save the search
     $savedSearch = new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $this->_id;
     // Use the query parameters rather than the form values - these have already been assessed / converted
     // with the extra knowledge that the form has.
     // Note that we want to move towards a standardised way of saving the query that is not
     // an exact match for the form requirements & task the form layer with converting backwards and forwards.
     // Ideally per CRM-17075 we will use entity reference fields heavily in the form layer & convert to the
     // sql operator syntax at the query layer.
     $savedSearch->form_values = serialize($this->get('queryParams'));
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
     CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success');
     // also create a group that is associated with this saved search only if new saved search
     $params = array();
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (isset($formValues['group_type']) && is_array($formValues['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
     } else {
         $params['group_type'] = '';
     }
     $params['visibility'] = 'User and User Admin Only';
     $params['saved_search_id'] = $savedSearch->id;
     $params['is_active'] = 1;
     //CRM-14190
     $params['parents'] = $formValues['parents'];
     if ($this->_id) {
         $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
     }
     $group = CRM_Contact_BAO_Group::create($params);
     // CRM-9464
     $this->_id = $savedSearch->id;
     //CRM-14190
     if (!empty($formValues['parents'])) {
         CRM_Contact_BAO_GroupNestingCache::update();
     }
 }
Пример #6
0
 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $updateNestingCache = false;
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Contact_BAO_Group::discard($this->_id);
         CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", array(1 => $this->_title)));
         $updateNestingCache = true;
     } else {
         // store the submitted values in an array
         $params = $this->controller->exportValues($this->_name);
         $params['is_active'] = 1;
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $params['id'] = $this->_id;
         }
         if ($this->_action & CRM_Core_Action::UPDATE && isset($this->_groupOrganizationID)) {
             $params['group_organization'] = $this->_groupOrganizationID;
         }
         $customFields = CRM_Core_BAO_CustomField::getFields('Group');
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Group');
         require_once 'CRM/Contact/BAO/Group.php';
         $group =& CRM_Contact_BAO_Group::create($params);
         /*
          * Remove any parent groups requested to be removed
          */
         if (CRM_Utils_Array::value('parents', $this->_groupValues)) {
             $parentGroupIds = explode(',', $this->_groupValues['parents']);
             foreach ($parentGroupIds as $parentGroupId) {
                 if (isset($params["remove_parent_group_{$parentGroupId}"])) {
                     CRM_Contact_BAO_GroupNesting::remove($parentGroupId, $group->id);
                     $updateNestingCache = true;
                 }
             }
         }
         CRM_Core_Session::setStatus(ts('The Group \'%1\' has been saved.', array(1 => $group->title)));
         /*
          * Add context to the session, in case we are adding members to the group
          */
         if ($this->_action & CRM_Core_Action::ADD) {
             $this->set('context', 'amtg');
             $this->set('amtgID', $group->id);
             $session =& CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id));
         }
     }
     // update the nesting cache
     if ($updateNestingCache) {
         require_once 'CRM/Contact/BAO/GroupNestingCache.php';
         CRM_Contact_BAO_GroupNestingCache::update();
     }
     require_once 'CRM/Utils/Recent.php';
     // add the recently added group
     CRM_Utils_Recent::add($group->title, CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id), $group->id, 'Group', null, null);
 }
Пример #7
0
 /**
  * Create a new group
  *
  * @param array $params     Associative array of parameters
  *
  * @return object|null      The new group BAO (if created)
  * @access public
  * @static
  */
 public static function &create(&$params)
 {
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Group', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Group', NULL, $params);
     }
     // form the name only if missing: CRM-627
     if (!CRM_Utils_Array::value('name', $params) && !CRM_Utils_Array::value('id', $params)) {
         $params['name'] = CRM_Utils_String::titleToVar($params['title']);
     }
     // convert params if array type
     if (isset($params['group_type'])) {
         if (is_array($params['group_type'])) {
             $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $params['group_type'] = '';
     }
     $group = new CRM_Contact_BAO_Group();
     $group->copyValues($params);
     if (!CRM_Utils_Array::value('id', $params)) {
         $group->name .= "_tmp";
     }
     $group->save();
     if (!$group->id) {
         return NULL;
     }
     if (!CRM_Utils_Array::value('id', $params)) {
         $group->name = substr($group->name, 0, -4) . "_{$group->id}";
     }
     $group->buildClause();
     $group->save();
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_group', $group->id);
     }
     // make the group, child of domain/site group by default.
     $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
     if (CRM_Utils_Array::value('no_parent', $params) !== 1) {
         if (empty($params['parents']) && $domainGroupID != $group->id && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled') && !CRM_Contact_BAO_GroupNesting::hasParentGroups($group->id)) {
             // if no parent present and the group doesn't already have any parents,
             // make sure site group goes as parent
             $params['parents'] = array($domainGroupID => 1);
         } elseif (array_key_exists('parents', $params) && !is_array($params['parents'])) {
             $params['parents'] = array($params['parents'] => 1);
         }
         if (!empty($params['parents'])) {
             foreach ($params['parents'] as $parentId => $dnc) {
                 if ($parentId && !CRM_Contact_BAO_GroupNesting::isParentChild($parentId, $group->id)) {
                     CRM_Contact_BAO_GroupNesting::add($parentId, $group->id);
                 }
             }
         }
         // clear any descendant groups cache if exists
         $finalGroups = CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
         // this is always required, since we don't know when a
         // parent group is removed
         CRM_Contact_BAO_GroupNestingCache::update();
         // update group contact cache for all parent groups
         $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id);
         foreach ($parentIds as $parentId) {
             CRM_Contact_BAO_GroupContactCache::add($parentId);
         }
     }
     if (CRM_Utils_Array::value('organization_id', $params)) {
         $groupOrg = array();
         $groupOrg = $params;
         $groupOrg['group_id'] = $group->id;
         CRM_Contact_BAO_GroupOrganization::add($groupOrg);
     }
     CRM_Contact_BAO_GroupContactCache::add($group->id);
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Group', $group->id, $group);
     } else {
         CRM_Utils_Hook::post('create', 'Group', $group->id, $group);
     }
     $recentOther = array();
     if (CRM_Core_Permission::check('edit groups')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=update&id=' . $group->id);
         // currently same permission we are using for delete a group
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=delete&id=' . $group->id);
     }
     // add the recently added group (unless hidden: CRM-6432)
     if (!$group->is_hidden) {
         CRM_Utils_Recent::add($group->title, CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $group->id), $group->id, 'Group', NULL, NULL, $recentOther);
     }
     return $group;
 }