/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $typeField = self::translateFieldName(DrmKeyPeer::PROVIDER, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $drmKeyType = $row[$typeField]; $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $drmKeyType); if ($extendedCls) { return $extendedCls; } } return parent::OM_CLASS; }
/** * Returns the matching delivery profile class by the delivery profile type. * @param DeliveryProfileType $deliveryType * @return string representing the delivery object class */ public static function getClassByDeliveryProfileType($deliveryType) { if (isset(self::$class_types_cache[$deliveryType])) { return self::$class_types_cache[$deliveryType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $deliveryType); if ($extendedCls) { self::$class_types_cache[$deliveryType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$deliveryType] = parent::OM_CLASS; return parent::OM_CLASS; }
public static function getOMClass($row, $colnum) { if ($row) { $typeField = self::translateFieldName(BusinessProcessServerPeer::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $type = $row[$typeField]; if (isset(self::$class_types_cache[$type])) { return self::$class_types_cache[$type]; } $extendedCls = KalturaPluginManager::getObjectClass('BusinessProcessServer', $type); if ($extendedCls) { self::$class_types_cache[$type] = $extendedCls; return $extendedCls; } } return null; }
public static function getOMClass($row, $colnum) { if ($row) { $colnum += self::translateFieldName(self::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $assetType = $row[$colnum]; if (isset(self::$class_types_cache[$assetType])) { return self::$class_types_cache[$assetType]; } $extendedCls = KalturaPluginManager::getObjectClass(self::OM_CLASS, $assetType); if ($extendedCls) { self::$class_types_cache[$assetType] = $extendedCls; return $extendedCls; } } throw new Exception("Can't instantiate un-typed cue point [" . print_r($row, true) . "]"); }
public static function getOMClass($row, $colnum) { $serverNodeType = null; if ($row) { $typeField = self::translateFieldName(self::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $serverNodeType = $row[$typeField]; if (isset(self::$class_types_cache[$serverNodeType])) { return self::$class_types_cache[$serverNodeType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $serverNodeType); if ($extendedCls) { self::$class_types_cache[$serverNodeType] = $extendedCls; return $extendedCls; } } throw new Exception("Can't instantiate un-typed [{$serverNodeType}] remoteServer [" . print_r($row, true) . "]"); }
/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $protocolField = self::translateFieldName(StorageProfilePeer::PROTOCOL, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $storageProfileProtocol = $row[$protocolField]; if (isset(self::$class_types_cache[$storageProfileProtocol])) { return self::$class_types_cache[$storageProfileProtocol]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $storageProfileProtocol); if ($extendedCls) { self::$class_types_cache[$storageProfileProtocol] = $extendedCls; return $extendedCls; } self::$class_types_cache[$storageProfileProtocol] = parent::OM_CLASS; } return parent::OM_CLASS; }
private static function getOMClassImpl($row, $colnum) { if ($row) { $assetType = $row[$colnum + 4]; // provider type column if (isset(self::$class_types_cache[$assetType])) { return self::$class_types_cache[$assetType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $assetType); if ($extendedCls) { self::$class_types_cache[$assetType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$assetType] = GenericDistributionProfilePeer::OM_CLASS; } return GenericDistributionProfilePeer::OM_CLASS; }
public static function getOMClass($row, $colnum) { $type = null; if ($row) { $typeField = self::translateFieldName(EventNotificationTemplatePeer::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $type = $row[$typeField]; if (isset(self::$class_types_cache[$type])) { return self::$class_types_cache[$type]; } $extendedCls = KalturaPluginManager::getObjectClass('EventNotificationTemplate', $type); if ($extendedCls) { self::$class_types_cache[$type] = $extendedCls; return $extendedCls; } } throw new kCoreException("Event notification template type [{$type}] not found", kCoreException::OBJECT_TYPE_NOT_FOUND, $type); }
/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $assetType = $row[$colnum + 21]; // type column if (isset(self::$class_types_cache[$assetType])) { return self::$class_types_cache[$assetType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $assetType); if ($extendedCls) { self::$class_types_cache[$assetType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$assetType] = parent::OM_CLASS; } return parent::OM_CLASS; }
public static function getOMClass($row, $colnum) { if ($row) { $colnum += self::translateFieldName(self::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $assetType = $row[$colnum]; if (isset(self::$class_types_cache[$assetType])) { return self::$class_types_cache[$assetType]; } $extendedCls = KalturaPluginManager::getObjectClass(self::OM_CLASS, $assetType); if ($extendedCls) { self::$class_types_cache[$assetType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$assetType] = self::OM_CLASS; } return self::OM_CLASS; }
public function toObject($objectToFill = null, $propsToSkip = array()) { if (is_null($objectToFill)) { $objectToFill = new kEventNotificationScope(); } /** @var kEventNotificationScope $objectToFill */ $objectToFill = parent::toObject($objectToFill); $objectClassName = KalturaPluginManager::getObjectClass('EventNotificationEventObjectType', kPluginableEnumsManager::apiToCore('EventNotificationEventObjectType', $this->scopeObjectType)); $peerClass = $objectClassName . 'Peer'; $objectId = $this->objectId; if (class_exists($peerClass)) { $objectToFill->setObject($peerClass::retrieveByPk($objectId)); } else { $b = new $objectClassName(); $peer = $b->getPeer(); $object = $peer::retrieveByPK($objectId); $objectToFill->setObject($object); } if (is_null($objectToFill->getObject())) { throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $this->objectId); } return $objectToFill; }
/** * @param KalturaMetadataObjectType $objectType * * @return string */ public static function getObjectTypeName($objectType) { if (isset(self::$objectTypeNames[$objectType])) { return self::$objectTypeNames[$objectType]; } return KalturaPluginManager::getObjectClass('IMetadataObject', $objectType); }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('layout')->disableLayout(); $this->client = Kaltura_ClientHelper::getClient(); $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 = $this->client->distributionProfile->get($profileId); $providerType = $distributionProfile->providerType; $partnerId = $distributionProfile->partnerId; } else { $providerType = $this->_getParam('provider_type'); $partnerId = $this->_getParam('partner_id'); } $form = null; $profileClass = 'KalturaDistributionProfile'; if ($providerType == KalturaDistributionProviderType::GENERIC) { $form = new Form_GenericProviderProfileConfiguration($partnerId, $providerType); $profileClass = 'KalturaGenericDistributionProfile'; } elseif ($providerType == KalturaDistributionProviderType::SYNDICATION) { $form = new Form_SyndicationProviderProfileConfiguration($partnerId, $providerType); $profileClass = 'KalturaSyndicationDistributionProfile'; } else { $form = KalturaPluginManager::loadObject('Form_ProviderProfileConfiguration', $providerType, array($partnerId, $providerType)); $profileClass = KalturaPluginManager::getObjectClass('KalturaDistributionProfile', $providerType); } 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 KalturaFilterPager(); $pager->pageSize = 100; $flavorParamsResponse = $this->client->flavorParams->listAction(null, $pager); if ($profileId) { if ($request->isPost()) { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); $form->resetUnUpdatebleAttributes($distributionProfile); $distributionProfile = $this->client->distributionProfile->update($profileId, $distributionProfile); $form->saveProviderAdditionalObjects($distributionProfile); $form->setAttrib('class', 'valid'); } else { $form->populateFromObject($distributionProfile); $optionalFlavorParamsIds = array(); $requiredFlavorParamsIds = array(); if (!is_null($distributionProfile->optionalFlavorParamsIds) && strlen($distributionProfile->optionalFlavorParamsIds)) { $optionalFlavorParamsIds = explode(',', $distributionProfile->optionalFlavorParamsIds); } if (!is_null($distributionProfile->requiredFlavorParamsIds) && strlen($distributionProfile->requiredFlavorParamsIds)) { $requiredFlavorParamsIds = explode(',', $distributionProfile->requiredFlavorParamsIds); } $form->addFlavorParamsFields($flavorParamsResponse, $optionalFlavorParamsIds, $requiredFlavorParamsIds); foreach ($distributionProfile->requiredThumbDimensions as $dimensions) { $form->addThumbDimensions($dimensions, true); } foreach ($distributionProfile->optionalThumbDimensions as $dimensions) { $form->addThumbDimensions($dimensions, false); } $form->addThumbDimensionsForm(); } $action->view->form = $form; } else { if ($request->isPost()) { $form->populate($request->getPost()); $distributionProfile = $form->getObject($profileClass, $request->getPost()); if (!$distributionProfile->partnerId) { $distributionProfile->partnerId = 0; } Kaltura_ClientHelper::impersonate($distributionProfile->partnerId); $distributionProfile->partnerId = null; $distributionProfile = $this->client->distributionProfile->add($distributionProfile); Kaltura_ClientHelper::unimpersonate(); $form->saveProviderAdditionalObjects($distributionProfile); $form->setAttrib('class', 'valid'); } else { $form->addFlavorParamsFields($flavorParamsResponse); $form->addThumbDimensionsForm(); } $action->view->form = $form; } } catch (Exception $e) { KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString()); $action->view->errMessage = $e->getMessage(); } }
/** * Function sweeps the given fields of the emailNotificationTemplate, and parses expressions of the type * {metadata:[metadataProfileSystemName]:[metadataProfileFieldSystemName]} */ public static function editTemplateFields($sweepFieldValues, $scope, $objectType) { KalturaLog::debug('Field values to sweep: ' . print_r($sweepFieldValues, true)); if (!$scope instanceof kEventScope) { return array(); } if (!method_exists($scope->getObject(), 'getPartnerId')) { return array(); } $partnerId = $scope->getObject()->getPartnerId(); /* @var $scope kEventScope */ $metadataContentParameters = array(); foreach ($sweepFieldValues as $sweepFieldValue) { //Obtain matches for the set structure {metadata:[profileSystemName][profileFieldSystemName]} preg_match_all(self::METADATA_EMAIL_NOTIFICATION_REGEX, $sweepFieldValue, $matches); foreach ($matches[0] as $match) { $match = str_replace(array('{', '}'), array('', ''), $match); list($metadata, $profileSystemName, $fieldSystemName, $format) = explode(':', $match, 4); $profile = MetadataProfilePeer::retrieveBySystemName($profileSystemName, $partnerId); if (!$profile) { KalturaLog::info("Metadata profile with system name {$profileSystemName} not found for this partner. Token will be replaced with empty string."); $metadataContentParameters[$match] = ''; continue; } $objectId = null; $metadataObjectId = null; //If the metadataProfileobjectType matches the one on the emailNotification, we can proceed //If the objectType of the email template is 'asset' we can use the entryId //If the objectType of the email template is a metadata object we can use its id if (kMetadataManager::getObjectTypeName($profile->getObjectType()) == KalturaPluginManager::getObjectClass('EventNotificationEventObjectType', $objectType)) { $objectId = $scope->getObject()->getId(); } elseif (kMetadataManager::getObjectTypeName($profile->getObjectType()) == 'entry' && $scope->getObject() instanceof asset) { $objectId = $scope->getObject()->getEntryId(); } elseif ($scope->getObject() instanceof categoryEntry) { $profileObject = kMetadataManager::getObjectTypeName($profile->getObjectType()); $getter = "get{$profileObject}Id"; KalturaLog::info("Using {$getter} in order to retrieve the metadata object ID"); $categoryEntry = $scope->getObject(); $objectId = $categoryEntry->{$getter}(); } elseif (KalturaPluginManager::getObjectClass('EventNotificationEventObjectType', $objectType) == MetadataPeer::OM_CLASS) { $metadataObjectId = $scope->getObject()->getId(); } if ($objectId) { $result = MetadataPeer::retrieveByObject($profile->getId(), $profile->getObjectType(), $objectId); } elseif ($metadataObjectId) { $result = MetadataPeer::retrieveByPK($metadataObjectId); } else { //There is not enough specification regarding the required metadataObject, abort. KalturaLog::info("The template does not contain an object Id for which custom metadata can be retrieved. Token will be replaced with empty string."); $metadataContentParameters[$match] = ''; continue; } if (!$result) { KalturaLog::info("Metadata object could not be retrieved. Token will be replaced with empty string."); $metadataContentParameters[$match] = ''; continue; } $strvals = kMetadataManager::getMetadataValueForField($result, $fieldSystemName); foreach ($strvals as &$strval) { if ($format && is_numeric($strval)) { $strval = date($format, $strval); } } $metadataContentParameters[$match] = implode(',', $strvals); } } return $metadataContentParameters; }
public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false) { if (isset($properties[self::EXTENSION_SUBFORM_NAME])) { $properties = array_merge($properties[self::EXTENSION_SUBFORM_NAME], $properties); } $objectType = KalturaPluginManager::getObjectClass($objectType, $properties['type']); $object = parent::getObject($objectType, $properties, $add_underscore, $include_empty_fields); if ($object->fileHandlerType === Kaltura_Client_DropFolder_Enum_DropFolderFileHandlerType::CONTENT) { $object->fileHandlerConfig = $this->getSubForm('contentHandlerConfig')->getObject('Kaltura_Client_DropFolder_Type_DropFolderContentFileHandlerConfig', $properties, $add_underscore, $include_empty_fields); } else { if ($object->fileHandlerType === Kaltura_Client_DropFolder_Enum_DropFolderFileHandlerType::XML) { $object->fileHandlerConfig = new Kaltura_Client_DropFolderXmlBulkUpload_Type_DropFolderXmlBulkUploadFileHandlerConfig(); } } $extendTypeSubForm = $this->getSubForm(self::EXTENSION_SUBFORM_NAME); if ($extendTypeSubForm) { $object = $extendTypeSubForm->getObject($object, $objectType, $properties, $add_underscore, $include_empty_fields); } return $object; }
/** * @param int $assetType enum from assetType * @return asset */ public static function getNewAsset($assetType) { $class = null; if (isset(self::$class_types_cache[$assetType])) { $class = self::$class_types_cache[$assetType]; } if (!$class) { $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $assetType); if ($extendedCls) { self::$class_types_cache[$assetType] = $extendedCls; $class = $extendedCls; } } if (!$class) { throw new kCoreException("Unable to instatiate asset of type [{$assetType}]", kCoreException::OBJECT_TYPE_NOT_FOUND); } return new $class(); }
/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $typeField = self::translateFieldName(BulkUploadResultPeer::OBJECT_TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $bulkUploadReultObjectType = $row[$typeField]; if (isset(self::$class_types_cache[$bulkUploadReultObjectType])) { return self::$class_types_cache[$bulkUploadReultObjectType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $bulkUploadReultObjectType); if ($extendedCls) { self::$class_types_cache[$bulkUploadReultObjectType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$bulkUploadReultObjectType] = parent::OM_CLASS; } return parent::OM_CLASS; }
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 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; }
/** * @param int $eventType * @param string $eventObjectClassName core class name * @param int $partnerId * @return array<EventNotificationTemplate> */ public static function getNotificationTemplates($eventType, $eventObjectClassName, $partnerId) { if (is_null(self::$allNotificationTemplates)) { self::$allNotificationTemplates = EventNotificationTemplatePeer::retrieveByPartnerId($partnerId); KalturaLog::debug("Found [" . count(self::$allNotificationTemplates) . "] templates"); } $notificationTemplates = array(); foreach (self::$allNotificationTemplates as $notificationTemplate) { /* @var $notificationTemplate EventNotificationTemplate */ if (!$notificationTemplate->getAutomaticDispatchEnabled()) { continue; } if ($notificationTemplate->getEventType() != $eventType) { continue; } $templateObjectClassName = KalturaPluginManager::getObjectClass('EventNotificationEventObjectType', $notificationTemplate->getObjectType()); if (strcmp($eventObjectClassName, $templateObjectClassName) && !is_subclass_of($eventObjectClassName, $templateObjectClassName)) { continue; } $notificationTemplates[] = $notificationTemplate; } return $notificationTemplates; }
/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $entryType = $row[$colnum + 4]; // type if (isset(self::$class_types_cache[$entryType])) { return self::$class_types_cache[$entryType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $entryType); if ($extendedCls) { KalturaLog::debug("Found class[{$extendedCls}]"); self::$class_types_cache[$entryType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$entryType] = parent::OM_CLASS; } return parent::OM_CLASS; }
/** * @param KalturaBaseEntry $entry * @param entry $dbEntry * @return entry */ protected function prepareEntryForInsert(KalturaBaseEntry $entry, entry $dbEntry = null) { // create a default name if none was given if (!$entry->name) { $entry->name = $this->getPartnerId() . '_' . time(); } if ($entry->licenseType === null) { $entry->licenseType = KalturaLicenseType::UNKNOWN; } // first copy all the properties to the db entry, then we'll check for security stuff if (!$dbEntry) { $coreType = kPluginableEnumsManager::apiToCore('entryType', $entry->type); $class = KalturaPluginManager::getObjectClass(entryPeer::OM_CLASS, $coreType); if (!$class) { $class = entryPeer::OM_CLASS; } KalturaLog::debug("Creating new entry of API type [{$entry->type}] core type [{$coreType}] class [{$class}]"); $dbEntry = new $class(); } $dbEntry = $entry->toInsertableObject($dbEntry); // KalturaLog::debug("Inserted entry id [" . $dbEntry->getId() . "] data [" . print_r($dbEntry->toArray(), true) . "]"); $this->checkAndSetValidUserInsert($entry, $dbEntry); $this->checkAdminOnlyInsertProperties($entry); $this->validateAccessControlId($entry); $this->validateEntryScheduleDates($entry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setDefaultModerationStatus(); return $dbEntry; }
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(); $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); } } }
/** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param array $row PropelPDO result row. * @param int $colnum Column to examine for OM class information (first is 0). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass($row, $colnum) { if ($row) { $typeField = self::translateFieldName(entryPeer::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_NUM); $entryType = $row[$typeField]; if (isset(self::$class_types_cache[$entryType])) { return self::$class_types_cache[$entryType]; } $extendedCls = KalturaPluginManager::getObjectClass(parent::OM_CLASS, $entryType); if ($extendedCls) { KalturaLog::debug("Found class[{$extendedCls}]"); self::$class_types_cache[$entryType] = $extendedCls; return $extendedCls; } self::$class_types_cache[$entryType] = parent::OM_CLASS; } return parent::OM_CLASS; }