Example #1
0
function createSphinxConnection($sphinxServer, $port = 9312)
{
    $dsn = "mysql:host={$sphinxServer};port={$port};";
    try {
        $con = new PDO($dsn);
        return $con;
    } catch (PropelException $pex) {
        KalturaLog::alert($pex->getMessage());
        throw new PropelException("Database error");
    }
}
 /**
  * @param Metadata $metadata
  * @param SimpleXMLElement $mrss
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contributeMetadata(Metadata $metadata, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null)
 {
     $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
     $xml = kFileSyncUtils::file_get_contents($key, true, false);
     if (is_null($xml)) {
         KalturaLog::alert("ready file sync was not found for key[{$key}]");
         return;
     }
     $metadataXml = new SimpleXMLElement($xml);
     $customData = $mrss->addChild('customData');
     $customData->addAttribute('metadataId', $metadata->getId());
     $customData->addAttribute('metadataVersion', $metadata->getVersion());
     $customData->addAttribute('metadataProfileId', $metadata->getMetadataProfileId());
     $customData->addAttribute('metadataProfileVersion', $metadata->getMetadataProfileVersion());
     $this->contributeMetadataObject($customData, $metadataXml, $mrssParams, '');
 }
Example #3
0
 public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaConditionArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         $nObj = self::getInstanceByDbObject($obj);
         if (!$nObj) {
             KalturaLog::alert("Object [" . get_class($obj) . "] type [" . $obj->getType() . "] could not be translated to API object");
             continue;
         }
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
Example #4
0
 public function execute($input_parameters = null)
 {
     if (!kQueryCache::isCurrentQueryHandled()) {
         kApiCache::disableConditionalCache();
     }
     $search = array();
     $replace = array();
     if (is_null($input_parameters)) {
         $search = array_reverse(array_keys($this->values));
         $replace = array_reverse($this->values);
     } else {
         $i = 1;
         foreach ($input_parameters as $value) {
             $search[] = ':p' . $i++;
             if (is_null($value)) {
                 $replace[] = "NULL";
             } else {
                 $replace[] = "'{$value}'";
             }
         }
         $search = array_reverse($search);
         $replace = array_reverse($replace);
     }
     $sql = str_replace($search, $replace, $this->queryString);
     KalturaLog::debug($sql);
     $sqlStart = microtime(true);
     if (self::$dryRun && !preg_match('/^(\\/\\*.+\\*\\/ )?SELECT/i', $sql)) {
         KalturaLog::debug("Sql dry run - " . (microtime(true) - $sqlStart) . " seconds");
     } else {
         try {
             parent::execute($input_parameters);
         } catch (PropelException $pex) {
             KalturaLog::alert($pex->getMessage());
             throw new PropelException("Database error");
         }
         $sqlTook = microtime(true) - $sqlStart;
         KalturaLog::debug("Sql took - " . $sqlTook . " seconds");
         KalturaMonitorClient::monitorDatabaseAccess($sql, $sqlTook);
     }
 }
 public function execute($input_parameters = null)
 {
     if (class_exists('KalturaResponseCacher')) {
         KalturaResponseCacher::disableConditionalCache();
     }
     $search = array();
     $replace = array();
     if (is_null($input_parameters)) {
         $search = array_reverse(array_keys($this->values));
         $replace = array_reverse($this->values);
     } else {
         $i = 1;
         foreach ($input_parameters as $value) {
             $search[] = ':p' . $i++;
             if (is_null($value)) {
                 $replace[] = "NULL";
             } else {
                 $replace[] = "'{$value}'";
             }
         }
         $search = array_reverse($search);
         $replace = array_reverse($replace);
     }
     $sql = str_replace($search, $replace, $this->queryString);
     KalturaLog::debug($sql);
     $sqlStart = microtime(true);
     if (self::$dryRun) {
         KalturaLog::debug("Sql dry run - " . (microtime(true) - $sqlStart) . " seconds");
     } else {
         try {
             parent::execute($input_parameters);
         } catch (PropelException $pex) {
             KalturaLog::alert($pex->getMessage());
             throw new PropelException("Database error");
         }
         KalturaLog::debug("Sql took - " . (microtime(true) - $sqlStart) . " seconds");
     }
 }
    /* (non-PHPdoc)
     * @see categoryEntry::postInsert()
     */
    public function postInsert(PropelPDO $con = null)
    {
        // DO nothing - don't increase category entries count
    }
}
$partnerId = null;
$startEntryIntId = null;
$limit = null;
$page = 200;
$dryRun = false;
if ($argc == 1 || strtolower($argv[1]) != 'realrun') {
    $dryRun = true;
    KalturaLog::alert('Using dry run mode');
}
if ($argc > 2) {
    $partnerId = $argv[2];
}
if ($argc > 3) {
    $startEntryIntId = $argv[3];
}
if ($argc > 4) {
    $limit = $argv[4];
}
$criteria = new Criteria();
$criteria->addAscendingOrderByColumn(entryPeer::INT_ID);
if ($partnerId) {
    $criteria->add(entryPeer::PARTNER_ID, $partnerId);
}
Example #7
0
 public function setFullName($v)
 {
     // full_name column is deprecated
     KalturaLog::alert('Field [full_name] on object [kuser] is deprecated');
     list($firstName, $lastName) = kString::nameSplit($v);
     $this->setFirstName($firstName);
     $this->setLastName($lastName);
 }
 public function execute($add_extra_debug_data = true)
 {
     date_default_timezone_set(kConf::get("date_default_timezone"));
     // TODO - remove for production - use some configuration to determine
     kConfigTable::$should_use_cache = false;
     $start_impl = $end_impl = 0;
     $nocache = false;
     if ($this->getP("nocache")) {
         $nocache = true;
         $this->logMessage("Not using cache!");
         objectWrapperBase::useCache(false);
     }
     $add_benchmarks = $this->getP("add_benchmarks", false);
     // while testing our system - will match each service agains its description
     // $this->matchInDescription();
     $this->msg = array();
     $this->error = array();
     $this->debug = array();
     $start_time = microtime(true);
     $start = microtime(true);
     $this->benchmarkStart("beforeImpl");
     $this->response_type = $this->getP("format", self::DEFAULT_FORMAT);
     //
     /*
     		$should_debug = $this->getP ( "should_debug" , true );
     		if ( $should_debug == "false" ) $this->should_debug  = false;
     */
     if ($this->should_debug && $add_extra_debug_data) {
         $this->benchmarkStart("signature");
         $sig_type = $this->getP("sigtype", self::SIG_TYPE_POST);
         $signature_params = self::getParamsFromSigType($sig_type);
         $signatura_valid = self::validateSignature($signature_params);
         $this->benchmarkEnd("signature");
         $this->addDebug("sigtype", $sig_type);
         $this->addDebug("validateSignature", $signatura_valid);
         $this->addDebug("signature", self::signature($signature_params));
         //			$this->addDebug( "rawsignature" , self::signature( $signature_params , false ) );
     }
     $partner_id = $this->getP("partner_id");
     if (!$partner_id) {
         $partner_id = $this->getP("partnerId");
     }
     $subp_id = $this->getP("subp_id");
     if (!$subp_id) {
         $subp_id = $this->getP("subpId");
     }
     $puser_id = $this->getP("uid");
     $ks_str = $this->getP("ks");
     if ($ks_str == "{ks}") {
         $ks_str = "";
     }
     // if the client DIDN'T replace the dynamic ks - ignore it
     // the $execution_cache_key can be used by services to cache the results depending on the inpu parameters
     // if the $execution_cache_key is not null, the rendere will search for the result of the rendering depending on the $execution_cache_key
     // if it doesn't find it - it will create it (per format) and store it for next time
     $execution_cache_key = null;
     // moved the renderer here to see if has the $execution_cache_key and if so - skip the implementation
     $renderer = new kalturaWebserviceRenderer($this->response_context);
     $private_partner_data = false;
     try {
         try {
             $arr = list($partner_id, $subp_id, $uid, $private_partner_data) = $this->validateTicketSetPartner($partner_id, $subp_id, $puser_id, $ks_str);
         } catch (Exception $ex) {
             KalturaLog::log('validateTicketSetPartner failed - not caching response');
             defPartnerservices2baseAction::disableCache();
             throw $ex;
         }
         // if PS2 permission validation is enabled for the current partner, only the actions defined in kConf's parameter "ps2_actions_not_blocked_by_permissions" will be allowed
         $currentPartner = $this->getPartner();
         if ($currentPartner && $currentPartner->getEnabledService(PermissionName::FEATURE_PS2_PERMISSIONS_VALIDATION)) {
             if (!in_array(strtolower(get_class($this)), kConf::get('ps2_actions_not_blocked_by_permissions'))) {
                 KalturaLog::log('PS2 action ' . get_class($this) . ' is being blocked for partner ' . $currentPartner->getId() . ' defined with FEATURE_PS2_PERMISSIONS_VALIDATION enabled');
                 $this->addException(APIErrors::SERVICE_FORBIDDEN, get_class($this));
             }
         }
         $this->private_partner_data = $private_partner_data;
         //print_r ( $arr );
         // TODO - validate the matchIp is ok with the user's IP
         $this->validateIp();
         // most services should not attempt to cache the results - for them this will return null
         $execution_cache_key = $this->getExecutionCacheKeyWrapper($partner_id, $subp_id, $puser_id);
         // if the key is not null - it will be used in the renderer for using the cotent from the cache
         if ($nocache) {
             $renderer->deleteCacheKey($execution_cache_key, $this->response_type);
         } else {
             $renderer->setCacheKey($execution_cache_key);
         }
         if (!$renderer->hasContentForCacheKey($this->response_type)) {
             $this->benchmarkStart("applyPartnerFilters");
             //init entitlement before set the default criteire by myPartnerUtils::applyPartnerFilters
             kEntitlementUtils::initEntitlementEnforcement();
             // apply filters for Criteria so there will be no chance of exposure of date from other partners !
             // TODO - add the parameter for allowing kaltura network
             myPartnerUtils::applyPartnerFilters($partner_id, $private_partner_data, $this->partnerGroup2(), $this->kalturaNetwork2());
             $this->benchmarkEnd("applyPartnerFilters");
             $this->benchmarkStart("puserKuser");
             list($partner_id, $subp_id, $puser_id, $partner_prefix) = $this->preparePartnerPuserDetails($partner_id, $subp_id, $puser_id);
             $puser_kuser = $this->getPuserKuser($partner_id, $subp_id, $puser_id);
             $this->benchmarkEnd("puserKuser");
             $this->benchmarkEnd("beforeImpl");
             // ----------------------------- impl --------------------------
             $start_impl = microtime(true);
             $result = $this->executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser);
             $end_impl = microtime(true);
             kEventsManager::flushEvents();
         } else {
             /// the renderer claims to have the desired result ! just flow down the code ... ;)
         }
         // ----------------------------- impl --------------------------
     } catch (APIException $api_ex) {
         $message = $api_ex->getMessage();
         if ($this->should_debug && $message) {
             $this->addError(APIErrors::SERVERL_ERROR, "[{$message}]");
         } elseif ($api_ex->api_code) {
             call_user_func_array(array(&$this, 'addError'), $api_ex->extra_data);
             //				$this->addError ( $api_ex->api_code ,$api_ex->extra_data );
         }
     } catch (PropelException $pex) {
         KalturaLog::alert($pex->getMessage());
         $this->addError(APIErrors::INTERNAL_DATABASE_ERROR);
     } catch (Exception $ex) {
         $this->addError(APIErrors::INTERNAL_SERVERL_ERROR, $ex->getMessage());
         KalturaLog::err($ex->getMessage());
     }
     $execute_impl_end_time = microtime(true);
     // render according to the format_type
     $res = array();
     $this->addMsg("serverTime", time());
     $res['result'] = $this->msg;
     $res['error'] = $this->error;
     if ($this->should_debug) {
         // this specific debug line should be used
         $this->addDebug("execute_impl_time", $end_impl - $start_impl);
         $this->addDebug("execute_time", $execute_impl_end_time - $start_time);
         // will be used as a place holder and will be replaced after the rendering.
         if ($add_extra_debug_data) {
             $this->addDebug("total_time", self::__TOTAL_TIME__);
         }
         if ($add_benchmarks && count($this->benchmarks) > 0) {
             $this->addDebug("host", @$_ENV["HOSTNAME"]);
             $this->addDebug("benchmarks", $this->getBenchmarks());
         }
         $res['debug'] = $this->debug;
     }
     // ignore all the errors and debug - the first msg is the only html used
     if ($this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_HTML) {
         $res = "<html>";
         foreach ($this->msg as $html_bit) {
             $res .= $html_bit;
         }
         $res .= "</html>";
     }
     if ($this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_MRSS) {
         // in case of mRss - render only the result not the errors ot the debug
         list($response, $content_type) = $renderer->renderDataInRequestedFormat($res['result'], $this->response_type, true, self::$escape_text);
     } else {
         list($response, $content_type) = $renderer->renderDataInRequestedFormat($res, $this->response_type, true, self::$escape_text);
     }
     $end_time = microtime(true);
     if (is_string($response)) {
         $this->logMessage("Rendereing took: [" . ($end_time - $start_time) . "] seconds. Response size [" . strlen($response) . "]", SF_LOG_WARNING);
         $this->logMessage($response, SF_LOG_WARNING);
     } else {
         $this->logMessage("Rendereing took: [" . ($end_time - $start_time) . "]");
     }
     if ($this->should_debug && $add_extra_debug_data) {
         // fix the total time including the render time
         $str_time = (string) ($end_time - $start_time);
         if ($this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP) {
             // replcate the placehoder with the real execution time
             // this is a nasty hack - we replace the serialized PHP value - the length of the placeholder is 14 characters
             // the length of the str_time can be less - replace the whole string phrase
             $replace_string = 's:' . strlen($str_time) . ':"' . $str_time;
             $response = str_replace('s:14:"' . self::__TOTAL_TIME__, $replace_string, $response);
         } elseif ($this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_ARRAY || $this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_OBJECT) {
             // the $response is not a string - we can't just replace it
             $res["debug"]["total_time"] = $str_time;
         } elseif ($this->response_type == kalturaWebserviceRenderer::RESPONSE_TYPE_MRSS) {
             // do nothing to the result
         } else {
             $response = str_replace(self::__TOTAL_TIME__, $str_time, $response);
         }
     }
     header("Access-Control-Allow-Origin:*");
     // avoid html5 xss issues
     $this->setContentType($content_type);
     // while testing our system - will match each service agains its description
     // $this->matchOutDescription();
     return $response;
 }
 public function query()
 {
     if (class_exists('KalturaResponseCacher')) {
         KalturaResponseCacher::disableConditionalCache();
     }
     $args = func_get_args();
     $sql = $args[0];
     KalturaLog::debug($sql);
     $comment = $this->getCommentWrapped();
     $sql = $comment . $sql;
     $sqlStart = microtime(true);
     try {
         if (version_compare(PHP_VERSION, '5.3', '<')) {
             $result = call_user_func_array(array($this, 'parent::query'), $args);
         } else {
             $result = call_user_func_array('parent::query', $args);
         }
     } catch (PropelException $pex) {
         KalturaLog::alert($pex->getMessage());
         throw new PropelException("Database error");
     }
     KalturaLog::debug("Sql took - " . (microtime(true) - $sqlStart) . " seconds");
     return $result;
 }
 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;
 }
