summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php43
-rw-r--r--classes/User.php23
2 files changed, 60 insertions, 6 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 4aec4ed55..7651d8bd5 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -175,13 +175,43 @@ class Notice extends Memcached_DataObject
}
}
+ /**
+ * Save a new notice and push it out to subscribers' inboxes.
+ * Poster's permissions are checked before sending.
+ *
+ * @param int $profile_id Profile ID of the poster
+ * @param string $content source message text; links may be shortened
+ * per current user's preference
+ * @param string $source source key ('web', 'api', etc)
+ * @param array $options Associative array of optional properties:
+ * string 'created' timestamp of notice; defaults to now
+ * int 'is_local' source/gateway ID, one of:
+ * Notice::LOCAL_PUBLIC - Local, ok to appear in public timeline
+ * Notice::REMOTE_OMB - Sent from a remote OMB service;
+ * hide from public timeline but show in
+ * local "and friends" timelines
+ * Notice::LOCAL_NONPUBLIC - Local, but hide from public timeline
+ * Notice::GATEWAY - From another non-OMB service;
+ * will not appear in public views
+ * 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
+ * int 'reply_to'; notice ID this is a reply to
+ * int 'repeat_of'; notice ID this is a repeat of
+ * string 'uri' permalink to notice; defaults to local notice URL
+ *
+ * @return Notice
+ * @throws ClientException
+ */
static function saveNew($profile_id, $content, $source, $options=null) {
+ $defaults = array('uri' => null,
+ 'reply_to' => null,
+ 'repeat_of' => null);
if (!empty($options)) {
+ $options = $options + $defaults;
extract($options);
- if (!isset($reply_to)) {
- $reply_to = NULL;
- }
}
if (empty($is_local)) {
@@ -966,6 +996,9 @@ class Notice extends Memcached_DataObject
return true;
}
+ /**
+ * @return array of integer profile IDs
+ */
function saveReplies()
{
// Alternative reply format
@@ -1044,8 +1077,8 @@ class Notice extends Memcached_DataObject
$recipientIds = array_keys($replied);
- foreach ($recipientIds as $recipient) {
- $user = User::staticGet('id', $recipient);
+ foreach ($recipientIds as $recipientId) {
+ $user = User::staticGet('id', $recipientId);
if ($user) {
mail_notify_attn($user, $this);
}
diff --git a/classes/User.php b/classes/User.php
index d04f7d679..ae709b46b 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -180,6 +180,27 @@ class User extends Memcached_DataObject
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
@@ -329,7 +350,7 @@ class User extends Memcached_DataObject
$profile->query('COMMIT');
- if ($email && !$user->email) {
+ if (!empty($email) && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
}