public static function OnUserDelete($ID) { global $DB; if (!CSocNetGroup::__ValidateID($ID)) { return false; } $ID = IntVal($ID); $bSuccess = True; if (!CSocNetGroup::DeleteNoDemand($ID)) { if ($ex = $GLOBALS["APPLICATION"]->GetException()) { $err = $ex->GetString(); } $GLOBALS["APPLICATION"]->ThrowException($err); $bSuccess = false; } if ($bSuccess) { CSocNetUserRelations::DeleteNoDemand($ID); CSocNetUserPerms::DeleteNoDemand($ID); CSocNetUserEvents::DeleteNoDemand($ID); CSocNetMessages::DeleteNoDemand($ID); CSocNetUserToGroup::DeleteNoDemand($ID); CSocNetLogEvents::DeleteNoDemand($ID); CSocNetLog::DeleteNoDemand($ID); CSocNetLogComments::DeleteNoDemand($ID); CSocNetFeatures::DeleteNoDemand($ID); CSocNetSubscription::DeleteEx($ID); CUserOptions::DeleteOption("socialnetwork", "~menu_" . SONET_ENTITY_USER . "_" . $ID, false, 0); } return $bSuccess; }
public static function Add($arFields) { global $DB; $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CSocNetSubscription::CheckFields("ADD", $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_sonet_subscription", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($arInsert[0]) > 0) { $arInsert[0] .= ", "; } $arInsert[0] .= $key; if (strlen($arInsert[1]) > 0) { $arInsert[1] .= ", "; } $arInsert[1] .= $value; } $ID = false; if (strlen($arInsert[0]) > 0) { $strSql = "INSERT INTO b_sonet_subscription(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_subscription_" . $arFields["CODE"]); } return $ID; }
$dbLog = CSocNetLog::GetList(array('ID' => 'DESC'), array('SOURCE_ID' => $arParams['ELEMENT_ID'])); if ($arLog = $dbLog->Fetch()) { $arSoFields = array('=LOG_DATE' => $GLOBALS['DB']->CurrentTimeFunction(), '=LOG_UPDATE' => $GLOBALS['DB']->CurrentTimeFunction(), 'USER_ID' => $GLOBALS['USER']->GetID(), 'TITLE' => $newName, 'TEXT_MESSAGE' => "\n" . GetMessage('WIKI_MODIFY_COMMENT') . ": " . GetMessage('WIKI_PAGE_RENAMED', array("%OLD_NAME%" => $arParams['ELEMENT_NAME'], "%NEW_NAME%" => $newName)) . "\n", 'URL' => $postUrl); //die(print_r($arSoFields,true)); $logID = CSocNetLog::Update($arLog['ID'], $arSoFields); if (intval($logID) > 0) { CSocNetLogRights::SetForSonet($arLog['ID'], SONET_SUBSCRIBE_ENTITY_GROUP, intval($arParams['SOCNET_GROUP_ID']), "wiki", "view"); CSocNetLog::CounterIncrement($logID); $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arLog["TITLE"]); $notify_title_old = TruncateText($notify_title_tmp, 100); $notify_title_old_out = TruncateText($notify_title_tmp, 255); $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $newName); $notify_title_new = TruncateText($notify_title_tmp, 100); $notify_title_new_out = TruncateText($notify_title_tmp, 255); $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arParams['SOCNET_GROUP_ID']), "NOTIFY_MESSAGE" => "", "FROM_USER_ID" => $arSoFields["USER_ID"], "URL" => $arSoFields["URL"], "MESSAGE" => GetMessage("WIKI_SONET_IM_RENAME", array("#title_old#" => $notify_title_old, "#title_new#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">" . $notify_title_new . "</a>")), "MESSAGE_OUT" => GetMessage("WIKI_SONET_IM_RENAME", array("#title_old#" => $notify_title_old_out, "#title_new#" => $notify_title_new_out)) . " (#URL#)", "EXCLUDE_USERS" => array($arSoFields["USER_ID"])); CSocNetSubscription::NotifyGroup($arNotifyParams); } } } $arParams['ELEMENT_NAME'] = $newName; break; } if (empty($arResult['ERROR_MESSAGE'])) { if (!isset($_POST['apply'])) { LocalRedirect(CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), array('wiki_page_cache_clear' => 'Y'))); } else { LocalRedirect(CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST_EDIT'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N' ? array($arParams['OPER_VAR'] => $arResult['WIKI_oper']) : array())); } } else { $arParams['ELEMENT_NAME'] = $arResult['ELEMENT']['NAME']; }
function DeleteRelation($userID, $groupID) { global $APPLICATION; $userID = IntVal($userID); if ($userID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_USERID"), "ERROR_USER_ID"); return false; } $groupID = IntVal($groupID); if ($groupID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_GROUPID"), "ERROR_GROUPID"); return false; } $dbResult = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $groupID, "USER_ID" => $userID), false, false, array("ID", "ROLE", "GROUP_VISIBLE", "GROUP_NAME")); if ($arResult = $dbResult->Fetch()) { if ($arResult["ROLE"] != SONET_ROLES_USER && $arResult["ROLE"] != SONET_ROLES_MODERATOR) { return false; } if (CSocNetUserToGroup::Delete($arResult["ID"])) { if (IsModuleInstalled("im")) { $arNotifyParams = array("TYPE" => "unjoin", "RELATION_ID" => $arResult["ID"], "USER_ID" => $userID, "GROUP_ID" => $groupID, "GROUP_NAME" => $arResult["GROUP_NAME"]); CSocNetUserToGroup::NotifyImToModerators($arNotifyParams); CSocNetSubscription::DeleteEx($userID, "SG" . $groupID); } } 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_DELETE_RELATION"); return false; } } else { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_NO_USER2GROUP"), "ERROR_NO_MEMBER_REQUEST"); return false; } CSocNetUserToGroup::__SpeedFileCheckMessages($userID); return true; }
public static function IsUserSubscribed($userID, $code) { $userID = intval($userID); if ($userID <= 0) { return false; } $code = trim($code); if (strlen($code) <= 0) { return false; } $cache = new CPHPCache(); $cache_time = 31536000; $cache_id = "entity_" . $code; $cache_path = "/sonet/subscription/"; if ($cache->InitCache($cache_time, $cache_id, $cache_path)) { $arCacheVars = $cache->GetVars(); $arSubscriberID = $arCacheVars["arSubscriberID"]; } else { $cache->StartDataCache($cache_time, $cache_id, $cache_path); $arSubscriberID = array(); $rsSubscription = CSocNetSubscription::GetList(array(), array("CODE" => $code)); while ($arSubscription = $rsSubscription->Fetch()) { $arSubscriberID[] = $arSubscription["USER_ID"]; } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path); $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_subscription_" . $code); $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group"); } $arCacheData = array("arSubscriberID" => $arSubscriberID); $cache->EndDataCache($arCacheData); if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->EndTagCache(); } } return in_array($userID, $arSubscriberID); }
public static function NotifyIm($arParams) { if (!CModule::IncludeModule("im")) { return; } $arUsers = array(); $arUserIDSent = array(); if (!empty($arParams["TO_USER_ID"])) { foreach ($arParams["TO_USER_ID"] as $val) { $val = IntVal($val); if ($val > 0 && $val != $arParams["FROM_USER_ID"]) { $arUsers[] = $val; } } } if (!empty($arParams["TO_SOCNET_RIGHTS"])) { foreach ($arParams["TO_SOCNET_RIGHTS"] as $v) { if (substr($v, 0, 1) == "U") { $u = IntVal(substr($v, 1)); if ($u > 0 && !in_array($u, $arUsers) && (!array_key_exists("U", $arParams["TO_SOCNET_RIGHTS_OLD"]) || empty($arParams["TO_SOCNET_RIGHTS_OLD"]["U"][$u])) && $u != $arParams["FROM_USER_ID"]) { $arUsers[] = $u; } } } } $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "blog"); $aditGM = ""; if (IntVal($arParams["FROM_USER_ID"]) > 0) { $dbUser = CUser::GetByID($arParams["FROM_USER_ID"]); if ($arUser = $dbUser->Fetch()) { if ($arUser["PERSONAL_GENDER"] == "F") { $aditGM = "_FEMALE"; } } } if (CModule::IncludeModule("socialnetwork")) { $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("blog_post", "blog_post_important", "blog_post_micro"), "SOURCE_ID" => $arParams["ID"]), false, false, array("ID")); if ($arLog = $rsLog->Fetch()) { $arMessageFields["LOG_ID"] = $arLog["ID"]; } } $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]); $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100); $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255); $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", "")); if (IsModuleInstalled("extranet")) { $user_path = COption::GetOptionString("socialnetwork", "user_page", false, SITE_ID); if (strpos($arParams["URL"], $user_path) === 0) { $arParams["URL"] = str_replace($user_path, "#USER_PATH#", $arParams["URL"]); } } if ($arParams["TYPE"] == "POST") { $arMessageFields["NOTIFY_EVENT"] = "post"; $arMessageFields["NOTIFY_TAG"] = "BLOG|POST|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . ""; } elseif ($arParams["TYPE"] == "COMMENT") { $arMessageFields["NOTIFY_EVENT"] = "comment"; $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "\n\n" . $arParams["BODY"]; $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "\n\n" . $arParams["BODY"]; } elseif ($arParams["TYPE"] == "SHARE") { $arMessageFields["NOTIFY_EVENT"] = "share"; $arMessageFields["NOTIFY_TAG"] = "BLOG|SHARE|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . ""; } elseif ($arParams["TYPE"] == "SHARE2USERS") { $arMessageFields["NOTIFY_EVENT"] = "share2users"; $arMessageFields["NOTIFY_TAG"] = "BLOG|SHARE2USERS|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . ""; } foreach ($arUsers as $v) { if (!empty($arParams["EXCLUDE_USERS"]) && IntVal($arParams["EXCLUDE_USERS"][$v]) > 0) { continue; } if (IsModuleInstalled("extranet")) { $arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arParams["URL"]), $v); $url = $arTmp["URLS"]["URL"]; if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) { $serverName = ""; } else { $serverName = $arTmp["SERVER_NAME"]; } if ($arParams["TYPE"] == "POST") { $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $url . ")"; } elseif ($arParams["TYPE"] == "COMMENT") { $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "\n\n" . $arParams["BODY"]; $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "\n\n" . $arParams["BODY"]; } elseif ($arParams["TYPE"] == "SHARE") { $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . ""; } elseif ($arParams["TYPE"] == "SHARE2USERS") { $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . ""; } } $arMessageFieldsTmp = $arMessageFields; if ($arParams["TYPE"] == "COMMENT") { if ($arParams["AUTHOR_ID"] == $v) { $arMessageFieldsTmp["NOTIFY_MESSAGE"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR"]; $arMessageFieldsTmp["NOTIFY_MESSAGE_OUT"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"]; } } $arMessageFieldsTmp["TO_USER_ID"] = $v; $ID = CIMNotify::Add($arMessageFieldsTmp); $arUserIDSent[] = $v; } if (!empty($arParams["MENTION_ID"])) { if (!is_array($arParams["MENTION_ID_OLD"])) { $arParams["MENTION_ID_OLD"] = array(); } foreach ($arParams["MENTION_ID"] as $val) { $val = IntVal($val); if (IntVal($val) > 0 && !in_array($val, $arUsers) && !in_array($val, $arParams["MENTION_ID_OLD"]) && $val != $arParams["FROM_USER_ID"]) { if (CBlogPost::GetSocNetPostPerms($arParams["ID"], false, $val) >= BLOG_PERMS_READ) { $arMessageFields["TO_USER_ID"] = $val; $arMessageFields["NOTIFY_EVENT"] = "mention"; if (IsModuleInstalled("extranet")) { $arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arParams["URL"]), $val); $url = $arTmp["URLS"]["URL"]; if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) { $serverName = ""; } else { $serverName = $arTmp["SERVER_NAME"]; } if ($arParams["TYPE"] == "POST") { $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . ""; } elseif ($arParams["TYPE"] == "COMMENT") { $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . ""; } } else { if ($arParams["TYPE"] == "POST") { $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . ""; } elseif ($arParams["TYPE"] == "COMMENT") { $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"]; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . ""; } } $ID = CIMNotify::Add($arMessageFields); $arUserIDSent[] = $val; if (intval($ID) > 0 && intval($arMessageFields["LOG_ID"]) > 0) { foreach (GetModuleEvents("blog", "OnBlogPostMentionNotifyIm", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $arMessageFields)); } } } } } } if ($arParams["TYPE"] == "POST" && !empty($arParams["TO_SOCNET_RIGHTS"])) { $arGroupsId = array(); foreach ($arParams["TO_SOCNET_RIGHTS"] as $perm_tmp) { if (preg_match('/^SG(\\d+)_' . SONET_ROLES_USER . '$/', $perm_tmp, $matches) || preg_match('/^SG(\\d+)$/', $perm_tmp, $matches)) { $group_id_tmp = $matches[1]; if ($group_id_tmp > 0 && (!array_key_exists("SG", $arParams["TO_SOCNET_RIGHTS_OLD"]) || empty($arParams["TO_SOCNET_RIGHTS_OLD"]["SG"][$group_id_tmp]))) { $arGroupsId[] = $group_id_tmp; } } } if (!empty($arGroupsId)) { $title_tmp = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]); $title = TruncateText($title_tmp, 100); $title_out = TruncateText($title_tmp, 255); $arNotifyParams = array("LOG_ID" => $arMessageFields["LOG_ID"], "GROUP_ID" => $arGroupsId, "NOTIFY_MESSAGE" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "URL" => $arParams["URL"], "MESSAGE" => GetMessage("SONET_IM_NEW_POST", array("#title#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">" . $title . "</a>")), "MESSAGE_OUT" => GetMessage("SONET_IM_NEW_POST", array("#title#" => $title_out)) . " #URL#", "EXCLUDE_USERS" => array_merge(array($arParams["FROM_USER_ID"]), array($arUserIDSent))); CSocNetSubscription::NotifyGroup($arNotifyParams); } } }
if (!$GLOBALS["USER"]->IsAuthorized()) { echo CUtil::PhpToJsObject(array("ERROR" => "CURRENT_USER_NOT_AUTH")); die; } $groupID = intval($_POST["groupID"]); if ($groupID <= 0) { echo CUtil::PhpToJsObject(array("ERROR" => "EMPTY_GROUP_ID")); die; } if (check_bitrix_sessid()) { if (in_array($_POST["action"], array("set", "unset"))) { $userRole = CSocNetUserToGroup::GetUserRole($GLOBALS["USER"]->GetID(), $groupID); if (!in_array($userRole, array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR, SONET_ROLES_USER))) { echo CUtil::PhpToJsObject(array("ERROR" => "INCORRECT_USER_ROLE")); die; } if (CSocNetSubscription::Set($GLOBALS["USER"]->GetID(), "SG" . $groupID, $_POST["action"] == "set" ? "Y" : "N")) { $rsSubscription = CSocNetSubscription::GetList(array(), array("USER_ID" => $GLOBALS["USER"]->GetID(), "CODE" => "SG" . $groupID)); if ($arSubscription = $rsSubscription->Fetch()) { echo CUtil::PhpToJsObject(array("SUCCESS" => "Y", "RESULT" => "Y")); } else { echo CUtil::PhpToJsObject(array("SUCCESS" => "Y", "RESULT" => "N")); } } } else { echo CUtil::PhpToJsObject(array("ERROR" => "UNKNOWN_ACTION")); } } else { echo CUtil::PhpToJsObject(array("ERROR" => "SESSION_ERROR")); } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
function CreateGroup($ownerID, $arFields, $bAutoSubscribe = true) { global $APPLICATION, $DB; $ownerID = IntVal($ownerID); if ($ownerID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_OWNERID") . ". ", "ERROR_OWNERID"); return false; } if (!isset($arFields) || !is_array($arFields)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_FIELDS") . ". ", "ERROR_FIELDS"); return false; } $DB->StartTransaction(); $arFields["=DATE_CREATE"] = $GLOBALS["DB"]->CurrentTimeFunction(); $arFields["=DATE_UPDATE"] = $GLOBALS["DB"]->CurrentTimeFunction(); $arFields["=DATE_ACTIVITY"] = $GLOBALS["DB"]->CurrentTimeFunction(); $arFields["ACTIVE"] = "Y"; $arFields["OWNER_ID"] = $ownerID; if (!is_set($arFields, "SPAM_PERMS") || strlen($arFields["SPAM_PERMS"]) <= 0) { $arFields["SPAM_PERMS"] = SONET_ROLES_OWNER; } $groupID = CSocNetGroup::Add($arFields); if (!$groupID || IntVal($groupID) <= 0) { $errorMessage = ""; if ($e = $APPLICATION->GetException()) { $errorMessage = $e->GetString(); $errorID = $e->GetID(); if (StrLen($errorID) <= 0 && isset($e->messages) && is_array($e->messages) && is_array($e->messages[0]) && array_key_exists("id", $e->messages[0])) { $errorID = $e->messages[0]["id"]; } } if (StrLen($errorMessage) <= 0) { $errorMessage = GetMessage("SONET_UR_ERROR_CREATE_GROUP") . ". "; } if (StrLen($errorID) <= 0) { $errorID = "ERROR_CREATE_GROUP"; } $GLOBALS["APPLICATION"]->ThrowException($errorMessage, $errorID); $DB->Rollback(); return false; } $arFields1 = array("USER_ID" => $ownerID, "GROUP_ID" => $groupID, "ROLE" => SONET_ROLES_OWNER, "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $ownerID, "MESSAGE" => false); if (!CSocNetUserToGroup::Add($arFields1)) { $errorMessage = ""; if ($e = $APPLICATION->GetException()) { $errorMessage = $e->GetString(); } if (StrLen($errorMessage) <= 0) { $errorMessage = GetMessage("SONET_UR_ERROR_CREATE_U_GROUP") . ". "; } $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_GROUP"); $DB->Rollback(); return false; } if ($bAutoSubscribe) { CSocNetLogEvents::AutoSubscribe($ownerID, SONET_ENTITY_GROUP, $groupID); } CSocNetSubscription::Set($ownerID, "SG" . $groupID, "Y"); $DB->Commit(); return $groupID; }
} if (CModule::IncludeModule("extranet")) { $arExtranetUserID = array(); $arFilter = array("GROUPS_ID" => array(CExtranet::GetExtranetUserGroupID()), "UF_DEPARTMENT" => false); $rsUsers = CUser::GetList($by = "ID", $order = "asc", $arFilter); while ($arUser = $rsUsers->Fetch()) { $arExtranetUserID[] = $arUser["ID"]; } } $arResult["Group"] = $arGroup; if ($arResult["Group"]["CLOSED"] == "Y" && COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") { $arResult["HideArchiveLinks"] = true; } $arResult["CurrentUserPerms"] = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arResult["Group"], CSocNetUser::IsCurrentUserModuleAdmin()); if (in_array($arResult["CurrentUserPerms"]["UserRole"], array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR, SONET_ROLES_USER))) { $arResult["bSubscribed"] = CSocNetSubscription::IsUserSubscribed($GLOBALS["USER"]->GetID(), "SG" . $arParams["GROUP_ID"]); } else { $arResult["bSubscribed"] = false; } if ($arResult["Group"]["VISIBLE"] == "Y" && !$arResult["bExtranet"] && !$arResult["HideArchiveLinks"] && (!$arResult["CurrentUserPerms"]["UserRole"] || $arResult["CurrentUserPerms"]["UserRole"] == SONET_ROLES_REQUEST && $arResult["CurrentUserPerms"]["InitiatedByType"] == SONET_INITIATED_BY_GROUP)) { $arResult["bUserCanRequestGroup"] = true; $arResult["bDescriptionOpen"] = true; } elseif ($GLOBALS["USER"]->IsAuthorized()) { $arUserOptions = CUserOptions::GetOption("socialnetwork", "sonet_group_description", array(), $GLOBALS["USER"]->GetID()); if (is_array($arUserOptions) && array_key_exists("state", $arUserOptions)) { $arResult["bDescriptionOpen"] = $arUserOptions["state"] == "Y"; } } else { $arResult["bDescriptionOpen"] = true; } //display flag to show information when the group request is sent
public static function OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult) { static $arSiteWorkgroupsPage; if (!CModule::IncludeModule("iblock")) { return; } if (!array_key_exists("IS_SOCNET", $arComponentParams) || $arComponentParams["IS_SOCNET"] != "Y") { return; } $bPassword = false; $arComponentResult["SECTION"]["PATH"] = array(); $rsSectionAlbum = CIBlockSection::GetList(array(), array("ID" => intval($arFields["IBLOCK_SECTION"])), false, array("ID", "LEFT_MARGIN", "RIGHT_MARGIN", "DEPTH_LEVEL")); if ($arSectionAlbum = $rsSectionAlbum->Fetch()) { $dbSection = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arComponentParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSectionAlbum["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSectionAlbum["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSectionAlbum["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD")); while ($arPath = $dbSection->Fetch()) { $arComponentResult["SECTION"]["PATH"][] = $arPath; } } foreach ($arComponentResult["SECTION"]["PATH"] as $arPathSection) { if (strlen(trim($arPathSection["UF_PASSWORD"])) > 0) { $bPassword = true; break; } } if (array_key_exists("USER_ALIAS", $arComponentParams) && strlen($arComponentParams["USER_ALIAS"]) > 0) { $arTmp = explode("_", $arComponentParams["USER_ALIAS"]); if (is_array($arTmp) && count($arTmp) == 2) { $entity_type = $arTmp[0]; $entity_id = $arTmp[1]; if ($entity_type == "group") { $entity_type = SONET_ENTITY_GROUP; } elseif ($entity_type == "user") { $entity_type = SONET_ENTITY_USER; } } if ((!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER)) || intval($entity_id) <= 0) && count($arComponentResult["SECTION"]["PATH"]) > 0) { $entity_type = SONET_ENTITY_USER; $entity_id = $arComponentResult["SECTION"]["PATH"][0]["CREATED_BY"]; } } if (!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER)) || intval($entity_id) <= 0) { return; } if (!$arSiteWorkgroupsPage && IsModuleInstalled("extranet") && $entity_type == SONET_ENTITY_GROUP) { $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($arSite = $rsSite->Fetch()) { $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]); } } if (is_set($arComponentParams["DETAIL_URL"]) && is_array($arSiteWorkgroupsPage) && $entity_type == SONET_ENTITY_GROUP) { foreach ($arSiteWorkgroupsPage as $groups_page) { if (strpos($arComponentParams["DETAIL_URL"], $groups_page) === 0) { $arComponentParams["DETAIL_URL"] = "#GROUPS_PATH#" . substr($arComponentParams["DETAIL_URL"], strlen($groups_page), strlen($arComponentParams["DETAIL_URL"]) - strlen($groups_page)); } } } $db_res = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo", "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"] . "_" . $arFields["MODIFIED_BY"], ">=LOG_UPDATE" => ConvertTimeStamp(AddToTimeStamp(array("MI" => -5)) + CTimeZone::GetOffset(), "FULL"))); if (array_key_exists("SECTION", $arComponentResult) && array_key_exists("NAME", $arComponentResult["SECTION"])) { $strSectionName = $arComponentResult["SECTION"]["NAME"]; } else { $strSectionName = $arComponentResult["SECTION"]["PATH"][count($arComponentResult["SECTION"]["PATH"]) - 1]["NAME"]; } if (array_key_exists("URL", $arComponentResult) && array_key_exists("SECTION_EMPTY", $arComponentResult["URL"])) { $strSectionUrl = $arComponentResult["URL"]["SECTION_EMPTY"]; } else { $strSectionUrl = $arComponentResult["SECTION_URL"]; } $strSectionUrl = str_replace(array("#SECTION_ID#", "#section_id#"), $arFields["IBLOCK_SECTION"], $strSectionUrl); if ($db_res && ($res = $db_res->Fetch())) { if (strlen($res["PARAMS"]) > 0) { $arResParams = unserialize($res["PARAMS"]); array_push($arResParams["arItems"], $arFields["ID"]); } else { return; } $arLogParams = array("COUNT" => $arResParams["COUNT"] + 1, "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"], "ALIAS" => $arComponentParams["USER_ALIAS"], "DETAIL_URL" => $arResParams["DETAIL_URL"], "arItems" => $arResParams["arItems"]); $arSonetFields = array("=LOG_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "PARAMS" => serialize($arLogParams)); CSocNetLog::Update($res["ID"], $arSonetFields); if (!$bPassword) { CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view"); } $logID = $res["ID"]; } else { $arLogParams = array("COUNT" => 1, "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"], "DETAIL_URL" => $arComponentParams["DETAIL_URL"], "ALIAS" => $arComponentParams["USER_ALIAS"], "arItems" => array($arFields["ID"])); $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST"); $sAuthorUrl = ""; if ($GLOBALS["USER"]->IsAuthorized()) { $sAuthorName = trim($GLOBALS["USER"]->GetFullName()); $sAuthorName = empty($sAuthorName) ? $GLOBALS["USER"]->GetLogin() : $sAuthorName; } $arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTO_LOG_1")), "TITLE" => str_replace("#COUNT#", "1", GetMessage("SONET_PHOTO_LOG_2")), "MESSAGE" => "", "URL" => $strSectionUrl, "MODULE_ID" => false, "CALLBACK_FUNC" => false, "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"] . "_" . $arFields["MODIFIED_BY"], "PARAMS" => serialize($arLogParams), "SOURCE_ID" => $arFields["IBLOCK_SECTION"]); $serverName = defined("SITE_SERVER_NAME") && strLen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name"); $arSonetFields["TEXT_MESSAGE"] = str_replace(array("#TITLE#"), array($strSectionName), GetMessage("SONET_PHOTO_LOG_MAIL_TEXT")); if ($GLOBALS["USER"]->IsAuthorized()) { $arSonetFields["USER_ID"] = $GLOBALS["USER"]->GetID(); } $logID = CSocNetLog::Add($arSonetFields, false); if (intval($logID) > 0) { CSocNetLog::Update($logID, array("TMP_ID" => $logID, "RATING_TYPE_ID" => "IBLOCK_SECTION", "RATING_ENTITY_ID" => $arFields["IBLOCK_SECTION"])); if ($bPassword) { CSocNetLogRights::DeleteByLogID($logID); CSocNetLogRights::Add($logID, array("U" . $GLOBALS["USER"]->GetID(), "SA")); } else { CSocNetLogRights::SetForSonet($logID, $entity_type, $entity_id, "photo", "view", true); } CSocNetLog::CounterIncrement($logID); } } if ($entity_type == SONET_ENTITY_GROUP) { $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID)); while ($arRight = $dbRight->Fetch()) { if ($arRight["GROUP_CODE"] == "SG" . $entity_id . "_" . SONET_ROLES_USER) { $title_tmp = str_replace(array("\r\n", "\n"), " ", $strSectionName); $title = TruncateText($title_tmp, 100); $title_out = TruncateText($title_tmp, 255); $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => array($entity_id), "NOTIFY_MESSAGE" => "", "FROM_USER_ID" => $arFields["MODIFIED_BY"], "URL" => $strSectionUrl, "MESSAGE" => GetMessage("SONET_IM_NEW_PHOTO", array("#title#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">" . $title . "</a>")), "MESSAGE_OUT" => GetMessage("SONET_IM_NEW_PHOTO", array("#title#" => $title_out)) . " (#URL#)", "EXCLUDE_USERS" => array($arFields["MODIFIED_BY"])); CSocNetSubscription::NotifyGroup($arNotifyParams); break; } } } }
private function notifySonetGroup(File $fileModel) { //todo create NotifyManager, which provides notify (not only group) if (!Loader::includeModule('socialnetwork')) { return; } $storage = $fileModel->getStorage(); if (!$storage->getProxyType() instanceof Group) { return; } $groupId = (int) $storage->getEntityId(); if ($groupId <= 0) { return; } $fileUrl = Driver::getInstance()->getUrlManager()->getPathFileDetail($fileModel); $fileCreatedBy = $fileModel->getCreatedBy(); $fileName = $fileModel->getName(); /** @noinspection PhpDynamicAsStaticMethodCallInspection */ \CSocNetSubscription::notifyGroup(array('LOG_ID' => false, 'GROUP_ID' => array($groupId), 'NOTIFY_MESSAGE' => '', 'FROM_USER_ID' => $fileCreatedBy, 'URL' => $fileUrl, 'MESSAGE' => Loc::getMessage('DISK_FOLDER_MODEL_IM_NEW_FILE', array('#TITLE#' => '<a href="#URL#" class="bx-notifier-item-action">' . $fileName . '</a>')), 'MESSAGE_OUT' => Loc::getMessage('DISK_FOLDER_MODEL_IM_NEW_FILE', array('#TITLE#' => $fileName)) . ' (#URL#)', 'EXCLUDE_USERS' => array($fileCreatedBy))); }
function CheckRequest() { global $DB; $result = ""; if (!CModule::IncludeModule("socialnetwork")) { return $result; } $current_time = time(); $time_of_exec = false; $rsScheme = CXDILFScheme::GetList(array(), array("ACTIVE" => "Y", "AUTO" => "Y")); while (($arScheme = $rsScheme->Fetch()) && $time_of_exec === false) { if ($arScheme["LAST_EXECUTED"] == '') { continue; } $last_executed = MakeTimeStamp(ConvertDateTime($arScheme["LAST_EXECUTED"], "DD.MM.YYYY HH:MI:SS"), "DD.MM.YYYY HH:MI:SS"); if ($last_executed <= 0) { continue; } $arEventTmp = CSocNetLogTools::FindLogEventByID($arScheme["EVENT_ID"]); if (array_key_exists("REAL_EVENT_ID", $arEventTmp) && strlen($arEventTmp["REAL_EVENT_ID"]) > 0) { $arScheme["EVENT_ID"] = $arEventTmp["REAL_EVENT_ID"]; } //parse schedule $arDoM = CXDImport::ParseDaysOfMonth($arScheme["DAYS_OF_MONTH"]); $arDoW = CXDImport::ParseDaysOfWeek($arScheme["DAYS_OF_WEEK"]); $arToD = CXDImport::ParseTimesOfDay($arScheme["TIMES_OF_DAY"]); if ($arToD) { sort($arToD, SORT_NUMERIC); } $arSDate = localtime($last_executed); //sdate = truncate(last_execute) $sdate = mktime(0, 0, 0, $arSDate[4] + 1, $arSDate[3], $arSDate[5] + 1900); while ($sdate < $current_time && $time_of_exec === false) { $arSDate = localtime($sdate); if ($arSDate[6] == 0) { $arSDate[6] = 7; } //determine if date is good for execution if ($arDoM) { $flag = array_search($arSDate[3], $arDoM); if ($arDoW) { $flag = array_search($arSDate[6], $arDoW); } } elseif ($arDoW) { $flag = array_search($arSDate[6], $arDoW); } else { $flag = false; } if ($flag !== false && $arToD) { foreach ($arToD as $intToD) { if ($sdate + $intToD > $last_executed && $sdate + $intToD <= $current_time) { $time_of_exec = $sdate + $intToD; break; } } } $sdate = mktime(0, 0, 0, date("m", $sdate), date("d", $sdate) + 1, date("Y", $sdate)); //next day } if ($time_of_exec !== false) { if ($arScheme["TYPE"] == "XML") { $arParams = array(); if (strlen($arScheme["PARAMS"]) > 0) { $arTmp = explode("&", $arScheme["PARAMS"]); if (is_array($arTmp) && count($arTmp) > 0) { foreach ($arTmp as $pair) { list($key, $value) = explode("=", $pair); $arParams[$key] = $value; } } } $arResponse = CXDILFSchemeXML::Request($arScheme["HOST"], $arScheme["PAGE"], $arScheme["PORT"], $arScheme["METHOD"], "http://" . $arScheme["HOST"], $arScheme["LOGIN"], $arScheme["PASSWORD"], $arParams); if ($arResponse && is_array($arResponse)) { if (XDI_DEBUG) { CXDImport::WriteToLog("Successful webservice response, scheme ID: " . $arScheme["ID"], "RXML"); } $entityName = $arScheme["NAME"]; if ($arScheme["EVENT_ID"] == "news") { $rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y", "TYPE" => "news", "ID" => $arScheme["ENTITY_ID"])); if ($arIBlock = $rsIBlock->Fetch()) { $entityName = $arIBlock["NAME"]; } } $arLogParams = array("ENTITY_NAME" => $entityName, "ENTITY_URL" => $arResponse["URL"]); $arSonetFields = array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "ENABLE_COMMENTS" => $arScheme["ENABLE_COMMENTS"], "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $arResponse["TITLE"], "TITLE" => $arResponse["TITLE"], "MESSAGE" => $arResponse["MESSAGE"], "TEXT_MESSAGE" => $arResponse["TEXT_MESSAGE"], "URL" => $arResponse["URL"], "PARAMS" => serialize($arLogParams), "MODULE_ID" => false, "CALLBACK_FUNC" => false); $logID = CSocNetLog::Add($arSonetFields, false); if (intval($logID) > 0) { $arUpdateFields = array("TMP_ID" => $logID, "RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logID); CSocNetLog::Update($logID, $arUpdateFields); CXDILFScheme::SetSonetLogRights($logID, $arScheme["ENTITY_TYPE"], $arScheme["ENTITY_ID"], $arScheme["EVENT_ID"]); CSocNetLog::CounterIncrement($logID); if ($arScheme["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arScheme["ENTITY_ID"]) > 0) { $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arScheme["NAME"]); $notify_title = TruncateText($notify_title_tmp, 100); $notify_title_out = TruncateText($notify_title_tmp, 255); $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arScheme["ENTITY_ID"]), "NOTIFY_MESSAGE" => "", "URL" => "", "MESSAGE" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title)), "MESSAGE_OUT" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title_out)), "EXCLUDE_USERS" => array()); CSocNetSubscription::NotifyGroup($arNotifyParams); } } } else { CXDImport::WriteToLog("ERROR: Incorrect webservice response. Scheme ID: " . $arScheme["ID"] . ", server: " . $arScheme["HOST"] . ", port: " . $arScheme["PORT"] . ", page: " . $arScheme["PAGE"] . ", method: " . $arScheme["METHOD"] . ", params: " . $arScheme["PARAMS"], "RXML"); } } elseif ($arScheme["TYPE"] == "RSS") { $arResponse = CXDILFSchemeRSS::Request($arScheme["HOST"], $arScheme["PAGE"], $arScheme["PORT"], $arScheme["PARAMS"], $arScheme["URI"]); if ($arResponse && is_array($arResponse) && array_key_exists("item", $arResponse) && is_array($arResponse["item"]) && count($arResponse["item"]) > 0) { if (XDI_DEBUG) { CXDImport::WriteToLog("Successful RSS response. Scheme ID: " . $arScheme["ID"], "RRSS"); } foreach ($arResponse["item"] as $arItem) { $checksum = md5(serialize($arItem)); $rsLogEvents = CSocNetLog::GetList(array(), array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "EXTERNAL_ID" => $checksum), false, array("nTopCount" => 1)); $arLogEvent = $rsLogEvents->Fetch(); if (!$arLogEvent) { $entityName = $arScheme["NAME"]; if ($arScheme["EVENT_ID"] == "news") { $rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y", "TYPE" => "news", "ID" => $arScheme["ENTITY_ID"])); if ($arIBlock = $rsIBlock->Fetch()) { $entityName = $arIBlock["NAME"]; } } $arLogParams = array("SCHEME_ID" => $arScheme["ID"], "ENTITY_NAME" => $entityName, "ENTITY_URL" => $arResponse["link"]); if (strlen($arItem["pubDate"]) > 0) { $arLogParams["SOURCE_TIMESTAMP"] = strtotime($arItem["pubDate"]); } $description = preg_replace("#^(.*?)([\\s]*<br[\\s]*/>)+[\\s]*[\n]*[\\s]*\$#is", "\\1", $arItem["description"]); $arSonetFields = array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "ENABLE_COMMENTS" => $arScheme["ENABLE_COMMENTS"], "TITLE_TEMPLATE" => $arItem["title"], "TITLE" => $arItem["title"], "MESSAGE" => $description, "TEXT_MESSAGE" => "", "URL" => $arItem["link"], "PARAMS" => serialize($arLogParams), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "EXTERNAL_ID" => $checksum, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction()); $logID = CSocNetLog::Add($arSonetFields, false); if (intval($logID) > 0) { $arUpdateFields = array("TMP_ID" => $logID, "RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logID); CSocNetLog::Update($logID, $arUpdateFields); CXDILFScheme::SetSonetLogRights($logID, $arScheme["ENTITY_TYPE"], $arScheme["ENTITY_ID"], $arScheme["EVENT_ID"]); CSocNetLog::CounterIncrement($logID); if ($arScheme["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arScheme["ENTITY_ID"]) > 0) { $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arScheme["NAME"]); $notify_title = TruncateText($notify_title_tmp, 100); $notify_title_out = TruncateText($notify_title_tmp, 255); $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arScheme["ENTITY_ID"]), "NOTIFY_MESSAGE" => "", "URL" => "", "MESSAGE" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title)), "MESSAGE_OUT" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title_out)), "EXCLUDE_USERS" => array()); CSocNetSubscription::NotifyGroup($arNotifyParams); } } } elseif (XDI_DEBUG) { CXDImport::WriteToLog("RSS item is already in log. Scheme ID: " . $arScheme["ID"] . ", log ID: " . $arLogEvent["ID"], "RRSS"); } } } else { CXDImport::WriteToLog("ERROR: Incorrect RSS response. Scheme ID: " . $arScheme["ID"] . ", server: " . $arScheme["HOST"] . ", port: " . $arScheme["PORT"] . ", page: " . $arScheme["PAGE"] . ", params: " . $arScheme["PARAMS"], "RRSS"); } } $strSql = "UPDATE b_xdi_lf_scheme SET LAST_EXECUTED=" . $DB->GetNowFunction() . " WHERE ID=" . intval($arScheme["ID"]); $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } $result = "CXDILFScheme::CheckRequest();"; } return $result; }
foreach ($arGroups as $ind => $arGroup) { $idTmp = CSocNetGroup::Add($arGroup); if ($idTmp) { $arGroupsId[$ind] = IntVal($idTmp); } else { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorString .= $e->GetString(); } $bSonetError = true; } } } if (!$bSonetError) { foreach ($arGroupsId as $ind => $val) { CSocNetUserToGroup::Add(array("USER_ID" => 1, "GROUP_ID" => $val, "ROLE" => "A", "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => 1, "MESSAGE" => false)); CSocNetSubscription::Set(1, "SG" . $val, "Y"); } foreach ($arGroupsId as $ind => $val) { CSocNetFeatures::Add(array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $val, "FEATURE" => "forum", "FEATURE_NAME" => GetSocNetMessageLocal("SONET_I_FEATURE_FORUM", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction())); CSocNetFeatures::Add(array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $val, "FEATURE" => "blog", "FEATURE_NAME" => GetSocNetMessageLocal("SONET_I_FEATURE_BLOG", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction())); } } } } // ------------------ FORUM ------------------------------- $forumID = 0; if (CModule::IncludeModule("forum")) { $dbResult = CForumNew::GetListEx(array(), array("SITE_ID" => $arSite["SITE_ID"], "XML_ID" => "car_forum_demo")); if ($arResult = $dbResult->Fetch()) { $forumID = $arResult["ID"]; } else {
public function SocnetNotify($arParams, $file = null) { if (!class_exists('CSocNetSubscription')) { return; } if (!array_key_exists("group_id", $arParams["OBJECT"]["ATTRIBUTES"]) || intval($arParams["OBJECT"]["ATTRIBUTES"]["group_id"]) <= 0) { return; } if (array_key_exists("dropped", $arParams["ELEMENT"]) && $arParams["ELEMENT"]["dropped"]) { return; } $arReaders = CWebDavIblock::GetReaders($arParams["ELEMENT"]["id"], $arParams["OBJECT"]["IBLOCK_ID"]); if (!in_array("SG" . intval($arParams["OBJECT"]["ATTRIBUTES"]["group_id"]) . "_" . SONET_ROLES_USER, $arReaders)) { return; } $url = $this->arPath["PATH_TO_GROUP_FILES_ELEMENT"]; if (IsModuleInstalled("extranet") && strlen($this->arPath["SEF_FOLDER"]) > 0 && strpos($url, $this->arPath["SEF_FOLDER"]) === 0) { $url = str_replace($this->arPath["SEF_FOLDER"], "#GROUPS_PATH#", $url); } $urlParams = array("SECTION_ID" => isset($arParams["OBJECT"]["SECTION_ID"]) ? $arParams["OBJECT"]["SECTION_ID"] : $arParams["section_id"], "ELEMENT_ID" => $arParams["ELEMENT"]["id"], "element_id" => $arParams["ELEMENT"]["id"], "ID" => $arParams["ELEMENT"]["id"], "group_id" => intval($arParams["OBJECT"]["ATTRIBUTES"]["group_id"]), "GROUP_ID" => intval($arParams["OBJECT"]["ATTRIBUTES"]["group_id"])); if (strpos($url, "#PATH#") !== false && $this->object != null) { $urlParams["PATH"] = $this->object->GetObjectPath($this->object->GetObject(array("element_id" => $arParams["ELEMENT"]["id"]))); } $arNotifyParams = array("LOG_ID" => false, "GROUP_ID" => array(intval($arParams["OBJECT"]["ATTRIBUTES"]["group_id"])), "NOTIFY_MESSAGE" => "", "FROM_USER_ID" => intval($arParams["ELEMENT"]["element"]["element_array"]["CREATED_BY"]), "URL" => str_replace(array('///', '//'), '/', CComponentEngine::MakePathFromTemplate($url, $urlParams)), "MESSAGE" => GetMessage("SONET_IM_NEW_FILE", array("#title#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">" . $arParams["ELEMENT"]["name"] . "</a>")), "MESSAGE_OUT" => GetMessage("SONET_IM_NEW_FILE", array("#title#" => $arParams["ELEMENT"]["name"])) . " (#URL#)", "EXCLUDE_USERS" => array(intval($arParams["ELEMENT"]["element"]["element_array"]["CREATED_BY"]))); CSocNetSubscription::NotifyGroup($arNotifyParams); return true; }
echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : ""))); die; } elseif ($_POST['ACTION'] == 'SETOWNER' && !CSocNetUserToGroup::SetOwner($arUserID[0], $arGroup["ID"], $arGroup)) { echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : ""))); die; } elseif ($_POST['ACTION'] == 'BAN' && !CSocNetUserToGroup::BanMember($GLOBALS["USER"]->GetID(), $arGroup["ID"], $arRelationID, CSocNetUser::IsCurrentUserModuleAdmin())) { echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : ""))); die; } elseif ($_POST['ACTION'] == 'UNBAN' && !CSocNetUserToGroup::UnBanMember($GLOBALS["USER"]->GetID(), $arGroup["ID"], $arRelationID, CSocNetUser::IsCurrentUserModuleAdmin())) { echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : ""))); die; } elseif ($_POST['ACTION'] == 'EX') { foreach ($arRelalationData as $relationData) { //group owner can't exclude himself from the group if ($relationData["ROLE"] == SONET_ROLES_OWNER) { echo CUtil::PhpToJsObject(array('ERROR' => 'SONET_GUE_T_OWNER_CANT_EXCLUDE_HIMSELF')); die; } if (!CSocNetUserToGroup::Delete($relationData["ID"], true)) { echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : ""))); die; } else { CSocNetSubscription::DeleteEx($relationData["USER_ID"], "SG" . $relationData["GROUP_ID"]); } } } echo CUtil::PhpToJsObject(array('SUCCESS' => 'Y')); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'SESSION_ERROR')); } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";