aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 21:52:24 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 21:52:24 +0000
commit30264aed3809e54fc2246f7ae3e588f13e820db6 (patch)
tree5c5585a9e1f697ae12be4f26c291509107df8162 /engine/lib
parent500545ecfe71cb20a0afec0bf37e3f30339c8513 (diff)
downloadelgg-30264aed3809e54fc2246f7ae3e588f13e820db6.tar.gz
elgg-30264aed3809e54fc2246f7ae3e588f13e820db6.tar.bz2
Fixes #2049. Created migration for 1.7 custom profile fields to 1.8.
git-svn-id: http://code.elgg.org/elgg/trunk@8369 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/upgrades/2011022000-1.8_svn-custom_profile_fields-390ac967b0bb5665.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/engine/lib/upgrades/2011022000-1.8_svn-custom_profile_fields-390ac967b0bb5665.php b/engine/lib/upgrades/2011022000-1.8_svn-custom_profile_fields-390ac967b0bb5665.php
new file mode 100644
index 000000000..7561b84ba
--- /dev/null
+++ b/engine/lib/upgrades/2011022000-1.8_svn-custom_profile_fields-390ac967b0bb5665.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Elgg 2011010401 upgrade 00
+ * custom_profile_fields
+ *
+ * Migrate 1.7 style custom profile fields to 1.8
+ */
+
+$plugin = elgg_get_plugin_from_id('profile');
+
+// plugin not installed
+if (!$plugin) {
+ return true;
+}
+
+$settings = $plugin->getAllSettings();
+// no fields to migrate
+if (!$settings['user_defined_fields']) {
+ return true;
+}
+
+$order = array();
+$remove_settings = array();
+
+// make sure we have a name and type
+foreach ($settings as $k => $v) {
+ if (!preg_match('/admin_defined_profile_([0-9]+)/i', $k, $matches)) {
+ continue;
+ }
+
+ $i = $matches[1];
+ $type_name = "admin_defined_profile_type_$i";
+ $type = elgg_extract($type_name, $settings, null);
+
+ if ($type) {
+ // field name
+ elgg_save_config($k, $v);
+ // field value
+ elgg_save_config($type_name, $type);
+
+ $order[] = $i;
+ $remove_settings[] = $k;
+ $remove_settings[] = $type_name;
+ }
+}
+
+if ($order) {
+ // these will always need to be in order, but there might be gaps
+ ksort($order);
+
+ $order_str = implode(',', $order);
+ elgg_save_config('profile_custom_fields', $order_str);
+
+ foreach ($remove_settings as $name) {
+ $plugin->unsetSetting($name);
+ }
+
+ $plugin->unsetSetting('user_defined_fields');
+} \ No newline at end of file