<?php

/**
 * @package deployment
 * @subpackage live.liveStream
 *
 * Create email-notification and custom-data profile on partner 99
 *
 * No need to re-run after server code deploy
 */
chdir(__DIR__);
require_once __DIR__ . '/../bootstrap.php';
$realRun = isset($argv[1]) && $argv[1] == 'realrun';
KalturaStatement::setDryRun(!$realRun);
const FEATURE_TVINCI_INGEST_BASE = 'FEATURE_TVINCI_INGEST_V';
function createMetadataProfile($version, $versionToXsdMap)
{
    $metadataProfile = new MetadataProfile();
    $metadataProfile->setPartnerId(99);
    $metadataProfile->setStatus(MetadataProfile::STATUS_ACTIVE);
    $metadataProfile->setName('Tvinci ingest v' . $version);
    $metadataProfile->setSystemName('TvinciIngestV' . $version);
    $metadataProfile->setDescription('Tvinci ingest schema version ' . $version);
    $metadataProfile->setObjectType(MetadataObjectType::ENTRY);
    $metadataProfile->setRequiredCopyTemplatePermissions(FEATURE_TVINCI_INGEST_BASE . $version);
    $metadataProfile->save();
    $xsdData = $versionToXsdMap[$version];
    $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
    kFileSyncUtils::file_put_contents($key, $xsdData);
    kMetadataManager::parseProfileSearchFields($metadataProfile->getPartnerId(), $metadataProfile);
}
Ejemplo n.º 2
0
	'Content Uploader' => 'CONTENT_MANAGE_ENTRY_USERS'.
