You are here

function print_mail_update_6007 in Printer, email and PDF versions 5.x

Same name and namespace in other branches
  1. 5.4 print_mail/print_mail.install \print_mail_update_6007()
  2. 6 print_mail/print_mail.install \print_mail_update_6007()

Update to version 6.x-1.11

File

print_mail/print_mail.install, line 297
Install file of the print_mail module

Code

function print_mail_update_6007() {
  $ret = array();
  foreach (node_get_types() as $key => $value) {
    $print_mail_display = variable_get('print_mail_display_' . $value->type, 1);
    $print_mail_display_comment = variable_get('print_mail_display_comment_' . $value->type, 0);
    $print_mail_display_urllist = variable_get('print_mail_display_urllist_' . $value->type, 1);
    if (!$print_mail_display || $print_mail_display_comment || !$print_mail_display_urllist) {
      $result = db_query("SELECT n.nid, link, comments, url_list from {node} AS n LEFT JOIN {print_mail_node_conf} AS pnc ON n.nid = pnc.nid WHERE type = '%s'", $value->type);
      while ($conf = db_fetch_object($result)) {
        if ($conf->link != NULL && $conf->comments != NULL && $conf->url_list != NULL) {
          $conf->link = !$print_mail_display ? 0 : $conf->link;
          $conf->comments = $print_mail_display_comment ? 1 : $conf->comments;
          $conf->url_list = !$print_mail_display_urllist ? 0 : $conf->url_list;
          $ret[] = update_sql("UPDATE {print_mail_node_conf} SET link = {$conf->link}, comments = {$conf->comments}, url_list = {$conf->url_list} WHERE nid = {$conf->nid}");
        }
        else {
          $ret[] = update_sql("INSERT INTO {print_mail_node_conf} (nid, link, comments, url_list) VALUES ({$conf->nid}, {$print_mail_display}, {$print_mail_display_comment}, {$print_mail_display_urllist})");
        }
      }
    }
  }
  return $ret;
}