Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2v7, teams, automation script #12979

Open
wants to merge 4 commits into
base: Ursa-21.4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
/**
* enable feature for each partner with exclusions
* examples:
* php enablePermissionForPartnersWithExclusions.php 2946661,133402,30832,133302 realrun
*
* @package Deployment
* @subpackage updates
*/

$dryRun = true;
if (in_array ( 'realrun', $argv ))
{
$dryRun = false;
}

$countLimitEachLoop = 500;
$freePackages = [1,100,101,102,103];
$offset = $countLimitEachLoop;

if ($argc >= 2)
{
$permissionName = $argv[1];
$partnersToExclude = explode(',', $argv[2]);
}
else
{
echo 'usage: php ' . $_SERVER ['SCRIPT_NAME'] . ' {partners_to_exclude} [realrun]' . PHP_EOL;
die;
}


//------------------------------------------------------


require_once(dirname ( __FILE__ ) . '/../../bootstrap.php');

$con = myDbHelper::getConnection ( myDbHelper::DB_HELPER_CONN_PROPEL2 );
KalturaStatement::setDryRun ( $dryRun );

$c = new Criteria();
$c->addAscendingOrderByColumn(PartnerPeer::ID);
$c->addAnd(PartnerPeer::ID, 99, Criteria::GREATER_THAN);
$c->addAnd(PartnerPeer::STATUS,1, Criteria::EQUAL);
$c->setLimit($countLimitEachLoop);
$partners = PartnerPeer::doSelect ( $c, $con );

while (count($partners))
{
foreach ( $partners as $partner )
{
/* @var $partner partner */
$v2v7Permission = PermissionPeer::getByNameAndPartner(PermissionName::FEATURE_V2_V7_REDIRECT, $partner->getId());
if (!$v2v7Permission)
{
$v2v7Permission = new Permission ();
$v2v7Permission->setType(PermissionType::SPECIAL_FEATURE);
$v2v7Permission->setPartnerId($partner->getId());
$v2v7Permission->setName(PermissionName::FEATURE_V2_V7_REDIRECT);
danbar0kal marked this conversation as resolved.
Show resolved Hide resolved
$v2v7Permission->setStatus(PermissionStatus::ACTIVE);
$v2v7Permission->save();
KalturaLog::debug('Set permission [' . PermissionName::FEATURE_V2_V7_REDIRECT . '] for partner id [' . $partner->getId() . ']');
}
elseif ($v2v7Permission->getStatus() != PermissionStatus::ACTIVE)
{
$v2v7Permission->setStatus(PermissionStatus::ACTIVE);
$v2v7Permission->save();
KalturaLog::debug('Set permission [' . PermissionName::FEATURE_V2_V7_REDIRECT . '] for partner id [' . $partner->getId() . ']');
}

if (!$partner->getIsSelfServe() && !in_array($partner->getPartnerPackage(), $freePackages))
{
$automationManagerPermission = PermissionPeer::getByNameAndPartner(PermissionName::FEATURE_MEDIA_REPURPOSING_NG_PERMISSION, $partner->getId());
if (!$automationManagerPermission)
{
$automationManagerPermission = new Permission ();
$automationManagerPermission->setType(PermissionType::SPECIAL_FEATURE);
$automationManagerPermission->setPartnerId($partner->getId());
$automationManagerPermission->setName(PermissionName::FEATURE_MEDIA_REPURPOSING_NG_PERMISSION);
danbar0kal marked this conversation as resolved.
Show resolved Hide resolved
$automationManagerPermission->setStatus(PermissionStatus::ACTIVE);
$automationManagerPermission->save();
KalturaLog::debug('Set permission [' . PermissionName::FEATURE_MEDIA_REPURPOSING_NG_PERMISSION . '] for partner id [' . $partner->getId() . ']');
}
elseif ($automationManagerPermission->getStatus() != PermissionStatus::ACTIVE)
{
$automationManagerPermission->setStatus(PermissionStatus::ACTIVE);
$automationManagerPermission->save();
KalturaLog::debug('Set permission [' . PermissionName::FEATURE_MEDIA_REPURPOSING_NG_PERMISSION . '] for partner id [' . $partner->getId() . ']');
}


if (!in_array($partner->getId(), $partnersToExclude))
{
$teamsPermission = PermissionPeer::getByNameAndPartner('FEATURE_TEAMS_RECORDING_UPLOAD_PERMISSION', $partner->getId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding 'FEATURE_TEAMS_RECORDING_UPLOAD_PERMISSION' as Enum at PermissionName.php

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this permission is not in PermissionName.php. i had to reference to it like this

if (!$teamsPermission)
{
$teamsPermission = new Permission ();
$teamsPermission->setType(PermissionType::SPECIAL_FEATURE);
$teamsPermission->setPartnerId($partner->getId());
$teamsPermission->setName($permissionName);
danbar0kal marked this conversation as resolved.
Show resolved Hide resolved
$teamsPermission->setStatus(PermissionStatus::ACTIVE);
$teamsPermission->save();
KalturaLog::debug('Set permission [FEATURE_TEAMS_RECORDING_UPLOAD_PERMISSION] for partner id [' . $partner->getId() . ']');
}
elseif ($teamsPermission->getStatus() != PermissionStatus::ACTIVE)
{
$teamsPermission->setStatus(PermissionStatus::ACTIVE);
$teamsPermission->save();
KalturaLog::debug('Set permission [FEATURE_TEAMS_RECORDING_UPLOAD_PERMISSION] for partner id [' . $partner->getId() . ']');
}
}
}
}

kMemoryManager::clearMemory();
$c = new Criteria ();
$c->add (PartnerPeer::STATUS, Partner::PARTNER_STATUS_ACTIVE, Criteria::EQUAL);
$c->add (PartnerPeer::ID, 99, Criteria::GREATER_EQUAL);
$c->addAscendingOrderByColumn (PartnerPeer::ID);
$c->setLimit ($countLimitEachLoop);
$c->setOffset($offset);

$partners = PartnerPeer::doSelect ( $c, $con );
$offset += $countLimitEachLoop;
}
print("Done");