return $result;
}
+ /**
+ * Register a new user account and profile and set up default subscriptions.
+ * If a new-user welcome message is configured, this will be sent.
+ *
+ * @param array $fields associative array of optional properties
+ * string 'bio'
+ * string 'email'
+ * bool 'email_confirmed' pass true to mark email as pre-confirmed
+ * string 'fullname'
+ * string 'homepage'
+ * string 'location' informal string description of geolocation
+ * float 'lat' decimal latitude for geolocation
+ * float 'lon' decimal longitude for geolocation
+ * int 'location_id' geoname identifier
+ * int 'location_ns' geoname namespace to interpret location_id
+ * string 'nickname' REQUIRED
+ * string 'password' (may be missing for eg OpenID registrations)
+ * string 'code' invite code
+ * ?string 'uri' permalink to notice; defaults to local notice URL
+ * @return mixed User object or false on failure
+ */
static function register($fields) {
// MAGICALLY put fields into current scope
return false;
}
+ // Everyone gets an inbox
+
+ $inbox = new Inbox();
+
+ $inbox->user_id = $user->id;
+ $inbox->notice_ids = '';
+
+ $result = $inbox->insert();
+
+ if (!$result) {
+ common_log_db_error($inbox, 'INSERT', __FILE__);
+ return false;
+ }
+
// Everyone is subscribed to themself
$subscription = new Subscription();
$profile->query('COMMIT');
- if ($email && !$user->email) {
+ if (!empty($email) && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
}
function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
-
+ $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
return Notice::getStreamByIds($ids);
}
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
+ $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
+ return Notice::getStreamByIds($ids);
+ }
+
+ function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
+ {
+ $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
+
+ return Notice::getStreamByIds($ids);
+ }
+
+ function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
+ {
+ $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
return Notice::getStreamByIds($ids);
}
// Cancel their subscription, if it exists
- subs_unsubscribe_to($other->getUser(),$this->getProfile());
+ $otherUser = User::staticGet('id', $other->id);
+
+ if (!empty($otherUser)) {
+ subs_unsubscribe_to($otherUser, $this->getProfile());
+ }
$block->query('COMMIT');
'Remember_me',
'Foreign_link',
'Invitation',
- 'Notice_inbox',
);
Event::handle('UserDeleteRelated', array($this, &$related));
return $ids;
}
+
+ function repeatedToMe($offset=0, $limit=20, $since_id=null, $max_id=null)
+ {
+ throw new Exception("Not implemented since inbox change.");
+ }
+
+ function shareLocation()
+ {
+ $cfg = common_config('location', 'share');
+
+ if ($cfg == 'always') {
+ return true;
+ } else if ($cfg == 'never') {
+ return false;
+ } else { // user
+ $share = true;
+
+ $prefs = User_location_prefs::staticGet('user_id', $this->id);
+
+ if (empty($prefs)) {
+ $share = common_config('location', 'sharedefault');
+ } else {
+ $share = $prefs->share_location;
+ $prefs->free();
+ }
+
+ return $share;
+ }
+ }
}