1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Implementation of hook_schema().
|
5 |
|
|
*/
|
6 |
|
|
function panels_node_schema() {
|
7 |
|
|
// This should always point to our 'current' schema. This makes it relatively easy
|
8 |
|
|
// to keep a record of schema as we make changes to it.
|
9 |
|
|
return panels_node_schema_1();
|
10 |
|
|
}
|
11 |
|
|
|
12 |
|
|
/**
|
13 |
|
|
* Schema version 1 for Panels in D6.
|
14 |
|
|
*/
|
15 |
|
|
function panels_node_schema_1() {
|
16 |
|
|
$schema = array();
|
17 |
|
|
|
18 |
|
|
$schema['panels_node'] = array(
|
19 |
|
|
'fields' => array(
|
20 |
|
|
'nid' => array(
|
21 |
|
|
'type' => 'int',
|
22 |
|
|
'not null' => TRUE,
|
23 |
|
|
'default' => 0,
|
24 |
|
|
),
|
25 |
|
|
'css_id' => array(
|
26 |
|
|
'type' => 'varchar',
|
27 |
|
|
'length' => '255',
|
28 |
|
|
),
|
29 |
|
|
'did' => array(
|
30 |
|
|
'type' => 'int',
|
31 |
|
|
'not null' => TRUE,
|
32 |
|
|
),
|
33 |
|
|
'pipeline' => array(
|
34 |
|
|
'type' => 'varchar',
|
35 |
|
|
'length' => '255',
|
36 |
|
|
),
|
37 |
|
|
),
|
38 |
|
|
'primary key' => array('did'),
|
39 |
|
|
);
|
40 |
|
|
|
41 |
|
|
return $schema;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
* Implementation of hook_install().
|
46 |
|
|
*/
|
47 |
|
|
function panels_node_install() {
|
48 |
|
|
db_query("UPDATE {system} SET weight = 11 WHERE name = 'panels_node'");
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
/**
|
52 |
|
|
* Implementation of hook_uninstall().
|
53 |
|
|
*/
|
54 |
|
|
function panels_node_uninstall() {
|
55 |
|
|
db_query("DELETE FROM {node} WHERE type = 'panel'");
|
56 |
|
|
drupal_uninstall_schema('panels_node');
|
57 |
|
|
}
|
58 |
|
|
|
59 |
136a805a
|
Assos Assos
|
/**
|
60 |
|
|
* Implements hook_update_dependencies().
|
61 |
|
|
*/
|
62 |
|
|
function panels_node_update_dependencies() {
|
63 |
|
|
// Update 7301 requires panels storage support
|
64 |
|
|
$dependencies['panels_node'][7301] = array(
|
65 |
|
|
'panels' => 7305,
|
66 |
|
|
);
|
67 |
|
|
|
68 |
|
|
return $dependencies;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
85ad3d82
|
Assos Assos
|
/**
|
72 |
|
|
* Implementation of hook_update to handle adding a pipeline
|
73 |
|
|
*/
|
74 |
|
|
function panels_node_update_6001() {
|
75 |
|
|
$ret = array();
|
76 |
|
|
$field = array(
|
77 |
|
|
'type' => 'varchar',
|
78 |
|
|
'length' => '255',
|
79 |
|
|
);
|
80 |
|
|
|
81 |
|
|
db_add_field('panels_node', 'pipeline', $field);
|
82 |
|
|
return $ret;
|
83 |
|
|
}
|
84 |
136a805a
|
Assos Assos
|
|
85 |
|
|
/**
|
86 |
|
|
* Migrate legacy Drupal 6 permissions to Drupal 7.
|
87 |
|
|
*/
|
88 |
|
|
function panels_node_update_7301() {
|
89 |
|
|
$permissions = array(
|
90 |
|
|
'create panel-nodes' => 'create panel content',
|
91 |
|
|
'edit any panel-nodes' => 'edit any panel content',
|
92 |
|
|
'edit own panel-nodes' => 'edit own panel content',
|
93 |
|
|
'delete any panel-nodes' => 'delete any panel content',
|
94 |
|
|
'delete own panel-nodes' => 'delete own panel content',
|
95 |
|
|
);
|
96 |
|
|
foreach ($permissions as $legacy_permission => $new_permission) {
|
97 |
|
|
$query = db_select('role_permission', 'p')
|
98 |
|
|
->fields('p', array('rid'))
|
99 |
|
|
->condition('permission', $legacy_permission);
|
100 |
|
|
$rids = $query->execute()->fetchCol();
|
101 |
|
|
foreach ($rids as $rid) {
|
102 |
|
|
// Insert the new permission if it doesn't already exist.
|
103 |
|
|
db_merge('role_permission')
|
104 |
|
|
->key(array(
|
105 |
|
|
'rid' => $rid,
|
106 |
|
|
'permission' => $new_permission,
|
107 |
|
|
))
|
108 |
|
|
->insertFields(array(
|
109 |
|
|
'rid' => $rid,
|
110 |
|
|
'permission' => $new_permission,
|
111 |
|
|
'module' => 'node',
|
112 |
|
|
))
|
113 |
|
|
->execute();
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
// Delete the legacy permission.
|
117 |
|
|
db_delete('role_permission')
|
118 |
|
|
->condition('permission', $legacy_permission)
|
119 |
|
|
->execute();
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
2545992a
|
Assos Assos
|
/**
|
124 |
136a805a
|
Assos Assos
|
* Set the storage type and id on existing panels nodes.
|
125 |
|
|
*/
|
126 |
|
|
function panels_node_update_7302() {
|
127 |
|
|
if (!isset($sandbox['progress'])) {
|
128 |
|
|
// Initialize batch update information.
|
129 |
|
|
$sandbox['progress'] = (float)0;
|
130 |
|
|
$sandbox['current_did'] = -1;
|
131 |
|
|
$sandbox['max'] = db_query("SELECT COUNT(pd.did)
|
132 |
|
|
FROM {panels_display} pd
|
133 |
|
|
JOIN {panels_node} pn ON pn.did = pd.did
|
134 |
|
|
WHERE pd.storage_type = ''")->fetchField();
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
// Set a limit of how many rows to process per batch.
|
138 |
|
|
$limit = 1000;
|
139 |
|
|
|
140 |
|
|
// Run the query
|
141 |
|
|
$result = db_query_range("SELECT pd.did, pn.nid
|
142 |
|
|
FROM {panels_display} pd
|
143 |
|
|
JOIN {panels_node} pn ON pn.did = pd.did
|
144 |
|
|
WHERE pd.storage_type = '' AND pd.did > :current_did", 0, $limit, array(':current_did' => $sandbox['current_did']));
|
145 |
|
|
|
146 |
|
|
foreach ($result as $row) {
|
147 |
|
|
db_update('panels_display')
|
148 |
|
|
->fields(array(
|
149 |
|
|
'storage_type' => 'panels_node',
|
150 |
|
|
'storage_id' => $row->nid,
|
151 |
|
|
))
|
152 |
|
|
->condition('did', $row->did)
|
153 |
|
|
->execute();
|
154 |
|
|
|
155 |
|
|
// Update our progress information.
|
156 |
|
|
$sandbox['progress']++;
|
157 |
|
|
$sandbox['current_did'] = $row->did;
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
// Set the "finished" status, to tell batch engine whether this function
|
161 |
|
|
// needs to run again.
|
162 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
163 |
|
|
|
164 |
|
|
if ($sandbox['#finished']) {
|
165 |
|
|
return t('Added the storage type for panels_node to relevant panels displays');
|
166 |
|
|
}
|
167 |
|
|
} |