You are here

seochecklist.install in SEO Checklist 7.3

Install, update and uninstall functions for the seochecklist module.

File

seochecklist.install
View source
<?php

// $Id$

/**
 * @file
 * Install, update and uninstall functions for the seochecklist module.
 */

/**
 * Implementation of hook_schema().
 */
function seochecklist_schema() {
  $schema['seo_checklist'] = array(
    'description' => 'seo_checklist',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'size' => 'tiny',
        'not null' => TRUE,
        'description' => 'id',
      ),
      'completed' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'UNIX timestamp of when this task was completed, or 0 if the task has not yet been completed.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {user}.uid of the account that completed this task.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function seochecklist_install() {
  global $user;
  menu_rebuild();
  db_query("INSERT INTO {seo_checklist} (id, completed, uid) VALUES (:id, :time, :uid)", array(
    ':id' => 69,
    ':time' => time(),
    ':uid' => $user->uid,
  ));
}

/**
 * Implementation of hook_uninstall().
 */
function seochecklist_uninstall() {

  //drupal_uninstall_schema('seochecklist');
  variable_del('seo_checklist_link');
  variable_del('seo_checklist_thanks');
  variable_del('seo_checklist_podcast');
  variable_del('seo_checklist_book_references');
}

/**
 * Update from 6.x-1.x to 6.x-2.x.
 */
function seochecklist_update_6001() {
  $ret = array();
  $linked_seo = db_query("SELECT linked_seo FROM {seo_checklist} ORDER BY id DESC LIMIT 1")
    ->fetchField();

  //$result = db_fetch_object($query);
  variable_set('seo_checklist_link', intval($linked_seo));
  $result = db_query("SELECT extra2, extra3 FROM {seo_checklist} WHERE id = 1")
    ->fetchObject();
  variable_set('seo_checklist_thanks', intval($result->extra2));
  variable_set('seo_checklist_podcast', intval($result->extra3));
  db_drop_field('seo_checklist', 'extra2');
  db_drop_field('seo_checklist', 'extra3');
  db_drop_field('seo_checklist', 'linked_seo');
  db_drop_field('seo_group', 'subgroup');
  db_drop_table('seo_subgroup');

  //return $ret;
}

/**
 * Fix the link in the clean URL task.
 */
function seochecklist_update_6202() {
  $ret = array();
  $ret[] = update_sql("UPDATE {seo_checklist} SET name = 'Clean URLs - Activate (Usually automatic. Please double-check!)', configure = 'admin/settings/clean-urls' WHERE id = 2");

  //return $ret;
}

/**
 * Update from Live to Bing and fix links.
 */
function seochecklist_update_6203() {
  $ret = array();
  $ret[] = db_query("UPDATE {seo_checklist} SET name = 'Get a Windows Live ID - You will need this for steps that follow - <a href=\"https://signup.live.com/\">https://signup.live.com/</a>' WHERE id = 44");
  $ret[] = db_query("UPDATE {seo_checklist} SET name = 'Login to Bing - <a href=\"http://www.bing.com/webmaster/\">http://www.bing.com/webmaster/</a>', order_id = 17 WHERE id = 42");
  $ret[] = db_query("UPDATE {seo_checklist} SET name = 'Authenticate your site with Bing', order_id = 19 WHERE id = 43");
  $ret[] = db_query("UPDATE {seo_checklist} SET name = 'Submit your XML Sitemap to Bing - <a href=\"http://www.bing.com/webmaster/WebmasterAddSitesPage.aspx\">http://webmaster.live.com/webmaster/WebmasterAddSitesPage.aspx</a>', order_id = 21 WHERE id = 28");
  $ret[] = db_query("UPDATE {seo_checklist} SET module = 'xmlsitemap' WHERE id = 21");

  //return $ret;
}

/**
 * Convert the date_changed and option_checked fields into one UNIX completed
 * field.
 */
function seochecklist_update_6204() {
  $ret = array();
  db_add_field('seo_checklist', 'completed', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'description' => 'UNIX timestamp of when this task was completed.',
  ));
  $query = db_query("SELECT id, date_changed FROM {seo_checklist} WHERE option_checked <> 0");
  foreach ($query as $record) {
    $record->changed = strtotime($record->date_changed);
    if (!$record->changed) {
      $record->changed = time();
    }
    $ret[] = db_query("UPDATE {seo_checklist} SET completed = {$record->changed} WHERE id = {$record->id}");
  }
  db_drop_field('seo_checklist', 'date_changed');
  db_drop_field('seo_checklist', 'option_checked');
  db_drop_field('seo_checklist', 'checked_module');

  //return $ret;
}

/**
 * Remove the {seo_checklist}.subgroup_id field and add {seo_checklist}.uid.
 */