*/
require_once dirname(__FILE__) . '/../../bootstrap.php';
if ($argc < 3) {
    echo 'usage: php ' . $_SERVER['SCRIPT_NAME'] . ' {partner_id / \'null\'} {role_name} {permission_names} {realrun / dryrun}' . PHP_EOL;
    exit(-1);
}
$page = 500;
$dryRun = true;
if (in_array('realrun', $argv)) {
    $dryRun = false;
    KalturaLog::debug('Using real run mode');
} else {
    KalturaLog::debug('Using dry run mode');
}
KalturaStatement::setDryRun($dryRun);
$partnerId = $argv[1] == 'null' ? null : $argv[1];
$roleName = $argv[2];
$parmissionNames = explode(',', $argv[3]);
$criteria = new Criteria();
if (!is_null($partnerId)) {
    $criteria->addAnd(UserRolePeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
}
$criteria->addAnd(UserRolePeer::NAME, $roleName, Criteria::EQUAL);
$criteria->addAscendingOrderByColumn(UserRolePeer::ID);
$criteria->setLimit($page);
$userRoles = UserRolePeer::doSelect($criteria);
while (count($userRoles)) {
    KalturaLog::info("[" . count($userRoles) . "] user roles .");
    foreach ($userRoles as $userRole) {
        foreach ($parmissionNames as $parmissionName) {
Ejemplo n.º 3
0
 protected static function init()
 {
     kEventsManager::enableDeferredEvents(false);
     MetadataProfilePeer::setUseCriteriaFilter(false);
     MetadataPeer::setUseCriteriaFilter(false);
     entryPeer::setUseCriteriaFilter(false);
     uiConfPeer::setUseCriteriaFilter(false);
     assetPeer::setUseCriteriaFilter(false);
     PartnerPeer::setUseCriteriaFilter(false);
     FileSyncPeer::setUseCriteriaFilter(false);
     $options = getopt('hrl:p:o:b:e:', array('real-run', 'error-objects', 'old-versions', 'blocked-partners', 'files'));
     if (isset($options['h'])) {
         self::failWrongInputs();
     }
     if (isset($options['blocked-partners'])) {
         self::$deleteDeletedPartnersFileSyncs = true;
     }
     if (isset($options['error-objects'])) {
         self::$deleteErrorObjects = true;
     }
     if (isset($options['old-versions'])) {
         self::$deleteOldVersions = true;
     }
     if (isset($options['files'])) {
         self::$purgeDeletedFileSyncs = true;
     }
     if (isset($options['r']) || isset($options['real-run'])) {
         self::$dryRun = false;
     }
     KalturaStatement::setDryRun(self::$dryRun);
     $cacheFilePath = kConf::get('cache_root_path') . '/scripts/deleteOldContent.cache';
     if (file_exists($cacheFilePath)) {
         $cache = unserialize(file_get_contents($cacheFilePath));
         if (isset($cache['oldVersionsStartUpdatedAt'])) {
             self::$oldVersionsStartUpdatedAt = $cache['oldVersionsStartUpdatedAt'];
         }
         if (isset($cache['purgeStartUpdatedAt'])) {
             self::$purgeStartUpdatedAt = $cache['purgeStartUpdatedAt'];
         }
     }
     if (!self::$purgeStartUpdatedAt) {
         $criteria = new Criteria();
         $criteria->add(FileSyncPeer::UPDATED_AT, 0, Criteria::GREATER_THAN);
         $criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
         $criteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_DELETED);
         $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
         $stmt = FileSyncPeer::doSelectStmt($criteria);
         $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (count($mins)) {
             self::$purgeStartUpdatedAt = reset($mins);
         }
     }
     if (is_null(self::$purgeStartUpdatedAt)) {
         self::$purgeStartUpdatedAt = 0;
     }
     self::$purgeNextStartUpdatedAt = self::$purgeStartUpdatedAt;
     $oldVersionsUpdatedAtPeriod = 30;
     // days
     if (isset($options['o'])) {
         if (!is_numeric($options['o']) || $options['o'] < 0) {
             self::failWrongInputs("Period of old versions to delete must be positive numeric of days");
         }
         $oldVersionsUpdatedAtPeriod = $options['o'];
     }
     foreach (self::$oldVersionsStartUpdatedAt as $objectType => $oldVersionsStartUpdatedAt) {
         self::$oldVersionsEndUpdatedAt[$objectType] = $oldVersionsStartUpdatedAt + $oldVersionsUpdatedAtPeriod * 60 * 60 * 24;
     }
     // days
     $purgeUpdatedAtPeriod = 30;
     // days
     if (isset($options['p'])) {
         if (!is_numeric($options['p']) || $options['p'] < 0) {
             self::failWrongInputs("Period of purge must be positive numeric of days");
         }
         $purgeUpdatedAtPeriod = $options['p'];
     }
     self::$purgeEndUpdatedAt = self::$purgeStartUpdatedAt + $purgeUpdatedAtPeriod * 60 * 60 * 24;
     // days
     $oldPartnersUpdatedAtPeriod = 24;
     // months
     if (isset($options['b'])) {
         if (!is_numeric($options['b']) || $options['b'] < 0) {
             self::failWrongInputs("Period of blocked partners to delete must be positive numeric of months");
         }
         $oldPartnersUpdatedAtPeriod = $options['b'];
     }
     self::$oldPartnersUpdatedAt = time() - $oldPartnersUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     $errObjectsUpdatedAtPeriod = 24;
     // months
     if (isset($options['e'])) {
         if (!is_numeric($options['e']) || $options['e'] < 0) {
             self::failWrongInputs("Period of error objects to delete must be positive numeric of months");
         }
         $errObjectsUpdatedAtPeriod = $options['e'];
     }
     self::$errObjectsUpdatedAt = time() - $errObjectsUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     if (isset($options['l'])) {
         if (!is_numeric($options['l']) || $options['l'] < 0) {
             self::failWrongInputs("Limit querymust be positive numeric value");
         }
         self::$queryLimit = $options['l'];
     }
 }
        $categoryEntriesCriteria->add(categoryEntryPeer::ENTRY_ID, $entry->getId());
        $categoryEntriesCriteria->add(categoryEntryPeer::CATEGORY_ID, $categoryIds, Criteria::IN);
        $stmt = categoryEntryPeer::doSelectStmt($categoryEntriesCriteria);
        $categoryEntriesIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
        KalturaStatement::setDryRun($dryRun);
        foreach ($categories as $category) {
            /* @var $category category */
            $entryId = $entry->getId();
            $categoryId = $category->getId();
            if (in_array($categoryId, $categoryEntriesIds)) {
                KalturaLog::debug("CategoryEntry already exists for entry [{$entryId}] and category [{$categoryId}]");
                continue;
            }
            $categoryEntry = new migrationCategoryEntry();
            $categoryEntry->setEntryId($entryId);
            $categoryEntry->setCategoryId($categoryId);
            $categoryEntry->setPartnerId($entry->getPartnerId());
            $categoryEntry->setCategoryFullIds($category->getFullIds());
            $categoryEntry->setStatus(CategoryEntryStatus::ACTIVE);
            $categoryEntry->save();
        }
        KalturaStatement::setDryRun(false);
        $lastIntId = $entry->getIntId();
        KalturaLog::info("Migrated entry [" . $entry->getId() . "] with int id [{$lastIntId}].");
    }
    kMemoryManager::clearMemory();
    $nextCriteria = clone $criteria;
    $nextCriteria->add(entryPeer::INT_ID, $lastIntId, Criteria::GREATER_THAN);
    $entries = entryPeer::doSelect($nextCriteria);
}
KalturaLog::info("Done");
Ejemplo n.º 5
0
 /**
  * @param bool $dryRun
  */
 public static function setDryRun($dryRun)
 {
     self::$dryRun = $dryRun;
 }
<?php

chdir(dirname(__FILE__));
require_once dirname(__FILE__) . '/../bootstrap.php';
$partnerId = null;
if ($argc > 1 && is_numeric($argv[1])) {
    $partnerId = $argv[1];
}
if (in_array('dryRun', $argv)) {
    KalturaStatement::setDryRun(true);
}
$batchClient = new myBatchPartnerUsage($partnerId);
KalturaLog::debug('Done.');
Ejemplo n.º 7
0
<?php

ini_set('memory_limit', '1024M');
if ($argc < 3) {
    die($argv[0] . " <Partner ID> <comma,separated,asset,Ids> <dry-run|real-run>.\n");
}
$partnerId = $argv[1];
$entryIds = $argv[2];
$entryIdsArray = explode(',', trim($entryIds));
require_once __DIR__ . '/../bootstrap.php';
KalturaStatement::setDryRun($argv[3] !== 'real-run');
if (!PartnerPeer::retrieveByPK($partnerId)) {
    die("Partner ID not found.\n");
}
$c = new Criteria();
$c->add(assetPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
$c->add(assetPeer::STATUS, entryStatus::DELETED, Criteria::EQUAL);
$c->add(assetPeer::ID, $entryIdsArray, Criteria::IN);
assetPeer::setUseCriteriaFilter(false);
$assets = assetPeer::doSelect($c);
foreach ($assets as $deletedAsset) {
    echo 'LOG: Changing status of asset ' . $deletedAsset->getId() . ' to: ' . asset::ASSET_STATUS_READY . ".\n";
    $deletedAsset->setStatus(asset::ASSET_STATUS_READY);
    $deletedAsset->save();
    assetPeer::clearInstancePool();
    FileSyncPeer::setUseCriteriaFilter(false);
    $assetSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
    $assetfileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($assetSyncKey);
    foreach ($assetfileSyncs as $assetfileSync) {
        if ($assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_DELETED || $assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_PURGED) {
            $file_full_path = $assetfileSync->getFullPath();