]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelistitem.php
Merge branch 'master' into social-master
[quix0rs-gnu-social.git] / lib / noticelistitem.php
index be55c522c8b4543ab832457b5961bae668c419cf..c8bf2c312d51d87ed891ee28d80cdd80da94a550 100644 (file)
@@ -60,6 +60,7 @@ class NoticeListItem extends Widget
 
     protected $addressees = true;
     protected $attachments = true;
+    protected $id_prefix = null;
     protected $options = true;
     protected $maxchars = 0;   // if <= 0 it means use full posts
 
@@ -99,6 +100,12 @@ class NoticeListItem extends Widget
                 $this->$key = (bool)$prefs[$key];
             }
         }
+        // string preferences
+        foreach(array('id_prefix') as $key) {
+            if (array_key_exists($key, $prefs)) {
+                $this->$key = $prefs[$key];
+            }
+        }
     }
 
     /**
@@ -181,7 +188,8 @@ class NoticeListItem extends Widget
     {
         if (Event::handle('StartShowNoticeOptions', array($this))) {
             $user = common_current_user();
-            if ($user) {
+
+            if ($user instanceof User) {
                 $this->out->elementStart('div', 'notice-options');
                 if (Event::handle('StartShowNoticeOptionItems', array($this))) {
                     $this->showReplyLink();
@@ -191,6 +199,7 @@ class NoticeListItem extends Widget
                 }
                 $this->out->elementEnd('div');
             }
+
             Event::handle('EndShowNoticeOptions', array($this));
         }
     }
@@ -211,8 +220,9 @@ class NoticeListItem extends Widget
             if (!empty($this->notice->source)) {
                 $class .= ' notice-source-'.$this->notice->source;
             }
+            $id_prefix = (strlen($this->id_prefix) ? $this->id_prefix . '-' : '');
             $this->out->elementStart('li', array('class' => $class,
-                                                 'id' => 'notice-' . $id));
+                                                 'id' => "${id_prefix}notice-${id}"));
             Event::handle('EndOpenNoticeListItemElement', array($this));
         }
     }