Beispiel #1
0
 public function init()
 {
     $this->setAttrib('class', 'simple');
     $this->setTemplatePath('forms/investigate.phtml');
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setEnctype('multipart/form-data');
     $this->setAttrib('id', 'frmSearch');
     $this->addElement('select', 'searchType', array('required' => true, 'multiOptions' => array('by-entry-id' => 'By Entry ID', 'by-flavor-asset-id' => 'By Flavor Asset ID')));
     // Add an entryId element
     $this->addElement('text', 'entryId', array('required' => true, 'filters' => array('StringTrim'), 'validators' => array()));
     if (Infra_Support::isAdminEnabled()) {
         $this->addElement('file', 'entryFile');
     }
     // Add the search button
     $this->addElement('button', 'search', array('type' => 'submit', 'ignore' => true, 'label' => 'entry-history search button'));
     $this->addElement('hidden', 'submitAction');
     $this->addElement('hidden', 'partnerId');
     $this->addElement('hidden', 'actionFlavorAssetId');
     $this->addElement('hidden', 'actionJobId');
     $this->addElement('hidden', 'actionJobType');
 }
Beispiel #2
0
 public function entryInvestigationAction()
 {
     $request = $this->getRequest();
     $this->view->errors = array();
     $this->view->investigateData = null;
     $this->view->enableActions = false;
     $action = $this->view->url(array('controller' => 'batch', 'action' => 'entry-investigation'), null, true);
     $this->view->searchEntryForm = new Form_Batch_SearchEntry();
     $this->view->searchEntryForm->populate($request->getParams());
     $this->view->searchEntryForm->setAction($action);
     $submitAction = $this->view->searchEntryForm->getElement('submitAction');
     $submitAction->setValue('');
     if (Infra_Support::isAdminEnabled()) {
         $upload = new Zend_File_Transfer_Adapter_Http();
         $files = $upload->getFileInfo();
         if (count($files) && isset($files['entryFile']) && $files['entryFile']['size']) {
             $file = $files['entryFile'];
             $investigateData = unserialize(base64_decode(file_get_contents($file['tmp_name'])));
             $entryIdField = $this->view->searchEntryForm->getElement('entryId');
             $entryIdField->setValue($investigateData->entry->id);
             $this->view->investigateData = $investigateData;
             $this->view->enableActions = false;
             return;
         }
     }
     $entryId = $request->getParam('entryId', false);
     if (!$entryId) {
         return;
     }
     $client = Infra_ClientHelper::getClient();
     if (!$client) {
         $this->view->errors[] = 'init client failed';
         return;
     }
     $adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client);
     if ($request->getParam('searchType') == 'by-flavor-asset-id') {
         try {
             // $entryId is actually flavor id in this case
             $entry = $adminConsolePlugin->entryAdmin->getByFlavorId($entryId);
         } catch (Exception $e) {
             $this->view->errors[] = 'Flavor asset not found: ' . $e->getMessage();
             return;
         }
         $entryId = $entry->id;
     }
     $submitAction = $request->getParam('submitAction', false);
     if ($submitAction && strlen($submitAction)) {
         $partnerId = $request->getParam('partnerId', 0);
         Infra_ClientHelper::impersonate($partnerId);
         if ($submitAction == 'retry') {
             $jobId = $request->getParam('actionJobId', 0);
             $jobType = $request->getParam('actionJobType', 0);
             try {
                 $client->jobs->retryJob($jobId, $jobType);
             } catch (Exception $e) {
                 $this->view->errors[] = "Retry job [{$jobId}] error: " . $e->getMessage();
             }
         }
         if ($submitAction == 'boostEntryJobs') {
             try {
                 $client->jobs->boostEntryJobs($entryId);
             } catch (Exception $e) {
                 $this->view->errors[] = "Boost entry [{$entryId}] jobs error: " . $e->getMessage();
             }
         }
         if ($submitAction == 'reconvertEntry') {
             try {
                 $client->jobs->addConvertProfileJob($entryId);
             } catch (Exception $e) {
                 $this->view->errors[] = "Reconvert entry [{$entryId}] error: " . $e->getMessage();
             }
         }
         if ($submitAction == 'reconvert') {
             $flavorAssetId = $request->getParam('actionFlavorAssetId', 0);
             try {
                 $client->flavorAsset->reconvert($flavorAssetId);
             } catch (Exception $e) {
                 $this->view->errors[] = "Reconvert flavor [{$flavorAssetId}] error: " . $e->getMessage();
             }
         }
         if ($submitAction == 'regenerate') {
             $thumbAssetId = $request->getParam('actionFlavorAssetId', 0);
             try {
                 $client->thumbAsset->regenerate($thumbAssetId);
             } catch (Exception $e) {
                 $this->view->errors[] = "Regenerate thumbnail [{$thumbAssetId}] error: " . $e->getMessage();
             }
         }
         Infra_ClientHelper::unimpersonate();
     }
     $this->view->investigateData = $this->getEntryInvestigationData($entryId, $this->view->errors);
     $this->view->enableActions = true;
     if (!$this->view || !$this->view->investigateData) {
         return;
     }
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaApplicationPartialView');
     foreach ($pluginInstances as $pluginInstance) {
         $entryInvestigatePlugins = $pluginInstance->getApplicationPartialViews('batch', 'entryInvestigation');
         if (!$entryInvestigatePlugins) {
             continue;
         }
         foreach ($entryInvestigatePlugins as $plugin) {
             /* @var $plugin Kaltura_View_Helper_PartialViewPlugin */
             $plugin->plug($this->view);
         }
     }
 }