示例#1
0
文件: user.php 项目: rasuldev/torino
 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;
 }
示例#2
0
 function _FormatUser(&$arUser, $arPath)
 {
     global $USER, $CACHE_ABSENCE;
     if ($arUser['PERSONAL_PHOTO']) {
         $arImage = CIntranetUtils::InitImage($arUser['PERSONAL_PHOTO'], 30);
         $arUser['PERSONAL_PHOTO'] = $arImage['IMG'];
     }
     if ($arPath['DETAIL_URL']) {
         $arUser['DETAIL_URL'] = str_replace('#ID#', $arUser['ID'], $arPath['DETAIL_URL']);
     }
     $arUser["canViewProfile"] = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $arUser['ID'], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
     $arUser["canMessage"] = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $arUser['ID'], "message", CSocNetUser::IsCurrentUserModuleAdmin());
     if ($arPath['MESSAGES_CHAT_URL']) {
         $arUser['MESSAGES_CHAT_URL'] = str_replace('#ID#', $arUser['ID'], $arPath['MESSAGES_CHAT_URL']);
     }
     $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']);
     $arUser['IS_ONLINE'] = CSocNetUser::IsOnLine($arUser['ID']);
     if ($arUser['IS_ABSENT']) {
         $maxAbsence = 0;
         foreach ($CACHE_ABSENCE[$arUser["ID"]] as $arAbsence) {
             if (MakeTimeStamp($arAbsence["DATE_TO"]) > $maxAbsence) {
                 $arUser['ABSENT_TILL'] = $arAbsence["DATE_TO"];
             }
         }
     }
     $arFilter = array("TO_USER_ID" => $arUser['ID'], "MESSAGE_TYPE" => SONET_MESSAGE_PRIVATE, "FROM_USER_ID" => $USER->GetID());
     $dbMessages = CSocNetMessages::GetList(array("DATE_CREATE" => "DESC"), $arFilter, false, array("nTopCount" => 1), array("ID", "DATE_CREATE"));
     if ($arMessages = $dbMessages->GetNext()) {
         $arUser['LAST_CHAT'] = $arMessages["DATE_CREATE"];
     }
     return true;
 }
 /**
  * @param int $idUserFrom
  * @param int $idUserTo
  * @param string $title
  * @param string $type
  * @param string $idQuestion
  * @param string $textMessage
  * @return int
  */
 public static function sendMes($idUserFrom = 1, $idUserTo = 1, $title, $idQuestion, $textMessage = "", $type = "P")
 {
     $res = false;
     $senderUserID = $idUserFrom;
     $targetUserID = $idUserTo;
     $arFieldsMes = array("FROM_USER_ID" => $senderUserID, "TO_USER_ID" => $targetUserID, "TITLE" => $title, "MESSAGE" => $idQuestion, "DATE_CREATE" => date("d.m.Y H:i:s", time() - DIFFERENT_WITH_MOSCOW_TIME), "DATE_VIEW" => false, "MESSAGE_TYPE" => $type, "FROM_DELETED" => "N", "TO_DELETED" => "N", "SEND_MAIL" => "Y");
     if (CModule::IncludeModule("socialnetwork")) {
         $res = CSocNetMessages::Add($arFieldsMes);
         if ($res) {
             if (CModule::IncludeModule("iblock")) {
                 if (CModule::IncludeModule('payments')) {
                     $userInfo = new CLawPayment();
                     $InfoUserFrom = $userInfo->userInfo($idUserFrom);
                     $InfoUserTo = $userInfo->userInfo($idUserTo);
                     $emailFrom = $InfoUserFrom["EMAIL"];
                     $emailUser = $InfoUserTo["EMAIL"];
                     SendMessage::sendMessOnEmail($emailFrom, $emailUser, $title, $textMessage);
                 }
             }
         } else {
             $errorMessage = "";
             if ($err = $GLOBALS["APPLICATION"]->GetException()) {
                 $errorMessage = $err->GetString();
             }
             if (StrLen($errorMessage) <= 0) {
                 $errorMessage = GetMessage("SONET_UR_ERROR_CREATE_MESSAGE");
             }
             $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_MESSAGE");
         }
     }
     return $res;
 }
示例#4
0
 function Update($ID, $arFields)
 {
     global $DB;
     if (!CSocNetGroup::__ValidateID($ID)) {
         return false;
     }
     $ID = IntVal($ID);
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSocNetMessages::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetMessagesUpdate");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID, $arFields)) === false) {
             return false;
         }
     }
     $strUpdate = $DB->PrepareUpdate("b_sonet_messages", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (strlen($strUpdate) > 0) {
         $strSql = "UPDATE b_sonet_messages SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $events = GetModuleEvents("socialnetwork", "OnSocNetMessagesUpdate");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, $arFields));
         }
     } else {
         $ID = False;
     }
     return $ID;
 }
 public function Execute()
 {
     if (!CModule::IncludeModule("socialnetwork")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $arMessageUserFrom = CBPHelper::ExtractUsers($this->MessageUserFrom, $documentId, true);
     $arMessageUserTo = CBPHelper::ExtractUsers($this->MessageUserTo, $documentId, false);
     $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $arMessageUserFrom, "MESSAGE" => CBPHelper::ConvertTextForMail($this->MessageText));
     $ar = array();
     foreach ($arMessageUserTo as $userTo) {
         if (in_array($userTo, $ar)) {
             continue;
         }
         $ar[] = $userTo;
         $arMessageFields["TO_USER_ID"] = $userTo;
         CSocNetMessages::Add($arMessageFields);
     }
     return CBPActivityExecutionStatus::Closed;
 }
示例#6
0
        } else {
            $message = $_REQUEST["data"];
            CUtil::decodeURIComponent($message);
            $message = Trim($message);
            if (StrLen($message) <= 0) {
                echo GetMessage("SONET_C50_NO_TEXT") . ".";
            } else {
                if (empty($aUserId)) {
                    echo GetMessage("SONET_C50_NO_USER_ID") . ".";
                } else {
                    foreach ($aUserId as $userID) {
                        if (!CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $userID, "message", CSocNetUser::IsCurrentUserModuleAdmin(false))) {
                            echo GetMessage("SONET_C50_CANT_WRITE") . ".";
                        } else {
                            $errorMessage = "";
                            if (!CSocNetMessages::CreateMessage($GLOBALS["USER"]->GetID(), $userID, $message)) {
                                if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                                    $errorMessage .= $e->GetString();
                                }
                            }
                            if (strlen($errorMessage) > 0) {
                                echo $errorMessage;
                            }
                        }
                    }
                }
            }
        }
    }
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
示例#7
0
             $errorMessage .= $e->GetString();
         }
     }
     if (strlen($errorMessage) > 0) {
         $arResult["ErrorMessage"] = $errorMessage;
     }
 }
 /*********************  END ACTIONS  *****************************/
 if ($arParams["SET_TITLE"] == "Y") {
     $APPLICATION->SetTitle(GetMessage("SONET_C30_PAGE_TITLE"));
 }
 if ($arParams["SET_NAV_CHAIN"] != "N") {
     $APPLICATION->AddChainItem(GetMessage("SONET_C30_PAGE_TITLE"));
 }
 $arResult["Events"] = false;
 $dbMessages = CSocNetMessages::GetMessagesUsers($GLOBALS["USER"]->GetID(), $arNavParams);
 while ($arMessages = $dbMessages->GetNext()) {
     if ($arResult["Events"] == false) {
         $arResult["Events"] = array();
     }
     $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arMessages["ID"]));
     $canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
     $canAnsver = $arMessages["ACTIVE"] != "N" && (IsModuleInstalled("im") || CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["ID"], "message", CSocNetUser::IsCurrentUserModuleAdmin()));
     $relation = CSocNetUserRelations::GetRelation($GLOBALS["USER"]->GetID(), $arMessages["ID"]);
     if (intval($arMessages["PERSONAL_PHOTO"]) <= 0) {
         switch ($arMessages["PERSONAL_GENDER"]) {
             case "M":
                 $suffix = "male";
                 break;
             case "F":
                 $suffix = "female";
示例#8
0
 function SendRemindEventAgentNew($taskId)
 {
     if (!CModule::IncludeModule("socialnetwork") && !CModule::IncludeModule("iblock")) {
         return;
     }
     $iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
     if ($iblockId <= 0) {
         return;
     }
     $taskId = IntVal($taskId);
     if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) {
         $bTmpUser = True;
         $GLOBALS["USER"] = new CUser();
     }
     $arTask = CIntranetTasks::GetById($taskId);
     if (!$arTask) {
         return;
     }
     if ($arTask["TaskType"] == "user") {
         $path2view = str_replace(array("#USER_ID#", "#TASK_ID#"), array($arTask["OwnerId"], $taskId), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
     } else {
         $path2view = str_replace(array("#GROUP_ID#", "#TASK_ID#"), array($arTask["OwnerId"], $taskId), COption::GetOptionString("intranet", "path_task_group_entry", "/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/"));
     }
     $path2view = ($GLOBALS["APPLICATION"]->IsHTTPS() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $path2view;
     $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $arTask["CREATED_BY"], "TO_USER_ID" => $arTask["PROPERTY_TaskAssignedTo"], "MESSAGE" => str_replace(array("#URL_VIEW#", "#NAME#"), array($path2view, $arTask["NAME"]), GetMessage("INTE_REMIND_TASK_MESSAGE")));
     CSocNetMessages::Add($arMessageFields);
     if ($bTmpUser) {
         unset($GLOBALS["USER"]);
     }
     //return "CIntranetTasks::SendRemindEventAgent($iblockId, $taskId, \"$pathTemplate\");";
 }
示例#9
0
文件: log.php 项目: ASDAFF/bxApiDocs
	public static function SendEvent($ID, $mailTemplate = "SONET_NEW_EVENT", $tmp_id = false, $bAgent = false, $bTransport = false)
	{
		$ID = IntVal($ID);
		if ($ID <= 0)
			return false;

		if (intval($tmp_id) > 0)
			$arFilter = array("ID" => $tmp_id);
		else
			$arFilter = array("ID" => $ID);

		$dbLog = CSocNetLog::GetList(
			array(),
			$arFilter,
			false,
			false,
			array("ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "EVENT_ID", "LOG_DATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "SITE_ID", "PARAMS", "SOURCE_ID", "GROUP_NAME", "CREATED_BY_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_LOGIN", "LOG_SOURCE_ID"),
			array("MIN_ID_JOIN" => true)
		);
		$arLog = $dbLog->Fetch();
		if (!$arLog)
			return $bAgent;

		if (MakeTimeStamp($arLog["LOG_DATE"]) > (time() + CTimeZone::GetOffset()))
		{
			$agent = "CSocNetLog::SendEventAgent(".$ID.", '".$mailTemplate."', ".($tmp_id ? $tmp_id : 'false').");";
			$rsAgents = CAgent::GetList(array("ID"=>"DESC"), array("NAME" => $agent));
			if(!$rsAgents->Fetch())
			{
				$res = CAgent::AddAgent($agent, "socialnetwork", "N", 0, $arLog["LOG_DATE"], "Y", $arLog["LOG_DATE"]);
				if(!$res)
					$GLOBALS["APPLICATION"]->ResetException();
			}
			elseif ($bAgent)
			{
				CAgent::RemoveAgent($agent, "socialnetwork");
				CAgent::AddAgent($agent, "socialnetwork", "N", 0, $arLog["LOG_DATE"], "Y", $arLog["LOG_DATE"]);
				return true;
			}
			return false;
		}

		$arEvent = CSocNetLogTools::FindLogEventByID($arLog["EVENT_ID"], $arLog["ENTITY_TYPE"]);
		if (
			$arEvent
			&& array_key_exists("CLASS_FORMAT", $arEvent)
			&& array_key_exists("METHOD_FORMAT", $arEvent)
		)
		{
			$dbSiteCurrent = CSite::GetByID(SITE_ID);
			if ($arSiteCurrent = $dbSiteCurrent->Fetch())
				if ($arSiteCurrent["LANGUAGE_ID"] != LANGUAGE_ID)
					$arLog["MAIL_LANGUAGE_ID"] = $arSiteCurrent["LANGUAGE_ID"];

			$arLog["FIELDS_FORMATTED"] = call_user_func(array($arEvent["CLASS_FORMAT"], $arEvent["METHOD_FORMAT"]), $arLog, array(), true);
		}

		if (
			array_key_exists($arLog["ENTITY_TYPE"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"])
			&& array_key_exists("HAS_MY", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["HAS_MY"] == "Y"
			&& array_key_exists("CLASS_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& array_key_exists("METHOD_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"]) > 0
			&& strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"]) > 0
			&& method_exists($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"])
		)
			$arOfEntities = call_user_func(array($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"]), $arLog["ENTITY_ID"]);

		if ($bTransport)
		{
			$arListParams = array(
				"USE_SUBSCRIBE" => "Y",
				"ENTITY_TYPE" => $arLog["ENTITY_TYPE"],
				"ENTITY_ID" => $arLog["ENTITY_ID"],
				"EVENT_ID" => $arLog["EVENT_ID"],
				"USER_ID" => $arLog["USER_ID"],
				"OF_ENTITIES" => $arOfEntities,
				"TRANSPORT" => array("M", "X")
			);

			$arLogSites = array();
			$rsLogSite = CSocNetLog::GetSite($ID);

			while($arLogSite = $rsLogSite->Fetch())
				$arLogSites[] = $arLogSite["LID"];

			if (CModule::IncludeModule("extranet"))
			{
				$arSites = array();
				$dbSite = CSite::GetList($by="sort", $order="desc", array("ACTIVE" => "Y"));
				while($arSite = $dbSite->Fetch())
					$arSites[$arSite["ID"]] = array(
						"DIR" => (strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/"),
						"SERVER_NAME" => (strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]))
					);

				$extranet_site_id = CExtranet::GetExtranetSiteID();
				$intranet_site_id = CSite::GetDefSite();

				$arIntranetUsers = CExtranet::GetIntranetUsers();
			}

			$dbSubscribers = CSocNetLogEvents::GetList(
				array("TRANSPORT" => "DESC"),
				array(
					"USER_ACTIVE" => "Y",
					"SITE_ID" => array_merge($arLogSites, array(false))
				),
				false,
				false,
				array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_LID", "USER_EMAIL", "TRANSPORT"),
				$arListParams
			);

			$arListParams = array(
				"USE_SUBSCRIBE" => "Y",
				"ENTITY_TYPE" => $arLog["ENTITY_TYPE"],
				"ENTITY_ID" => $arLog["ENTITY_ID"],
				"EVENT_ID" => $arLog["EVENT_ID"],
				"USER_ID" => $arLog["USER_ID"],
				"OF_ENTITIES" => $arOfEntities,
				"TRANSPORT" => "N"
			);

			$dbUnSubscribers = CSocNetLogEvents::GetList(
				array("TRANSPORT" => "DESC"),
				array(
					"USER_ACTIVE" => "Y",
					"SITE_ID" => array_merge($arLogSites, array(false))
				),
				false,
				false,
				array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "TRANSPORT", "EVENT_ID"),
				$arListParams
			);

			$arUnSubscribers = array();
			while ($arUnSubscriber = $dbUnSubscribers->Fetch())
				$arUnSubscribers[] = $arUnSubscriber["USER_ID"]."_".$arUnSubscriber["ENTITY_TYPE"]."_".$arUnSubscriber["ENTITY_ID"]."_".$arUnSubscriber["ENTITY_MY"]."_".$arUnSubscriber["ENTITY_CB"]."_".$arUnSubscriber["EVENT_ID"];

			$bHasAccessAll = CSocNetLogRights::CheckForUserAll($arLog["ID"]);

			$arSentUserID = array("M" => array(), "X" => array());
			while ($arSubscriber = $dbSubscribers->Fetch())
			{
				if (
					is_array($arIntranetUsers)
					&& !in_array($arSubscriber["USER_ID"], $arIntranetUsers)
					&& !in_array($extranet_site_id, $arLogSites)
				)
					continue;

				if (
					array_key_exists($arSubscriber["TRANSPORT"], $arSentUserID)
					&& in_array($arSubscriber["USER_ID"], $arSentUserID[$arSubscriber["TRANSPORT"]])
				)
					continue;

				if (
					intval($arSubscriber["ENTITY_ID"]) != 0
					&& $arSubscriber["EVENT_ID"] == "all"
					&&
					(
						in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arSubscriber["ENTITY_ID"]."_N_".$arSubscriber["ENTITY_CB"]."_".$arLog["EVENT_ID"], $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arSubscriber["ENTITY_ID"]."_Y_".$arSubscriber["ENTITY_CB"]."_".$arLog["EVENT_ID"], $arUnSubscribers)
					)
				)
					continue;
				elseif (
					intval($arSubscriber["ENTITY_ID"]) == 0
					&& $arSubscriber["ENTITY_CB"] == "N"
					&& $arSubscriber["EVENT_ID"] != "all"
					&&
					(
						in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_Y_N_all", $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_N_N_all", $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_Y_N_".$arLog["EVENT_ID"], $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_N_N_".$arLog["EVENT_ID"], $arUnSubscribers)
					)
				)
					continue;

				$arSentUserID[$arSubscriber["TRANSPORT"]][] = $arSubscriber["USER_ID"];

				if (!$bHasAccessAll)
				{
					$bHasAccess = CSocNetLogRights::CheckForUserOnly($arLog["ID"], $arSubscriber["USER_ID"]);
					if (!$bHasAccess)
						continue;
				}

				if (CModule::IncludeModule("extranet"))
				{
					$server_name = $arSites[((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id)]["SERVER_NAME"];
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = str_replace(
						array("#SERVER_NAME#", "#GROUPS_PATH#"),
						array(
							$server_name,
							COption::GetOptionString("socialnetwork", "workgroups_page", false, ((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id))
						),
						$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]
					);
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"] = str_replace(
						array("#SERVER_NAME#", "#GROUPS_PATH#"),
						array(
							$server_name,
							COption::GetOptionString("socialnetwork", "workgroups_page", false, ((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id))
						),
						$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]
					);
				}
				else
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"];

				switch ($arSubscriber["TRANSPORT"])
				{
					case "X":

						if (
							array_key_exists("URL_TO_SEND", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0
						)
							$link = GetMessage("SONET_GL_SEND_EVENT_LINK").$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
						elseif (
							array_key_exists("URL", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]) > 0
						)
							$link = GetMessage("SONET_GL_SEND_EVENT_LINK").$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
						else
							$link = "";

						$arMessageFields = array(
							"FROM_USER_ID" => (intval($arLog["USER_ID"]) > 0 ? $arLog["USER_ID"] : 1),
							"TO_USER_ID" => $arSubscriber["USER_ID"],
							"MESSAGE" => $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]." #BR#".$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"].(strlen($link) > 0 ? "#BR# ".$link : ""),
							"=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
							"MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM,
							"IS_LOG" => "Y"
						);
						CSocNetMessages::Add($arMessageFields);
						break;
					case "M":
						$arFields["SUBSCRIBER_ID"] = $arSubscriber["USER_ID"];
						$arFields["SUBSCRIBER_NAME"] = $arSubscriber["USER_NAME"];
						$arFields["SUBSCRIBER_LAST_NAME"] = $arSubscriber["USER_LAST_NAME"];
						$arFields["SUBSCRIBER_LOGIN"] = $arSubscriber["USER_LOGIN"];
						$arFields["SUBSCRIBER_EMAIL"] = $arSubscriber["USER_EMAIL"];
						$arFields["EMAIL_TO"] = $arSubscriber["USER_EMAIL"];
						$arFields["TITLE"] = str_replace("#BR#", "\n", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]);
						$arFields["MESSAGE"] = str_replace("#BR#", "\n", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"]);
						$arFields["ENTITY"] = $arLog["FIELDS_FORMATTED"]["ENTITY"]["FORMATTED"];
						$arFields["ENTITY_TYPE"] = $arLog["FIELDS_FORMATTED"]["ENTITY"]["TYPE_MAIL"];

						if (
							array_key_exists("URL_TO_SEND", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0
						)
							$arFields["URL"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
						elseif (
							array_key_exists("URL", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]) > 0
						)
							$arFields["URL"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
						else
							$arFields["URL"] = $arLog["URL"];

						if (CModule::IncludeModule("extranet"))
							$arUserGroup = CUser::GetUserGroup($arSubscriber["USER_ID"]);

						foreach ($arLogSites as $site_id_tmp)
						{
							if (IsModuleInstalled("extranet"))
							{
								if (
									(
										CExtranet::IsExtranetSite($site_id_tmp)
										&& in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)
									)
									||
									(
										!CExtranet::IsExtranetSite($site_id_tmp)
										&& !in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)
									)
								)
								{
									$siteID = $site_id_tmp;
									break;
								}
								else
									continue;
							}
							else
							{
								$siteID = $site_id_tmp;
								break;
							}
						}

						if (!$siteID)
							$siteID = (defined("SITE_ID") ? SITE_ID : $arSubscriber["SITE_ID"]);

						if (StrLen($siteID) <= 0)
							$siteID = $arSubscriber["USER_LID"];
						if (StrLen($siteID) <= 0)
							continue;

						$event = new CEvent;
						$event->Send($mailTemplate, $siteID, $arFields, "N");
						break;
					default:
				}
			}
		}

		CSocNetLog::CounterIncrement($arLog["ID"], $arLog["EVENT_ID"], $arOfEntities);

		return true;
	}
示例#10
0
 function SendEvent($ID, $mailTemplate = "SONET_NEW_EVENT")
 {
     $ID = IntVal($ID);
     if ($ID <= 0) {
         return false;
     }
     $arFilter = array("ID" => $ID);
     $dbLogComments = CSocNetLogComments::GetList(array(), $arFilter, false, false, array("ID", "LOG_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "EVENT_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "GROUP_NAME", "CREATED_BY_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_LOGIN", "LOG_SITE_ID", "SOURCE_ID", "LOG_SOURCE_ID"));
     $arLogComment = $dbLogComments->Fetch();
     if (!$arLogComment) {
         return false;
     }
     $arLog = array();
     if (intval($arLogComment["LOG_ID"]) > 0) {
         $dbLog = CSocNetLog::GetList(array(), array("ID" => $arLogComment["LOG_ID"]));
         $arLog = $dbLog->Fetch();
         if (!$arLog) {
             $arLog = array();
         }
     }
     $arEvent = CSocNetLogTools::FindLogCommentEventByID($arLogComment["EVENT_ID"]);
     if ($arEvent && array_key_exists("CLASS_FORMAT", $arEvent) && array_key_exists("METHOD_FORMAT", $arEvent) && strlen($arEvent["CLASS_FORMAT"]) > 0 && strlen($arEvent["METHOD_FORMAT"]) > 0) {
         $dbSiteCurrent = CSite::GetByID(SITE_ID);
         if ($arSiteCurrent = $dbSiteCurrent->Fetch()) {
             if ($arSiteCurrent["LANGUAGE_ID"] != LANGUAGE_ID) {
                 $arLogComment["MAIL_LANGUAGE_ID"] = $arSiteCurrent["LANGUAGE_ID"];
             }
         }
         $arLogComment["FIELDS_FORMATTED"] = call_user_func(array($arEvent["CLASS_FORMAT"], $arEvent["METHOD_FORMAT"]), $arLogComment, array(), true, $arLog);
     }
     if (array_key_exists($arLogComment["ENTITY_TYPE"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"]) && array_key_exists("HAS_MY", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["HAS_MY"] == "Y" && array_key_exists("CLASS_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && array_key_exists("METHOD_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"]) > 0 && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]) > 0 && method_exists($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"])) {
         $arOfEntities = call_user_func(array($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]), $arLogComment["ENTITY_ID"]);
     }
     $arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => array("M", "X"));
     $arLogSites = array();
     $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
     while ($arLogSite = $rsLogSite->Fetch()) {
         $arLogSites[] = $arLogSite["LID"];
     }
     if (CModule::IncludeModule("extranet")) {
         if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
             $arSites = array();
             $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
             while ($arSite = $dbSite->Fetch()) {
                 $arSites[$arSite["ID"]] = array("DIR" => strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/", "SERVER_NAME" => strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]));
             }
             $intranet_site_id = CSite::GetDefSite();
         }
         $arIntranetUsers = CExtranet::GetIntranetUsers();
         $extranet_site_id = CExtranet::GetExtranetSiteID();
     }
     $dbSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_LID", "USER_EMAIL", "TRANSPORT"), $arListParams);
     $arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => "N");
     $dbUnSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "TRANSPORT", "EVENT_ID"), $arListParams);
     $arUnSubscribers = array();
     while ($arUnSubscriber = $dbUnSubscribers->Fetch()) {
         $arUnSubscribers[] = $arUnSubscriber["USER_ID"] . "_" . $arUnSubscriber["ENTITY_TYPE"] . "_" . $arUnSubscriber["ENTITY_ID"] . "_" . $arUnSubscriber["ENTITY_MY"] . "_" . $arUnSubscriber["ENTITY_CB"] . "_" . $arUnSubscriber["EVENT_ID"];
     }
     $bHasAccessAll = CSocNetLogRights::CheckForUserAll($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"]);
     $arSentUserID = array("M" => array(), "X" => array());
     while ($arSubscriber = $dbSubscribers->Fetch()) {
         if (is_array($arIntranetUsers) && !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && !in_array($extranet_site_id, $arLogSites)) {
             continue;
         }
         if (array_key_exists($arSubscriber["TRANSPORT"], $arSentUserID) && in_array($arSubscriber["USER_ID"], $arSentUserID[$arSubscriber["TRANSPORT"]])) {
             continue;
         }
         if (intval($arSubscriber["ENTITY_ID"]) != 0 && $arSubscriber["EVENT_ID"] == "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_N_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_Y_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) {
             continue;
         } elseif (intval($arSubscriber["ENTITY_ID"]) == 0 && $arSubscriber["ENTITY_CB"] == "N" && $arSubscriber["EVENT_ID"] != "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) {
             continue;
         }
         $arSentUserID[$arSubscriber["TRANSPORT"]][] = $arSubscriber["USER_ID"];
         if (!$bHasAccessAll) {
             $bHasAccess = CSocNetLogRights::CheckForUserOnly($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"], $arSubscriber["USER_ID"]);
             if (!$bHasAccess) {
                 continue;
             }
         }
         if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP && is_array($arIntranetUsers) && CModule::IncludeModule("extranet")) {
             $server_name = $arSites[!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id]["SERVER_NAME"];
             $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = str_replace(array("#SERVER_NAME#", "#GROUPS_PATH#"), array($server_name, COption::GetOptionString("socialnetwork", "workgroups_page", false, !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id)), $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]);
         } else {
             $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
         }
         switch ($arSubscriber["TRANSPORT"]) {
             case "X":
                 if (array_key_exists("URL_TO_SEND", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && strlen($arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0) {
                     $link = GetMessage("SONET_GLC_SEND_EVENT_LINK") . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
                 } else {
                     $link = "";
                 }
                 $arMessageFields = array("FROM_USER_ID" => intval($arLogComment["USER_ID"]) > 0 ? $arLogComment["USER_ID"] : 1, "TO_USER_ID" => $arSubscriber["USER_ID"], "MESSAGE" => $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"] . " #BR# " . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] . (strlen($link) > 0 ? "#BR# " . $link : ""), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "IS_LOG" => "Y");
                 CSocNetMessages::Add($arMessageFields);
                 break;
             case "M":
                 $arFields["SUBSCRIBER_ID"] = $arSubscriber["USER_ID"];
                 $arFields["SUBSCRIBER_NAME"] = $arSubscriber["USER_NAME"];
                 $arFields["SUBSCRIBER_LAST_NAME"] = $arSubscriber["USER_LAST_NAME"];
                 $arFields["SUBSCRIBER_LOGIN"] = $arSubscriber["USER_LOGIN"];
                 $arFields["SUBSCRIBER_EMAIL"] = $arSubscriber["USER_EMAIL"];
                 $arFields["EMAIL_TO"] = $arSubscriber["USER_EMAIL"];
                 $arFields["TITLE"] = str_replace("#BR#", "\n", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]);
                 $arFields["MESSAGE"] = str_replace("#BR#", "\n", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]);
                 $arFields["ENTITY"] = $arLogComment["FIELDS_FORMATTED"]["ENTITY"]["FORMATTED"];
                 $arFields["ENTITY_TYPE"] = $arLogComment["FIELDS_FORMATTED"]["ENTITY"]["TYPE_MAIL"];
                 if (array_key_exists("URL_TO_SEND", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && strlen($arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0) {
                     $arFields["URL"] = $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
                 } else {
                     $arFields["URL"] = $arLogComment["URL"];
                 }
                 if (CModule::IncludeModule("extranet")) {
                     $arUserGroup = CUser::GetUserGroup($arSubscriber["USER_ID"]);
                 }
                 foreach ($arLogSites as $site_id_tmp) {
                     if (IsModuleInstalled("extranet")) {
                         if (CExtranet::IsExtranetSite($site_id_tmp) && in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup) || !CExtranet::IsExtranetSite($site_id_tmp) && !in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)) {
                             $siteID = $site_id_tmp;
                             break;
                         } else {
                             continue;
                         }
                     } else {
                         $siteID = $site_id_tmp;
                         break;
                     }
                 }
                 if (!$siteID) {
                     $siteID = defined("SITE_ID") ? SITE_ID : $arSubscriber["SITE_ID"];
                 }
                 if (StrLen($siteID) <= 0) {
                     $siteID = $arSubscriber["USER_LID"];
                 }
                 if (StrLen($siteID) <= 0) {
                     continue;
                 }
                 $event = new CEvent();
                 $event->Send($mailTemplate, $siteID, $arFields, "N");
                 break;
             default:
         }
     }
     CUserCounter::IncrementWithSelect(CSocNetLogCounter::GetSubSelect($arLog["ID"], $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $arLogComment["EVENT_ID"], $arLogComment["USER_ID"], $arOfEntities, false, false, "Y", "LC"));
     return true;
 }
示例#11
0
 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;
 }
示例#12
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$arResult["ITEMS_TOTAL"] = 0;
$arResult["ITEMS_MESSAGES"] = 0;
$arResult["ITEMS_REQUESTS_USER"] = 0;
$arResult["ITEMS_REQUESTS_GROUP"] = 0;
/* friends requests */
$arFilter = array("SECOND_USER_ID" => $GLOBALS["USER"]->GetID(), "RELATION" => SONET_RELATIONS_REQUEST);
$dbUserRequests = CSocNetUserRelations::GetList(array(), $arFilter, array("SECOND_USER_ID"), false, array("COUNT" => "ID"));
if ($arUserRequests = $dbUserRequests->Fetch()) {
    $arResult["ITEMS_TOTAL"] += intval($arUserRequests["CNT"]);
    $arResult["ITEMS_REQUESTS_USER"] += intval($arUserRequests["CNT"]);
}
/* group requests */
$arFilter = array("USER_ID" => $GLOBALS["USER"]->GetID(), "ROLE" => SONET_ROLES_REQUEST, "INITIATED_BY_TYPE" => SONET_INITIATED_BY_GROUP);
$dbUserRequests = CSocNetUserToGroup::GetList(array(), $arFilter, array("USER_ID"), false, array("COUNT" => "ID"));
if ($arUserRequests = $dbUserRequests->Fetch()) {
    $arResult["ITEMS_TOTAL"] += intval($arUserRequests["CNT"]);
    $arResult["ITEMS_REQUESTS_GROUP"] += intval($arUserRequests["CNT"]);
}
/* messages */
$arFilter = array("TO_USER_ID" => $GLOBALS["USER"]->GetID(), "DATE_VIEW" => "", "TO_DELETED" => "N", "IS_LOG_ALL" => "Y");
$dbUserRequests = CSocNetMessages::GetList(array(), $arFilter, array("TO_USER_ID"), false, array("COUNT" => "ID"));
if ($arUserRequests = $dbUserRequests->Fetch()) {
    $arResult["ITEMS_TOTAL"] += intval($arUserRequests["CNT"]);
    $arResult["ITEMS_MESSAGES"] += intval($arUserRequests["CNT"]);
}
示例#13
0
 }
 /*********************  END ACTIONS  *****************************/
 $arResult["Urls"]["ReadAll"] = htmlspecialcharsbx($APPLICATION->GetCurUri("eventID=" . $arMessages["ID"] . "&action=close&" . bitrix_sessid_get() . ""));
 if ($arParams["SET_TITLE"] == "Y") {
     $APPLICATION->SetTitle(GetMessage("SONET_C27_PAGE_TITLE"));
 }
 if ($arParams["SET_NAV_CHAIN"] != "N") {
     $APPLICATION->AddChainItem(GetMessage("SONET_C27_PAGE_TITLE"));
 }
 $parser = new CSocNetTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
 $arResult["Events"] = false;
 $arFilter = array("TO_USER_ID" => $GLOBALS["USER"]->GetID(), "MESSAGE_TYPE" => SONET_MESSAGE_PRIVATE, "TO_DELETED" => "N");
 if ($arParams["USER_ID"] > 0 && $arParams["USER_ID"] != $GLOBALS["USER"]->GetID()) {
     $arFilter["FROM_USER_ID"] = $arParams["USER_ID"];
 }
 $dbMessages = CSocNetMessages::GetList(array("DATE_CREATE" => "DESC"), $arFilter, false, $arNavParams, array("ID", "FROM_USER_ID", "TITLE", "MESSAGE", "DATE_CREATE", "DATE_VIEW", "MESSAGE_TYPE", "FROM_USER_NAME", "FROM_USER_LAST_NAME", "FROM_USER_SECOND_NAME", "FROM_USER_LOGIN_NAME", "FROM_USER_PERSONAL_PHOTO", "FROM_USER_PERSONAL_GENDER"));
 while ($arMessages = $dbMessages->GetNext()) {
     if ($arResult["Events"] == false) {
         $arResult["Events"] = array();
     }
     $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arMessages["FROM_USER_ID"]));
     $canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["FROM_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
     $canAnsver = IsModuleInstalled("im") || CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["FROM_USER_ID"], "message", CSocNetUser::IsCurrentUserModuleAdmin());
     $relation = CSocNetUserRelations::GetRelation($GLOBALS["USER"]->GetID(), $arMessages["FROM_USER_ID"]);
     if (intval($arMessages["FROM_USER_PERSONAL_PHOTO"]) <= 0) {
         switch ($arMessages["FROM_USER_PERSONAL_GENDER"]) {
             case "M":
                 $suffix = "male";
                 break;
             case "F":
                 $suffix = "female";
示例#14
0
 public function ReceiveMessage($senderJId, array $arMessage, CXMPPClient $senderClient)
 {
     if (!$senderClient->IsAuthenticated()) {
         return false;
     }
     if (strlen($senderJId) <= 0) {
         return false;
     }
     if (!array_key_exists("message", $arMessage) || !array_key_exists(".", $arMessage["message"])) {
         return false;
     }
     $type = "normal";
     if (array_key_exists("type", $arMessage["message"]["."])) {
         $type = $arMessage["message"]["."]["type"];
     }
     if ($type == "error") {
         return false;
     }
     $mid = "";
     if (array_key_exists("id", $arMessage["message"]["."])) {
         $mid = $arMessage["message"]["."]["id"];
     }
     if (!in_array($type, array("chat", "groupchat", "headline", "normal"))) {
         return CXMPPUtility::GetErrorArray($senderJId, "message", "modify", "bad-request", "", $mid, "", $senderClient->GetClientDomain());
     }
     $recipientJId = "";
     if (array_key_exists("to", $arMessage["message"]["."])) {
         $recipientJId = $arMessage["message"]["."]["to"];
     }
     if (strlen($recipientJId) <= 0) {
         return CXMPPUtility::GetErrorArray($senderJId, "message", "modify", "bad-request", "", $mid, "", $senderClient->GetClientDomain());
     }
     $body = "";
     if (array_key_exists("body", $arMessage["message"])) {
         $body = $arMessage["message"]["body"]["#"];
     }
     if (strlen($body) <= 0) {
         return true;
     }
     //$body = CXMPPReceiveMessage::htmlspecialcharsback($body);
     //$body = html_entity_decode($body);
     $body = html_entity_decode($body, ENT_COMPAT, SITE_CHARSET);
     $body = str_replace("&apos;", "'", $body);
     $arSender = CXMPPUtility::GetUserByJId($senderJId);
     if (!$arSender) {
         return CXMPPUtility::GetErrorArray($senderJId, "message", "auth", "forbidden", $recipientJId, $mid, "", $senderClient->GetClientDomain());
     }
     $arRecipient = CXMPPUtility::GetUserByJId($recipientJId);
     if (!$arRecipient) {
         return CXMPPUtility::GetErrorArray($senderJId, "message", "cancel", "item-not-found", $recipientJId, $mid, "", $senderClient->GetClientDomain());
     }
     if (!CSocNetUserPerms::CanPerformOperation($arSender["ID"], $arRecipient["ID"], "message", false)) {
         return CXMPPUtility::GetErrorArray($senderJId, "message", "auth", "forbidden", $recipientJId, $mid, "", $senderClient->GetClientDomain());
     }
     if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
         $arMessageFields = array("FROM_USER_ID" => $arSender["ID"], "TO_USER_ID" => $arRecipient["ID"], "MESSAGE" => $body);
         CIMMessage::Add($arMessageFields);
     } else {
         $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_PRIVATE, "FROM_USER_ID" => $arSender["ID"], "TO_USER_ID" => $arRecipient["ID"], "MESSAGE" => $body);
         CSocNetMessages::Add($arMessageFields);
     }
     return true;
 }
