summaryrefslogtreecommitdiff
path: root/lib/noticelist.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r--lib/noticelist.php85
1 files changed, 80 insertions, 5 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 21cec528f..4c11ceed6 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -147,6 +147,10 @@ class NoticeListItem extends Widget
var $notice = null;
+ /** The notice that was repeated. */
+
+ var $repeat = null;
+
/** The profile of the author of the notice, extracted once for convenience. */
var $profile = null;
@@ -162,8 +166,18 @@ class NoticeListItem extends Widget
function __construct($notice, $out=null)
{
parent::__construct($out);
- $this->notice = $notice;
- $this->profile = $notice->getProfile();
+ if (!empty($notice->repeat_of)) {
+ $original = Notice::staticGet('id', $notice->repeat_of);
+ if (empty($original)) { // could have been deleted
+ $this->notice = $notice;
+ } else {
+ $this->notice = $original;
+ $this->repeat = $notice;
+ }
+ } else {
+ $this->notice = $notice;
+ }
+ $this->profile = $this->notice->getProfile();
}
/**
@@ -202,6 +216,7 @@ class NoticeListItem extends Widget
$this->showNoticeSource();
$this->showNoticeLocation();
$this->showContext();
+ $this->showRepeat();
$this->out->elementEnd('div');
}
@@ -212,6 +227,7 @@ class NoticeListItem extends Widget
$this->out->elementStart('div', 'notice-options');
$this->showFaveForm();
$this->showReplyLink();
+ $this->showRepeatForm();
$this->showDeleteLink();
$this->out->elementEnd('div');
}
@@ -227,8 +243,9 @@ class NoticeListItem extends Widget
{
// XXX: RDFa
// TODO: add notice_type class e.g., notice_video, notice_image
+ $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
$this->out->elementStart('li', array('class' => 'hentry notice',
- 'id' => 'notice-' . $this->notice->id));
+ 'id' => 'notice-' . $id));
}
/**
@@ -508,6 +525,40 @@ class NoticeListItem extends Widget
}
/**
+ * show a link to the author of repeat
+ *
+ * @return void
+ */
+
+ function showRepeat()
+ {
+ if (!empty($this->repeat)) {
+
+ $repeater = Profile::staticGet('id', $this->repeat->profile_id);
+
+ $attrs = array('href' => $repeater->profileurl,
+ 'class' => 'url');
+
+ if (!empty($repeater->fullname)) {
+ $attrs['title'] = $repeater->fullname . ' (' . $repeater->nickname . ')';
+ }
+
+ $this->out->elementStart('span', 'repeat vcard');
+
+ $this->out->raw(_('Repeated by'));
+
+ $avatar = $repeater->getAvatar(AVATAR_MINI_SIZE);
+
+ $this->out->elementStart('a', $attrs);
+
+ $this->out->element('span', 'nickname', $repeater->nickname);
+ $this->out->elementEnd('a');
+
+ $this->out->elementEnd('span');
+ }
+ }
+
+ /**
* show a link to reply to the current notice
*
* Should either do the reply in the current notice form (if available), or
@@ -540,11 +591,13 @@ class NoticeListItem extends Widget
{
$user = common_current_user();
+ $todel = (empty($this->repeat)) ? $this->notice : $this->repeat;
+
if (!empty($user) &&
- ($this->notice->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
+ ($todel->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
$deleteurl = common_local_url('deletenotice',
- array('notice' => $this->notice->id));
+ array('notice' => $todel->id));
$this->out->element('a', array('href' => $deleteurl,
'class' => 'notice_delete',
'title' => _('Delete this notice')), _('Delete'));
@@ -552,6 +605,28 @@ class NoticeListItem extends Widget
}
/**
+ * show the form to repeat a notice
+ *
+ * @return void
+ */
+
+ function showRepeatForm()
+ {
+ $user = common_current_user();
+ if ($user && $user->id != $this->notice->profile_id) {
+ $profile = $user->getProfile();
+ if ($profile->hasRepeated($this->notice->id)) {
+ $this->out->element('span', array('class' => 'repeated',
+ 'title' => _('Notice repeated')),
+ _('Repeated'));
+ } else {
+ $rf = new RepeatForm($this->out, $this->notice);
+ $rf->show();
+ }
+ }
+ }
+
+ /**
* finish the notice
*
* Close the last elements in the notice list item