/**
  * @param KalturaScheduledTaskProfile $profile
  */
 protected function processProfile(KalturaScheduledTaskProfile $profile)
 {
     $this->updateProfileBeforeExecution($profile);
     if ($profile->maxTotalCountAllowed) {
         $maxTotalCountAllowed = $profile->maxTotalCountAllowed;
     } else {
         $maxTotalCountAllowed = $this->getParams('maxTotalCountAllowed');
     }
     $pager = new KalturaFilterPager();
     $pager->pageIndex = 1;
     $pager->pageSize = 500;
     while (true) {
         $this->impersonate($profile->partnerId);
         try {
             $result = ScheduledTaskBatchHelper::query($this->getClient(), $profile, $pager);
             $this->unimpersonate();
         } catch (Exception $ex) {
             $this->unimpersonate();
             throw $ex;
         }
         if ($result->totalCount > $maxTotalCountAllowed) {
             KalturaLog::crit("List query for profile {$profile->id} returned too many results ({$result->totalCount} when the allowed total count is {$maxTotalCountAllowed}), suspending the profile");
             $this->suspendProfile($profile);
             break;
         }
         if (!count($result->objects)) {
             break;
         }
         foreach ($result->objects as $object) {
             $this->processObject($profile, $object);
         }
         $pager->pageIndex++;
     }
 }
Exemplo n.º 2
0
 public function __construct($key)
 {
     if (self::$exists) {
         KalturaLog::crit('Unexpected - query cache key already exists');
     }
     self::$exists = true;
     $this->key = $key;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionJobUpdatedAlmostDone(BatchJob $dbBatchJob, kDistributionJobData $data, BatchJob $twinJob = null)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $providerData = $data->getProviderData();
     KalturaLog::crit('provider data type' . get_class($providerData));
     if ($providerData instanceof kYouTubeDistributionJobProviderData) {
         KalturaLog::debug('setting currentPlaylists to entryDistribution custom data');
         $entryDistribution->putInCustomData('currentPlaylists', $providerData->getCurrentPlaylists());
         $entryDistribution->save();
     }
     return $dbBatchJob;
 }
 public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaPermissionItemArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         if ($obj->getType() == PermissionItemType::API_ACTION_ITEM) {
             $nObj = new KalturaApiActionPermissionItem();
         } else {
             if ($obj->getType() == PermissionItemType::API_PARAMETER_ITEM) {
                 $nObj = new KalturaApiParameterPermissionItem();
             } else {
                 KalturaLog::crit('Unknown permission item type [' . $obj->getType() . '] defined with id [' . $obj->getId() . '] - skipping!');
                 continue;
             }
         }
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 public function run()
 {
     KalturaLog::info("Email ingestion batch is running");
     if ($this->taskConfig->isInitOnly()) {
         return $this->init();
     }
     // get parameters from ini file
     try {
         $this->TEMP_FILE_DIR = $this->taskConfig->params->localTempPath;
     } catch (Exception $e) {
         KalturaLog::crit("Cannot find all required parameters from config file");
     }
     // create a temp file path
     if (!self::createDir($this->TEMP_FILE_DIR)) {
         KalturaLog::crit("Cannot continue email ingestion without a temp directory");
         return false;
         // quit run()
     }
     // ----------------------------------
     // loop through all defined mailboxes
     // ----------------------------------
     $mailboxNumber = 0;
     while (isset($this->taskConfig->params->{'mailbox' . ($mailboxNumber + 1)})) {
         $mailboxNumber++;
         $mailesProcessed = 0;
         $keepCurMailbox = true;
         $params = $this->taskConfig->params->{'mailbox' . $mailboxNumber};
         // get parameters
         try {
             $host = $params->hostname;
             $port = $params->port;
             $user = $params->user;
             $pass = $params->pass;
             $options = $params->options;
             $maxMails = $params->maxMailsPerRun;
         } catch (Exception $e) {
             KalturaLog::crit("Cannot find all required parameters from config file for mailbox number [{$mailboxNumber}]");
             continue;
             // skip current mailbox
         }
         // connect to current mailbox
         $mailChecker = new KMailChecker($host, $port, $user, $pass, $options);
         if (!$mailChecker->connect()) {
             KalturaLog::crit("Error connecting to [{$host}:{$port}] as [{$user}] - " . imap_last_error());
             continue;
             // skip current mailbox
         }
         KalturaLog::info("Sucessfuly connected to [{$host}:{$port}] as [{$user}]");
         // check for unread mails
         $newMails = $mailChecker->getUnreadIds();
         if (!$newMails || count($newMails) <= 0) {
             // no new mail availble in current mailbox
             KalturaLog::info("No new mails found on [{$user}@{$host}]");
             continue;
             // skip current mailbox
         }
         KalturaLog::info('[' . count($newMails) . "] unread mails found on [{$user}@{$host}]");
         // -----------------------------------------
         // loop through all mails in current mailbox
         // -----------------------------------------
         while ($keepCurMailbox && (list(, $curId) = each($newMails))) {
             if ($mailesProcessed >= $maxMails) {
                 KalturaLog::info("Reached the max mails per job for current mailbox [{$mailboxNumber}] - skipping to next mailbox");
                 $keepCurMailbox = false;
                 // skip current mailbox
                 continue;
                 // skip current mail --> skip current mailbox
             }
             $mailesProcessed++;
             // fetch current message
             $curMail = $mailChecker->fetchMsg($curId);
             if (!$curMail) {
                 KalturaLog::err("Error fetching message with folder ID [{$curId}] from [{$user}@{$host}] - " . imap_last_error());
                 continue;
                 // skip current mail - error fetching
             }
             // check if mail contains attachments
             if (!$curMail->attachments || count($curMail->attachments) == 0) {
                 // no attachments found
                 KalturaLog::info('No attachments found for mail [' . $curMail->header->msgid . "] on [{$user}@{$host}] from [" . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . ']');
                 if (!$mailChecker->moveMsg($curId, self::NO_ATTACHMENT)) {
                     KalturaLog::err('Failed moving msg [' . $curMail->header->msgid . '] to the [' . self::NO_ATTACHMENT . '] folder - ' . imap_last_error());
                 }
                 continue;
                 // skip current mail - no attachments
             }
             // validate partner and get email profile
             $email_profiles = $this->validePartnerAndGetProfile($curMail->header->toadd, $user . '@' . $host);
             if (!$email_profiles) {
                 // error validating partner
                 KalturaLog::err('Partner validation failed for [' . $curMail->header->msgid . "] on [{$user}@{$host}] from [" . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . ']');
                 if (!$mailChecker->moveMsg($curId, self::PARTNER_INVALID)) {
                     KalturaLog::err('Failed moving msg [' . $curMail->header->msgid . '] to the [' . self::PARTNER_INVALID . '] folder - ' . imap_last_error());
                 }
                 continue;
                 // skip current mail - partner invalid
             }
             // create a new media entry from data in mail body text
             $mediaEntry = $this->createMediaEntry($curMail->header, $curMail->body);
             // add the mail's attachment for each valid email profile
             $failures = new AddEntriesFailures();
             foreach ($email_profiles as $profile) {
                 KalturaLog::info("*** Currently processing attachments for email profile id [{$profile->id}] of partner id [{$profile->partnerId}]");
                 // add a new entry for each attachment
                 //TODO: currently, the same attachment will be uploaded again and again for each different profile because the uploaded file is being transferred on the server - this should be changed.
                 if (!$this->addEntries($curMail, $profile, $mediaEntry, $failures)) {
                     KalturaLog::err("Some errors occured while adding entries for email profile id [{$profile->id}] of partner id [{$profile->partnerId}]");
                 }
             }
             // check if any problems happened
             if ($failures->problemsHappened()) {
                 $new_folder = self::UNKNOWN;
                 if ($failures->upload_failed || $failures->add_entry_failed || $failures->error_saving_temp_file) {
                     // some attachments had problems
                     $new_folder = self::ADD_ENTRY_FAIL;
                     KalturaLog::crit('Failed adding some attachments for [' . $curMail->header->msgid . "] on [{$user}@{$host}] Moving msg to [" . $new_folder . '] folder');
                 } else {
                     if ($failures->too_many_attachments) {
                         // too many attachments
                         $new_folder = self::INCOMPLETE;
                         KalturaLog::err('Msg [' . $curMail->header->msgid . "] on [{$user}@{$host}] from [" . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . "] contains too many attachments. Moving msg to [{$new_folder}] folder");
                     } else {
                         if ($failures->attachment_too_big || $failures->attachment_invalid) {
                             // errors in specific attachments
                             if (count($curMail->attachments) > 1) {
                                 $new_folder = self::INCOMPLETE;
                                 KalturaLog::err('Some invalid attachments found for msg [' . $curMail->header->msgid . "] on [{$user}@{$host}] from [" . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . "]. Moving msg to [{$new_folder}] folder");
                             } else {
                                 $new_folder = self::ATTACHMENT_INVALID;
                                 KalturaLog::err('Msg attachment is invalid for msg [' . $curMail->header->msgid . "] on [{$user}@{$host}] from [" . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . "]. Moving msg to [{$new_folder}] folder");
                             }
                         } else {
                             // shouldn't get here
                             KalturaLog::err('*** Not all addEntriesFailures situations were handled.');
                         }
                     }
                 }
                 // move msg to the right error folder
                 if (!$mailChecker->moveMsg($curId, $new_folder)) {
                     KalturaLog::err('Failed moving msg [' . $curMail->header->msgid . '] to the [' . $new_folder . '] folder - ' . imap_last_error());
                 }
             } else {
                 // ------------------------------------------------------
                 // all attachments were added succesfuly for all profiles
                 // ------------------------------------------------------
                 if (!$mailChecker->moveMsg($curId, self::PROCESS_OK)) {
                     KalturaLog::err('Msg [' . $curMail->header->msgid . '] from [' . $curMail->header->fromadd . '] with subject [' . $curMail->header->subject . '] was processed OK but failed moving to the [' . self::PROCESS_OK . '] folder - ' . imap_last_error());
                 }
             }
         }
         // end loop through mails in current mailbox
     }
     // end loop through mailboxes
 }
Exemplo n.º 6
0
 public function getExceptionObject($ex, $service, $action)
 {
     KalturaResponseCacher::adjustApiCacheForException($ex);
     if ($ex instanceof KalturaAPIException) {
         KalturaLog::err($ex);
         $object = $ex;
     } else {
         if ($ex instanceof APIException) {
             $args = $ex->extra_data;
             $reflectionException = new ReflectionClass("KalturaAPIException");
             $ex = $reflectionException->newInstanceArgs($args);
             KalturaLog::err($ex);
             $object = $ex;
         } else {
             if ($ex instanceof kCoreException) {
                 switch ($ex->getCode()) {
                     case kCoreException::USER_BLOCKED:
                         $object = new KalturaAPIException(KalturaErrors::USER_BLOCKED);
                         break;
                     case kCoreException::PARTNER_BLOCKED:
                         $object = new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN_CONTENT_BLOCKED);
                         break;
                     case kCoreException::INVALID_KS:
                         $object = new KalturaAPIException(KalturaErrors::INVALID_KS, $ex->getData(), ks::INVALID_STR, 'INVALID_STR');
                         break;
                     case kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED:
                         $object = new KalturaAPIException(KalturaErrors::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED, $ex->getData());
                         break;
                     case kCoreException::MAX_CATEGORIES_PER_ENTRY:
                         $object = new KalturaAPIException(KalturaErrors::MAX_CATEGORIES_FOR_ENTRY_REACHED, $ex->getData());
                         break;
                     case kCoreException::MAX_ASSETS_PER_ENTRY:
                         $object = new KalturaAPIException(KalturaErrors::MAX_ASSETS_FOR_ENTRY_REACHED, asset::MAX_ASSETS_PER_ENTRY);
                         break;
                     case kCoreException::SEARCH_TOO_GENERAL:
                         $object = new KalturaAPIException(KalturaErrors::SEARCH_TOO_GENERAL);
                         break;
                     case kCoreException::SOURCE_FILE_NOT_FOUND:
                         $object = new KalturaAPIException(KalturaErrors::SOURCE_FILE_NOT_FOUND);
                         break;
                     case APIErrors::INVALID_ACTIONS_LIMIT:
                         $object = new KalturaAPIException(APIErrors::INVALID_ACTIONS_LIMIT);
                         break;
                     case APIErrors::PRIVILEGE_IP_RESTRICTION:
                         $object = new KalturaAPIException(APIErrors::PRIVILEGE_IP_RESTRICTION);
                         break;
                     case APIErrors::INVALID_SET_ROLE:
                         $object = new KalturaAPIException(APIErrors::INVALID_SET_ROLE);
                         break;
                     case APIErrors::UNKNOWN_ROLE_ID:
                         $object = new KalturaAPIException(APIErrors::UNKNOWN_ROLE_ID);
                         break;
                     case APIErrors::SEARCH_ENGINE_QUERY_FAILED:
                         $object = new KalturaAPIException(APIErrors::SEARCH_ENGINE_QUERY_FAILED);
                         break;
                     case kCoreException::FILE_NOT_FOUND:
                         $object = new KalturaAPIException(KalturaErrors::FILE_NOT_FOUND);
                         break;
                     case kCoreException::LOCK_TIMED_OUT:
                         $object = new KalturaAPIException(KalturaErrors::LOCK_TIMED_OUT);
                         break;
                     case kCoreException::SPHINX_CRITERIA_EXCEEDED_MAX_MATCHES_ALLOWED:
                         $object = new KalturaAPIException(KalturaErrors::SPHINX_CRITERIA_EXCEEDED_MAX_MATCHES_ALLOWED);
                         break;
                     case kCoreException::INVALID_ENTRY_ID:
                         $object = new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $ex->getData());
                         break;
                     case kCoreException::MAX_FILE_SYNCS_FOR_OBJECT_PER_DAY_REACHED:
                         $object = new KalturaAPIException(KalturaErrors::MAX_FILE_SYNCS_FOR_OBJECT_PER_DAY_REACHED, $ex->getData());
                         break;
                     case kCoreException::ID_NOT_FOUND:
                         $object = new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $ex->getData());
                         break;
                     default:
                         KalturaLog::crit($ex);
                         $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
                 }
             } else {
                 if ($ex instanceof PropelException) {
                     KalturaLog::alert($ex);
                     $object = new KalturaAPIException(KalturaErrors::INTERNAL_DATABASE_ERROR);
                 } else {
                     KalturaLog::crit($ex);
                     $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
                 }
             }
         }
     }
     return $this->handleErrorMapping($object, $service, $action);
 }
