]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
adminUpdates setting not available now
[quix0rs-gnu-social.git] / lib / noticelist.php
index 3bd7b05b4adb8c446d40d2225f86ef848c78b531..b00e476d92a1e11f231fea7b40977f7e096e97c8 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/favorform.php';
-require_once INSTALLDIR.'/lib/disfavorform.php';
-require_once INSTALLDIR.'/lib/attachmentlist.php';
+if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
 
 /**
  * widget for displaying a list of notices
@@ -87,7 +81,7 @@ class NoticeList extends Widget
                $total   = count($notices);
                $notices = array_slice($notices, 0, NOTICES_PER_PAGE);
                
-       $this->prefill($notices);
+       self::prefill($notices);
        
        foreach ($notices as $notice) {
 
@@ -122,9 +116,33 @@ class NoticeList extends Widget
         return new NoticeListItem($notice, $this->out);
     }
     
-    function prefill(&$notices)
+    static function prefill(&$notices, $avatarSize=AVATAR_STREAM_SIZE)
     {
-       // Prefill the profiles
-       Notice::fillProfiles($notices);
+        if (Event::handle('StartNoticeListPrefill', array(&$notices, $avatarSize))) {
+
+            // Prefill attachments
+            Notice::fillAttachments($notices);
+            // Prefill attachments
+            Notice::fillFaves($notices);
+            // Prefill repeat data
+            Notice::fillRepeats($notices);
+            // Prefill the profiles
+            $profiles = Notice::fillProfiles($notices);
+       
+            $p = Profile::current();
+            if ($p instanceof Profile) {
+
+                $ids = array();
+       
+                foreach ($notices as $notice) {
+                    $ids[] = $notice->id;
+                }
+       
+                Fave::pivotGet('notice_id', $ids, array('user_id' => $p->id));
+                Notice::pivotGet('repeat_of', $ids, array('profile_id' => $p->id));
+            }
+
+            Event::handle('EndNoticeListPrefill', array(&$notices, &$profiles, $avatarSize));
+        }
     }
 }