Code snippets and useful queries (6.x-4.x)

Last updated on
30 April 2025

Import from Subscriptions 5.x

$result = db_query('SELECT DISTINCT(s.sid), s.uid, s.stype, u.mail FROM subscriptions s INNER JOIN {users} u on u.uid = s.uid');
  while ($data = db_fetch_object($result)) {
    switch ($data->stype) {
      case 'node':
        $fields = array('nid' => $data->sid);
        $subs = new Notifications_Subscription(array('type' => 'thread',
'event_type' => 'node', 'fields' => $fields, 'uid' => $data->uid,
'send_method' => 'mimemail', 'send_interval' => 0, 'module' =>
'notifications'));
        $subs->check_destination(); // This will create the destination
fields
        // based on uid, method....
        $subs->save();
        break;
      case 'blog':
        $fields = array('author' => $data->sid, 'type' => 'blog');
        $subs = new Notifications_Subscription(array('type' =>
'typeauthor', 'event_type' => 'node', 'fields' => $fields, 'uid' =>
$data->uid, 'send_method' => 'mimemail', 'send_interval' => 0, 'module'
=> 'notifications'));
        $subs->check_destination(); // This will create the destination
fields
        // based on uid, method....
        $subs->save();
        break;
    }
  }

Reset data

Help improve this page

Page status: Not set

You can: