protected function checkAclForNavigation(Zend_Navigation_Container $navigation)
 {
     $accessConfig = Zend_Registry::get('config')->access;
     $pages = $navigation->getPages();
     foreach ($pages as $page) {
         $controller = $page->get('controller');
         $action = $page->get('action');
         $allowed = Infra_AclHelper::isAllowed($controller, $action);
         if (!$allowed) {
             $navigation->removePage($page);
         } else {
             $this->checkAclForNavigation($page);
         }
         if ($action == 'dynamic_action') {
             $localPages = $page->getPages();
             $firstPage = reset($localPages);
             if ($firstPage) {
                 $firstPageAction = $firstPage->get('action');
                 $page->set('action', $firstPageAction);
             }
         }
     }
 }
Пример #2
0
 /**
  * @param Kaltura_Client_SystemPartner_Type_SystemPartnerConfiguration $object
  * @param bool $add_underscore
  */
 public function populateFromObject($object, $add_underscore = true)
 {
     /* @var $object Kaltura_Client_SystemPartner_Type_SystemPartnerConfiguration */
     parent::populateFromObject($object, $add_underscore);
     if (is_array($object->limits)) {
         foreach ($object->limits as $limit) {
             if (isset($this->limitSubForms[$limit->type])) {
                 $subFormObject = $this->limitSubForms[$limit->type];
                 /* @var $subFormObject Form_PartnerConfigurationLimitSubForm */
                 $subFormObject->populateFromObject($this, $object, $limit, false);
             }
         }
     }
     $element = $this->getElement('use_default_streamers');
     $element->setAttrib('checked', is_null($object->customDeliveryTypes) || !count($object->customDeliveryTypes));
     if (!is_null($object->customDeliveryTypes)) {
         foreach ($object->customDeliveryTypes as $customDeliveryType) {
             /* @var $customDeliveryType Kaltura_Client_Type_KeyBooleanValue */
             $element = $this->getElement('delivery_type_' . $customDeliveryType->key);
             if ($customDeliveryType->value) {
                 $element->setAttrib('data-checked', true);
             } else {
                 $element->setAttrib('data-checked', false);
             }
             KalturaLog::debug("delivery_type_{$customDeliveryType->key} was set to [" . $customDeliveryType->value . "]");
         }
     }
     if (!$object->permissions || !count($object->permissions)) {
         return;
     }
     foreach ($object->permissions as $permission) {
         KalturaLog::debug("Set Permission: " . $permission->name . " status: " . $permission->status);
         $this->setDefault($permission->name, $permission->status == Kaltura_Client_Enum_PermissionStatus::ACTIVE);
     }
     // partner is set to free trail package
     if (intval($object->partnerPackage) == PartnerController::PARTNER_PACKAGE_FREE) {
         if (!Infra_AclHelper::isAllowed('partner', 'configure-account-packages-service-paid')) {
             $this->setPermissionGroupElementsToDisabled(array('accountPackagesService'));
         }
     }
 }
Пример #3
0
 public function indexAction()
 {
     if (Infra_AclHelper::isAllowed('partner', 'list')) {
         $this->_helper->redirector('list', 'partner');
     }
 }
