本文整理汇总了PHP中PartnerPeer::doSelectOne方法的典型用法代码示例。如果您正苦于以下问题:PHP PartnerPeer::doSelectOne方法的具体用法?PHP PartnerPeer::doSelectOne怎么用?PHP PartnerPeer::doSelectOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PartnerPeer
的用法示例。
在下文中一共展示了PartnerPeer::doSelectOne方法的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: getAction
/**
* Retrieve partner object by Id
*
* @action get
* @param int $id
* @return KalturaPartner
*
* @throws APIErrors::INVALID_PARTNER_ID
*/
public function getAction($id = null)
{
if (is_null($id)) {
$id = $this->getPartnerId();
}
$c = PartnerPeer::getDefaultCriteria();
$c->addAnd(PartnerPeer::ID, $id);
$dbPartner = PartnerPeer::doSelectOne($c);
if (is_null($dbPartner)) {
throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $id);
}
$partner = new KalturaPartner();
$partner->fromObject($dbPartner);
return $partner;
}
示例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);
}