Example #1
0
 public static function updateProfile(Profile $profile, ActivityObject $object, array $hints = array())
 {
     $orig = clone $profile;
     // Existing nickname is better than nothing.
     if (!array_key_exists('nickname', $hints)) {
         $hints['nickname'] = $profile->nickname;
     }
     $nickname = self::getActivityObjectNickname($object, $hints);
     if (!empty($nickname)) {
         $profile->nickname = $nickname;
     }
     if (!empty($object->title)) {
         $profile->fullname = $object->title;
     } else {
         if (array_key_exists('fullname', $hints)) {
             $profile->fullname = $hints['fullname'];
         }
     }
     if (!empty($object->link)) {
         $profile->profileurl = $object->link;
     } else {
         if (array_key_exists('profileurl', $hints)) {
             $profile->profileurl = $hints['profileurl'];
         } else {
             if (common_valid_http_url($object->id)) {
                 $profile->profileurl = $object->id;
             }
         }
     }
     $bio = self::getActivityObjectBio($object, $hints);
     if (!empty($bio)) {
         $profile->bio = $bio;
     }
     $location = self::getActivityObjectLocation($object, $hints);
     if (!empty($location)) {
         $profile->location = $location;
     }
     $homepage = self::getActivityObjectHomepage($object, $hints);
     if (!empty($homepage)) {
         $profile->homepage = $homepage;
     }
     if (!empty($object->geopoint)) {
         $location = ActivityContext::locationFromPoint($object->geopoint);
         if (!empty($location)) {
             $profile->lat = $location->lat;
             $profile->lon = $location->lon;
         }
     }
     // @todo FIXME: tags/categories
     // @todo tags from categories
     if ($profile->id) {
         common_log(LOG_DEBUG, "Updating OStatus profile {$profile->id} from remote info {$object->id}: " . var_export($object, true) . var_export($hints, true));
         $profile->update($orig);
     }
 }
 protected static function updateProfile($profile, $object, $hints = array())
 {
     $orig = clone $profile;
     $profile->nickname = self::getActivityObjectNickname($object, $hints);
     if (!empty($object->title)) {
         $profile->fullname = $object->title;
     } else {
         if (array_key_exists('fullname', $hints)) {
             $profile->fullname = $hints['fullname'];
         }
     }
     if (!empty($object->link)) {
         $profile->profileurl = $object->link;
     } else {
         if (array_key_exists('profileurl', $hints)) {
             $profile->profileurl = $hints['profileurl'];
         } else {
             if (Validate::uri($object->id, array('allowed_schemes' => array('http', 'https')))) {
                 $profile->profileurl = $object->id;
             }
         }
     }
     $profile->bio = self::getActivityObjectBio($object, $hints);
     $profile->location = self::getActivityObjectLocation($object, $hints);
     $profile->homepage = self::getActivityObjectHomepage($object, $hints);
     if (!empty($object->geopoint)) {
         $location = ActivityContext::locationFromPoint($object->geopoint);
         if (!empty($location)) {
             $profile->lat = $location->lat;
             $profile->lon = $location->lon;
         }
     }
     // @fixme tags/categories
     // @todo tags from categories
     if ($profile->id) {
         common_log(LOG_DEBUG, "Updating OStatus profile {$profile->id} from remote info {$object->id}: " . var_export($object, true) . var_export($hints, true));
         $profile->update($orig);
     }
 }