当前位置: 首页>>代码示例>>PHP>>正文


PHP CTextParser::convertText方法代码示例

本文整理汇总了PHP中CTextParser::convertText方法的典型用法代码示例。如果您正苦于以下问题:PHP CTextParser::convertText方法的具体用法?PHP CTextParser::convertText怎么用?PHP CTextParser::convertText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTextParser的用法示例。


在下文中一共展示了CTextParser::convertText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addSignature

 public static function addSignature(&$message, $contentType = 0)
 {
     if (!Bitrix24Manager::isEnabled()) {
         return false;
     }
     self::includeLangFile();
     $text = '';
     if (!Bitrix24Manager::isPaidAccount()) {
         $text = GetMessage('CRM_B24_EMAIL_FREE_LICENSE_SIGNATURE');
     } elseif (self::isSignatureEnabled()) {
         $text = GetMessage('CRM_B24_EMAIL_PAID_LICENSE_SIGNATURE');
     }
     if ($text === '') {
         return false;
     }
     if (!\CCrmContentType::IsDefined($contentType)) {
         $contentType = \CCrmContentType::PlainText;
     }
     if ($contentType === \CCrmContentType::BBCode) {
         $message .= "\n\n" . $text;
     } elseif ($contentType === \CCrmContentType::Html) {
         //Convert BBCODE to HTML
         $parser = new \CTextParser();
         $message .= "<br/><br/>" . $parser->convertText($text);
     } elseif ($contentType === \CCrmContentType::PlainText) {
         $message .= "\n\n" . preg_replace('/\\[[^\\]]+\\]/', '', $text);
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:29,代码来源:bitrix24email.php

示例2: 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));
         }
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:57,代码来源:messageparamhandler.php

示例3: convertHtmlToBbCode

 public static function convertHtmlToBbCode($html)
 {
     $html = strval($html);
     if ($html === '') {
         return '';
     }
     $eventManager = \Bitrix\Main\EventManager::getInstance();
     $eventKey = $eventManager->addEventHandlerCompatible("main", "TextParserBeforeTags", array("\\Bitrix\\Crm\\Format\\TextHelper", "onTextParserBeforeTags"));
     $textParser = new \CTextParser();
     $textParser->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "Y", "ALIGN" => "Y");
     $result = $textParser->convertText($html);
     $result = htmlspecialcharsback($result);
     $result = preg_replace("/\\<br\\s*\\/*\\>/is" . BX_UTF_PCRE_MODIFIER, "\n", $result);
     $result = preg_replace("/&nbsp;/is" . BX_UTF_PCRE_MODIFIER, "", $result);
     $result = preg_replace("/\\<([^>]*?)>/is" . BX_UTF_PCRE_MODIFIER, "", $result);
     $result = htmlspecialcharsbx($result);
     $eventManager->removeEventHandler("main", "TextParserBeforeTags", $eventKey);
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:19,代码来源:texthelper.php

