]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
Revert "* [Cc]an't -> [Cc]annot"
[quix0rs-gnu-social.git] / lib / noticelist.php
index 5429d943f14b8039977d62aa2d44d0506855305b..bf12bb73c5dfd4df71e48bee9503a08dc89b6d0a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * widget for displaying a list of notices
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  UI
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @author    Sarven Capadisli <csarven@controlyourself.ca>
- * @copyright 2008 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @copyright 2008 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -45,10 +45,10 @@ require_once INSTALLDIR.'/lib/attachmentlist.php';
  * data for e.g. the profile page.
  *
  * @category UI
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  * @see      Notice
  * @see      NoticeListItem
  * @see      ProfileNoticeList
@@ -133,10 +133,10 @@ class NoticeList extends Widget
  * author info (since that's implicit by the data in the page).
  *
  * @category UI
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  * @see      NoticeList
  * @see      ProfileNoticeListItem
  */
@@ -178,9 +178,12 @@ class NoticeListItem extends Widget
     function show()
     {
         $this->showStart();
-        $this->showNotice();
-        $this->showNoticeInfo();
-        $this->showNoticeOptions();
+        if (Event::handle('StartShowNoticeItem', array($this))) {
+            $this->showNotice();
+            $this->showNoticeInfo();
+            $this->showNoticeOptions();
+            Event::handle('EndShowNoticeItem', array($this));
+        }
         $this->showEnd();
     }
 
@@ -196,6 +199,7 @@ class NoticeListItem extends Widget
     {
         $this->out->elementStart('div', 'entry-content');
         $this->showNoticeLink();
+        $this->showNoticeLocation();
         $this->showNoticeSource();
         $this->showContext();
         $this->out->elementEnd('div');
@@ -261,7 +265,7 @@ class NoticeListItem extends Widget
         $attrs = array('href' => $this->profile->profileurl,
                        'class' => 'url');
         if (!empty($this->profile->fullname)) {
-            $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
+            $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
         }
         $this->out->elementStart('a', $attrs);
         $this->showAvatar();
@@ -366,6 +370,44 @@ class NoticeListItem extends Widget
         $this->out->elementEnd('a');
     }
 
+    /**
+     * show the notice location
+     *
+     * shows the notice location in the correct language.
+     *
+     * If an URL is available, makes a link. Otherwise, just a span.
+     *
+     * @return void
+     */
+
+    function showNoticeLocation()
+    {
+        $id = $this->notice->id;
+
+        $location = $this->notice->getLocation();
+
+        if (empty($location)) {
+            return;
+        }
+
+        $name = $location->getName();
+
+        if (empty($name)) {
+            // XXX: Could be a translation issue. Fall back to... something?
+            return;
+        }
+
+        $url  = $location->getUrl();
+
+        if (empty($url)) {
+            $this->out->element('span', array('class' => 'location'), $name);
+        } else {
+            $this->out->element('a', array('class' => 'location',
+                                           'href' => $url),
+                                $name);
+        }
+    }
+
     /**
      * Show the source of the notice
      *
@@ -418,9 +460,17 @@ class NoticeListItem extends Widget
 
     function showContext()
     {
-        // XXX: also show context if there are replies to this notice
-        if (!empty($this->notice->conversation)
-            && $this->notice->conversation != $this->notice->id) {
+        $hasConversation = false;
+        if( !empty($this->notice->conversation)
+            && $this->notice->conversation != $this->notice->id){
+            $hasConversation = true;
+        }else{
+            $conversation = Notice::conversationStream($this->notice->id, 1, 1);
+            if($conversation->N > 0){
+                $hasConversation = true;
+            }
+        }
+        if ($hasConversation){
             $convurl = common_local_url('conversation',
                                          array('id' => $this->notice->conversation));
             $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
@@ -442,7 +492,7 @@ class NoticeListItem extends Widget
     {
         if (common_logged_in()) {
             $reply_url = common_local_url('newnotice',
-                                          array('replyto' => $this->profile->nickname));
+                                          array('replyto' => $this->profile->nickname, 'inreplyto' => $this->notice->id));
             $this->out->elementStart('a', array('href' => $reply_url,
                                                 'class' => 'notice_reply',
                                                 'title' => _('Reply to this notice')));
@@ -461,7 +511,10 @@ class NoticeListItem extends Widget
     function showDeleteLink()
     {
         $user = common_current_user();
-        if ($user && $this->notice->profile_id == $user->id) {
+
+        if (!empty($user) &&
+            ($this->notice->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
+
             $deleteurl = common_local_url('deletenotice',
                                           array('notice' => $this->notice->id));
             $this->out->element('a', array('href' => $deleteurl,