<?php
/**
 * Implement hook_rules_action_info().
 */
function simplenews_unsubscribe_all_rules_action_info() {
  return array(
    'simplenews_unsubscribe_all_rules_action_unsubscribe_all' => array(
      'label' => t('Simplenews unsubscribe all from a newsletter'),
      'group' => t('Simplenews'),
      'parameter' => array(
        'tid' => array(
          'type' => 'integer',
          'label' => t('Simplenews category'),
          'descrption' => t('For which newsletter category the unsubscription should happen.'),
          'options list' => 'simplenews_category_list',
        ),
      ),
    ),
  );
}
//function simplenews_unsubscribe_all_rules_action_info() {
//  return array(
//    'simplenews_unsubscribe_all_rules_action_unsubscribe_all' => array(
//      'label' => t('Simplenews unsubscribe all from a newsletter'),
//      'group' => t('Simplenews'),
//       ),
//  );
//}

/**
 * Action Implementation: Unsubscribe an e-mail adress to a Simplenews newsletter.
 */
function simplenews_unsubscribe_all_rules_action_unsubscribe_all($args, $settings) {
  // Pass the call forward.
  db_query('delete from {simplenews_subscription} where tid=:tid', array(':tid'=>$args));
}

//function simplenews_unsubscribe_all_rules_action_unsubscribe_all() {
//  // Pass the call forward.
// // db_query('delete from {simplenews_subscription} where tid=:tid', array(':tid'=>$args));
// $result = db_truncate('simplenews_subscription')->execute();
//}