Пример #4
0
 public function listAction()
 {
     $request = $this->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     // reset form url
     $action = $this->view->url(array('controller' => $request->getParam('controller'), 'action' => $request->getParam('action')), null, true);
     $client = Infra_ClientHelper::getClient();
     $form = new Form_PartnerFilter();
     $form->setAction($action);
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     $partnerPackages = $systemPartnerPlugin->systemPartner->getPackages();
     Form_PackageHelper::addPackagesToForm($form, $partnerPackages, 'partner_package', true, 'All Service Editions');
     if ($request->isPost() && $request->getParam('filter_type')) {
         $form->isValid($request->getPost());
     }
     $this->view->partnerPackages = array();
     foreach ($partnerPackages as $package) {
         $this->view->partnerPackages[$package->id] = $package->name;
     }
     // init filter
     $partnerFilter = $this->getPartnerFilterFromRequest($request);
     // if non-commercial partners are not allowed, add to filter
     if (Infra_AclHelper::isAllowed('partner', 'commercial')) {
         $this->view->commercialFiltered = false;
     } else {
         $this->view->commercialFiltered = true;
         $partnerFilter->partnerPackageLessThanOrEqual = self::PARTNER_PACKAGE_FREE;
     }
     // get results and paginate
     $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
     $paginatorAdapter = new Infra_FilterPaginator($systemPartnerPlugin->systemPartner, "listAction", null, $partnerFilter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     // popule the form
     $form->populate($request->getParams());
     // set view
     $this->view->form = $form;
     $this->view->paginator = $paginator;
     $plugins = array();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaAdminConsolePages');
     $partnerActionPluginPages = array();
     foreach ($pluginInstances as $pluginInstance) {
         $pluginPages = $pluginInstance->getApplicationPages(Infra_AclHelper::getCurrentPermissions());
         foreach ($pluginPages as $pluginPage) {
             if ($pluginPage instanceof IKalturaAdminConsolePublisherAction && $pluginPage->accessCheck(Infra_AclHelper::getCurrentPermissions())) {
                 $partnerActionPluginPages[] = $pluginPage;
             }
         }
     }
     $this->view->partnerActionPluginPages = $partnerActionPluginPages;
 }
 public function createAction()
 {
     $request = $this->getRequest();
     $client = Infra_ClientHelper::getClient();
     $form = new Form_PartnerCreate();
     $partner = Zend_Registry::get('config')->partner;
     $this->view->errorDescription = "";
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $partner = $form->getObject("Kaltura_Client_Type_Partner", $request->getPost());
             $templatePartnerId = $form->getValue("copyPartner");
             /* @var $partner Kaltura_Client_Type_Partner */
             if (is_array($partner->contentCategories)) {
                 $partner->contentCategories = implode(',', $partner->contentCategories);
             }
             $partner->description = "Multi-publishers console";
             $partner->type = Kaltura_Client_Enum_PartnerType::ADMIN_CONSOLE;
             try {
                 $result = $client->partner->register($partner, null, $templatePartnerId);
                 // check for errors in partner.register
                 if ($client->isError($result)) {
                     if (strpos($result[0]['message'], 'already exists in system') !== false) {
                         $form->getElement('admin_email')->addError('Email already exists');
                     } else {
                         $this->view->errorDescription = 'An error occured: ' . $e->getMessage();
                     }
                 } else {
                     Infra_AclHelper::refreshCurrentUserAllowrdPartners();
                     $this->_helper->redirector('list');
                 }
             } catch (Exception $e) {
                 $this->view->errorDescription = 'An error occured: ' . $e->getMessage();
             }
         } else {
             $form->populate($request->getPost());
         }
     }
     $varConsoleFilter = new Kaltura_Client_VarConsole_Type_VarConsolePartnerFilter();
     $varConsoleFilter->groupTypeEq = Kaltura_Client_Enum_PartnerGroupType::TEMPLATE;
     $varConsoleFilter->statusEqual = Kaltura_Client_Enum_PartnerStatus::ACTIVE;
     $pager = new Kaltura_Client_Type_FilterPager();
     $templatePartnerList = $client->partner->listAction($varConsoleFilter, $pager);
     $providers = array();
     $providers[0] = $this->view->translate('partner-create default copy partner');
     foreach ($templatePartnerList->objects as $templatePartner) {
         /* @var $templatePartner Kaltura_Client_Type_Partner */
         $providers[$templatePartner->id] = $templatePartner->name;
     }
     $form->setProviders($providers);
     //If available sub-publisher quota was reached, submit button should be disabled.
     //Exclude publisher iteself, template sub-publisher and deleted sub-publisher
     $currentPartner = $client->partner->getInfo();
     $filter = new Kaltura_Client_VarConsole_Type_VarConsolePartnerFilter();
     $filter->idNotIn = $currentPartner->id;
     $filter->statusIn = implode(",", array(Kaltura_Client_Enum_PartnerStatus::ACTIVE, Kaltura_Client_Enum_PartnerStatus::BLOCKED));
     $filter->groupTypeEq = Kaltura_Client_Enum_PartnerGroupType::PUBLISHER;
     $subPublisherCount = $client->partner->count($filter);
     /* @var $currentPartner Kaltura_Client_Type_Partner */
     if ($currentPartner->publishersQuota - $subPublisherCount <= 0) {
         $submitBtn = $form->getElement('submit');
         $submitBtn->setOptions(array('disable' => array(1, 2)));
     }
     $this->view->usedPublishers = $subPublisherCount;
     $this->view->remainingPublishers = $currentPartner->publishersQuota - $subPublisherCount > 0 ? $currentPartner->publishersQuota - $subPublisherCount : 0;
     $this->view->form = $form;
 }
