<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Album_Widget_BreadcrumbPhotoController extends Engine_Content_Widget_Abstract {

  public function indexAction() {
  
    $viewer = Engine_Api::_()->user()->getViewer();
    $this->view->photo = $photo = Engine_Api::_()->core()->getSubject('album_photo');

    if(!$photo) 
      return $this->setNoRender();
      
    $this->view->album = $album = $photo->getAlbum();
    
    // if this is sending a message id, the user is being directed from a coversation
    // check if member is part of the conversation
    $message_id = $this->_getParam('message');
    $message_view = false;
    if ($message_id) {
      $conversation = Engine_Api::_()->getItem('messages_conversation', $message_id);
      if($conversation->hasRecipient(Engine_Api::_()->user()->getViewer())) $message_view = true;
    }
    
    $this->view->message_view = $message_view;
    $this->view->isprivate = 0;
    if(engine_in_array($album->type, array("group","event"))){
        $this->view->isprivate = 1;
        if($album->getOwner()->getIdentity() == $viewer->getIdentity()){
            $this->view->isprivate = 0;
        }
    }
  }
}