Exemplo n.º 7
0
 public function dispatch($service, $action, $params = array())
 {
     $start = microtime(true);
     // prevent impersonate to partner zero
     $p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
     if (!$p) {
         $p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
     }
     $GLOBALS["partnerId"] = $p;
     // set for logger
     $userId = "";
     $ksStr = isset($params["ks"]) ? $params["ks"] : null;
     if (!$service) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
     }
     //strtolower on service - map is indexed according to lower-case service IDs
     $service = strtolower($service);
     $serviceActionItem = KalturaServicesMap::retrieveServiceActionItem($service, $action);
     $action = strtolower($action);
     if (!isset($serviceActionItem->actionMap[$action])) {
         KalturaLog::crit("Action does not exist!");
         throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
     }
     try {
         $actionReflector = new KalturaActionReflector($service, $action, $serviceActionItem->actionMap[$action]);
     } catch (Exception $e) {
         throw new Exception("Could not create action reflector for service [{$service}], action [{$action}]. Received error: " . $e->getMessage());
     }
     $actionParams = $actionReflector->getActionParams();
     $actionInfo = $actionReflector->getActionInfo();
     // services.ct - check if partner is allowed to access service ...
     kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname();
     kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
     kCurrentContext::$ps_vesion = "ps3";
     kCurrentContext::$service = $serviceActionItem->serviceInfo->serviceName;
     kCurrentContext::$action = $action;
     kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
     kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
     // validate it's ok to access this service
     $deserializer = new KalturaRequestDeserializer($params);
     $this->arguments = $deserializer->buildActionArguments($actionParams);
     KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "], reqIndex [" . kCurrentContext::$multiRequest_index . "] with params " . print_r($this->arguments, true));
     $responseProfile = $deserializer->getResponseProfile();
     if ($responseProfile) {
         KalturaLog::debug("Response profile: " . print_r($responseProfile, true));
     }
     kPermissionManager::init(kConf::get('enable_cache'));
     kEntitlementUtils::initEntitlementEnforcement();
     $disableTags = $actionInfo->disableTags;
     if ($disableTags && is_array($disableTags) && count($disableTags)) {
         foreach ($disableTags as $disableTag) {
             KalturaCriterion::disableTag($disableTag);
         }
     }
     if ($actionInfo->validateUserObjectClass && $actionInfo->validateUserIdParamName && isset($actionParams[$actionInfo->validateUserIdParamName])) {
         //			// TODO maybe if missing should throw something, maybe a bone?
         //			if(!isset($actionParams[$actionInfo->validateUserIdParamName]))
         //				throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, $actionInfo->validateUserIdParamName);
         KalturaLog::debug("validateUserIdParamName: " . $actionInfo->validateUserIdParamName);
         $objectId = $params[$actionInfo->validateUserIdParamName];
         $this->validateUser($actionInfo->validateUserObjectClass, $objectId, $actionInfo->validateUserPrivilege, $actionInfo->validateOptions);
     }
     // initialize the service before invoking the action on it
     // action reflector will init the service to maintain the pluginable action transparency
     $actionReflector->initService($responseProfile);
     $invokeStart = microtime(true);
     KalturaLog::debug("Invoke start");
     try {
         $res = $actionReflector->invoke($this->arguments);
     } catch (KalturaAPIException $e) {
         if ($actionInfo->returnType != 'file') {
             throw $e;
         }
         KalturaResponseCacher::adjustApiCacheForException($e);
         $res = new kRendererDieError($e->getCode(), $e->getMessage());
     }
     kEventsManager::flushEvents();
     KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
     KalturaLog::debug("Dispatch took - " . (microtime(true) - $start) . " seconds, memory: " . memory_get_peak_usage(true));
     return $res;
 }
 /**
  * Function tpo retrieve a specific KalturaServiceActionItem from the cache by a service ID and action ID.
  * If the item was not found, it is retrieved from the services map and cached.
  * @param string $serviceId
  * @param string $actionId
  * @throws KalturaAPIException
  * @return KalturaServiceActionItem
  */
 public static function retrieveServiceActionItem($serviceId, $actionId)
 {
     if (function_exists('apc_fetch')) {
         $apcFetchSuccess = null;
         $serviceItemFromCache = apc_fetch($serviceId, $apcFetchSuccess);
         if ($apcFetchSuccess && $serviceItemFromCache[KalturaServicesMap::SERVICES_MAP_MODIFICATION_TIME] == self::getServiceMapModificationTime()) {
             return $serviceItemFromCache["serviceActionItem"];
         }
     }
     // load the service reflector
     $serviceMap = self::getMap();
     if (!isset($serviceMap[$serviceId])) {
         KalturaLog::crit("Service does not exist!");
         throw new KalturaAPIException(KalturaErrors::SERVICE_DOES_NOT_EXISTS, $serviceId);
     }
     // check if action exists
     if (!$actionId) {
         KalturaLog::crit("Action not specified!");
         throw new KalturaAPIException(KalturaErrors::ACTION_NOT_SPECIFIED, $serviceId);
     }
     $reflector = $serviceMap[$serviceId];
     if (function_exists('apc_store')) {
         $servicesMapLastModTime = self::getServiceMapModificationTime();
         $success = apc_store($serviceId, array("serviceActionItem" => $serviceMap[$serviceId], KalturaServicesMap::SERVICES_MAP_MODIFICATION_TIME => $servicesMapLastModTime));
     }
     return $reflector;
 }
