I'm trying to migrate to CiviCRM 2.2, but I have, what appears to be a simple problem.

the require_once for 'api/v2/Group.php' file is not being found on the civicrm_subscribe_block method.

switch ($op) {
    case 'list':
      require_once 'api/v2/Group.php';
      civicrm_initialize();
      $groups = variable_get('civicrm_subscribe_groups', array());
      foreach ($groups as $group_id) {
  

I have the module installed in sites/all/civicrm/drupal/modules/civicrm_subscribe and i get the error below, when i'm not in the //site/civicrm path. Any ideas?
warning: require_once(api/v2/Group.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\drupal6\sites\all\modules\civicrm\drupal\modules\civicrm_subscribe\civicrm_subscribe.module on line 191.

Comments

rpalomo’s picture

Assigned: Unassigned » rpalomo

I moved the civicrm_initialize at the top of the module and that fixed it. Now I'm having problems with the subscribe form after submitting.

EvanDonovan’s picture

Status: Active » Closed (duplicate)

Marking as duplicate of #249530: CiviCRM 2.1+ compatibility: try the patch that I have uploaded to that thread. It doesn't actually subscribe yet, because I think there are changes to the Contact API, but it's closer to working.

rpalomo’s picture

Status: Closed (duplicate) » Active

My changes are for Drupal 6.x and CiviCRM 2.2. It already adds the user to the group right now, but doesn't send an email, probably my configuration problem. I should've seen your changes to make my life easier but I had to discover all the problem on my own, I guess good learning experience.

I'm looking into setting an option to use CIVIMail or drupal mail for the registration, but at this point I'm stuck.
I still need to test a little more all the other stuff about opt-out other conditions in the code.

rpalomo’s picture

even better now, if instead of calling civicrm_subscribe you do the following, it does the subscription and contact for you, there is no adding contacts or anything.

    require_once "api/Mailer.php";
    if (crm_mailer_event_subscribe($form_state['values']['email'],$groups[0]))

Then we just need to retrieve the group name to display it in the drupal_message screen..

EvanDonovan’s picture

Excellent! Sounds like you've gotten much further with this than I did. Care to post your code as a patch? Then maybe we can get it committed to the 6.x branch and close both our issues :)

rpalomo’s picture

Ok, I gotta read the documentation on creating a patch, I'll get around it this week.

EvanDonovan’s picture

Status: Active » Closed (duplicate)

Check out #249530: CiviCRM 2.1+ compatibility: after several hours of struggling with the CiviCRM Subscribe module's current implementation of adding to a group, I tried the API function you suggested. While it stumped me at first (due to CRM-1797: Subscribing to a group via CiviMail should be only able for groups with public visibility), I was eventually able to get it to work once I set my groups' visibility to Public in CiviCRM.

Anyway, if you could review the patch and possibly incorporate anything good from your version which I missed, that would be great. Hopefully we can get this committed soon.

The one thing that I'm missing is a civicrm_subscribe_block implementation, because it wasn't in the code that I was working from. You might be able to just drop your code in for that, though.

I'm flagging this as a duplicate so we can continue our work in the other issue, without having to check on both.

Btw, to create a patch the command is: diff -up old-file new-file.