From d1a96dc7afe487b4adf757b75f7060ff767609ad Mon Sep 17 00:00:00 2001
From: Brion Vibber <brion@pobox.com>
Date: Wed, 2 Feb 2011 17:29:34 -0800
Subject: [PATCH] work in progress: prepping for storage of extended profile
 details

---
 plugins/ExtendedProfile/Profile_detail.php  | 16 ++++++++++++++++
 plugins/ExtendedProfile/extendedprofile.php | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 plugins/ExtendedProfile/Profile_detail.php

diff --git a/plugins/ExtendedProfile/Profile_detail.php b/plugins/ExtendedProfile/Profile_detail.php
new file mode 100644
index 0000000000..ae8cdcee50
--- /dev/null
+++ b/plugins/ExtendedProfile/Profile_detail.php
@@ -0,0 +1,16 @@
+<?php
+/* 
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+class Profile_detail extends Memcached_DataObject
+{
+    public $id;
+    public $profile_id;
+    public $field;
+    public $index; // relative ordering of multiple values in the same field
+    public $value; // primary text value
+    public $rel; // detail for some field types; eg "home", "mobile", "work" for phones or "aim", "irc", "xmpp" for IM
+    public $ref_profile; // for people types, allows pointing to a known profile in the system
+
+}
\ No newline at end of file
diff --git a/plugins/ExtendedProfile/extendedprofile.php b/plugins/ExtendedProfile/extendedprofile.php
index 18fef20331..7f69f90899 100644
--- a/plugins/ExtendedProfile/extendedprofile.php
+++ b/plugins/ExtendedProfile/extendedprofile.php
@@ -23,6 +23,25 @@ if (!defined('STATUSNET')) {
 
 class ExtendedProfile
 {
+    function __construct(Profile $profile)
+    {
+        $this->profile = $profile;
+        $this->sections = $this->getSections();
+        $this->fields = $this->loadFields();
+    }
+
+    function loadFields()
+    {
+        $detail = new Profile_detail();
+        $detail->profile_id = $this->profile->id;
+        $detail->find();
+        
+        while ($detail->get()) {
+            $fields[$detail->field][] = clone($detail);
+        }
+        return $fields;
+    }
+
     function getSections()
     {
         return array(
-- 
2.39.5