Пример #1
0
 private static function loadPackges()
 {
     if (is_null(self::$packages)) {
         $client = Infra_ClientHelper::getClient();
         $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
         self::$packages = $systemPartnerPlugin->systemPartner->getPackages();
     }
 }
Пример #2
0
 public function entryLifecycleAction()
 {
     $request = $this->getRequest();
     $this->view->errors = array();
     $this->view->entry = null;
     $this->view->partner = null;
     $action = $this->view->url(array('controller' => 'batch', 'action' => 'entry-lifecycle'), null, true);
     $this->view->searchEntryForm = new Form_Batch_SearchEntry();
     $this->view->searchEntryForm->populate($request->getParams());
     $this->view->searchEntryForm->setAction($action);
     $entryId = $request->getParam('entryId', false);
     if (!$entryId) {
         return;
     }
     $client = Infra_ClientHelper::getClient();
     $adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client);
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     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 = $adminConsolePlugin->entryAdmin->getByFlavorId($entryId);
         } catch (Exception $e) {
             $this->view->errors[] = 'Flavor asset not found: ' . $e->getMessage();
             return;
         }
         $entryId = $entry->id;
     } else {
         try {
             $entry = $adminConsolePlugin->entryAdmin->get($entryId);
         } catch (Exception $e) {
             $this->view->errors[] = 'Entry not found: ' . $e->getMessage();
             return;
         }
     }
     $this->view->entry = $entry;
     try {
         $this->view->partner = $systemPartnerPlugin->systemPartner->get($entry->partnerId);
     } catch (Exception $e) {
         $this->view->errors[] = 'Partner not found: ' . $e->getMessage();
     }
     $filter = new Infra_BatchJobFilter();
     $filter->entryIdEqual = $entryId;
     $paginatorAdapter = new Infra_FilterPaginator($client->jobs, "listBatchJobs", null, $filter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request, null, 20);
     $paginator->setAction($action);
     $this->view->paginator = $paginator;
 }
Пример #3
0
 public function exportCsvAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $request = $this->getRequest();
     $from = new Zend_Date($this->_getParam('from_date', $this->getDefaultFromDate()));
     $to = new Zend_Date($this->_getParam('to_date', $this->getDefaultToDate()));
     $client = Infra_ClientHelper::getClient();
     if ($client->getKs() == null) {
         $client->setKs(self::generateKs());
     }
     $form = new Form_PartnerUsageFilter();
     $form->populate($request->getParams());
     // init filters
     $partnerFilter = $this->getPartnerFilterFromForm($form);
     $usageFilter = new Kaltura_Client_SystemPartner_Type_SystemPartnerUsageFilter();
     $usageFilter->fromDate = $from->toString(Zend_Date::TIMESTAMP);
     $usageFilter->toDate = $to->toString(Zend_Date::TIMESTAMP);
     $pager = new Kaltura_Client_Type_FilterPager();
     $pager->pageIndex = 1;
     $pager->pageSize = 500;
     $items = array();
     while (true) {
         $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
         $response = $systemPartnerPlugin->systemPartner->getUsage($partnerFilter, $usageFilter, $pager);
         if (count($response->objects) <= 0) {
             break;
         }
         foreach ($response->objects as &$object) {
             $items[] = $object;
         }
         $pager->pageIndex++;
     }
     $format = $this->view->translate('csv date');
     $fileName = 'Usage report ' . $from->toString($format) . ' to ' . $to->toString($format) . '.csv';
     header('Content-type: text/csv');
     header('Content-Disposition: attachment; filename="' . $fileName . '"');
     // echo the csv header
     echo $this->view->translate('partner-usage table partnerStatus'), ',', $this->view->translate('partner-usage table partnerName'), ',', $this->view->translate('partner-usage table partnerId'), ',', $this->view->translate('partner-usage table partnerCreatedAt'), ',', $this->view->translate('partner-usage table partnerPackage'), ',', $this->view->translate('partner-usage table views'), ',', $this->view->translate('partner-usage table plays'), ',', $this->view->translate('partner-usage table entriesCount'), ',', $this->view->translate('partner-usage table totalEntriesCount'), ',', $this->view->translate('partner-usage table videoEntriesCount'), ',', $this->view->translate('partner-usage table imagesEntriesCount'), ',', $this->view->translate('partner-usage table audioEntriesCount'), ',', $this->view->translate('partner-usage table mixEntriesCount'), ',', $this->view->translate('partner-usage table bandwidth'), ',', $this->view->translate('partner-usage table storage'), ',', $this->view->translate('partner-usage table deletedStorage'), ',', $this->view->translate('partner-usage table peakStorage'), ',', $this->view->translate('partner-usage table averageStorage'), ',', $this->view->translate('partner-usage table combinedBandwidthStorage'), ',', $this->view->translate('partner-usage table transcodingUsage'), "\r\n";
     // echo the csv data
     foreach ($items as $item) {
         $d = new Zend_Date($item->partnerCreatedAt);
         echo $this->view->enumTranslate('KalturaPartnerStatus', $item->partnerStatus), ',', $item->partnerName, ',', $item->partnerId, ',', '"', $d->toString(Zend_Date::DATE_LONG), '",', $this->view->translate($this->view->packageNameById($item->partnerPackage)), ',', (int) $item->views, ',', (int) $item->plays, ',', (int) $item->entriesCount, ',', (int) $item->totalEntriesCount, ',', (int) $item->videoEntriesCount, ',', (int) $item->imageEntriesCount, ',', (int) $item->audioEntriesCount, ',', (int) $item->mixEntriesCount, ',', (int) $item->bandwidth, ',', (int) $item->storage, ',', (int) $item->deletedStorage, ',', (int) $item->peakStorage, ',', (int) $item->avgStorage, ',', (int) $item->combinedBandwidthStorage, ',', (int) $item->transcodingUsage, "\r\n";
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $form = new Form_NewFlavorParam();
     $action->view->form = $form;
     $request = $action->getRequest();
     if ($request->isPost()) {
         $params = $request->getParams();
         $client = Infra_ClientHelper::getClient();
         $fp = new Kaltura_Client_Type_FlavorParams();
         if ($form->isValid($params)) {
             $fp->name = $params['name'];
             $fp->systemName = $params['name'];
             $fp->isSystemDefault = Kaltura_Client_Enum_NullableBoolean::TRUE_VALUE;
             $fp->description = $params['description'];
             $fp->tags = $params['tags'];
             $fp->partnerId = $params['partner_id'];
             $fp->videoCodec = $params['video_codec'];
             $fp->audioCodec = $params['audio_codec'];
             $fp->format = $params['container_format'];
             $fp->videoBitrate = $params['video_bitrate'];
             $fp->audioBitrate = $params['audio_bitrate'];
             $fp->height = $params['video_height'];
             $fp->width = $params['video_width'];
             $fp->twoPass = $params['two_pass'];
             $fp->conversionEngines = '2,99,3';
             $fp->conversionEnginesExtraParams = strlen($params['extra_params']) > 0 ? $params['extra_params'] : '-flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq \'blurCplx^(1-qComp)\' -level 30 -async 2 -vsync 1 -threads 4 | -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq \'blurCplx^(1-qComp)\' -level 30 -async 2 -vsync 1 | -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200';
             try {
                 $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
                 $filter = new Kaltura_Client_SystemPartner_Type_SystemPartnerFilter();
                 $partner = $systemPartnerPlugin->systemPartner->get($fp->partnerId);
                 $oldKs = $client->getKs();
                 $newKs = $client->generateSession($partner->adminSecret, "", Kaltura_Client_Enum_SessionType::ADMIN, $fp->partnerId, 86400, "");
                 $client->setKs($newKs);
                 $result = $client->flavorParams->add($fp);
                 $client->setKs($oldKs);
                 $action->view->resultString = 'Flavor named \'' . $result->name . '\' successfully created ID is: ' . $result->id;
             } catch (Exception $e) {
                 var_dump($e);
             }
         }
     }
 }