Example #11
0
 private static function getPermissions($roleId)
 {
     $map = self::initEmptyMap();
     // get cache dirty time
     $roleCacheDirtyAt = 0;
     if (self::$operatingPartner) {
         $roleCacheDirtyAt = self::$operatingPartner->getRoleCacheDirtyAt();
     }
     // get role from cache
     $roleCacheKey = self::getRoleIdKey($roleId, self::$operatingPartnerId);
     $cacheRole = self::getFromCache($roleCacheKey, $roleCacheDirtyAt);
     // compare updatedAt between partner dirty flag and cache
     if ($cacheRole) {
         return $cacheRole;
         // initialization from cache finished
     }
     // cache is not updated - delete stored value and re-init from DB
     $dbRole = null;
     if (!is_null($roleId)) {
         UserRolePeer::setUseCriteriaFilter(false);
         $dbRole = UserRolePeer::retrieveByPK($roleId);
         UserRolePeer::setUseCriteriaFilter(true);
         if (!$dbRole) {
             KalturaLog::alert('User role ID [' . $roleId . '] set for user ID [' . self::$ksUserId . '] of partner [' . self::$operatingPartnerId . '] was not found in the DB');
             throw new kPermissionException('User role ID [' . $roleId . '] set for user ID [' . self::$ksUserId . '] of partner [' . self::$operatingPartnerId . '] was not found in the DB', kPermissionException::ROLE_NOT_FOUND);
         }
     }
     $map = self::getPermissionsFromDb($dbRole);
     // update cache
     $cacheRole = array('updatedAt' => time(), 'mapHash' => md5(serialize($map)));
     self::storeInCache($roleCacheKey, $cacheRole, $map);
     return $map;
 }
