public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     $form = new Form_PartnerIdFilter();
     $form->populate($request->getParams());
     $newForm = new Form_NewEventNotificationTemplate();
     $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'EventNotificationTemplatesListAction'), null, true);
     $form->setAction($actionUrl);
     // init filter
     $partnerFilter = $this->getPartnerFilterFromRequest($request);
     $client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($client);
     // get results and paginate
     $paginatorAdapter = new Infra_FilterPaginator($eventNotificationPlugin->eventNotificationTemplate, "listByPartner", null, $partnerFilter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     if ($partnerFilter) {
         $newForm->getElement('newPartnerId')->setValue($partnerFilter->idIn);
     }
     // set view
     $action->view->form = $form;
     $action->view->newForm = $newForm;
     $action->view->paginator = $paginator;
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('viewRenderer')->setNoRender();
     $templateId = $this->_getParam('template_id');
     $status = $this->_getParam('status');
     $client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($client);
     try {
         $eventNotificationPlugin->eventNotificationTemplate->updateStatus($templateId, $status);
         echo $action->getHelper('json')->sendJson('ok', false);
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         echo $action->getHelper('json')->sendJson($e->getMessage(), false);
     }
 }
Example #3
0
 protected function getDataArray()
 {
     $client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($client);
     $businessProcessNotificationPlugin = Kaltura_Client_BusinessProcessNotification_Plugin::get($client);
     $errDescriptions = array();
     $businessProcessCases = array();
     try {
         Infra_ClientHelper::impersonate($this->partnerId);
         $objectType = Kaltura_Client_EventNotification_Enum_EventNotificationEventObjectType::ENTRY;
         $businessProcessCases = $businessProcessNotificationPlugin->businessProcessCase->listAction($objectType, $this->entryId);
         Infra_ClientHelper::unimpersonate();
     } catch (Exception $e) {
         $errDescriptions[] = $e->getMessage();
     }
     $templateIds = array();
     $businessProcesses = array();
     $businessProcessCasesUrls = array();
     if (count($businessProcessCases)) {
         foreach ($businessProcessCases as $businessProcessCase) {
             $businessProcessCasesUrls[$businessProcessCase->businessProcessStartNotificationTemplateId] = $businessProcessNotificationPlugin->businessProcessCase->serveDiagram($objectType, $this->entryId, $businessProcessCase->businessProcessStartNotificationTemplateId);
             $businessProcesses[$businessProcessCase->businessProcessStartNotificationTemplateId] = $businessProcessCase;
             $templateIds[] = $businessProcessCase->businessProcessStartNotificationTemplateId;
         }
     }
     $eventNotificationTemplates = array();
     if (count($templateIds)) {
         $filter = new Kaltura_Client_EventNotification_Type_EventNotificationTemplateFilter();
         $filter->idIn = implode(',', $templateIds);
         try {
             Infra_ClientHelper::impersonate($this->partnerId);
             $eventNotificationTemplateList = $eventNotificationPlugin->eventNotificationTemplate->listAction($filter);
             Infra_ClientHelper::unimpersonate();
             $eventNotificationTemplates = $eventNotificationTemplateList->objects;
         } catch (Exception $e) {
             $errDescriptions[] = $e->getMessage();
         }
     }
     return array('businessProcessCases' => $businessProcesses, 'businessProcessCasesUrls' => $businessProcessCasesUrls, 'eventNotificationTemplates' => $eventNotificationTemplates, 'errDescriptions' => $errDescriptions);
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $this->client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($this->client);
     $request = $action->getRequest();
     $partnerId = $this->_getParam('partner_id');
     if (!$partnerId) {
         $partnerId = 0;
     }
     $templateId = $this->_getParam('template_id');
     $cloneTemplateId = $this->_getParam('clone_template_id');
     $type = null;
     $eventNotificationTemplate = null;
     $action->view->errMessage = null;
     $action->view->form = '';
     $action->view->plugins = array();
     $form = null;
     try {
         Infra_ClientHelper::impersonate($partnerId);
         if ($cloneTemplateId) {
             if ($partnerId) {
                 $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->cloneAction($cloneTemplateId);
                 $templateId = $eventNotificationTemplate->id;
                 $type = $eventNotificationTemplate->type;
             } else {
                 $action->view->errMessage = "Partner ID must be defined.";
                 $templateId = null;
                 Infra_ClientHelper::unimpersonate();
                 return;
             }
         } elseif ($templateId) {
             $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->get($templateId);
             $type = $eventNotificationTemplate->type;
         } else {
             $type = $this->_getParam('type');
         }
         $form = KalturaPluginManager::loadObject('Form_EventNotificationTemplateConfiguration', $type, array($partnerId, $type));
         /* @var $form Form_EventNotificationTemplateConfiguration */
         $templateClass = KalturaPluginManager::getObjectClass('Kaltura_Client_EventNotification_Type_EventNotificationTemplate', $type);
         KalturaLog::debug("template class [{$templateClass}]");
         if (!$form || !$form instanceof Form_EventNotificationTemplateConfiguration) {
             $action->view->errMessage = "Template form not found for type [{$type}]";
             return;
         }
         $urlParams = array('controller' => 'plugin', 'action' => 'EventNotificationTemplateConfigureAction', 'clone_template_id' => null);
         if ($templateId) {
             $urlParams['template_id'] = $templateId;
         }
         $form->setAction($action->view->url($urlParams));
         if ($templateId) {
             if ($request->isPost()) {
                 if ($form->isValid($request->getPost())) {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                     $form->resetUnUpdatebleAttributes($eventNotificationTemplate);
                     $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->update($templateId, $eventNotificationTemplate);
                     $form->setAttrib('class', 'valid');
                     $action->view->formValid = true;
                 } else {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 }
                 $form->finit($eventNotificationTemplate);
             } else {
                 $form->populateFromObject($eventNotificationTemplate);
             }
         } else {
             if ($request->isPost() && $form->isValid($request->getPost())) {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 $eventNotificationTemplate->partnerId = null;
                 $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->add($eventNotificationTemplate);
                 $form->setAttrib('class', 'valid');
                 $action->view->formValid = true;
             } else {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
             }
             $form->finit($eventNotificationTemplate);
         }
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
         if ($form) {
             $form->populate($request->getPost());
             $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
         }
     }
     Infra_ClientHelper::unimpersonate();
     $action->view->form = $form;
     $action->view->templateId = $templateId;
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaApplicationPartialView');
     KalturaLog::debug("plugin instances [" . count($pluginInstances) . "]");
     foreach ($pluginInstances as $pluginInstance) {
         $entryInvestigatePlugins = $pluginInstance->getApplicationPartialViews('plugin', get_class($this));
         if (!$entryInvestigatePlugins) {
             continue;
         }
         foreach ($entryInvestigatePlugins as $plugin) {
             /* @var $plugin Kaltura_View_Helper_PartialViewPlugin */
             $plugin->plug($action->view);
         }
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $this->client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($this->client);
     $request = $action->getRequest();
     $templateId = $this->_getParam('template_id');
     $type = null;
     $partnerId = null;
     $eventNotificationTemplate = null;
     $action->view->errMessage = null;
     $action->view->form = '';
     $form = null;
     try {
         if ($templateId) {
             $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->get($templateId);
             $type = $eventNotificationTemplate->type;
             $partnerId = $eventNotificationTemplate->partnerId;
         } else {
             $type = $this->_getParam('type');
             $partnerId = $this->_getParam('partner_id');
         }
         $form = KalturaPluginManager::loadObject('Form_EventNotificationTemplateConfiguration', $type, array($partnerId, $type));
         /* @var $form Form_EventNotificationTemplateConfiguration */
         $templateClass = KalturaPluginManager::getObjectClass('Kaltura_Client_EventNotification_Type_EventNotificationTemplate', $type);
         KalturaLog::debug("template class [{$templateClass}]");
         if (!$form || !$form instanceof Form_EventNotificationTemplateConfiguration) {
             $action->view->errMessage = "Template form not found for type [{$type}]";
             return;
         }
         $form->setAction($action->view->url(array('controller' => 'plugin', 'action' => 'EventNotificationTemplateConfigureAction')));
         $pager = new Kaltura_Client_Type_FilterPager();
         $pager->pageSize = 100;
         if ($templateId) {
             if ($request->isPost()) {
                 if ($form->isValid($request->getPost())) {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                     $form->resetUnUpdatebleAttributes($eventNotificationTemplate);
                     $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->update($templateId, $eventNotificationTemplate);
                     $form->setAttrib('class', 'valid');
                     $action->view->formValid = true;
                 } else {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 }
                 $form->finit();
             } else {
                 $form->populateFromObject($eventNotificationTemplate);
             }
         } else {
             if ($request->isPost() && $form->isValid($request->getPost())) {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 if (!$eventNotificationTemplate->partnerId) {
                     $eventNotificationTemplate->partnerId = 0;
                 }
                 Infra_ClientHelper::impersonate($eventNotificationTemplate->partnerId);
                 $eventNotificationTemplate->partnerId = null;
                 $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->add($eventNotificationTemplate);
                 Infra_ClientHelper::unimpersonate();
                 $form->setAttrib('class', 'valid');
                 $action->view->formValid = true;
             } else {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
             }
             $form->finit();
         }
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
         if ($form) {
             $form->populate($request->getPost());
             $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
         }
     }
     $action->view->form = $form;
 }