本文整理汇总了PHP中CSocNetUserPerms::GetOperationPerms方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserPerms::GetOperationPerms方法的具体用法?PHP CSocNetUserPerms::GetOperationPerms怎么用?PHP CSocNetUserPerms::GetOperationPerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetUserPerms
的用法示例。
在下文中一共展示了CSocNetUserPerms::GetOperationPerms方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CanPerformOperation
/**
* <p>Метод проверяет, может ли пользователь совершать указанную операцию над профайлом заданного пользователя.</p>
*
*
* @param int $fromUserID Код пользователя, права которого проверяются.
*
* @param int $toUserID Код пользователя, к профайлу которого осуществляется доступ.
*
* @param string $operation Операция.</bod
*
* @param bool $bCurrentUserIsAdmin = false Является ли администратором пользователь, права которого
* проверяются. Необязательный парамтер. По умолчанию равен false.
*
* @return bool <p>True, если права на выполнение операции есть. Иначе - false.</p> <br><br>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/csocnetuserperms/canperformoperation.php
* @author Bitrix
*/
public static function CanPerformOperation($fromUserID, $toUserID, $operation, $bCurrentUserIsAdmin = false)
{
global $arSocNetUserOperations;
$fromUserID = IntVal($fromUserID);
$toUserID = IntVal($toUserID);
if ($toUserID <= 0) {
return false;
}
$operation = StrToLower(Trim($operation));
if (!array_key_exists($operation, $arSocNetUserOperations)) {
return false;
}
// use no profile private permission restrictions at the extranet site
if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
return true;
}
if ($bCurrentUserIsAdmin) {
return true;
}
if ($fromUserID == $toUserID) {
return true;
}
$usersRelation = CSocNetUserRelations::GetRelation($fromUserID, $toUserID);
if ($usersRelation == SONET_RELATIONS_BAN && !IsModuleInstalled("im")) {
return false;
}
$toUserOperationPerms = CSocNetUserPerms::GetOperationPerms($toUserID, $operation);
if ($toUserOperationPerms == SONET_RELATIONS_TYPE_NONE) {
return false;
}
if ($toUserOperationPerms == SONET_RELATIONS_TYPE_ALL) {
return true;
}
if ($toUserOperationPerms == SONET_RELATIONS_TYPE_AUTHORIZED) {
return $fromUserID > 0;
}
if ($toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS || $toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2) {
return CSocNetUserRelations::IsFriends($fromUserID, $toUserID);
}
return false;
}
示例2: GetMessage
if ($arParams["USER_ID"] <= 0) {
$arResult["FatalError"] = GetMessage("SONET_C40_NO_USER_ID") . ".";
}
if (StrLen($arResult["FatalError"]) <= 0) {
$dbUser = CUser::GetByID($arParams["USER_ID"]);
$arResult["User"] = $dbUser->GetNext();
if (is_array($arResult["User"])) {
$arResult["CurrentUserPerms"] = CSocNetUserPerms::InitUserPerms($GLOBALS["USER"]->GetID(), $arResult["User"]["ID"], CSocNetUser::IsCurrentUserModuleAdmin());
if ($arResult["CurrentUserPerms"]["Operations"]["modifyuser"]) {
$arResult["Features"] = array();
global $arSocNetUserOperations;
foreach ($arSocNetUserOperations as $feature => $perm) {
if (IsModuleInstalled("im") && $feature == "message") {
continue;
}
$perm = CSocNetUserPerms::GetOperationPerms($arResult["User"]["ID"], $feature);
if ($bExtranetInstalled && $perm == SONET_RELATIONS_TYPE_ALL) {
$perm = SONET_RELATIONS_TYPE_AUTHORIZED;
}
$arResult["Features"][$feature] = $perm;
}
} else {
$arResult["FatalError"] = GetMessage("SONET_C40_NO_PERMS") . ".";
}
} else {
$arResult["FatalError"] = GetMessage("SONET_C40_NO_USER") . ".";
}
}
if (StrLen($arResult["FatalError"]) <= 0) {
$arResult["Urls"]["User"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arResult["User"]["ID"]));
$arTmpUser = array('NAME' => $arResult["User"]["~NAME"], 'LAST_NAME' => $arResult["User"]["~LAST_NAME"], 'SECOND_NAME' => $arResult["User"]["~SECOND_NAME"], 'LOGIN' => $arResult["User"]["~LOGIN"]);
示例3: DeleteRelation
function DeleteRelation($senderUserID, $targetUserID)
{
global $APPLICATION;
$senderUserID = IntVal($senderUserID);
if ($senderUserID <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_SENDER_USER_ID"), "ERROR_SENDER_USER_ID");
return false;
}
$targetUserID = IntVal($targetUserID);
if ($targetUserID <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_TARGET_USER_ID"), "ERROR_TARGET_USER_ID");
return false;
}
$arRelation = CSocNetUserRelations::GetByUserID($senderUserID, $targetUserID);
if (!$arRelation)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_RELATION_NOT_FOUND"), "ERROR_RELATION_NOT_FOUND");
return false;
}
if (CSocNetUserRelations::Delete($arRelation["ID"]))
{
$logID = CSocNetLog::Add(
array(
"ENTITY_TYPE" => SONET_ENTITY_USER,
"ENTITY_ID" => $senderUserID,
"EVENT_ID" => "system_friends",
"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
"TITLE_TEMPLATE" => false,
"TITLE" => "unfriend",
"MESSAGE" => $targetUserID,
"URL" => false,
"MODULE_ID" => false,
"CALLBACK_FUNC" => false,
"USER_ID" => $targetUserID,
),
false
);
if (intval($logID) > 0)
{
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
$perm = CSocNetUserPerms::GetOperationPerms($senderUserID, "viewfriends");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID, "S".SONET_ENTITY_USER.$senderUserID."_".$perm));
elseif ($perm == SONET_RELATIONS_TYPE_NONE)
CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID));
elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
CSocNetLogRights::Add($logID, array("SA", "AU"));
elseif ($perm == SONET_RELATIONS_TYPE_ALL)
CSocNetLogRights::Add($logID, array("SA", "G2"));
$tmpID = $logID;
}
$logID2 = CSocNetLog::Add(
array(
"ENTITY_TYPE" => SONET_ENTITY_USER,
"ENTITY_ID" => $targetUserID,
"EVENT_ID" => "system_friends",
"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
"TITLE_TEMPLATE" => false,
"TITLE" => "unfriend",
"MESSAGE" => $senderUserID,
"URL" => false,
"MODULE_ID" => false,
"CALLBACK_FUNC" => false,
"USER_ID" => $senderUserID,
"TMP_ID" => (intval($tmpID) > 0 ? $tmpID : false),
),
false
);
if (intval($logID2) > 0)
{
$perm = CSocNetUserPerms::GetOperationPerms($targetUserID, "viewfriends");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
CSocNetLogRights::Add($logID2, array("SA", "U".$targetUserID, "S".SONET_ENTITY_USER.$targetUserID."_".$perm));
elseif ($perm == SONET_RELATIONS_TYPE_NONE)
CSocNetLogRights::Add($logID2, array("SA", "U".$targetUserID));
elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
CSocNetLogRights::Add($logID2, array("SA", "AU"));
elseif ($perm == SONET_RELATIONS_TYPE_ALL)
CSocNetLogRights::Add($logID2, array("SA", "G2"));
}
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $tmpID);
if ($arRelation["RELATION"] == SONET_RELATIONS_FRIEND)
$GLOBALS["DB"]->Query("DELETE FROM b_sonet_event_user_view WHERE
ENTITY_TYPE = '".SONET_ENTITY_USER."'
AND (
(USER_ID = ".$arRelation["FIRST_USER_ID"]." AND ENTITY_ID = ".$arRelation["SECOND_USER_ID"].")
OR (USER_ID = ".$arRelation["SECOND_USER_ID"]." AND ENTITY_ID = ".$arRelation["FIRST_USER_ID"].")
OR (ENTITY_ID = ".$arRelation["FIRST_USER_ID"]." AND USER_IM_ID = ".$arRelation["SECOND_USER_ID"].")
//.........这里部分代码省略.........
示例4: array
$perm = CSocNetUserPerms::GetOperationPerms($arLog["ENTITY_ID"], $operation);
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"], "SU" . $arLog["ENTITY_ID"] . "_" . $perm));
} elseif ($perm == SONET_RELATIONS_TYPE_NONE) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"]));
} elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "AU"));
} elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "G2"));
}
} elseif ($featureID = CSocNetLogTools::FindFeatureByEventID($arLog["EVENT_ID"])) {
CSocNetLogRights::SetForSonet($arLog["ID"], $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $featureID, $GLOBALS["arSocNetFeaturesSettings"][$featureID]["subscribe_events"][$arLog["EVENT_ID"]]["OPERATION"]);
} elseif ($arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_OWNER, "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_MODERATOR, "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_USER));
} elseif ($arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_USER) {
$perm = CSocNetUserPerms::GetOperationPerms($arLog["ENTITY_ID"], "viewprofile");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"], "SU" . $arLog["ENTITY_ID"] . "_" . $perm));
} elseif ($perm == SONET_RELATIONS_TYPE_NONE) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"]));
} elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "AU"));
} elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
CSocNetLogRights::Add($arLog["ID"], array("SA", "G2"));
}
// tasks!!!
}
} elseif (in_array($arLog["ENTITY_TYPE"], array('R'))) {
// reports
} elseif (in_array($arLog["ENTITY_TYPE"], array('T'))) {
// timeman
示例5: SetFeature
function SetFeature($entityType, $entityID, $feature, $op = false, $permX = false, $bCheckEmpty = false)
{
global $APPLICATION, $DB, $arSocNetAllowedEntityTypes;
$arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
$arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
$CacheRelatedUsers = array();
$entityType = trim($entityType);
if (!in_array($entityType, $arSocNetAllowedEntityTypes)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
return false;
}
$entityID = IntVal($entityID);
if ($entityID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
return false;
}
if (!$bCheckEmpty || !CSocNetEventUserView::IsEntityEmpty($entityType, $entityID)) {
$event_id = array();
if (!$op || !$permX) {
if (array_key_exists($feature, $arSocNetFeaturesSettings) && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])) {
foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
continue;
}
if (!array_key_exists("ENTITIES", $arEventIDTmp) || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])) {
continue;
}
$event_id[$arEventIDTmp["OPERATION"]][] = $event_id_tmp;
if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0) {
$event_id[$arEventIDTmp["OPERATION"]][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
}
}
if (is_array($event_id[$arEventIDTmp["OPERATION"]])) {
$event_id[$arEventIDTmp["OPERATION"]] = array_unique($event_id[$arEventIDTmp["OPERATION"]]);
}
}
} else {
$arOpTmp = array();
if (array_key_exists($feature, $arSocNetFeaturesSettings) && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])) {
foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
continue;
}
if (!array_key_exists("ENTITIES", $arEventIDTmp) || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])) {
continue;
}
if (!array_key_exists("OPERATION", $arEventIDTmp) || strlen($arEventIDTmp["OPERATION"]) <= 0) {
continue;
}
$arOpTmp[] = $arEventIDTmp["OPERATION"];
if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0) {
$arOpTmp[] = $arEventIDTmp["COMMENT_EVENT"]["OPERATION"];
}
}
}
if (is_array($arOpTmp)) {
$arOpTmp = array_unique($arOpTmp);
}
if (in_array($op, $arOpTmp)) {
foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
if ($arEventIDTmp["OPERATION"] == $op) {
$event_id[$op][] = $event_id_tmp;
}
if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] == $op) {
$event_id[$op][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
}
}
if (is_array($event_id[$op])) {
$event_id[$op] = array_unique($event_id[$op]);
}
} else {
return true;
}
}
if (intval($entityID) > 0 && array_key_exists($entityType, $arSocNetAllowedSubscribeEntityTypesDesc) && array_key_exists("CLASS_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]) && array_key_exists("METHOD_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType])) {
$arEntityTmp = call_user_func(array($arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["CLASS_DESC_GET"], $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["METHOD_DESC_GET"]), $entityID);
}
foreach ($event_id as $op => $arEvent) {
$arRelatedUsers = array();
if (is_array($arEvent)) {
foreach ($arEvent as $event) {
if (!CSocNetEventUserView::Delete($entityType, $entityID, $feature, $event)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
return false;
}
if (!$feature || !$permX) {
$perm = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $op);
} else {
$perm = $permX;
}
if ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP && $arEntityTmp && $arEntityTmp["VISIBLE"] == "N" && $perm > SONET_ROLES_USER) {
$perm = SONET_ROLES_USER;
} elseif ($entityType == SONET_SUBSCRIBE_ENTITY_USER) {
$perm_profile = CSocNetUserPerms::GetOperationPerms($entityID, "viewprofile");
if ($perm < $perm_profile) {
$perm = $perm_profile;
}
}
if (array_key_exists($entityType, $CacheRelatedUsers) && array_key_exists($entityID, $CacheRelatedUsers[$entityType]) && array_key_exists($perm, $CacheRelatedUsers[$entityType][$entityID])) {
$arRelatedUsers = $CacheRelatedUsers[$entityType][$entityID][$perm];
//.........这里部分代码省略.........
示例6: SetSonetLogRights
function SetSonetLogRights($logID, $entity_type, $entity_id, $event_id)
{
if (!CModule::IncludeModule("socialnetwork")) {
return;
}
if (in_array($entity_type, array(SONET_SUBSCRIBE_ENTITY_USER, SONET_SUBSCRIBE_ENTITY_GROUP))) {
if (in_array($event_id, array("blog_post", "forum", "photo", "blog_post_micro", "files", "wiki"))) {
$arLogEventTmp = CSocNetLogTools::FindLogEventByID($event_id);
CSocNetLogRights::SetForSonet($logID, $entity_type, $entity_id, CSocNetLogTools::FindFeatureByEventID($event_id), $arLogEventTmp["OPERATION"]);
} elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_GROUP) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
} elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_USER) {
$perm = CSocNetUserPerms::GetOperationPerms($entity_id, "viewprofile");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id, "S" . SONET_SUBSCRIBE_ENTITY_USER . $entity_id . "_" . $perm));
} elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
CSocNetLogRights::Add($logID, array("SA", "AU"));
} elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
CSocNetLogRights::Add($logID, array("SA", "G2"));
}
}
} elseif ($entity_type == SONET_SUBSCRIBE_ENTITY_PROVIDER) {
$arRights = array("SA");
$rsSchemeRights = CXDILFSchemeRights::GetList(array(), array("SCHEME_ID" => $entity_id));
while ($arSchemeRights = $rsSchemeRights->Fetch()) {
if (substr($arSchemeRights["GROUP_CODE"], 0, 1) == "U") {
if (substr($arSchemeRights["GROUP_CODE"], 1) == "A") {
$arRights[] = "AU";
break;
} elseif (substr($arSchemeRights["GROUP_CODE"], 1) == "N") {
$arRights[] = "G2";
break;
} elseif (intval(substr($arSchemeRights["GROUP_CODE"], 1)) > 0) {
$arRights[] = "U" . substr($arSchemeRights["GROUP_CODE"], 1);
}
}
}
if (count($arRights) > 0) {
CSocNetLogRights::Add($logID, $arRights);
}
} elseif (defined("SONET_SUBSCRIBE_ENTITY_NEWS") && $entity_type == SONET_SUBSCRIBE_ENTITY_NEWS) {
CSocNetLogRights::Add($logID, array("SA", "G2"));
}
}
示例7: initSonetUserPerms
protected function initSonetUserPerms($arUserID)
{
if (!is_array($arUserID)) {
$arUserID = array(intval($arUserID));
}
CSocNetUserPerms::GetOperationPerms($arUserID, "viewprofile");
}