Esempio n. 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 (Kaltura_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');
 }
Esempio n. 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 (Kaltura_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 = Kaltura_ClientHelper::getClient();
     if (!$client) {
         $this->view->errors[] = 'init client failed';
         return;
     }
     if ($request->getParam('searchType') == 'by-flavor-asset-id') {
         try {
             // $entryId is actually flavor id in this case
             $entry = $client->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);
         Kaltura_ClientHelper::impersonate($partnerId);
         if ($submitAction == 'retry') {
             $jobId = $request->getParam('actionJobId', 0);
             $jobType = $request->getParam('actionJobType', 0);
             $client->jobs->retryJob($jobId, $jobType);
         }
         if ($submitAction == 'reconvertEntry') {
             $client->jobs->addConvertProfileJob($entryId);
         }
         if ($submitAction == 'reconvert') {
             $flavorAssetId = $request->getParam('actionFlavorAssetId', 0);
             $client->flavorAsset->reconvert($flavorAssetId);
         }
         if ($submitAction == 'regenerate') {
             $thumbAssetId = $request->getParam('actionFlavorAssetId', 0);
             $client->thumbAsset->regenerate($thumbAssetId);
         }
         Kaltura_ClientHelper::unimpersonate();
     }
     $this->view->investigateData = $this->getEntryInvestigationData($entryId, $this->view->errors);
     $this->view->enableActions = true;
     $partnerId = $this->view->investigateData->entry->partnerId;
     $this->view->plugins = array();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaAdminConsoleEntryInvestigate');
     foreach ($pluginInstances as $pluginInstance) {
         $entryInvestigatePlugins = $pluginInstance->getEntryInvestigatePlugins();
         if (!$entryInvestigatePlugins) {
             continue;
         }
         foreach ($entryInvestigatePlugins as $plugin) {
             $this->view->addBasePath($plugin->getTemplatePath());
             $this->view->plugins[$plugin->getPHTML()] = $plugin->getDataArray($entryId, $partnerId);
         }
     }
 }