protected static function parseUser(CultureFeed_SimpleXMLElement $element) { $user = new CultureFeed_User(); $user->id = $element->xpath_str('/foaf:person/rdf:id'); $user->preferredLanguage = $element->xpath_str('/foaf:person/preferredLanguage'); $user->nick = $element->xpath_str('/foaf:person/foaf:nick'); $user->givenName = $element->xpath_str('/foaf:person/foaf:givenName'); $user->familyName = $element->xpath_str('/foaf:person/foaf:familyName'); $user->mbox = $element->xpath_str('/foaf:person/foaf:mbox'); $user->mboxVerified = $element->xpath_bool('/foaf:person/mboxVerified'); $user->gender = $element->xpath_str('/foaf:person/foaf:gender'); $user->dob = $element->xpath_time('/foaf:person/foaf:dob'); $user->hasChildren = $element->xpath_bool('/foaf:person/hasChildren'); $user->depiction = $element->xpath_str('/foaf:person/foaf:depiction'); $user->bio = $element->xpath_str('/foaf:person/bio'); $user->street = $element->xpath_str('/foaf:person/homeAddress/street'); $user->zip = $element->xpath_str('/foaf:person/homeAddress/zip'); $user->city = $element->xpath_str('/foaf:person/homeAddress/city'); $user->country = $element->xpath_str('/foaf:person/homeAddress/country'); $user->lifestyleProfile = $element->xpath_str('/foaf:person/lifestyleProfile'); $user->status = $element->xpath_str('/foaf:person/status'); $user->points = $element->xpath_str('/foaf:person/points'); $user->calendarId = $element->xpath_str('/foaf:person/calendarId'); if ($user->status) { $user->status = strtolower($user->status); } $user->openid = $element->xpath_str('/foaf:person/foaf:openid'); $lat = $element->xpath_float('/foaf:person/homeLocation/geo:lat'); $lng = $element->xpath_float('/foaf:person/homeLocation/geo:long'); if ($lat && $lng) { $user->homeLocation = new CultureFeed_Location($lat, $lng); } $lat = $element->xpath_float('/foaf:person/currentLocation/geo:lat'); $lng = $element->xpath_float('/foaf:person/currentLocation/geo:long'); if ($lat && $lng) { $user->currentLocation = new CultureFeed_Location($lat, $lng); } $accounts = array(); $objects = $element->xpath('/foaf:person/foaf:holdsAccount/foaf:onlineAccount'); foreach ($objects as $object) { $account = new CultureFeed_OnlineAccount(); $account->accountType = $object->xpath_str('accountType'); $account->accountServiceHomepage = $object->xpath_str('foaf:accountServiceHomepage'); $account->accountName = $object->xpath_str('foaf:accountName'); $account->accountNick = $object->xpath_str('accountNick'); $account->accountDepiction = $object->xpath_str('accountDepiction'); $account->private = $object->xpath_bool('private'); $account->publishActivities = $object->xpath_bool('publishActivities'); $accounts[] = $account; } if ($element->xpath_str('/foaf:person/privateNick') !== NULL) { $privacy_config = new CultureFeed_UserPrivacyConfig(); $vars = array('nick', 'givenName', 'familyName', 'mbox', 'gender', 'dob', 'depiction', 'bio', 'homeAddress', 'homeLocation', 'currentLocation', 'openId', 'calendarId'); foreach ($vars as $var) { $privacy = $element->xpath_bool('/foaf:person/private' . ucfirst($var)); if (is_bool($privacy)) { $privacy_config->{$var} = $privacy ? CultureFeed_UserPrivacyConfig::PRIVACY_PRIVATE : CultureFeed_UserPrivacyConfig::PRIVACY_PUBLIC; } } $user->privacyConfig = $privacy_config; } if (!empty($accounts)) { $user->holdsAccount = $accounts; } // Add memberships. $memberships = $element->xpath('/foaf:person/pageMemberships/pageMembership'); $user_memberships = array(); foreach ($memberships as $membership) { $pageId = $membership->xpath_str('page/uid'); if (empty($pageId)) { continue; } $user_membership = new CultureFeed_Pages_Membership(); $page = new CultureFeed_Cdb_Item_Page(); $page->setId($pageId); $page->setName($membership->xpath_str('page/name')); // Set categories $categories_element = $membership->xpath('page/categoryIds/categoryId'); $categories = array(); foreach ($categories_element as $category) { $categories[] = (string) $category; } $page->setCategories($categories); $user_membership->page = $page; $user_membership->validated = $membership->xpath_bool('validated'); $user_membership->role = $membership->xpath_str('role'); $user_membership->relation = $membership->xpath_str('relation'); $user_membership->creationDate = $membership->xpath_time('creationDate'); $user_memberships[] = $user_membership; } if (!empty($user_memberships)) { $user->pageMemberships = $user_memberships; $adminPagesCount = 0; foreach ($user->pageMemberships as $membership) { if ($membership->role == CultureFeed_Pages_Membership::MEMBERSHIP_ROLE_ADMIN) { $adminPagesCount++; } } $user->adminPagesCount = $adminPagesCount; } // Add following pages. $following = $element->xpath('/foaf:person/following/page'); foreach ($following as $object) { $pageId = $object->xpath_str('uid'); if (empty($pageId)) { continue; } $follower = new CultureFeed_Pages_Follower(); $page = new CultureFeed_Cdb_Item_Page(); $page->setId($pageId); $page->setName($object->xpath_str('name')); // Set categories $categories_element = $object->xpath('categoryIds/categoryId'); $categories = array(); foreach ($categories_element as $category) { $categories[] = (string) $category; } $page->setCategories($categories); $follower->page = $page; $follower->user = $user; $follower->creationDate = $object->xpath_time('dateCreated'); $followers[] = $follower; } if (!empty($followers)) { $user->following = $followers; } return $user; }