Can you bring in the functionality of the Simplenew Subscription Manager (http://drupal.org/project/simplenews_sub_manager) into the Simplenews Module?

I don't plan on releasing the module, it's useful, and a majority of the code in the module is code duplication from Simplenews.

Comments

guillaumeduveau’s picture

To the maintainers : what do you think about including this module in Simplenews ? I tested it with Simplenews-6-x.1.0 and it works fine (.zip available on #387360: file release?).

Let us know if we should go on as a separate module or if we can submit patches.

Another thing I want is : users who manage subscriptions to a given newsletter should be able to send issues for the same newsletter but not for those he does not manage.

guillaumeduveau’s picture

For the last part :

/**
 * Implementation of hook_form_alter().
 */
function mymodule_form_alter(&$form, $form_state, $form_id) {
  // if the user is a manager defined by the module simplenews_sub_manager, allow only the terms he manages
  if (module_exists('simplenews_sub_manager')) {
    if ($form_id == 'simplenews_node_form' && db_result(db_query("SELECT COUNT(*) FROM {simplenews_sub_manager} WHERE uid = %d", $user->uid))) {
      $simplenews_vid = variable_get('simplenews_vid', '');
      $my_newsletters = array();
      $result = db_query("SELECT tid FROM {simplenews_sub_manager} WHERE uid = %d", $user->uid);
      while ($item = db_fetch_object($result)) {
        $my_newsletters[] = $item->tid;
      }
      foreach ($form['taxonomy'][$simplenews_vid]['#options'] as $key => $value) {
        $value_option = (array)$value->option;
        $term_array_keys = array_keys($value_option);
        if (!in_array($term_array_keys[0], $my_newsletters)) {
          unset($form['taxonomy'][$simplenews_vid]['#options'][$key]);
        }
      }
    }
  }
}

2 good solutions would be :

1 (best) : to include everything in simplenews (what do you think maintainers ?)
2 (good too) : rename simplenews_sub_manager to simplenews_managers and include my code above (what do you think mfer ?)

cya
Guix

sutharsan’s picture

Is this something to combine with/contribute to #418006: Simplenews in combination with OG?

geerlingguy’s picture

I think that would be a worthy goal. Functionality would be similar...

guillaumeduveau’s picture

Hi,

Well, while some code could be shared, using OG for dedicated newsletters is not enough if you just want to let people subscribe with the email only, and not having to create a user.

geerlingguy’s picture

I was thinking more in terms of each OG having it's own newsletter which certain users could edit. The way Simplenews is currently set up, anybody with access to create newsletters can create any newsletter. But I'd like a way to assign newsletters to certain users or groups of users, so that, for instance, user A can't send a newsletter on behalf of user B—he can only send the newsletter he's allowed to send.

sutharsan’s picture

Status: Active » Closed (won't fix)

I have no intention to include the functionality in simplenews. I don't have the time to rework the code nor the time to maintain this in the future.