Projet

Général

Profil

Paste
Télécharger (4,99 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / commerce / modules / checkout / commerce_checkout.install @ dbb0c974

1
<?php
2

    
3
/**
4
 * Implements hook_schema().
5
 */
6
function commerce_checkout_schema() {
7
  $schema = array();
8

    
9
  $schema['commerce_checkout_pane'] = array(
10
    'description' => 'Checkout pane configuration data.',
11
    'fields' => array(
12
      'pane_id' => array(
13
        'description' => 'The machine readable name of the order state.',
14
        'type' => 'varchar',
15
        'length' => 255,
16
        'not null' => TRUE,
17
      ),
18
      'page' => array(
19
        'description' => 'The ID of the checkout page on which this pane appears.',
20
        'type' => 'varchar',
21
        'length' => 255,
22
        'not null' => TRUE,
23
        'default' => '1',
24
      ),
25
      'fieldset' => array(
26
        'description' => 'Boolean value indicating whether or not the pane should appear in a fieldset.',
27
        'type' => 'int',
28
        'size' => 'tiny',
29
        'not null' => TRUE,
30
        'default' => 1,
31
      ),
32
      'collapsible' => array(
33
        'description' => 'Boolean value indicating whether or not the pane should appear collapsed.',
34
        'type' => 'int',
35
        'size' => 'tiny',
36
        'not null' => TRUE,
37
        'default' => 0,
38
      ),
39
      'collapsed' => array(
40
        'description' => 'Boolean value indicating whether or not the pane should appear collapsed.',
41
        'type' => 'int',
42
        'size' => 'tiny',
43
        'not null' => TRUE,
44
        'default' => 0,
45
      ),
46
      'weight' => array(
47
        'description' => 'The sorting weight of the status for lists of statuses.',
48
        'type' => 'int',
49
        'size' => 'small',
50
        'not null' => TRUE,
51
        'default' => 0,
52
      ),
53
      'enabled' => array(
54
        'description' => 'Boolean value indicating whether or not the pane is enabled.',
55
        'type' => 'int',
56
        'size' => 'tiny',
57
        'not null' => TRUE,
58
        'default' => 1,
59
      ),
60
      'review' => array(
61
        'description' => 'Boolean value indicating whether or not the pane should appear on the checkout review.',
62
        'type' => 'int',
63
        'size' => 'tiny',
64
        'not null' => TRUE,
65
        'default' => 1,
66
      ),
67
    ),
68
    'primary key' => array('pane_id'),
69
  );
70

    
71
  return $schema;
72
}
73

    
74
/**
75
 * Implements hook_uninstall().
76
 */
77
function commerce_checkout_uninstall() {
78
  variable_del('commerce_checkout_completion_message');
79
}
80

    
81
/**
82
 * Delete the deprecated checkout completion message override variable.
83
 */
84
function commerce_checkout_update_7100() {
85
  variable_del('commerce_checkout_completion_message_override');
86
}
87

    
88
/**
89
 * Disable the new local action to simulate checkout completion for an order.
90
 */
91
function commerce_checkout_update_7101() {
92
  variable_set('commerce_order_simulate_checkout_link', FALSE);
93
  return t('A new local action link on order edit forms for simulating checkout completion for an order has been disabled by default; enable it on the order settings form if desired.');
94
}
95

    
96
/**
97
 * Disable the new checkout completion rule that updates order created dates to
98
 * the checkout completion date.
99
 */
100
function commerce_checkout_update_7102() {
101
  variable_set('enable_commerce_checkout_order_created_date_update', FALSE);
102
  return t('A new core checkout completion rule has been added that updates order creation timestamps to the time of checkout completion. It has been disabled by default to not interfere with existing order workflows, but you may enable it in your checkout settings if desired.');
103
}
104

    
105
/**
106
 * If the variable commerce_checkout_run_update_7103 is set, change all user
107
 * names that contain @ and look like an e-mail address to prevent the
108
 * disclosure of e-mail addresses to non-trusted users. Refer to the release
109
 * notes for Commerce 1.10 for instructions on how to set this variable.
110
 * Otherwise you are responsible to clean the usernames on your own.
111
 */
112
function commerce_checkout_update_7103(&$sandbox) {
113
  // Every site may not want to disrupt all their account usernames with this
114
  // update, so we require sites to set a variable explicitly to run the update.
115
  // Sites that do not must do their own handling of the security issue.
116
  if (!variable_get('commerce_checkout_run_update_7103', FALSE)) {
117
    return t('Skipped update 7103 because the variable commerce_checkout_run_update_7103 is not set. You must make sure usernames are not valid e-mail adresses on your own.');
118
  }
119

    
120
  if (!isset($sandbox['progress'])) {
121
    $sandbox['progress'] = 0;
122
    $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE name LIKE '%@%'")->fetchField();
123
  }
124

    
125
  // Update 100 user names at a time.
126
  $names = db_query("SELECT uid, name FROM {users} WHERE name LIKE '%@%' LIMIT 100")->fetchAllKeyed();
127
  $order = new stdClass();
128
  foreach ($names as $uid => $name) {
129
    $order->mail = $name;
130
    $new_name = commerce_order_get_properties($order, array(), 'mail_username');
131
    db_update('users')
132
      ->fields(array(
133
        'name' => $new_name,
134
      ))
135
      ->condition('uid', $uid)
136
      ->execute();
137
    $sandbox['progress']++;
138
  }
139

    
140
  $sandbox['#finished'] = empty($names) ? 1 : ($sandbox['progress'] / $sandbox['max']);
141

    
142
  return t('Usernames resembling e-mail addresses have been cleaned.');
143
}