summaryrefslogtreecommitdiff
path: root/classes/User.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-22 13:56:16 -0700
committerBrion Vibber <brion@pobox.com>2010-03-22 13:56:16 -0700
commite89908f26140c217e01b2f8f755712f38f3935f3 (patch)
tree6b241fc2e33f3528cf48b415ef67906826b02e24 /classes/User.php
parent714d920faea302b55857cc3bec4e9e6160ea136a (diff)
parenteb563937df921e5fc67ca0c87e229feb2907fd19 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 1.0.x
Conflicts: lib/channel.php scripts/imdaemon.php
Diffstat (limited to 'classes/User.php')
-rw-r--r--classes/User.php64
1 files changed, 21 insertions, 43 deletions
diff --git a/classes/User.php b/classes/User.php
index 15ec4ad94..1ba940a69 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -70,7 +70,11 @@ class User extends Memcached_DataObject
function getProfile()
{
- return Profile::staticGet('id', $this->id);
+ $profile = Profile::staticGet('id', $this->id);
+ if (empty($profile)) {
+ throw new UserNoProfileException($this);
+ }
+ return $profile;
}
function isSubscribed($other)
@@ -82,6 +86,7 @@ class User extends Memcached_DataObject
function updateKeys(&$orig)
{
+ $this->_connect();
$parts = array();
foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
if (strcmp($this->$k, $orig->$k) != 0) {
@@ -127,13 +132,15 @@ class User extends Memcached_DataObject
return !in_array($nickname, $blacklist);
}
- function getCurrentNotice($dt=null)
+ /**
+ * Get the most recent notice posted by this user, if any.
+ *
+ * @return mixed Notice or null
+ */
+ function getCurrentNotice()
{
$profile = $this->getProfile();
- if (!$profile) {
- return null;
- }
- return $profile->getCurrentNotice($dt);
+ return $profile->getCurrentNotice();
}
function getCarrier()
@@ -141,19 +148,12 @@ class User extends Memcached_DataObject
return Sms_carrier::staticGet('id', $this->carrier);
}
+ /**
+ * @deprecated use Subscription::start($sub, $other);
+ */
function subscribeTo($other)
{
- $sub = new Subscription();
- $sub->subscriber = $this->id;
- $sub->subscribed = $other->id;
-
- $sub->created = common_sql_now(); // current time
-
- if (!$sub->insert()) {
- return false;
- }
-
- return true;
+ return Subscription::start($this->getProfile(), $other);
}
function hasBlocked($other)
@@ -334,17 +334,7 @@ class User extends Memcached_DataObject
common_log(LOG_WARNING, sprintf("Default user %s does not exist.", $defnick),
__FILE__);
} else {
- $defsub = new Subscription();
- $defsub->subscriber = $user->id;
- $defsub->subscribed = $defuser->id;
- $defsub->created = $user->created;
-
- $result = $defsub->insert();
-
- if (!$result) {
- common_log_db_error($defsub, 'INSERT', __FILE__);
- return false;
- }
+ Subscription::start($user, $defuser);
}
}
@@ -460,21 +450,13 @@ class User extends Memcached_DataObject
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
$profile = $this->getProfile();
- if (!$profile) {
- return null;
- } else {
- return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
- }
+ return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
}
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
{
$profile = $this->getProfile();
- if (!$profile) {
- return null;
- } else {
- return $profile->getNotices($offset, $limit, $since_id, $before_id);
- }
+ return $profile->getNotices($offset, $limit, $since_id, $before_id);
}
function favoriteNotices($offset=0, $limit=NOTICES_PER_PAGE, $own=false)
@@ -615,14 +597,12 @@ class User extends Memcached_DataObject
function getSubscriptions($offset=0, $limit=null)
{
$profile = $this->getProfile();
- assert(!empty($profile));
return $profile->getSubscriptions($offset, $limit);
}
function getSubscribers($offset=0, $limit=null)
{
$profile = $this->getProfile();
- assert(!empty($profile));
return $profile->getSubscribers($offset, $limit);
}
@@ -686,9 +666,7 @@ class User extends Memcached_DataObject
function delete()
{
$profile = $this->getProfile();
- if ($profile) {
- $profile->delete();
- }
+ $profile->delete();
$related = array('Fave',
'Confirm_address',