Exemplo n.º 9
0
 public function getExceptionObject($ex)
 {
     if ($ex instanceof KalturaAPIException) {
         KalturaLog::err($ex);
         $object = $ex;
     } else {
         if ($ex instanceof APIException) {
             $args = $ex->extra_data;
             $reflectionException = new ReflectionClass("KalturaAPIException");
             $ex = $reflectionException->newInstanceArgs($args);
             KalturaLog::err($ex);
             $object = $ex;
         } else {
             if ($ex instanceof kCoreException) {
                 switch ($ex->getCode()) {
                     case kCoreException::MAX_CATEGORY_DEPTH_REACHED:
                         KalturaLog::err($ex);
                         $object = new KalturaAPIException(KalturaErrors::MAX_CATEGORY_DEPTH_REACHED, category::MAX_CATEGORY_DEPTH);
                         break;
                     case kCoreException::MAX_NUMBER_OF_CATEGORIES_REACHED:
                         KalturaLog::err($ex);
                         $object = new KalturaAPIException(KalturaErrors::MAX_NUMBER_OF_CATEGORIES_REACHED, Partner::MAX_NUMBER_OF_CATEGORIES);
                         break;
                     case kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED:
                         KalturaLog::err($ex);
                         $object = new KalturaAPIException(KalturaErrors::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED, Partner::MAX_ACCESS_CONTROLS);
                         break;
                     case kCoreException::MAX_CATEGORIES_PER_ENTRY:
                         KalturaLog::err($ex);
                         $object = new KalturaAPIException(KalturaErrors::MAX_CATEGORIES_FOR_ENTRY_REACHED, entry::MAX_CATEGORIES_PER_ENTRY);
                         break;
                     default:
                         KalturaLog::crit($ex);
                         $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
                 }
             } else {
                 KalturaLog::crit($ex);
                 $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
             }
         }
     }
     return $object;
 }
