You are here

function user_badges_schema in User Badges 7.3

Same name and namespace in other branches
  1. 6.2 user_badges.install \user_badges_schema()
  2. 6 user_badges.install \user_badges_schema()
  3. 7.4 user_badges.install \user_badges_schema()
  4. 7 user_badges.install \user_badges_schema()
  5. 7.2 user_badges.install \user_badges_schema()

Implements hook_schema().

File

./user_badges.install, line 24
@brief User Badges install file

Code

function user_badges_schema() {
  $schema = array();
  $schema['user_badges_badges'] = array(
    'description' => 'Defines the user badges themselves (image, weight etc.)',
    'fields' => array(
      'bid' => array(
        'description' => 'Original badge ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'Badge name',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
      'image' => array(
        'description' => 'Associated image. Can be a full URL, or a relative path for the image library.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'description' => 'Order in list',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'href' => array(
        'description' => 'Badge description URL',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'tid' => array(
        'description' => 'Optional associated taxonomn term id',
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
      ),
      'unhideable' => array(
        'description' => 'If this is 1, the badge cannot be hidden by being moved down in weight. It will always show up.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'fixedweight' => array(
        'description' => 'If this is 1, the badge cannot have a user assigned weight, regardless of settings.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'doesnotcounttolimit' => array(
        'description' => 'If this is 1, the badge does not count towards the limit for number of badges to display per user.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'bid',
    ),
    'indexes' => array(
      'bid_weight_name' => array(
        'bid',
        'weight',
        'name',
      ),
      'weight_name' => array(
        'weight',
        'name',
      ),
      'tid_name' => array(
        'tid',
        'name',
      ),
    ),
  );
  $schema['user_badges_roles'] = array(
    'description' => 'Stores which roles grant which badges.',
    'fields' => array(
      'rid' => array(
        'description' => 'Role ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'bid' => array(
        'description' => 'Badge ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'bid',
      'rid',
    ),
  );
  $schema['user_badges_user'] = array(
    'description' => 'Stores which users have which badges.',
    'fields' => array(
      'uid' => array(
        'description' => 'User ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'bid' => array(
        'description' => 'Badge ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => "Whether set as part of the role, or individually assigned ('user', 'role')",
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'userweight' => array(
        'description' => 'Order in list, as set by user.',
        'type' => 'int',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'bid',
      'uid',
      'type',
    ),
    'indexes' => array(
      'uid_bid' => array(
        'uid',
        'bid',
      ),
      'uid_weight' => array(
        'uid',
        'userweight',
      ),
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}