diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-21 18:15:32 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-28 07:44:22 -0700 |
commit | 1685c8a4fa0c5e2eab514b5eea23ddc963255cbb (patch) | |
tree | 1ce80838167dbf210e78c5308cb7773eca606b2d /plugins/YammerImport/yammerimporter.php | |
parent | 37c67c3f9ff7af942c3fa629724589e4de31f94e (diff) |
Fetch more user data in Yammer imports, including the primary email address (preconfirmed, so we can do stuff like tell people to reset their passwords and log in!) and some bio info.
Diffstat (limited to 'plugins/YammerImport/yammerimporter.php')
-rw-r--r-- | plugins/YammerImport/yammerimporter.php | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/plugins/YammerImport/yammerimporter.php b/plugins/YammerImport/yammerimporter.php index bb6db7352..583ed3a8c 100644 --- a/plugins/YammerImport/yammerimporter.php +++ b/plugins/YammerImport/yammerimporter.php @@ -158,16 +158,60 @@ class YammerImporter $options['nickname'] = $item['name']; $options['fullname'] = trim($item['full_name']); - // We don't appear to have full bio avail here! - $options['bio'] = $item['job_title']; - - // What about other data like emails? - // Avatar... this will be the "_small" variant. // Remove that (pre-extension) suffix to get the orig-size image. $avatar = $item['mugshot_url']; - // Warning: we don't have following state for other users? + // The following info is only available in full data, not in the reference version. + + // There can be extensive contact info, but for now we'll only pull the primary email. + if (isset($item['contact'])) { + foreach ($item['contact']['email_addresses'] as $addr) { + if ($addr['type'] == 'primary') { + $options['email'] = $addr['address']; + $options['email_confirmed'] = true; + break; + } + } + } + + // There can be multiple external URLs; for now pull the first one as home page. + if (isset($item['external_urls'])) { + foreach ($item['external_urls'] as $url) { + if (common_valid_http_url($url)) { + $options['homepage'] = $url; + break; + } + } + } + + // Combine a few bits into the bio... + $bio = array(); + if (!empty($item['job_title'])) { + $bio[] = $item['job_title']; + } + if (!empty($item['summary'])) { + $bio[] = $item['summary']; + } + if (!empty($item['expertise'])) { + $bio[] = _m('Expertise:') . ' ' . $item['expertise']; + } + $options['bio'] = implode("\n\n", $bio); + + // Pull raw location string, may be lookupable + if (!empty($item['location'])) { + $options['location'] = $item['location']; + } + + // Timezone is in format like 'Pacific Time (US & Canada)' + // We need to convert that to a zone id. :P + // @fixme timezone not yet supported at registration time :) + if (!empty($item['timezone'])) { + $tz = $this->timezone($item['timezone']); + if ($tz) { + $options['timezone'] = $tz; + } + } return array('orig_id' => $origId, 'orig_url' => $origUrl, @@ -325,6 +369,18 @@ class YammerImporter return common_sql_date(strtotime($ts)); } + private function timezone($tz) + { + // Blaaaaaarf! + $known = array('Pacific Time (US & Canada)' => 'America/Los_Angeles', + 'Eastern Time (US & Canada)' => 'America/New_York'); + if (array_key_exists($known, $tz)) { + return $known[$tz]; + } else { + return false; + } + } + /** * Download and update given avatar image * |