return $avatar;
}
+ /**
+ * Delete attached avatars for this user from the database and filesystem.
+ * This should be used instead of a batch delete() to ensure that files
+ * get removed correctly.
+ *
+ * @param boolean $original true to delete only the original-size file
+ * @return <type>
+ */
function delete_avatars($original=true)
{
$avatar = new Avatar();
return $profile;
}
- 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 subscriptionCount()
{
$c = common_memcache();
return $cnt;
}
+ /**
+ * Is this profile subscribed to another profile?
+ *
+ * @param Profile $other
+ * @return boolean
+ */
+ function isSubscribed($other)
+ {
+ return Subscription::exists($this, $other);
+ }
+
+ /**
+ * Are these two profiles subscribed to each other?
+ *
+ * @param Profile $other
+ * @return boolean
+ */
+ function mutuallySubscribed($other)
+ {
+ return $this->isSubscribed($other) &&
+ $other->isSubscribed($this);
+ }
+
function hasFave($notice)
{
$cache = common_memcache();
$this->_deleteMessages();
$this->_deleteTags();
$this->_deleteBlocks();
+ $this->delete_avatars();
- $related = array('Avatar',
- 'Reply',
+ // Warning: delete() will run on the batch objects,
+ // not on individual objects.
+ $related = array('Reply',
'Group_member',
);
Event::handle('ProfileDeleteRelated', array($this, &$related));
case Right::NEWNOTICE:
case Right::NEWMESSAGE:
case Right::SUBSCRIBE:
+ case Right::CREATEGROUP:
$result = !$this->isSilenced();
break;
case Right::PUBLICNOTICE: