Пример #1
0
 public function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     EmailIngestionProfilePeer::clearInstancePool();
     entryPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     flavorAssetPeer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     flavorParamsOutputPeer::clearInstancePool();
     flavorParamsPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     notificationPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     // TODO clear default filters
     // TODO call all memory cleaner plugins
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
Пример #2
0
 public function save(PropelPDO $con = null)
 {
     if ($this->isColumnModified(accessControlPeer::DELETED_AT)) {
         if ($this->isDefault === true) {
             throw new Exception("Default access control profile can't be deleted");
         }
         $c = new Criteria();
         $c->add(entryPeer::ACCESS_CONTROL_ID, $this->getId());
         $entryCount = entryPeer::doCount($c);
         if ($entryCount > 0) {
             throw new Exception("Access control profile is linked with entries and can't be deleted");
         }
     }
     if ($this->isNew()) {
         $c = new Criteria();
         $c->add(accessControlPeer::PARTNER_ID, $this->partner_id);
         $count = accessControlPeer::doCount($c);
         if ($count >= Partner::MAX_ACCESS_CONTROLS) {
             throw new kCoreException("Max number of access control profiles was reached", kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED);
         }
     }
     parent::save($con);
     // set this conversion profile as partners default
     $partner = PartnerPeer::retrieveByPK($this->partner_id);
     if ($partner && $this->isDefault === true) {
         $partner->setDefaultAccessControlId($this->getId());
         $partner->save();
     }
 }
Пример #3
0
 public static function setDefaultCriteriaFilter()
 {
     if (self::$s_criteria_filter == null) {
         self::$s_criteria_filter = new criteriaFilter();
     }
     $c = new Criteria();
     $c->add(self::DELETED_AT, null, Criteria::EQUAL);
     self::$s_criteria_filter->setFilter($c);
 }
 public function preInsert(PropelPDO $con = null)
 {
     $c = new Criteria();
     $c->add(accessControlPeer::PARTNER_ID, $this->getPartnerId());
     $count = accessControlPeer::doCount($c);
     $partner = PartnerPeer::retrieveByPK($this->getPartnerId());
     $maxAccessControls = $partner->getAccessControls();
     if ($count >= $maxAccessControls) {
         throw new kCoreException("Max number of access control profiles [{$maxAccessControls}] was reached", kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED, $maxAccessControls);
     }
     return parent::preInsert($con);
 }
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $accessControlFilter = $this->toObject();
     $c = new Criteria();
     $accessControlFilter->attachToCriteria($c);
     $totalCount = accessControlPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = accessControlPeer::doSelect($c);
     $list = KalturaAccessControlArray::fromDbArray($dbList, $responseProfile);
     $response = new KalturaAccessControlListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Пример #6
0
 public static function copyAccessControls(Partner $fromPartner, Partner $toPartner)
 {
     $copiedList = array();
     KalturaLog::log("Copying access control profiles from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "]");
     $c = new Criteria();
     $c->add(accessControlPeer::PARTNER_ID, $fromPartner->getId());
     $accessControls = accessControlPeer::doSelect($c);
     foreach ($accessControls as $accessControl) {
         $newAccessControl = $accessControl->copy();
         $newAccessControl->setPartnerId($toPartner->getId());
         $newAccessControl->save();
         KalturaLog::log("Copied [" . $accessControl->getId() . "], new id is [" . $newAccessControl->getId() . "]");
         $copiedList[$accessControl->getId()] = $newAccessControl->getId();
     }
     $toPartner->save();
     // make sure access control profile is set on the new partner
     if (!$toPartner->getDefaultAccessControlId()) {
         $fromPartnerAccessControl = $fromPartner->getDefaultAccessControlId();
         if ($fromPartnerAccessControl && key_exists($fromPartnerAccessControl, $copiedList)) {
             $toPartner->setDefaultAccessControlId($copiedList[$fromPartnerAccessControl]);
             $toPartner->save();
         }
     }
 }
Пример #7
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(accessControlPeer::DATABASE_NAME);
         $criteria->add(accessControlPeer::ID, $pks, Criteria::IN);
         $objs = accessControlPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Пример #8
