public function initService($serviceId, $serviceName, $actionName) { parent::initService($serviceId, $serviceName, $actionName); if ($this->getPartnerId() != Partner::BATCH_PARTNER_ID) { throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName); } myPartnerUtils::resetAllFilters(); }
<?php require_once dirname(__FILE__) . '/../bootstrap.php'; $f = fopen("php://stdin", "r"); $count = 0; $sphinxMgr = new kSphinxSearchManager(); $dbConf = kConf::getDB(); DbManager::setConfig($dbConf); DbManager::initialize(); $connection = Propel::getConnection(); while ($s = trim(fgets($f))) { $sep = strpos($s, "\t") ? "\t" : " "; list($entryId, $plays, $views) = explode($sep, $s); myPartnerUtils::resetAllFilters(); entryPeer::setDefaultCriteriaFilter(); $entry = entryPeer::retrieveByPK($entryId); if (is_null($entry)) { KalturaLog::err('Couldn\'t find entry [' . $entryId . ']'); continue; } if ($entry->getViews() != $views || $entry->getPlays() != $plays) { $entry->setViews($views); $entry->setPlays($plays); KalturaLog::debug('Successfully saved entry [' . $entryId . ']'); try { // update entry without setting the updated at $updateSql = "UPDATE entry set views='{$views}',plays='{$plays}' WHERE id='{$entryId}'"; $stmt = $connection->prepare($updateSql); $stmt->execute(); $affectedRows = $stmt->rowCount(); KalturaLog::log("AffectedRows: " . $affectedRows);
public function initService($serviceId, $serviceName, $actionName) { // init service and action name $this->serviceId = $serviceId; $this->serviceName = $serviceName; $this->actionName = $actionName; // impersonated partner = partner parameter from the request $this->impersonatedPartnerId = kCurrentContext::$partner_id; $this->ks = kCurrentContext::$ks_object ? kCurrentContext::$ks_object : null; // operating partner = partner from the request or the ks partner $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; // if there is no session, assume it's partner 0 using actions that doesn't require ks if (is_null($partnerId)) { $partnerId = 0; } $this->partner = PartnerPeer::retrieveByPK($partnerId); if (!$this->partner) { $this->partner = null; } // check if current aciton is allowed and if private partner data access is allowed $allowPrivatePartnerData = false; $actionPermitted = $this->isPermitted($allowPrivatePartnerData); // action not permitted at all, not even kaltura network if (!$actionPermitted) { $e = new KalturaAPIException(APIErrors::SERVICE_FORBIDDEN, $this->serviceId . '->' . $this->actionName); //TODO: should sometimes thorow MISSING_KS instead header("X-Kaltura:error-" . $e->getCode()); header("X-Kaltura-App: exiting on error " . $e->getCode() . " - " . $e->getMessage()); throw $e; } // init partner filter parameters $this->private_partner_data = $allowPrivatePartnerData; $this->partnerGroup = kPermissionManager::getPartnerGroup($this->serviceId, $this->actionName); if ($this->globalPartnerAllowed($this->actionName)) { $this->partnerGroup = PartnerPeer::GLOBAL_PARTNER . ',' . trim($this->partnerGroup, ','); } // apply partner filters according to current context and permissions myPartnerUtils::resetAllFilters(); myPartnerUtils::applyPartnerFilters($partnerId, $this->private_partner_data, $this->partnerGroup, $this->kalturaNetworkAllowed($this->actionName)); }
/** * apply partner filters according to current context and permissions * * @param int $partnerId */ protected function setPartnerFilters($partnerId) { myPartnerUtils::resetAllFilters(); myPartnerUtils::applyPartnerFilters($partnerId, $this->private_partner_data, $this->partnerGroup(), $this->kalturaNetworkAllowed($this->actionName)); }
public function executeMultiRequest() { // several default params $global_format = @$this->original_request_params["format"]; if (!$global_format) { $global_format = kalturaWebserviceRenderer::RESPONSE_TYPE_XML; } $this->response_type = $global_format; // $multi_response = array(); while (($params = $this->getNextRequestParams($multi_response)) != null) { // start by resetting the peers so there will be no effect from the previous "request" myPartnerUtils::resetAllFilters(); // echo ( "Now executing request [{$this->current_action_index}}]<br>" ); $service_name = @$params["service"]; if (!$service_name) { // error - cannot find service to execute ! // LOG & STOP ! break; } $service_name = strtolower(str_replace("_", "", $service_name)); if ($service_name == self::MULTI_END) { break; } $clazz_name = $service_name . "Action"; $include_result = (include_once dirname(__FILE__) . "/../modules/partnerservices2/actions/{$clazz_name}.class.php"); if ($include_result) { $myaction = new $clazz_name(); // request the response as // becuase the format is global - it cannot be used per service anyway. $params["format"] = kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_ARRAY; $myaction->setInputParams($params); //$myaction->setResponseContext ( "response{$this->current_action_index}"); $response = $myaction->execute(false); // foreach single action - pass false so no extra debug data will be outputed // $this->addMsg ( "response{$this->current_action_index}" , $response ); $multi_response["response{$this->current_action_index}"] = $response; $error = @$response["error"]; } else { $error = "Invalid service [{$service_name}]"; } if ($error != null) { if ($this->stop_on_error == self::STOP_ON_FIRST_ERROR) { // make the error public as well as in the specific response // $this->addError( $error ); // $this->addError( "errornos_request" , $this->current_action_index ); //$this->setRawError( $error ); $this->addRawError($error); $this->addRawError(array("errornos_request" => $this->current_action_index)); // $multi_response["error"] = $error; // $multi_response["errornos_request"] = $this->current_action_index; // don't continue iterating break; } } } if (count($this->errors) > 0) { if (!isset($multi_response["debug"])) { $multi_response["debug"] = array(); } // $this->addDebug ( "error_replacing" , $this->errors ); $multi_response["debug"] = $this->errors; } $this->setMsg($multi_response); return $multi_response; }
/** * Function creates new partner, saves all the required data to it, and copies objects & filesyncs of template content to its ID. * @param string $partner_name * @param string $contact * @param string $email * @param CommercialUseType $ID_is_for * @param string $SDK_terms_agreement * @param string $description * @param string $website_url * @param string $password * @param Partner $partner * @param int $templatePartnerId * @return Partner */ private function createNewPartner($partner_name, $contact, $email, $ID_is_for, $SDK_terms_agreement, $description, $website_url, $password = null, $newPartner = null, $templatePartnerId = null) { $secret = md5($this->str_makerand(5, 10, true, false, true)); $admin_secret = md5($this->str_makerand(5, 10, true, false, true)); if (!$newPartner) { $newPartner = new Partner(); } if ($partner_name) { $newPartner->setPartnerName($partner_name); } $newPartner->setAdminSecret($admin_secret); $newPartner->setSecret($secret); $newPartner->setAdminName($contact); $newPartner->setAdminEmail($email); $newPartner->setUrl1($website_url); if ($ID_is_for === "commercial_use" || $ID_is_for === CommercialUseType::COMMERCIAL_USE) { $newPartner->setCommercialUse(true); } else { //($ID_is_for == "non-commercial_use") || $ID_is_for === CommercialUseType::NON_COMMERCIAL_USE) $newPartner->setCommercialUse(false); } $newPartner->setDescription($description); $newPartner->setKsMaxExpiryInSeconds(86400); $newPartner->setModerateContent(false); $newPartner->setNotify(false); $newPartner->setAppearInSearch(mySearchUtils::DISPLAY_IN_SEARCH_PARTNER_ONLY); $newPartner->setIsFirstLogin(true); /* fix drupal5 module partner type */ //var_dump($description); if ($this->partnerParentId) { // this is a child partner of some VAR/partner GROUP $newPartner->setPartnerParentId($this->partnerParentId); $newPartner->setMonitorUsage(PartnerFreeTrialType::NO_LIMIT); $parentPartner = PartnerPeer::retrieveByPK($this->partnerParentId); $newPartner->setPartnerPackage($parentPartner->getPartnerPackage()); } if (substr_count($description, 'Drupal module|')) { $newPartner->setType(102); } $newPartner->save(); // if name was left empty - which should not happen - use id as name if (!$partner_name) { $partner_name = $newPartner->getId(); } $newPartner->setPartnerName($partner_name); $newPartner->setPrefix($newPartner->getId()); $newPartner->setPartnerAlias(md5($newPartner->getId() . 'kaltura partner')); // set default conversion profile for trial accounts if ($newPartner->getType() == Partner::PARTNER_TYPE_KMC) { $newPartner->setDefConversionProfileType(ConversionProfile::DEFAULT_TRIAL_COVERSION_PROFILE_TYPE); } $newPartner->save(); // remove the default criteria from all peers and recreate it with the right partner id myPartnerUtils::resetAllFilters(); myPartnerUtils::applyPartnerFilters($newPartner->getId(), true); $partner_id = $newPartner->getId(); widget::createDefaultWidgetForPartner($partner_id, $this->createNewSubPartner($newPartner)); $fromPartner = PartnerPeer::retrieveByPK($templatePartnerId ? $templatePartnerId : kConf::get("template_partner_id")); if (!$fromPartner) { KalturaLog::log("Template content partner was not found!"); } else { $newPartner->setI18nTemplatePartnerId($templatePartnerId); myPartnerUtils::copyTemplateContent($fromPartner, $newPartner, true); } if ($newPartner->getType() == Partner::PARTNER_TYPE_WORDPRESS) { kPermissionManager::setPs2Permission($newPartner); } $newPartner->setKmcVersion(kConf::get('new_partner_kmc_version')); $newPartner->save(); return $newPartner; }