本文整理汇总了PHP中CSocNetUserToGroup::InitUserPerms方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserToGroup::InitUserPerms方法的具体用法?PHP CSocNetUserToGroup::InitUserPerms怎么用?PHP CSocNetUserToGroup::InitUserPerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetUserToGroup
的用法示例。
在下文中一共展示了CSocNetUserToGroup::InitUserPerms方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
$arFilter["SITE_ID"] = SITE_ID;
} else {
$arFilter["SITE_ID"] = array(SITE_ID, false);
}
$cnt = 0;
$dbEvents = CSocNetLog::GetList(array("LOG_DATE" => "DESC"), $arFilter, false, false, array("MIN_ID_JOIN" => true));
while ($arEvents = $dbEvents->GetNext()) {
if (intval($arParams["LOG_CNT"]) > 0 && $cnt >= $arParams["LOG_CNT"]) {
break;
}
if ($arResult["Events"] == false) {
$arResult["Events"] = array();
}
if ($arEvents["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
$arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), array("ID" => $arEvents["ENTITY_ID"], "OWNER_ID" => $arEvents["GROUP_OWNER_ID"], "INITIATE_PERMS" => $arEvents["GROUP_INITIATE_PERMS"], "VISIBLE" => $arEvents["GROUP_VISIBLE"], "OPENED" => $arEvents["GROUP_OPENED"]), $bCurrentUserIsAdmin);
if ($arEvents["EVENT_ID"] == "system") {
if (!$arCurrentUserPerms["UserIsMember"]) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_post") {
if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_post_micro") {
if (!array_key_exists("microblog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_comment") {
if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_comment", $bCurrentUserIsAdmin)) {
continue;
示例2: UnBanMember
function UnBanMember($userID, $groupID, $arRelationID, $currentUserIsAdmin)
{
global $APPLICATION, $DB;
$userID = IntVal($userID);
if ($userID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_USERID"), "ERROR_USERID");
return false;
}
$groupID = IntVal($groupID);
if ($groupID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_GROUPID"), "ERROR_GROUPID");
return false;
}
if (!is_array($arRelationID)) {
return true;
}
$arGroup = CSocNetGroup::GetByID($groupID);
if (!$arGroup || !is_array($arGroup)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_ERROR_NO_GROUP_ID"), "ERROR_NO_GROUP");
return false;
}
$arUserPerms = CSocNetUserToGroup::InitUserPerms($userID, $arGroup, $currentUserIsAdmin);
if (!$arUserPerms["UserCanModifyGroup"] && !$arUserPerms["UserCanModerateGroup"]) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_ERROR_NO_PERMS"), "ERROR_NO_PERMS");
return false;
}
$bSuccess = true;
$tmp_count = count($arRelationID);
for ($i = 0; $i < $tmp_count; $i++) {
$arRelationID[$i] = IntVal($arRelationID[$i]);
if ($arRelationID[$i] <= 0) {
continue;
}
$arRelation = CSocNetUserToGroup::GetByID($arRelationID[$i]);
if (!$arRelation) {
continue;
}
if ($arRelation["GROUP_ID"] != $groupID || $arRelation["ROLE"] != SONET_ROLES_BAN) {
continue;
}
$arFields = array("ROLE" => SONET_ROLES_USER, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction());
if (CSocNetUserToGroup::Update($arRelation["ID"], $arFields)) {
$arMessageFields = array("FROM_USER_ID" => $userID, "TO_USER_ID" => $arRelation["USER_ID"], "MESSAGE" => str_replace("#NAME#", $arGroup["NAME"], GetMessage("SONET_UG_UNBANMEMBER_MESSAGE")), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM);
CSocNetMessages::Add($arMessageFields);
} else {
$errorMessage = "";
if ($e = $APPLICATION->GetException()) {
$errorMessage = $e->GetString();
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_UR_ERROR_CREATE_USER2GROUP");
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_UNBANMEMBER");
$bSuccess = false;
}
}
return $bSuccess;
}
示例3: GetMessage
$arResult["NEED_AUTH"] = "Y";
} else {
$arGroup = CSocNetGroup::GetByID($arParams["GROUP_ID"]);
if (!$arGroup || !is_array($arGroup) || $arGroup["ACTIVE"] != "Y") {
$arResult["FatalError"] = GetMessage("SONET_P_USER_NO_GROUP");
} else {
$arGroupSites = array();
$rsGroupSite = CSocNetGroup::GetSite($arGroup["ID"]);
while ($arGroupSite = $rsGroupSite->Fetch()) {
$arGroupSites[] = $arGroupSite["LID"];
}
if (!in_array(SITE_ID, $arGroupSites)) {
$arResult["FatalError"] = GetMessage("SONET_P_USER_NO_GROUP");
} else {
$arResult["Group"] = $arGroup;
$arResult["CurrentUserPerms"] = CSocNetUserToGroup::InitUserPerms($USER->GetID(), $arResult["Group"], CSocNetUser::IsCurrentUserModuleAdmin());
if (!$arResult["CurrentUserPerms"] || !$arResult["CurrentUserPerms"]["UserCanViewGroup"]) {
$arResult["FatalError"] = GetMessage("SONET_C12_NO_PERMS") . ". ";
} else {
$arResult["Urls"]["Group"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arResult["Group"]["ID"]));
$arResult["Urls"]["RequestSearch"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP_REQUEST_SEARCH"], array("group_id" => $arResult["Group"]["ID"]));
if ($arParams["SET_TITLE"] == "Y") {
$APPLICATION->SetTitle($arResult["Group"]["NAME"] . ": " . GetMessage("SONET_C12_TITLE"));
}
if ($arParams["SET_NAVCHAIN"] != "N") {
$APPLICATION->AddChainItem($arResult["Group"]["NAME"], $arResult["Urls"]["Group"]);
$APPLICATION->AddChainItem(GetMessage("SONET_C12_TITLE"));
}
if (!$arResult["CurrentUserPerms"]["UserCanInitiate"]) {
$arResult["FatalError"] = GetMessage("SONET_C12_CANT_INVITE") . ". ";
} else {
示例4: while
while ($arGroup = $dbGroup->GetNext()) {
if ($arCacheResult["Groups"]["List"] == false) {
$arCacheResult["Groups"]["List"] = array();
}
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arGroup["ID"]));
if (intval($arGroup["IMAGE_ID"]) <= 0) {
$arGroup["IMAGE_ID"] = COption::GetOptionInt("socialnetwork", "default_group_picture", false, SITE_ID);
}
$arImageResized = false;
$imageFile = CFile::GetFileArray($arGroup["IMAGE_ID"]);
if ($imageFile !== false) {
$arImageResized = CFile::ResizeImageGet($imageFile, array("width" => $arParams["THUMBNAIL_SIZE"], "height" => $arParams["THUMBNAIL_SIZE"]), BX_RESIZE_IMAGE_EXACT);
}
$arImage = CSocNetTools::InitImage($arGroup["IMAGE_ID"], 150, "/bitrix/images/socialnetwork/nopic_group_150.gif", 150, $pu, true);
if ($arParams["PAGE"] == "group_request_group_search") {
$arCurrentUserPerms4Group = CSocNetUserToGroup::InitUserPerms($arResult["User"]["ID"], array("ID" => $arGroup["ID"], "OWNER_ID" => $arGroup["OWNER_ID"], "INITIATE_PERMS" => $arGroup["INITIATE_PERMS"], "VISIBLE" => $arGroup["VISIBLE"], "OPENED" => $arGroup["OPENED"]), CSocNetUser::IsCurrentUserModuleAdmin());
}
$arCacheResult["Groups"]["List"][] = array("GROUP_ID" => $arGroup["ID"], "GROUP_NAME" => $arGroup["NAME"], "GROUP_DESCRIPTION" => strlen($arGroup["DESCRIPTION"]) > 50 ? substr($arGroup["DESCRIPTION"], 0, 50) . "..." : $arGroup["DESCRIPTION"], "GROUP_PHOTO" => $arGroup["IMAGE_ID"], "GROUP_PHOTO_FILE" => $arImage["FILE"], "GROUP_PHOTO_IMG" => $arImage["IMG"], "GROUP_PHOTO_RESIZED" => $arImageResized, "GROUP_URL" => $pu, "GROUP_REQUEST_USER_URL" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP_REQUEST_USER"], array("group_id" => $arGroup["ID"], "user_id" => $arResult["UserRequest"]["ID"])), "CAN_INVITE2GROUP" => $arParams["PAGE"] != "user_groups" ? $arCurrentUserPerms4Group && $arCurrentUserPerms4Group["UserCanInitiate"] : false, "FULL" => array("DATE_CREATE_FORMATTED" => date($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arGroup["DATE_CREATE"], CSite::GetDateFormat("FULL"))), "DATE_UPDATE_FORMATTED" => date($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arGroup["DATE_UPDATE"], CSite::GetDateFormat("FULL"))), "DATE_ACTIVITY_FORMATTED" => date($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arGroup["DATE_ACTIVITY"], CSite::GetDateFormat("FULL")))));
$arGroupID[] = $arGroup["ID"];
}
if (CModule::IncludeModule("extranet") && !CExtranet::IsExtranetSite()) {
$arExtranetGroupID = array();
$dbGroupTmp = CSocNetGroup::GetList(array(), array("ID" => $arGroupID, "SITE_ID" => CExtranet::GetExtranetSiteID()), false, false, array("ID"));
while ($arGroupTmp = $dbGroupTmp->Fetch()) {
$arExtranetGroupID[] = $arGroupTmp["ID"];
}
if (count($arExtranetGroupID) > 0 && is_array($arCacheResult["Groups"]["List"])) {
foreach ($arCacheResult["Groups"]["List"] as $key => $arGroupTmp) {
$arCacheResult["Groups"]["List"][$key]["IS_EXTRANET"] = in_array($arGroupTmp["GROUP_ID"], $arExtranetGroupID) ? "Y" : "N";
}
}
示例5: array
}
if (strlen($arResult["SERVER_NAME"]) <= 0 && defined("SITE_SERVER_NAME")) {
$arResult["SERVER_NAME"] = SITE_SERVER_NAME;
}
if (strlen($arResult["SERVER_NAME"]) <= 0 && defined("SITE_SERVER_NAME")) {
$rsSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => SITE_ID));
if ($arSite = $rsSite->Fetch()) {
$arResult["SERVER_NAME"] = $arSite["SERVER_NAME"];
}
}
if (strlen($arResult["SERVER_NAME"]) <= 0) {
$arResult["SERVER_NAME"] = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
}
if ($arParams["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
$arGroup = CSocNetGroup::GetByID($arParams["ENTITY_ID"]);
$arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arGroup, $bCurrentUserIsAdmin);
if (!$arCurrentUserPerms || !$arCurrentUserPerms["UserCanViewGroup"]) {
$APPLICATION->RestartBuffer();
$arResult["NAME"] = GetMessage("SONET_LOG_RSS_ERROR");
$arResult["Events"] = array(array("LOG_DATE" => date("r"), "TITLE_FORMAT" => htmlspecialcharsbx(GetMessage("SONET_LOG_RSS_GROUP_NO_PERMS_TITLE")), "MESSAGE_FORMAT" => htmlspecialcharsbx(GetMessage("SONET_LOG_RSS_GROUP_NO_PERMS_MESSAGE")), "URL" => ""));
$this->IncludeComponentTemplate();
$r = $APPLICATION->EndBufferContentMan();
echo $r;
die;
}
if (intval($arGroup["IMAGE_ID"]) <= 0) {
$arGroup["IMAGE_ID"] = COption::GetOptionInt("socialnetwork", "default_group_picture", false, SITE_ID);
}
$arResult["PICTURE"] = CSocNetTools::InitImage($arGroup["IMAGE_ID"], 100, "/bitrix/images/socialnetwork/nopic_group_100.gif", 100, "", false);
$arResult["PICTURE"]["FILE"]["SRC"] = __RSSCheckServerName($arResult["PICTURE"]["FILE"]["SRC"], $arResult["SERVER_NAME"]);
$arResult["NAME"] = $arGroup["NAME"];
示例6: RequestToSonetGroups
public static function RequestToSonetGroups($arUserId, $arGroupCode, $arGroupName, $bExtranetUser = false)
{
$arGroupToAdd = array();
$strError = false;
if (!is_array($arUserId)) {
$arUserId = array($arUserId);
}
if (is_array($arGroupCode) && !empty($arGroupCode) && CModule::IncludeModule("socialnetwork")) {
foreach ($arGroupCode as $group_code) {
if ($bExtranetUser && preg_match('/^(SGN\\d+)$/', $group_code, $match) && is_array($arGroupName) && isset($arGroupName[$match[1]]) && strlen($arGroupName[$match[1]]) > 0 && CModule::IncludeModule("extranet") && (CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false) || $GLOBALS["APPLICATION"]->GetGroupRight("socialnetwork", false, "Y", "Y", array(CExtranet::GetExtranetSiteID(), false)) >= "K")) {
// check and create group, for extranet only
$dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => CExtranet::GetExtranetSiteID()), false, false, array("ID"));
if ($arSubject = $dbSubjects->GetNext()) {
$arSocNetGroupFields = array("NAME" => $arGroupName[$match[1]], "DESCRIPTION" => "", "VISIBLE" => "N", "OPENED" => "N", "CLOSED" => "N", "SUBJECT_ID" => $arSubject["ID"], "INITIATE_PERMS" => "E", "SPAM_PERMS" => "K", "SITE_ID" => array($SITE_ID, CExtranet::GetExtranetSiteID()));
if ($group_id = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arSocNetGroupFields, false)) {
$arGroupToAdd[] = $group_id;
} elseif ($e = $GLOBALS["APPLICATION"]->GetException()) {
$strError = $e->GetString();
}
}
} elseif (preg_match('/^SG(\\d+)$/', $group_code, $match)) {
$group_id = $match[1];
if (($arGroup = CSocNetGroup::GetByID($group_id)) && ($arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arGroup, CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false))) && $arCurrentUserPerms["UserCanInitiate"] && $arGroup["CLOSED"] != "Y") {
$arGroupToAdd[] = $group_id;
}
}
}
if (!$strError) {
foreach ($arGroupToAdd as $group_id) {
foreach ($arUserId as $user_id) {
if (!CSocNetUserToGroup::SendRequestToJoinGroup($GLOBALS["USER"]->GetID(), $user_id, $group_id, "", false)) {
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$strError .= $e->GetString();
}
}
}
}
}
}
return $strError;
}
示例7: IncludeModuleLangFile
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
IncludeModuleLangFile(__FILE__);
$errorMessage = "";
if (check_bitrix_sessid()) {
$GROUP_ID = intval($_REQUEST['GROUP_ID']);
$USER_ID = intval($_REQUEST['USER_ID']);
if ($GROUP_ID && $USER_ID && CModule::IncludeModule('socialnetwork')) {
$arGroup = CSocNetGroup::GetByID($GROUP_ID);
if (intval($arGroup["OWNER_ID"]) != $USER_ID) {
if ($arGroup) {
$CurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arGroup, CSocNetUser::IsCurrentUserModuleAdmin($arGroup["SITE_ID"]));
if ($CurrentUserPerms["UserCanModifyGroup"]) {
$res = CSocNetUserToGroup::SetOwner($USER_ID, $GROUP_ID, $arGroup);
if (!$res && ($e = $GLOBALS["APPLICATION"]->GetException())) {
$errorMessage = $e->GetString();
}
if (strlen($errorMessage) <= 0) {
echo '<script>window.location.reload();</script>';
} else {
echo '<script>alert(\'' . CUtil::JSEscape($errorMessage) . '\');</script>';
}
} else {
echo '<script>alert(\'Access denied!\');</script>';
}
} else {
echo '<script>alert(\'Group error!\');</script>';
}
} else {
// new owner is equal to old one