You are here

function comment_notify_install in Comment Notify 6

Same name and namespace in other branches
  1. 8 comment_notify.install \comment_notify_install()
  2. 5.2 comment_notify.install \comment_notify_install()
  3. 5 comment_notify.install \comment_notify_install()
  4. 7 comment_notify.install \comment_notify_install()

Implementation of hook_install().

File

./comment_notify.install, line 10
comment_notify.install.

Code

function comment_notify_install() {

  // Create the table.
  drupal_install_schema('comment_notify');

  // Insert a record for each existing comment.
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_query("INSERT INTO {comment_notify} (cid, notify, notify_hash) SELECT c.cid, 0, md5(c.mail || coalesce(u.mail, u.init) || c.uid || c.name || c.nid) FROM {comments} c LEFT OUTER JOIN {users} u on c.uid = u.uid");
  }
  else {
    db_query("INSERT INTO {comment_notify} (cid, notify, notify_hash) SELECT c.cid, 0, md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid)) FROM {comments} c LEFT OUTER JOIN {users} u on c.uid = u.uid");
  }

  // Set module weight low so that other modules act on the comment first.
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'comment_notify'");
}