public function doAction(Zend_Controller_Action $action) { $request = $action->getRequest(); $action->view->errors = array(); $formAction = $action->view->url(array('controller' => 'plugin', 'action' => 'AdminConsoleGalleryAction'), null, true); $action->view->searchEntriesForm = new Form_Batch_SearchEntries(); $action->view->searchEntriesForm->setAction($formAction); $filter = $action->view->searchEntriesForm->getFilter($request->getParams()); $action->view->searchEntriesForm->populate($request->getParams()); $client = Infra_ClientHelper::getClient(); if (!$client) { $action->view->errors[] = 'init client failed'; return; } $partnerId = $request->getParam('partnerId'); if ($partnerId > 0) { $paginatorAdapter = new Infra_FilterPaginator($client->media, "listAction", $partnerId, $filter); $paginator = new Infra_Paginator($paginatorAdapter, $request, null, 30); $paginator->setAvailablePageSizes(array(15, 30, 60, 100)); $paginator->setAction($formAction); $action->view->paginator = $paginator; $action->view->playerPartnerId = $partnerId; $action->view->uiConf = null; $action->view->swfUrl = null; $adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client); $uiConfId = Zend_Registry::get('config')->settings->defaultUiConfId; if ($uiConfId) { $action->view->uiConf = $adminConsolePlugin->uiConfAdmin->get($uiConfId); } else { $uiConfFilter = new Kaltura_Client_Type_UiConfFilter(); $uiConfFilter->partnerIdIn = 0; $uiConfFilter->objTypeEqual = Kaltura_Client_Enum_UiConfObjType::PLAYER_V3; $uiConfFilter->orderBy = Kaltura_Client_Enum_UiConfOrderBy::CREATED_AT_DESC; $uiConfPager = new Kaltura_Client_Type_FilterPager(); $uiConfPager->pageSize = 1; $uiConfList = $adminConsolePlugin->uiConfAdmin->listAction($uiConfFilter, $uiConfPager); /* @var $uiConfList Kaltura_Client_AdminConsole_Type_UiConfAdminListResponse */ if (count($uiConfList->objects)) { $action->view->uiConf = reset($uiConfList->objects); } } if ($action->view->uiConf) { $action->view->swfUrl = "/index.php/kwidget/wid/_{$partnerId}/cache_st/" . time() . "/uiconf_id/" . $action->view->uiConf->id; } } }
public function failedTasksAction() { $defaultJobTypes = array(Kaltura_Client_Enum_BatchJobType::CONVERT, Kaltura_Client_Enum_BatchJobType::IMPORT, Kaltura_Client_Enum_BatchJobType::BULKUPLOAD); $oClass = new ReflectionClass('Kaltura_Client_Enum_ConversionEngineType'); $convertSubTypes = $oClass->getConstants(); $oClass = new ReflectionClass('Kaltura_Client_Enum_BatchJobType'); $jobTypes = array_flip($oClass->getConstants()); $jobTypes[Kaltura_Client_Enum_BatchJobType::CONVERT] = $convertSubTypes; $oClass = new ReflectionClass('Kaltura_Client_Enum_BatchJobErrorTypes'); $errorTypes = $oClass->getConstants(); $oClass = new ReflectionClass('Kaltura_Client_Enum_BatchJobStatus'); $statuses = array_flip($oClass->getConstants()); $statuses[Kaltura_Client_Enum_BatchJobStatus::FAILED] = $errorTypes; $request = $this->getRequest(); $this->view->errors = array(); $client = Infra_ClientHelper::getClient(); if (!$client) { $this->view->errors[] = 'init client failed'; return; } $submitAction = $request->getParam('submitAction', false); if ($submitAction && strlen($submitAction)) { $actionJobs = $request->getParam('actionJobs', array()); $jobsArr = explode(';', $actionJobs); $jobs = array(); foreach ($jobsArr as $jobData) { list($jobId, $jobType) = explode(',', $jobData); $jobs[$jobId] = $jobType; } $client->startMultiRequest(); foreach ($jobs as $jobId => $jobType) { if ($submitAction == 'retry') { Infra_AclHelper::validateAccess('batch', 'failed-retry-delete'); $client->jobs->retryJob($jobId, $jobType); } elseif ($submitAction == 'delete') { Infra_AclHelper::validateAccess('batch', 'failed-retry-delete'); $client->jobs->deleteJob($jobId, $jobType); } } $results = $client->doMultiRequest(); } $action = $this->view->url(array('controller' => 'batch', 'action' => 'failed-tasks'), null, true); $this->view->tasksFailedForm = new Form_Batch_TasksFailed(); $this->view->tasksFailedForm->populate($request->getParams()); $this->view->tasksFailedForm->setAction($action); $submitAction = $this->view->tasksFailedForm->getElement('submitAction'); $submitAction->setValue(''); $filter = new Infra_BatchJobFilter(); $filter->orderBy = Kaltura_Client_Enum_BatchJobOrderBy::CREATED_AT_DESC; if ($request->getParam('createdAtFrom', false)) { $createdAtFrom = new Zend_Date($this->_getParam('createdAtFrom', $this->getDefaultFromDate())); $filter->createdAtGreaterThanOrEqual = $createdAtFrom->toString(Zend_Date::TIMESTAMP); } else { $createdAtFrom = $this->view->tasksFailedForm->getElement('createdAtFrom'); $createdAtFrom->setValue(date('m/d/Y', $this->getDefaultFromDate())); $filter->createdAtGreaterThanOrEqual = $this->getDefaultFromDate(); } if ($request->getParam('createdAtTo', false)) { $createdAtTo = new Zend_Date($this->_getParam('createdAtTo', $this->getDefaultToDate())); $filter->createdAtLessThanOrEqual = $createdAtTo->toString(Zend_Date::TIMESTAMP); } else { $createdAtTo = $this->view->tasksFailedForm->getElement('createdAtTo'); $createdAtTo->setValue(date('m/d/Y', $this->getDefaultToDate())); $filter->createdAtLessThanOrEqual = $this->getDefaultToDate(); } $entryId = $request->getParam('entryId', null); if ($entryId && strlen($entryId)) { $filter->entryIdEqual = $entryId; } $partnerId = $request->getParam('partnerId', null); if ($partnerId && is_numeric($partnerId)) { $filter->partnerIdEqual = $partnerId; } $inFailedStatuses = array(); if ($request->getParam('allReasons', false) == '0') { $inErrorTypes = array(); foreach ($statuses as $status => $errTypes) { $statusChecked = $request->getParam("status_{$status}", false); if ($statusChecked) { $inFailedStatuses[] = $status; } if (is_array($errTypes)) { foreach ($errTypes as $errType) { if (!$statusChecked && $request->getParam("status_{$status}_{$errType}", false)) { $inFailedStatuses[] = $status; $inErrorTypes[] = $errType; } } } } if (count($inErrorTypes)) { $filter->errTypeIn = implode(',', $inErrorTypes); } } if (!count($inFailedStatuses)) { $inFailedStatuses = array(Kaltura_Client_Enum_BatchJobStatus::FAILED, Kaltura_Client_Enum_BatchJobStatus::ABORTED, Kaltura_Client_Enum_BatchJobStatus::FATAL); } $filter->statusIn = implode(',', $inFailedStatuses); // $allJobs = $request->getParam('allJobs', false); // if($allJobs == '0') // { foreach ($jobTypes as $jobType => $jobSubTypes) { if (is_array($jobSubTypes)) { $inJobSubTypes = array(); foreach ($jobSubTypes as $jobSubType) { $fieldName = 'job_' . str_replace('.', '_', $jobType) . '_' . str_replace('.', '_', $jobSubType); if ($request->getParam($fieldName, false)) { $inJobSubTypes[] = $jobSubType; } } if (count($inJobSubTypes)) { $filter->addJobType($jobType, $inJobSubTypes); } } else { $fieldName = 'job_' . str_replace('.', '_', $jobType); if ($request->getParam($fieldName, false)) { $filter->addJobType($jobType); } } } // } // if(!$allJobs && is_bool($allJobs)) if (!$filter->hasJobTypeFilter()) { $filter->jobTypeIn = implode(',', $defaultJobTypes); } $paginatorAdapter = new Infra_FilterPaginator($client->jobs, "listBatchJobs", null, $filter); $paginator = new Infra_Paginator($paginatorAdapter, $request); $paginator->setAction($action); $this->view->paginator = $paginator; }