3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
23 * Table Definition for profile
25 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
27 class Profile extends Memcached_DataObject
30 /* the code below is auto generated do not remove the above tag */
32 public $__table = 'profile'; // table name
33 public $id; // int(4) primary_key not_null
34 public $nickname; // varchar(64) multiple_key not_null
35 public $fullname; // varchar(255) multiple_key
36 public $profileurl; // varchar(255)
37 public $homepage; // varchar(255) multiple_key
38 public $bio; // text() multiple_key
39 public $location; // varchar(255) multiple_key
40 public $lat; // decimal(10,7)
41 public $lon; // decimal(10,7)
42 public $location_id; // int(4)
43 public $location_ns; // int(4)
44 public $created; // datetime() not_null
45 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
48 function staticGet($k,$v=NULL) {
49 return Memcached_DataObject::staticGet('Profile',$k,$v);
52 /* the code above is auto generated do not remove the tag below */
57 return User::staticGet('id', $this->id);
60 function getAvatar($width, $height=null)
62 if (is_null($height)) {
65 return Avatar::pkeyGet(array('profile_id' => $this->id,
67 'height' => $height));
70 function getOriginalAvatar()
72 $avatar = DB_DataObject::factory('avatar');
73 $avatar->profile_id = $this->id;
74 $avatar->original = true;
75 if ($avatar->find(true)) {
82 function setOriginal($filename)
84 $imagefile = new ImageFile($this->id, Avatar::path($filename));
86 $avatar = new Avatar();
87 $avatar->profile_id = $this->id;
88 $avatar->width = $imagefile->width;
89 $avatar->height = $imagefile->height;
90 $avatar->mediatype = image_type_to_mime_type($imagefile->type);
91 $avatar->filename = $filename;
92 $avatar->original = true;
93 $avatar->url = Avatar::url($filename);
94 $avatar->created = DB_DataObject_Cast::dateTime(); # current time
96 // XXX: start a transaction here
98 if (!$this->delete_avatars() || !$avatar->insert()) {
99 @unlink(Avatar::path($filename));
103 foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
104 // We don't do a scaled one if original is our scaled size
105 if (!($avatar->width == $size && $avatar->height == $size)) {
106 $scaled_filename = $imagefile->resize($size);
108 //$scaled = DB_DataObject::factory('avatar');
109 $scaled = new Avatar();
110 $scaled->profile_id = $this->id;
111 $scaled->width = $size;
112 $scaled->height = $size;
113 $scaled->original = false;
114 $scaled->mediatype = image_type_to_mime_type($imagefile->type);
115 $scaled->filename = $scaled_filename;
116 $scaled->url = Avatar::url($scaled_filename);
117 $scaled->created = DB_DataObject_Cast::dateTime(); # current time
119 if (!$scaled->insert()) {
129 * Delete attached avatars for this user from the database and filesystem.
130 * This should be used instead of a batch delete() to ensure that files
131 * get removed correctly.
133 * @param boolean $original true to delete only the original-size file
136 function delete_avatars($original=true)
138 $avatar = new Avatar();
139 $avatar->profile_id = $this->id;
141 while ($avatar->fetch()) {
142 if ($avatar->original) {
143 if ($original == false) {
153 * Gets either the full name (if filled) or the nickname.
157 function getBestName()
159 return ($this->fullname) ? $this->fullname : $this->nickname;
163 * Gets the full name (if filled) with nickname as a parenthetical, or the nickname alone
164 * if no fullname is provided.
168 function getFancyName()
170 if ($this->fullname) {
171 // TRANS: Full name of a profile or group followed by nickname in parens
172 return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->fullname, $this->nickname);
174 return $this->nickname;
179 * Get the most recent notice posted by this user, if any.
181 * @return mixed Notice or null
184 function getCurrentNotice()
186 $notice = $this->getNotices(0, 1);
188 if ($notice->fetch()) {
189 if ($notice instanceof ArrayWrapper) {
190 // hack for things trying to work with single notices
191 return $notice->_items[0];
199 function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
201 $stream = new NoticeStream(array($this, '_streamTaggedDirect'),
203 'profile:notice_ids_tagged:'.$this->id.':'.$tag);
205 return $stream->getNotices($offset, $limit, $since_id, $max_id);
208 function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
210 $stream = new NoticeStream(array($this, '_streamDirect'),
212 'profile:notice_ids:' . $this->id);
214 return $stream->getNotices($offset, $limit, $since_id, $max_id);
217 function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
219 // XXX It would be nice to do this without a join
220 // (necessary to do it efficiently on accounts with long history)
222 $notice = new Notice();
225 "select id from notice join notice_tag on id=notice_id where tag='".
226 $notice->escape($tag) .
227 "' and profile_id=" . intval($this->id);
229 $since = Notice::whereSinceId($since_id, 'id', 'notice.created');
231 $query .= " and ($since)";
234 $max = Notice::whereMaxId($max_id, 'id', 'notice.created');
236 $query .= " and ($max)";
239 $query .= ' order by notice.created DESC, id DESC';
241 if (!is_null($offset)) {
242 $query .= " LIMIT " . intval($limit) . " OFFSET " . intval($offset);
245 $notice->query($query);
249 while ($notice->fetch()) {
250 $ids[] = $notice->id;
256 function _streamDirect($offset, $limit, $since_id, $max_id)
258 $notice = new Notice();
260 $notice->profile_id = $this->id;
262 $notice->selectAdd();
263 $notice->selectAdd('id');
265 Notice::addWhereSinceId($notice, $since_id);
266 Notice::addWhereMaxId($notice, $max_id);
268 $notice->orderBy('created DESC, id DESC');
270 if (!is_null($offset)) {
271 $notice->limit($offset, $limit);
278 while ($notice->fetch()) {
279 $ids[] = $notice->id;
285 function isMember($group)
287 $mem = new Group_member();
289 $mem->group_id = $group->id;
290 $mem->profile_id = $this->id;
299 function isAdmin($group)
301 $mem = new Group_member();
303 $mem->group_id = $group->id;
304 $mem->profile_id = $this->id;
314 function isPendingMember($group)
316 $request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
317 'group_id' => $group->id));
318 return !empty($request);
321 function getGroups($offset=0, $limit=null)
324 'SELECT user_group.* ' .
325 'FROM user_group JOIN group_member '.
326 'ON user_group.id = group_member.group_id ' .
327 'WHERE group_member.profile_id = %d ' .
328 'ORDER BY group_member.created DESC ';
330 if ($offset>0 && !is_null($limit)) {
332 if (common_config('db','type') == 'pgsql') {
333 $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
335 $qry .= ' LIMIT ' . $offset . ', ' . $limit;
340 $groups = new User_group();
342 $cnt = $groups->query(sprintf($qry, $this->id));
348 * Request to join the given group.
349 * May throw exceptions on failure.
351 * @param User_group $group
352 * @return mixed: Group_member on success, Group_join_queue if pending approval, null on some cancels?
354 function joinGroup(User_group $group)
357 if ($group->join_policy == User_group::JOIN_POLICY_MODERATE) {
358 $join = Group_join_queue::saveNew($this, $group);
360 if (Event::handle('StartJoinGroup', array($group, $this))) {
361 $join = Group_member::join($group->id, $this->id);
362 Event::handle('EndJoinGroup', array($group, $this));
366 // Send any applicable notifications...
373 * Cancel a pending group join...
375 * @param User_group $group
377 function cancelJoinGroup(User_group $group)
379 $request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
380 'group_id' => $group->id));
382 if (Event::handle('StartCancelJoinGroup', array($group, $this))) {
384 Event::handle('EndCancelJoinGroup', array($group, $this));
390 * Complete a pending group join on our end...
392 * @param User_group $group
394 function completeJoinGroup(User_group $group)
397 $request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
398 'group_id' => $group->id));
400 if (Event::handle('StartJoinGroup', array($group, $this))) {
401 $join = Group_member::join($group->id, $this->id);
403 Event::handle('EndJoinGroup', array($group, $this));
406 throw new Exception(_m('Invalid group join approval: not pending.'));
415 * Leave a group that this profile is a member of.
417 * @param User_group $group
419 function leaveGroup(User_group $group)
421 if (Event::handle('StartLeaveGroup', array($group, $this))) {
422 Group_member::leave($group->id, $this->id);
423 Event::handle('EndLeaveGroup', array($group, $this));
427 function avatarUrl($size=AVATAR_PROFILE_SIZE)
429 $avatar = $this->getAvatar($size);
431 return $avatar->displayUrl();
433 return Avatar::defaultImage($size);
437 function getSubscriptions($offset=0, $limit=null)
439 $subs = Subscription::bySubscriber($this->id,
445 while ($subs->fetch()) {
446 $profile = Profile::staticGet($subs->subscribed);
448 $profiles[] = $profile;
452 return new ArrayWrapper($profiles);
455 function getSubscribers($offset=0, $limit=null)
457 $subs = Subscription::bySubscribed($this->id,
463 while ($subs->fetch()) {
464 $profile = Profile::staticGet($subs->subscriber);
466 $profiles[] = $profile;
470 return new ArrayWrapper($profiles);
473 function subscriptionCount()
475 $c = Cache::instance();
478 $cnt = $c->get(Cache::key('profile:subscription_count:'.$this->id));
479 if (is_integer($cnt)) {
484 $sub = new Subscription();
485 $sub->subscriber = $this->id;
487 $cnt = (int) $sub->count('distinct subscribed');
489 $cnt = ($cnt > 0) ? $cnt - 1 : $cnt;
492 $c->set(Cache::key('profile:subscription_count:'.$this->id), $cnt);
498 function subscriberCount()
500 $c = Cache::instance();
502 $cnt = $c->get(Cache::key('profile:subscriber_count:'.$this->id));
503 if (is_integer($cnt)) {
508 $sub = new Subscription();
509 $sub->subscribed = $this->id;
510 $sub->whereAdd('subscriber != subscribed');
511 $cnt = (int) $sub->count('distinct subscriber');
514 $c->set(Cache::key('profile:subscriber_count:'.$this->id), $cnt);
521 * Is this profile subscribed to another profile?
523 * @param Profile $other
526 function isSubscribed($other)
528 return Subscription::exists($this, $other);
532 * Are these two profiles subscribed to each other?
534 * @param Profile $other
537 function mutuallySubscribed($other)
539 return $this->isSubscribed($other) &&
540 $other->isSubscribed($this);
543 function hasFave($notice)
545 $cache = Cache::instance();
547 // XXX: Kind of a hack.
549 if (!empty($cache)) {
550 // This is the stream of favorite notices, in rev chron
551 // order. This forces it into cache.
553 $ids = Fave::idStream($this->id, 0, NoticeStream::CACHE_WINDOW);
555 // If it's in the list, then it's a fave
557 if (in_array($notice->id, $ids)) {
561 // If we're not past the end of the cache window,
562 // then the cache has all available faves, so this one
565 if (count($ids) < NoticeStream::CACHE_WINDOW) {
569 // Otherwise, cache doesn't have all faves;
570 // fall through to the default
573 $fave = Fave::pkeyGet(array('user_id' => $this->id,
574 'notice_id' => $notice->id));
575 return ((is_null($fave)) ? false : true);
580 $c = Cache::instance();
582 $cnt = $c->get(Cache::key('profile:fave_count:'.$this->id));
583 if (is_integer($cnt)) {
589 $faves->user_id = $this->id;
590 $cnt = (int) $faves->count('distinct notice_id');
593 $c->set(Cache::key('profile:fave_count:'.$this->id), $cnt);
599 function noticeCount()
601 $c = Cache::instance();
604 $cnt = $c->get(Cache::key('profile:notice_count:'.$this->id));
605 if (is_integer($cnt)) {
610 $notices = new Notice();
611 $notices->profile_id = $this->id;
612 $cnt = (int) $notices->count('distinct id');
615 $c->set(Cache::key('profile:notice_count:'.$this->id), $cnt);
621 function blowFavesCache()
623 $cache = Cache::instance();
625 // Faves don't happen chronologically, so we need to blow
627 $cache->delete(Cache::key('fave:ids_by_user:'.$this->id));
628 $cache->delete(Cache::key('fave:ids_by_user:'.$this->id.';last'));
629 $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id));
630 $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id.';last'));
632 $this->blowFaveCount();
635 function blowSubscriberCount()
637 $c = Cache::instance();
639 $c->delete(Cache::key('profile:subscriber_count:'.$this->id));
643 function blowSubscriptionCount()
645 $c = Cache::instance();
647 $c->delete(Cache::key('profile:subscription_count:'.$this->id));
651 function blowFaveCount()
653 $c = Cache::instance();
655 $c->delete(Cache::key('profile:fave_count:'.$this->id));
659 function blowNoticeCount()
661 $c = Cache::instance();
663 $c->delete(Cache::key('profile:notice_count:'.$this->id));
667 static function maxBio()
669 $biolimit = common_config('profile', 'biolimit');
670 // null => use global limit (distinct from 0!)
671 if (is_null($biolimit)) {
672 $biolimit = common_config('site', 'textlimit');
677 static function bioTooLong($bio)
679 $biolimit = self::maxBio();
680 return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
685 $this->_deleteNotices();
686 $this->_deleteSubscriptions();
687 $this->_deleteMessages();
688 $this->_deleteTags();
689 $this->_deleteBlocks();
690 $this->delete_avatars();
692 // Warning: delete() will run on the batch objects,
693 // not on individual objects.
694 $related = array('Reply',
697 Event::handle('ProfileDeleteRelated', array($this, &$related));
699 foreach ($related as $cls) {
701 $inst->profile_id = $this->id;
708 function _deleteNotices()
710 $notice = new Notice();
711 $notice->profile_id = $this->id;
713 if ($notice->find()) {
714 while ($notice->fetch()) {
715 $other = clone($notice);
721 function _deleteSubscriptions()
723 $sub = new Subscription();
724 $sub->subscriber = $this->id;
728 while ($sub->fetch()) {
729 $other = Profile::staticGet('id', $sub->subscribed);
733 if ($other->id == $this->id) {
736 Subscription::cancel($this, $other);
739 $subd = new Subscription();
740 $subd->subscribed = $this->id;
743 while ($subd->fetch()) {
744 $other = Profile::staticGet('id', $subd->subscriber);
748 if ($other->id == $this->id) {
751 Subscription::cancel($other, $this);
754 $self = new Subscription();
756 $self->subscriber = $this->id;
757 $self->subscribed = $this->id;
762 function _deleteMessages()
764 $msg = new Message();
765 $msg->from_profile = $this->id;
768 $msg = new Message();
769 $msg->to_profile = $this->id;
773 function _deleteTags()
775 $tag = new Profile_tag();
776 $tag->tagged = $this->id;
780 function _deleteBlocks()
782 $block = new Profile_block();
783 $block->blocked = $this->id;
786 $block = new Group_block();
787 $block->blocked = $this->id;
791 // XXX: identical to Notice::getLocation.
793 function getLocation()
797 if (!empty($this->location_id) && !empty($this->location_ns)) {
798 $location = Location::fromId($this->location_id, $this->location_ns);
801 if (is_null($location)) { // no ID, or Location::fromId() failed
802 if (!empty($this->lat) && !empty($this->lon)) {
803 $location = Location::fromLatLon($this->lat, $this->lon);
807 if (is_null($location)) { // still haven't found it!
808 if (!empty($this->location)) {
809 $location = Location::fromName($this->location);
816 function hasRole($name)
819 if (Event::handle('StartHasRole', array($this, $name, &$has_role))) {
820 $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
822 $has_role = !empty($role);
823 Event::handle('EndHasRole', array($this, $name, $has_role));
828 function grantRole($name)
830 if (Event::handle('StartGrantRole', array($this, $name))) {
832 $role = new Profile_role();
834 $role->profile_id = $this->id;
836 $role->created = common_sql_now();
838 $result = $role->insert();
841 throw new Exception("Can't save role '$name' for profile '{$this->id}'");
844 if ($name == 'owner') {
845 User::blow('user:site_owner');
848 Event::handle('EndGrantRole', array($this, $name));
854 function revokeRole($name)
856 if (Event::handle('StartRevokeRole', array($this, $name))) {
858 $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
862 // TRANS: Exception thrown when trying to revoke an existing role for a user that does not exist.
863 // TRANS: %1$s is the role name, %2$s is the user ID (number).
864 throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; does not exist.'),$name, $this->id));
867 $result = $role->delete();
870 common_log_db_error($role, 'DELETE', __FILE__);
871 // TRANS: Exception thrown when trying to revoke a role for a user with a failing database query.
872 // TRANS: %1$s is the role name, %2$s is the user ID (number).
873 throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; database error.'),$name, $this->id));
876 if ($name == 'owner') {
877 User::blow('user:site_owner');
880 Event::handle('EndRevokeRole', array($this, $name));
886 function isSandboxed()
888 return $this->hasRole(Profile_role::SANDBOXED);
891 function isSilenced()
893 return $this->hasRole(Profile_role::SILENCED);
898 $this->grantRole(Profile_role::SANDBOXED);
903 $this->revokeRole(Profile_role::SANDBOXED);
908 $this->grantRole(Profile_role::SILENCED);
913 $this->revokeRole(Profile_role::SILENCED);
917 * Does this user have the right to do X?
919 * With our role-based authorization, this is merely a lookup for whether the user
920 * has a particular role. The implementation currently uses a switch statement
921 * to determine if the user has the pre-defined role to exercise the right. Future
922 * implementations may allow per-site roles, and different mappings of roles to rights.
924 * @param $right string Name of the right, usually a constant in class Right
925 * @return boolean whether the user has the right in question
927 function hasRight($right)
931 if ($this->hasRole(Profile_role::DELETED)) {
935 if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
938 case Right::DELETEOTHERSNOTICE:
939 case Right::MAKEGROUPADMIN:
940 case Right::SANDBOXUSER:
941 case Right::SILENCEUSER:
942 case Right::DELETEUSER:
943 case Right::DELETEGROUP:
944 $result = $this->hasRole(Profile_role::MODERATOR);
946 case Right::CONFIGURESITE:
947 $result = $this->hasRole(Profile_role::ADMINISTRATOR);
949 case Right::GRANTROLE:
950 case Right::REVOKEROLE:
951 $result = $this->hasRole(Profile_role::OWNER);
953 case Right::NEWNOTICE:
954 case Right::NEWMESSAGE:
955 case Right::SUBSCRIBE:
956 case Right::CREATEGROUP:
957 $result = !$this->isSilenced();
959 case Right::PUBLICNOTICE:
960 case Right::EMAILONREPLY:
961 case Right::EMAILONSUBSCRIBE:
962 case Right::EMAILONFAVE:
963 $result = !$this->isSandboxed();
965 case Right::WEBLOGIN:
966 $result = !$this->isSilenced();
969 $result = !$this->isSilenced();
971 case Right::BACKUPACCOUNT:
972 $result = common_config('profile', 'backup');
974 case Right::RESTOREACCOUNT:
975 $result = common_config('profile', 'restore');
977 case Right::DELETEACCOUNT:
978 $result = common_config('profile', 'delete');
980 case Right::MOVEACCOUNT:
981 $result = common_config('profile', 'move');
991 function hasRepeated($notice_id)
993 // XXX: not really a pkey, but should work
995 $notice = Memcached_DataObject::pkeyGet('Notice',
996 array('profile_id' => $this->id,
997 'repeat_of' => $notice_id));
999 return !empty($notice);
1003 * Returns an XML string fragment with limited profile information
1004 * as an Atom <author> element.
1006 * Assumes that Atom has been previously set up as the base namespace.
1008 * @param Profile $cur the current authenticated user
1012 function asAtomAuthor($cur = null)
1014 $xs = new XMLStringer(true);
1016 $xs->elementStart('author');
1017 $xs->element('name', null, $this->nickname);
1018 $xs->element('uri', null, $this->getUri());
1021 $attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
1022 $attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
1023 $xs->element('statusnet:profile_info', $attrs, null);
1025 $xs->elementEnd('author');
1027 return $xs->getString();
1031 * Extra profile info for atom entries
1033 * Clients use some extra profile info in the atom stream.
1034 * This gives it to them.
1036 * @param User $cur Current user
1038 * @return array representation of <statusnet:profile_info> element or null
1041 function profileInfo($cur)
1043 $profileInfoAttr = array('local_id' => $this->id);
1046 // Whether the current user is a subscribed to this profile
1047 $profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
1048 // Whether the current user is has blocked this profile
1049 $profileInfoAttr['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
1052 return array('statusnet:profile_info', $profileInfoAttr, null);
1056 * Returns an XML string fragment with profile information as an
1057 * Activity Streams <activity:actor> element.
1059 * Assumes that 'activity' namespace has been previously defined.
1063 function asActivityActor()
1065 return $this->asActivityNoun('actor');
1069 * Returns an XML string fragment with profile information as an
1070 * Activity Streams noun object with the given element type.
1072 * Assumes that 'activity', 'georss', and 'poco' namespace has been
1073 * previously defined.
1075 * @param string $element one of 'actor', 'subject', 'object', 'target'
1079 function asActivityNoun($element)
1081 $noun = ActivityObject::fromProfile($this);
1082 return $noun->asString('activity:' . $element);
1086 * Returns the best URI for a profile. Plugins may override.
1088 * @return string $uri
1094 // give plugins a chance to set the URI
1095 if (Event::handle('StartGetProfileUri', array($this, &$uri))) {
1097 // check for a local user first
1098 $user = User::staticGet('id', $this->id);
1100 if (!empty($user)) {
1103 // return OMB profile if any
1104 $remote = Remote_profile::staticGet('id', $this->id);
1105 if (!empty($remote)) {
1106 $uri = $remote->uri;
1109 Event::handle('EndGetProfileUri', array($this, &$uri));
1115 function hasBlocked($other)
1117 $block = Profile_block::get($this->id, $other->id);
1119 if (empty($block)) {
1128 function getAtomFeed()
1132 if (Event::handle('StartProfileGetAtomFeed', array($this, &$feed))) {
1133 $user = User::staticGet('id', $this->id);
1134 if (!empty($user)) {
1135 $feed = common_local_url('ApiTimelineUser', array('id' => $user->id,
1136 'format' => 'atom'));
1138 Event::handle('EndProfileGetAtomFeed', array($this, $feed));
1144 static function fromURI($uri)
1148 if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
1149 // Get a local user or remote (OMB 0.1) profile
1150 $user = User::staticGet('uri', $uri);
1151 if (!empty($user)) {
1152 $profile = $user->getProfile();
1154 $remote_profile = Remote_profile::staticGet('uri', $uri);
1155 if (!empty($remote_profile)) {
1156 $profile = Profile::staticGet('id', $remote_profile->profile_id);
1159 Event::handle('EndGetProfileFromURI', array($uri, $profile));