Пример #5
0
 public function isValid($value)
 {
     $this->_setValue($value);
     $client = Infra_ClientHelper::getClient();
     // get results and paginate
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     $filter = new Kaltura_Client_Type_UserLoginDataFilter();
     $filter->loginEmailEqual = $value;
     $otherUsersWithTheSameEmail = $systemPartnerPlugin->systemPartner->listUserLoginData($filter);
     if (count($otherUsersWithTheSameEmail->objects)) {
         try {
             // allow to use email of admin console users
             $client->user->getByLoginId($value);
         } catch (Exception $ex) {
             $this->_error();
             return false;
         }
     }
     return true;
 }
 /**
  * 
  * @param int $offset
  * @param int $itemCountPerPage
  */
 protected function callService($offset, $itemCountPerPage)
 {
     $objects = parent::callService($offset, $itemCountPerPage);
     $partners = array();
     foreach ($objects as $object) {
         $partners[$object->partnerId] = null;
     }
     $filter = new Kaltura_Client_Type_PartnerFilter();
     $filter->idIn = implode(',', array_keys($partners));
     $client = Infra_ClientHelper::getClient();
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     $partnersResponse = $systemPartnerPlugin->systemPartner->listAction($filter);
     foreach ($partnersResponse->objects as $partner) {
         $partners[$partner->id] = $partner;
     }
     foreach ($objects as $object) {
         if (!is_null($partners[$object->partnerId])) {
             $object->partner = $partners[$object->partnerId];
         }
     }
     return $objects;
 }
Пример #7
0
 protected function getReportFilterFromRequest(Zend_Controller_Request_Abstract $request)
 {
     $reportFilter = new Kaltura_Client_Type_ReportFilter();
     $partnerFilter = null;
     $filterType = $request->getParam('filter_type');
     $filterInput = $request->getParam('filter_input');
     switch ($filterType) {
         case 'by-report-id':
             $reportFilter->idIn = $filterInput;
             break;
         case 'byid':
             $reportFilter->partnerIdIn = $filterInput;
             break;
         case 'by-partner-name':
             $partnerFilter = new Kaltura_Client_Type_PartnerFilter();
             $partnerFilter->nameLike = $filterInput;
             $statuses = array();
             $statuses[] = Kaltura_Client_Enum_PartnerStatus::ACTIVE;
             $statuses[] = Kaltura_Client_Enum_PartnerStatus::BLOCKED;
             $partnerFilter->statusIn = implode(',', $statuses);
             $partnerFilter->orderBy = Kaltura_Client_Enum_PartnerOrderBy::ID_DESC;
             $client = Infra_ClientHelper::getClient();
             $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
             $partnersResponse = $systemPartnerPlugin->systemPartner->listAction($partnerFilter);
             if (count($partnersResponse->objects) == 0) {
                 $reportFilter->idEqual = -1;
                 // nothing should be found
             } else {
                 $partnerIds = array();
                 foreach ($partnersResponse->objects as $partner) {
                     $partnerIds[] = $partner->id;
                 }
                 $reportFilter->partnerIdIn = implode(',', $partnerIds);
             }
     }
     return $reportFilter;
 }
Пример #8
0
 public function assignPartnersAction()
 {
     $this->_helper->layout->disableLayout();
     $request = $this->getRequest();
     $userId = $this->_getParam('userId');
     $client = Infra_ClientHelper::getClient();
     $user = $client->user->get($userId);
     $form = new Form_AssignPartners();
     $client = Infra_ClientHelper::getClient();
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     Form_PackageHelper::addPackagesToForm($form, $systemPartnerPlugin->systemPartner->getPackages(), 'partner_package');
     $form->getElement('name')->setValue($user->fullName);
     $form->getElement('partners')->setValue($user->allowedPartnerIds);
     $form->getElement('partner_package')->setValue(explode(",", $user->allowedPartnerPackages));
     if ($request->isPost()) {
         $form->isValid($request->getPost());
         $this->proccessAssignPartnersForm($form);
     }
     $this->view->form = $form;
 }
