| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: station.install,v 1.14 2009/04/19 23:01:58 drewish Exp $
|
| 4 |
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Implementation of hook_uninstall().
|
| 8 |
*/
|
| 9 |
function station_uninstall() {
|
| 10 |
variable_del('station_remote_archive_url');
|
| 11 |
variable_del('station_remote_schedule_url');
|
| 12 |
}
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Implementation of hook_update_last_removed().
|
| 16 |
*/
|
| 17 |
function station_update_last_removed() {
|
| 18 |
// We've removed the 5.x-1.x version of mymodule, including database updates.
|
| 19 |
// The next update function is mymodule_update_5200().
|
| 20 |
return 100;
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Rename the module's permissions to make them consistent with core.
|
| 25 |
*/
|
| 26 |
function station_update_6000() {
|
| 27 |
$ret = array();
|
| 28 |
|
| 29 |
$replacements = array(
|
| 30 |
// Archive
|
| 31 |
'administer archive' => array('administer station archive'),
|
| 32 |
// Catalog
|
| 33 |
'administer catalog' => array('administer station catalog'),
|
| 34 |
'view catalog' => array('view station album content'),
|
| 35 |
'create album content' => array('create station album content'),
|
| 36 |
'edit album content' => array('edit any station album content', 'delete any station album content'),
|
| 37 |
// Playlist
|
| 38 |
'create playlists' => array('create station playlist content'),
|
| 39 |
'edit own playlists' => array('edit own station playlist content', 'delete own station playlist content'),
|
| 40 |
// Program
|
| 41 |
'administer programs' => array('administer station programs'),
|
| 42 |
'edit program content' => array('edit any station program content'),
|
| 43 |
'edit own program content' => array('edit own station program content'),
|
| 44 |
// Schedule
|
| 45 |
'administer schedule' => array('administer station schedule'),
|
| 46 |
);
|
| 47 |
|
| 48 |
$result = db_query("SELECT rid, perm FROM {permission}");
|
| 49 |
while ($row = db_fetch_object($result)) {
|
| 50 |
$old_perms = explode(', ', $row->perm);
|
| 51 |
$new_perms = $old_perms;
|
| 52 |
|
| 53 |
// Rename the permission.
|
| 54 |
foreach ($replacements as $from => $to) {
|
| 55 |
$key = array_search($from, $old_perms);
|
| 56 |
if ($key !== FALSE) {
|
| 57 |
unset($new_perms[$key]);
|
| 58 |
$new_perms = array_merge($new_perms, $to);
|
| 59 |
}
|
| 60 |
}
|
| 61 |
|
| 62 |
// If they had 'access content' permissions before grant them the new
|
| 63 |
// view permissions.
|
| 64 |
if (in_array('access content', $old_perms)) {
|
| 65 |
$new_perms = array_merge($new_perms, array(
|
| 66 |
'view station playlist content',
|
| 67 |
'view station program content',
|
| 68 |
'view station schedule content',
|
| 69 |
));
|
| 70 |
}
|
| 71 |
|
| 72 |
$new_perm = db_escape_string(implode(', ', array_unique($new_perms)));
|
| 73 |
$ret[] = update_sql("UPDATE {permission} SET perm = '". db_escape_string($new_perm) ."' WHERE rid = ". (int) $row->rid);
|
| 74 |
}
|
| 75 |
|
| 76 |
return $ret;
|
| 77 |
}
|
| 78 |
|
| 79 |
/**
|
| 80 |
* Remove the "Add multiple" options and suggest that using the Submit Again
|
| 81 |
* module instead.
|
| 82 |
*/
|
| 83 |
function station_update_6001() {
|
| 84 |
$ret = array();
|
| 85 |
|
| 86 |
if (variable_get('station_catalog_redirect_on_add', TRUE) || variable_get('station_program_redirect_on_add', TRUE)) {
|
| 87 |
$ret[] = array('success' => TRUE, 'query' => t("The Station module's add multiple feature has been removed. If you'd like to retain this functionality you should install the <a href='http://drupal.org/project/submitagain'>Submit Again</a> module."));
|
| 88 |
}
|
| 89 |
variable_del('station_catalog_redirect_on_add');
|
| 90 |
variable_del('station_program_redirect_on_add');
|
| 91 |
|
| 92 |
return $ret;
|
| 93 |
}
|