Пример #1
0
 private static function initPartnerUserObjects()
 {
     if (self::$ksPartnerId == Partner::BATCH_PARTNER_ID) {
         self::$operatingPartner = null;
         self::$operatingPartnerId = self::$ksPartnerId;
         return;
     }
     $ksPartner = null;
     $requestedPartner = null;
     // init ks partner = operating partner
     if (!is_null(self::$ksPartnerId)) {
         $ksPartner = PartnerPeer::retrieveByPK(self::$ksPartnerId);
         if (!$ksPartner) {
             KalturaLog::crit('Unknown partner id [' . self::$ksPartnerId . ']');
             throw new kCoreException("Unknown partner Id [" . self::$ksPartnerId . "]", kCoreException::ID_NOT_FOUND);
         }
     }
     // init requested partner
     if (!is_null(self::$requestedPartnerId)) {
         $requestedPartner = PartnerPeer::retrieveByPK(self::$requestedPartnerId);
         if (!$requestedPartner) {
             KalturaLog::crit('Unknown partner id [' . self::$requestedPartnerId . ']');
             throw new kCoreException("Unknown partner Id [" . self::$requestedPartnerId . "]", kCoreException::ID_NOT_FOUND);
         }
     }
     // init current kuser
     if (self::$ksUserId && !self::$kuser) {
         // will never be null because ks::uid is never null
         kuserPeer::setUseCriteriaFilter(false);
         self::$kuser = kuserPeer::getActiveKuserByPartnerAndUid(self::$ksPartnerId, self::$ksUserId);
         kuserPeer::setUseCriteriaFilter(true);
         if (!self::$kuser) {
             self::$kuser = null;
             // error not thrown to support adding users 'on-demand'
             // current session will get default role according to session type (user/admin)
         }
     }
     // choose operating partner!
     if ($ksPartner) {
         self::$operatingPartner = $ksPartner;
         self::$operatingPartnerId = $ksPartner->getId();
     } else {
         if (!self::$ksString && $requestedPartner) {
             self::$operatingPartner = $requestedPartner;
             self::$operatingPartnerId = $requestedPartner->getId();
             self::$kuser = null;
         }
     }
 }