aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--start.php8
-rw-r--r--upgrades/2012022501.php44
2 files changed, 31 insertions, 21 deletions
diff --git a/start.php b/start.php
index 9b7dd3084..431015b24 100644
--- a/start.php
+++ b/start.php
@@ -313,10 +313,8 @@ function videolist_preprocess_url($hook, $type, $returnvalue, $params) {
/**
* Process upgrades for the videolist plugin
*/
-function videolist_run_upgrades() {
- $path = elgg_get_plugins_path() . 'videolist/upgrades/';
- $files = elgg_get_upgrade_files($path);
- foreach ($files as $file) {
- include "$path{$file}";
+function videolist_run_upgrades($event, $type, $details) {
+ if (include_once(elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php')) {
+ upgrade_module_run('videolist');
}
}
diff --git a/upgrades/2012022501.php b/upgrades/2012022501.php
index 50102e875..e109406d6 100644
--- a/upgrades/2012022501.php
+++ b/upgrades/2012022501.php
@@ -7,7 +7,7 @@
$items = elgg_get_entities(array(
'type' => 'object',
- 'subtype' => 'videolist_item',
+ 'subtype' => 'videolist',
'limit' => 5,
'order_by' => 'e.time_created asc',
));
@@ -17,14 +17,6 @@ if (!$items) {
return;
}
-// if all five of the items have empty thumbnails, we need to upgrade
-foreach ($items as $item) {
- if ($item->thumbnail === true) {
- return;
- }
-}
-
-
/**
* Downloads the thumbnail and saves into data folder
*
@@ -32,12 +24,9 @@ foreach ($items as $item) {
* @return bool
*/
function videolist_2012022501($item) {
+ require_once(elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php');
- // do not upgrade videos that have already been upgraded
- if ($item->thumbnail === true) {
- return true;
- }
-
+ // get thumbnail image
$thumbnail = file_get_contents($item->thumbnail);
if (!$thumbnail) {
return false;
@@ -51,14 +40,37 @@ function videolist_2012022501($item) {
$filehandler->write($thumbnail);
$filehandler->close();
- $item->thumbnail = true;
+ // update properties
+ if ($item->url) {
+ $item->video_url = $item->url;
+ $item->deleteMetadata('url');
+ }
+ if ($item->desc) {
+ $item->description = $item->desc;
+ $item->deleteMetadata('desc');
+ $item->save();
+ }
+ if ($item->embedurl) {
+ $item->deleteMetadata('embedurl');
+ }
+ upgrade_change_subtype($item, 'videolist_item');
+
+ // update river
+ $options = array('object_guid' => $item->guid);
+ $river_items = elgg_get_river($options);
+ foreach($river_items as $river_item) {
+ if ($river_item->action_type == 'create') {
+ upgrade_update_river($river_item->id, 'river/object/videolist_item/create', $item->guid, 0);
+ }
+ }
+
return true;
}
$previous_access = elgg_set_ignore_access(true);
$options = array(
'type' => 'object',
- 'subtype' => 'videolist_item',
+ 'subtype' => 'videolist',
'limit' => 0,
);
$batch = new ElggBatch('elgg_get_entities', $options, 'videolist_2012022501', 100);