Пример #6
0
 public function setupAction()
 {
     $request = $this->getRequest();
     $this->view->errors = array();
     $this->view->schedulers = array();
     $this->view->workers = array();
     $client = Infra_ClientHelper::getClient();
     if (!$client) {
         $this->view->errors[] = 'init client failed';
         return;
     }
     $adminId = Infra_AuthHelper::getAuthInstance()->getIdentity()->getUser()->id;
     $action = $request->getParam('hdnAction', false);
     if ($action) {
         Infra_AclHelper::validateAccess('batch', 'setup-stop-start');
         $workerId = $request->getParam('hdnWorkerId', false);
         $cause = $request->getParam('hdnCause', false);
         try {
             switch ($action) {
                 case "stop":
                     $client->batchcontrol->stopWorker($workerId, $adminId, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] stop command sent.\n";
                     break;
                 case "start":
                     $client->batchcontrol->startWorker($workerId, $adminId, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] start command sent.\n";
                     break;
                 case "disable":
                     $configParam = 'enable';
                     $configValue = '0';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] disable command sent.\n";
                     break;
                 case "enable":
                     $configParam = 'enable';
                     $configValue = '1';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] enable command sent.\n";
                     break;
                 case "start-manual":
                     $configParam = 'enable';
                     $configValue = '1';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $configParam = 'autoStart';
                     $configValue = '0';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] start manualy command sent.\n";
                     break;
                 case "start-auto":
                     $configParam = 'enable';
                     $configValue = '1';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $configParam = 'autoStart';
                     $configValue = '1';
                     $configParamPart = null;
                     $client->batchcontrol->setWorkerConfig($workerId, $adminId, $configParam, $configValue, $configParamPart, $cause);
                     $this->view->actionDescription .= "Worker [{$workerId}] start automatic command sent.\n";
                     break;
             }
         } catch (Exception $e) {
             $this->view->errors[] = $e->getMessage();
         }
     }
     $filter = new Kaltura_Client_Type_ControlPanelCommandFilter();
     $filter->createdByIdEqual = $adminId;
     $filter->statusIn = Kaltura_Client_Enum_ControlPanelCommandStatus::HANDLED . ',' . Kaltura_Client_Enum_ControlPanelCommandStatus::PENDING;
     $this->view->disabledWorkers = array();
     try {
         $commandsList = $client->batchcontrol->listCommands($filter);
         foreach ($commandsList->objects as $command) {
             if ($command->type != Kaltura_Client_Enum_ControlPanelCommandType::CONFIG) {
                 $this->view->disabledWorkers[$command->workerId] = $command;
             }
         }
     } catch (Exception $e) {
         $this->view->errors[] = $e->getMessage();
     }
     $settings = Zend_Registry::get('config')->settings;
     $controlCommandsTimeFrame = $settings->controlCommandsTimeFrame * 60;
     $filter = new Kaltura_Client_Type_ControlPanelCommandFilter();
     $filter->createdByIdEqual = $adminId;
     $filter->createdAtGreaterThanOrEqual = time() - $controlCommandsTimeFrame;
     try {
         $commandsList = $client->batchcontrol->listCommands($filter);
         $this->view->commands = $commandsList->objects;
     } catch (Exception $e) {
         $this->view->commands = array();
     }
     try {
         $schedulersList = $client->batchcontrol->listSchedulers();
         $this->view->schedulers = $schedulersList->objects;
     } catch (Exception $e) {
         $this->view->schedulers = array();
     }
     try {
         $workersList = $client->batchcontrol->listWorkers();
         $this->view->workers = $workersList->objects;
     } catch (Exception $e) {
         $this->view->workers = array();
     }
 }
 /**
  * @param Kaltura_Client_SystemPartner_Type_SystemPartnerConfiguration $object
  * @param bool $add_underscore
  */
 public function populateFromObject($object, $add_underscore = true)
 {
     /* @var $object Kaltura_Client_SystemPartner_Type_SystemPartnerConfiguration */
     parent::populateFromObject($object, $add_underscore);
     if (is_array($object->limits)) {
         foreach ($object->limits as $limit) {
             if (isset($this->limitSubForms[$limit->type])) {
                 $subFormObject = $this->limitSubForms[$limit->type];
                 $subFormObject->populateFromObject($this, $limit, false);
             }
         }
     }
     if (!$object->permissions || !count($object->permissions)) {
         return;
     }
     foreach ($object->permissions as $permission) {
         KalturaLog::debug("Set Permission: " . $permission->name . " status: " . $permission->status);
         $this->setDefault($permission->name, $permission->status == Kaltura_Client_Enum_PermissionStatus::ACTIVE);
     }
     // partner is set to free trail package
     if (intval($object->partnerPackage) == PartnerController::PARTNER_PACKAGE_FREE) {
         if (!Infra_AclHelper::isAllowed('partner', 'configure-account-packages-service-paid')) {
             $this->setPermissionGroupElementsToDisabled(array('accountPackagesService'));
         }
     }
 }