]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/GNUsocialPhotos/actions/photo.php
Conversation IDs (again) no longer based on Notice ID
[quix0rs-gnu-social.git] / plugins / GNUsocialPhotos / actions / photo.php
index 4d08e5bbd6393ed15870285397c72ce394a7075c..ecd64919c598c3fd0593cb863708d7da76b1dd96 100644 (file)
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-include_once INSTALLDIR . '/actions/conversation.php';
-include_once INSTALLDIR . '/classes/Notice.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
-class PhotoAction extends Action
+class PhotoAction extends ManagedAction
 {
     var $user = null;
+    var $conv = null;   // Conversation dataobject
 
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
         $args = $this->returnToArgs();
         $this->photoid = $args[1]['photoid'];
-        $this->photo = GNUsocialPhoto::staticGet('id', $this->photoid);
-        $this->notice = Notice::staticGet('id', $this->photo->notice_id);
+        $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
+        $this->notice = Notice::getKV('id', $this->photo->notice_id);
 
-        $this->user = Profile::staticGet('id', $this->notice->profile_id);
-        
-        $notices = Notice::conversationStream((int)$this->notice->conversation, null, null); 
-        $this->conversation = new ConversationTree($notices, $this);
-        return true;
-
-    }
+        $this->user = Profile::getKV('id', $this->notice->profile_id);
+        $this->conv = $this->notice->getConversation();
 
-    function handle($args)
-    {
-        parent::handle($args);
-        $this->showPage();
+        return true;
     }
 
     function title()
@@ -102,6 +90,12 @@ class PhotoAction extends Action
         $this->element('p', array('class' => 'photodescription'), $this->photo->photo_description);
         //This is a hack to hide the top-level comment
         $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photo->notice_id} ol li div { display: inline }");
-        $this->conversation->show();
+
+        if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
+            $notices = $this->conv->getNotices($this->scoped);
+            $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
+            $cnt = $nl->show();
+        }
+        Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
     }
 }