| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: xmlsitemap_user.install,v 1.6.2.15.2.10 2010/04/30 03:31:22 davereid Exp $ 3 4 /** 5 * @file 6 * Install and uninstall schema and functions for the xmlsitemap_user module. 7 */ 8 9 /** 10 * Implements hook_requirements(). 11 */ 12 function xmlsitemap_user_requirements($phase) { 13 $requirements = array(); 14 $t = get_t(); 15 16 if ($phase == 'runtime') { 17 if (!user_access('access user profiles', drupal_anonymous_user())) { 18 $requirements['xmlsitemap_user_anonymous_permission'] = array( 19 'title' => $t('XML sitemap user'), 20 'value' => $t('Anonymous access to user profiles'), 21 'description' => $t('In order to list user profile links in the sitemap, the anonymous user must have the <a href="@perm-link"><em>access user profiles</em> permission</a>.', array('@perm-link' => url('admin/user/permissions', array('fragment' => 'module-user')))), 22 'severity' => REQUIREMENT_ERROR, 23 ); 24 } 25 } 26 27 return $requirements; 28 } 29 30 /** 31 * Implements hook_uninstall(). 32 */ 33 function xmlsitemap_user_uninstall() { 34 drupal_load('module', 'user'); 35 drupal_load('module', 'xmlsitemap'); 36 db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap_settings_user_%%"); 37 xmlsitemap_link_bundle_delete('user', 'user'); 38 } 39 40 /** 41 * Migrate 6.x-1.x user variables. 42 */ 43 function xmlsitemap_user_update_6200() { 44 drupal_load('module', 'user'); 45 $status = 0; 46 $priority = variable_get('xmlsitemap_user_default_priority', 0.5); 47 if ($priority == -1) { 48 $priority = 0.5; 49 } 50 else { 51 $status = 1; 52 } 53 variable_set('xmlsitemap_settings_user_user', array('status' => $status, 'priority' => $priority)); 54 55 if (db_table_exists('xmlsitemap_user_role')) { 56 $query = db_query("SELECT rid, priority FROM {xmlsitemap_user_role}"); 57 while ($role = db_fetch_object($query)) { 58 $status = 0; 59 if ($role->priority == -1) { 60 $role->priority = 0.5; 61 } 62 else { 63 $status = 1; 64 } 65 variable_set('xmlsitemap_settings_user_' . $role->rid, array('status' => $status, 'priority' => $role->priority)); 66 } 67 } 68 69 return array(); 70 } 71 72 /** 73 * Migrate 6.x-1.x user data. 74 */ 75 function xmlsitemap_user_update_6201(&$context) { 76 $ret = array(); 77 78 if (!db_table_exists('xmlsitemap_user')) { 79 // Skip if the 6.x-1.x table doesn't exist. 80 return $ret; 81 } 82 elseif (db_column_exists('xmlsitemap', 'sid')) { 83 // Skip if the main {xmlsitemap} table hasn't been upgraded yet. 84 $ret['#abort'] = array('success' => FALSE, 'query' => 'The primary xmlsitemap table upgrade has not yet been completed. Re-run the upgrade script.'); 85 return $ret; 86 } 87 88 if (!isset($context['progress'])) { 89 $context['progress'] = $context['last'] = 0; 90 $context['count'] = db_result(db_query("SELECT COUNT(uid) FROM {xmlsitemap_user} WHERE priority_override <> -2 AND uid > %d", $context['last'])); 91 } 92 93 drupal_load('module', 'xmlsitemap_user'); 94 drupal_load('module', 'xmlsitemap'); 95 96 $query = db_query_range("SELECT uid, priority_override FROM {xmlsitemap_user} WHERE priority_override <> -2 AND uid > %d ORDER BY uid", $context['last'], 0, 10); 97 while ($record = db_fetch_object($query)) { 98 if ($account = user_load($record->uid)) { 99 $link = xmlsitemap_user_create_link($account); 100 if ($record->priority_override == -1) { 101 $link['status'] = 0; 102 $link['status_override'] = 1; 103 } 104 elseif ($record->priority_override != -2) { 105 $link['priority'] = $record->priority_override; 106 $link['priority_override'] = 1; 107 } 108 xmlsitemap_link_save($link); 109 } 110 $context['last'] = $record->uid; 111 $context['progress']++; 112 } 113 114 $ret['#finished'] = empty($context['count']) ? 1 : ($context['progress'] / $context['count']); 115 return $ret; 116 } 117 118 /** 119 * Cleanup any remaining 6.x-1.x tables, variables or weights. 120 */ 121 function xmlsitemap_user_update_6202() { 122 $ret = array(); 123 if (db_table_exists('xmlsitemap_user')) { 124 db_drop_table($ret, 'xmlsitemap_user'); 125 } 126 if (db_table_exists('xmlsitemap_user_role')) { 127 db_drop_table($ret, 'xmlsitemap_user_role'); 128 } 129 variable_del('xmlsitemap_user_default_priority'); 130 $ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE type = 'module' AND name = 'xmlsitemap_user'"); 131 return $ret; 132 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |