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 (!CSocNetUserEvents::CheckFields("ADD", $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_sonet_user_events", $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_user_events(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); } return $ID; }
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; }
function SendEvent($relationID, $mailType = "INVITE_FRIEND") { $relationID = IntVal($relationID); if ($relationID <= 0) return false; $dbRelation = CSocNetUserRelations::GetList( array(), array("ID" => $relationID), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID", "RELATION", "DATE_CREATE", "MESSAGE", "INITIATED_BY", "FIRST_USER_NAME", "FIRST_USER_LAST_NAME", "FIRST_USER_LOGIN", "FIRST_USER_EMAIL", "FIRST_USER_LID", "SECOND_USER_NAME", "SECOND_USER_LAST_NAME", "SECOND_USER_LOGIN", "SECOND_USER_EMAIL", "SECOND_USER_LID") ); $arRelation = $dbRelation->Fetch(); if (!$arRelation) return false; $fromUserPref = "FIRST"; $toUserPref = "SECOND"; if ($arRelation["INITIATED_BY"] == "S") { $fromUserPref = "SECOND"; $toUserPref = "FIRST"; } $mailTemplate = "SONET_INVITE_FRIEND"; if ($mailType == "AGREE_FRIEND") $mailTemplate = "SONET_AGREE_FRIEND"; elseif ($mailType == "BAN_FRIEND") $mailTemplate = "SONET_BAN_FRIEND"; $defSiteID = $arRelation[$toUserPref."_USER_LID"]; $siteID = CSocNetUserEvents::GetEventSite($arRelation[$toUserPref."_USER_ID"], $mailTemplate, $defSiteID); if ($siteID == false || StrLen($siteID) <= 0) return false; if (IsModuleInstalled("im")) { $url = str_replace("#USER_ID#", $arRelation[$toUserPref."_USER_ID"], COption::GetOptionString("socialnetwork", "user_request_page", (IsModuleInstalled("intranet")) ? "/company/personal/user/#USER_ID#/requests/" : "/club/user/#USER_ID#/requests/", $siteID)); } else $url = COption::GetOptionString("socialnetwork", "messages_path", "/company/personal/messages/", $siteID); $arFields = array( "RELATION_ID" => $relationID, "SENDER_USER_ID" => $arRelation[$fromUserPref."_USER_ID"], "SENDER_USER_NAME" => $arRelation[$fromUserPref."_USER_NAME"], "SENDER_USER_LAST_NAME" => $arRelation[$fromUserPref."_USER_LAST_NAME"], "SENDER_EMAIL_TO" => $arRelation[$fromUserPref."_USER_EMAIL"], "RECIPIENT_USER_ID" => $arRelation[$toUserPref."_USER_ID"], "RECIPIENT_USER_NAME" => $arRelation[$toUserPref."_USER_NAME"], "RECIPIENT_USER_LAST_NAME" => $arRelation[$toUserPref."_USER_LAST_NAME"], "RECIPIENT_USER_EMAIL_TO" => $arRelation[$toUserPref."_USER_EMAIL"], "MESSAGE" => $arRelation["MESSAGE"], "URL" => $url ); $event = new CEvent; $event->Send($mailTemplate, $siteID, $arFields, "N"); return true; }
function GetEventSite($userID, $event, $defSiteID) { global $arSocNetUserEvents; $userID = IntVal($userID); if ($userID <= 0) { return false; } $event = StrToUpper(Trim($event)); if (!in_array($event, $arSocNetUserEvents)) { return false; } $arUserEvents = array(); if (isset($GLOBALS["SONET_USER_EVENTS_" . $userID]) && is_array($GLOBALS["SONET_USER_EVENTS_" . $userID]) && !in_array("SONET_USER_EVENTS_" . $userID, $_REQUEST)) { $arUserEvents = $GLOBALS["SONET_USER_EVENTS_" . $userID]; } else { $dbResult = CSocNetUserEvents::GetList(array(), array("USER_ID" => $userID)); while ($arResult = $dbResult->Fetch()) { $arUserEvents[$arResult["EVENT_ID"]] = $arResult["ACTIVE"] == "Y" ? $arResult["SITE_ID"] : false; } $GLOBALS["SONET_USER_EVENTS_" . $userID] = $arUserEvents; } if (!array_key_exists($event, $arUserEvents)) { return $defSiteID; } return $arUserEvents[$event]; }
public static function SendEventAgent() { global $DB; if (IsModuleInstalled("im")) { return "CSocNetMessages::SendEventAgent();"; } $dbMessage = CSocNetMessages::GetList(array(), array("DATE_VIEW" => "", "TO_DELETED" => "N", "SEND_MAIL" => "N", "!IS_LOG" => "Y"), false, false, array("ID", "FROM_USER_ID", "TO_USER_ID", "TITLE", "MESSAGE", "DATE_CREATE", "FROM_USER_NAME", "FROM_USER_LAST_NAME", "FROM_USER_LOGIN", "TO_USER_NAME", "TO_USER_LAST_NAME", "TO_USER_LOGIN", "TO_USER_EMAIL", "TO_USER_LID", "EMAIL_TEMPLATE", "IS_LOG")); while ($arMessage = $dbMessage->Fetch()) { if (isset($arMessage["EMAIL_TEMPLATE"]) && strlen($arMessage["EMAIL_TEMPLATE"]) > 0) { $mailTemplate = $arMessage["EMAIL_TEMPLATE"]; } else { $mailTemplate = "SONET_NEW_MESSAGE"; } $defSiteID = $arMessage["TO_USER_LID"]; $siteID = CSocNetUserEvents::GetEventSite($arMessage["TO_USER_ID"], $mailTemplate, $defSiteID); if ($siteID == false || StrLen($siteID) <= 0) { $siteID = CSite::GetDefSite(); } if ($siteID == false || StrLen($siteID) <= 0) { continue; } $arFields = array("MESSAGE_ID" => $arMessage["ID"], "USER_ID" => $arMessage["TO_USER_ID"], "USER_NAME" => $arMessage["TO_USER_NAME"], "USER_LAST_NAME" => $arMessage["TO_USER_LAST_NAME"], "SENDER_ID" => $arMessage["FROM_USER_ID"], "SENDER_NAME" => $arMessage["FROM_USER_NAME"], "SENDER_LAST_NAME" => $arMessage["FROM_USER_LAST_NAME"], "EMAIL_TO" => $arMessage["TO_USER_EMAIL"], "TITLE" => $arMessage["TITLE"], "MESSAGE" => CSocNetTextParser::convert4mail($arMessage["MESSAGE"])); $event = new CEvent(); $event->Send($mailTemplate, $siteID, $arFields, "N"); CSocNetMessages::Update($arMessage["ID"], array("SEND_MAIL" => "Y")); } return "CSocNetMessages::SendEventAgent();"; }