seochecklist.install in SEO Checklist 5.2
Same filename and directory in other branches
Install, update and uninstall functions for the seochecklist module.
File
seochecklist.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the seochecklist module.
*/
/**
* Implementation of hook_install().
*/
function seochecklist_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {seo_group} (\n id tinyint NOT NULL auto_increment,\n name varchar(255) NOT NULL default '',\n description varchar(255) NOT NULL default '',\n PRIMARY KEY (id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {seo_checklist} (\n id tinyint NOT NULL auto_increment,\n group_id tinyint NOT NULL default '0',\n name varchar(255) NOT NULL default '',\n module varchar(255) NOT NULL default '',\n download varchar(255) NOT NULL default '',\n enable varchar(255) NOT NULL default '',\n configure varchar(255) NOT NULL default '',\n order_id tinyint NOT NULL default '0',\n completed int unsigned NOT NULL default '0',\n uid int unsigned NOT NULL default '0',\n PRIMARY KEY (id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {seo_group} (\n id serial CHECK (id >= 0),\n name varchar(255) NOT NULL default '',\n description varchar(255) NOT NULL default '',\n PRIMARY KEY (id)\n )");
db_query("CREATE TABLE {seo_checklist} (\n id serial CHECK (id >= 0),\n group_id smallint NOT NULL default '0',\n name varchar(255) NOT NULL default '',\n module varchar(255) NOT NULL default '',\n download varchar(255) NOT NULL default '',\n enable varchar(255) NOT NULL default '',\n configure varchar(255) NOT NULL default '',\n order_id smallint NOT NULL default '0',\n completed int_unsigned NOT NULL default '0',\n uid int_unsigned NOT NULL default '0',\n PRIMARY KEY (id)\n )");
break;
}
$task_fields = "(id, group_id, name, module, download, enable, configure, order_id)";
// Page title tasks
db_query("INSERT INTO {seo_group} VALUES (1, 'Page Titles', 'The single most important thing you can do for on-site SEO.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (39, 1, 'Token (required for other modules to function)', 'token', 'http://drupal.org/project/token', 'admin/build/modules', '', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (1, 1, 'Page Title Module', 'page_title', 'http://drupal.org/project/page_title', 'admin/build/modules', 'admin/content/page_title', 2)");
// URL tasks
db_query("INSERT INTO {seo_group} VALUES (2, 'URL paths', 'The second most important thing you can do.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (2, 2, 'Clean URLs - Activate (Usually automatic. Please double-check!)', '', '', '', 'admin/settings/clean-urls', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (3, 2, 'Find URL Alias Module', 'find_path', 'http://drupal.org/project/find_path', 'admin/build/modules', '', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (6, 2, 'Global Redirect Module', 'globalredirect', 'http://drupal.org/project/globalredirect', 'admin/build/modules', '', 3)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (4, 2, 'Simple: URLify Module', 'urlify', 'http://drupal.org/project/urlify', 'admin/build/modules', 'settings', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (5, 2, 'Powerful: Pathauto Module', 'pathauto', 'http://drupal.org/project/pathauto', 'admin/build/modules', 'admin/settings/pathauto', 2)");
// Search engine account tasks
db_query("INSERT INTO {seo_group} VALUES (3, 'Create Search Engine Accounts', 'Set yourself up with the search engines.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (7, 3, 'Get a Google Account - You will need this for several of the steps that follow - <a href=\"https://www.google.com/accounts/NewAccount\">https://www.google.com/accounts/NewAccount</a>', '', '', '', '', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (8, 3, 'Get a Yahoo Account - You will need this for steps that follow - <a href=\"http://www.yahoo.com/r/m7\">http://www.yahoo.com/r/m7</a>', '', '', '', '', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (44, 3, 'Get a Windows Live ID - You will need this for steps that follow - <a href=\"https://signup.live.com/\">https://signup.live.com/</a>', '', '', '', '', 3)");
// Visitor tracking tasks
db_query("INSERT INTO {seo_group} VALUES (4, 'Track your visitors', 'Know where your visitors are coming from and what they do while visiting your site.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (9, 4, 'Google Analytics Module', 'googleanalytics', 'http://drupal.org/project/google_analytics', 'admin/build/modules', 'admin/settings/googleanalytics', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (10, 4, 'Sign in to your Google Analytics Account - <a href=\"http://www.google.com/analytics\">http://www.google.com/analytics</a>', '', '', '', '', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (11, 4, 'Create an Analytics for your website', '', '', '', '', 3)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (12, 4, 'Paste Google Analytics code into Google Analytics Module', '', '', '', '', 4)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (13, 4, 'Authenticate your site with Google Analytics', '', '', '', '', 5)");
// Page content tasks
db_query("INSERT INTO {seo_group} VALUES (5, 'Page content', 'Take control of your page content.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (14, 5, 'Excerpt Module', 'excerpt', 'http://drupal.org/project/excerpt', 'admin/build/modules', '', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (15, 5, 'Meta Tags Module (AKA Nodewords)', 'nodewords', 'http://drupal.org/project/nodewords', 'admin/build/modules', 'admin/content/nodewords', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (16, 5, 'Scheduler Module', 'scheduler', 'http://drupal.org/project/scheduler', 'admin/build/modules', '', 3)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (17, 5, 'Safe HTML Module', 'safehtml', 'http://drupal.org/project/safehtml', 'admin/build/modules', 'admin/settings/filters/1', 4)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (18, 5, 'Search 404 Module', 'search404', 'http://drupal.org/project/search404', 'admin/build/modules', 'admin/settings/search404', 5)");
// Source code tasks
db_query("INSERT INTO {seo_group} VALUES (6, 'Clean code', 'Well written markup is very important to the search engine spiders.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (19, 6, 'Validate your site - <a href=\"http://validator.w3.org/\">http://validator.w3.org/</a>', '', '', '', '', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (20, 6, 'Check your links - <a href=\"http://validator.w3.org/checklink\">http://validator.w3.org/checklink</a>', '', '', '', '', 2)");
// XML sitemap tasks
db_query("INSERT INTO {seo_group} VALUES (7, 'Submit your Site to the search engines.', 'Now that you\\'ve got your site ready for the search engines, tell them about it!')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (21, 7, 'XML Sitemap Module', 'xmlsitemap', 'http://drupal.org/project/xmlsitemap', 'admin/build/modules', 'admin/settings/xmlsitemap', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (22, 7, 'Login to Google Webmaster Tools - <a href=\"http://www.google.com/webmasters/tools\">http://www.google.com/webmasters/tools</a>', '', '', '', '', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (23, 7, 'Authenticate your site with Google', '', '', '', '', 3)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (24, 7, 'Submit your XML Sitemap to Google - <a href=\"http://www.google.com/webmasters/sitemaps/\">http://www.google.com/webmasters/sitemaps/</a>', '', '', '', '', 4)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (25, 7, 'Login to Yahoo Site Explorer Account - <a href=\"https://siteexplorer.search.yahoo.com/\">https://siteexplorer.search.yahoo.com/</a>', '', '', '', '', 5)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (26, 7, 'Authenticate your site with Yahoo', '', '', '', '', 6)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (27, 7, 'Submit your XML Sitemap to Yahoo - <a href=\"https://siteexplorer.search.yahoo.com/submit\">https://siteexplorer.search.yahoo.com/submit</a>', '', '', '', '', 7)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (42, 7, 'Login to Bing - <a href=\"http://www.bing.com/webmaster/\">http://www.bing.com/webmaster/</a>', '', '', '', '', 8)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (43, 7, 'Authenticate your site with Bing', '', '', '', '', 9)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (28, 7, 'Submit your XML Sitemap to Bing - <a href=\"http://www.bing.com/webmaster/WebmasterAddSitesPage.aspx\">http://webmaster.live.com/webmaster/WebmasterAddSitesPage.aspx</a>', '', '', '', '', 10)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (29, 7, '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>', '', '', '', '', 11)");
// Social links tasks
db_query("INSERT INTO {seo_group} VALUES (8, 'Social Tracking', 'Using Social news sites, blogs, etc? Consider these:')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (30, 8, 'Digg This Module', 'diggthis', 'http://drupal.org/project/diggthis', 'admin/build/modules', 'admin/settings/diggthis', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (31, 8, 'Service Links Module', 'service_links', 'http://drupal.org/project/service_links', 'admin/build/modules', 'admin/settings/service_links', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (32, 8, 'Trackback Module', 'trackback', 'http://drupal.org/project/trackback', 'admin/build/modules', 'admin/settings/trackback', 3)");
// Spam tasks
db_query("INSERT INTO {seo_group} VALUES (9, 'Protect your site from Spam', 'If your site will get heavy use from visitors creating accounts, commenting and/or creating content then consider these. NOTE: Most sites just need Mollom. The other modules are here in case Mollom does not work for you for some reason.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (40, 9, 'Mollom Module', 'mollom', 'http://drupal.org/project/mollom', 'admin/build/modules', 'admin/settings/mollom', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (33, 9, 'Captcha Module', 'captcha', 'http://drupal.org/project/captcha', 'admin/build/modules', 'admin/user/captcha', 2)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (34, 9, 'Akismet Module', 'akismet', 'http://drupal.org/project/akismet', 'admin/build/modules', 'admin/settings/akismet', 3)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (35, 9, 'http:BL Module', 'httpbl', 'http://drupal.org/project/httpbl', 'admin/build/modules', 'admin/settings/httpbl', 4)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (36, 9, 'Spam Module', 'spam', 'http://drupal.org/project/spam', 'admin/build/modules', 'admin/settings/spam', 5)");
// Beta modules
db_query("INSERT INTO {seo_group} VALUES (10, 'Beta Modules (Use with Caution!)', 'These are probably good modules but need some work. Test them first.')");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (37, 10, 'Google Proxy Hacking Protector Module', 'antiproxyhack', 'http://drupal.org/project/antiproxyhack', 'admin/build/modules', '', 1)");
db_query("INSERT INTO {seo_checklist} {$task_fields} VALUES (38, 10, 'Path Redirect Module', 'path_redirect', 'http://drupal.org/project/path_redirect', 'admin/build/modules', '', 2)");
}
/**
* Implementation of hook_uninstall().
*/
function seochecklist_uninstall() {
db_query("DROP TABLE {seo_group}");
db_query("DROP TABLE {seo_checklist}");
variable_del('seo_checklist_link');
variable_del('seo_checklist_thanks');
variable_del('seo_checklist_podcast');
}
/**
* Update from 5.x-1.x to 5.x-2.x.
*/
function seochecklist_update_5001() {
$ret = array();
$query = db_query("SELECT linked_seo FROM {seo_checklist} ORDER BY id DESC LIMIT 1");
$result = db_fetch_object($query);
variable_set('seo_checklist_link', intval($result->linked_seo));
$query = db_query("SELECT extra2, extra3 FROM {seo_checklist} WHERE id = 1");
$result = db_fetch_object($query);
variable_set('seo_checklist_thanks', intval($result->extra2));
variable_set('seo_checklist_podcast', intval($result->extra3));
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP extra2");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP extra3");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP linked_seo");
$ret[] = update_sql("ALTER TABLE {seo_group} DROP subgroup");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN extra2");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN extra3");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN linked_seo");
$ret[] = update_sql("ALTER TABLE {seo_group} DROP COLUMN subgroup");
break;
}
$ret[] = update_sql("DROP TABLE {seo_subgroup}");
return $ret;
}
/**
* Update from MSN to Bing and fix links.
*/
function seochecklist_update_5200() {
$ret = array();
$ret[] = update_sql("INSERT INTO {seo_checklist} (id, group_id, name, order_id) VALUES (44, 3, 'Get a Windows Live ID - You will need this for steps that follow - <a href=\"https://signup.live.com/\">https://signup.live.com/</a>', 3)");
$ret[] = update_sql("INSERT INTO {seo_checklist} (id, group_id, name, order_id) VALUES (42, 7, 'Login to Bing - <a href=\"http://www.bing.com/webmaster/\">http://www.bing.com/webmaster/</a>', 8)");
$ret[] = update_sql("INSERT INTO {seo_checklist} (id, group_id, name, order_id) VALUES (43, 7, 'Authenticate your site with Bing', 9)");
$ret[] = update_sql("UPDATE {seo_checklist} SET name = 'Submit your XML Sitemap to Bing - <a href=\"http://www.bing.com/webmaster/WebmasterAddSitesPage.aspx\">http://www.bing.com/webmaster/WebmasterAddSitesPage.aspx</a>', order_id = 10 WHERE id = 28");
$ret[] = update_sql("UPDATE {seo_checklist} SET order_id = 11 WHERE id = 29");
$ret[] = update_sql("UPDATE {seo_checklist} SET module = 'xmlsitemap', download = 'http://drupal.org/project/xmlsitemap', configure = 'admin/settings/xmlsitemap' WHERE id = 21");
return $ret;
}
/**
* Convert the date_changed and option_checked fields into one UNIX completed
* field.
*/
function seochecklist_update_5201() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {seo_checklist} ADD completed int unsigned NOT NULL default '0'");
break;
case 'pgsql':
db_add_column($ret, 'seo_checklist', 'completed', 'int', array(
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
break;
}
$query = db_query("SELECT id, date_changed FROM {seo_checklist} WHERE option_checked <> 0");
while ($record = db_fetch_object($query)) {
$record->changed = strtotime($record->date_changed);
if (!$record->changed) {
$record->changed = time();
}
$ret[] = update_sql("UPDATE {seo_checklist} SET completed = {$record->changed} WHERE id = {$record->id}");
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP date_changed");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP option_checked");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP checked_module");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN date_changed");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN option_checked");
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN checked_module");
break;
}
return $ret;
}
/**
* Remove the {seo_checklist}.subgroup_id field and add {seo_checklist}.uid.
*/
function seochecklist_update_5202() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP subgroup_id");
$ret[] = update_sql("ALTER TABLE {seo_checklist} ADD uid int unsigned NOT NULL default '0'");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {seo_checklist} DROP COLUMN subgroup_id");
db_add_column($ret, 'seo_checklist', 'uid', 'int', array(
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
break;
}
$ret[] = update_sql("UPDATE {seo_checklist} SET module = LOWER(module)");
return $ret;
}
/**
* Fixed the link to Google Local Business Center.
*/
function seochecklist_update_5203() {
$ret = array();
$ret[] = update_sql("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;
}
Functions
Name![]() |
Description |
---|---|
seochecklist_install | Implementation of hook_install(). |
seochecklist_uninstall | Implementation of hook_uninstall(). |
seochecklist_update_5001 | Update from 5.x-1.x to 5.x-2.x. |
seochecklist_update_5200 | Update from MSN to Bing and fix links. |
seochecklist_update_5201 | Convert the date_changed and option_checked fields into one UNIX completed field. |
seochecklist_update_5202 | Remove the {seo_checklist}.subgroup_id field and add {seo_checklist}.uid. |
seochecklist_update_5203 | Fixed the link to Google Local Business Center. |