| 1 |
<?php
|
| 2 |
// $Id: video_cck.install,v 1.5 2008/02/17 19:07:51 aaron Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function video_cck_install() {
|
| 8 |
}
|
| 9 |
|
| 10 |
/**
|
| 11 |
* we need to make sure to show our new 'embed code' filter on views
|
| 12 |
*/
|
| 13 |
function video_cck_update_1() {
|
| 14 |
return _video_cck_update_reset_cache();
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* we need a new data field for extra info stored by certain providers, such as blip.tv
|
| 19 |
*/
|
| 20 |
function video_cck_update_2() {
|
| 21 |
$ret = array();
|
| 22 |
|
| 23 |
include_once('./'. drupal_get_path('module', 'content') .'/content.module');
|
| 24 |
include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
|
| 25 |
|
| 26 |
content_clear_type_cache();
|
| 27 |
$fields = content_fields();
|
| 28 |
|
| 29 |
foreach ($fields as $field) {
|
| 30 |
switch ($field['type']) {
|
| 31 |
case 'video_cck':
|
| 32 |
$columns = array(
|
| 33 |
'data' => array('type' => 'longtext', 'not null' => TRUE, 'default' => "''", 'sortable' => false),
|
| 34 |
);
|
| 35 |
// the following line will trigger (negligible) warnings if video_cck_update_2 was run before
|
| 36 |
// (column already exists)
|
| 37 |
@content_alter_db_field(array(), array(), $field, $columns);
|
| 38 |
break;
|
| 39 |
}
|
| 40 |
}
|
| 41 |
$ret = _video_cck_update_reset_cache();
|
| 42 |
$ret[] = update_sql("DELETE FROM {cache}");
|
| 43 |
return $ret;
|
| 44 |
}
|
| 45 |
|
| 46 |
function _video_cck_update_reset_cache() {
|
| 47 |
$ret = _video_cck_update_reset_cache_views();
|
| 48 |
$ret[] = update_sql("DELETE FROM {cache_content}");
|
| 49 |
return $ret;
|
| 50 |
}
|
| 51 |
|
| 52 |
/**
|
| 53 |
* since we made our engine dependent on emfield, we need to change some variables accordingly
|
| 54 |
*/
|
| 55 |
function video_cck_update_3() {
|
| 56 |
$ret = array();
|
| 57 |
foreach (emfield_system_list('video_cck') as $provider) {
|
| 58 |
// TODO: this will need some attention when we upgrade to d6
|
| 59 |
$test = variable_get('video_cck_allow_'. $provider->name, NULL);
|
| 60 |
if (isset($test)) {
|
| 61 |
variable_set('emfield_'. $module .'_allow_'. $provider->name, variable_get('video_cck_allow_'. $provider->name, true));
|
| 62 |
}
|
| 63 |
}
|
| 64 |
$ret[] = array(
|
| 65 |
'query' => t('The Embedded Video Field allowed provider variables have been updated.'),
|
| 66 |
'success' => TRUE
|
| 67 |
);
|
| 68 |
$ret = array_merge($ret, _video_cck_update_reset_cache());
|
| 69 |
|
| 70 |
// now we need to depend on emfield's menu. remove our old admin menu path
|
| 71 |
menu_rebuild();
|
| 72 |
return $ret;
|
| 73 |
}
|
| 74 |
|
| 75 |
/**
|
| 76 |
* oops. cleanup from update 3 -- we don't want to accidentally reset our variables
|
| 77 |
* if we have to run update 3 again...
|
| 78 |
*/
|
| 79 |
function video_cck_update_4() {
|
| 80 |
$ret = array();
|
| 81 |
foreach (emfield_system_list('video_cck') as $provider) {
|
| 82 |
// TODO: this will need some attention when we upgrade to d6
|
| 83 |
$test = variable_get('video_cck_allow_'. $provider->name, NULL);
|
| 84 |
if (isset($test)) {
|
| 85 |
variable_set('video_cck_allow_'. $provider->name, NULL);
|
| 86 |
}
|
| 87 |
}
|
| 88 |
$ret[] = array(
|
| 89 |
'query' => t('The old Embedded Video Field allowed provider variables have been cleaned up.'),
|
| 90 |
'success' => TRUE
|
| 91 |
);
|
| 92 |
return $ret;
|
| 93 |
}
|
| 94 |
|
| 95 |
/**
|
| 96 |
* changed the data structure for blip.tv
|
| 97 |
* TODO: this doesn't work. thought data was cached? ...
|
| 98 |
*/
|
| 99 |
function video_cck_update_5() {
|
| 100 |
$ret = _video_cck_update_reset_cache();
|
| 101 |
$ret[] = update_sql("DELETE FROM {cache}");
|
| 102 |
return $ret;
|
| 103 |
}
|
| 104 |
|
| 105 |
function video_cck_update_6() {
|
| 106 |
$ret = _video_cck_update_reset_cache_views();
|
| 107 |
return $ret;
|
| 108 |
}
|
| 109 |
|
| 110 |
// I'd like this to be conditional, so it only runs if they don't have views installed.
|
| 111 |
// however, module_exists doesn't actually work in the update scripts.
|
| 112 |
function _video_cck_update_reset_cache_views() {
|
| 113 |
$ret = array();
|
| 114 |
$ret[] = update_sql("DELETE FROM {cache_views}");
|
| 115 |
return $ret;
|
| 116 |
}
|