protected function getMetadataFields() { if (is_array($this->metadataProfileFields)) { return $this->metadataProfileFields; } $this->metadataProfileFields = array(); Infra_ClientHelper::impersonate($this->partnerId); $client = Infra_ClientHelper::getClient(); $metadataPlugin = Kaltura_Client_Metadata_Plugin::get($client); try { $metadataProfileFilter = new Kaltura_Client_Metadata_Type_MetadataProfileFilter(); $metadataProfileFilter->partnerIdEqual = $this->partnerId; $metadataProfileList = $metadataPlugin->metadataProfile->listAction($metadataProfileFilter); if ($metadataProfileList->totalCount) { $client->startMultiRequest(); foreach ($metadataProfileList->objects as $metadataProfile) { $metadataFieldList = $metadataPlugin->metadataProfile->listFields($metadataProfile->id); } $results = $client->doMultiRequest(); foreach ($results as $metadataFieldList) { foreach ($metadataFieldList->objects as $metadataField) { $this->metadataProfileFields[$metadataField->xPath] = $metadataField->label; } } } } catch (Exception $e) { Infra_ClientHelper::unimpersonate(); throw $e; } Infra_ClientHelper::unimpersonate(); return $this->metadataProfileFields; }
protected function addProviderElements() { $this->setDescription('Unicorn Distribution Profile'); $element = new Zend_Form_Element_Hidden('providerElements'); $element->setLabel('Unicorn Specific Configuration'); $element->setDecorators(array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'b')))); $this->addElements(array($element)); $this->addElement('text', 'api_host_url', array('label' => 'API host URL:', 'filters' => array('StringTrim'))); $this->addElement('text', 'username', array('label' => 'Username:'******'filters' => array('StringTrim'))); $this->addElement('text', 'password', array('label' => 'Password:'******'filters' => array('StringTrim'))); $this->addElement('text', 'domain_name', array('label' => 'Domain name:', 'filters' => array('StringTrim'))); $this->addElement('text', 'domain_guid', array('label' => 'Domain GUID:', 'filters' => array('StringTrim'))); $this->addElement('text', 'channel_guid', array('label' => 'Channel GUID:', 'filters' => array('StringTrim'))); $this->addElement('text', 'ad_free_application_guid', array('label' => 'Ad free application GUID:', 'filters' => array('StringTrim'))); $this->addElement('select', 'remote_asset_params_id', array('label' => 'Remote asset params ID:', 'registerInArrayValidator' => false)); $storageProfiles = array(); try { $client = Infra_ClientHelper::getClient(); Infra_ClientHelper::impersonate($this->partnerId); $storageProfileList = $client->storageProfile->listAction(); Infra_ClientHelper::unimpersonate(); foreach ($storageProfileList->objects as $storageProfile) { /* @var $storageProfile Kaltura_Client_Type_StorageProfile */ $storageProfiles[$storageProfile->id] = $storageProfile->name; } } catch (Kaltura_Client_Exception $e) { } $this->addElement('select', 'storage_profile_id', array('label' => 'Storage profile ID:', 'multiOptions' => $storageProfiles)); }
/** * * @param int $offset * @param int $itemCountPerPage */ protected function callService($offset, $itemCountPerPage) { $client = Infra_ClientHelper::getClient(); if ($this->impersonatedPartnerId) { Infra_ClientHelper::impersonate($this->impersonatedPartnerId); } $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageIndex = (int) ($offset / $itemCountPerPage) + 1; $pager->pageSize = $itemCountPerPage; $action = $this->action; $params = $this->args; $params[] = $pager; try { $this->errorDescription = null; $response = call_user_func_array(array($this->service, $action), $params); } catch (Exception $e) { Infra_ClientHelper::unimpersonate(); $this->errorDescription = $e->getMessage(); $this->totalCount = 0; return array(); } Infra_ClientHelper::unimpersonate(); $this->totalCount = $response->totalCount; if (!$response->objects) { return array(); } return $response->objects; }
public function getDataArray($entryId, $partnerId) { $client = Infra_ClientHelper::getClient(); if (!$client) { $errors[] = 'init client failed'; return; } $attachmentPlugin = Kaltura_Client_Attachment_Plugin::get($client); $fileSyncPlugin = Kaltura_Client_FileSync_Plugin::get($client); $filter = new Kaltura_Client_Attachment_Type_AttachmentAssetFilter(); $filter->entryIdEqual = $entryId; $attachmentAssets = array(); $attachmentAssetsFileSyncs = array(); $errDescription = null; try { Infra_ClientHelper::impersonate($partnerId); $attachmentAssetsList = $attachmentPlugin->attachmentAsset->listAction($filter); Infra_ClientHelper::unimpersonate(); $attachmentAssets = $attachmentAssetsList->objects; } catch (Exception $e) { $errDescription = $e->getMessage(); } $attachmentAssetIds = array(); if (is_array($attachmentAssets)) { foreach ($attachmentAssets as $attachmentAsset) { $attachmentAssetsFileSyncs[$attachmentAsset->id] = array(); $attachmentAssetIds[] = $attachmentAsset->id; } } if (count($attachmentAssetIds)) { try { $filter = new Kaltura_Client_FileSync_Type_FileSyncFilter(); $filter->fileObjectTypeEqual = Kaltura_Client_Enum_FileSyncObjectType::FLAVOR_ASSET; $filter->objectIdIn = implode(',', $attachmentAssetIds); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 100; $fileSyncList = $fileSyncPlugin->fileSync->listAction($filter, $pager); $fileSyncs = $fileSyncList->objects; foreach ($fileSyncs as $fileSync) { $attachmentAssetsFileSyncs[$fileSync->objectId][] = $fileSync; } } catch (Exception $e) { $errDescription = $e->getMessage(); } } return array('attachmentAssets' => $attachmentAssets, 'attachmentAssetsFileSyncs' => $attachmentAssetsFileSyncs, 'errDescription' => $errDescription); }
public function getDataArray($entryId, $partnerId) { $client = Infra_ClientHelper::getClient(); $contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($client); $fileSyncPlugin = Kaltura_Client_FileSync_Plugin::get($client); if (!$client) { $errors[] = 'init client failed'; return; } $filter = new Kaltura_Client_ContentDistribution_Type_EntryDistributionFilter(); $filter->entryIdEqual = $entryId; $distributions = array(); $distributionFileSyncs = array(); $errDescription = null; try { Infra_ClientHelper::impersonate($partnerId); $entryDistributionList = $contentDistributionPlugin->entryDistribution->listAction($filter); Infra_ClientHelper::unimpersonate(); $distributions = $entryDistributionList->objects; } catch (Exception $e) { $errDescription = $e->getMessage(); } $distributionIds = array(); if (is_array($distributions)) { foreach ($distributions as $distribution) { $distributionFileSyncs[$distribution->id] = array(); $distributionIds[] = $distribution->id; } } if (count($distributionIds)) { try { $filter = new Kaltura_Client_FileSync_Type_FileSyncFilter(); $filter->fileObjectTypeEqual = Kaltura_Client_Enum_FileSyncObjectType::ENTRY_DISTRIBUTION; $filter->objectIdIn = implode(',', $distributionIds); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 100; $fileSyncList = $fileSyncPlugin->fileSync->listAction($filter, $pager); $fileSyncs = $fileSyncList->objects; foreach ($fileSyncs as $fileSync) { $distributionFileSyncs[$fileSync->objectId][] = $fileSync; } } catch (Exception $e) { $errDescription = $e->getMessage(); } } return array('distributions' => $distributions, 'distributionFileSyncs' => $distributionFileSyncs, 'errDescription' => $errDescription); }
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); $partnerId = $this->_getParam('partner_id'); if ($partnerId) { Infra_ClientHelper::impersonate($partnerId); } 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); } }
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); }
private function processForm(Form_DrmProfileConfigure $form, $formData, $partnerId, $drmProfileId = null) { if ($form->isValid($formData)) { $client = Infra_ClientHelper::getClient(); $drmPluginClient = Kaltura_Client_Drm_Plugin::get($client); $drmProfile = $form->getObject("Kaltura_Client_Drm_Type_DrmProfile", $formData, false, true); unset($drmProfile->id); Infra_ClientHelper::impersonate($partnerId); if (is_null($drmProfileId)) { $drmProfile->status = Kaltura_Client_Drm_Enum_DrmProfileStatus::ACTIVE; $responseDrmProfile = $drmPluginClient->drmProfile->add($drmProfile); } else { $responseDrmProfile = $drmPluginClient->drmProfile->update($drmProfileId, $drmProfile); } Infra_ClientHelper::unimpersonate(); $form->setAttrib('class', 'valid'); return true; } else { $form->populate($formData); return false; } }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('viewRenderer')->setNoRender(); $serverId = $this->_getParam('server_id'); $client = Infra_ClientHelper::getClient(); $businessProcessNotificationPlugin = Kaltura_Client_BusinessProcessNotification_Plugin::get($client); $partnerId = $this->_getParam('partner_id'); if ($partnerId) { Infra_ClientHelper::impersonate($partnerId); } try { $server = $businessProcessNotificationPlugin->businessProcessServer->get($serverId); /* @var $server Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessServer */ $businessProcessProvider = kBusinessProcessProvider::get($server); $processes = $businessProcessProvider->listBusinessProcesses(); asort($processes); } catch (Exception $e) { KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString()); echo $action->getHelper('json')->sendJson($e->getMessage(), false); } echo $action->getHelper('json')->sendJson($processes, false); }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('layout')->disableLayout(); $this->client = Infra_ClientHelper::getClient(); $contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($this->client); $request = $action->getRequest(); $profileId = $this->_getParam('profile_id'); $providerType = null; $partnerId = null; $distributionProfile = null; $action->view->errMessage = null; $action->view->form = ''; try { if ($profileId) { $distributionProfile = $contentDistributionPlugin->distributionProfile->get($profileId); $providerType = $distributionProfile->providerType; $partnerId = $distributionProfile->partnerId; } else { $providerType = $this->_getParam('provider_type'); $partnerId = $this->_getParam('partner_id'); } $form = null; $profileClass = 'Kaltura_Client_ContentDistribution_Type_DistributionProfile'; if ($providerType == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::GENERIC) { $form = new Form_GenericProviderProfileConfiguration($partnerId, $providerType, $distributionProfile); $profileClass = 'Kaltura_Client_ContentDistribution_Type_GenericDistributionProfile'; } elseif ($providerType == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::SYNDICATION) { $form = new Form_SyndicationProviderProfileConfiguration($partnerId, $providerType, $distributionProfile); $profileClass = 'Kaltura_Client_ContentDistribution_Type_SyndicationDistributionProfile'; } else { $form = KalturaPluginManager::loadObject('Form_ProviderProfileConfiguration', $providerType, array($partnerId, $providerType, $distributionProfile)); $profileClass = KalturaPluginManager::getObjectClass($profileClass, $providerType); } KalturaLog::debug("profile class [{$profileClass}]"); if (!$form) { $action->view->errMessage = "Profile form not found for provider [{$providerType}]"; return; } $form->setAction($action->view->url(array('controller' => 'plugin', 'action' => 'DistributionProfileConfigureAction'))); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 100; Infra_ClientHelper::impersonate($partnerId); $flavorParamsResponse = $this->client->flavorParams->listAction(null, $pager); Infra_ClientHelper::unimpersonate(); if ($profileId) { if ($request->isPost()) { if ($form->isValid($request->getPost())) { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); $form->resetUnUpdatebleAttributes($distributionProfile); Infra_ClientHelper::impersonate($partnerId); $distributionProfile = $contentDistributionPlugin->distributionProfile->update($profileId, $distributionProfile); $form->saveProviderAdditionalObjects($distributionProfile); Infra_ClientHelper::unimpersonate(); $form->setAttrib('class', 'valid'); $action->view->formValid = true; } else { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); $this->populateForm($form, $distributionProfile, $flavorParamsResponse); } } else { $form->populateFromObject($distributionProfile); $this->populateForm($form, $distributionProfile, $flavorParamsResponse); } } else { if ($request->isPost() && $form->isValid($request->getPost())) { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); if (!$distributionProfile->partnerId) { $distributionProfile->partnerId = 0; } Infra_ClientHelper::impersonate($distributionProfile->partnerId); $distributionProfile->partnerId = null; $distributionProfile = $contentDistributionPlugin->distributionProfile->add($distributionProfile); $form->saveProviderAdditionalObjects($distributionProfile); Infra_ClientHelper::unimpersonate(); $form->setAttrib('class', 'valid'); $action->view->formValid = true; } else { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); $this->populateForm($form, $distributionProfile, $flavorParamsResponse); } } } catch (Exception $e) { KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString()); $action->view->errMessage = $e->getMessage(); $form->populate($request->getPost()); if (isset($flavorParamsResponse)) { $distributionProfile = $form->getObject($profileClass, $request->getPost()); $this->populateForm($form, $distributionProfile, $flavorParamsResponse); } Infra_ClientHelper::unimpersonate(); } $action->view->form = $form; }
public function addMetadataFieldsAsValues($elementName) { $this->getElement($elementName)->clearMultiOptions(); Infra_ClientHelper::impersonate($this->partnerId); $client = Infra_ClientHelper::getClient(); $metadataPlugin = Kaltura_Client_Metadata_Plugin::get($client); $profileListResponse = $metadataPlugin->metadataProfile->listAction(); $metadataFields = array(); foreach ($profileListResponse->objects as $profile) { $doc = new DOMDocument(); $doc->loadXML($profile->xsd); $xpath = new DOMXPath($doc); $xpath->registerNamespace('xsd', 'http://www.w3.org/2001/XMLSchema'); $nameNodes = $xpath->query('//xsd:element//xsd:element/@name'); foreach ($nameNodes as $nameNode) { $metadataFields[$profile->id . ':' . $nameNode->nodeValue] = $profile->name . ' > ' . $nameNode->nodeValue; } } Infra_ClientHelper::unimpersonate(); $this->getElement($elementName)->addMultiOptions(array('' => '')); $this->getElement($elementName)->addMultiOptions($metadataFields); }
public function configureStorageAction() { $this->_helper->layout->disableLayout(); $storageId = $this->_getParam('storageId'); $editMode = false; if ($storageId) { $editMode = true; } $client = Infra_ClientHelper::getClient(); $form = new Form_Partner_StorageConfiguration(); $request = $this->getRequest(); $form->populate($request->getParams()); Form_Partner_StorageHelper::addProtocolsToForm($form); Form_Partner_StorageHelper::addPathManagersToForm($form); Form_Partner_StorageHelper::addUrlManagersToForm($form); Form_Partner_StorageHelper::addTriggersToForm($form); $request = $this->getRequest(); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 500; if (!$editMode) { $flavorParamsResponse = $client->flavorParams->listAction(null, $pager); $form->addFlavorParamsFields($flavorParamsResponse); $form->getElement('partnerId')->setAttrib('readonly', true); $form->getElement('partnerId')->setValue($request->getParam('new_partner_id')); } else { $storage = $client->storageProfile->get($storageId); Infra_ClientHelper::impersonate($storage->partnerId); $flavorParamsResponse = $client->flavorParams->listAction(null, $pager); Infra_ClientHelper::unimpersonate(); $flavorParamsIds = array(); if ($storage->flavorParamsIds) { $flavorParamsIds = explode(',', $storage->flavorParamsIds); } $form->getElement('partnerId')->setAttrib('readonly', true); $form->addFlavorParamsFields($flavorParamsResponse, $flavorParamsIds); if (!$request->isPost()) { $form->populateFromObject($storage, false); } } if ($request->isPost()) { $request = $this->getRequest(); $formData = $request->getPost(); if ($form->isValid($formData)) { $this->view->formValid = true; KalturaLog::log('Request: ' . print_r($request->getPost(), true)); $form->populate($request->getPost()); $storage = $form->getObject("Kaltura_Client_Type_StorageProfile", $request->getPost(), false, true); $flavorParams = array(); foreach ($flavorParamsResponse->objects as $flavorParamsItem) { if ($this->_getParam('flavorParamsId_' . $flavorParamsItem->id, false)) { $flavorParams[] = $flavorParamsItem->id; } } if (count($flavorParams)) { $storage->flavorParamsIds = implode(',', $flavorParams); } else { $storage->flavorParamsIds = ''; } KalturaLog::log('Storage: ' . print_r($storage, true)); Infra_ClientHelper::impersonate($storage->partnerId); $storage->partnerId = null; if (!$editMode) { $client->storageProfile->add($storage); } else { $client->storageProfile->update($storageId, $storage); } } else { $this->view->formValid = false; $form->populate($formData); } } $this->view->form = $form; }
public function updateDeliveryProfileStatusAction() { $request = $this->getRequest(); $status = $request->getParam('status'); $partnerId = $request->getParam('partnerId'); $deliveryProfileId = $request->getParam('deliveryProfileId'); $client = Infra_ClientHelper::getClient(); $deliveryProfileService = new Kaltura_Client_DeliveryProfileService($client); Infra_ClientHelper::impersonate($partnerId); $deliveryProfile = new Kaltura_Client_Type_DeliveryProfile(); $deliveryProfile->status = $status; $deliveryProfileService->update($deliveryProfileId, $deliveryProfile); Infra_ClientHelper::unimpersonate(); echo $this->_helper->json('ok', false); }
protected function addMetadataProfile($enableNone = false) { $metadataProfiles = null; try { $metadataProfileFilter = new Kaltura_Client_Metadata_Type_MetadataProfileFilter(); $metadataProfileFilter->metadataObjectTypeEqual = Kaltura_Client_Metadata_Enum_MetadataObjectType::ENTRY; $client = Infra_ClientHelper::getClient(); $metadataPlugin = Kaltura_Client_Metadata_Plugin::get($client); Infra_ClientHelper::impersonate($this->partnerId); $metadataProfileList = $metadataPlugin->metadataProfile->listAction($metadataProfileFilter); Infra_ClientHelper::unimpersonate(); $metadataProfiles = $metadataProfileList->objects; } catch (Kaltura_Client_Exception $e) { $metadataProfiles = null; } if (count($metadataProfiles)) { $this->addElement('select', 'metadata_profile_id', array('label' => 'Metadata Profile ID:', 'filters' => array('StringTrim'))); $element = $this->getElement('metadata_profile_id'); if ($enableNone) { $element->addMultiOption('', 'None'); } foreach ($metadataProfiles as $metadataProfile) { $element->addMultiOption($metadataProfile->id, $metadataProfile->name); } } else { $this->addElement('hidden', 'metadata_profile_id', array('value' => 0)); } }
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); } } }
protected function addConversionProfiles() { $conversionProfiles = null; if (!is_null($this->newPartnerId)) { try { $conversionProfileFilter = new Kaltura_Client_Type_ConversionProfileFilter(); $client = Infra_ClientHelper::getClient(); Infra_ClientHelper::impersonate($this->newPartnerId); $conversionProfileList = $client->conversionProfile->listAction($conversionProfileFilter); Infra_ClientHelper::unimpersonate(); $conversionProfiles = $conversionProfileList->objects; } catch (Kaltura_Client_Exception $e) { $conversionProfiles = null; } } if (!is_null($conversionProfiles) && count($conversionProfiles)) { $this->addElement('select', 'conversionProfileId', array('label' => 'Conversion Profile ID:', 'required' => false, 'filters' => array('StringTrim'))); $element = $this->getElement('conversionProfileId'); foreach ($conversionProfiles as $conversionProfile) { $element->addMultiOption($conversionProfile->id, $conversionProfile->id . ' - ' . $conversionProfile->name); } } else { $this->addElement('text', 'conversionProfileId', array('label' => 'Conversion Profile ID:', 'required' => false, 'filters' => array('StringTrim'))); } }
public function configureStorageAction() { $this->_helper->layout->disableLayout(); $partnerId = $this->_getParam('partnerId'); $storageId = $this->_getParam('storageId'); $type = $this->_getParam('type'); $editMode = false; $client = Infra_ClientHelper::getClient(); $storage = null; if ($storageId) { Infra_ClientHelper::impersonate($partnerId); try { $storage = $client->storageProfile->get($storageId); } catch (Exception $e) { Infra_ClientHelper::unimpersonate(); throw $e; } Infra_ClientHelper::unimpersonate(); $type = $storage->protocol; } $form = KalturaPluginManager::loadObject('Form_Partner_BaseStorageConfiguration', $type, array($partnerId, $type)); /* @var $form Form_StorageConfiguration */ KalturaLog::debug("form class: " . get_class($form)); if (!$form || !$form instanceof Form_Partner_BaseStorageConfiguration) { if ($type == Kaltura_Client_Enum_StorageProfileProtocol::LOCAL) { $form = new Form_Partner_LocalStorageConfiguration(); } else { $form = new Form_Partner_StorageConfiguration(); } } //$form->setAction($action->view->url(array('controller' => 'partner', 'action' => 'configureStorageAction'))); $request = $this->getRequest(); $form->populate($request->getParams()); $request = $this->getRequest(); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 500; if (!$storageId) { $partnerId = $request->getParam('new_partner_id'); $form->getElement('partnerId')->setAttrib('readonly', true); $form->getElement('partnerId')->setValue($partnerId); Infra_ClientHelper::impersonate($partnerId); $flavorParamsResponse = $client->flavorParams->listAction(null, $pager); Infra_ClientHelper::unimpersonate(); $form->addFlavorParamsFields($flavorParamsResponse); } else { $flavorParamsResponse = null; Infra_ClientHelper::impersonate($partnerId); try { $flavorParamsResponse = $client->flavorParams->listAction(null, $pager); } catch (Exception $e) { Infra_ClientHelper::unimpersonate(); throw $e; } Infra_ClientHelper::unimpersonate(); $flavorParamsIds = array(); if ($storage->flavorParamsIds) { $flavorParamsIds = explode(',', $storage->flavorParamsIds); } $form->getElement('partnerId')->setAttrib('readonly', true); $form->addFlavorParamsFields($flavorParamsResponse, $flavorParamsIds); if (!$request->isPost()) { $form->populateFromObject($storage, false); } } if ($request->isPost()) { $request = $this->getRequest(); $formData = $request->getPost(); if ($form->isValid($formData)) { $this->view->formValid = true; $form->populate($formData); $storageProfileClass = KalturaPluginManager::getObjectClass('Kaltura_Client_Type_StorageProfile', $type); if (!$storageProfileClass) { if ($type == Kaltura_Client_Enum_StorageProfileProtocol::S3) { $storageProfileClass = 'Kaltura_Client_Type_AmazonS3StorageProfile'; } else { $storageProfileClass = 'Kaltura_Client_Type_StorageProfile'; } } $storageFromForm = $form->getObject($storageProfileClass, $formData, false, true); $flavorParams = array(); foreach ($flavorParamsResponse->objects as $flavorParamsItem) { if ($this->_getParam('flavorParamsId_' . $flavorParamsItem->id, false)) { $flavorParams[] = $flavorParamsItem->id; } } if (count($flavorParams)) { $storageFromForm->flavorParamsIds = implode(',', $flavorParams); } else { $storageFromForm->flavorParamsIds = ''; } if (!$editMode) { $storageFromForm->protocol = $type; } KalturaLog::log('Storage: ' . print_r($storageFromForm, true)); Infra_ClientHelper::impersonate($storageFromForm->partnerId); $storageFromForm->partnerId = null; if (!$storageId) { $client->storageProfile->add($storageFromForm); } else { $client->storageProfile->update($storageId, $storageFromForm); } } else { $this->view->formValid = false; $form->populate($formData); } } KalturaLog::debug("storage protocol: {$type}"); $this->view->form = $form; $this->view->protocol = $type; }
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; }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('layout')->disableLayout(); $providerId = $this->_getParam('provider_id'); $this->client = Infra_ClientHelper::getClient(); $contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($this->client); $form = new Form_GenericProviderConfiguration(); $form->setAction($action->view->url(array('controller' => 'plugin', 'action' => 'GenericDistributionProviderConfigureAction'))); $request = $action->getRequest(); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 100; $flavorParamsResponse = $this->client->flavorParams->listAction(null, $pager); $action->view->errMessage = null; $action->view->form = ''; try { if ($providerId) { if ($request->isPost()) { $form->isValid($request->getPost()); $form->populate($request->getPost()); $genericDistributionProvider = $form->getObject("Kaltura_Client_ContentDistribution_Type_GenericDistributionProvider", $request->getPost()); $genericDistributionProvider->partnerId = null; $contentDistributionPlugin->genericDistributionProvider->update($providerId, $genericDistributionProvider); $this->saveProviderActions($providerId, $form); } else { $genericDistributionProvider = $contentDistributionPlugin->genericDistributionProvider->get($providerId); $form->populateFromObject($genericDistributionProvider); $optionalFlavorParamsIds = array(); $requiredFlavorParamsIds = array(); if (!is_null($genericDistributionProvider->optionalFlavorParamsIds) && strlen($genericDistributionProvider->optionalFlavorParamsIds)) { $optionalFlavorParamsIds = explode(',', $genericDistributionProvider->optionalFlavorParamsIds); } if (!is_null($genericDistributionProvider->requiredFlavorParamsIds) && strlen($genericDistributionProvider->requiredFlavorParamsIds)) { $requiredFlavorParamsIds = explode(',', $genericDistributionProvider->requiredFlavorParamsIds); } $form->addFlavorParamsFields($flavorParamsResponse, $optionalFlavorParamsIds, $requiredFlavorParamsIds); if (is_array($genericDistributionProvider->requiredThumbDimensions)) { foreach ($genericDistributionProvider->requiredThumbDimensions as $dimensions) { $form->addThumbDimensions($dimensions, true); } } if (is_array($genericDistributionProvider->optionalThumbDimensions)) { foreach ($genericDistributionProvider->optionalThumbDimensions as $dimensions) { $form->addThumbDimensions($dimensions, false); } } $form->addThumbDimensionsForm(); $form->addProviderActions(); $form->populateActions($genericDistributionProvider); $action->view->form = $form; } } else { if ($request->isPost()) { $form->isValid($request->getPost()); $form->populate($request->getPost()); $genericDistributionProvider = $form->getObject("Kaltura_Client_ContentDistribution_Type_GenericDistributionProvider", $request->getPost()); if (!$genericDistributionProvider->partnerId) { $genericDistributionProvider->partnerId = 0; } Infra_ClientHelper::impersonate($genericDistributionProvider->partnerId); $genericDistributionProvider->partnerId = null; $genericDistributionProvider = $contentDistributionPlugin->genericDistributionProvider->add($genericDistributionProvider); $this->saveProviderActions($genericDistributionProvider->id, $form); Infra_ClientHelper::unimpersonate(); } else { $form->addFlavorParamsFields($flavorParamsResponse); $form->addThumbDimensionsForm(); $form->addProviderActions(); $action->view->form = $form; } } } catch (Exception $e) { KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString()); $action->view->errMessage = $e->getMessage(); } }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('layout')->disableLayout(); $profileId = $this->_getParam('profileId'); $editMode = false; if ($profileId != null) { $editMode = true; } $client = Infra_ClientHelper::getClient(); $virusScanPlugin = Kaltura_Client_VirusScan_Plugin::get($client); $form = new Form_Partner_VirusScanConfiguration(); $action->view->formValid = false; $request = $action->getRequest(); if ($request->isPost()) { $formData = $request->getPost(); if ($form->isValid($formData)) { $profile = $form->getObject("Kaltura_Client_VirusScan_Type_VirusScanProfile", $request->getPost(), false, true); $entryFilter = new Kaltura_Client_Type_BaseEntryFilter(); $entryTypeArray = $request->getPost('entryTypeToFilter'); if (is_array($entryTypeArray)) { $entryFilter->typeIn = implode(',', $entryTypeArray); } $profile->entryFilter = $entryFilter; unset($profile->entryTypeToFilter); //update profile try { if ($editMode) { $virusScanPlugin->virusScanProfile->update($profileId, $profile); } else { Infra_ClientHelper::impersonate($profile->partnerId); unset($profile->partnerId); $virusScanPlugin->virusScanProfile->add($profile); Infra_ClientHelper::unimpersonate(); } $action->view->formValid = true; } catch (Exception $ex) { $action->view->formValid = false; $action->view->errMessage = $ex->getMessage(); } } else { $form->populate($formData); $form->getElement('partnerId')->setValue($this->_getParam('new_partner_id')); } } else { $partnerId = $request->getParam('new_partner_id'); if ($editMode || $partnerId) { //disable field if $editMode, so partnerId won't change $form->getElement('partnerId')->setAttrib('readonly', true); $form->getElement('partnerId')->setAttrib('class', 'readonly'); $form->getElement('partnerId')->setValue($request->getParam('new_partner_id')); if ($profileId != null) { $profile = $virusScanPlugin->virusScanProfile->get($profileId); $form->populateFromObject($profile, false); //setting multicheck drop down list values $typesArr = array(); if (!empty($profile->entryFilter->typeEqual)) { $typesArr[] = $profile->entryFilter->typeEqual; } else { if (!empty($profile->entryFilter->typeIn)) { $typesArr = array_map('trim', explode(',', $profile->entryFilter->typeIn)); } } $form->getElement('entryTypeToFilter')->setValue($typesArr); } } } $action->view->form = $form; }
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); } } }