示例4: GetRecentList

	public static function GetRecentList($arParams = Array())
	{
		global $DB, $USER;

		$bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y'? true: false;
		$bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N'? false: true;
		$bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N'? false: true;

		$nameTemplate = COption::GetOptionString("im", "user_name_template", "#LAST_NAME# #NAME#", SITE_ID);
		$nameTemplateSite = CSite::GetNameFormat(false);
		$nameOfSite = CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()? "ex": false;
		$bIntranetEnable = IsModuleInstalled('intranet') && CModule::IncludeModule('intranet')? true: false;

		$arRecent = Array();
		$arUsers = Array();

		$cache_ttl = 2592000;
		$cache_id = $GLOBALS['USER']->GetID();
		$cache_dir = '/bx/imc/rec'.CIMMessenger::GetCachePath($cache_id);
		$obCache = new CPHPCache();
		if($obCache->InitCache($cache_ttl, $cache_id, $cache_dir))
		{
			$ar = $obCache->GetVars();
			$arRecent = $ar['recent'];
			$arUsers = $ar['users'];
		}
		else
		{
			if (!$bTimeZone)
				CTimeZone::Disable();
			$strSql = "
				SELECT
					R.ITEM_TYPE, R.ITEM_ID,
					R.ITEM_MID M_ID, M.AUTHOR_ID M_AUTHOR_ID, M.MESSAGE M_MESSAGE, ".$DB->DatetimeToTimestampFunction('M.DATE_CREATE')." M_DATE_CREATE,
					C.TITLE C_TITLE, C.AUTHOR_ID C_OWNER_ID,
					U.LOGIN, U.NAME, U.LAST_NAME, U.PERSONAL_PHOTO, U.SECOND_NAME, U.PERSONAL_BIRTHDAY, U.PERSONAL_GENDER
				FROM
				b_im_recent R
				LEFT JOIN b_user U ON R.ITEM_TYPE = '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = U.ID
				LEFT JOIN b_im_chat C ON R.ITEM_TYPE = '".IM_MESSAGE_GROUP."' AND R.ITEM_ID = C.ID
				LEFT JOIN b_im_message M ON R.ITEM_MID = M.ID
				WHERE R.USER_ID = ".$USER->GetId();
			if (!$bTimeZone)
				CTimeZone::Enable();

			$toDelete = Array();
			$CCTP = new CTextParser();
			$CCTP->MaxStringLen = 255;
			$CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => ($bSmiles? "Y": "N"), "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			while ($arRes = $dbRes->GetNext(true, false))
			{
				$arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
				if ($arRes['M_DATE_CREATE']+2592000 < time())
				{
					$toDelete[$arRes['ITEM_TYPE']][] = $arRes['ITEM_ID'];
					continue;
				}

				$itemId = $arRes['ITEM_ID'];
				$item = Array(
					'TYPE' => $arRes['ITEM_TYPE'],
					'MESSAGE' => Array(
						'id' => $arRes['M_ID'],
						'senderId' => $arRes['M_AUTHOR_ID'],
						'date' => $arRes['M_DATE_CREATE'],
						'text' => $CCTP->convertText(preg_replace("/\[s\].*?\[\/s\]/i", "", $arRes['M_MESSAGE']))
					)
				);
				$item['MESSAGE']['text'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" "," ", " ", " "), $item['MESSAGE']['text']), "<img>"));
				if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE)
				{
					$arUsers[] = $arRes['ITEM_ID'];
					$arFileTmp = CFile::ResizeImageGet(
						$arRes["PERSONAL_PHOTO"],
						array('width' => 58, 'height' => 58),
						BX_RESIZE_IMAGE_EXACT,
						false
					);

					$item['USER'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => CUser::FormatName($nameTemplateSite, $arRes, true, false),
						'nameList' => CUser::FormatName($nameTemplate, $arRes, true, false),
						'avatar' => empty($arFileTmp['src'])? '/bitrix/js/im/images/blank.gif': $arFileTmp['src'],
						'gender' => $arRes['PERSONAL_GENDER'] == 'F'? 'F': 'M',
						'status' => 'offline',
						'birthday' => $arRes['PERSONAL_BIRTHDAY'],
						'profile' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('im', 'path_to_user_profile', "", $nameOfSite), array("user_id" => $arRes["ITEM_ID"]))
					);
				}
				else
				{
					$itemId = 'chat'.$itemId;
					$item['CHAT'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => $arRes["C_TITLE"],
						'owner' => $arRes["C_OWNER_ID"],
					);
				}
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:im_contact_list.php

示例5: 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);
		}

//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:101,代码来源:im_messenger.php

示例6: CTextParser

    $arGadget["FORCE_REDIRECT"] = true;
}
$arData = $arGadget["USERDATA"];
$content = $arData["content"];
?>

<?php 
if (!$bEdit) {
    ?>

<?php 
    if ($content) {
        $parser = new CTextParser();
        $parser->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "Y", "CUT_ANCHOR" => "N", "ALIGN" => "Y");
        $parser->parser_nofollow = "Y";
        echo $parser->convertText($content);
    } else {
        if ($arParams["PERMISSION"] > "R") {
            echo GetMessage("GD_HTML_AREA_NO_CONTENT");
        }
    }
    ?>