require_once ROOT_DIR . '/api_v3/bootstrap.php';
PermissionPeer::clearInstancePool();
PermissionItemPeer::clearInstancePool();
//-- Script start
// define all items
$permissionItems = array(array('object' => 'KalturaBaseEntry', 'parameter' => 'startDate', 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_SCHEDULE), array('object' => 'KalturaBaseEntry', 'parameter' => 'startDate', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_SCHEDULE), array('object' => 'KalturaBaseEntry', 'parameter' => 'endDate', 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_SCHEDULE), array('object' => 'KalturaBaseEntry', 'parameter' => 'endDate', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_SCHEDULE), array('object' => 'KalturaBaseEntry', 'parameter' => 'accessControlId', 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_ACCESS_CONTROL), array('object' => 'KalturaBaseEntry', 'parameter' => 'accessControlId', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_ACCESS_CONTROL), array('object' => 'KalturaBaseEntry', 'parameter' => 'categories', 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_ASSIGN_CATEGORIES . ',' . PermissionName::USER_SESSION_PERMISSION), array('object' => 'KalturaBaseEntry', 'parameter' => 'categories', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_ASSIGN_CATEGORIES . ',' . PermissionName::USER_SESSION_PERMISSION), array('object' => 'KalturaBaseEntry', 'parameter' => 'categoriesIds', 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_ASSIGN_CATEGORIES . ',' . PermissionName::USER_SESSION_PERMISSION), array('object' => 'KalturaBaseEntry', 'parameter' => 'categoriesIds', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_ASSIGN_CATEGORIES . ',' . PermissionName::USER_SESSION_PERMISSION), array('object' => 'KalturaBaseEntry', 'parameter' => 'name', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_METADATA . ',' . PermissionName::USER_SESSION_PERMISSION . ',' . PermissionName::CONTENT_MODERATE_METADATA), array('object' => 'KalturaBaseEntry', 'parameter' => 'tags', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_METADATA . ',' . PermissionName::USER_SESSION_PERMISSION . ',' . PermissionName::CONTENT_MODERATE_METADATA), array('object' => 'KalturaBaseEntry', 'parameter' => 'description', 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_METADATA . ',' . PermissionName::USER_SESSION_PERMISSION . ',' . PermissionName::CONTENT_MODERATE_METADATA), array('object' => 'KalturaLiveStreamAdminEntry', 'parameter' => kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER, 'action' => ApiParameterPermissionItemAction::READ, 'permission' => PermissionName::CONTENT_MANAGE_BASE), array('object' => 'KalturaLiveStreamAdminEntry', 'parameter' => kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER, 'action' => ApiParameterPermissionItemAction::INSERT, 'permission' => PermissionName::CONTENT_MANAGE_BASE), array('object' => 'KalturaLiveStreamAdminEntry', 'parameter' => kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER, 'action' => ApiParameterPermissionItemAction::UPDATE, 'permission' => PermissionName::CONTENT_MANAGE_BASE), array('object' => 'KalturaPartner', 'parameter' => 'secret', 'action' => ApiParameterPermissionItemAction::READ, 'permission' => PermissionName::INTEGRATION_BASE), array('object' => 'KalturaPartner', 'parameter' => 'adminSecret', 'action' => ApiParameterPermissionItemAction::READ, 'permission' => PermissionName::INTEGRATION_BASE));
// add all to required permissions
foreach ($permissionItems as $cur) {
    $item = new kApiParameterPermissionItem();
    $item->setObject($cur['object']);
    $item->setParameter($cur['parameter']);
    $item->setAction($cur['action']);
    $item->setPartnerId(PartnerPeer::GLOBAL_PARTNER);
    $item->save();
    $permissions = $cur['permission'];
    $permissions = explode(',', $permissions);
    foreach ($permissions as $permissionName) {
        if (!$permissionName) {
            continue;
        }
        $permission = PermissionPeer::getByNameAndPartner(trim($permissionName), array(PartnerPeer::GLOBAL_PARTNER));
        if (!$permission) {
            $msg = '***** ERROR - Permission [' . $cur['permission'] . '] not found for item [' . $cur['object'] . '->' . $cur['parameter'] . ']';
            KalturaLog::alert($msg);
            echo $msg . PHP_EOL;
            continue;
        }
        $permission->addPermissionItem($item->getId());
        $permission->save();
    }
}
function getNewRole($oldRoleName, $userRoles)
{
    if (!$oldRoleName) {
        $oldRoleName = 'guest';
    }
    if (!isset($userRoles[$oldRoleName])) {
        KalturaLog::alert('New role name was not found for old role name [' . $oldRoleName . ']');
        return null;
    }
    $c = new Criteria();
    $c->addAnd(UserRolePeer::PARTNER_ID, ADMIN_CONSOLE_PARTNER_ID, Criteria::EQUAL);
    $c->addAnd(UserRolePeer::ID, $userRoles[$oldRoleName]->getId(), Criteria::EQUAL);
    $c->addAnd(UserRolePeer::TAGS, '%admin_console%', Criteria::LIKE);
    UserRolePeer::clearInstancePool();
    UserRolePeer::setUseCriteriaFilter(false);
    $newRole = UserRolePeer::doSelectOne($c);
    UserRolePeer::setUseCriteriaFilter(true);
    if (!$newRole) {
        KalturaLog::alert('Role with id [' . $userRoles[$oldRoleName]->getId() . '] was not found in DB!');
        return null;
    }
    return $newRole;
}
Example #14
0
 public function fromObject($source_object)
 {
     $reflector = KalturaTypeReflectorCacher::get(get_class($this));
     foreach ($this->getMapBetweenObjects() as $this_prop => $object_prop) {
         if (is_numeric($this_prop)) {
             $this_prop = $object_prop;
         }
         if (array_key_exists($object_prop, $source_object->fields)) {
             $value = $source_object->get($object_prop);
             $property = $reflector->getProperty($this_prop);
             if ($property->isDynamicEnum()) {
                 $propertyType = $property->getType();
                 $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                 $value = kPluginableEnumsManager::coreToApi($enumType, $value);
             } elseif ($property->getDynamicType()) {
                 $propertyType = $property->getDynamicType();
                 $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                 $values = explode(',', $value);
                 $finalValues = array();
                 foreach ($values as $val) {
                     $finalValues[] = kPluginableEnumsManager::coreToApi($enumType, $val);
                 }
                 $value = implode(',', $finalValues);
             }
             $this->{$this_prop} = $value;
         } else {
             KalturaLog::alert("field [{$object_prop}] was not found on filter object class [" . get_class($source_object) . "]");
         }
     }
     $newOrderBy = "";
     $orderByMap = $this->getOrderByMap();
     if ($orderByMap) {
         $orderProps = explode(",", $this->orderBy);
         foreach ($orderProps as $prop) {
             $key = array_search($prop, $orderByMap);
             if ($key !== false) {
                 $newOrderBy .= $key . ",";
             }
         }
     }
     if (strpos($newOrderBy, ",") === strlen($newOrderBy) - 1) {
         $newOrderBy = substr($newOrderBy, 0, strlen($newOrderBy) - 1);
     }
     $this->orderBy = $newOrderBy;
     $advancedSearch = $source_object->getAdvancedSearch();
     if (is_object($advancedSearch) && $advancedSearch instanceof AdvancedSearchFilterItem) {
         $apiClass = $advancedSearch->getKalturaClass();
         if (!class_exists($apiClass)) {
             KalturaLog::err("Class [{$apiClass}] not found");
         } else {
             $this->advancedSearch = new $apiClass();
             $this->advancedSearch->fromObject($advancedSearch);
         }
     } else {
         KalturaLog::debug("Advanced search not defined");
     }
 }
 public function toInsertableObject($object_to_fill = null, $props_to_skip = array())
 {
     if (is_null($object_to_fill)) {
         KalturaLog::alert("No object returned from toInsertableObject, object_to_fill [" . get_class($object_to_fill) . "], this [" . get_class($this) . "] line [" . __LINE__ . "]");
         return null;
     }
     $dbObject = parent::toInsertableObject($object_to_fill, $props_to_skip);
     if (!$dbObject) {
         KalturaLog::alert("No object returned from toInsertableObject, object_to_fill [" . get_class($object_to_fill) . "], this [" . get_class($this) . "] line [" . __LINE__ . "]");
         return null;
     }
     $pluginsData = $this->createPluginDataMap();
     $dbObject->setPluginsData($pluginsData);
     return $dbObject;
 }
