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/www/sites/all/modules/submenutree/submenutree.install
<?php
/**
 * @file
 * Install, update and uninstall functions for the Submenu Tree module.
 */

/**
 * Implements hook_schema().
 */
function submenutree_schema() {
  $schema['node_submenutree'] = array(
    'description' => t('The base table for submenutree.'),
    'fields' => array(
      'nid' => array(
        'description' => 'The primary identifier for a node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'submenutree_enable' => array(
        'description' => 'The status of sub content associated with this node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'submenutree_title' => array(
        'description' => 'The title for the sub content associated with this node.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'submenutree_display' => array(
        'description' => 'The method of displaying sub content associated with this node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'submenutree_weight' => array(
        'description' => 'The weight of sub content associated with this node.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'siblingmenutree_enable' => array(
        'description' => 'The status of sibling content associated with this node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'siblingmenutree_title' => array(
        'description' => 'The title for the sibling content associated with this node.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'siblingmenutree_display' => array(
        'description' => 'The method of displaying sibling content associated with this node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'siblingmenutree_weight' => array(
        'description' => 'The weight of sibling content associated with this node.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('nid'),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function submenutree_uninstall() {
  // Clear the configuration variables
  variable_del('submenutree_block_title');
  variable_del('submenutree_block_title_content_menu_parent_level');
  variable_del('submenutree_extended_menu_name');
  variable_del('submenutree_extended_menu_level');

  // Clear the node specific variables
  $types = node_type_get_names();
  foreach ($types as $type => $name) {
    variable_del("submenutree_node_type_{$type}");
    variable_del("submenutree_enable_{$type}");
    variable_del("submenutree_title_{$type}");
    variable_del("submenutree_display_{$type}");
    variable_del("submenutree_weight_{$type}");
    variable_del("siblingmenutree_enable_{$type}");
    variable_del("siblingmenutree_title_{$type}");
    variable_del("siblingmenutree_display_{$type}");
    variable_del("siblingmenutree_weight_{$type}");
  }
}

/**
 * Make columns submenutree_weight and siblingmenutree_weight signed integers.
 * See http://drupal.org/node/455690
 */
function submenutree_update_6001() {
  $fields = array(
    'submenutree_weight' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'disp-width' => '10',
    ),
    'siblingmenutree_weight' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'disp-width' => '10',
    ),
  );

  $ret = array();
  foreach ($fields as $field => $spec) {
    db_change_field($ret, 'node_submenutree', $field, $field, $spec);
  }
  return $ret;
}

/**
 * Update roles with Submenu Tree 7.x-1.x permissions.
 */
function submenutree_update_7200() {
  // Find every role with sub or sibling content permissions
  $sub_content_roles = user_roles(FALSE, 'administer submenu trees');
  $sibling_content_roles = user_roles(FALSE, 'administer siblingmenu trees');

  // Define which permissions should be added and removed from roles with the old "administer submenu trees" permission
  $new_sub_content_permissions = array(
    'administer submenu trees' => FALSE,
    'administer sub content' => TRUE,
    'administer sub content title' => TRUE,
    'administer sub content display type' => TRUE,
    'administer sub content weight' => TRUE,
  );

  // Define which permissions should be added and removed from roles with the old "administer siblingmenu trees" permission
  $new_sibling_content_permissions = array(
    'administer siblingmenu trees' => FALSE,
    'administer sibling content' => TRUE,
    'administer sibling content title' => TRUE,
    'administer sibling content display type' => TRUE,
    'administer sibling content weight' => TRUE,
  );

  // Update roles with the old sub content permission
  foreach ($sub_content_roles as $role_id => $role_name) {
    user_role_change_permissions($role_id, $new_sub_content_permissions);
  }

  // Update roles with the old sibling content permission
  foreach ($sibling_content_roles as $role_id => $role_name) {
    user_role_change_permissions($role_id, $new_sibling_content_permissions);
  }

  return t('Successfully migrated all user roles with old Submenu Tree permissions.');
}