<?php 
    if ($arParams["PERMISSION"] > "R") {
        ?>
<div class="gdhtmlareach" style="padding-top: 10px;"><a class="gdhtmlareachlink" href="<?php 
        echo $GLOBALS["APPLICATION"]->GetCurPageParam("gdhtml=" . $id . "&edit=true", array("gdhtml", "edit"));
        ?>
"><?php 
        echo GetMessage("GD_HTML_AREA_CHANGE_LINK");
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:index.php

示例7: GetMoreChatMessage

 function GetMoreChatMessage($pageId, $chatId, $bTimeZone = true)
 {
     global $DB;
     $iNumPage = 1;
     if (intval($pageId) > 0) {
         $iNumPage = intval($pageId);
     }
     $chatId = IntVal($chatId);
     $limitById = '';
     $ar = \CIMChat::GetRelationById($chatId, $this->user_id);
     if ($ar && $ar['START_ID'] > 0) {
         $limitById = 'AND M.ID >= ' . intval($ar['START_ID']);
     }
     $strSql = "\n\t\t\tSELECT COUNT(M.ID) as CNT\n\t\t\tFROM b_im_message M\n\t\t\tINNER JOIN b_im_relation R1 ON M.CHAT_ID = R1.CHAT_ID\n\t\t\tWHERE R1.CHAT_ID = " . $chatId . " AND R1.USER_ID = " . $this->user_id . " " . $limitById . "\n\t\t";
     $res_cnt = $DB->Query($strSql);
     $res_cnt = $res_cnt->Fetch();
     $cnt = $res_cnt["CNT"];
     $arMessages = array();
     $arMessageFiles = array();
     $arMessageId = array();
     $usersMessage = array();
     if ($cnt > 0 && ceil($cnt / 20) >= $iNumPage) {
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tM.ID,\n\t\t\t\t\tM.CHAT_ID,\n\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\t" . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\t\tM.AUTHOR_ID\n\t\t\t\tFROM b_im_message M\n\t\t\t\tINNER JOIN b_im_relation R1 ON M.CHAT_ID = R1.CHAT_ID\n\t\t\t\tWHERE R1.CHAT_ID = " . $chatId . " AND R1.USER_ID = " . $this->user_id . " " . $limitById . "\n\t\t\t\tORDER BY M.DATE_CREATE DESC, M.ID DESC\n\t\t\t";
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $dbRes = new CDBResult();
         $dbRes->NavQuery($strSql, $cnt, array('iNumPage' => $iNumPage, 'nPageSize' => 20));
         $CCTP = new CTextParser();
         $CCTP->MaxStringLen = 200;
         $CCTP->allow = array("HTML" => "N", "ANCHOR" => $this->bHideLink ? "N" : "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => $this->bHideLink ? "N" : "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
         while ($arRes = $dbRes->Fetch()) {
             $arMessages[$arRes['ID']] = array('id' => $arRes['ID'], 'chatId' => $arRes['CHAT_ID'], 'senderId' => $arRes['AUTHOR_ID'], 'recipientId' => $arRes['CHAT_ID'], 'date' => $arRes['DATE_CREATE'], 'system' => $arRes['AUTHOR_ID'] > 0 ? 'N' : 'Y', 'text' => $CCTP->convertText(htmlspecialcharsbx($arRes['MESSAGE'])));
             $usersMessage[$arRes['CHAT_ID']][] = $arRes['ID'];
             $arMessageId[] = $arRes['ID'];
         }
         $params = CIMMessageParam::Get($arMessageId);
         $arFiles = array();
         foreach ($params as $messageId => $param) {
             $arMessages[$messageId]['params'] = $param;
             if (isset($param['FILE_ID'])) {
                 foreach ($param['FILE_ID'] as $fileId) {
                     $arFiles[$fileId] = $fileId;
                 }
             }
         }
         $arMessageFiles = CIMDisk::GetFiles($chatId, $arFiles);
     }
     return array('chatId' => $chatId, 'message' => $arMessages, 'usersMessage' => $usersMessage, 'files' => $arMessageFiles);
 }
开发者ID:Satariall,项目名称:izurit,代码行数:53,代码来源:im_history.php

示例8: array

         $ar = array("FROM_USER_ID" => intval($USER->GetID()), "TO_USER_ID" => intval($_POST['RECIPIENT_ID']), "MESSAGE" => $_POST['MESSAGE']);
     }
     $errorMessage = "";
     if (!($insertID = CIMMessage::Add($ar))) {
         if ($e = $GLOBALS["APPLICATION"]->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) == 0) {
             $errorMessage = GetMessage('UNKNOWN_ERROR');
         }
     }
     $CCTP = new CTextParser();
     $CCTP->MaxStringLen = 200;
     $CCTP->allow = array("HTML" => "N", "ANCHOR" => isset($_POST['MOBILE']) ? "N" : "Y", "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");
     $userTzOffset = isset($_POST['USER_TZ_OFFSET']) ? intval($_POST['USER_TZ_OFFSET']) : CTimeZone::GetOffset();
     $arResult = array('TMP_ID' => $tmpID, 'ID' => $insertID, 'SEND_DATE' => time() + $userTzOffset, 'SEND_MESSAGE' => $CCTP->convertText(htmlspecialcharsbx($ar['MESSAGE'])), 'SENDER_ID' => intval($USER->GetID()), 'RECIPIENT_ID' => $_POST['CHAT'] == 'Y' ? htmlspecialcharsbx($_POST['RECIPIENT_ID']) : intval($_POST['RECIPIENT_ID']), 'ERROR' => $errorMessage);
     if (isset($_POST['MOBILE'])) {
         $arFormat = array("today" => "today, " . GetMessage('IM_MESSAGE_FORMAT_TIME'), "" => GetMessage('IM_MESSAGE_FORMAT_DATE'));
         $arResult['SEND_DATE_FORMAT'] = FormatDate($arFormat, time() + $userTzOffset);
     }
     echo CUtil::PhpToJsObject($arResult);
     CIMContactList::SetOnline(null, true);
     CIMMessenger::SetCurrentTab(intval($_POST['TAB']));
 } else {
     if ($_POST['IM_READ_MESSAGE'] == 'Y') {
         $errorMessage = "";
         if (substr($_POST['USER_ID'], 0, 4) == 'chat') {
             $CIMChat = new CIMChat();
             $CIMChat->SetReadMessage(intval(substr($_POST['USER_ID'], 4)), isset($_POST['LAST_ID']) && intval($_POST['LAST_ID']) > 0 ? $_POST['LAST_ID'] : null);
         } else {
             $CIMMessage = new CIMMessage();
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:im.ajax.php

示例9: afterUpdateTrigger

 /**
  * Method will be invoked after an database record updated.
  *
  * @param array $oldRecord All fields before update.
  * @param array $newRecord All fields after update.
  *
  * @return void
  */
 public function afterUpdateTrigger(array $oldRecord, array $newRecord)
 {
     if (!\Bitrix\Main\Loader::includeModule('pull')) {
         return;
     }
     $arFields = \CIMMessenger::GetById($newRecord['ID'], array('WITH_FILES' => 'Y'));
     if (!$arFields) {
         return;
     }
     $arFields['DATE_MODIFY'] = time() + \CTimeZone::GetOffset();
     $CCTP = new \CTextParser();
     $CCTP->MaxStringLen = 200;
     $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
     $pullMessage = $CCTP->convertText(htmlspecialcharsbx($arFields['MESSAGE']));
     $relations = \CIMChat::GetRelationById($arFields['CHAT_ID']);
     $arPullMessage = array('id' => $arFields['ID'], 'type' => $arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE ? 'private' : 'chat', 'text' => $pullMessage, 'date' => $arFields['DATE_MODIFY']);
     if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) {
         $arFields['FROM_USER_ID'] = $arFields['AUTHOR_ID'];
         foreach ($relations as $rel) {
             if ($rel['USER_ID'] != $arFields['AUTHOR_ID']) {
                 $arFields['TO_USER_ID'] = $rel['USER_ID'];
             }
         }
         $arPullMessage['fromUserId'] = $arFields['FROM_USER_ID'];
         $arPullMessage['toUserId'] = $arFields['TO_USER_ID'];
     } else {
         $arPullMessage['chatId'] = $arFields['CHAT_ID'];
         $arPullMessage['senderId'] = $arFields['AUTHOR_ID'];
     }
     \CPullStack::AddByUsers(array_keys($relations), $p = array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     foreach ($relations as $rel) {
         $obCache = new \CPHPCache();
         $obCache->CleanDir('/bx/imc/recent' . \CIMMessenger::GetCachePath($rel['USER_ID']));
     }
     if ($newRecord['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) {
         \CPullWatch::AddToStack('IM_PUBLIC_' . $arFields['CHAT_ID'], array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     }
     foreach (\GetModuleEvents("im", "OnAfterMessagesUpdate", true) as $arEvent) {
         \ExecuteModuleEventEx($arEvent, array(intval($newRecord['ID']), $arFields));
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:49,代码来源:messagehandler.php

示例10: FormatDate

         $arResult['SEND_DATE_FORMAT'] = FormatDate($arFormat, time() + $userTzOffset);
     }
     echo CUtil::PhpToJsObject($arResult);
     CIMContactList::SetOnline();
     CIMMessenger::SetCurrentTab($_POST['TAB']);
 } else {
     if ($_POST['IM_EDIT_MESSAGE'] == 'Y') {
         CUtil::decodeURIComponent($_POST);
         if (!CIMMessenger::Update($_POST['ID'], $_POST['MESSAGE'])) {
             $arResult = array('ERROR' => 'CANT_EDIT_MESSAGE');
         } else {
             $CCTP = new CTextParser();
             $CCTP->MaxStringLen = 200;
             $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
             $userTzOffset = isset($_POST['USER_TZ_OFFSET']) ? intval($_POST['USER_TZ_OFFSET']) : CTimeZone::GetOffset();
             $arResult = array('ID' => $insertID, 'MESSAGE' => $CCTP->convertText(htmlspecialcharsbx($_POST['MESSAGE'])), 'DATE' => time() + $userTzOffset, 'ERROR' => '');
         }
         echo CUtil::PhpToJsObject($arResult);
     } else {
         if ($_POST['IM_DELETE_MESSAGE'] == 'Y') {
             $errorMessage = '';
             if (!CIMMessenger::Delete($_POST['ID'])) {
                 $errorMessage = 'CANT_EDIT_MESSAGE';
             }
             $arResult = array('ERROR' => $errorMessage);
             echo CUtil::PhpToJsObject($arResult);
         } else {
             if ($_POST['IM_LIKE_MESSAGE'] == 'Y') {
                 $errorMessage = '';
                 $result = CIMMessenger::Like($_POST['ID'], $_POST['ACTION']);
                 if ($result === false) {
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:im.ajax.php

示例11: GetUnreadMessage

 public function GetUnreadMessage($arParams = array())
 {
     global $DB;
     $bSpeedCheck = isset($arParams['SPEED_CHECK']) && $arParams['SPEED_CHECK'] == 'N' ? false : true;
     $lastId = !isset($arParams['LAST_ID']) || $arParams['LAST_ID'] == null ? null : IntVal($arParams['LAST_ID']);
     $order = isset($arParams['ORDER']) && $arParams['ORDER'] == 'ASC' ? 'ASC' : 'DESC';
     $loadDepartment = isset($arParams['LOAD_DEPARTMENT']) && $arParams['LOAD_DEPARTMENT'] == 'N' ? false : true;
     $bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N' ? false : true;
     $bGroupByChat = isset($arParams['GROUP_BY_CHAT']) && $arParams['GROUP_BY_CHAT'] == 'Y' ? true : false;
     $bUserLoad = isset($arParams['USER_LOAD']) && $arParams['USER_LOAD'] == 'N' ? false : true;
     $arExistUserData = isset($arParams['EXIST_USER_DATA']) && is_array($arParams['EXIST_USER_DATA']) ? $arParams['EXIST_USER_DATA'] : array();
     $arMessages = array();
     $arUnreadMessage = array();
     $arUsersMessage = array();
     $arResult = array('message' => array(), 'unreadMessage' => array(), 'usersMessage' => array(), 'users' => array(), 'userInGroup' => array(), 'woUserInGroup' => array(), 'countMessage' => 0, 'chat' => array(), 'userInChat' => array(), 'result' => false);
     $bLoadMessage = $bSpeedCheck ? CIMMessenger::SpeedFileExists($this->user_id, IM_SPEED_GROUP) : false;
     $count = CIMMessenger::SpeedFileGet($this->user_id, IM_SPEED_GROUP);
     if (!$bLoadMessage || $bLoadMessage && $count > 0) {
         $ssqlLastId = "R1.LAST_ID";
         $ssqlStatus = " AND R1.STATUS < " . IM_STATUS_READ;
         if (!is_null($lastId) && intval($lastId) > 0 && !CIMMessenger::CheckXmppStatusOnline()) {
             $ssqlLastId = intval($lastId);
             $ssqlStatus = "";
         }
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tM.ID,\n\t\t\t\t\tM.CHAT_ID,\n\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\t" . $DB->DateToCharFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\t\tM.AUTHOR_ID,\n\t\t\t\t\tR1.STATUS R1_STATUS\n\t\t\t\tFROM b_im_message M\n\t\t\t\tINNER JOIN b_im_relation R1 ON M.ID > " . $ssqlLastId . " AND M.CHAT_ID = R1.CHAT_ID AND R1.USER_ID != M.AUTHOR_ID\n\t\t\t\tWHERE R1.USER_ID = " . $this->user_id . " AND R1.MESSAGE_TYPE = '" . IM_MESSAGE_GROUP . "' " . $ssqlStatus . "\n\t\t\t\tORDER BY ID " . ($order == "DESC" ? "DESC" : "ASC") . "\n\t\t\t";
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $arLastMessage = array();
         $arMark = array();
         $arChat = array();
         $CCTP = new CTextParser();
         $CCTP->MaxStringLen = 200;
         $CCTP->allow = array("HTML" => "N", "ANCHOR" => $this->bHideLink ? "N" : "Y", "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");
         if (!$this->bHideLink) {
             $CCTPM = new CTextParser();
             $CCTPM->MaxStringLen = 200;
             $CCTPM->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");
         }
         while ($arRes = $dbRes->Fetch()) {
             $arUsers[] = $arRes['AUTHOR_ID'];
             $arMessages[$arRes['ID']] = array('id' => $arRes['ID'], 'senderId' => $arRes['AUTHOR_ID'], 'recipientId' => $arRes['CHAT_ID'], 'date' => MakeTimeStamp($arRes['DATE_CREATE']), 'text' => $arRes['MESSAGE']);
             if ($bGroupByChat) {
                 $arMessages[$arRes['ID']]['conversation'] = $arRes['CHAT_ID'];
                 $arMessages[$arRes['ID']]['unread'] = $this->user_id != $arRes['AUTHOR_ID'] ? 'Y' : 'N';
             } else {
                 $arUsersMessage[$arRes['CHAT_ID']][] = $arRes['ID'];
                 if ($this->user_id != $arRes['AUTHOR_ID']) {
                     $arUnreadMessage[$arRes['CHAT_ID']][] = $arRes['ID'];
                 }
             }
             if ($arRes['R1_STATUS'] == IM_STATUS_UNREAD && (!isset($arMark[$arRes["CHAT_ID"]]) || $arMark[$arRes["CHAT_ID"]] < $arRes["ID"])) {
                 $arMark[$arRes["CHAT_ID"]] = $arRes["ID"];
             }
             if (!isset($arLastMessage[$arRes["CHAT_ID"]]) || $arLastMessage[$arRes["CHAT_ID"]] < $arRes["ID"]) {
                 $arLastMessage[$arRes["CHAT_ID"]] = $arRes["ID"];
             }
             $arChat[$arRes["CHAT_ID"]] = $arRes["CHAT_ID"];
         }
         if ($bGroupByChat) {
             foreach ($arMessages as $key => $value) {
                 $arMessages[$arLastMessage[$value['conversation']]]['counter']++;
                 if ($arLastMessage[$value['conversation']] != $value['id']) {
                     unset($arMessages[$key]);
                 } else {
                     $arMessages[$key]['text'] = $CCTP->convertText(htmlspecialcharsbx($value['text']));
                     if ($this->bHideLink) {
                         $arMessages[$key]['text_mobile'] = $arMessages[$key]['text'];
                     } else {
                         $arMessages[$key]['text_mobile'] = $CCTPM->convertText(htmlspecialcharsbx($value['text']));
                     }
                     $arUsersMessage[$value['conversation']][] = $value['id'];
                     if ($value['unread'] == 'Y') {
                         $arUnreadMessage[$value['conversation']][] = $value['id'];
                     }
                     unset($arMessages[$key]['conversation']);
                     unset($arMessages[$key]['unread']);
                 }
             }
         } else {
             foreach ($arMessages as $key => $value) {
                 $arMessages[$key]['text'] = $CCTP->convertText(htmlspecialcharsbx($value['text']));
                 if ($this->bHideLink) {
                     $arMessages[$key]['text_mobile'] = $arMessages[$key]['text'];
                 } else {
                     $arMessages[$key]['text_mobile'] = $CCTPM->convertText(htmlspecialcharsbx($value['text']));
                 }
             }
         }
         foreach ($arMark as $chatId => $lastSendId) {
             CIMMessage::SetLastSendId($chatId, $this->user_id, $lastSendId);
         }
         $arResult['message'] = $arMessages;
         $arResult['unreadMessage'] = $arUnreadMessage;
         $arResult['usersMessage'] = $arUsersMessage;
         $arChat = self::GetChatData(array('ID' => $arChat, 'USE_CACHE' => 'N'));
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:im_chat.php

示例12: GetMessage

                break;
            default:
                $task['META::STATUS_FORMATTED_NAME'] = $task['REAL_STATUS'];
                break;
        }
        $task['META::STATUS_FORMATTED_NAME'] .= ' ' . GetMessage('MB_TASKS_TASKS_LIST_STATUS_DATE_PREPOSITION') . ' ' . CTasksTools::FormatDatetimeBeauty($task['STATUS_CHANGED_DATE'], array(), $arParams['DATE_TIME_FORMAT']);
        $task['META:DEADLINE_FORMATTED'] = '';
        if (MakeTimeStamp($task['DEADLINE']) > 86400) {
            $task['META:DEADLINE_FORMATTED'] = CTasksTools::FormatDatetimeBeauty($task['DEADLINE'], array(), $arParams['DATE_TIME_FORMAT']);
        }
        // HTML-format must be supported in future, because old tasks' data not converted from HTML to BB
        if ($task['DESCRIPTION_IN_BBCODE'] === 'N') {
            // HTML detected, sanitize if need
            $task['DESCRIPTION'] = CTasksTools::SanitizeHtmlDescriptionIfNeed($task['DESCRIPTION']);
        } else {
            $task['DESCRIPTION'] = $parser->convertText($task['DESCRIPTION']);
        }
        // files list will be fetched below
        $task['FILES'] = array();
    }
    $arResult['TASKS'][$task['ID']] = $task;
}
$arResult['TASKS_IDS_AS_INTEGERS'] = $arTasksIDs;
$arTaskOriginatorsAndResponsibles = array_unique($arTaskOriginatorsAndResponsibles);
// Get photos for originators and responsibles
$rsUser = CUser::GetList($passByReference1 = 'id', $passByReference2 = 'asc', $passByReference3 = array('ID' => implode('|', $arTaskOriginatorsAndResponsibles)));
$arUsersPhotos = array();
while ($arUser = $rsUser->Fetch()) {
    $arUsersPhotos[$arUser['ID']] = false;
    if (intval($arUser['PERSONAL_PHOTO']) > 0) {
        $imageFile = CFile::GetFileArray($arUser['PERSONAL_PHOTO']);
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例13: elseif

     die;
 } elseif (!empty($arErrors)) {
     echo CUtil::PhpToJSObject(array('ERROR' => $arErrors));
     die;
 }
 $subject = isset($data['subject']) ? strval($data['subject']) : '';
 $message = isset($data['message']) ? strval($data['message']) : '';
 if ($message !== '') {
     CCrmActivity::AddEmailSignature($message, CCrmContentType::BBCode);
 }
 if ($message === '') {
     $messageHtml = '';
 } else {
     //Convert BBCODE to HTML
     $parser = new CTextParser();
     $messageHtml = $parser->convertText($message);
 }
 $now = ConvertTimeStamp(time() + CTimeZone::GetOffset(), 'FULL', $siteID);
 if ($subject === '') {
     $subject = GetMessage('CRM_EMAIL_ACTION_DEFAULT_SUBJECT', array('#DATE#' => $now));
 }
 $description = $message;
 $descriptionHtml = $messageHtml;
 //$description = preg_replace('/<br\s*[^>]*>/i', PHP_EOL, $message);
 //$description = preg_replace('/<(?:\/)?[a-z0-9]+[^>]*>/i', '', $description);
 $arFields = array('OWNER_ID' => $ownerID, 'OWNER_TYPE_ID' => CCrmOwnerType::ResolveID($ownerTypeName), 'TYPE_ID' => CCrmActivityType::Email, 'SUBJECT' => $subject, 'START_TIME' => $now, 'END_TIME' => $now, 'COMPLETED' => 'Y', 'RESPONSIBLE_ID' => $userID, 'PRIORITY' => CCrmActivityPriority::Medium, 'DESCRIPTION' => $description, 'DESCRIPTION_TYPE' => CCrmContentType::BBCode, 'DIRECTION' => CCrmActivityDirection::Outgoing, 'LOCATION' => '', 'NOTIFY_TYPE' => CCrmActivityNotifyType::None, 'BINDINGS' => array_values($arBindings));
 if (count($arFields['BINDINGS']) === 1) {
     // In single bindind mode override owner data
     $arBinding = $arFields['BINDINGS'][0];
     $arFields['OWNER_TYPE_ID'] = $arBinding['OWNER_TYPE_ID'];
     $arFields['OWNER_ID'] = $arBinding['OWNER_ID'];
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:ajax.php

示例14: SendUpdateMessage


//.........这里部分代码省略.........
                         }
                         break;
                     case "PARENT_ID":
                         if ($value["FROM_VALUE"]) {
                             $rsTaskFrom = CTasks::GetList(array(), array("ID" => $value["FROM_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskFrom = $rsTaskFrom->GetNext()) {
                                 $tmpStr .= $arTaskFrom["TITLE"] . " -> ";
                             }
                         }
                         if ($value["TO_VALUE"]) {
                             $rsTaskTo = CTasks::GetList(array(), array("ID" => $value["TO_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskTo = $rsTaskTo->GetNext()) {
                                 $tmpStr .= $arTaskTo["TITLE"];
                             }
                         } else {
                             $tmpStr .= GetMessage("TASKS_MESSAGE_NO_VALUE");
                         }
                         break;
                     case "DEPENDS_ON":
                         $arTasksFromStr = array();
                         if ($value["FROM_VALUE"]) {
                             $rsTasksFrom = CTasks::GetList(array(), array("ID" => explode(",", $value["FROM_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskFrom = $rsTasksFrom->GetNext()) {
                                 $arTasksFromStr[] = $arTaskFrom["TITLE"];
                             }
                         }
                         $arTasksToStr = array();
                         if ($value["TO_VALUE"]) {
                             $rsTasksTo = CTasks::GetList(array(), array("ID" => explode(",", $value["TO_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskTo = $rsTasksTo->GetNext()) {
                                 $arTasksToStr[] = $arTaskTo["TITLE"];
                             }
                         }
                         $tmpStr .= ($arTasksFromStr ? implode(", ", $arTasksFromStr) . " -> " : "") . ($arTasksToStr ? implode(", ", $arTasksToStr) : GetMessage("TASKS_MESSAGE_NO_VALUE"));
                         break;
                     case "MARK":
                         $tmpStr .= (!$value["FROM_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["FROM_VALUE"])) . " -> " . (!$value["TO_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["TO_VALUE"]));
                         break;
                     case "ADD_IN_REPORT":
                         $tmpStr .= ($value["FROM_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO")) . " -> " . ($value["TO_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO"));
                         break;
                     case "DELETED_FILES":
                         $tmpStr .= $value["FROM_VALUE"];
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                     case "NEW_FILES":
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                 }
                 if ((string) $tmpStr != '') {
                     $changeMessage .= ": [COLOR=#000]" . $tmpStr . "[/COLOR]";
                 }
                 $arInvariantChangesStrs[] = $changeMessage;
             }
         }
         $recp2tz = array();
         foreach ($arRecipientsIDsByTimezone as $tz => $rcp) {
             foreach ($rcp as $uid) {
                 $recp2tz[$uid] = $tz;
             }
         }
         $invariantDescription = null;
         if (!empty($arInvariantChangesStrs)) {
             $invariantDescription = implode("\r\n", $arInvariantChangesStrs);
         }
         if ($invariantDescription !== null && !empty($arRecipientsIDs)) {
             // If there is no volatile part of descriptions, send to all recipients at once
             if (empty($arVolatileDescriptions)) {
                 $arVolatileDescriptions['some_timezone'] = array();
                 $arRecipientsIDsByTimezone['some_timezone'] = $arRecipientsIDs;
             }
             $updateMessage = self::getGenderMessage($occurAsUserId, 'TASKS_TASK_CHANGED_MESSAGE');
             $taskName = self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID'], false);
             $instant = str_replace(array("#TASK_TITLE#"), array($taskName), $updateMessage);
             $email = str_replace(array("#TASK_TITLE#"), array(strip_tags($taskName)), $updateMessage);
             //_dump_r('Sending UPDATE from '.$occurAsUserId.' TO '.implode(':', $arRecipientsIDs));
             CTaskNotifications::sendMessageEx($arTask["ID"], $occurAsUserId, $arRecipientsIDs, array('INSTANT' => $instant, 'EMAIL' => $email, 'PUSH' => self::makePushMessage('TASKS_TASK_CHANGED_MESSAGE', $occurAsUserId, $arTask)), array('EVENT_DATA' => array('ACTION' => 'TASK_UPDATE', 'arFields' => $arFields, 'arChanges' => $arChanges), 'TASK_ASSIGNED_TO' => $taskReassignedTo, 'CALLBACK' => array('BEFORE_SEND' => function ($message) use($isBbCodeDescription, $invariantDescription, $arVolatileDescriptions, $recp2tz) {
                 $rcp = $message['TO_USER_IDS'][0];
                 $volatile = $arVolatileDescriptions[$recp2tz[$rcp]];
                 if (is_array($volatile)) {
                     $description = str_replace(array_keys($volatile), $volatile, $invariantDescription);
                 } else {
                     $description = $invariantDescription;
                 }
                 $message['MESSAGE']['INSTANT'] = str_replace(array("#TASK_EXTRA#"), array($description), $message['MESSAGE']['INSTANT']);
                 if ($isBbCodeDescription) {
                     $parser = new CTextParser();
                     $description = str_replace("\t", ' &nbsp; &nbsp;', $parser->convertText($description));
                 }
                 $message['MESSAGE']['EMAIL'] = str_replace(array("#TASK_EXTRA#"), array($description), $message['MESSAGE']['EMAIL']);
                 return $message;
             })));
         }
     }
     // sonet log
     self::SendMessageToSocNet($arFields, $bSpawnedByAgent, $arChanges, $arTask, $parameters);
     if ($cacheWasEnabled) {
         self::disableStaticCache();
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:tasknotifications.php

示例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']));
         $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('#\\-{54}.+?\\-{54}#s', " [" . 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" => $USER->GetId(), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "im", "NOTIFY_EVENT" => "like", "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#' => $isChat ? '[CHAT=' . $chat['ID'] . ']' . $chat['TITLE'] . '[/CHAT]' : $chat['TITLE'])), "NOTIFY_MESSAGE_OUT" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $chat['TITLE'])));
         CIMNotify::Add($arMessageFields);
     }
     $arPullMessage = array('id' => $id, 'chatId' => $chat['ID'], 'senderId' => $USER->GetId(), 'users' => $like);
     foreach ($relations as $rel) {
         CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage));
     }
     if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
         CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage));
     }
     return $like;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:78,代码来源:im_messenger.php


注:本文中的CTextParser::convertText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。