Exemplo n.º 10
0
 protected function initConfig($language = null)
 {
     KalturaLog::debug(__METHOD__ . "()");
     $languages = array($language ? $language : self::DEFAULT_LANGUAGE);
     // now we read the ini files with the texts
     // NOTE: '=' signs CANNOT be used inside the ini files, instead use "<EQ>"
     $rootdir = realpath(dirname(__FILE__) . '');
     foreach ($languages as $language) {
         if (!isset($this->texts_array[$language])) {
             $filename = $rootdir . "/emails_" . $language . ".ini";
             KalturaLog::debug('ini filename = ' . $filename);
             if (!file_exists($filename)) {
                 KalturaLog::crit('Fatal:::: Cannot find file: ' . $filename);
                 continue;
             }
             $ini_array = parse_ini_file($filename, true);
             $this->texts_array[$language] = array('subjects' => $ini_array['subjects'], 'bodies' => $ini_array['bodies'], 'common_text' => $ini_array['common_text']);
         }
     }
 }
Exemplo n.º 11
0
 private static function initPartnerUserObjects()
 {
     if (self::$ksPartnerId == Partner::BATCH_PARTNER_ID) {
         self::$operatingPartner = null;
         self::$operatingPartnerId = self::$ksPartnerId;
         return;
     }
     $ksPartner = null;
     $requestedPartner = null;
     // init ks partner = operating partner
     if (!is_null(self::$ksPartnerId)) {
         $ksPartner = PartnerPeer::retrieveByPK(self::$ksPartnerId);
         if (!$ksPartner) {
             KalturaLog::crit('Unknown partner id [' . self::$ksPartnerId . ']');
             throw new kCoreException("Unknown partner Id [" . self::$ksPartnerId . "]", kCoreException::ID_NOT_FOUND);
         }
     }
     // init requested partner
     if (!is_null(self::$requestedPartnerId)) {
         $requestedPartner = PartnerPeer::retrieveByPK(self::$requestedPartnerId);
         if (!$requestedPartner) {
             KalturaLog::crit('Unknown partner id [' . self::$requestedPartnerId . ']');
             throw new kCoreException("Unknown partner Id [" . self::$requestedPartnerId . "]", kCoreException::ID_NOT_FOUND);
         }
     }
     // init current kuser
     if (self::$ksUserId && !self::$kuser) {
         // will never be null because ks::uid is never null
         kuserPeer::setUseCriteriaFilter(false);
         self::$kuser = kuserPeer::getActiveKuserByPartnerAndUid(self::$ksPartnerId, self::$ksUserId);
         kuserPeer::setUseCriteriaFilter(true);
         if (!self::$kuser) {
             self::$kuser = null;
             // error not thrown to support adding users 'on-demand'
             // current session will get default role according to session type (user/admin)
         }
     }
     // choose operating partner!
     if ($ksPartner) {
         self::$operatingPartner = $ksPartner;
         self::$operatingPartnerId = $ksPartner->getId();
     } else {
         if (!self::$ksString && $requestedPartner) {
             self::$operatingPartner = $requestedPartner;
             self::$operatingPartnerId = $requestedPartner->getId();
             self::$kuser = null;
         }
     }
 }