Пример #9
0
 /**
  * Multi-Publisher Console redirect
  */
 public function mpConsoleRedirectAction()
 {
     $partnerId = $this->_getParam('partner_id');
     $userId = $this->_getParam('user_id');
     $client = Infra_ClientHelper::getClient();
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     try {
         $ks = $systemPartnerPlugin->systemPartner->getAdminSession($partnerId, $userId);
     } catch (Exception $e) {
         $this->view->partnerId = $partnerId;
         $this->view->errorMessage = $e->getMessage();
         return;
     }
     $url = null;
     $settings = Zend_Registry::get('config')->settings;
     if ($settings->mpConsoleUrl) {
         $url = Infra_ClientHelper::getServiceUrl();
         $url .= $settings->mpConsoleUrl;
     }
     $identiry = Infra_AuthHelper::getAuthInstance()->getIdentity();
     /* @var $identiry Infra_UserIdentity */
     $formdata = array('ks' => $ks, 'timezone_offset' => $identiry->getTimezoneOffset());
     $url .= '?' . http_build_query($formdata);
     $this->getResponse()->setRedirect($url);
 }
 public function mpConsoleRedirectAction()
 {
     $partnerId = $this->_getParam('partner_id');
     $userId = $this->_getParam('user_id');
     $client = Infra_ClientHelper::getClient();
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     try {
         $ks = $systemPartnerPlugin->systemPartner->getAdminSession($partnerId, $userId);
     } catch (Exception $e) {
         $this->view->partnerId = $partnerId;
         $this->view->errorMessage = $e->getMessage();
         return;
     }
     $url = null;
     $settings = Zend_Registry::get('config')->settings;
     if ($settings->mpConsoleUrl) {
         $url = Infra_ClientHelper::getServiceUrl();
         $url .= $settings->mpConsoleUrl;
     }
     $url .= '?ks=' . $ks;
     $this->getResponse()->setRedirect($url);
 }
Пример #11
0
 protected function getUiConfFilterFromRequest(Zend_Controller_Request_Abstract $request)
 {
     $uiConfFilter = new Kaltura_Client_Type_UiConfFilter();
     $uiConfFilter->objTypeIn = implode(',', array_keys($this->getSupportedUiConfTypes()));
     $partnerFilter = null;
     $filterType = $request->getParam('filter_type');
     $filterInput = $request->getParam('filter_input');
     switch ($filterType) {
         case 'by-uiconf-id':
             $uiConfFilter->idIn = $filterInput;
             break;
         case 'byid':
             $uiConfFilter->partnerIdIn = $filterInput;
             break;
         case 'by-partner-name':
             $partnerFilter = new Kaltura_Client_Type_PartnerFilter();
             $partnerFilter->nameLike = $filterInput;
             $statuses = array();
             $statuses[] = Kaltura_Client_Enum_PartnerStatus::ACTIVE;
             $statuses[] = Kaltura_Client_Enum_PartnerStatus::BLOCKED;
             $partnerFilter->statusIn = implode(',', $statuses);
             $partnerFilter->orderBy = Kaltura_Client_Enum_PartnerOrderBy::ID_DESC;
             $client = Infra_ClientHelper::getClient();
             $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
             $partnersResponse = $systemPartnerPlugin->systemPartner->listAction($partnerFilter);
             if (count($partnersResponse->objects) == 0) {
                 $uiConfFilter->idEqual = -1;
                 // nothing should be found
             } else {
                 $partnerIds = array();
                 foreach ($partnersResponse->objects as $partner) {
                     $partnerIds[] = $partner->id;
                 }
                 $uiConfFilter->partnerIdIn = implode(',', $partnerIds);
             }
             break;
         default:
             // We don't want to query all ui-confs.
             $uiConfFilter->partnerIdIn = 0;
     }
     return $uiConfFilter;
 }