/**
  * @param int $partnerId
  * @param string $puserId
  * @param bool $ignore_puser_kuser
  * @return kuser
  */
 public static function getKuserByPartnerAndUid($partnerId, $puserId, $ignorePuserKuser = false)
 {
     if (!$ignorePuserKuser && !kCurrentContext::isApiV3Context()) {
         $puserKuser = PuserKuserPeer::retrieveByPartnerAndUid($partnerId, 0, $puserId, true);
         if ($puserKuser) {
             return $puserKuser->getKuser();
         }
     }
     $c = new Criteria();
     $c->add(self::PARTNER_ID, $partnerId);
     $c->add(self::PUSER_ID, $puserId);
     return self::doSelectOne($c);
 }
Exemplo n.º 2
0
 /**
  * @param int $partnerId
  * @param string $puserId
  * @param bool $ignore_puser_kuser
  * @return kuser
  */
 public static function getKuserByPartnerAndUid($partnerId, $puserId, $ignorePuserKuser = false)
 {
     if (!$ignorePuserKuser && !kCurrentContext::isApiV3Context()) {
         $puserKuser = PuserKuserPeer::retrieveByPartnerAndUid($partnerId, 0, $puserId, true);
         if ($puserKuser) {
             return $puserKuser->getKuser();
         }
     }
     $c = new Criteria();
     $c->add(self::PARTNER_ID, $partnerId);
     $c->add(self::PUSER_ID, $puserId);
     // in case of more than one deleted kusers - get the last one
     $c->addDescendingOrderByColumn(kuserPeer::UPDATED_AT);
     return self::doSelectOne($c);
 }
Exemplo n.º 3
0
 public function getPuserId()
 {
     if (kCurrentContext::isApiV3Context()) {
         return parent::getPuserId();
     }
     $puser_id = $this->getFromCustomData("puserId");
     if ($this->m_puser_id) {
         return $this->m_puser_id;
     } else {
         if ($this->getKuserId()) {
             $puser_id = PuserKuserPeer::getPuserIdFromKuserId($this->getPartnerId(), $this->getKuserId());
             $this->putInCustomData("puserId", $puser_id);
             $this->m_puser_id = $puser_id;
         }
     }
     return $puser_id;
 }
 public function getPuserId()
 {
     $puserId = parent::getPuserId();
     if (is_null($puserId) && !kCurrentContext::isApiV3Context()) {
         $puserId = PuserKuserPeer::getPuserIdFromKuserId($this->getPartnerId(), $this->getId());
     }
     return $puserId;
 }
Exemplo n.º 5
0
 /**
  * @param BatchJob $dbBatchJob
  * @param BatchJob $twinJob
  * @return bool true if should continue to the next consumer
  */
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     // virus scan only works in api_v3 context because it uses dynamic enums
     if (!class_exists('kCurrentContext') || !kCurrentContext::isApiV3Context()) {
         return true;
     }
     if ($dbBatchJob->getJobType() == VirusScanPlugin::getBatchJobTypeCoreValue(VirusScanBatchJobType::VIRUS_SCAN)) {
         $dbBatchJob = $this->updatedVirusScan($dbBatchJob, $dbBatchJob->getData(), $twinJob);
     }
     return true;
 }
 /**
  * @param string $baseClass
  * @param string $enumValue
  * @return string
  */
 public static function getObjectClass($baseClass, $enumValue)
 {
     // virus scan only works in api_v3 context because it uses dynamic enums
     if (!class_exists('kCurrentContext') || !kCurrentContext::isApiV3Context()) {
         return null;
     }
     if ($baseClass == 'kJobData') {
         if ($enumValue == self::getBatchJobTypeCoreValue(VirusScanBatchJobType::VIRUS_SCAN)) {
             return 'kVirusScanJobData';
         }
     }
     if ($baseClass == 'KalturaJobData') {
         if ($enumValue == self::getApiValue(VirusScanBatchJobType::VIRUS_SCAN)) {
             return 'KalturaVirusScanJobData';
         }
     }
     return null;
 }
