CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Reset contact status in Smart Group to "Smart"
Pages: [1]

Author Topic: Reset contact status in Smart Group to "Smart"  (Read 1549 times)

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Reset contact status in Smart Group to "Smart"
April 22, 2011, 04:42:51 am
We've a Smart Group which has had contacts added or removed in the past.  I'd like to reset their status to "smart" ie automatically determined by the smart group criteria.  In the contact Groups tab I can add or remove the contact from the group, but not reset to "smart" as far as I can see.

I have tested that removing the relevant row from the civicrm_group_contact table has the desired effect.

Is there a way of doing this from the user interface?

Thanks Chris
Drupal 3.3.3 / 3.3.6

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Reset contact status in Smart Group to "Smart"
April 22, 2011, 07:14:52 am

currently no, but this has come up recently for regular groups also. Seems like would be a good option to add a "delete" link from the group in addition to remove (with good docs to explain to folks)

any interest in working on a patch for this

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
April 22, 2011, 07:53:25 am
Thanks for getting back to me so soon today.

I'll have a think about what's required to fix - at some point.

It might also be useful for the contact Groups list to say "Included in smart group"" rather than "Added (by Admin)" for the smart group case.

So having a "Reset to smart group criteria" would suitable in this case - and "Delete" suitable for regular groups?

Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Reset contact status in Smart Group to "Smart"
April 22, 2011, 09:41:30 am
Chris - Just a heads up in case you weren't aware of it ... when a contact is in a smart group based on search query, the fact that they are in that group is NOT displayed in their Contact "Groups" tab. Only regular groups and smart groups where they've been explicitly added or removed are shown (i.e. group_contact records).

There was a Make it Happen to address this, but it didn't get any traction despite the fact that lots of folks had expressed the need :-(:
http://civicrm.org/index.php?q=civicrm/contribute/transact&reset=1&id=3&widgetID=1

The main issue in implementing this is providing caching so that all smart group queries aren't run each time someone views a contact page.
Protect your investment in CiviCRM by  becoming a Member!

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
April 22, 2011, 12:22:10 pm
Ah yes - I was mistaken in what I said before - I was confused by a similar group name.

Yes, seeing which smart groups a contact is in would be useful.  I can understand the need for caching.

Thanks again Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
April 23, 2011, 03:11:39 am
I thought it important for us to have the ability to 'revert to Smart', ie remove the Added/Removed row for a contact, so I've added a [Delete] option beside [Remove] etc for Current, Pending and Past groups.  I implemented this using a new status parameter of "st=d".  Eventually in CRM/Contact/BAO/GroupContact.php I do a delete from civicrm_group_contact.

The present removeContactsFromGroup() has a call to CRM_Contact_BAO_SubscriptionHistory::create($historyParams); for the case when info is added to civicrm_group_contact.  Should I be adding something here as well.

With this addition, I was able to permanently fix two false positives and two false negatives - so worthwile doing.  There were also several true negatives (and one or two true positives) which could cause problems in the future, so it was good to fix these as well.  (Beginning to sound like Rumsfelt here.)

I can share my changes to these files:
- templates/CRM/Contact/Page/View/GroupContact.tpl
- CRM/Contact/Page/View/groupContact.php
- CRM/Contact/BAO/GroupContact.php

What [Delete] does, as opposed to [Remove], may need careful explaining.

Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Reset contact status in Smart Group to "Smart"
April 25, 2011, 10:23:47 am
To be consistent, I think we should also add a record to subscription_history on the delete action. If you can implement that and then roll a patchfile against the latest (3.4) release code, you can then file an issue on the issue tracker and attach your patch for review / inclusion in next release. Jump on IRC if you need guidance on these steps. thx!
Protect your investment in CiviCRM by  becoming a Member!

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
May 04, 2011, 07:50:36 am
Sorry for the delay on producing a patch.

I just looked at adding a record to the subscription_history.  (I must admit that I'm not sure where the subscription_history is visible in the user interface.)  At the moment, the status fields is an enum of 'Added', 'Removed' and 'Pending', so adding a row with a status of 'Deleted' ends up with a blank column in the database.  To do this fully, the schema would need updating to add another enum value.

I also realised that the $displayName template variable was not set.  This is used in various places in CRM/Contact/Page/View/GroupContact.tpl.  It would be nice to get this set.  However I couldn't find where to set this.   Where do you suggest?

Thanks Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Reset contact status in Smart Group to "Smart"
May 04, 2011, 03:47:28 pm
Chris - You can include an update to the schema in your patch to add Deleted to that enum. If you submit in the next point release cycle, you'll be patching CRM/Upgrade/Incremental/sql/3.4.2.mysql.tpl

 Regarding $displayName - it is available to that template in my 3.4.1 (from svn) local install. I see it in the jScript confirm pop-up (are u sure ...) and in the Past Groups section: "Dave Green is no longer part of these group(s)."
Protect your investment in CiviCRM by  becoming a Member!

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
May 09, 2011, 04:10:59 am
I've added my changes as a patch here:
http://issues.civicrm.org/jira/browse/CRM-8062
I've not changed the indenting in one file so it's clearer where the changes are.

Let me know if I've done it the right way, ie running the DELETE direct.

Also: looking at the code again: I may being doing the actual delete a fraction too early.  Perhaps my code should be just before the line that includes "CRM-3711" in CRM_Contact_BAO_GroupContact.php

The patch doesn't include the schema change, though I have listed it, so someone else will have to add that.

Yes: $displayName is included in 3.4.0 onwards.

Chris

davesage

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 3
  • CiviCRM version: 3.4 & 4.1
  • CMS version: Joomla 1.5 & 2.5
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Reset contact status in Smart Group to "Smart"
June 22, 2011, 08:31:51 am
Hi,

I'm running 3.4.3 and I want to use the option to 'return to smart' from reading up this topic it seems like it should be available. Was this released or is it still a patch I have to apply manually?

Cheers,

Dave

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Reset contact status in Smart Group to "Smart"
June 22, 2011, 10:41:16 am
My patch is here:
http://issues.civicrm.org/jira/browse/CRM-8062
This says that it is being applied from 4.1.

So you'll need to apply my patch yourself.  Do a file backup beforehand as a precaution.

Chris

davesage

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 3
  • CiviCRM version: 3.4 & 4.1
  • CMS version: Joomla 1.5 & 2.5
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Reset contact status in Smart Group to "Smart"
June 22, 2011, 01:07:42 pm
Fantastic - thanks for the link.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Reset contact status in Smart Group to "Smart"

This forum was archived on 2017-11-26.