示例#15
0
		"PATH_TO_GROUP" => "/club/group/#group_id#/", 
		"PATH_TO_GROUP_SEARCH" => "/club/group/search/", 
		"ITEMS_COUNT" => "4", 
		"DATE_TIME_FORMAT" => "d.m.Y H:i:s", 
		"DISPLAY_IMAGE" => "Y", 
		"DISPLAY_DESCRIPTION" => "N", 
		"DISPLAY_NUMBER_OF_MEMBERS" => "Y", 
		"DISPLAY_SUBJECT" => "Y", 
		"CACHE_TIME" => "180" 
	)
);?>
</div>';
CWizardUtil::ReplaceMacros($_SERVER["DOCUMENT_ROOT"] . "/index_inc.php", array('<!-- SOCNETWORK_GROUPS -->' => $strIndexIncGroup), $skipSharp = true);
//welcome message
$arMessageFields = array("FROM_USER_ID" => 1, "TO_USER_ID" => 1, "MESSAGE" => GetMessage("SOCNET_WELCOME_MESSAGE"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM);
CSocNetMessages::Add($arMessageFields);
//gallery, forum and blog examples
$source_base = dirname(__FILE__);
if (IsModuleInstalled('blog') && file_exists($_SERVER["DOCUMENT_ROOT"] . "/communication/blog")) {
    CopyDirFiles($source_base . "/public/" . $LID . "/blogs", $_SERVER["DOCUMENT_ROOT"] . "/club/blogs", false, true);
    DemoSiteUtil::AddMenuItem("/club/.left.menu.php", array(GetMessage("SOCNET_MENU_BLOG"), "blogs/", array(), array(), ""));
}
if (IsModuleInstalled('photogallery') && file_exists($_SERVER["DOCUMENT_ROOT"] . "/content/gallery") && CModule::IncludeModule("iblock")) {
    CopyDirFiles($source_base . "/public/" . $LID . "/gallery", $_SERVER["DOCUMENT_ROOT"] . "/club/gallery", false, true);
    //replace default gallery infoblock with user gallery
    $res = CIBlock::GetList(array(), array("CODE" => "gallery"));
    $res_arr = $res->Fetch();
    $photo_id = $res_arr["ID"];
    $res = CIBlock::GetList(array(), array("CODE" => "car_photo_user_demo"));
    $res_arr = $res->Fetch();
    $socnet_photo_id = $res_arr["ID"];
示例#16
0
    }
    if (!strlen($arResult['ERROR']) && $arUser['ID'] == $USER->GetID()) {
        $arResult['ERROR'] = GetMessage('SPT_ERROR_CANNT_YOURSELF');
    }
    if (!strlen($arResult['ERROR'])) {
        $arResult['TO_USER'] = $arUser;
        if (strlen($_REQUEST['send_money_now'])) {
            $arUserCurr = CUser::GetByID($USER->GetID())->Fetch();
            CSaleUserAccount::UpdateAccount($USER->GetID(), -$arResult['MONEY_OFF'], $arResult['REQUEST_ACCOUNT'], GetMessage('SPT_TRANSACT_DESC_FROM', $arUser), 0, $arResult['~REQUEST_COMMENT']);
            CSaleUserAccount::UpdateAccount($arUser['ID'], $arResult['REQUEST_AMOUNT'], $arResult['REQUEST_ACCOUNT'], GetMessage('SPT_TRANSACT_DESC_TO', $arUserCurr), 0, $arResult['~REQUEST_COMMENT']);
            if ($arParams['NOTIFY_USER'] == 'Y' && CModule::IncludeModule('socialnetwork')) {
                $letter = GetMessage('SPT_MESS_DESC_TO', array_merge($arUserCurr, array('SUM' => SaleFormatCurrency($arResult['REQUEST_AMOUNT'], $arResult['REQUEST_ACCOUNT']))));
                if (strlen($arResult['~REQUEST_COMMENT'])) {
                    $letter .= ' (' . $arResult['~REQUEST_COMMENT'] . ')';
                }
                CSocNetMessages::Add(array('FROM_USER_ID' => $USER->GetID(), 'TO_USER_ID' => $arUser['ID'], 'MESSAGE' => $letter, '=DATE_CREATE' => 'now()', 'MESSAGE_TYPE' => 'S', 'FROM_DELETED' => 'N', 'TO_DELETED' => 'N', 'SEND_MAIL' => 'Y'));
            }
            LocalRedirect($APPLICATION->GetCurPageParam('success', array('success')));
        }
    }
}
if (!function_exists('asd_cmp_account')) {
    function asd_cmp_account($a, $b)
    {
        if ($a['CURRENT_BUDGET'] == $b['CURRENT_BUDGET']) {
            return 0;
        }
        return $a['CURRENT_BUDGET'] < $b['CURRENT_BUDGET'] ? 1 : -1;
    }
}
usort($arResult['FROM_ACCOUNT'], 'asd_cmp_account');
示例#17
0
 }
 if ($arResult["IsCurrentUser"]) {
     $arResult["FatalError"] = GetMessage("SONET_C26_SELF") . ". ";
 } elseif (!$arResult["CurrentUserPerms"]["Message"]) {
     $arResult["FatalError"] = GetMessage("SONET_C26_PERM_MESS") . ". ";
 } else {
     $arResult["ShowForm"] = "Input";
     if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["save"]) > 0 && check_bitrix_sessid()) {
         $errorMessage = "";
         if (strlen($_POST["POST_MESSAGE"]) <= 0) {
             $errorMessage .= GetMessage("SONET_C26_NO_TEXT") . ". ";
         }
         if (strlen($errorMessage) <= 0) {
             if (CSocNetMessages::CreateMessage($GLOBALS["USER"]->GetID(), $arResult["User"]["ID"], $_POST["POST_MESSAGE"])) {
                 if ($arParams["MESSAGE_ID"] > 0) {
                     CSocNetMessages::MarkMessageRead($GLOBALS["USER"]->GetID(), $arParams["MESSAGE_ID"]);
                 }
             } else {
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage .= $e->GetString();
                 }
             }
         }
         if (strlen($errorMessage) > 0) {
             $arResult["ErrorMessage"] = $errorMessage;
         } else {
             $arResult["ShowForm"] = "Confirm";
         }
     }
     $arResult["PrintSmilesList"] = CSocNetSmile::PrintSmilesList(3, LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
 }
示例#18
0
	function SetOwner($userID, $groupID, $arGroup = false)
	{
		global $DB, $APPLICATION, $USER;

		if (!$arGroup)
			$arGroup = CSocNetGroup::GetByID($groupID);

		if (!$arGroup)
			return false;

		$DB->StartTransaction();
				
		// setting relations for the old owner
		$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arGroup["OWNER_ID"], "GROUP_ID" => $groupID), false, false, array("ID"));
		if ($arRelation = $dbRelation->Fetch())
		{
			$arFields = array(
				"ROLE" => SONET_ROLES_USER,
				"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
				"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
				"INITIATED_BY_USER_ID" => $USER->GetID(),
			);

			if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields))
			{
				$errorMessage = "";
				if ($e = $APPLICATION->GetException())
					$errorMessage = $e->GetString();
				if (StrLen($errorMessage) <= 0)
					$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_CURRENT_OWNER");

				$APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
				$DB->Rollback();
				return false;
			}
		}
		else
		{
			$errorMessage = "";
			if ($e = $APPLICATION->GetException())
				$errorMessage = $e->GetString();
			if (StrLen($errorMessage) <= 0)
				$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_GET_CURRENT_OWNER_RELATION");

			$APPLICATION->ThrowException($errorMessage, "ERROR_GET_USER2GROUP");
			$DB->Rollback();
			return false;
		}

		// delete requests to the old owner
		if (strlen($errorMessage) <= 0)
			CSocNetUserToGroup::__SpeedFileDelete($arGroup["OWNER_ID"]);

		if (strlen($errorMessage) <= 0)
		{
			// setting relations for the new owner
			$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $userID, "GROUP_ID" => $groupID), false, false, array("ID"));
			if ($arRelation = $dbRelation->Fetch())
			{
				$arFields = array(
					"ROLE" => SONET_ROLES_OWNER,
					"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
					"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
					"INITIATED_BY_USER_ID" => $USER->GetID(),
				);

				if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields))
				{
					$errorMessage = "";
					if ($e = $APPLICATION->GetException())
						$errorMessage = $e->GetString();
					if (StrLen($errorMessage) <= 0)
						$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_NEW_OWNER_RELATION");

					$APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
					$DB->Rollback();
					return false;
				}
			}
			else
			{
				$arFields = array(
					"USER_ID" => $userID,
					"GROUP_ID" => $groupID,
					"ROLE" => SONET_ROLES_OWNER,
					"=DATE_CREATE" => $DB->CurrentTimeFunction(),
					"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
					"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
					"INITIATED_BY_USER_ID" => $USER->GetID(),
					"MESSAGE" => false,
				);

				if (!CSocNetUserToGroup::Add($arFields))
				{
					$errorMessage = "";
					if ($e = $APPLICATION->GetException())
						$errorMessage = $e->GetString();
					if (StrLen($errorMessage) <= 0)
						$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_ADD_NEW_OWNER_RELATION");

					$APPLICATION->ThrowException($errorMessage, "ERROR_ADD_USER2GROUP");
					$DB->Rollback();
					return false;
				}
			}
		}

		if (strlen($errorMessage) <= 0)
		{
			$GROUP_ID = CSocNetGroup::Update($groupID, array("OWNER_ID" => $userID));
			if (!$GROUP_ID || IntVal($GROUP_ID) <= 0)
			{
				$errorMessage = "";
				if ($e = $APPLICATION->GetException())
					$errorMessage = $e->GetString();
				if (StrLen($errorMessage) <= 0)
					$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_GROUP");

				$APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_GROUP");
				$DB->Rollback();
				return false;
			}
		}

		// send message to the old owner
		$arMessageFields = array(
			"FROM_USER_ID" => $USER->GetID(),
			"TO_USER_ID" => $arGroup["OWNER_ID"],
			"MESSAGE" => str_replace("#NAME#", $arGroup["NAME"], GetMessage("SONET_UG_OWNER2MEMBER_MESSAGE")),
			"=DATE_CREATE" => $DB->CurrentTimeFunction(),
			"MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM
		);
		CSocNetMessages::Add($arMessageFields);

		// send message to the new owner
		$arMessageFields = array(
			"FROM_USER_ID" => $USER->GetID(),
			"TO_USER_ID" => $userID,
			"MESSAGE" => str_replace("#NAME#", $arGroup["NAME"], GetMessage("SONET_UG_MEMBER2OWNER_MESSAGE")),
			"=DATE_CREATE" => $DB->CurrentTimeFunction(),
			"MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM
		);
		CSocNetMessages::Add($arMessageFields);

		// add entry to log
		$logID = CSocNetLog::Add(
			array(
				"ENTITY_TYPE" => SONET_ENTITY_GROUP,
				"SITE_ID" => $arGroup["SITE_ID"],
				"ENTITY_ID" => $groupID,
				"EVENT_ID" => "system",
				"=LOG_DATE" => $DB->CurrentTimeFunction(),
				"TITLE_TEMPLATE" => false,
				"TITLE" => "owner",
				"MESSAGE" => $userID,
				"URL" => false,
				"MODULE_ID" => false,
				"CALLBACK_FUNC" => false,
				"USER_ID" => $userID,
			)
		);
		if (intval($logID) > 0)
		{
			CSocNetLog::Update($logID, array("TMP_ID" => $logID));
			CSocNetLogRights::Add($logID, array("SA", "S".SONET_ENTITY_GROUP.$groupID, "S".SONET_ENTITY_GROUP.$groupID."_".SONET_ROLES_OWNER, "S".SONET_ENTITY_GROUP.$groupID."_".SONET_ROLES_MODERATOR, "S".SONET_ENTITY_GROUP.$groupID."_".SONET_ROLES_USER));
			CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
		}

		if (strlen($errorMessage) <= 0)
		{
			$DB->Commit();
			return true;
		}
		else
		{
			$DB->Rollback();
			return false;	
		}
	}
示例#19
0
             $arTmpData["MESSAGE"] = str_replace("#BR#", "<br />", $arTmpData["MESSAGE"]);
             $arTmpData["URL_MESSAGE"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_MESSAGE_FORM_MESS"], array("user_id" => $arUserRequests["FROM_USER_ID"], "message_id" => $arUserRequests["ID"]));
             $arTmpData["URL_BAN"] = "EventType=Message&userID=" . $arUserRequests["FROM_USER_ID"] . "&action=ban";
             $arTmpData["CAN_ANSWER"] = $arUserRequests["MESSAGE_TYPE"] == SONET_MESSAGE_PRIVATE && $canAnsver ? "Y" : "N";
             $arTmpData["CAN_BAN"] = !CSocNetUser::IsUserModuleAdmin($arUserRequests["FROM_USER_ID"], $site) && $arUserRequests["MESSAGE_TYPE"] == SONET_MESSAGE_PRIVATE ? "Y" : "N";
             if ($arTmpData["CAN_ANSWER"] == "Y") {
                 $arTmpData["BUTTONS"] = array(array("NAME" => GetMessage("SONET_C2_ANSWER"), "ID" => "reply", "ONCLICK" => "function () \n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\twindow.open('" . $arTmpData["URL_MESSAGE"] . "', '', 'location=yes,status=no,scrollbars=yes,resizable=yes,width=700,height=550,top='+Math.floor((screen.height - 550)/2-14)+',left='+Math.floor((screen.width - 700)/2-5));\n\t\t\t\t\t\t\t\t\t\t_this.Next();\n\t\t\t\t\t\t\t\t\t\t_this.oData.splice(_this.oCurrentMessagePointer-1, 1);\n\t\t\t\t\t\t\t\t\t\tif (_this.oCurrentMessagePointer > 0)\n\t\t\t\t\t\t\t\t\t\t\t_this.oCurrentMessagePointer--;\n\t\t\t\t\t\t\t\t\t\t_this.adjustPaging();\n\t\t\t\t\t\t\t\t\t\t_this.ShowContent(_this.oCurrentMessagePointer);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}"));
             }
             $arData[] = $arTmpData;
         }
         // while
     }
     // if bGet
 }
 if (count($arData) <= 0 || $arData[0] != "*") {
     CSocNetMessages::__SpeedFileCheckMessages($GLOBALS["USER"]->GetID());
     CSocNetUserToGroup::__SpeedFileCheckMessages($GLOBALS["USER"]->GetID());
     CSocNetUserRelations::__SpeedFileCheckMessages($GLOBALS["USER"]->GetID());
 }
 global $tmpSite;
 $tmpSite = $site;
 function date_cmp($a, $b)
 {
     global $tmpSite, $DB;
     $ts_a = $DB->CharToDateFunction($a["DATE"], "FULL", $tmpSite);
     $ts_b = $DB->CharToDateFunction($b["DATE"], "FULL", $tmpSite);
     if ($ts_a == $ts_b) {
         return 0;
     }
     return $ts_a < $ts_b ? -1 : 1;
 }
示例#20
0
	function UnBanMember($senderUserID, $relationID)
	{
		global $APPLICATION, $DB;

		$senderUserID = IntVal($senderUserID);
		if ($senderUserID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_SENDER_USER_ID"), "ERROR_SENDER_USER_ID");
			return false;
		}

		$relationID = IntVal($relationID);
		if ($relationID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_RELATION"), "ERROR_RELATIONID");
			return false;
		}

		$arRelation = CSocNetUserRelations::GetByID($relationID);
		if (!$arRelation)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_ERROR_NO_RELATION"), "ERROR_NO_RELATION");
			return false;
		}

		if ($arRelation["RELATION"] == SONET_RELATIONS_BAN
			&&
			($arRelation["FIRST_USER_ID"] == $senderUserID && $arRelation["INITIATED_BY"] == "F"
			|| $arRelation["SECOND_USER_ID"] == $senderUserID && $arRelation["INITIATED_BY"] == "S"))
		{
			if (CSocNetUserRelations::Delete($arRelation["ID"]))
			{
				$arMessageFields = array(
					"FROM_USER_ID" => $senderUserID,
					"TO_USER_ID" => ($arRelation["FIRST_USER_ID"] == $senderUserID ? $arRelation["SECOND_USER_ID"] : $arRelation["FIRST_USER_ID"]),
					"MESSAGE" => GetMessage("SONET_UR_UNBANUSER_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_RELATION_DELETE_ERROR");

				$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_DELETE_RELATION");
				return false;
			}
		}
		else
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_UNBAN_ERROR"), "ERROR_UNBAN");
			return false;
		}

		return true;
	}
示例#21
0
function __InTaskTaskComplete($taskCompleteId, $iblockId, $taskType, $ownerId, $arTaskStatus, $arParams)
{
    $errorMessage = "";
    $taskCompleteId = IntVal($taskCompleteId);
    if ($taskCompleteId <= 0) {
        return "";
    }
    $arTask = __InTaskGetTask($taskCompleteId, $iblockId, $taskType, $ownerId);
    if (!$arTask) {
        $errorMessage .= GetMessage("INTL_TASK_NOT_FOUND") . ".";
    }
    if (StrLen($errorMessage) <= 0) {
        if ($arTask["PROPS"]["TASKASSIGNEDTO"]["VALUE"] != $GLOBALS["USER"]->GetID()) {
            $errorMessage .= GetMessage("INTL_CAN_NOT_FINISH") . ".";
        }
    }
    if (StrLen($arResult["ErrorMessage"]) <= 0) {
        $obIB = new CIBlockElement();
        $obIB->SetPropertyValueCode($taskCompleteId, $arTask["PROPS"]["TASKSTATUS"]["ID"], $arTaskStatus["COMPLETED"]["ID"]);
        $obIB->SetPropertyValueCode($taskCompleteId, $arTask["PROPS"]["TASKCOMPLETE"]["ID"], array(100));
        $obIB->SetPropertyValueCode($taskCompleteId, $arTask["PROPS"]["TASKFINISH"]["ID"], array(Date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME))));
        // added by sigurd
        CIntranetUtils::UpdateOWSVersion($iblockId, $taskCompleteId);
        $obIB->Update($taskCompleteId, array('TIMESTAMP_X' => Date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME))));
        $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $GLOBALS["USER"]->GetID(), "TO_USER_ID" => $arTask["FIELDS"]["CREATED_BY"]);
        if ($arMessageFields["FROM_USER_ID"] != $arMessageFields["TO_USER_ID"]) {
            $path2view = ($GLOBALS["APPLICATION"]->IsHTTPS() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_TASKS_TASK"], array("owner_id" => $arTask["PROPS"]["TASKASSIGNEDTO"]["VALUE"], "task_id" => $taskCompleteId, "action" => "view"));
            $arMessageFields["MESSAGE"] = str_replace(array("#URL_VIEW#", "#NAME#"), array($path2view, $arTask["FIELDS"]["NAME"]), GetMessage("INTL_FINISH_MESSAGE"));
            CSocNetMessages::Add($arMessageFields);
        }
    }
    return $errorMessage;
}
示例#22
0
 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();";
 }
示例#23
0
            switch ($arResult["User"]["PERSONAL_GENDER"]) {
                case "M":
                    $suffix = "male";
                    break;
                case "F":
                    $suffix = "female";
                    break;
                default:
                    $suffix = "unknown";
            }
            $arResult["User"]["PERSONAL_PHOTO"] = COption::GetOptionInt("socialnetwork", "default_user_picture_" . $suffix, false, SITE_ID);
        }
        $arImage = CSocNetTools::InitImage($arResult["User"]["PERSONAL_PHOTO"], 150, "/bitrix/images/socialnetwork/nopic_user_150.gif", 150, $arResult["Urls"]["User"], $arResult["CanViewProfile"]);
        $arResult["User"]["PERSONAL_PHOTO_FILE"] = $arImage["FILE"];
        $arResult["User"]["PERSONAL_PHOTO_IMG"] = $arImage["IMG"];
        $parser = new CSocNetTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
        $arResult["Events"] = false;
        $dbMessages = CSocNetMessages::GetMessagesForChat($GLOBALS["USER"]->GetID(), $arResult["User"]["ID"], false, $arNavParams);
        while ($arMessages = $dbMessages->GetNext()) {
            if ($arResult["Events"] == false) {
                $arResult["Events"] = array();
            }
            $arResult["Events"][] = array("WHO" => $arMessages["WHO"], "ID" => $arMessages["ID"], "TITLE" => $arMessages["TITLE"], "DATE_VIEW" => $arMessages["DATE_VIEW"], "DATE_CREATE" => $arMessages["DATE_CREATE"], "DATE_CREATE_FMT" => $arMessages["DATE_CREATE_FMT"], "DATE_CREATE_FORMAT" => $arMessages["DATE_CREATE_FORMAT"], "IS_READ" => StrLen($arMessages["DATE_VIEW"]) > 0 || $arMessages["WHO"] == "OUT", "READ_LINK" => htmlspecialcharsbx($APPLICATION->GetCurUri("eventID=" . $arMessages["ID"] . "&action=close&" . bitrix_sessid_get() . "")), "DELETE_LINK" => htmlspecialcharsbx($APPLICATION->GetCurUri("eventID=" . $arMessages["ID"] . "&action=delete&" . bitrix_sessid_get() . "")), "MESSAGE" => $parser->convert($arMessages["~MESSAGE"], false, array(), array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LIST" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "SMILES" => "Y", "UPLOAD" => "N", "NL2BR" => "N")));
        }
        $arResult["NAV_STRING"] = $dbMessages->GetPageNavStringEx($navComponentObject, GetMessage("SONET_C31_NAV"), "", false);
        $arResult["NAV_CACHED_DATA"] = $navComponentObject->GetTemplateCachedData();
        $arResult["NAV_RESULT"] = $dbMessages;
    }
}
//echo "<pre>".print_r($arResult, true)."</pre>";
$this->IncludeComponentTemplate();
示例#24
0
         //12
         $arData[13] = "EventType=GroupRequest&eventID=" . $arUserRequests["ID"] . "&action=add";
         //13
         $arData[14] = "EventType=GroupRequest&eventID=" . $arUserRequests["ID"] . "&action=reject";
         //14
     }
 }
 if (!$bFound) {
     $arFilter = array("TO_USER_ID" => $GLOBALS["USER"]->GetID(), "DATE_VIEW" => "", "TO_DELETED" => "N");
     if ($arParams["POPUP"] == "Y") {
         $last_message_id = CUserOptions::GetOption('socialnetwork', 'SONET_EVENT_M', 0);
         if (intval($last_message_id) > 0) {
             $arFilter[">ID"] = $last_message_id;
         }
     }
     $dbUserRequests = CSocNetMessages::GetList(array("DATE_CREATE" => "ASC"), $arFilter, false, array("nTopCount" => 1), array("ID", "FROM_USER_ID", "TITLE", "MESSAGE", "DATE_CREATE", "MESSAGE_TYPE", "FROM_USER_NAME", "FROM_USER_LAST_NAME", "FROM_USER_SECOND_NAME", "FROM_USER_LOGIN", "FROM_USER_PERSONAL_PHOTO", "FROM_USER_PERSONAL_GENDER"));
     if ($arUserRequests = $dbUserRequests->GetNext()) {
         if ($arParams["POPUP"] == "Y") {
             CUserOptions::SetOption('socialnetwork', 'SONET_EVENT_M', $arUserRequests["ID"]);
         }
         $bFound = true;
         $arData[0] = "M";
         //0
         $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arUserRequests["FROM_USER_ID"]));
         $canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arUserRequests["FROM_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
         $canAnsver = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arUserRequests["FROM_USER_ID"], "message", CSocNetUser::IsCurrentUserModuleAdmin());
         if ($arParams["POPUP_TEMPLATE"]) {
             $ImageSize = 50;
         } else {
             $ImageSize = 150;
         }
示例#25
0
         $arResult["Friends"][] = array("USER_ID" => $arUser["ID"], "USER_NAME" => $arUser["NAME"], "USER_LAST_NAME" => $arUser["LAST_NAME"], "USER_SECOND_NAME" => $arUser["SECOND_NAME"], "USER_LOGIN" => $arUser["LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arUser["ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arUser["IS_ONLINE"] == "Y");
     }
 }
 //Recent users
 $arResult["RecentUsers"] = array();
 $arNavParams = array("nPageSize" => 20, "bDescPageNumbering" => false);
 $dbMessages = CSocNetMessages::GetMessagesUsers($GLOBALS["USER"]->GetID(), $arNavParams);
 while ($arMessages = $dbMessages->GetNext()) {
     $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arMessages["ID"]));
     $canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
     $arTmpUser = array("NAME" => $arMessages["~NAME"], "LAST_NAME" => $arMessages["~LAST_NAME"], "SECOND_NAME" => $arMessages["~SECOND_NAME"], "LOGIN" => $arMessages["~LOGIN"]);
     $strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arTmpUser, $bUseLogin);
     $arResult["RecentUsers"][] = array("USER_ID" => $arMessages["ID"], "USER_NAME" => $arMessages["NAME"], "USER_LAST_NAME" => $arMessages["LAST_NAME"], "USER_SECOND_NAME" => $arMessages["SECOND_NAME"], "USER_LOGIN" => $arMessages["LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arMessages["ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arMessages["IS_ONLINE"] == "Y");
 }
 $arResult["PrintSmilesList"] = CSocNetSmile::PrintSmilesList(0, LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
 $strNow = CSocNetMessages::Now();
 $strNow_ts = MakeTimeStamp($strNow, "YYYY-MM-DD HH:MI:SS") + CTimeZone::GetOffset();
 $arResult["Now"] = date("Y-m-d H:i:s", $strNow_ts);
 //user options
 require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . strtolower($GLOBALS['DB']->type) . "/favorites.php";
 $arResult["USER_OPTIONS"] = CUserOptions::GetOption('socnet', 'chat', array());
 if ($arResult["USER_OPTIONS"]["sound"] != "N") {
     $arResult["USER_OPTIONS"]["sound"] = "Y";
 }
 if ($arResult["USER_OPTIONS"]["contacts"] != "Y") {
     $arResult["USER_OPTIONS"]["contacts"] = "N";
 }
 $arResult["USER_OPTIONS"]["contacts_width"] = intval($arResult["USER_OPTIONS"]["contacts_width"]);
 $dirPath = '/bitrix/components/bitrix/socialnetwork.messages_chat';
 $arResult["MsgAddPath"] = $dirPath . "/add_message.php";
 $arResult["MsgGetPath"] = $dirPath . "/get_message.php";
示例#26
0
             }
         }
     } elseif ($_REQUEST["action"] == "reject") {
         if (!CSocNetUserToGroup::UserRejectRequestToBeMember($GLOBALS["USER"]->GetID(), IntVal($_REQUEST["eventID"]))) {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                 $errorMessage .= $e->GetString();
             }
         }
     }
     if (strlen($errorMessage) > 0) {
         echo $errorMessage;
     }
 } elseif ($_REQUEST["EventType"] == "Message" && IntVal($_REQUEST["eventID"]) > 0) {
     $errorMessage = "";
     if ($_REQUEST["action"] == "close") {
         if (!CSocNetMessages::MarkMessageRead($GLOBALS["USER"]->GetID(), IntVal($_REQUEST["eventID"]))) {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                 if ($e->GetID() != "ERROR_NO_MESSAGE") {
                     $errorMessage .= $e->GetString();
                 }
             }
         }
     }
     if (strlen($errorMessage) > 0) {
         echo $errorMessage;
     }
 } elseif ($_REQUEST["EventType"] == "Message" && IntVal($_REQUEST["userID"]) > 0) {
     $errorMessage = "";
     if ($_REQUEST["action"] == "ban") {
         if (!CSocNetUserRelations::BanUser($GLOBALS["USER"]->GetID(), IntVal($_REQUEST["userID"]))) {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
示例#27
0
 public function SendUnreadMessages($receiverJId, $domain = "")
 {
     $receiverJId = trim($receiverJId);
     if (strlen($receiverJId) <= 0) {
         return false;
     }
     $receiver = CXMPPUtility::GetUserByJId($receiverJId, $domain);
     if (!$receiver) {
         return false;
     }
     $factory = CXMPPFactory::GetFactory();
     if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
         $CIMMessage = new CIMMessage($receiverJId, array('hide_link' => true));
         $arMessage = $CIMMessage->GetUnreadMessage(array('SPEED_CHECK' => 'N', 'ORDER' => 'ASC', 'USE_SMILES' => 'N', 'USER_LOAD' => 'N', 'LOAD_DEPARTMENT' => 'N'));
         if ($arMessage['result']) {
             foreach ($arMessage['message'] as $id => $arMessage) {
                 $factory->__SendMessage($arMessage["senderId"], $arMessage["recipientId"], $arMessage["id"], IM_MESSAGE_PRIVATE, htmlspecialcharsbx(CTextParser::convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", $arMessage["text"]))), $domain);
             }
         }
         // Notify
         $CIMNotify = new CIMNotify($receiverJId);
         $arNotify = $CIMNotify->GetUnreadNotify(array('SPEED_CHECK' => 'N', 'ORDER' => 'ASC'));
         if ($arNotify['result']) {
             foreach ($arNotify['original_notify'] as $id => $arNotify) {
                 if (isset($arNotify["NOTIFY_MODULE"]) && isset($arNotify["NOTIFY_EVENT"]) && !CIMSettings::GetNotifyAccess($arNotify["TO_USER_ID"], $arNotify["NOTIFY_MODULE"], $arNotify["NOTIFY_EVENT"], CIMSettings::CLIENT_XMPP)) {
                     continue;
                 }
                 if ($arNotify["MESSAGE_OUT"] == IM_MAIL_SKIP) {
                     $arNotify["MESSAGE_OUT"] = '';
                 }
                 $factory->__SendMessage($arNotify["FROM_USER_ID"], $arNotify["TO_USER_ID"], $arNotify["ID"], IM_MESSAGE_SYSTEM, htmlspecialcharsbx(CTextParser::convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", strlen($arNotify["MESSAGE_OUT"]) > 0 ? $arNotify["MESSAGE_OUT"] : $arNotify["MESSAGE"]))), $domain);
             }
         }
     } else {
         $parser = new CSocNetTextParser();
         $dbMessages = CSocNetMessages::GetList(array("DATE_CREATE" => "ASC"), array("TO_USER_ID" => $receiver["ID"], "DATE_VIEW" => "", "TO_DELETED" => "N", "IS_LOG_ALL" => "Y"), false, false, array("ID", "FROM_USER_ID", "TO_USER_ID", "MESSAGE", "DATE_VIEW", "MESSAGE_TYPE", "FROM_DELETED", "TO_DELETED", "IS_LOG"));
         while ($arMessage = $dbMessages->Fetch()) {
             $factory->__SendMessage($arMessage["IS_LOG"] == "Y" ? -5 : $arMessage["FROM_USER_ID"], $arMessage["TO_USER_ID"], $arMessage["ID"], $arMessage["MESSAGE_TYPE"], htmlspecialcharsbx($parser->convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", $arMessage["MESSAGE"]))), $domain);
         }
     }
     return true;
 }
示例#28
0
 function SendRemindAgent($iblockId, $eventId, $userId, $pathToPage, $ownerType, $ownerId)
 {
     if (!CModule::IncludeModule("iblock")) {
         return;
     }
     if (!CModule::IncludeModule("socialnetwork")) {
         return;
     }
     if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) {
         $bTmpUser = True;
         $GLOBALS["USER"] = new CUser();
     }
     $rsEvent = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "ID" => $eventId, "CHECK_PERMISSIONS" => "N"), false, false, array("ID", "ACTIVE_FROM", "NAME", "IBLOCK_ID", "CREATED_BY", "IBLOCK_SECTION_ID"));
     if ($arEvent = $rsEvent->Fetch()) {
         $MESS = GetMessage('EC_EVENT_REMINDER', array('#EVENT_NAME#' => $arEvent["NAME"], '#DATE_FROM#' => $arEvent["ACTIVE_FROM"]));
         // Get Calendar Info:
         $rsCalendar = CIBlockSection::GetList(array('ID' => 'ASC'), array("ID" => $arEvent['IBLOCK_SECTION_ID'], "IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "N"));
         if (!($arCalendar = $rsCalendar->Fetch())) {
             return false;
         }
         $calendarName = $arCalendar['NAME'];
         if ($ownerType == 'USER' && $ownerId == $userId) {
             $MESS .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_PERSONAL', array('#CALENDAR_NAME#' => $calendarName));
         } else {
             if ($ownerType == 'USER') {
                 // Get user name
                 $dbUser = CUser::GetByID($ownerId);
                 if (!($arUser = $dbUser->Fetch())) {
                     return;
                 }
                 $ownerName = $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                 $MESS .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_USER', array('#CALENDAR_NAME#' => $calendarName, '#USER_NAME#' => $ownerName));
             } else {
                 if ($ownerType == 'GROUP') {
                     // Get group name
                     if (!($arGroup = CSocNetGroup::GetByID($ownerId))) {
                         return;
                     }
                     $ownerName = $arGroup["NAME"];
                     $MESS .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_GROUP', array('#CALENDAR_NAME#' => $calendarName, '#GROUP_NAME#' => $ownerName));
                 } else {
                     // Get iblock name
                     $rsIblock = CIBlock::GetList(array(), array("ID" => $iblockId, "CHECK_PERMISSIONS" => 'N'));
                     if (!($arIblock = $rsIblock->Fetch())) {
                         return;
                     }
                     $iblockName = $arIblock['NAME'];
                     $MESS .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_COMMON', array('#CALENDAR_NAME#' => $calendarName, '#IBLOCK_NAME#' => $iblockName));
                 }
             }
         }
         $MESS .= "\n" . GetMessage('EC_EVENT_REMINDER_DETAIL', array('#URL_VIEW#' => $pathToPage));
         $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $arEvent["CREATED_BY"], "TO_USER_ID" => $userId, "MESSAGE" => $MESS);
         CSocNetMessages::Add($arMessageFields);
         $db_events = GetModuleEvents("intranet", "OnRemindEventCalendar");
         while ($arEvent = $db_events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array(array('iblockId' => $iblockId, 'eventId' => $eventId, 'userId' => $userId, 'pathToPage' => $pathToPage, 'ownerType' => $ownerType, 'ownerId' => $ownerId)));
         }
     }
     if ($bTmpUser) {
         unset($GLOBALS["USER"]);
     }
 }
示例#29
0
 public static function UndeliveredMessageAgent()
 {
     if (!CModule::IncludeModule("socialnetwork")) {
         return false;
     }
     $activateNewAgent = false;
     $dbMessage = CSocNetMessages::GetList(array("ID" => "ASC"), array("DATE_VIEW" => "", "TO_DELETED" => "N", "MESSAGE_TYPE" => "P"), false, array("nTopCount" => '500'), array("ID", "FROM_USER_ID", "TO_USER_ID", "MESSAGE", "DATE_CREATE"));
     while ($arMessage = $dbMessage->Fetch()) {
         $ar = array("FROM_USER_ID" => intval($arMessage["FROM_USER_ID"]), "TO_USER_ID" => intval($arMessage["TO_USER_ID"]), "MESSAGE" => $arMessage["MESSAGE"], "MESSAGE_DATE" => $arMessage["DATE_CREATE"]);
         CIMMessage::Add($ar);
         CSocNetMessages::Update($arMessage["ID"], array("TO_DELETED" => "Y", "FROM_DELETED" => "Y"));
         $activateNewAgent = true;
     }
     return $activateNewAgent ? "CIMConvert::UndeliveredMessageAgent();" : "";
 }
示例#30
0
     while ($arMessages = $dbMessages->GetNext()) {
         if ($arMessages["WHO"] != "IN") {
             if ($userId > 0) {
                 if ($userId != $arMessages["USER_ID"]) {
                     continue;
                 }
             } else {
                 if ($bFirst) {
                     $bFirst = false;
                 } else {
                     continue;
                 }
             }
         }
         if ($userId > 0 && $userId == $arMessages["USER_ID"] && StrLen($arMessages["DATE_VIEW"]) <= 0 && $arMessages["WHO"] == "IN") {
             CSocNetMessages::Update($arMessages["ID"], array("=DATE_VIEW" => $DB->CurrentTimeFunction()));
         }
         echo "m" . $arMessages["USER_ID"] . "\r\n";
         echo $arMessages["DATE_CREATE_FMT"] . "\r\n";
         echo $arMessages["WHO"] . $arMessages["ID"] . "\r\n";
         echo $parser->convert($arMessages["~MESSAGE"], false, array(), array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LIST" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "SMILES" => "Y", "UPLOAD" => "N", "NL2BR" => "N"));
         echo "\r\n";
     }
 }
 //online status
 $db = CUser::GetList($by, $order, array("LAST_ACTIVITY" => 120));
 while ($dba = $db->Fetch()) {
     if ($dba['ID'] != $currUserId) {
         echo "+" . $dba['ID'] . "\r\n";
     }
 }