本文整理汇总了PHP中Partner::getWidgetSessionRoleId方法的典型用法代码示例。如果您正苦于以下问题:PHP Partner::getWidgetSessionRoleId方法的具体用法?PHP Partner::getWidgetSessionRoleId怎么用?PHP Partner::getWidgetSessionRoleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partner
的用法示例。
在下文中一共展示了Partner::getWidgetSessionRoleId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initRoleIds
private static function initRoleIds()
{
$roleIds = null;
if (!self::$operatingPartner || !self::$ksString) {
// no partner or session -> no role
$roleIds = null;
} else {
$ks = ks::fromSecureString(self::$ksString);
$ksSetRoleId = $ks->getSetRole();
if ($ksSetRoleId) {
//check if role exists
$c = new Criteria();
$c->addAnd(is_numeric($ksSetRoleId) ? UserRolePeer::ID : UserRolePeer::SYSTEM_NAME, $ksSetRoleId, Criteria::EQUAL);
$c->addAnd(UserRolePeer::PARTNER_ID, array(self::$ksPartnerId, PartnerPeer::GLOBAL_PARTNER), Criteria::IN);
$roleId = UserRolePeer::doSelectOne($c);
if ($roleId) {
$roleIds = $roleId->getId();
} else {
KalturaLog::debug("Role id [{$ksSetRoleId}] does not exists");
throw new KalturaAPIException(APIErrors::UNKNOWN_ROLE_ID, $ksSetRoleId);
}
}
// if user is defined -> get his role IDs
if (!$roleIds && self::$kuser) {
$roleIds = self::$kuser->getRoleIds();
}
// if user has no defined roles or no user is defined -> get default role IDs according to session type (admin/not)
if (!$roleIds) {
if ($ks->isWidgetSession()) {
//there is only one partner widget role defined in the system
$roleIds = self::$operatingPartner->getWidgetSessionRoleId();
} elseif (self::$adminSession) {
// there is only one partner admin role defined in the system
$roleIds = self::$operatingPartner->getAdminSessionRoleId();
} else {
// a partner may have special defined user session roles - get them from partner object
$roleIds = self::$operatingPartner->getUserSessionRoleId();
}
}
if ($roleIds) {
$roleIds = explode(',', trim($roleIds, ','));
}
}
self::$roleIds = $roleIds;
}
示例2: getRoleIds
public static function getRoleIds(Partner $operatingPartner = null, kuser $kuser = null)
{
$roleIds = null;
$ksString = kCurrentContext::$ks;
$isAdminSession = !self::isEmpty(kCurrentContext::$is_admin_session) ? kCurrentContext::$is_admin_session : false;
if (!$ksString || !$operatingPartner && kCurrentContext::$ks_partner_id != Partner::BATCH_PARTNER_ID) {
$roleId = UserRolePeer::getIdByStrId(UserRoleId::NO_SESSION_ROLE);
if ($roleId) {
return array($roleId);
}
return null;
}
$ks = ks::fromSecureString($ksString);
$ksSetRoleId = $ks->getSetRole();
if ($ksSetRoleId) {
if ($ksSetRoleId == 'null') {
return null;
}
$ksPartnerId = !self::isEmpty(kCurrentContext::$ks_partner_id) ? kCurrentContext::$ks_partner_id : null;
//check if role exists
$c = new Criteria();
$c->addAnd(is_numeric($ksSetRoleId) ? UserRolePeer::ID : UserRolePeer::SYSTEM_NAME, $ksSetRoleId, Criteria::EQUAL);
$partnerIds = array_map('strval', array($ksPartnerId, PartnerPeer::GLOBAL_PARTNER));
$c->addAnd(UserRolePeer::PARTNER_ID, $partnerIds, Criteria::IN);
$roleId = UserRolePeer::doSelectOne($c);
if ($roleId) {
$roleIds = $roleId->getId();
} else {
KalturaLog::debug("Role id [{$ksSetRoleId}] does not exists");
throw new kCoreException("Unknown role Id [{$ksSetRoleId}]", kCoreException::ID_NOT_FOUND);
}
}
// if user is defined -> get his role IDs
if (!$roleIds && $kuser) {
$roleIds = $kuser->getRoleIds();
}
// if user has no defined roles or no user is defined -> get default role IDs according to session type (admin/not)
if (!$roleIds) {
if (!$operatingPartner) {
// use system default roles
if ($ks->isWidgetSession()) {
$strId = UserRoleId::WIDGET_SESSION_ROLE;
} elseif ($isAdminSession) {
$strId = UserRoleId::PARTNER_ADMIN_ROLE;
} else {
$strId = UserRoleId::BASE_USER_SESSION_ROLE;
}
$roleIds = UserRolePeer::getIdByStrId($strId);
} else {
if ($ks->isWidgetSession()) {
//there is only one partner widget role defined in the system
$roleIds = $operatingPartner->getWidgetSessionRoleId();
} elseif ($isAdminSession) {
// there is only one partner admin role defined in the system
$roleIds = $operatingPartner->getAdminSessionRoleId();
} else {
// a partner may have special defined user session roles - get them from partner object
$roleIds = $operatingPartner->getUserSessionRoleId();
}
}
}
if ($roleIds) {
$roleIds = explode(',', trim($roleIds, ','));
}
return $roleIds;
}