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 // TRANS: Exception thrown trying to approve a non-existing group join request.
407 throw new Exception(_('Invalid group join approval: not pending.'));
416 * Leave a group that this profile is a member of.
418 * @param User_group $group
420 function leaveGroup(User_group $group)
422 if (Event::handle('StartLeaveGroup', array($group, $this))) {
423 Group_member::leave($group->id, $this->id);
424 Event::handle('EndLeaveGroup', array($group, $this));
428 function avatarUrl($size=AVATAR_PROFILE_SIZE)
430 $avatar = $this->getAvatar($size);
432 return $avatar->displayUrl();
434 return Avatar::defaultImage($size);
438 function getSubscriptions($offset=0, $limit=null)
440 $subs = Subscription::bySubscriber($this->id,
446 while ($subs->fetch()) {
447 $profile = Profile::staticGet($subs->subscribed);
449 $profiles[] = $profile;
453 return new ArrayWrapper($profiles);
456 function getSubscribers($offset=0, $limit=null)
458 $subs = Subscription::bySubscribed($this->id,
464 while ($subs->fetch()) {
465 $profile = Profile::staticGet($subs->subscriber);
467 $profiles[] = $profile;
471 return new ArrayWrapper($profiles);
474 function subscriptionCount()
476 $c = Cache::instance();
479 $cnt = $c->get(Cache::key('profile:subscription_count:'.$this->id));
480 if (is_integer($cnt)) {
485 $sub = new Subscription();
486 $sub->subscriber = $this->id;
488 $cnt = (int) $sub->count('distinct subscribed');
490 $cnt = ($cnt > 0) ? $cnt - 1 : $cnt;
493 $c->set(Cache::key('profile:subscription_count:'.$this->id), $cnt);
499 function subscriberCount()
501 $c = Cache::instance();
503 $cnt = $c->get(Cache::key('profile:subscriber_count:'.$this->id));
504 if (is_integer($cnt)) {
509 $sub = new Subscription();
510 $sub->subscribed = $this->id;
511 $sub->whereAdd('subscriber != subscribed');
512 $cnt = (int) $sub->count('distinct subscriber');
515 $c->set(Cache::key('profile:subscriber_count:'.$this->id), $cnt);
522 * Is this profile subscribed to another profile?
524 * @param Profile $other
527 function isSubscribed($other)
529 return Subscription::exists($this, $other);
533 * Are these two profiles subscribed to each other?
535 * @param Profile $other
538 function mutuallySubscribed($other)
540 return $this->isSubscribed($other) &&
541 $other->isSubscribed($this);
544 function hasFave($notice)
546 $cache = Cache::instance();
548 // XXX: Kind of a hack.
550 if (!empty($cache)) {
551 // This is the stream of favorite notices, in rev chron
552 // order. This forces it into cache.
554 $ids = Fave::idStream($this->id, 0, NoticeStream::CACHE_WINDOW);
556 // If it's in the list, then it's a fave
558 if (in_array($notice->id, $ids)) {
562 // If we're not past the end of the cache window,
563 // then the cache has all available faves, so this one
566 if (count($ids) < NoticeStream::CACHE_WINDOW) {
570 // Otherwise, cache doesn't have all faves;
571 // fall through to the default
574 $fave = Fave::pkeyGet(array('user_id' => $this->id,
575 'notice_id' => $notice->id));
576 return ((is_null($fave)) ? false : true);
581 $c = Cache::instance();
583 $cnt = $c->get(Cache::key('profile:fave_count:'.$this->id));
584 if (is_integer($cnt)) {
590 $faves->user_id = $this->id;
591 $cnt = (int) $faves->count('distinct notice_id');
594 $c->set(Cache::key('profile:fave_count:'.$this->id), $cnt);
600 function noticeCount()
602 $c = Cache::instance();
605 $cnt = $c->get(Cache::key('profile:notice_count:'.$this->id));
606 if (is_integer($cnt)) {
611 $notices = new Notice();
612 $notices->profile_id = $this->id;
613 $cnt = (int) $notices->count('distinct id');
616 $c->set(Cache::key('profile:notice_count:'.$this->id), $cnt);
622 function blowFavesCache()
624 $cache = Cache::instance();
626 // Faves don't happen chronologically, so we need to blow
628 $cache->delete(Cache::key('fave:ids_by_user:'.$this->id));
629 $cache->delete(Cache::key('fave:ids_by_user:'.$this->id.';last'));
630 $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id));
631 $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id.';last'));
633 $this->blowFaveCount();
636 function blowSubscriberCount()
638 $c = Cache::instance();
640 $c->delete(Cache::key('profile:subscriber_count:'.$this->id));
644 function blowSubscriptionCount()
646 $c = Cache::instance();
648 $c->delete(Cache::key('profile:subscription_count:'.$this->id));
652 function blowFaveCount()
654 $c = Cache::instance();
656 $c->delete(Cache::key('profile:fave_count:'.$this->id));
660 function blowNoticeCount()
662 $c = Cache::instance();
664 $c->delete(Cache::key('profile:notice_count:'.$this->id));
668 static function maxBio()
670 $biolimit = common_config('profile', 'biolimit');
671 // null => use global limit (distinct from 0!)
672 if (is_null($biolimit)) {
673 $biolimit = common_config('site', 'textlimit');
678 static function bioTooLong($bio)
680 $biolimit = self::maxBio();
681 return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
686 $this->_deleteNotices();
687 $this->_deleteSubscriptions();
688 $this->_deleteMessages();
689 $this->_deleteTags();
690 $this->_deleteBlocks();
691 $this->delete_avatars();
693 // Warning: delete() will run on the batch objects,
694 // not on individual objects.
695 $related = array('Reply',
698 Event::handle('ProfileDeleteRelated', array($this, &$related));
700 foreach ($related as $cls) {
702 $inst->profile_id = $this->id;
709 function _deleteNotices()
711 $notice = new Notice();
712 $notice->profile_id = $this->id;
714 if ($notice->find()) {
715 while ($notice->fetch()) {
716 $other = clone($notice);
722 function _deleteSubscriptions()
724 $sub = new Subscription();
725 $sub->subscriber = $this->id;
729 while ($sub->fetch()) {
730 $other = Profile::staticGet('id', $sub->subscribed);
734 if ($other->id == $this->id) {
737 Subscription::cancel($this, $other);
740 $subd = new Subscription();
741 $subd->subscribed = $this->id;
744 while ($subd->fetch()) {
745 $other = Profile::staticGet('id', $subd->subscriber);
749 if ($other->id == $this->id) {
752 Subscription::cancel($other, $this);
755 $self = new Subscription();
757 $self->subscriber = $this->id;
758 $self->subscribed = $this->id;
763 function _deleteMessages()
765 $msg = new Message();
766 $msg->from_profile = $this->id;
769 $msg = new Message();
770 $msg->to_profile = $this->id;
774 function _deleteTags()
776 $tag = new Profile_tag();
777 $tag->tagged = $this->id;
781 function _deleteBlocks()
783 $block = new Profile_block();
784 $block->blocked = $this->id;
787 $block = new Group_block();
788 $block->blocked = $this->id;
792 // XXX: identical to Notice::getLocation.
794 function getLocation()
798 if (!empty($this->location_id) && !empty($this->location_ns)) {
799 $location = Location::fromId($this->location_id, $this->location_ns);
802 if (is_null($location)) { // no ID, or Location::fromId() failed
803 if (!empty($this->lat) && !empty($this->lon)) {
804 $location = Location::fromLatLon($this->lat, $this->lon);
808 if (is_null($location)) { // still haven't found it!
809 if (!empty($this->location)) {
810 $location = Location::fromName($this->location);
817 function hasRole($name)
820 if (Event::handle('StartHasRole', array($this, $name, &$has_role))) {
821 $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
823 $has_role = !empty($role);
824 Event::handle('EndHasRole', array($this, $name, $has_role));
829 function grantRole($name)
831 if (Event::handle('StartGrantRole', array($this, $name))) {
833 $role = new Profile_role();
835 $role->profile_id = $this->id;
837 $role->created = common_sql_now();
839 $result = $role->insert();
842 throw new Exception("Can't save role '$name' for profile '{$this->id}'");
845 if ($name == 'owner') {
846 User::blow('user:site_owner');
849 Event::handle('EndGrantRole', array($this, $name));
855 function revokeRole($name)
857 if (Event::handle('StartRevokeRole', array($this, $name))) {
859 $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
863 // TRANS: Exception thrown when trying to revoke an existing role for a user that does not exist.
864 // TRANS: %1$s is the role name, %2$s is the user ID (number).
865 throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; does not exist.'),$name, $this->id));
868 $result = $role->delete();
871 common_log_db_error($role, 'DELETE', __FILE__);
872 // TRANS: Exception thrown when trying to revoke a role for a user with a failing database query.
873 // TRANS: %1$s is the role name, %2$s is the user ID (number).
874 throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; database error.'),$name, $this->id));
877 if ($name == 'owner') {
878 User::blow('user:site_owner');
881 Event::handle('EndRevokeRole', array($this, $name));
887 function isSandboxed()
889 return $this->hasRole(Profile_role::SANDBOXED);
892 function isSilenced()
894 return $this->hasRole(Profile_role::SILENCED);
899 $this->grantRole(Profile_role::SANDBOXED);
904 $this->revokeRole(Profile_role::SANDBOXED);
909 $this->grantRole(Profile_role::SILENCED);
914 $this->revokeRole(Profile_role::SILENCED);
918 * Does this user have the right to do X?
920 * With our role-based authorization, this is merely a lookup for whether the user
921 * has a particular role. The implementation currently uses a switch statement
922 * to determine if the user has the pre-defined role to exercise the right. Future
923 * implementations may allow per-site roles, and different mappings of roles to rights.
925 * @param $right string Name of the right, usually a constant in class Right
926 * @return boolean whether the user has the right in question
928 function hasRight($right)
932 if ($this->hasRole(Profile_role::DELETED)) {
936 if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
939 case Right::DELETEOTHERSNOTICE:
940 case Right::MAKEGROUPADMIN:
941 case Right::SANDBOXUSER:
942 case Right::SILENCEUSER:
943 case Right::DELETEUSER:
944 case Right::DELETEGROUP:
945 $result = $this->hasRole(Profile_role::MODERATOR);
947 case Right::CONFIGURESITE:
948 $result = $this->hasRole(Profile_role::ADMINISTRATOR);
950 case Right::GRANTROLE:
951 case Right::REVOKEROLE:
952 $result = $this->hasRole(Profile_role::OWNER);
954 case Right::NEWNOTICE:
955 case Right::NEWMESSAGE:
956 case Right::SUBSCRIBE:
957 case Right::CREATEGROUP:
958 $result = !$this->isSilenced();
960 case Right::PUBLICNOTICE:
961 case Right::EMAILONREPLY:
962 case Right::EMAILONSUBSCRIBE:
963 case Right::EMAILONFAVE:
964 $result = !$this->isSandboxed();
966 case Right::WEBLOGIN:
967 $result = !$this->isSilenced();
970 $result = !$this->isSilenced();
972 case Right::BACKUPACCOUNT:
973 $result = common_config('profile', 'backup');
975 case Right::RESTOREACCOUNT:
976 $result = common_config('profile', 'restore');
978 case Right::DELETEACCOUNT:
979 $result = common_config('profile', 'delete');
981 case Right::MOVEACCOUNT:
982 $result = common_config('profile', 'move');
992 function hasRepeated($notice_id)
994 // XXX: not really a pkey, but should work
996 $notice = Memcached_DataObject::pkeyGet('Notice',
997 array('profile_id' => $this->id,
998 'repeat_of' => $notice_id));
1000 return !empty($notice);
1004 * Returns an XML string fragment with limited profile information
1005 * as an Atom <author> element.
1007 * Assumes that Atom has been previously set up as the base namespace.
1009 * @param Profile $cur the current authenticated user
1013 function asAtomAuthor($cur = null)
1015 $xs = new XMLStringer(true);
1017 $xs->elementStart('author');
1018 $xs->element('name', null, $this->nickname);
1019 $xs->element('uri', null, $this->getUri());
1022 $attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
1023 $attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
1024 $xs->element('statusnet:profile_info', $attrs, null);
1026 $xs->elementEnd('author');
1028 return $xs->getString();
1032 * Extra profile info for atom entries
1034 * Clients use some extra profile info in the atom stream.
1035 * This gives it to them.
1037 * @param User $cur Current user
1039 * @return array representation of <statusnet:profile_info> element or null
1042 function profileInfo($cur)
1044 $profileInfoAttr = array('local_id' => $this->id);
1047 // Whether the current user is a subscribed to this profile
1048 $profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
1049 // Whether the current user is has blocked this profile
1050 $profileInfoAttr['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
1053 return array('statusnet:profile_info', $profileInfoAttr, null);
1057 * Returns an XML string fragment with profile information as an
1058 * Activity Streams <activity:actor> element.
1060 * Assumes that 'activity' namespace has been previously defined.
1064 function asActivityActor()
1066 return $this->asActivityNoun('actor');
1070 * Returns an XML string fragment with profile information as an
1071 * Activity Streams noun object with the given element type.
1073 * Assumes that 'activity', 'georss', and 'poco' namespace has been
1074 * previously defined.
1076 * @param string $element one of 'actor', 'subject', 'object', 'target'
1080 function asActivityNoun($element)
1082 $noun = ActivityObject::fromProfile($this);
1083 return $noun->asString('activity:' . $element);
1087 * Returns the best URI for a profile. Plugins may override.
1089 * @return string $uri
1095 // give plugins a chance to set the URI
1096 if (Event::handle('StartGetProfileUri', array($this, &$uri))) {
1098 // check for a local user first
1099 $user = User::staticGet('id', $this->id);
1101 if (!empty($user)) {
1104 // return OMB profile if any
1105 $remote = Remote_profile::staticGet('id', $this->id);
1106 if (!empty($remote)) {
1107 $uri = $remote->uri;
1110 Event::handle('EndGetProfileUri', array($this, &$uri));
1116 function hasBlocked($other)
1118 $block = Profile_block::get($this->id, $other->id);
1120 if (empty($block)) {
1129 function getAtomFeed()
1133 if (Event::handle('StartProfileGetAtomFeed', array($this, &$feed))) {
1134 $user = User::staticGet('id', $this->id);
1135 if (!empty($user)) {
1136 $feed = common_local_url('ApiTimelineUser', array('id' => $user->id,
1137 'format' => 'atom'));
1139 Event::handle('EndProfileGetAtomFeed', array($this, $feed));
1145 static function fromURI($uri)
1149 if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
1150 // Get a local user or remote (OMB 0.1) profile
1151 $user = User::staticGet('uri', $uri);
1152 if (!empty($user)) {
1153 $profile = $user->getProfile();
1155 $remote_profile = Remote_profile::staticGet('uri', $uri);
1156 if (!empty($remote_profile)) {
1157 $profile = Profile::staticGet('id', $remote_profile->profile_id);
1160 Event::handle('EndGetProfileFromURI', array($uri, $profile));