0
 public function getaccessControl(PropelPDO $con = null)
 {
     if (!$this->getParentEntryId()) {
         return accessControlPeer::retrieveByPK($this->access_control_id, $con);
     }
     $parentEntry = $this->getParentEntry();
     if ($parentEntry) {
         return $parentEntry->getaccessControl($con);
     }
     return null;
 }
 public function getFieldNameFromPeer($field_name)
 {
     $res = accessControlPeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
Пример #10
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = accessControlPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPartnerId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDescription($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setUpdatedAt($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setDeletedAt($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSiteRestrictType($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setSiteRestrictList($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setCountryRestrictType($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCountryRestrictList($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setKsRestrictPrivilege($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setPrvRestrictPrivilege($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setPrvRestrictLength($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setKdirRestrictType($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setCustomData($arr[$keys[15]]);
     }
 }
Пример #11
0
 /**
  * Delete Access Control Profile by id
  * 
  * @action delete
  * @param int $id
  */
 function deleteAction($id)
 {
     $dbAccessControl = accessControlPeer::retrieveByPK($id);
     if (!$dbAccessControl) {
         throw new KalturaAPIException(KalturaErrors::ACCESS_CONTROL_ID_NOT_FOUND, $id);
     }
     if ($dbAccessControl->getIsDefault()) {
         throw new KalturaAPIException(KalturaErrors::CANNOT_DELETE_DEFAULT_ACCESS_CONTROL);
     }
     $dbAccessControl->setDeletedAt(time());
     try {
         $dbAccessControl->save();
     } catch (kCoreException $e) {
         $code = $e->getCode();
         switch ($code) {
             case kCoreException::EXCEEDED_MAX_ENTRIES_PER_ACCESS_CONTROL_UPDATE_LIMIT:
                 throw new KalturaAPIException(KalturaErrors::EXCEEDED_ENTRIES_PER_ACCESS_CONTROL_FOR_UPDATE, $id);
             case kCoreException::NO_DEFAULT_ACCESS_CONTROL:
                 throw new KalturaAPIException(KalturaErrors::CANNOT_TRANSFER_ENTRIES_TO_ANOTHER_ACCESS_CONTROL_OBJECT);
             default:
                 throw $e;
         }
     }
 }
Пример #12
0
 /**
  * Get the associated accessControl object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     accessControl The associated accessControl object.
  * @throws     PropelException
  */
 public function getaccessControl(PropelPDO $con = null)
 {
     if ($this->aaccessControl === null && $this->access_control_id !== null) {
         $this->aaccessControl = accessControlPeer::retrieveByPk($this->access_control_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aaccessControl->addentrys($this);
         		 */
     }
     return $this->aaccessControl;
 }
        $this->policyId = $policyId;
    }
}
$permCrit = new Criteria();
$permCrit->add(PermissionPeer::NAME, 'PLAYREADY_PLUGIN_PERMISSION', Criteria::EQUAL);
$permCrit->addAnd(PermissionPeer::STATUS, 1, Criteria::EQUAL);
$permissions = PermissionPeer::doSelect($permCrit);
$partners = array();
foreach ($permissions as $perm) {
    $partners[] = $perm->getPartnerId();
}
KalturaLog::debug("Partners are '" . print_r($partners, true) . "'");
$c = new Criteria();
$c->add(accessControlPeer::PARTNER_ID, $partners, Criteria::IN);
$c->addAnd(accessControlPeer::RULES, '%kAccessControlPlayReadyPolicyAction%', Criteria::LIKE);
$acs = accessControlPeer::doSelect($c);
foreach ($acs as $ac) {
    KalturaLog::debug("checking access control '" . $ac->getId() . "'");
    $rules = $ac->getRulesArray();
    foreach ($rules as $rule) {
        $actions = $rule->getActions();
        $j = 0;
        foreach ($actions as $action) {
            KalturaLog::debug("checking action '" . print_r($action, true) . "'");
            if (get_class($action) == 'kAccessControlPlayReadyPolicyAction') {
                KalturaLog::debug("replacing kAccessControlPlayReadyPolicyAction with kAccessControlDrmPolicyAction");
                $newAction = new kAccessControlDrmPolicyAction();
                $newAction->setPolicyId($action->getPolicyId());
                $actions[$j] = $newAction;
                $rule->setActions($actions);
                $ac->setRulesArray($rules);
Пример #14
0
 /**
  * Selects a collection of entry objects pre-filled with all related objects except conversionProfile2.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of entry objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptconversionProfile2(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     entryPeer::addSelectColumns($criteria);
     $startcol2 = entryPeer::NUM_COLUMNS - entryPeer::NUM_LAZY_LOAD_COLUMNS;
     kshowPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (kshowPeer::NUM_COLUMNS - kshowPeer::NUM_LAZY_LOAD_COLUMNS);
     kuserPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (kuserPeer::NUM_COLUMNS - kuserPeer::NUM_LAZY_LOAD_COLUMNS);
     accessControlPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + (accessControlPeer::NUM_COLUMNS - accessControlPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(entryPeer::KSHOW_ID, kshowPeer::ID, $join_behavior);
     $criteria->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, $join_behavior);
     $criteria->addJoin(entryPeer::ACCESS_CONTROL_ID, accessControlPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = entryPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = entryPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = entryPeer::getOMClass($row, 0);
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             entryPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined kshow rows
         $key2 = kshowPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = kshowPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = kshowPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 kshowPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (entry) to the collection in $obj2 (kshow)
             $obj2->addentry($obj1);
         }
         // if joined row is not null
         // Add objects for joined kuser rows
         $key3 = kuserPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = kuserPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = kuserPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 kuserPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (entry) to the collection in $obj3 (kuser)
             $obj3->addentry($obj1);
         }
         // if joined row is not null
         // Add objects for joined accessControl rows
         $key4 = accessControlPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = accessControlPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = accessControlPeer::getOMClass(false);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 accessControlPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (entry) to the collection in $obj4 (accessControl)
             $obj4->addentry($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Пример #15
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(accessControlPeer::DATABASE_NAME);
     $criteria->add(accessControlPeer::ID, $this->id);
     if ($this->alreadyInSave) {
         if ($this->isColumnModified(accessControlPeer::CUSTOM_DATA)) {
             if (!is_null($this->custom_data_md5)) {
                 $criteria->add(accessControlPeer::CUSTOM_DATA, "MD5(cast(" . accessControlPeer::CUSTOM_DATA . " as char character set latin1)) = '{$this->custom_data_md5}'", Criteria::CUSTOM);
             } else {
                 $criteria->add(accessControlPeer::CUSTOM_DATA, NULL, Criteria::ISNULL);
             }
         }
         if (count($this->modifiedColumns) == 2 && $this->isColumnModified(accessControlPeer::UPDATED_AT)) {
             $theModifiedColumn = null;
             foreach ($this->modifiedColumns as $modifiedColumn) {
                 if ($modifiedColumn != accessControlPeer::UPDATED_AT) {
                     $theModifiedColumn = $modifiedColumn;
                 }
             }
             $atomicColumns = accessControlPeer::getAtomicColumns();
             if (in_array($theModifiedColumn, $atomicColumns)) {
                 $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
             }
         }
     }
     return $criteria;
 }
Пример #16
0
<?php

require_once dirname(__FILE__) . '/../bootstrap.php';
$limit = 200;
if ($argc > 1) {
    $limit = $argv[1];
}
$criteria = new Criteria();
if ($argc < 3 || intval($argv[2])) {
    $criteria->add(accessControlPeer::RULES, null, Criteria::ISNULL);
}
$criteria->addAscendingOrderByColumn(accessControlPeer::ID);
$criteria->setLimit($limit);
$accessControls = accessControlPeer::doSelect($criteria);
while (count($accessControls)) {
    echo "Migrating [" . count($accessControls) . "] access control profiles." . PHP_EOL;
    $lastId = null;
    foreach ($accessControls as $accessControl) {
        /* @var $accessControl accessControl */
        $accessControl->setRulesArray($accessControl->getRulesArray(true));
        $accessControl->save();
        $lastId = $accessControl->getId();
        echo "Migrated access control profile [{$lastId}]." . PHP_EOL;
    }
    kMemoryManager::clearMemory();
    $nextCriteria = clone $criteria;
    $nextCriteria->add(accessControlPeer::ID, $lastId, Criteria::GREATER_THAN);
    $accessControls = accessControlPeer::doSelect($nextCriteria);
}
echo "Done." . PHP_EOL;
 public static function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     kuserPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     entryPeer::clearInstancePool();
     //	    kvotePeer::clearInstancePool();
     //	    commentPeer::clearInstancePool();
     //	    flagPeer::clearInstancePool();
     //	    favoritePeer::clearInstancePool();
     //	    KshowKuserPeer::clearInstancePool();
     //	    MailJobPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     ControlPanelCommandPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     //	    PriorityGroupPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     //	    blockedEmailPeer::clearInstancePool();
     //	    conversionPeer::clearInstancePool();
     //	    flickrTokenPeer::clearInstancePool();
     PuserKuserPeer::clearInstancePool();
     //	    PuserRolePeer::clearInstancePool();
     PartnerPeer::clearInstancePool();
     //	    WidgetLogPeer::clearInstancePool();
     //	    adminKuserPeer::clearInstancePool();
     //	    notificationPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     //	    widgetPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     //	    PartnerStatsPeer::clearInstancePool();
     //	    PartnerActivityPeer::clearInstancePool();
     ConversionProfilePeer::clearInstancePool();
     //	    ConversionParamsPeer::clearInstancePool();
     //	    KceInstallationErrorPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     accessControlPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     assetParamsPeer::clearInstancePool();
     assetParamsOutputPeer::clearInstancePool();
     assetPeer::clearInstancePool();
     conversionProfile2Peer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     //	    SystemUserPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     //	    EmailIngestionProfilePeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     //	    invalidSessionPeer::clearInstancePool();
     DynamicEnumPeer::clearInstancePool();
     UserLoginDataPeer::clearInstancePool();
     PermissionPeer::clearInstancePool();
     UserRolePeer::clearInstancePool();
     PermissionItemPeer::clearInstancePool();
     PermissionToPermissionItemPeer::clearInstancePool();
     KuserToUserRolePeer::clearInstancePool();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaMemoryCleaner');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->cleanMemory();
     }
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
 public function validateForUpdate($sourceObject, $propertiesToSkip = array())
 {
     /* @var $sourceObject accessControl */
     $this->validatePropertyMinMaxLength('name', 1, 128, true);
     $this->validate();
     if ($this->systemName) {
         $c = KalturaCriteria::create(accessControlPeer::OM_CLASS);
         $c->add(accessControlPeer::ID, $sourceObject->getId(), Criteria::NOT_EQUAL);
         $c->add(accessControlPeer::SYSTEM_NAME, $this->systemName);
         if (accessControlPeer::doCount($c)) {
             throw new KalturaAPIException(KalturaErrors::SYSTEM_NAME_ALREADY_EXISTS, $this->systemName);
         }
     }
     return parent::validateForUpdate($sourceObject, $propertiesToSkip);
 }
Пример #19
0
 /**
  * Throws an error if trying to set invalid Access Control Profile
  * 
  * @param KalturaBaseEntry $entry
  */
 protected function validateAccessControlId(KalturaBaseEntry $entry)
 {
     if ($entry->accessControlId !== null) {
         $this->applyPartnerFilterForClass('accessControl');
         $accessControl = accessControlPeer::retrieveByPK($entry->accessControlId);
         if (!$accessControl) {
             throw new KalturaAPIException(KalturaErrors::ACCESS_CONTROL_ID_NOT_FOUND, $entry->accessControlId);
         }
     }
 }
Пример #20
0
 /**
  * @return AccessControl
  */
 public function getApiAccessControl()
 {
     $id = $this->getApiAccessControlId();
     if ($id) {
         return accessControlPeer::retrieveByPK($id);
     } else {
         return null;
     }
 }
Пример #21
0
 public function validateObjectsExist(entry $sourceObject = null)
 {
     $this->validateConversionProfile($sourceObject);
     if (!is_null($this->accessControlId)) {
         $accessControlProfile = accessControlPeer::retrieveByPK($this->accessControlId);
         if (!$accessControlProfile) {
             throw new KalturaAPIException(KalturaErrors::ACCESS_CONTROL_ID_NOT_FOUND, $this->accessControlId);
         }
     }
 }
Пример #22
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(accessControlPeer::DATABASE_NAME);
     $criteria->add(accessControlPeer::ID, $this->id);
     if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(accessControlPeer::UPDATED_AT)) {
         $theModifiedColumn = null;
         foreach ($this->modifiedColumns as $modifiedColumn) {
             if ($modifiedColumn != accessControlPeer::UPDATED_AT) {
                 $theModifiedColumn = $modifiedColumn;
             }
         }
         $atomicColumns = accessControlPeer::getAtomicColumns();
         if (in_array($theModifiedColumn, $atomicColumns)) {
             $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
         }
     }
     return $criteria;
 }
 /**
  * List Access Control Profiles by filter and pager
  * 
  * @action list
  * @param KalturaFilterPager $filter
  * @param KalturaAccessControlFilter $pager
  * @return KalturaAccessControlListResponse
  */
 function listAction(KalturaAccessControlFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaAccessControlFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $accessControlFilter = new accessControlFilter();
     $filter->toObject($accessControlFilter);
     $c = new Criteria();
     $accessControlFilter->attachToCriteria($c);
     $totalCount = accessControlPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = accessControlPeer::doSelect($c);
     $list = KalturaAccessControlArray::fromDbArray($dbList);
     $response = new KalturaAccessControlListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Пример #24
0
 /**
  * Validate the amount of core and plugin objects found on the template partner.
  * @param Partner $templatePartner
  */
 private function validateTemplatePartner(Partner $templatePartner)
 {
     //access control profiles
     $c = new Criteria();
     $c->add(accessControlPeer::PARTNER_ID, $templatePartner->getId());
     $count = accessControlPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_ac_profiles')) {
         throw new kCoreException("Template partner's number of [accessControlProfiles] objects exceed allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     //categories
     categoryPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(categoryPeer::PARTNER_ID, $templatePartner->getId());
     $c->addAnd(categoryPeer::STATUS, CategoryStatus::ACTIVE);
     $count = categoryPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_categories')) {
         throw new kCoreException("Template partner's number of [category] objects exceed allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     categoryPeer::setUseCriteriaFilter(true);
     //conversion profiles
     $c = new Criteria();
     $c->add(conversionProfile2Peer::PARTNER_ID, $templatePartner->getId());
     $count = conversionProfile2Peer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_conversion_profiles')) {
         throw new kCoreException("Template partner's number of [conversionProfile] objects exceeds allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     //entries
     entryPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $templatePartner->getId());
     $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
     $c->addAnd(entryPeer::STATUS, entryStatus::READY);
     $count = entryPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_entries')) {
         throw new kCoreException("Template partner's number of MEDIA_CLIP objects exceed allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     entryPeer::setUseCriteriaFilter(true);
     //playlists
     entryPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $templatePartner->getId());
     $c->addAnd(entryPeer::TYPE, entryType::PLAYLIST);
     $c->addAnd(entryPeer::STATUS, entryStatus::READY);
     $count = entryPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_playlists')) {
         throw new kCoreException("Template partner's number of PLAYLIST objects exceed allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     entryPeer::setUseCriteriaFilter(true);
     //flavor params
     $c = new Criteria();
     $c->add(assetParamsPeer::PARTNER_ID, $templatePartner->getId());
     $count = assetParamsPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_flavor_params')) {
         throw new kCoreException("Template partner's number of [flavorParams] objects exceeds allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     //uiconfs
     uiConfPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(uiConfPeer::PARTNER_ID, $templatePartner->getId());
     $c->addAnd(uiConfPeer::OBJ_TYPE, array(uiConf::UI_CONF_TYPE_KDP3, uiConf::UI_CONF_TYPE_WIDGET), Criteria::IN);
     $c->addAnd(uiConfPeer::STATUS, uiConf::UI_CONF_STATUS_READY);
     $count = uiConfPeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_ui_confs')) {
         throw new kCoreException("Template partner's number of [uiconf] objects exceeds allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     uiConfPeer::setUseCriteriaFilter(true);
     //user roles
     UserRolePeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(UserRolePeer::PARTNER_ID, $templatePartner->getId(), Criteria::EQUAL);
     $c->addAnd(UserRolePeer::STATUS, UserRoleStatus::ACTIVE, Criteria::EQUAL);
     $count = UserRolePeer::doCount($c);
     if ($count > kConf::get('copy_partner_limit_user_roles')) {
         throw new kCoreException("Template partner's number of [userRole] objects exceed allowed limit", kCoreException::TEMPLATE_PARTNER_COPY_LIMIT_EXCEEDED);
     }
     UserRolePeer::setUseCriteriaFilter(true);
     $validatorPlugins = KalturaPluginManager::getPluginInstances('IKalturaObjectValidator');
     foreach ($validatorPlugins as $validatorPlugins) {
         $validatorPlugins->validateObject($templatePartner, IKalturaObjectValidator::OPERATION_COPY);
     }
 }