aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/upgrades
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-23 11:27:43 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-23 11:27:43 +0000
commit07497cfef9e93527f9ef4941d1b339565af77ce1 (patch)
tree4bd0c2955cec10ffda8be3a9f5c271a4ad8f95c2 /engine/lib/upgrades
parent24a0a62b2f0778ce6c1706834c1c88aaabc6c93c (diff)
downloadelgg-07497cfef9e93527f9ef4941d1b339565af77ce1.tar.gz
elgg-07497cfef9e93527f9ef4941d1b339565af77ce1.tar.bz2
Fixes #3193 converts the default widgets for 1.8 - leaves behind the default widgets object
git-svn-id: http://code.elgg.org/elgg/trunk@8826 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/upgrades')
-rw-r--r--engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php b/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php
new file mode 100644
index 000000000..6a5f2fa02
--- /dev/null
+++ b/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Elgg 1.8-svn upgrade 2011032300
+ * update_default_widgets
+ *
+ * Pre-1.8, default widgets were stored as metadata on a defaultwidgets object.
+ * Now they are stored as widget objects owned by the site.
+ */
+
+$object = elgg_get_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'moddefaultwidgets',
+ 'limit' => 1,
+));
+
+if (!$object) {
+ // nothing to upgrade
+ return true;
+}
+
+$object = $object[0];
+
+$site = elgg_get_site_entity();
+
+$ia = elgg_set_ignore_access(true);
+foreach (array('profile', 'dashboard') as $context) {
+ if (isset($object->$context)) {
+ elgg_push_context($context);
+ elgg_push_context('default_widgets');
+ elgg_push_context('widgets');
+
+ // deserialize the widget information
+ list($left, $middle, $right) = split('%%', $object->$context);
+ $left_widgets = split('::', $left);
+ $middle_widgets = split('::', $middle);
+ $right_widgets = split('::', $right);
+
+ // 1st column is right column in default theme
+ $widgets = array(
+ 1 => array_reverse($right_widgets),
+ 2 => array_reverse($middle_widgets),
+ 3 => array_reverse($left_widgets),
+ );
+
+ foreach ($widgets as $column => $column_widgets) {
+ foreach ($column_widgets as $handler) {
+ $guid = elgg_create_widget($site->getGUID(), $handler, $context);
+ if ($guid) {
+ $widget = get_entity($guid);
+ $widget->move($column, 0);
+ }
+ }
+ }
+
+ elgg_pop_context();
+ elgg_pop_context();
+ elgg_pop_context();
+ }
+}
+elgg_set_ignore_access($ia);