Example #16
0
$feedProcessingKey = "feedProcessing_{$feedId}_{$entryId}_{$limit}";
if (function_exists('apc_fetch')) {
    if (apc_fetch($feedProcessingKey)) {
        KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST);
    }
}
try {
    $syndicationFeedRenderer = new KalturaSyndicationFeedRenderer($feedId, $feedProcessingKey, $ks);
    $syndicationFeedRenderer->addFlavorParamsAttachedFilter();
    kCurrentContext::$partner_id = $syndicationFeedRenderer->syndicationFeed->partnerId;
    if (isset($entryId)) {
        $syndicationFeedRenderer->addEntryAttachedFilter($entryId);
    }
    $syndicationFeedRenderer->execute($limit);
} catch (PropelException $pex) {
    KalturaLog::alert($pex->getMessage());
    KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST, 'KalturaSyndication: Database error');
} catch (Exception $ex) {
    KalturaLog::err($ex->getMessage());
    $msg = 'KalturaSyndication: ' . str_replace(array("\n", "\r"), array("\t", ''), $ex->getMessage());
    KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST, $msg);
}
//in KalturaSyndicationFeedRenderer - if the limit does restrict the amount of entries - the entries counter passes the limit's value by one , so it must be decreased back
$entriesCount = $syndicationFeedRenderer->getReturnedEntriesCount();
$entriesCount--;
setCacheExpiry($entriesCount, $feedId);
$end = microtime(true);
KalturaLog::info("syndicationFeedRenderer-end [" . ($end - $start) . "] memory: " . memory_get_peak_usage(true));
KalturaLog::debug("<------------------------------------- syndicationFeedRenderer -------------------------------------");
$result = ob_get_contents();
ob_end_clean();
 }
 $new_kuser->setPuserId($user->getEmail());
 $new_kuser->setIsAdmin(true);
 $partnerData = new Kaltura_AdminConsoleUserPartnerData();
 $partnerData->isPrimary = $user->getIsPrimary();
 $partnerData->role = $user->getRole();
 $new_kuser->setPartnerData(serialize($partnerData));
 $c = new Criteria();
 $c->addAnd(UserLoginDataPeer::LOGIN_EMAIL, $user->getEmail());
 $existing_login_data = UserLoginDataPeer::doSelectOne($c);
 if ($existing_login_data) {
     KalturaLog::log('Existing user_login_data record with same email found with id [' . $existing_login_data->getId() . ']');
     if ($existing_login_data->getSalt() == $user->getSalt() && $existing_login_data->getSha1Password() == $user->getSha1Password()) {
         $new_kuser->setLoginDataId($existing_login_data->getId());
     } else {
         KalturaLog::alert('!!! ERROR - Existing user_login_data record with different password found with id [' . $existing_login_data->getId() . '] skipping user id [' . $lastUser . ']');
         echo '!!! ERROR - Existing user_login_data record with different password found with id [' . $existing_login_data->getId() . '] skipping user id [' . $lastUser . ']';
         continue;
     }
 } else {
     $new_login_data->setConfigPartnerId($admin_console_partner_id);
     $new_login_data->setLoginEmail($user->getEmail());
     $new_login_data->setFirstName($user->getFirstName());
     $new_login_data->setLastName($user->getLastName());
     $new_login_data->setSalt($user->getSalt());
     $new_login_data->setSha1Password($user->getSha1Password());
     $new_login_data->setCreatedAt($user->getCreatedAt());
     $new_login_data->setUpdatedAt($user->getUpdatedAt());
     $new_login_data->setLoginBlockedUntil(null);
     $new_login_data->setLoginAttempts(0);
     $new_login_data->setPasswordUpdatedAt(time());
    KalturaLog::log('last user file already exists with value - ' . $lastUser);
}
if (!$lastUser) {
    $lastUser = 0;
}
$users = getAdminUsers($lastUser, $userLimitEachLoop);
while (count($users)) {
    foreach ($users as $user) {
        if (file_exists($stopFile)) {
            die('STOP FILE CREATED');
        }
        $lastUser = $user->getId();
        KalturaLog::log('-- kuser id ' . $lastUser);
        $partner = PartnerPeer::retrieveByPK($user->getPartnerId());
        if (!$partner) {
            KalturaLog::alert('ERROR - cannot find partner id [' . $user->getPartnerId() . '] defined for kuser id [' . $lastUser . '] - skipping user');
            continue;
        }
        if ($partner->getId() == -2) {
            KalturaLog::log('Skipping partner -2 users... will be migrated in a later script');
            continue;
        }
        if ($partner->getId() == PartnerPeer::GLOBAL_PARTNER) {
            KalturaLog::log('Skipping partner 0');
            continue;
        }
        $adminRoleId = $partner->getAdminSessionRoleId();
        $user->setRoleIds($adminRoleId);
        if (!$dryRun) {
            KalturaLog::log('Setting kuser id [' . $user->getId() . '] admin [' . $user->getIsAdmin() . '] with role id [' . $adminRoleId . ']');
            $user->save();
/**
 * Create a special partner group permission for given partner id, or get an existing one
 * @param int $partnerId
 * @param string $partnerGroup
 */
function getOrCreatePartnerGroupPermission($partnerId, $partnerGroup)
{
    $permissionName = 'PARTNER_' . $partnerId . '_GROUP_' . $partnerGroup . '_PERMISSION';
    PermissionPeer::clearInstancePool();
    $c = new Criteria();
    $c->addAnd(PermissionPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
    $c->addAnd(PermissionPeer::NAME, $permissionName, Criteria::EQUAL);
    $c->addAnd(PermissionPeer::TYPE, PermissionType::PARTNER_GROUP, Criteria::EQUAL);
    $permission = PermissionPeer::doSelectOne($c);
    if (!$permission) {
        // create permission if not yet created
        $permission = new Permission();
        $permission->setPartnerId($partnerId);
        $permission->setName($permissionName);
        $permission->setFriendlyName('Partner ' . $partnerId . ' permission for group ' . $partnerGroup);
        $permission->setDescription('Partner ' . $partnerId . ' permission for group ' . $partnerGroup);
        $permission->setType(PermissionType::PARTNER_GROUP);
        $permission->setPartnerGroup($partnerGroup);
        $permission->setStatus(PermissionStatus::ACTIVE);
        $permission->save();
    } else {
        if ($permission->getPartnerGroup() != $partnerGroup) {
            $msg = '***** ERROR - Permission id [' . $permission->getId() . '] partner group [' . $permission->getPartnerGroup() . '] is different from the required partner group [' . $partnerGroup . ']';
            KalturaLog::alert($msg);
            echo $msg . PHP_EOL;
        }
    }
    return $permission;
}
 public function fromObject($object)
 {
     parent::fromObject($object);
     foreach (self::$actions as $action) {
         $actionAttribute = "{$action}Action";
         if (!$this->{$actionAttribute}) {
             $this->{$actionAttribute} = new KalturaGenericDistributionProfileAction();
         }
         $reflector = KalturaTypeReflectorCacher::get(get_class($this->{$actionAttribute}));
         $properties = $reflector->getProperties();
         foreach ($this->{$actionAttribute}->getMapBetweenObjects() as $this_prop => $object_prop) {
             if (is_numeric($this_prop)) {
                 $this_prop = $object_prop;
             }
             if (!isset($properties[$this_prop]) || $properties[$this_prop]->isWriteOnly()) {
                 continue;
             }
             $getter_callback = array($object, "get{$object_prop}");
             if (is_callable($getter_callback)) {
                 $value = call_user_func($getter_callback, $action);
                 if ($properties[$this_prop]->isDynamicEnum()) {
                     $propertyType = $properties[$this_prop]->getType();
                     $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                     $value = kPluginableEnumsManager::coreToApi($enumType, $value);
                 }
                 $this->{$actionAttribute}->{$this_prop} = $value;
             } else {
                 KalturaLog::alert("getter for property [{$object_prop}] was not found on object class [" . get_class($object) . "]");
             }
         }
     }
     $this->updateRequiredEntryFields = implode(',', $object->getUpdateRequiredEntryFields());
     $this->updateRequiredMetadataXPaths = implode(',', $object->getUpdateRequiredMetadataXPaths());
 }
Example #21
0
 protected function getContentTypeFromUrl($url)
 {
     $this->ch = curl_init();
     curl_setopt($this->ch, CURLOPT_URL, $url);
     curl_setopt($this->ch, CURLOPT_HEADER, true);
     curl_setopt($this->ch, CURLOPT_NOBODY, true);
     curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
     $headers = curl_exec($this->ch);
     if (preg_match('/Content-Type: (.*)/', $headers, $matched)) {
         return trim($matched[1]);
     } else {
         KalturaLog::alert('"Content-Type" header was not found for the following URL: ' . $url);
         return null;
     }
 }
Example #22
0
 public static function userFix($error_code, $error_str)
 {
     return;
     KalturaLog::alert("Fatal error: [" . $error_code . "]: " . $error_str);
 }
Example #23
0
 public function toObject($object_to_fill = null, $props_to_skip = array())
 {
     $this->validateForUsage($object_to_fill, $props_to_skip);
     // will check that not useable properties are not set
     $class = get_class($this);
     // enables extension with default empty object
     if (is_null($object_to_fill)) {
         KalturaLog::err("No object supplied for type [{$class}]");
         return null;
     }
     $typeReflector = KalturaTypeReflectorCacher::get($class);
     foreach ($this->getMapBetweenObjects() as $this_prop => $object_prop) {
         if (is_numeric($this_prop)) {
             $this_prop = $object_prop;
         }
         $value = $this->{$this_prop};
         if (is_null($value)) {
             continue;
         }
         if ($props_to_skip && is_array($props_to_skip) && in_array($this_prop, $props_to_skip)) {
             continue;
         }
         $propertyInfo = $typeReflector->getProperty($this_prop);
         if (!$propertyInfo) {
             KalturaLog::alert("property [{$this_prop}] was not found on object class [{$class}]");
             continue;
         }
         if ($value instanceof KalturaNullField) {
             $value = null;
         } elseif ($value instanceof KalturaTypedArray) {
             $value = $value->toObjectsArray();
         } elseif ($propertyInfo->isComplexType() && $value instanceof KalturaObject) {
             $value = $value->toObject();
         } elseif ($propertyInfo->isDynamicEnum()) {
             $propertyType = $propertyInfo->getType();
             $enumType = call_user_func(array($propertyType, 'getEnumClass'));
             $value = kPluginableEnumsManager::apiToCore($enumType, $value);
         } elseif ($propertyInfo->getDynamicType() && strlen($value)) {
             $propertyType = $propertyInfo->getDynamicType();
             $enumType = call_user_func(array($propertyType, 'getEnumClass'));
             $values = explode(',', $value);
             $finalValues = array();
             foreach ($values as $val) {
                 $finalValues[] = kPluginableEnumsManager::apiToCore($enumType, $val);
             }
             $value = implode(',', $finalValues);
         } elseif (is_string($value) && !kXml::isXMLValidContent($value)) {
             throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_CHAR, $this_prop);
         }
         $setter_callback = array($object_to_fill, "set{$object_prop}");
         if (is_callable($setter_callback)) {
             call_user_func_array($setter_callback, array($value));
         } else {
             KalturaLog::alert("setter for property [{$object_prop}] was not found on object class [" . get_class($object_to_fill) . "] defined as property [{$this_prop}] on api class [{$class}]");
         }
     }
     return $object_to_fill;
 }
function addItemToPermissions($item, $permissionNames, $partnerId)
{
    foreach ($permissionNames as $permissionName) {
        PermissionToPermissionItemPeer::clearInstancePool();
        $partnerPermission = array_map('trim', explode('>', $permissionName));
        if (count($partnerPermission) === 2) {
            $partnerId = trim($partnerPermission[0]);
        }
        $permissionName = trim(end($partnerPermission));
        $c = new Criteria();
        $c->addAnd(PermissionPeer::NAME, $permissionName, Criteria::EQUAL);
        $c->addAnd(PermissionPeer::TYPE, array(PermissionType::NORMAL, PermissionType::PARTNER_GROUP), Criteria::IN);
        $c->addAnd(PermissionPeer::PARTNER_ID, array(PartnerPeer::GLOBAL_PARTNER, $item->getPartnerId(), $partnerId), Criteria::IN);
        $permission = PermissionPeer::doSelectOne($c);
        if (!$permission) {
            KalturaLog::alert('ERROR - Permission name [' . $permissionName . '] for partner [' . $item->getPartnerId() . '] not found in database - skipping!');
            continue;
        }
        KalturaLog::log('Adding permission item id [' . $item->getId() . '] to permission id [' . $permission->getId() . ']');
        $permission->addPermissionItem($item->getId(), true);
    }
}
Example #25
0
 /**
  *
  * @param entry $clipEntry new entry to copy and adjust cue points from root entry to
  */
 public static function copyCuePointsToClipEntry(entry $clipEntry)
 {
     $clipAtts = self::getClipAttributesFromEntry($clipEntry);
     if (!is_null($clipAtts)) {
         $sourceEntry = entryPeer::retrieveByPK($clipEntry->getSourceEntryId());
         if (is_null($sourceEntry)) {
             KalturaLog::info("Didn't copy cuePoints for entry [{$clipEntry->getId()}] because source entry [" . $clipEntry->getSourceEntryId() . "] wasn't found");
             return;
         }
         $sourceEntryDuration = $sourceEntry->getLengthInMsecs();
         $clipStartTime = $clipAtts->getOffset();
         if (is_null($clipStartTime)) {
             $clipStartTime = 0;
         }
         $clipDuration = $clipAtts->getDuration();
         if (is_null($clipDuration)) {
             $clipDuration = $sourceEntryDuration;
         }
         $c = new KalturaCriteria();
         $c->add(CuePointPeer::ENTRY_ID, $clipEntry->getSourceEntryId());
         if ($clipDuration < $sourceEntryDuration) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime + $clipDuration, KalturaCriteria::LESS_EQUAL);
         }
         if ($clipStartTime > 0) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime, KalturaCriteria::GREATER_EQUAL);
             $c->addOr(CuePointPeer::START_TIME, 0, KalturaCriteria::EQUAL);
         }
         $c->addAscendingOrderByColumn(CuePointPeer::CREATED_AT);
         $rootEntryCuePointsToCopy = CuePointPeer::doSelect($c);
         if (count($rootEntryCuePointsToCopy) <= self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) {
             foreach ($rootEntryCuePointsToCopy as $cuePoint) {
                 $cuePoint->copyToClipEntry($clipEntry, $clipStartTime, $clipDuration);
             }
         } else {
             KalturaLog::alert("Can't copy cuePoints for entry [{$clipEntry->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]");
         }
     }
 }
 /**
  * 
  * Initializes the framework for all the tests
  */
 protected function initFramework(&$result = null)
 {
     //if we got codeCoverage then we add the rest of the server folders
     $codeCoverageFilter = PHP_CodeCoverage_Filter::getInstance();
     if ($codeCoverageFilter) {
         $testsBaseDir = dirname(__FILE__);
         $whiteList = $codeCoverageFilter->getWhitelist();
         if (!in_array("{$testsBaseDir}/../../api_v3", $whiteList)) {
             //				KalturaLog::debug("Adding" . $testsBaseDir . "/../../api_v3" . "to the CodeCoverage filter\n");
             //$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../api_v3/services");
             //$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../api_v3/lib");
         }
         if (!in_array("{$testsBaseDir}/../../plugins", $whiteList)) {
             //				KalturaLog::debug("Adding" . $testsBaseDir . "/../../plugins" . "to the CodeCoverage filter\n");
             //				$codeCoverageFilter->addDirectoryToWhitelist($testsBaseDir . "/../../plugins");
         }
     }
     if ($result) {
         if ($result instanceof KalturaTestResult) {
             if (!$result->isListenerExists('KalturaTestListener')) {
                 KalturaLog::debug("adding KalturaTestListener to result\n");
                 $result->addListener(new KalturaTestListener());
             }
         }
     }
     if (KalturaTestCaseBase::$isFrameworkInit == false) {
         KalturaLog::debug("Initing framework\n");
         $class = get_class($this);
         $classPath = KAutoloader::getClassFilePath($class);
         KalturaTestListener::setFailureFilePath(dirname($classPath) . "/testsData/{$class}.failures");
         KalturaTestListener::setDataFilePath(dirname($classPath) . "/testsData/{$class}.data");
         KalturaTestListener::setTotalFailureFilePath(KALTURA_TESTS_PATH . "/common/totalFailures.failures");
         $result->addListener(new KalturaTestListener());
         KalturaTestCaseBase::$isFrameworkInit = true;
         //If the test case failures wasn't added
         if (KalturaTestListener::getTestCaseFailures() == null) {
             KalturaTestListener::setCurrentTestCase($class);
             //Then add the test case failure
             KalturaTestListener::setTestCaseFailures(new KalturaTestCaseFailures(KalturaTestListener::getCurrentTestCase()));
             $testCaseFailures = KalturaTestListener::getTestCaseFailures();
             $testProcedureName = $this->getName(false);
             $testProcedure = $testCaseFailures->getTestProcedureFailure($testProcedureName);
             if (!$testProcedure) {
                 $testCaseFailures->addTestProcedureFailure(new KalturaTestProcedureFailure());
             } else {
                 KalturaLog::alert("Test procedure [{$testProcedureName}] already exists");
             }
         }
     }
 }
Example #27
0
 public function query()
 {
     kApiCache::disableConditionalCache();
     $args = func_get_args();
     $sql = $args[0];
     KalturaLog::debug($sql);
     $comment = $this->getCommentWrapped();
     $sql = $comment . $sql;
     $sqlStart = microtime(true);
     try {
         if (version_compare(PHP_VERSION, '5.3', '<')) {
             $result = call_user_func_array(array($this, 'parent::query'), $args);
         } else {
             $result = call_user_func_array('parent::query', $args);
         }
     } catch (PropelException $pex) {
         KalturaLog::alert($pex->getMessage());
         throw new PropelException("Database error");
     }
     $sqlTook = microtime(true) - $sqlStart;
     KalturaLog::debug("Sql took - " . $sqlTook . " seconds");
     KalturaMonitorClient::monitorDatabaseAccess($sql, $sqlTook, $this->hostName);
     return $result;
 }
     continue;
 }
 list($firstName, $lastName) = kString::nameSplit($user->getFullName());
 $c = new Criteria();
 $c->addAnd(UserLoginDataPeer::LOGIN_EMAIL, $user->getEmail());
 $existing_login_data = UserLoginDataPeer::doSelectOne($c);
 if ($existing_login_data) {
     if ($user->getPartnerId() === $existing_login_data->getConfigPartnerId()) {
         $checkKuser = kuserPeer::getByLoginDataAndPartner($existing_login_data->getId(), $user->getPartnerId());
         if ($checkKuser && $checkKuser->getIsAdmin()) {
             KalturaLog::notice('!!! NOTICE - Existing ADMIN login data found with id [' . $existing_login_data->getId() . '] partner [' . $existing_login_data->getConfigPartnerId() . '] - skipping user id [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] since this was probably caused by a bug');
             echo '!!! NOTICE - Existing ADMIN login data found with id [' . $existing_login_data->getId() . '] partner [' . $existing_login_data->getConfigPartnerId() . '] - skipping user id [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] since this was probably caused by a bug';
             continue;
         }
     }
     KalturaLog::alert('!!! ERROR - Existing login data found with id [' . $existing_login_data->getId() . '] partner [' . $existing_login_data->getConfigPartnerId() . '] - skipping user id [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] !!!!');
     echo '!!! ERROR - Existing login data found with id [' . $existing_login_data->getId() . '] partner [' . $existing_login_data->getConfigPartnerId() . '] - skipping user id [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] !!!!';
     continue;
 }
 $new_login_data->setConfigPartnerId($user->getPartnerId());
 $new_login_data->setLoginEmail($user->getEmail());
 $new_login_data->setFirstName($firstName);
 $new_login_data->setLastName($lastName);
 $new_login_data->setSalt($user->getSalt());
 $new_login_data->setSha1Password($user->getSha1Password());
 $new_login_data->setCreatedAt($user->getCreatedAt());
 $new_login_data->setUpdatedAt($user->getUpdatedAt());
 $new_login_data->setLoginBlockedUntil($user->getLoginBlockedUntil());
 $new_login_data->setLoginAttempts($user->getLoginAttempts());
 $new_login_data->setPasswordHashKey($user->getPasswordHashKey());
 $new_login_data->setPasswordUpdatedAt($user->getPasswordUpdatedAt());
Example #29
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);
 }
 /**
  * 
  * Creates a new KalturaTestResult object
  */
 public function __construct(PHP_CodeCoverage $codeCoverage = NULL)
 {
     if (method_exists($this, '__construct')) {
         parent::__construct($codeCoverage);
     } else {
         KalturaLog::alert("Parent don't have __construct method");
     }
 }