123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class User extends Managed_DataObject
- {
- const SUBSCRIBE_POLICY_OPEN = 0;
- const SUBSCRIBE_POLICY_MODERATE = 1;
-
-
- public $__table = 'user';
- public $id;
- public $nickname;
- public $password;
- public $email;
- public $incomingemail;
- public $emailnotifysub;
- public $emailnotifyfav;
- public $emailnotifynudge;
- public $emailnotifymsg;
- public $emailnotifyattn;
- public $emailmicroid;
- public $language;
- public $timezone;
- public $emailpost;
- public $sms;
- public $carrier;
- public $smsnotify;
- public $smsreplies;
- public $smsemail;
- public $uri;
- public $autosubscribe;
- public $subscribe_policy;
- public $urlshorteningservice;
- public $private_stream;
- public $created;
- public $modified;
-
-
- public static function schemaDef()
- {
- return array(
- 'description' => 'local users',
- 'fields' => array(
- 'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
- 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'),
- 'password' => array('type' => 'varchar', 'length' => 255, 'description' => 'salted password, can be null for OpenID users'),
- 'email' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for password recovery etc.'),
- 'incomingemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for post-by-email'),
- 'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'),
- 'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'),
- 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'),
- 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'),
- 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'),
- 'emailmicroid' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to publish email microid'),
- 'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'),
- 'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'),
- 'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'),
- 'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'),
- 'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'),
- 'smsnotify' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS'),
- 'smsreplies' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS on replies'),
- 'smsemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'built from sms and carrier'),
- 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'),
- 'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'),
- 'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
- 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
- 'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'),
- 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
- 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'user_nickname_key' => array('nickname'),
- 'user_email_key' => array('email'),
- 'user_incomingemail_key' => array('incomingemail'),
- 'user_sms_key' => array('sms'),
- 'user_uri_key' => array('uri'),
- ),
- 'foreign keys' => array(
- 'user_id_fkey' => array('profile', array('id' => 'id')),
- 'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')),
- ),
- 'indexes' => array(
- 'user_smsemail_idx' => array('smsemail'),
- ),
- );
- }
- protected $_profile = array();
-
- public function getProfile()
- {
- if (!isset($this->_profile[$this->id])) {
- $profile = Profile::getKV('id', $this->id);
- if (!$profile instanceof Profile) {
- throw new UserNoProfileException($this);
- }
- $this->_profile[$this->id] = $profile;
- }
- return $this->_profile[$this->id];
- }
- public function getUri()
- {
- return $this->uri;
- }
- public function getNickname()
- {
- return $this->getProfile()->getNickname();
- }
- function isSubscribed(Profile $other)
- {
- return $this->getProfile()->isSubscribed($other);
- }
- function hasPendingSubscription(Profile $other)
- {
- return $this->getProfile()->hasPendingSubscription($other);
- }
-
- function getCurrentNotice()
- {
- return $this->getProfile()->getCurrentNotice();
- }
- function getCarrier()
- {
- return Sms_carrier::getKV('id', $this->carrier);
- }
- function hasBlocked($other)
- {
- return $this->getProfile()->hasBlocked($other);
- }
-
- static function register(array $fields) {
-
- extract($fields);
- $profile = new Profile();
- if (!empty($email)) {
- $email = common_canonical_email($email);
- }
- try {
- $profile->nickname = Nickname::normalize($nickname, true);
- } catch (NicknameException $e) {
- common_log(LOG_WARNING, sprintf('Bad nickname during User registration for %s: %s', $nickname, $e->getMessage()), __FILE__);
- return false;
- }
- $profile->profileurl = common_profile_url($profile->nickname);
- if (!empty($fullname)) {
- $profile->fullname = $fullname;
- }
- if (!empty($homepage)) {
- $profile->homepage = $homepage;
- }
- if (!empty($bio)) {
- $profile->bio = $bio;
- }
- if (!empty($location)) {
- $profile->location = $location;
- $loc = Location::fromName($location);
- if (!empty($loc)) {
- $profile->lat = $loc->lat;
- $profile->lon = $loc->lon;
- $profile->location_id = $loc->location_id;
- $profile->location_ns = $loc->location_ns;
- }
- }
- $profile->created = common_sql_now();
- $user = new User();
- $user->nickname = $profile->nickname;
- $invite = null;
-
- if (!empty($code)) {
- $invite = Invitation::getKV($code);
- if ($invite instanceof Invitation && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
- $user->email = $invite->address;
- }
- }
- if(isset($email_confirmed) && $email_confirmed) {
- $user->email = $email;
- }
-
-
-
- $user->emailnotifysub = 1;
- $user->emailnotifynudge = 1;
- $user->emailnotifymsg = 1;
- $user->emailnotifyattn = 1;
- $user->emailmicroid = 1;
- $user->emailpost = 1;
- $user->jabbermicroid = 1;
- $user->created = common_sql_now();
- if (Event::handle('StartUserRegister', array($profile))) {
- $profile->query('BEGIN');
- $id = $profile->insert();
- if ($id === false) {
- common_log_db_error($profile, 'INSERT', __FILE__);
- return false;
- }
- $user->id = $id;
- if (!empty($uri)) {
- $user->uri = $uri;
- } else {
- $user->uri = common_user_uri($user);
- }
- if (!empty($password)) {
- $user->password = common_munge_password($password, $id);
- }
- $result = $user->insert();
- if ($result === false) {
- common_log_db_error($user, 'INSERT', __FILE__);
- $profile->query('ROLLBACK');
- return false;
- }
-
- $subscription = new Subscription();
- $subscription->subscriber = $user->id;
- $subscription->subscribed = $user->id;
- $subscription->created = $user->created;
- $result = $subscription->insert();
- if (!$result) {
- common_log_db_error($subscription, 'INSERT', __FILE__);
- $profile->query('ROLLBACK');
- return false;
- }
-
- if (!empty($invite)) {
- $invite->convert($user);
- }
- if (!empty($email) && !$user->email) {
- $confirm = new Confirm_address();
- $confirm->code = common_confirmation_code(128);
- $confirm->user_id = $user->id;
- $confirm->address = $email;
- $confirm->address_type = 'email';
- $result = $confirm->insert();
- if (!$result) {
- common_log_db_error($confirm, 'INSERT', __FILE__);
- $profile->query('ROLLBACK');
- return false;
- }
- }
- if (!empty($code) && $user->email) {
- $user->emailChanged();
- }
-
- $defnick = common_config('newuser', 'default');
- if (!empty($defnick)) {
- $defuser = User::getKV('nickname', $defnick);
- if (empty($defuser)) {
- common_log(LOG_WARNING, sprintf("Default user %s does not exist.", $defnick),
- __FILE__);
- } else {
- Subscription::start($profile, $defuser->getProfile());
- }
- }
- $profile->query('COMMIT');
- if (!empty($email) && !$user->email) {
- mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
- }
-
- $welcome = common_config('newuser', 'welcome');
- if (!empty($welcome)) {
- $welcomeuser = User::getKV('nickname', $welcome);
- if (empty($welcomeuser)) {
- common_log(LOG_WARNING, sprintf("Welcome user %s does not exist.", $defnick),
- __FILE__);
- } else {
- $notice = Notice::saveNew($welcomeuser->id,
-
-
- sprintf(_('Welcome to %1$s, @%2$s!'),
- common_config('site', 'name'),
- $user->nickname),
- 'system');
- }
- }
- Event::handle('EndUserRegister', array($profile));
- }
- return $user;
- }
-
- function emailChanged()
- {
- $invites = new Invitation();
- $invites->address = $this->email;
- $invites->address_type = 'email';
- if ($invites->find()) {
- while ($invites->fetch()) {
- try {
- $other = Profile::getKV('id', $invites->user_id);
- if (!($other instanceof Profile)) {
- continue;
- }
- Subscription::start($other, $this->getProfile());
- } catch (Exception $e) {
- continue;
- }
- }
- }
- }
- function mutuallySubscribed(Profile $other)
- {
- return $this->getProfile()->mutuallySubscribed($other);
- }
- function mutuallySubscribedUsers()
- {
-
- $UT = common_config('db','type')=='pgsql'?'"user"':'user';
- $qry = "SELECT $UT.* " .
- "FROM subscription sub1 JOIN $UT ON sub1.subscribed = $UT.id " .
- "JOIN subscription sub2 ON $UT.id = sub2.subscriber " .
- 'WHERE sub1.subscriber = %d and sub2.subscribed = %d ' .
- "ORDER BY $UT.nickname";
- $user = new User();
- $user->query(sprintf($qry, $this->id, $this->id));
- return $user;
- }
- function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
- {
- return Reply::stream($this->id, $offset, $limit, $since_id, $before_id);
- }
- function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
- return $this->getProfile()->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
- }
- function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
- {
- return $this->getProfile()->getNotices($offset, $limit, $since_id, $before_id);
- }
- function getSelfTags()
- {
- return Profile_tag::getTagsArray($this->id, $this->id, $this->id);
- }
- function setSelfTags($newtags, $privacy)
- {
- return Profile_tag::setTags($this->id, $this->id, $newtags, $privacy);
- }
- function block(Profile $other)
- {
-
-
- if ($this->id == $other->id) {
- common_log(LOG_WARNING,
- sprintf(
- "Profile ID %d (%s) tried to block themself.",
- $this->id,
- $this->nickname
- )
- );
- return false;
- }
- $block = new Profile_block();
-
- $block->query('BEGIN');
- $block->blocker = $this->id;
- $block->blocked = $other->id;
- $result = $block->insert();
- if (!$result) {
- common_log_db_error($block, 'INSERT', __FILE__);
- return false;
- }
- $self = $this->getProfile();
- if (Subscription::exists($other, $self)) {
- Subscription::cancel($other, $self);
- }
- if (Subscription::exists($self, $other)) {
- Subscription::cancel($self, $other);
- }
- $block->query('COMMIT');
- return true;
- }
- function unblock(Profile $other)
- {
-
- $block = Profile_block::exists($this->getProfile(), $other);
- if (!$block) {
- return false;
- }
- $result = $block->delete();
- if (!$result) {
- common_log_db_error($block, 'DELETE', __FILE__);
- return false;
- }
- return true;
- }
- function isMember(User_group $group)
- {
- return $this->getProfile()->isMember($group);
- }
- function isAdmin(User_group $group)
- {
- return $this->getProfile()->isAdmin($group);
- }
- function getGroups($offset=0, $limit=null)
- {
- return $this->getProfile()->getGroups($offset, $limit);
- }
-
- function joinGroup(User_group $group)
- {
- return $this->getProfile()->joinGroup($group);
- }
-
- function leaveGroup(User_group $group)
- {
- return $this->getProfile()->leaveGroup($group);
- }
- function getSubscribed($offset=0, $limit=null)
- {
- return $this->getProfile()->getSubscribed($offset, $limit);
- }
- function getSubscribers($offset=0, $limit=null)
- {
- return $this->getProfile()->getSubscribers($offset, $limit);
- }
- function getTaggedSubscribers($tag, $offset=0, $limit=null)
- {
- return $this->getProfile()->getTaggedSubscribers($tag, $offset, $limit);
- }
- function getTaggedSubscriptions($tag, $offset=0, $limit=null)
- {
- return $this->getProfile()->getTaggedSubscriptions($tag, $offset, $limit);
- }
- function hasRight($right)
- {
- return $this->getProfile()->hasRight($right);
- }
- function delete($useWhere=false)
- {
- if (empty($this->id)) {
- common_log(LOG_WARNING, "Ambiguous User->delete(); skipping related tables.");
- return parent::delete($useWhere);
- }
- try {
- $profile = $this->getProfile();
- $profile->delete();
- } catch (UserNoProfileException $unp) {
- common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion.");
- }
- $related = array(
- 'Confirm_address',
- 'Remember_me',
- 'Foreign_link',
- 'Invitation',
- );
- Event::handle('UserDeleteRelated', array($this, &$related));
- foreach ($related as $cls) {
- $inst = new $cls();
- $inst->user_id = $this->id;
- $inst->delete();
- }
- $this->_deleteTags();
- $this->_deleteBlocks();
- return parent::delete($useWhere);
- }
- function _deleteTags()
- {
- $tag = new Profile_tag();
- $tag->tagger = $this->id;
- $tag->delete();
- }
- function _deleteBlocks()
- {
- $block = new Profile_block();
- $block->blocker = $this->id;
- $block->delete();
-
- }
- function hasRole($name)
- {
- return $this->getProfile()->hasRole($name);
- }
- function grantRole($name)
- {
- return $this->getProfile()->grantRole($name);
- }
- function revokeRole($name)
- {
- return $this->getProfile()->revokeRole($name);
- }
- function isSandboxed()
- {
- return $this->getProfile()->isSandboxed();
- }
- function isSilenced()
- {
- return $this->getProfile()->isSilenced();
- }
- function receivesEmailNotifications()
- {
-
-
-
- if (empty($this->email) || !$this->emailnotifyattn) {
- return false;
- }
-
- if ($this->isSandboxed() || $this->isSilenced()) {
- return false;
- }
- return true;
- }
- function repeatedByMe($offset=0, $limit=20, $since_id=null, $max_id=null)
- {
- $stream = new RepeatedByMeNoticeStream($this);
- return $stream->getNotices($offset, $limit, $since_id, $max_id);
- }
- function repeatsOfMe($offset=0, $limit=20, $since_id=null, $max_id=null)
- {
- $stream = new RepeatsOfMeNoticeStream($this);
- return $stream->getNotices($offset, $limit, $since_id, $max_id);
- }
- function repeatedToMe($offset=0, $limit=20, $since_id=null, $max_id=null)
- {
-
- throw new Exception(_('Not implemented since inbox change.'));
- }
- public static function siteOwner()
- {
- $owner = self::cacheGet('user:site_owner');
- if ($owner === false) {
- $pr = new Profile_role();
- $pr->role = Profile_role::OWNER;
- $pr->orderBy('created');
- $pr->limit(1);
- if (!$pr->find(true)) {
- throw new NoResultException($pr);
- }
- $owner = User::getKV('id', $pr->profile_id);
- self::cacheSet('user:site_owner', $owner);
- }
- if ($owner instanceof User) {
- return $owner;
- }
- throw new ServerException(_('No site owner configured.'));
- }
-
- public static function singleUser()
- {
- if (!common_config('singleuser', 'enabled')) {
-
- throw new ServerException(_('Single-user mode code called when not enabled.'));
- }
- if ($nickname = common_config('singleuser', 'nickname')) {
- $user = User::getKV('nickname', $nickname);
- if ($user instanceof User) {
- return $user;
- }
- }
-
-
- return User::siteOwner();
- }
-
- static function singleUserNickname()
- {
- try {
- $user = User::singleUser();
- return $user->nickname;
- } catch (Exception $e) {
- if (common_config('singleuser', 'enabled') && common_config('singleuser', 'nickname')) {
- common_log(LOG_WARNING, "Warning: code attempting to pull single-user nickname when the account does not exist. If this is not setup time, this is probably a bug.");
- return common_config('singleuser', 'nickname');
- }
- throw $e;
- }
- }
-
- public function shortenLinks($text, $always=false)
- {
- return common_shorten_links($text, $always, $this);
- }
-
- function getConnectedApps($offset = 0, $limit = null)
- {
- $qry =
- 'SELECT u.* ' .
- 'FROM oauth_application_user u, oauth_application a ' .
- 'WHERE u.profile_id = %d ' .
- 'AND a.id = u.application_id ' .
- 'AND u.access_type > 0 ' .
- 'ORDER BY u.created DESC ';
- if ($offset > 0) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
- }
- $apps = new Oauth_application_user();
- $cnt = $apps->query(sprintf($qry, $this->id));
- return $apps;
- }
-
- function __sleep()
- {
- $vars = parent::__sleep();
- $skip = array('_profile');
- return array_diff($vars, $skip);
- }
- static function recoverPassword($nore)
- {
- $user = User::getKV('email', common_canonical_email($nore));
- if (!$user) {
- try {
- $user = User::getKV('nickname', common_canonical_nickname($nore));
- } catch (NicknameException $e) {
-
- }
- }
-
- if (!$user) {
-
-
-
- $confirm_email = new Confirm_address();
- $confirm_email->address = common_canonical_email($nore);
- $confirm_email->address_type = 'email';
- $confirm_email->find();
- if ($confirm_email->fetch()) {
- $user = User::getKV($confirm_email->user_id);
- } else {
- $confirm_email = null;
- }
- } else {
- $confirm_email = null;
- }
- if (!$user) {
-
- throw new ClientException(_('No user with that email address or username.'));
- return;
- }
-
- if (!$user->email && !$confirm_email) {
- $confirm_email = new Confirm_address();
- $confirm_email->user_id = $user->id;
- $confirm_email->address_type = 'email';
- $confirm_email->find();
- if (!$confirm_email->fetch()) {
- $confirm_email = null;
- }
- }
- if (!$user->email && !$confirm_email) {
-
- throw new ClientException(_('No registered email address for that user.'));
- return;
- }
-
- $confirm = new Confirm_address();
- $confirm->code = common_confirmation_code(128);
- $confirm->address_type = 'recover';
- $confirm->user_id = $user->id;
- $confirm->address = (!empty($user->email)) ? $user->email : $confirm_email->address;
- if (!$confirm->insert()) {
- common_log_db_error($confirm, 'INSERT', __FILE__);
-
- throw new ServerException(_('Error saving address confirmation.'));
- return;
- }
-
- $body = "Hey, $user->nickname.";
- $body .= "\n\n";
- $body .= 'Someone just asked for a new password ' .
- 'for this account on ' . common_config('site', 'name') . '.';
- $body .= "\n\n";
- $body .= 'If it was you, and you want to confirm, use the URL below:';
- $body .= "\n\n";
- $body .= "\t".common_local_url('recoverpassword',
- array('code' => $confirm->code));
- $body .= "\n\n";
- $body .= 'If not, just ignore this message.';
- $body .= "\n\n";
- $body .= 'Thanks for your time, ';
- $body .= "\n";
- $body .= common_config('site', 'name');
- $body .= "\n";
- $headers = _mail_prepare_headers('recoverpassword', $user->nickname, $user->nickname);
-
- mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address);
- }
- function streamModeOnly()
- {
- if (common_config('oldschool', 'enabled')) {
- $osp = Old_school_prefs::getKV('user_id', $this->id);
- if (!empty($osp)) {
- return $osp->stream_mode_only;
- }
- }
- return false;
- }
- function streamNicknames()
- {
- if (common_config('oldschool', 'enabled')) {
- $osp = Old_school_prefs::getKV('user_id', $this->id);
- if (!empty($osp)) {
- return $osp->stream_nicknames;
- }
- }
- return false;
- }
- function registrationActivity()
- {
- $profile = $this->getProfile();
- $service = new ActivityObject();
- $service->type = ActivityObject::SERVICE;
- $service->title = common_config('site', 'name');
- $service->link = common_root_url();
- $service->id = $service->link;
- $act = new Activity();
- $act->actor = $profile->asActivityObject();
- $act->verb = ActivityVerb::JOIN;
- $act->objects[] = $service;
- $act->id = TagURI::mint('user:register:%d',
- $this->id);
- $act->time = strtotime($this->created);
- $act->title = _("Register");
- $act->content = sprintf(_('%1$s joined %2$s.'),
- $profile->getBestName(),
- $service->title);
- return $act;
- }
- public function delPref($namespace, $topic)
- {
- return $this->getProfile()->delPref($namespace, $topic);
- }
- public function getPref($namespace, $topic, $default=null)
- {
- return $this->getProfile()->getPref($namespace, $topic, $default);
- }
- public function getConfigPref($namespace, $topic)
- {
- return $this->getProfile()->getConfigPref($namespace, $topic);
- }
- public function setPref($namespace, $topic, $data)
- {
- return $this->getProfile()->setPref($namespace, $topic, $data);
- }
- }
|