本文整理汇总了PHP中CIMNotify::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CIMNotify::Add方法的具体用法?PHP CIMNotify::Add怎么用?PHP CIMNotify::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMNotify
的用法示例。
在下文中一共展示了CIMNotify::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notify
public static function notify($arParams)
{
global $USER;
$arParams = array_change_key_case($arParams, CASE_UPPER);
$arMessageFields = array("TO_USER_ID" => $arParams['TO'], "FROM_USER_ID" => $USER->GetID(), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "rest", "NOTIFY_EVENT" => "rest_notify", "NOTIFY_MESSAGE" => $arParams['MESSAGE']);
return CIMNotify::Add($arMessageFields);
}
示例2: notify
public static function notify($arParams, $n, $server)
{
global $USER;
$arParams = array_change_key_case($arParams, CASE_UPPER);
if (!isset($arParams['TYPE']) || !in_array($arParams['TYPE'], array('USER', 'SYSTEM'))) {
$arParams['TYPE'] = 'USER';
}
if ($arParams['TYPE'] == 'SYSTEM') {
$result = \CBitrix24App::getList(array(), array('APP_ID' => $server->getAppId()));
$result = $result->fetch();
$moduleName = isset($result['APP_NAME']) ? $result['APP_NAME'] : $result['CODE'];
$fromUserId = 0;
$notifyType = IM_NOTIFY_SYSTEM;
$message = $moduleName . "#BR#" . $arParams['MESSAGE'];
} else {
$fromUserId = $USER->GetID();
$notifyType = IM_NOTIFY_FROM;
$message = $arParams['MESSAGE'];
}
$message = trim($message);
if (strlen($message) <= 0) {
return false;
}
$arMessageFields = array("TO_USER_ID" => $arParams['TO'], "FROM_USER_ID" => $fromUserId, "NOTIFY_TYPE" => $notifyType, "NOTIFY_MODULE" => "rest", "NOTIFY_EVENT" => "rest_notify", "NOTIFY_MESSAGE" => $message);
return CIMNotify::Add($arMessageFields);
}
示例3: Notify
public static function Notify($addresseeID, $internalMessage, $externalMessage, $schemeTypeID, $tag = '')
{
self::ClearErrors();
if (!(IsModuleInstalled('im') && CModule::IncludeModule('im'))) {
self::RegisterError('IM module is not installed.');
return false;
}
if ($addresseeID <= 0) {
self::RegisterError('Addressee is not assigned.');
return false;
}
$arMessage = array('TO_USER_ID' => $addresseeID, 'FROM_USER_ID' => 0, 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_MODULE' => 'crm', 'NOTIFY_MESSAGE' => strval($internalMessage), 'NOTIFY_MESSAGE_OUT' => strval($externalMessage));
$schemeTypeName = CCrmNotifierSchemeType::ResolveName($schemeTypeID);
if ($schemeTypeName !== '') {
$arMessage['NOTIFY_EVENT'] = $schemeTypeName;
}
$tag = strval($tag);
if ($tag !== '') {
$arMessage['NOTIFY_TAG'] = $tag;
}
$msgID = CIMNotify::Add($arMessage);
if (!$msgID) {
$e = $GLOBALS['APPLICATION']->GetException();
$errorMessage = $e ? $e->GetString() : 'Unknown sending error. message not send.';
self::RegisterError($errorMessage);
return false;
}
return true;
}
示例4: Add
function Add($arFields)
{
global $DB;
if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
if ($arFields["MESSAGE_TYPE"] == SONET_MESSAGE_SYSTEM) {
if (!(isset($arFields["EMAIL_TEMPLATE"]) && strlen($arFields["EMAIL_TEMPLATE"]) > 0)) {
$arFields["EMAIL_TEMPLATE"] = "SONET_NEW_MESSAGE";
}
$ID = CIMNotify::Add($arFields);
return $ID;
} else {
CIMMessenger::SpeedFileDelete($arFields['TO_USER_ID'], IM_SPEED_MESSAGE);
}
}
if (defined("INTASK_SKIP_SOCNET_MESSAGES1") && INTASK_SKIP_SOCNET_MESSAGES1) {
$arFields["=DATE_VIEW"] = $DB->CurrentTimeFunction();
}
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CSocNetMessages::CheckFields("ADD", $arFields)) {
return false;
}
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetMessagesAdd");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
$arInsert = $DB->PrepareInsert("b_sonet_messages", $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_messages(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
$events = GetModuleEvents("socialnetwork", "OnSocNetMessagesAdd");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
//CSocNetMessages::SendEvent($ID, "SONET_NEW_MESSAGE");
CSocNetMessages::__SpeedFileCreate($arFields["TO_USER_ID"]);
}
return $ID;
}
示例5: afterInsertTrigger
/**
* Method will be invoked after new database record inserted.
*
* @param array $newRecord All fields of inserted record.
*
* @return void
*/
public function afterInsertTrigger(array $newRecord)
{
$id = intval($newRecord['MESSAGE_ID']);
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
$message = \CIMMessenger::GetById($id, array('WITH_FILES' => 'Y'));
if (!$message) {
return;
}
if ($newRecord['PARAM_NAME'] === 'LIKE' && $newRecord["PARAM_VALUE"]) {
$like = $message['PARAMS']['LIKE'];
$result = \Bitrix\IM\ChatTable::getList(array('filter' => array('=ID' => $message['CHAT_ID'])));
$chat = $result->fetch();
$relations = \CIMMessenger::GetRelationById($id);
if (!isset($relations[$newRecord["PARAM_VALUE"]])) {
return;
}
if ($message['AUTHOR_ID'] > 0 && $message['AUTHOR_ID'] != $newRecord["PARAM_VALUE"]) {
$CCTP = new \CTextParser();
$CCTP->MaxStringLen = 200;
$CCTP->allow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
$message['MESSAGE'] = str_replace('<br />', ' ', $CCTP->convertText($message['MESSAGE']));
$message['MESSAGE'] = preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/\\[[bui]\\](.*?)\\[\\/[bui]\\]/i", "\$1", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/\\[USER=([0-9]{1,})\\](.*?)\\[\\/USER\\]/i", "\$2", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [" . GetMessage('IM_QUOTE') . "] ", str_replace(array("#BR#"), array(" "), $message['MESSAGE']));
if (count($message['FILES']) > 0 && strlen($message['MESSAGE']) < 200) {
foreach ($message['FILES'] as $file) {
$file = " [" . GetMessage('IM_MESSAGE_FILE') . ": " . $file['name'] . "]";
if (strlen($message['MESSAGE'] . $file) > 200) {
break;
}
$message['MESSAGE'] .= $file;
}
$message['MESSAGE'] = trim($message['MESSAGE']);
}
$isChat = $chat && strlen($chat['TITLE']) > 0;
$dot = strlen($message['MESSAGE']) >= 200 ? '...' : '';
$message['MESSAGE'] = substr($message['MESSAGE'], 0, 199) . $dot;
$message['MESSAGE'] = strlen($message['MESSAGE']) > 0 ? $message['MESSAGE'] : '-';
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $message['AUTHOR_ID'], "FROM_USER_ID" => $newRecord["PARAM_VALUE"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|IM|" . ($isChat ? 'G' : 'P') . "|" . ($isChat ? $chat['ID'] : $newRecord["PARAM_VALUE"]) . "|" . $id, "NOTIFY_MESSAGE" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $chat['TITLE'])));
\CIMNotify::Add($arMessageFields);
}
$arPullMessage = array('id' => $id, 'chatId' => $relations[$newRecord["PARAM_VALUE"]]['CHAT_ID'], 'senderId' => $newRecord["PARAM_VALUE"], 'users' => $like);
foreach ($relations as $rel) {
\CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage));
}
}
}
示例6: notify
public static function notify($arParams)
{
global $USER;
$arMessageFields = array(
"TO_USER_ID" => $arParams['to'],
"FROM_USER_ID" => $USER->GetID(),
"NOTIFY_TYPE" => IM_NOTIFY_FROM,
"NOTIFY_MODULE" => "rest",
"NOTIFY_EVENT" => "rest_notify",// - get it from the oauth module
"NOTIFY_MESSAGE" => $arParams['message'],
);
return CIMNotify::Add($arMessageFields);
}
示例7: SendMessage
/**
* Sends notifications to IM.
*
* @param $fromUserID
* @param $arRecipientsIDs
* @param $message
* @param int $taskID
* @param null $message_email
* @param array $arEventData
* @return bool|null
*/
public static function SendMessage($fromUserID, $arRecipientsIDs, $message, $taskID = 0, $message_email = null, $arEventData = array(), $taskAssignedTo = null)
{
if (!(IsModuleInstalled("im") && CModule::IncludeModule("im"))) {
return false;
}
$message_email = is_null($message_email) ? $message : $message_email;
if (!($fromUserID && $arRecipientsIDs && $message)) {
return false;
}
CTaskAssert::assert(is_array($arEventData));
$arEventData['fromUserID'] =& $fromUserID;
$arEventData['arRecipientsIDs'] =& $arRecipientsIDs;
$arEventData['message'] =& $message;
$arEventData['message_email'] =& $message_email;
foreach (GetModuleEvents('tasks', 'OnBeforeTaskNotificationSend', true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($arEventData)) === false) {
return false;
}
}
$arSites = array();
if (CModule::IncludeModule("extranet")) {
$dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
while ($arSite = $dbSite->Fetch()) {
$type = $arSite["ID"] == CExtranet::GetExtranetSiteID() ? "EXTRANET" : "INTRANET";
if ($type === 'INTRANET' && isset($arSites['INTRANET']) && $arSite['DEF'] !== 'Y') {
// Don't overwrite INTRANET site data by not default site
continue;
}
$arSites[$type] = array('SITE_ID' => $arSite['ID'], "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"]));
}
}
if (is_array($arRecipientsIDs) && count($arRecipientsIDs)) {
$arRecipientsIDs = array_unique($arRecipientsIDs);
$rsUser = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', $arRecipientsIDs)), array('FIELDS' => array('ID')));
while ($arUser = $rsUser->Fetch()) {
$notifyEvent = 'manage';
if ($taskAssignedTo !== null) {
if ($arUser['ID'] == $taskAssignedTo) {
$notifyEvent = 'task_assigned';
}
}
$pathToTask = CTaskNotifications::GetNotificationPath($arUser, $taskID, true, $arSites);
$arMessageFields = array("TO_USER_ID" => $arUser['ID'], "FROM_USER_ID" => $fromUserID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "tasks", "NOTIFY_EVENT" => $notifyEvent, "NOTIFY_MESSAGE" => str_replace("#PATH_TO_TASK#", $pathToTask, $message), "NOTIFY_MESSAGE_OUT" => strip_tags(str_replace("#PATH_TO_TASK#", $pathToTask, $message_email)));
CIMNotify::Add($arMessageFields);
}
}
return null;
}
示例8: onAfterTimeManagerDayStart
public static function onAfterTimeManagerDayStart($arData)
{
if (!(isset($arData['USER_ID'], $arData['MODIFIED_BY']) && $arData['USER_ID'] > 0 && $arData['MODIFIED_BY'] > 0 && $arData['MODIFIED_BY'] == $arData['USER_ID'] && IsModuleInstalled("im") && CModule::IncludeModule("im"))) {
return;
}
$recipientId = (int) $arData['USER_ID'];
try {
$tasksCounter = CTaskListCtrl::getMainCounterForUser($recipientId);
if ($tasksCounter <= 0) {
return;
}
/** @noinspection PhpDeprecationInspection */
CIMNotify::Add(array('FROM_USER_ID' => 0, 'TO_USER_ID' => $recipientId, 'NOTIFY_MODULE' => 'tasks', 'NOTIFY_EVENT' => 'notice', 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_TAG' => 'TASKS|COUNTERS_NOTICE|' . $recipientId, 'MESSAGE' => CTasksTools::getMessagePlural($tasksCounter, 'TASKS_COUNTERS_NOTICE_CONTENT_V2', array('#TASKS_COUNT#' => $tasksCounter, '#HREF#' => self::getTasksListLink($recipientId))), 'TITLE' => GetMessage('TASKS_COUNTERS_NOTICE_TITLE')));
} catch (Exception $e) {
CTaskAssert::logWarning('[0xb83d6845] unexpected exception in CTaskCountersNotifier::onAfterTimeManagerDayStart()' . ', file: ' . $e->getFile() . ', line: ' . $e->getLine() . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage());
}
}
示例9: Execute
public function Execute()
{
if (!CModule::IncludeModule("im")) {
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("FROM_USER_ID" => $arMessageUserFrom, "NOTIFY_TYPE" => intval($this->MessageType), "NOTIFY_MESSAGE" => $this->MessageSite, "NOTIFY_MESSAGE_OUT" => $this->MessageOut, "NOTIFY_MODULE" => "bizproc", "NOTIFY_EVENT" => "activity");
$ar = array();
foreach ($arMessageUserTo as $userTo) {
if (in_array($userTo, $ar)) {
continue;
}
$ar[] = $userTo;
$arMessageFields["TO_USER_ID"] = $userTo;
CIMNotify::Add($arMessageFields);
}
return CBPActivityExecutionStatus::Closed;
}
示例10: SendMentionNotification
public static function SendMentionNotification($arCommentFields)
{
if (!CModule::IncludeModule("im")) {
return false;
}
switch ($arCommentFields["EVENT_ID"]) {
case "forum":
$arTitleRes = self::OnSendMentionGetEntityFields_Forum($arCommentFields);
break;
default:
$db_events = GetModuleEvents("socialnetwork", "OnSendMentionGetEntityFields");
while ($arEvent = $db_events->Fetch()) {
$arTitleRes = ExecuteModuleEventEx($arEvent, array($arCommentFields));
if ($arTitleRes) {
break;
}
}
}
if ($arTitleRes && is_array($arTitleRes) && !empty($arTitleRes["NOTIFY_MESSAGE"])) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $arCommentFields["USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => !empty($arTitleRes["NOTIFY_MODULE"]) ? $arTitleRes["NOTIFY_MODULE"] : "socialnetwork", "NOTIFY_EVENT" => "mention", "NOTIFY_TAG" => !empty($arTitleRes["NOTIFY_TAG"]) ? $arTitleRes["NOTIFY_TAG"] : "LOG_COMMENT|COMMENT_MENTION|" . $arCommentFields["ID"]);
preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/ies" . BX_UTF_PCRE_MODIFIER, $arCommentFields["MESSAGE"], $arMention);
if (!empty($arMention)) {
$arMention = $arMention[1];
$arExcludeUsers = array();
if (!empty($arCommentFields["LOG_ID"])) {
$rsUnFollower = CSocNetLogFollow::GetList(array("CODE" => "L" . $arCommentFields["LOG_ID"], "TYPE" => "N"), array("USER_ID"));
while ($arUnFollower = $rsUnFollower->Fetch()) {
$arExcludeUsers[] = $arUnFollower["USER_ID"];
}
}
$arSourceURL = array("URL" => $arTitleRes["URL"]);
if (!empty($arTitleRes["CRM_URL"])) {
$arSourceURL["CRM_URL"] = $arTitleRes["CRM_URL"];
}
foreach ($arMention as $mentionUserID) {
$bHaveRights = CSocNetLogRights::CheckForUserOnly($arCommentFields["LOG_ID"], $mentionUserID);
if (!$bHaveRights && $arTitleRes["IS_CRM"] == "Y") {
$dbLog = CSocNetLog::GetList(array(), array("ID" => $arCommentFields["LOG_ID"], "ENTITY_TYPE" => $arCommentFields["ENTITY_TYPE"]), false, false, array("ID"), array("IS_CRM" => "Y", "CHECK_CRM_RIGHTS" => "Y", "USER_ID" => $mentionUserID, "USE_SUBSCRIBE" => "N"));
if ($arLog = $dbLog->Fetch()) {
$bHaveCrmRights = true;
}
}
if (in_array($mentionUserID, $arExcludeUsers) || !$bHaveRights && !$bHaveCrmRights) {
continue;
}
$url = false;
if (!empty($arSourceURL["URL"]) || !empty($arSourceURL["CRM_URL"])) {
$arTmp = CSocNetLogTools::ProcessPath($arSourceURL, $mentionUserID);
if ($arTitleRes["IS_CRM"] == "Y" && !$bHaveRights && !empty($arTmp["URLS"]["CRM_URL"])) {
$url = $arTmp["URLS"]["CRM_URL"];
} else {
$url = $arTmp["URLS"]["URL"];
}
$serverName = strpos($url, "http://") === 0 || strpos($url, "https://") === 0 ? "" : $arTmp["SERVER_NAME"];
}
$arMessageFields["TO_USER_ID"] = $mentionUserID;
$arMessageFields["NOTIFY_MESSAGE"] = str_replace(array("#url#", "#server_name#"), array($url, $serverName), $arTitleRes["NOTIFY_MESSAGE"]);
$arMessageFields["NOTIFY_MESSAGE_OUT"] = !empty($arTitleRes["NOTIFY_MESSAGE_OUT"]) ? str_replace(array("#url#", "#server_name#"), array($url, $serverName), $arTitleRes["NOTIFY_MESSAGE_OUT"]) : "";
CIMNotify::Add($arMessageFields);
}
$arMentionedDestCode = array();
foreach ($arMention as $val) {
$arMentionedDestCode[] = "U" . $val;
}
\Bitrix\Main\FinderDestTable::merge(array("CONTEXT" => "mention", "CODE" => array_unique($arMentionedDestCode)));
}
}
}
示例11: SynchronizeLiveFeedEvent
private static function SynchronizeLiveFeedEvent($activityID, $params)
{
if (!is_array($params)) {
$params = array();
}
$processBindings = isset($params['PROCESS_BINDINGS']) ? (bool) $params['PROCESS_BINDINGS'] : false;
$bindings = isset($params['BINDINGS']) && is_array($params['BINDINGS']) ? $params['BINDINGS'] : array();
$hasBindings = !empty($bindings);
if ($processBindings) {
CCrmSonetRelation::UnRegisterRelationsByEntity(CCrmOwnerType::Activity, $activityID, array('QUICK' => $hasBindings));
}
$arOwners = $hasBindings ? $bindings : self::GetBindings($activityID);
$slEntities = CCrmLiveFeed::GetLogEvents(array(), array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $activityID), array('ID', 'EVENT_ID'));
if (empty($slEntities)) {
return false;
}
global $DB;
foreach ($slEntities as &$slEntity) {
$slID = intval($slEntity['ID']);
$slEventType = $slEntity['EVENT_ID'];
if (isset($params['REFRESH_DATE']) ? (bool) $params['REFRESH_DATE'] : false) {
//Update LOG_UPDATE for force event to rise in global feed
//Update LOG_DATE for force event to rise in entity feed
CCrmLiveFeed::UpdateLogEvent($slID, array('=LOG_UPDATE' => $DB->CurrentTimeFunction(), '=LOG_DATE' => $DB->CurrentTimeFunction()));
} else {
//HACK: FAKE UPDATE FOR INVALIDATE CACHE
CCrmLiveFeed::UpdateLogEvent($slID, array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $activityID));
}
/*
'START_RESPONSIBLE_ID' => $arPrevEntity['RESPONSIBLE_ID'],
'FINAL_RESPONSIBLE_ID' => $responsibleID
*/
$userID = intval($params['EDITOR_ID']) > 0 ? $params['EDITOR_ID'] : CCrmSecurityHelper::GetCurrentUserID();
if (intval($params['START_RESPONSIBLE_ID']) != intval($params['FINAL_RESPONSIBLE_ID']) && CModule::IncludeModule("im")) {
switch ($params['TYPE_ID']) {
case CCrmActivityType::Call:
$type = 'CALL';
break;
case CCrmActivityType::Meeting:
$type = 'MEETING';
break;
default:
$type = false;
}
if ($type) {
$url = "/crm/stream/?log_id=#log_id#";
$url = str_replace(array("#log_id#"), array($slID), $url);
$serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $userID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "LOG_ID" => $slID, "NOTIFY_EVENT" => "activity_add", "NOTIFY_TAG" => "CRM|ACTIVITY|" . $activityID);
if (intval($params['START_RESPONSIBLE_ID']) != $userID) {
$bHasPermissions = false;
$perms = CCrmPerms::GetUserPermissions($params['START_RESPONSIBLE_ID']);
foreach ($arOwners as $arOwner) {
if (CCrmActivity::CheckReadPermission($arOwner["OWNER_TYPE_ID"], $arOwner["OWNER_ID"], $perms)) {
$bHasPermissions = true;
break;
}
}
if ($bHasPermissions) {
$arMessageFields["TO_USER_ID"] = $params['START_RESPONSIBLE_ID'];
$arMessageFields["NOTIFY_MESSAGE"] = GetMessage("CRM_ACTIVITY_" . $type . "_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => '<a href="' . $url . '">' . htmlspecialcharsbx($params['SUBJECT']) . '</a>'));
$arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("CRM_ACTIVITY_" . $type . "_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($params['SUBJECT']))) . " (" . $serverName . $url . ")";
CIMNotify::Add($arMessageFields);
}
}
if (intval($params['FINAL_RESPONSIBLE_ID']) != $userID) {
$bHasPermissions = false;
$perms = CCrmPerms::GetUserPermissions($params['FINAL_RESPONSIBLE_ID']);
foreach ($arOwners as $arOwner) {
if (CCrmActivity::CheckReadPermission($arOwner["OWNER_TYPE_ID"], $arOwner["OWNER_ID"], $perms)) {
$bHasPermissions = true;
break;
}
}
if ($bHasPermissions) {
$arMessageFields["TO_USER_ID"] = $params['FINAL_RESPONSIBLE_ID'];
$arMessageFields["NOTIFY_MESSAGE"] = GetMessage("CRM_ACTIVITY_" . $type . "_RESPONSIBLE_IM_NOTIFY", array("#title#" => '<a href="' . $url . '">' . htmlspecialcharsbx($params['SUBJECT']) . '</a>'));
$arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("CRM_ACTIVITY_" . $type . "_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($params['SUBJECT']))) . " (" . $serverName . $url . ")";
CIMNotify::Add($arMessageFields);
}
}
}
}
if ($processBindings && $hasBindings) {
CCrmSonetRelation::RegisterRelationBundle($slID, $slEventType, CCrmOwnerType::Activity, $activityID, $bindings, array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID', 'TYPE_ID' => CCrmSonetRelationType::Ownership));
}
}
unset($slEntity);
return true;
}
示例12: AddComment_Wiki
static function AddComment_Wiki($arFields)
{
if (!CModule::IncludeModule('iblock')) {
return false;
}
if (!CModule::IncludeModule('socialnetwork')) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array('ID' => 'DESC'), array('TMP_ID' => $arFields['LOG_ID']), false, false, array('ID', 'SOURCE_ID', 'PARAMS', 'URL'));
$bFound = false;
if ($arLog = $dbResult->Fetch()) {
if (strlen($arLog['PARAMS']) > 0) {
$arFieldsParams = explode('&', $arLog['PARAMS']);
if (is_array($arFieldsParams) && count($arFieldsParams) > 0) {
foreach ($arFieldsParams as $tmp) {
list($key, $value) = explode('=', $tmp);
if ($key == 'forum_id') {
$FORUM_ID = intval($value);
break;
}
}
}
}
if ($FORUM_ID > 0 && intval($arLog['SOURCE_ID']) > 0) {
$bFound = true;
}
}
if ($bFound) {
$arElement = false;
$arFilter = array('ID' => $arLog['SOURCE_ID']);
$arSelectedFields = array('IBLOCK_ID', 'ID', 'NAME', 'TAGS', 'CODE', 'IBLOCK_SECTION_ID', 'DETAIL_PAGE_URL', 'CREATED_BY', 'PREVIEW_PICTURE', 'PREVIEW_TEXT', 'PROPERTY_FORUM_TOPIC_ID', 'PROPERTY_FORUM_MESSAGE_CNT');
$db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
if ($db_res && ($res = $db_res->GetNext())) {
$arElement = $res;
}
if ($arElement) {
// check iblock properties
CSocNetLogTools::AddComment_Review_CheckIBlock($arElement);
$dbMessage = CForumMessage::GetList(array(), array('PARAM2' => $arElement['ID']));
if (!($arMessage = $dbMessage->Fetch())) {
// Add Topic and Root Message
$TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot($arElement, $FORUM_ID, false);
$bNewTopic = true;
} else {
$TOPIC_ID = $arMessage['TOPIC_ID'];
}
if (intval($TOPIC_ID) > 0) {
// Add comment
$messageID = false;
$arFieldsMessage = array('POST_MESSAGE' => $arFields['TEXT_MESSAGE'], 'USE_SMILES' => 'Y', 'PARAM2' => $arElement['ID'], 'APPROVED' => 'Y');
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$messageID = ForumAddMessage('REPLY', $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
if (!$messageID) {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
} else {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
CSocNetLogTools::AddComment_Review_UpdateElement($arElement, $TOPIC_ID, $bNewTopic);
$userID = $GLOBALS["USER"]->GetID();
if (CModule::IncludeModule("im") && intval($arElement["CREATED_BY"]) > 0 && $arElement["CREATED_BY"] != $userID) {
$rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arElement["CREATED_BY"], "CODE" => "L" . $arLog["ID"], "TYPE" => "N"), array("USER_ID"));
$arUnFollower = $rsUnFollower->Fetch();
if (!$arUnFollower) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arElement["CREATED_BY"], "FROM_USER_ID" => $userID, "LOG_ID" => $arLog["ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "wiki", "NOTIFY_EVENT" => "comment");
$arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arElement["NAME"]);
$arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
$arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
$arTmp = CSocNetLogTools::ProcessPath(array("ELEMENT_URL" => $arLog["URL"]), $arElement["CREATED_BY"]);
$serverName = $arTmp["SERVER_NAME"];
$url = $arTmp["URLS"]["ELEMENT_URL"];
$arMessageFields["NOTIFY_TAG"] = "WIKI|COMMENT|" . $arElement['ID'];
$arMessageFields["NOTIFY_MESSAGE"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => strlen($url) > 0 ? "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>" : htmlspecialcharsbx($arParams["TITLE"])));
$arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => htmlspecialcharsbx($arParams["TITLE"]))) . (strlen($url) > 0 ? " (" . $serverName . $url . ")" : "") . "#BR##BR#" . $arFields["TEXT_MESSAGE"];
CIMNotify::Add($arMessageFields);
}
}
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
//.........这里部分代码省略.........
示例13: NotifyComment
public static function NotifyComment($eventID, $arComment)
{
if (!CModule::IncludeModule("im")) {
return;
}
if (intval($eventID) <= 0) {
return;
}
if ($arCalendarEvent = CCalendarEvent::GetById($eventID)) {
$rsUser = CUser::GetList($by = 'id', $order = 'asc', array('ID_EQUAL_EXACT' => intval($arComment["USER_ID"])), array('FIELDS' => array('PERSONAL_GENDER')));
$strMsgAddComment = GetMessage("EC_LF_COMMENT_MESSAGE_ADD");
$strMsgEditComment = GetMessage("EC_LF_COMMENT_MESSAGE_ADD");
if ($arUser = $rsUser->fetch()) {
switch ($arUser['PERSONAL_GENDER']) {
case "F":
case "M":
$strMsgAddComment = GetMessage("EC_LF_COMMENT_MESSAGE_ADD" . '_' . $arUser['PERSONAL_GENDER']);
break;
default:
break;
}
}
$arMessageFields = array("FROM_USER_ID" => $arComment["USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "calendar", "NOTIFY_EVENT" => "event_comment", "NOTIFY_MESSAGE" => str_replace(array("#EVENT_TITLE#"), array(strlen($arComment["URL"]) > 0 ? "<a href=\"" . $arComment["URL"] . "\" class=\"bx-notifier-item-action\">" . $arCalendarEvent["NAME"] . "</a>" : $arCalendarEvent["NAME"]), $strMsgAddComment), "NOTIFY_MESSAGE_OUT" => str_replace(array("#EVENT_TITLE#"), array($arCalendarEvent["NAME"]), $strMsgAddComment) . (strlen($arComment["URL"]) > 0 ? " (" . $arComment["URL"] . ")" : "") . "#BR##BR#" . $arComment["MESSAGE"]);
if (is_array($arCalendarEvent["~ATTENDEES"])) {
foreach ($arCalendarEvent["~ATTENDEES"] as $arAttendee) {
if ($arAttendee["USER_ID"] == $arComment["USER_ID"]) {
continue;
}
$arMessageFields1 = array_merge($arMessageFields, array("TO_USER_ID" => $arAttendee["USER_ID"]));
CIMNotify::Add($arMessageFields1);
}
}
}
}
示例14: NotifyGroup
public static function NotifyGroup($arFields)
{
if (!CModule::IncludeModule("im")) {
return;
}
if (!is_array($arFields["GROUP_ID"])) {
$arFields["GROUP_ID"] = array($arFields["GROUP_ID"]);
}
if (empty($arFields["GROUP_ID"])) {
return;
}
if (empty($arFields["EXCLUDE_USERS"])) {
$arFields["EXCLUDE_USERS"] = array();
}
if (intval($arFields["LOG_ID"]) > 0) {
$rsUnFollower = CSocNetLogFollow::GetList(array("CODE" => "L" . intval($arFields["LOG_ID"]), "TYPE" => "N"), array("USER_ID"));
while ($arUnFollower = $rsUnFollower->Fetch()) {
$arFields["EXCLUDE_USERS"][] = $arUnFollower["USER_ID"];
}
$arFields["EXCLUDE_USERS"] = array_unique($arFields["EXCLUDE_USERS"]);
}
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "socialnetwork", "NOTIFY_EVENT" => "sonet_group_event", "NOTIFY_TAG" => "SONET|EVENT|" . (intval($arFields["LOG_ID"]) > 0 ? $arFields["LOG_ID"] : rand()));
if (intval($arFields["FROM_USER_ID"]) > 0) {
$arMessageFields["FROM_USER_ID"] = $arFields["FROM_USER_ID"];
}
$arUserToSend = array();
$arUserIDToSend = array();
$arGroupID = array();
$arCodes = array();
foreach ($arFields["GROUP_ID"] as $group_id) {
$arCodes[] = "SG" . $group_id;
}
$rsSubscriber = CSocNetSubscription::GetList(array(), array("CODE" => $arCodes), false, false, array("USER_ID", "CODE"));
while ($arSubscriber = $rsSubscriber->Fetch()) {
if (!in_array($arSubscriber["USER_ID"], $arFields["EXCLUDE_USERS"]) && !in_array($arSubscriber["USER_ID"], $arUserIDToSend)) {
if (preg_match('/^SG(\\d+)$/', $arSubscriber["CODE"], $matches)) {
$arUserToSend[] = array("USER_ID" => $arSubscriber["USER_ID"], "GROUP_ID" => $matches[1]);
$arUserIDToSend[] = $arSubscriber["USER_ID"];
$arGroupID[] = $matches[1];
}
}
}
$rsGroup = CSocNetGroup::GetList(array(), array("ID" => $arGroupID), false, false, array("ID", "NAME", "OWNER_ID"));
while ($arGroup = $rsGroup->GetNext()) {
$arGroups[$arGroup["ID"]] = $arGroup;
}
$workgroupsPage = COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID);
$groupUrlTemplate = COption::GetOptionString("socialnetwork", "group_path_template", "/workgroups/group/#group_id#/", SITE_ID);
$groupUrlTemplate = "#GROUPS_PATH#" . substr($groupUrlTemplate, strlen($workgroupsPage), strlen($groupUrlTemplate) - strlen($workgroupsPage));
foreach ($arUserToSend as $arUser) {
$arMessageFields["TO_USER_ID"] = $arUser["USER_ID"];
$arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arFields["URL"], "GROUP_URL" => str_replace(array("#group_id#", "#GROUP_ID#"), $arUser["GROUP_ID"], $groupUrlTemplate)), $arUser["USER_ID"]);
$url = $arTmp["URLS"]["URL"];
if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) {
$serverName = "";
} else {
$serverName = $arTmp["SERVER_NAME"];
}
$groupUrl = $serverName . $arTmp["URLS"]["GROUP_URL"];
$group_name = array_key_exists($arUser["GROUP_ID"], $arGroups) ? $arGroups[$arUser["GROUP_ID"]]["NAME"] : "";
$arMessageFields["NOTIFY_MESSAGE"] = str_replace(array("#URL#", "#url#", "#group_name#", "#GROUP_ID#", "#group_id#"), array($url, $url, "<a href=\"" . $groupUrl . "\" class=\"bx-notifier-item-action\">" . $group_name . "</a>", $arUser["GROUP_ID"], $arUser["GROUP_ID"]), $arFields["MESSAGE"]);
$arMessageFields["NOTIFY_MESSAGE_OUT"] = str_replace(array("#URL#", "#url#", "#group_name#"), array($serverName . $url, $serverName . $url, $group_name), $arFields["MESSAGE_OUT"]);
$arMessageFields2Send = $arMessageFields;
if (!is_set($arMessageFields2Send["FROM_USER_ID"]) || intval($arMessageFields2Send["FROM_USER_ID"]) <= 0) {
$arMessageFields2Send["NOTIFY_TYPE"] = IM_NOTIFY_SYSTEM;
$arMessageFields2Send["FROM_USER_ID"] = 0;
}
CIMNotify::Add($arMessageFields2Send);
}
}
示例15: Like
public static function Like($id, $action = 'auto')
{
global $USER;
if (!CModule::IncludeModule('pull'))
return false;
$action = in_array($action, Array('plus', 'minus'))? $action: 'auto';
$message = self::GetById($id, Array('WITH_FILES' => 'Y'));
if (!$message)
return false;
$relations = CIMMessenger::GetRelationById($id);
if (!isset($relations[$USER->GetId()]))
return false;
$isLike = false;
if (isset($message['PARAMS']['LIKE']))
{
$isLike = in_array($USER->GetId(), $message['PARAMS']['LIKE']);
}
if ($isLike && $action == 'plus')
{
return false;
}
else if (!$isLike && $action == 'minus')
{
return false;
}
$isLike = true;
if (isset($message['PARAMS']['LIKE']))
{
$like = $message['PARAMS']['LIKE'];
$selfLike = array_search($USER->GetId(), $like);
if ($selfLike !== false)
{
$isLike = false;
unset($like[$selfLike]);
}
else
{
$like[] = $USER->GetId();
}
}
else
{
$like = Array($USER->GetId());
}
sort($like);
CIMMessageParam::Set($id, Array('LIKE' => $like));
$result = IM\ChatTable::getList(Array(
'filter'=>Array(
'=ID' => $message['CHAT_ID']
)
));
$chat = $result->fetch();
if ($message['AUTHOR_ID'] > 0 && $message['AUTHOR_ID'] != $USER->GetId() && $isLike)
{
$CCTP = new CTextParser();
$CCTP->MaxStringLen = 200;
$CCTP->allow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
$message['MESSAGE'] = str_replace('<br />', ' ', $CCTP->convertText($message['MESSAGE']));
if (count($message['FILES']) > 0 && strlen($message['MESSAGE']) < 200)
{
foreach ($message['FILES'] as $file)
{
$file = " [".GetMessage('IM_MESSAGE_FILE').": ".$file['name']."]";
if (strlen($message['MESSAGE'].$file) > 200)
break;
$message['MESSAGE'] .= $file;
}
$message['MESSAGE'] = trim($message['MESSAGE']);
}
$isChat = $chat && strlen($chat['TITLE']) > 0;
$arMessageFields = array(
"MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
"TO_USER_ID" => $message['AUTHOR_ID'],
"FROM_USER_ID" => $USER->GetId(),
"NOTIFY_TYPE" => IM_NOTIFY_FROM,
"NOTIFY_MODULE" => "main",
"NOTIFY_EVENT" => "rating_vote",
"NOTIFY_TAG" => "RATING|IM|".($isChat? 'G':'P')."|".($isChat? $chat['ID']: $USER->GetId())."|".$id,
"NOTIFY_MESSAGE" => GetMessage($isChat? 'IM_MESSAGE_LIKE': 'IM_MESSAGE_LIKE_PRIVATE', Array(
'#MESSAGE#' => $message['MESSAGE'],
'#TITLE#' => $chat['TITLE']
))
);
CIMNotify::Add($arMessageFields);
}
//.........这里部分代码省略.........