Exemplo n.º 7
0
 /**
  * $notification_type -
  * $puser_id - the puser_id of the kuser that caused the modification
  * $object_data - can be either an object or an object id (if the object no longer exists
  * $partner_id - if exists, use this (usually in case of $object_data is an id), if not - use the partner_id from the object
  * $entry_id is optional
  */
 public static function createNotification($notification_type, $object_data, $partner_id = null, $puser_id = null, $prefix = null, $extra_notification_data = null, $entry_id = null)
 {
     if (!$entry_id && $object_data instanceof entry) {
         $entry_id = $object_data->getId();
     }
     if (!$partner_id) {
         if ($object_data instanceof BaseObject) {
             $partner_id = $object_data->getPartnerId();
         } else {
             KalturaLog::log("Cannot create notification [{$notification_type}] [{$object_data}] [{$partner_id}]");
             return false;
         }
     }
     //		echo "[$partner_id]";
     $nofication_config_str = null;
     list($nofity, $nofication_config_str) = myPartnerUtils::shouldNotify($partner_id);
     if (!$nofity) {
         return false;
     }
     $nofication_config = myNotificationsConfig::getInstance($nofication_config_str);
     $nofity_send_type = $nofication_config->shouldNotify($notification_type);
     //echo "nofication_config_str: $nofication_config_str<br>notification_type:$notification_type<br>";
     if ($nofity_send_type == self::NOTIFICATION_MGR_NO_SEND) {
         return false;
     }
     //echo "nofity_send_type: $nofity_send_type<br>";
     // now check what type of notification to use - none / synch / a-synch
     //		Remarked by Tan-Tan, Nov 5 2009 to support the new batches
     //
     //		$not = new notification();
     //		$not->setType( $notification_type );
     //		if (  $nofity_send_type == self::NOTIFICATION_MGR_SEND_ASYNCH || $nofity_send_type == self::NOTIFICATION_MGR_SEND_BOTH)
     //		{
     //
     //			// the notification should be in status pending so it will be sent in the
     //			$not->setStatus( BatchJob::BATCHJOB_STATUS_PENDING );
     //		}
     //		elseif (  $nofity_send_type == self::NOTIFICATION_MGR_SEND_SYNCH  )
     //		{
     //			$not->setStatus( BatchJob::BATCHJOB_STATUS_FINISHED );
     //		}
     //
     //		// return the notification to the caller
     //		$retrun_notification = ( $nofity_send_type == self::NOTIFICATION_MGR_SEND_SYNCH || $nofity_send_type == self::NOTIFICATION_MGR_SEND_BOTH );
     //
     ////echo "retrun_notification: $retrun_notification<br>";
     //
     //		$not->setPartnerId( $partner_id );
     //		$not->setPuserId( $puser_id );
     //		$not->setDc ( kDataCenterMgr::getCurrentDcId() );
     //		if ( $object_data instanceof BaseObject )
     //		{
     //			$not->setObjectId($object_data->getId() );
     //			$not->setData( self::createNotificationData ( $notification_type , $object_data, $extra_notification_data  ) );
     //
     //			if ( $object_data instanceof entry )
     //			{
     //				if (defined("KALTURA_API_V3"))
     //					$puser_id = $object_data->getKuser()->getPuserId();
     //				else
     //					$puser_id = PuserKuserPeer::getByKuserId( $object_data->getKuserId() , 1 );
     //
     //				$not->setPuserId( $puser_id );
     //
     //			}
     //		}
     //		else
     //		{
     //			// in this case all we have is the object data which is the id
     //			// this is probably the case of some delete and we mifght not have the object in hand but only the id
     //			$not->setObjectId( $object_data );
     //		}
     //		$not->save();
     //		Added by Tan-Tan, Nov 2009 to support the new batches
     //		if (  $nofity_send_type == self::NOTIFICATION_MGR_SEND_ASYNCH || $nofity_send_type == self::NOTIFICATION_MGR_SEND_BOTH)
     //		{
     //
     //			// the notification should be in status pending so it will be sent in the
     //			$job->setStatus( BatchJob::BATCHJOB_STATUS_PENDING );
     //		}
     //		else
     $dontSend = false;
     if ($nofity_send_type == self::NOTIFICATION_MGR_SEND_SYNCH) {
         $dontSend = true;
     }
     // return the notification to the caller
     $retrun_notification = $nofity_send_type == self::NOTIFICATION_MGR_SEND_SYNCH || $nofity_send_type == self::NOTIFICATION_MGR_SEND_BOTH;
     $objectId = null;
     $notificationData = null;
     if ($object_data instanceof BaseObject) {
         $objectId = $object_data->getId();
         $notificationData = self::createNotificationData($notification_type, $object_data, $extra_notification_data);
         if ($object_data instanceof entry) {
             if (kCurrentContext::isApiV3Context()) {
                 $kuser = $object_data->getKuser();
                 if ($kuser) {
                     $puser_id = $kuser->getPuserId();
                 } else {
                     $puser_id = null;
                     KalturaLog::log(__CLASS__ . '::' . __METHOD__ . ' [line: ' . __LINE__ . '] could not find kuser [' . $object_data->getKuserId() . '] from object [' . $object_data->getId() . ']');
                 }
             } else {
                 $puser_id = PuserKuserPeer::getByKuserId($object_data->getKuserId(), 1);
                 // in flatten (or maybe other old batches), KALTURA_API_V3 is not defined, but entry user could have
                 // been created through api v3, in that case there will not be a record in puser_kuser table
                 if (is_null($puser_id)) {
                     $puser_id = $object_data->getPuserId();
                     // if entry was created on PS2 and from some reason puserId is still missing
                     if (is_null($puser_id)) {
                         $kuser = kuserPeer::retrieveByPK($object_data->getKuserId());
                         if ($kuser) {
                             $puser_id = $kuser->getPuserId();
                         }
                     }
                 }
                 if (is_null($puser_id)) {
                     KalturaLog::log(__CLASS__ . '::' . __METHOD__ . ' [line: ' . __LINE__ . '] could not get puser_id out of api_v3 context puserId from entry:[' . $object_data->getPuserId() . '] kuser ID:[' . $object_data->getKuserId() . '] entry:[' . $object_data->getId() . ']');
                 }
             }
         }
     } else {
         // in this case all we have is the object data which is the id
         // this is probably the case of some delete and we mifght not have the object in hand but only the id
         $objectId = $object_data;
     }
     $job = kJobsManager::addNotificationJob(null, $entry_id, $partner_id, $notification_type, $nofity_send_type, $puser_id, $objectId, $notificationData);
     if ($retrun_notification) {
         // return the notification id, notification object , url & the serialized data
         $partner = PartnerPeer::retrieveByPK($partner_id);
         list($url, $signature_key) = self::getPartnerNotificationInfo($partner);
         list($params, $raw_signature) = self::prepareNotificationData($url, $signature_key, $job, $prefix);
         $serialized_params = http_build_query($params, "", "&");
         return array($job->getId(), $job, $url, $params, $serialized_params);
     } else {
         return $job->getId();
     }
 }
 /**
 	return array('status' => $status, 'message' => $message, 'objects' => $objects);
 		objects - array of
 				'thumb' 
 				'title'  
 				'description' 
 				'id' - unique id to be passed to getMediaInfo 
 */
 public function searchMedia($media_type, $searchText, $page, $pageSize, $authData = null, $extraData = null)
 {
     $page_size = $pageSize > 20 ? 20 : $pageSize;
     $page--;
     if ($page < 0) {
         $page = 0;
     }
     $status = "ok";
     $message = '';
     $objects = array();
     $should_serach = true;
     if (kCurrentContext::isApiV3Context()) {
         $kuser = kuserPeer::getKuserByPartnerAndUid(self::$partner_id, self::$puser_id);
         $should_serach = true;
         $kuser_id = $kuser->getId();
     } else {
         $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid(self::$partner_id, self::$subp_id, self::$puser_id, true);
         if (!$puser_kuser) {
             // very bad - does not exist in system
             $should_serach = false;
         } else {
             $kuser = $puser_kuser->getKuser();
             if (!$kuser) {
                 $should_serach = false;
             } else {
                 $kuser_id = $kuser->getId();
             }
         }
     }
     //		echo "[" . self::$partner_id . "],[".  self::$subp_id . "],[" . self::$puser_id . "],[$kuser_id]";
     if ($should_serach) {
         $c = KalturaCriteria::create(entryPeer::OM_CLASS);
         $c->add(entryPeer::KUSER_ID, $kuser_id);
         $c->add(entryPeer::MEDIA_TYPE, $media_type);
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
         //			$keywords_array = mySearchUtils::getKeywordsFromStr ( $searchText );
         $filter = new entryFilter();
         $filter->setPartnerSearchScope(self::$partner_id);
         $filter->addSearchMatchToCriteria($c, $searchText, entry::getSearchableColumnName());
         $c->setLimit($pageSize);
         $c->setOffset($page * $pageSize);
         $entry_results = entryPeer::doSelect($c);
         //JoinAll( $c );
         $number_of_results = $c->getRecordsCount();
         $number_of_pages = (int) ($number_of_results / $pageSize);
         if ($number_of_results % $pageSize != 0) {
             $number_of_pages += 1;
         }
         // if there are some left-overs - there must be a nother page
         // add thumbs when not image or video
         $should_add_thumbs = $media_type != entry::ENTRY_MEDIA_TYPE_AUDIO;
         foreach ($entry_results as $entry) {
             /* @var $entry entry */
             // send the id as the url
             $object = array("id" => $entry->getId(), "url" => $entry->getDataUrl(), "tags" => $entry->getTags(), "title" => $entry->getName(), "description" => $entry->getDescription(), "flash_playback_type" => $entry->getMediaTypeName());
             if ($should_add_thumbs) {
                 $object["thumb"] = $entry->getThumbnailUrl();
             }
             //Find the flavor sent over the dataUrl in order to send its extension
             $playedAsset = assetPeer::retrieveBestPlayByEntryId($entry->getId());
             if ($playedAsset) {
                 $object["file_ext"] = $playedAsset->getFileExt();
             }
             $objects[] = $object;
         }
     }
     return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
Exemplo n.º 9
0
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if (!class_exists('kCurrentContext') || !kCurrentContext::isApiV3Context()) {
         return false;
     }
     if ($dbBatchJob->getJobType() == VirusScanPlugin::getBatchJobTypeCoreValue(VirusScanBatchJobType::VIRUS_SCAN)) {
         return true;
     }
     return false;
 }
 public function getPuserId($real_puser_id = false)
 {
     if (kCurrentContext::isApiV3Context()) {
         return parent::getPuserId();
     }
     // HACK for FootBo
     if (!$real_puser_id && $this->getPartnerId() == 8304) {
         return $this->getContributorScreenName();
     }
     $puser_id = $this->getFromCustomData("puserId");
     if ($this->m_puser_id) {
         return $this->m_puser_id;
     } else {
         if ($this->getKuserId()) {
             $puser_id = PuserKuserPeer::getPuserIdFromKuserId($this->getPartnerId(), $this->getKuserId());
             $this->putInCustomData("puserId", $puser_id);
             $this->m_puser_id = $puser_id;
         }
     }
     return $puser_id;
 }