Exemplo n.º 12
0
 protected function initConfig()
 {
     KalturaLog::debug(__METHOD__ . "()");
     $cultures = array('en');
     // now we read the ini files with the texts
     // NOTE: '=' signs CANNOT be used inside the ini files, instead use "<EQ>"
     $rootdir = realpath(dirname(__FILE__) . '');
     foreach ($cultures as $culture) {
         $filename = $rootdir . "/emails_" . $culture . ".ini";
         KalturaLog::debug('ini filename = ' . $filename);
         if (!file_exists($filename)) {
             KalturaLog::crit('Fatal:::: Cannot find file: ' . $filename);
             die;
         }
         $ini_array = parse_ini_file($filename, true);
         $this->texts_array[$culture] = array('subjects' => $ini_array['subjects'], 'bodies' => $ini_array['bodies'], 'common_text' => $ini_array['common_text']);
     }
 }
 public function getExceptionObject($ex)
 {
     $this->adjustApiCacheForException($ex);
     if ($ex instanceof KalturaAPIException) {
         KalturaLog::err($ex);
         $object = $ex;
     } else {
         if ($ex instanceof APIException) {
             $args = $ex->extra_data;
             $reflectionException = new ReflectionClass("KalturaAPIException");
             $ex = $reflectionException->newInstanceArgs($args);
             KalturaLog::err($ex);
             $object = $ex;
         } else {
             if ($ex instanceof kCoreException) {
                 switch ($ex->getCode()) {
                     case kCoreException::INVALID_KS:
                         $object = new KalturaAPIException(KalturaErrors::INVALID_KS, $ex->getData(), ks::INVALID_STR, 'INVALID_STR');
                         break;
                     case kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED:
                         $object = new KalturaAPIException(KalturaErrors::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED, $ex->getData());
                         break;
                     case kCoreException::MAX_CATEGORIES_PER_ENTRY:
                         $object = new KalturaAPIException(KalturaErrors::MAX_CATEGORIES_FOR_ENTRY_REACHED, entry::MAX_CATEGORIES_PER_ENTRY);
                         break;
                     case kCoreException::SEARCH_TOO_GENERAL:
                         throw new KalturaAPIException(KalturaErrors::SEARCH_TOO_GENERAL);
                         break;
                     case kCoreException::SOURCE_FILE_NOT_FOUND:
                         $object = new KalturaAPIException(KalturaErrors::SOURCE_FILE_NOT_FOUND);
                         break;
                     case APIErrors::INVALID_ACTIONS_LIMIT:
                         $object = new KalturaAPIException(APIErrors::INVALID_ACTIONS_LIMIT);
                         break;
                     case APIErrors::PRIVILEGE_IP_RESTRICTION:
                         $object = new KalturaAPIException(APIErrors::PRIVILEGE_IP_RESTRICTION);
                         break;
                     case APIErrors::INVALID_SET_ROLE:
                         $object = new KalturaAPIException(APIErrors::INVALID_SET_ROLE);
                         break;
                     case APIErrors::UNKNOWN_ROLE_ID:
                         $object = new KalturaAPIException(APIErrors::UNKNOWN_ROLE_ID);
                         break;
                     case APIErrors::SEARCH_ENGINE_QUERY_FAILED:
                         $object = new KalturaAPIException(APIErrors::SEARCH_ENGINE_QUERY_FAILED);
                         break;
                     default:
                         KalturaLog::crit($ex);
                         $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
                 }
             } else {
                 if ($ex instanceof PropelException) {
                     KalturaLog::alert($ex);
                     $object = new KalturaAPIException(KalturaErrors::INTERNAL_DATABASE_ERROR);
                 } else {
                     KalturaLog::crit($ex);
                     $object = new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
                 }
             }
         }
     }
     return $object;
 }
Exemplo n.º 14
0
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     // append Msn specific report statistics
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     if (!$distributionProfile) {
         return KalturaLog::err('Distribution profile #' . $entryDistribution->getDistributionProfileId() . ' not found');
     }
     if (!$distributionProfile instanceof MsnDistributionProfile) {
         return KalturaLog::crit('Distribution profile #' . $entryDistribution->getDistributionProfileId() . ' is not instanceof MsnDistributionProfile');
     }
     $mrss->addChild('csid', $distributionProfile->getCsId());
     $mrss->addChild('source', $distributionProfile->getSource());
     $mrss->addChild('source_friendly_name', $distributionProfile->getSourceFriendlyName());
     $mrss->addChild('page_group', $distributionProfile->getPageGroup());
     $mrss->addChild('msnvideo_cat', $distributionProfile->getMsnvideoCat());
     $mrss->addChild('msnvideo_top', $distributionProfile->getMsnvideoTop());
     $mrss->addChild('msnvideo_top_cat', $distributionProfile->getMsnvideoTopCat());
 }