function seochecklist_update_6205() {
  $ret = array();
  db_drop_field('seo_checklist', 'subgroup_id');
  db_add_field('seo_checklist', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'description' => 'The {user}.uid of the account that completed this task.',
  ));
  $ret[] = db_query("UPDATE {seo_checklist} SET module = LOWER(module)");

  //return $ret;
}

/**
 * Fixed the link to Google Local Business Center.
 */
function seochecklist_update_6206() {
  $ret = array();
  $ret[] = db_query("UPDATE {seo_checklist} SET name = 'If appropriate, submit your company to Google Local Business Center - <a href=\"https://www.google.com/local/add/login\">https://www.google.com/local/add/login</a>' WHERE id = 29");

  //return $ret;
}
function seochecklist_update_6207() {
  $ret = array();
  $ret[] = db_query("UPDATE {seo_group} SET name = 'Social Media' WHERE id = 8");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (47, 7, 'Site Verification Module', 'site_verify', 'http://drupal.org/project/site_verify', 'admin/modules', '', 0)");
  $ret[] = db_query("INSERT INTO {seo_group} VALUES (10, 'Geographic', '')");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (50, 10, 'hCard Module', 'hcard', 'http://drupal.org/project/hcard', 'admin/modules', '', 1)");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (51, 10, 'Use the Meta Tags module to add geo meta tags to your site.', '', '', '', '', 2)");
  $ret[] = db_query("INSERT INTO {seo_group} VALUES (11, 'Optional (but helpful)', '')");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (52, 11, 'Vertical Tabs Module', 'vertical_tabs', 'http://drupal.org/project/vertical_tabs', 'admin/modules', '', 1)");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (53, 11, 'Administration Menu', 'admin_menu', 'http://drupal.org/project/admin_menu', 'admin/modules', '', 2)");
  $ret[] = db_query("INSERT INTO {seo_group} VALUES (12, 'Performance', '')");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (54, 12, 'Turn on Drupal\\'s built in caching.', '', '', '', 'admin/settings/performance/default', 1)");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (55, 12, 'Boost Module', 'boost', 'http://drupal.org/project/boost', 'admin/modules', 'admin/settings/performance/boost', 2)");
  $ret[] = db_query("INSERT INTO {seo_checklist} (id, group_id, name, module, download, enable, configure, order_id) VALUES (56, 12, 'Authcache Module', 'authcache', 'http://drupal.org/project/authcache', 'admin/modules', '', 3)");

  //return $ret;
}
function seochecklist_update_6301() {
  global $user;
  db_drop_table('seo_group');
  db_drop_field('seo_checklist', 'group_id');
  db_drop_field('seo_checklist', 'name');
  db_drop_field('seo_checklist', 'module');
  db_drop_field('seo_checklist', 'download');
  db_drop_field('seo_checklist', 'enable');
  db_drop_field('seo_checklist', 'configure');
  db_drop_field('seo_checklist', 'order_id');
  if (variable_get('seo_checklist_link', FALSE)) {
    db_query("INSERT INTO {seo_checklist} (id, completed, uid) VALUES (:id, :time, :uid)", array(
      ':id' => 66,
      ':time' => time(),
      ':uid' => $user->uid,
    ));
  }
  if (variable_get('seo_checklist_thanks', FALSE)) {
    db_query("INSERT INTO {seo_checklist} (id, completed, uid) VALUES (:id, :time, :uid)", array(
      ':id' => 67,
      ':time' => time(),
      ':uid' => $user->uid,
    ));
  }
  if (variable_get('seo_checklist_podcast', FALSE)) {
    db_query("INSERT INTO {seo_checklist} (id, completed, uid) VALUES (:id, :time, :uid)", array(
      ':id' => 68,
      ':time' => time(),
      ':uid' => $user->uid,
    ));
  }
  if (variable_get('seo_checklist_book_references', FALSE)) {
    db_query("INSERT INTO {seo_checklist} (id, completed, uid) VALUES (:id, :time, :uid)", array(
      ':id' => 69,
      ':time' => time(),
      ':uid' => $user->uid,
    ));
  }

  //variable_del('seo_checklist_link');
  variable_del('seo_checklist_thanks');
  variable_del('seo_checklist_podcast');
  variable_del('seo_checklist_book_references');
}

Functions

Namesort descending Description
seochecklist_install Implementation of hook_install().
seochecklist_schema Implementation of hook_schema().
seochecklist_uninstall Implementation of hook_uninstall().
seochecklist_update_6001 Update from 6.x-1.x to 6.x-2.x.
seochecklist_update_6202 Fix the link in the clean URL task.
seochecklist_update_6203 Update from Live to Bing and fix links.
seochecklist_update_6204 Convert the date_changed and option_checked fields into one UNIX completed field.
seochecklist_update_6205 Remove the {seo_checklist}.subgroup_id field and add {seo_checklist}.uid.
seochecklist_update_6206 Fixed the link to Google Local Business Center.
seochecklist_update_6207
seochecklist_update_6301