本文整理汇总了PHP中PartnerPeer::getDefaultCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP PartnerPeer::getDefaultCriteria方法的具体用法?PHP PartnerPeer::getDefaultCriteria怎么用?PHP PartnerPeer::getDefaultCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PartnerPeer
的用法示例。
在下文中一共展示了PartnerPeer::getDefaultCriteria方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: impersonateByKsAction
/**
* Start an impersonated session with Kaltura's server.
* The result KS info contains the session key that you should pass to all services that requires a ticket.
* Type, expiry and privileges won't be changed if they're not set
*
* @action impersonateByKs
* @param string $session The old KS of the impersonated partner
* @param KalturaSessionType $type Type of the new KS
* @param int $expiry Expiry time in seconds of the new KS
* @param string $privileges Privileges of the new KS
* @return KalturaSessionInfo
*
* @throws APIErrors::START_SESSION_ERROR
*/
function impersonateByKsAction($session, $type = null, $expiry = null, $privileges = null)
{
KalturaResponseCacher::disableCache();
$oldKS = null;
try {
$oldKS = ks::fromSecureString($session);
} catch (Exception $e) {
KalturaLog::err($e->getMessage());
throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $this->getPartnerId());
}
$impersonatedPartnerId = $oldKS->partner_id;
$impersonatedUserId = $oldKS->user;
$impersonatedType = $oldKS->type;
$impersonatedExpiry = $oldKS->valid_until - time();
$impersonatedPrivileges = $oldKS->privileges;
if (!is_null($type)) {
$impersonatedType = $type;
}
if (!is_null($expiry)) {
$impersonatedExpiry = $expiry;
}
if ($privileges) {
$impersonatedPrivileges = $privileges;
}
// verify partner is allowed to start session for another partner
$impersonatedPartner = null;
if (!myPartnerUtils::allowPartnerAccessPartner($this->getPartnerId(), $this->partnerGroup(), $impersonatedPartnerId)) {
$c = PartnerPeer::getDefaultCriteria();
$c->addAnd(PartnerPeer::ID, $impersonatedPartnerId);
$impersonatedPartner = PartnerPeer::doSelectOne($c);
} else {
// get impersonated partner
$impersonatedPartner = PartnerPeer::retrieveByPK($impersonatedPartnerId);
}
if (!$impersonatedPartner) {
KalturaLog::err("Impersonated partner [{$impersonatedPartnerId} ]could not be fetched from the DB");
throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $this->getPartnerId());
}
// set the correct secret according to required session type
if ($impersonatedType == KalturaSessionType::ADMIN) {
$impersonatedSecret = $impersonatedPartner->getAdminSecret();
} else {
$impersonatedSecret = $impersonatedPartner->getSecret();
}
$sessionInfo = new KalturaSessionInfo();
$result = kSessionUtils::startKSession($impersonatedPartnerId, $impersonatedSecret, $impersonatedUserId, $sessionInfo->ks, $impersonatedExpiry, $impersonatedType, '', $impersonatedPrivileges, $this->getPartnerId());
if ($result < 0) {
KalturaLog::err("Failed starting a session with result [{$result}]");
throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $this->getPartnerId());
}
$sessionInfo->partnerId = $impersonatedPartnerId;
$sessionInfo->userId = $impersonatedUserId;
$sessionInfo->expiry = $impersonatedExpiry;
$sessionInfo->sessionType = $impersonatedType;
$sessionInfo->privileges = $impersonatedPrivileges;
return $sessionInfo;
}
示例2: countAction
/**
* Count partner's existing sub-publishers (count includes the partner itself).
*
* @action count
* @param KalturaPartnerFilter $filter
* @return int
*/
public function countAction(KalturaPartnerFilter $filter = null)
{
if (!$filter) {
$filter = new KalturaPartnerFilter();
}
$dbFilter = new partnerFilter();
$filter->toObject($dbFilter);
$c = PartnerPeer::getDefaultCriteria();
$dbFilter->attachToCriteria($c);
return PartnerPeer::doCount($c);
}
示例3: updateStatusAction
/**
* Function to change a sub-publisher's status
* @action updateStatus
* @param int $id
* @param KalturaPartnerStatus $status
* @throws KalturaErrors::UNKNOWN_PARTNER_ID
*/
public function updateStatusAction($id, $status)
{
$c = PartnerPeer::getDefaultCriteria();
$c->addAnd(PartnerPeer::ID, $id);
$dbPartner = PartnerPeer::doSelectOne($c);
if (!$dbPartner) {
throw new KalturaAPIException(KalturaErrors::UNKNOWN_PARTNER_ID, $id);
}
$dbPartner->setStatus($status);
$dbPartner->save();
PartnerPeer::removePartnerFromCache($id);
}