Exemplo n.º 1
0
 public function manageAction()
 {
     //Checking Ynvideo Plugin - Viewer required -View privacy
     //$video_enable = Engine_Api::_()->hasModuleBootstrap('video');
     $video_enable = 1;
     $ynvideo_enable = Engine_Api::_()->hasModuleBootstrap('ynvideo');
     if (!$video_enable && !$ynvideo_enable) {
         return $this->_helper->requireSubject->forward();
     }
     if (!$this->_helper->requireUser()->isValid()) {
         return;
     }
     if (!$this->_helper->requireAuth()->setAuthParams($event, null, 'view')->isValid()) {
         return;
     }
     //Get viewer, event, search form
     $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->event = $event = Engine_Api::_()->core()->getSubject();
     $this->view->form = $form = new Ynevent_Form_Video_Search(array('manage' => '1'));
     // Check create video authorization
     $canCreate = $event->authorization()->isAllowed(null, 'video');
     $levelCreate = Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('event', $viewer, 'video');
     if ($canCreate && $levelCreate) {
         $this->view->canCreate = true;
     } else {
         $this->view->canCreate = false;
     }
     //Prepare data filer
     $params = array();
     $params = $this->_getAllParams();
     $params['parent_type'] = 'event';
     $params['parent_id'] = $event->getIdentity();
     $params['user_id'] = $viewer->getIdentity();
     $params['limit'] = 12;
     $form->populate($params);
     $this->view->formValues = $form->getValues();
     //Get data from table Mappings
     $tableMapping = Engine_Api::_()->getItemTable('ynevent_mapping');
     $mapping_ids = $tableMapping->getVideoIdsMapping();
     //Get data from table video
     $tableVideo = Engine_Api::_()->getItemTable('video');
     $select = $tableVideo->select()->from($tableVideo->info('name'), new Zend_Db_Expr("`video_id`"))->where('parent_type = "event"')->where('parent_id = ?', $event->getIdentity());
     $video_ids = $tableVideo->fetchAll($select);
     //Merge ids
     foreach ($mapping_ids as $mapping_id) {
         $params['ids'][] = $mapping_id->item_id;
     }
     foreach ($video_ids as $video_id) {
         $params['ids'][] = $video_id->video_id;
     }
     //Get data
     $this->view->paginator = $paginator = $event->getVideosPaginator($params);
     if (!empty($params['orderby'])) {
         switch ($params['orderby']) {
             case 'most_liked':
                 $this->view->infoCol = 'like';
                 break;
             case 'most_commented':
                 $this->view->infoCol = 'comment';
                 break;
             default:
                 $this->view->infoCol = 'view';
                 break;
         }
     }
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject('event');
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Prepare data
     $this->view->event = $event = $subject;
     //Get viewer, event, search form
     $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->event = $event = Engine_Api::_()->core()->getSubject();
     $this->view->form = $form = new Ynevent_Form_Video_Search();
     if (!$event->authorization()->isAllowed($viewer, 'view')) {
         return;
     }
     // Check create video authorization
     $canCreate = $event->authorization()->isAllowed($viewer, 'video');
     $levelCreate = Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('event', $viewer, 'video');
     if ($canCreate && $levelCreate) {
         $this->view->canCreate = true;
     } else {
         $this->view->canCreate = false;
     }
     //Prepare data filer
     $params = array();
     $params = $this->_getAllParams();
     $params['title'] = '';
     $params['parent_type'] = 'event';
     $params['parent_id'] = $event->getIdentity();
     $params['search'] = 1;
     $params['limit'] = 12;
     $form->populate($params);
     $this->view->formValues = $form->getValues();
     //Get data from table Mappings
     $tableMapping = Engine_Api::_()->getItemTable('ynevent_mapping');
     $mapping_ids = $tableMapping->getVideoIdsMapping();
     //Get data from table video
     $tableVideo = Engine_Api::_()->getItemTable('video');
     $select = $tableVideo->select()->from($tableVideo->info('name'), new Zend_Db_Expr("`video_id`"))->where('parent_type = "event"')->where('parent_id = ?', $event->getIdentity());
     $video_ids = $tableVideo->fetchAll($select);
     //Merge ids
     foreach ($mapping_ids as $mapping_id) {
         $params['ids'][] = $mapping_id->item_id;
     }
     foreach ($video_ids as $video_id) {
         $params['ids'][] = $video_id->video_id;
     }
     //Get data
     if (!Engine_Api::_()->hasItemType('video')) {
         return $this->setNoRender();
     }
     //$paginator = Engine_Api::_() -> ynvideo() -> getVideosPaginator($params);
     $paginator = $event->getVideosPaginator($params);
     $this->view->paginator = $paginator;
     // Add count to title if configured
     if ($this->_getParam('titleCount', false) && $paginator->getTotalItemCount() > 0) {
         $this->_childCount = $paginator->getTotalItemCount();
     }
 }