join('users', 'u', 'c.uid = u.uid'); $comments_select->addField('c', 'cid'); $comments_select->addExpression('0', 'notify'); if (db_driver() == 'pgsql') { $comments_select->addExpression('md5(c.mail || coalesce(u.mail, u.init) || c.uid || c.name || c.nid)', 'notify_hash'); } else { $comments_select->addExpression('md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid))', 'notify_hash'); } $comments_select->addField('c', 'cid'); // Set module weight low so that other modules act on the comment first. db_insert('comment_notify')->from($comments_select)->execute(); db_update('system')-> fields(array( 'weight' => 10 )) ->condition('name', 'comment_notify'); } /** * Implementation of hook_uninstall(). */ function comment_notify_uninstall() { drupal_uninstall_schema('comment_notify'); variable_del('node_notify_default_mailtext'); db_delete('variable') ->where('name', "comment_notify_%", 'LIKE'); } /** * Implementation of hook_schema(). */ function comment_notify_schema() { $schema['comment_notify'] = array( 'description' => t('Stores information about which commenters on the site have subscriped to followup emails.'), 'fields' => array( 'cid' => array( 'type' => 'int', 'unsigned' => TRUE, 'description' => 'The comment id from {comments}.cid', 'not null' => TRUE, 'disp-width' => '11'), 'notify' => array( 'type' => 'int', 'description' => 'A boolean indicator for whether or not they subscribed: 1 means subscribed, 0 means not subscribed.', 'size' => 'tiny', 'not null' => TRUE, 'disp-width' => '11'), 'notify_hash' => array( 'type' => 'varchar', 'description' => 'An md5 hash of unique information about the commenter. Used for unsubscribing users.', 'length' => '32', 'not null' => TRUE, 'default' => ''), 'notified' => array( 'type' => 'int', 'description' => 'A boolean indicator for whether or not a notification for the comment has been sent: 1 means yes, 0 means no.', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), ), 'primary key' => array('cid'), 'indexes' => array( 'notify_hash' => array('notify_hash')), ); $schema['comment_notify_user_settings'] = array( 'fields' => array( 'uid' => array( 'type' => 'int', 'unsigned' => TRUE, 'description' => 'The user id from {users}.cid', 'not null' => TRUE, 'disp-width' => '11'), 'node_notify' => array( 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 'comment_notify' => array( 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), ), 'primary key' => array('uid'), ); return $schema; }