minor happening changes

This commit is contained in:
Mikael Nordfeldth 2015-12-31 18:04:12 +01:00
parent f6df44ea85
commit 34ce2f6cfa
2 changed files with 14 additions and 11 deletions

View File

@ -27,9 +27,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
if (!defined('STATUSNET')) { if (!defined('GNUSOCIAL')) { exit(1); }
exit(1);
}
/** /**
* Data class for happenings * Data class for happenings
@ -172,14 +170,14 @@ class Happening extends Managed_DataObject
$options); $options);
if (!array_key_exists('uri', $options)) { if (!array_key_exists('uri', $options)) {
$options['uri'] = $ev->uri; $options['uri'] = $ev->getUri();
} }
if (!empty($url)) { if (!empty($url)) {
$options['urls'] = array($url); $options['urls'] = array($url);
} }
$saved = Notice::saveNew($profile->id, $saved = Notice::saveNew($profile->getID(),
$content, $content,
array_key_exists('source', $options) ? array_key_exists('source', $options) ?
$options['source'] : 'web', $options['source'] : 'web',
@ -202,14 +200,19 @@ class Happening extends Managed_DataObject
return $this->url; return $this->url;
} }
public function getUri()
{
return $this->uri;
}
function getNotice() function getNotice()
{ {
return Notice::getKV('uri', $this->uri); return Notice::getKV('uri', $this->getUri());
} }
static function fromNotice($notice) static function fromNotice($notice)
{ {
return Happening::getKV('uri', $notice->uri); return Happening::getKV('uri', $notice->getUri());
} }
function getRSVPs() function getRSVPs()
@ -219,7 +222,7 @@ class Happening extends Managed_DataObject
function getRSVP($profile) function getRSVP($profile)
{ {
return RSVP::pkeyGet(array('profile_id' => $profile->id, return RSVP::pkeyGet(array('profile_id' => $profile->getID(),
'event_id' => $this->id)); 'event_id' => $this->id));
} }
} }

View File

@ -28,7 +28,7 @@ class RawEventsNoticeStream extends NoticeStream
$qry .= 'AND notice.id <= ' . $max_id . ' '; $qry .= 'AND notice.id <= ' . $max_id . ' ';
} }
// NOTE: we sort by bookmark time, not by notice time! // NOTE: we sort by event time, not by notice time!
$qry .= 'ORDER BY created DESC '; $qry .= 'ORDER BY created DESC ';
if (!is_null($offset)) { if (!is_null($offset)) {
$qry .= "LIMIT $limit OFFSET $offset"; $qry .= "LIMIT $limit OFFSET $offset";
@ -53,9 +53,9 @@ class EventsNoticeStream extends ScopingNoticeStream
$stream = new RawEventsNoticeStream($target); $stream = new RawEventsNoticeStream($target);
if ($target->sameAs($scoped)) { if ($target->sameAs($scoped)) {
$key = 'bookmark:ids_by_user_own:'.$target->getID(); $key = 'happening:ids_for_user_own:'.$target->getID();
} else { } else {
$key = 'bookmark:ids_by_user:'.$target->getID(); $key = 'happening:ids_for_user:'.$target->getID();
} }
parent::__construct(new CachingNoticeStream($stream, $key), $scoped); parent::__construct(new CachingNoticeStream($stream, $key), $scoped);