HEX
Server: Apache
System: Linux dev.epsylon.net 3.10.0-1160.144.1.el7.tuxcare.els2.x86_64 #1 SMP Sun Feb 15 11:22:42 UTC 2026 x86_64
User: nexper (1054)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/nexper/public_html/sites/all/modules/node_convert/includes/book.node_convert.inc
<?php

/**
 * @file
 * Node convert book.module include
 *
 * Performs necessary changes regarding book type conversions.
 */

/**
 * Implementation of node_convert_change().
 */
function book_node_convert_change($data, $op) {
  if ($op == 'insert') {
    if ($data['dest_node_type'] == 'book') {
      $book = array();
      $node = $data['node'];
      $book['link_path'] = 'node/' . $node->nid;
      $book['link_title'] = $node->title;
      $book['plid'] = 0;
      $book['menu_name'] = book_menu_name($node->nid);
      $mlid = menu_link_save($book);
      $book['bid'] = $data['hook_options']['bid'];
      if ($book['bid'] == 'self') {
        $book['bid'] = $node->nid;
      }
      // TODO Please review the conversion of this statement to the D7 database API syntax.
      /* db_query("INSERT INTO {book} (nid, mlid, bid) VALUES (%d, %d, %d)", $node->nid, $book['mlid'], $book['bid']) */
      $id = db_insert('book')
  ->fields(array(
        'nid' => $node->nid,
        'mlid' => $book['mlid'],
        'bid' => $book['bid'],
      ))
  ->execute();
    }
  }
  elseif ($op == 'delete') {
    if ($data['node']->type == 'book') {
      menu_link_delete($data['node']->book['mlid']);
      // TODO Please review the conversion of this statement to the D7 database API syntax.
      /* db_query('DELETE FROM {book} WHERE mlid = %d', $data['node']->book['mlid']) */
      db_delete('book')
  ->condition('mlid', $data['node']->book['mlid'])
  ->execute();
    }
  }
  elseif ($op == 'options') {
    $form = array();
    if ($data['dest_node_type'] == 'book') {
      $options = array();
      foreach (book_get_books() as $book) {
        $options[$book['nid']] = $book['title'];
      }
      $options = array('self' => '<' . t('create a new book') . '>') + $options;
      $form['bid'] = array(
        '#type' => 'select',
        '#title' => t('Book'),
        '#options' => $options,
        '#description' => t('Your page will be a part of the selected book.'),
        '#attributes' => array('class' => 'book-title-select'),
      );
    }
    return $form;
  }
}