本文整理汇总了PHP中CSocNetLog::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetLog::Add方法的具体用法?PHP CSocNetLog::Add怎么用?PHP CSocNetLog::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetLog
的用法示例。
在下文中一共展示了CSocNetLog::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
public function Execute()
{
if (!CModule::IncludeModule("socialnetwork")) {
CBPActivityExecutionStatus::Closed;
}
$rootActivity = $this->GetRootActivity();
$documentId = $rootActivity->GetDocumentId();
$documentService = $this->workflow->GetService("DocumentService");
$document = $documentService->GetDocument($documentId);
$entityType = $this->EntityType;
if ($entityType == "user") {
$entityType = SONET_ENTITY_USER;
} elseif ($entityType == "group") {
$entityType = SONET_ENTITY_GROUP;
}
$USER_ID = false;
if ($GLOBALS["USER"]->IsAuthorized()) {
$USER_ID = $GLOBALS["USER"]->GetID();
}
$logID = CSocNetLog::Add(array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $this->EntityId, "EVENT_ID" => $this->Event, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $this->LogTitle, "TITLE" => $document["NAME"], "MESSAGE" => nl2br($this->LogText), "TEXT_MESSAGE" => $this->LogText, "URL" => $documentService->GetDocumentAdminPage($documentId), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "USER_ID" => $USER_ID), false);
if (intval($logID > 0)) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
}
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
return CBPActivityExecutionStatus::Closed;
}
示例2: NewUserMessage
public static function NewUserMessage($USER_ID)
{
global $DB, $APPLICATION;
if (!CModule::IncludeModule('socialnetwork')) {
return false;
}
$USER_ID = intval($USER_ID);
if ($USER_ID <= 0) {
return false;
}
$arRights = self::GetRights($USER_ID);
if (!$arRights) {
return false;
}
$dbRes = CUser::GetByID($USER_ID);
if ($arUser = $dbRes->Fetch()) {
$arSoFields = array("ENTITY_TYPE" => SONET_INTRANET_NEW_USER_ENTITY, "EVENT_ID" => SONET_INTRANET_NEW_USER_EVENT_ID, "ENTITY_ID" => $USER_ID, "SOURCE_ID" => $USER_ID, "USER_ID" => $USER_ID, "=LOG_DATE" => $DB->CurrentTimeFunction(), "MODULE_ID" => "intranet", "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => GetMessage('I_NEW_USER_TITLE'), "MESSAGE" => '', "TEXT_MESSAGE" => '', "CALLBACK_FUNC" => false, "SITE_ID" => SITE_ID, "ENABLE_COMMENTS" => "Y", "RATING_TYPE_ID" => "INTRANET_NEW_USER", "RATING_ENTITY_ID" => $USER_ID);
// check that there wasn't message for this user
$dbRes = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => $arSoFields['ENTITY_TYPE'], 'ENTITY_ID' => $arSoFields['ENTITY_ID'], 'EVENT_ID' => $arSoFields['EVENT_ID'], 'SOURCE_ID' => $arSoFields['SOURCE_ID']));
if (!$dbRes->Fetch()) {
$logID = CSocNetLog::Add($arSoFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
CSocNetLogRights::Add($logID, $arRights);
}
}
if (intval($logID) > 0) {
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
}
}
}
示例3: SendMessage
public static function SendMessage($ENTRY_ID, $SEND_TYPE = false)
{
global $DB, $APPLICATION, $USER;
$ENTRY_ID = intval($ENTRY_ID);
if ($ENTRY_ID <= 0) {
return false;
}
$dbEntry = CTimeManEntry::GetList(array(), array("ID" => $ENTRY_ID), false, false, array("ID", "USER_ID", "DATE_START", "USER_GENDER", "INACTIVE_OR_ACTIVATED"));
if (CModule::IncludeModule("socialnetwork") && ($arEntry = $dbEntry->Fetch())) {
$arRights = self::GetRights($arEntry["USER_ID"]);
if (!$arRights) {
return false;
}
$date = strlen($arEntry["DATE_START"]) > 0 ? MakeTimeStamp($arEntry["DATE_START"], CSite::GetDateFormat("FULL", $site_id)) > time() + CTimeZone::GetOffset() ? $DB->CharToDateFunction($arEntry["DATE_START"], "FULL", $site_id) : $DB->CurrentTimeFunction() : $DB->CurrentTimeFunction();
$arSoFields = array("EVENT_ID" => "timeman_entry", "=LOG_DATE" => $date, "MODULE_ID" => "timeman", "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => GetMessage("TIMEMAN_NOTIFY_TITLE") . $date_text, "MESSAGE" => '', "TEXT_MESSAGE" => '', "CALLBACK_FUNC" => false, "SOURCE_ID" => $ENTRY_ID, "SITE_ID" => SITE_ID, "ENABLE_COMMENTS" => "Y", "PARAMS" => serialize(array("FORUM_ID" => COption::GetOptionInt("timeman", "report_forum_id", ""))));
$arSoFields["ENTITY_TYPE"] = SONET_TIMEMAN_ENTRY_ENTITY;
$arSoFields["ENTITY_ID"] = $arEntry["USER_ID"];
$arSoFields["USER_ID"] = $USER->GetID();
//$arEntry["USER_ID"];
$dbRes = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => $arSoFields['ENTITY_TYPE'], 'ENTITY_ID' => $arSoFields['ENTITY_ID'], 'EVENT_ID' => $arSoFields['EVENT_ID'], 'SOURCE_ID' => $arSoFields['SOURCE_ID']));
$arRes = $dbRes->Fetch();
$bSend = false;
if ($arRes) {
$logID = $arRes['ID'];
if ($SEND_TYPE != 'A') {
$arSoFields["=LOG_UPDATE"] = $date;
CSocNetLog::Update($logID, $arSoFields);
$bSend = true;
if (IsModuleInstalled("im")) {
$arEntry["LOG_ID"] = $logID;
$arEntry["DATE_TEXT"] = FormatDate("j F", MakeTimeStamp($arEntry["DATE_START"], CSite::GetDateFormat("FULL", SITE_ID)));
if ($SEND_TYPE == "U") {
self::NotifyImApprove($arEntry);
} else {
self::NotifyImNew($arEntry);
}
}
}
} else {
if ($SEND_TYPE != 'U') {
$logID = CSocNetLog::Add($arSoFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
CSocNetLogRights::Add($logID, $arRights);
if ($arEntry["INACTIVE_OR_ACTIVATED"] == "Y" && IsModuleInstalled("im")) {
$arEntry["LOG_ID"] = $logID;
$arEntry["DATE_TEXT"] = FormatDate("j F", MakeTimeStamp($arEntry["DATE_START"], CSite::GetDateFormat("FULL", SITE_ID)));
self::NotifyImNew($arEntry);
}
$bSend = true;
}
}
}
if ($bSend && intval($logID) > 0) {
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
}
return $logID;
}
}
示例4: AddMessage
private function AddMessage()
{
global $DB;
$arNotification = $this->Notify->getNotification();
$arNotify = Array(
"EVENT_ID" => "idea",
"=LOG_DATE" => $DB->CurrentTimeFunction(),
"URL" => $arNotification["PATH"],
"TITLE" => $arNotification["TITLE"],
"TITLE_24" => $arNotification["TITLE_24"],
"MESSAGE" => $arNotification["DETAIL_TEXT"],
"CALLBACK_FUNC" => false,
"SOURCE_ID" => $arNotification["ID"],
"SITE_ID" => SITE_ID,
"ENABLE_COMMENTS" => "Y",
"ENTITY_TYPE" => SONET_ENTITY_USER,
"ENTITY_ID" => $arNotification["AUTHOR_ID"],
"USER_ID" => $arNotification["AUTHOR_ID"],
"MODULE_ID" => 'idea',
);
//Use rating
if($arNotification["SHOW_RATING"] == "Y")
{
$arNotify["RATING_ENTITY_ID"] = $arNotification["ID"];
$arNotify["RATING_TYPE_ID"] = "BLOG_POST";
}
if($arNotification["ACTION"] == "ADD")
{
$LogID = CSocNetLog::Add($arNotify, false);
if (intval($LogID) > 0)
{
CSocNetLog::Update($LogID, array("TMP_ID" => $LogID));
CSocNetLogRights::Add($LogID, array("G2")); //G2 - everyone
}
}
elseif($arNotification["ACTION"] == "UPDATE")
{
$arLog = CSocNetLog::GetList(
array("ID" => "DESC"),
array("SOURCE_ID" => $arNotification["ID"]),
false,
false,
array("ID")
)->Fetch();
if($arLog)
{
$LogID = $arLog["ID"];
CSocNetLog::Update($LogID, $arNotify);
}
}
return $LogID>0;
}
示例5: array
$bSocNetLogRecordExists = false;
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "forum", "SOURCE_ID" => $arFirstMessage["ID"]), false, false, array("ID", "TMP_ID"));
if ($arRes = $dbRes->Fetch()) {
$log_id = $arRes["TMP_ID"];
$bSocNetLogRecordExists = true;
} else {
// get root message
$arFirstMessage = CForumMessage::GetByIDEx($arFirstMessage["ID"], array("GET_TOPIC_INFO" => "Y", "getFiles" => "Y"));
$arTopic = $arFirstMessage["TOPIC_INFO"];
$sFirstMessageText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arFirstMessage["POST_MESSAGE_FILTER"] : $arFirstMessage["POST_MESSAGE"];
$sFirstMessageURL = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("UID" => $arFirstMessage["AUTHOR_ID"], "FID" => $arFirstMessage["FORUM_ID"], "TID" => $arFirstMessage["TOPIC_ID"], "MID" => $arFirstMessage["ID"]));
$arFieldsForSocnet = array("ENTITY_TYPE" => $arParams["MODE"] == "GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, "ENTITY_ID" => $arParams["MODE"] == "GROUP" ? $arParams["SOCNET_GROUP_ID"] : $arParams["USER_ID"], "EVENT_ID" => "forum", "LOG_DATE" => $arFirstMessage["POST_DATE"], "LOG_UPDATE" => $arFirstMessage["POST_DATE"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $arFirstMessage["AUTHOR_NAME"], GetMessage("SONET_FORUM_LOG_TOPIC_TEMPLATE")), "TITLE" => $arTopic["TITLE"], "MESSAGE" => $sFirstMessageText, "TEXT_MESSAGE" => $parser->convert4mail($sFirstMessageText), "URL" => $sFirstMessageURL, "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("TID" => $arParams["TID"])))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arFirstMessage["ID"], "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => intval($arParams["TID"]));
if (intVal($arFirstMessage["AUTHOR_ID"]) > 0) {
$arFieldsForSocnet["USER_ID"] = $arFirstMessage["AUTHOR_ID"];
}
$log_id = CSocNetLog::Add($arFieldsForSocnet, false);
if (intval($log_id) > 0) {
CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
CSocNetLogRights::SetForSonet($log_id, $arParams["MODE"] == "GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams["MODE"] == "GROUP" ? $arParams["SOCNET_GROUP_ID"] : $arParams["USER_ID"], "forum", "view");
}
}
if (intval($log_id) > 0) {
$arFieldsForSocnet = array("ENTITY_TYPE" => $arParams["MODE"] == "GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, "ENTITY_ID" => $arParams["MODE"] == "GROUP" ? $arParams["SOCNET_GROUP_ID"] : $arParams["USER_ID"], "EVENT_ID" => "forum", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $sText, "TEXT_MESSAGE" => $parser->convert4mail($sText), "URL" => str_replace("#result#", $arParams["MID"], $url), "MODULE_ID" => false, "SOURCE_ID" => $arParams["MID"], "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => intval($arParams["MID"]));
if ($bSocNetLogRecordExists) {
if (intVal($arResult["MESSAGE"]["AUTHOR_ID"]) > 0) {
$arFieldsForSocnet["USER_ID"] = $arResult["MESSAGE"]["AUTHOR_ID"];
}
CSocNetLogComments::Add($arFieldsForSocnet);
} else {
$dbComments = CForumMessage::GetListEx(array("ID" => "ASC"), array('TOPIC_ID' => $arParams["TID"], "NEW_TOPIC" => "N"));
if ($dbComments && ($arComment = $dbComments->Fetch())) {
示例6: createLogEntry
private function createLogEntry($iblockElementID)
{
$rsElement = CIBlockElement::GetByID($iblockElementID);
if ($arElement = $rsElement->Fetch()) {
$arWikiElement = CWiki::GetElementById($arElement['ID'], array('IBLOCK_ID' => $arElement['IBLOCK_ID']));
$CWikiParser = new CWikiParser();
$parserLog = new logTextParser();
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "N");
$text4message = $CWikiParser->Parse($arElement['DETAIL_TEXT'], $arElement['DETAIL_TEXT_TYPE'], $arWikiElement['IMAGES']);
$text4message = preg_replace("#<br[\\s]*\\/>#is", "#BR#", $text4message);
$text4message = htmlspecialcharsback($parserLog->convert($text4message, array(), $arAllow));
$text4message = preg_replace("#\\#BR\\##is", "\n", $text4message);
$text4message = $CWikiParser->Clear($text4message);
$url = str_replace(array('#group_id#', '#wiki_name#'), array(intval($this->SonetGroupID), urlencode($arElement['NAME'])), $this->arPath['PATH_TO_POST']);
$arSoFields = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'IS_CUSTOM_ET' => 'N', 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki', 'USER_ID' => $arElement['CREATED_BY'], 'LOG_DATE' => $arElement['DATE_CREATE'], 'LOG_UPDATE' => $arElement['DATE_CREATE'], 'TITLE_TEMPLATE' => GetMessage('WIKI_SONET_LOG_TITLE_TEMPLATE'), 'TITLE' => $arElement['NAME'], 'MESSAGE' => $text4message, 'TEXT_MESSAGE' => '', 'MODULE_ID' => 'wiki', 'URL' => $url, 'CALLBACK_FUNC' => false, 'SOURCE_ID' => intval($iblockElementID), 'PARAMS' => 'forum_id=' . $this->ForumID, 'RATING_TYPE_ID' => 'IBLOCK_ELEMENT', 'RATING_ENTITY_ID' => intval($iblockElementID));
$log_id = CSocNetLog::Add($arSoFields, false);
$log_user_id = $arElement['CREATED_BY'];
$log_title = $arElement["NAME"];
if (intval($log_id) > 0) {
CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
CSocNetLogRights::SetForSonet($log_id, SONET_SUBSCRIBE_ENTITY_GROUP, intval($this->SonetGroupID), "wiki", "view", true);
return array("LOG_ID" => $log_id, "LOG_USER_ID" => $log_user_id, "LOG_TITLE" => $log_title, "URL" => $url);
}
}
return false;
}
示例7: SocNetLog
function SocNetLog($arParams)
{
$ownerType = isset($arParams['ownerType']) ? $arParams['ownerType'] : $this->ownerType;
$ownerId = isset($arParams['ownerId']) ? $arParams['ownerId'] : $this->ownerId;
$iblockId = isset($arParams['iblockId']) ? $arParams['iblockId'] : $this->iblockId;
$pathToUserCalendar = isset($arParams['pathToUserCalendar']) ? $arParams['pathToUserCalendar'] : $this->pathToUserCalendar;
$pathToGroupCalendar = isset($arParams['pathToGroupCalendar']) ? $arParams['pathToGroupCalendar'] : $this->pathToGroupCalendar;
if (!class_exists('CSocNetLog') || !$ownerType || !$ownerId) {
return;
}
$target = $arParams['target'];
$id = $arParams['id'];
$name = htmlspecialcharsex($arParams['name']);
$from = htmlspecialcharsex($arParams['from']);
$to = htmlspecialcharsex($arParams['to']);
$desc = htmlspecialcharsex($arParams['desc']);
$accessibility = htmlspecialcharsex($arParams['accessibility']);
$importance = htmlspecialcharsex($arParams['importance']);
$calendarId = $arParams['calendarId'];
if ($ownerType == 'USER') {
// Get user name
$dbUser = CUser::GetByID($ownerId);
if (!($arUser = $dbUser->Fetch())) {
return;
}
$owner_mess = GetMessage('EC_LOG_EV_USER', array('#USER_NAME#' => $arUser["NAME"] . " " . $arUser["LAST_NAME"]));
$url = preg_replace('/#user_id#/i', $ownerId, $pathToUserCalendar);
$privateStatus = CECCalendar::GetPrivateStatus($iblockId, $calendarId, $ownerType);
if (!$accessibility) {
$accessibility = 'busy';
}
$accessibilityMess = GetMessage('EC_ACCESSIBILITY_' . strtoupper($accessibility));
if ($privateStatus == 'private') {
return;
} elseif ($privateStatus == 'time' || $privateStatus == 'title') {
if ($privateStatus == 'time') {
$name = $accessibilityMess;
$accessibility = '';
}
$desc = '';
}
} else {
// Get group name
if (!($arGroup = CSocNetGroup::GetByID($ownerId))) {
return;
}
$owner_mess = GetMessage('EC_LOG_EV_GROUP', array('#GROUP_NAME#' => $arGroup["NAME"]));
$url = preg_replace('/#group_id#/i', $ownerId, $pathToGroupCalendar);
$accessibility = '';
}
if ($calendarId <= 0) {
return;
}
$rsData = CIBlockSection::GetByID($calendarId);
if (!($arCalendar = $rsData->Fetch())) {
return;
}
$accessibility_mess = strlen($accessibility) ? '<br>' . GetMessage('EC_LOG_EV_ACCESS', array('#EV_ACCESS#' => $accessibilityMess)) : '';
$importance_mess = strlen($importance) ? '<br>' . GetMessage('EC_LOG_EV_IMP', array('#EV_IMP#' => GetMessage('EC_IMPORTANCE_' . strtoupper($importance)))) : '';
$desc_mess = strlen($desc) ? '<br>' . GetMessage('EC_LOG_EV_DESC', array('#EV_DESC#' => $desc)) : '';
$calendarTitle = htmlspecialcharsex($arCalendar['NAME']);
if ($target == 'add_event') {
$title_template = GetMessage('EC_LOG_NEW_EV_TITLE');
$mess = GetMessage('EC_LOG_NEW_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)) . ' ' . $owner_mess . ' ' . $desc_mess . $accessibility_mess . $importance_mess;
$url .= '?EVENT_ID=' . $id;
} elseif ($target == 'edit_event') {
$title_template = GetMessage('EC_LOG_EDIT_EV_TITLE');
$mess = GetMessage('EC_LOG_EDIT_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)) . ' ' . $owner_mess . ' ' . $desc_mess . $accessibility_mess . $importance_mess;
$url .= '?EVENT_ID=' . $id;
} elseif ($target == 'delete_event') {
$title_template = GetMessage('EC_LOG_DEL_EV_TITLE');
$mess = GetMessage('EC_LOG_DEL_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)) . ' ' . $owner_mess . ' ' . $desc_mess;
}
$USER_ID = false;
if ($GLOBALS["USER"]->IsAuthorized()) {
$USER_ID = $GLOBALS["USER"]->GetID();
}
$res = CSocNetLog::Add(array("ENTITY_TYPE" => $ownerType == 'GROUP' ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, "ENTITY_ID" => $ownerId, "EVENT_ID" => "calendar", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $title_template, "TITLE" => $name, "MESSAGE" => $mess, "TEXT_MESSAGE" => preg_replace(array("/<(\\/)?b>/i", "/<br>/i"), array('', " \n"), $mess), "URL" => $url, "MODULE_ID" => false, "CALLBACK_FUNC" => false, "USER_ID" => $USER_ID));
if (intval($res) > 0) {
CSocNetLog::Update($res, array("TMP_ID" => $res));
}
}
示例8: SendMessage
public static function SendMessage($REPORT_ID, $bSendEvent = true)
{
global $DB;
$REPORT_ID = intval($REPORT_ID);
if ($REPORT_ID <= 0) {
return false;
}
$dbReport = CTimeManReportFull::GetByID($REPORT_ID);
if (CModule::IncludeModule("socialnetwork") && ($arReport = $dbReport->Fetch())) {
$date_from = FormatDate("j F", MakeTimeStamp($arReport["DATE_FROM"], CSite::GetDateFormat("FULL", SITE_ID)));
$date_to = FormatDate("j F", MakeTimeStamp($arReport["DATE_TO"], CSite::GetDateFormat("FULL", SITE_ID)));
if ($date_from == $date_to) {
$date_text = $date_to;
} else {
$date_text = $date_from . " - " . $date_to;
}
$message = GetMessage('REPORT_DONE');
$arSoFields = array("EVENT_ID" => "report", "=LOG_DATE" => $DB->CurrentTimeFunction(), "MODULE_ID" => "timeman", "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => GetMessage("REPORT_PERIOD") . $date_text, "MESSAGE" => $message, "TEXT_MESSAGE" => $message, "CALLBACK_FUNC" => false, "SOURCE_ID" => $REPORT_ID, "SITE_ID" => SITE_ID, "ENABLE_COMMENTS" => "Y", "PARAMS" => serialize(array("FORUM_ID" => COption::GetOptionInt("timeman", "report_forum_id", ""))));
$arSoFields["ENTITY_TYPE"] = SONET_WORK_REPORT_ENTITY;
$arSoFields["ENTITY_ID"] = $arReport["USER_ID"];
$arSoFields["USER_ID"] = $arReport["USER_ID"];
// CReportNotifications::Subscribe($arReport["USER_ID"]);
$logID = CSocNetLog::Add($arSoFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
$arRights = CReportNotifications::GetRights($arReport["USER_ID"]);
CSocNetLogRights::Add($logID, $arRights);
if ($bSendEvent) {
// CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
$arReport["ID"] = $REPORT_ID;
$arReport["LOG_ID"] = $logID;
$arReport["PERIOD_TEXT"] = $date_text;
if (IsModuleInstalled("im")) {
self::NotifyIm($arReport);
}
}
}
return $logID;
}
return false;
}
示例9: NotifyError
private function NotifyError()
{
if ($this->arExternalSale == null) {
$this->arExternalSale = CCrmExternalSale::GetDefaultSettings($this->externalSaleId);
}
if (intval($this->arExternalSale["GROUP_ID"]) <= 0) {
return true;
}
static $isSNIncluded = null;
if ($isSNIncluded === null) {
$isSNIncluded = CModule::IncludeModule("socialnetwork");
}
if (!$isSNIncluded) {
return;
}
$ar = array("#NAME#" => $this->arExternalSale["NAME"], "#URL#" => "/crm/configs/external_sale/", "#DATE#" => date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), time()));
$message = GetMessage("CRM_GCES_NOTIFY_ERROR_MESSAGE", $ar);
$arFields = array("EVENT_ID" => "crm_10_errors", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => "SYSTEM MESSAGE", "TITLE" => GetMessage("CRM_GCES_NOTIFY_ERROR_TITLE", array("#NAME#" => $this->arExternalSale["NAME"])), "MESSAGE" => $message, "TEXT_MESSAGE" => HTMLToTxt($message), "MODULE_ID" => "crm", "CALLBACK_FUNC" => false, "SOURCE_ID" => false, "ENABLE_COMMENTS" => "Y", "ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $this->arExternalSale["GROUP_ID"], "URL" => "");
$logId = CSocNetLog::Add($arFields, false);
if (intval($logId) > 0) {
$arPerms = array("SG" . $this->arExternalSale["GROUP_ID"], "SG" . $this->arExternalSale["GROUP_ID"] . "_A", "SG" . $this->arExternalSale["GROUP_ID"] . "_E", "SG" . $this->arExternalSale["GROUP_ID"] . "_K");
CSocNetLog::Update($logId, array("TMP_ID" => $logId));
CSocNetLogRights::Add($logId, $arPerms);
CSocNetLog::SendEvent($logId, "SONET_NEW_EVENT", $logId);
return $logId;
}
if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
$this->AddError($ex->GetID(), $ex->GetString());
} else {
$this->AddError("CDA", "Notify error");
}
return false;
}
示例10: UpdateActivityIBlock
function UpdateActivityIBlock(&$arFields)
{
if ($arFields['RESULT']) {
// absence
$iblock = COption::GetOptionInt('intranet', 'iblock_absence');
if (!$iblock) {
$iblock = array();
$dbRes = CSite::GetList($b = 'SORT', $o = 'ASC');
while ($arRes = $dbRes->Fetch()) {
if ($ib = COption::GetOptionInt('intranet', 'iblock_absence', false, $arRes['ID'])) {
$iblock[] = $ib;
}
}
} else {
$iblock = array($iblock);
}
if (count($iblock) > 0) {
foreach ($iblock as $ib) {
if ($arFields['IBLOCK_ID'] == $ib) {
static $PROPERTY_USER = 0;
if ($PROPERTY_USER <= 0) {
$dbRes = CIBlockProperty::GetByID('USER', $arFields['IBLOCK_ID']);
if ($arRes = $dbRes->Fetch()) {
$PROPERTY_USER = $arRes['ID'];
}
}
if ($PROPERTY_USER > 0) {
// $arPropertyValue = array_values($arFields['PROPERTY_VALUES']);
// $USER_ID = $arPropertyValue[0];
$USER_ID = $arFields['PROPERTY_VALUES']['USER'];
$dbRes = CUser::GetByID($USER_ID);
if ($arUser = $dbRes->Fetch()) {
CIBlockElement::SetPropertyValues($arFields['ID'], $arFields['IBLOCK_ID'], $arUser['ACTIVE'], 'USER_ACTIVE');
}
}
}
}
}
// -- absence
// news
if (intval($arFields["IBLOCK_ID"]) > 0) {
$rsIBlock = CIBlock::GetByID($arFields["IBLOCK_ID"]);
if ($arIBlock = $rsIBlock->Fetch()) {
if ($arIBlock["IBLOCK_TYPE_ID"] == "news" && CModule::IncludeModule("socialnetwork")) {
CSocNetAllowed::GetAllowedEntityTypes();
$dbLog = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "news", "SOURCE_ID" => $arFields["ID"]));
if ($arLog = $dbLog->Fetch()) {
if ($arFields["ACTIVE"] == "Y" && (strlen($arFields["PREVIEW_TEXT"]) > 0 || strlen($arFields["DETAIL_TEXT"]) > 0) && (!array_key_exists("WF", $arFields) || $arFields["WF"] == "N" || $arFields["WF_STATUS_ID"] == 1 && $arFields["WF_PARENT_ELEMENT_ID"] == $arFields["ID"])) {
$arSoFields = array("=LOG_DATE" => strlen($arFields["ACTIVE_FROM"]) > 0 ? MakeTimeStamp($arFields["ACTIVE_FROM"], CSite::GetDateFormat("FULL", $site_id)) > time() ? $GLOBALS["DB"]->CharToDateFunction($arFields["ACTIVE_FROM"], "FULL", $site_id) : $GLOBALS["DB"]->CurrentTimeFunction() : $GLOBALS["DB"]->CurrentTimeFunction(), "=LOG_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE" => $arFields["NAME"], "MESSAGE" => strlen($arFields["DETAIL_TEXT"]) > 0 ? $arFields["DETAIL_TEXT_TYPE"] == "text" ? htmlspecialcharsbx($arFields["DETAIL_TEXT"]) : $arFields["DETAIL_TEXT"] : ($arFields["PREVIEW_TEXT_TYPE"] == "text" ? htmlspecialcharsbx($arFields["PREVIEW_TEXT"]) : $arFields["PREVIEW_TEXT"]));
$logID = CSocNetLog::Update($arLog["ID"], $arSoFields);
if (intval($logID) > 0) {
$rsRights = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID));
$arRights = $rsRights->Fetch();
if (!$arRights) {
CSocNetLogRights::Add($logID, "G2");
}
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT");
}
} else {
CSocNetLog::Delete($arLog["ID"]);
}
} else {
if ($arFields["ACTIVE"] == "Y" && (strlen($arFields["PREVIEW_TEXT"]) > 0 || strlen($arFields["DETAIL_TEXT"]) > 0) && (!array_key_exists("WF", $arFields) || $arFields["WF"] == "N" || $arFields["WF_STATUS_ID"] == 1 && $arFields["WF_PARENT_ELEMENT_ID"] == $arFields["ID"])) {
$dbIBlock = CIBlock::GetByID($arFields["IBLOCK_ID"]);
if ($arIBlock = $dbIBlock->Fetch()) {
$rsSite = CIBlock::GetSite($arFields["IBLOCK_ID"]);
if ($arSite = $rsSite->Fetch()) {
$site_id = $arSite["SITE_ID"];
}
$val = COption::GetOptionString("intranet", "sonet_log_news_iblock", "", $site_id);
if (strlen($val) > 0) {
$arIBCode = unserialize($val);
if (!is_array($arIBCode) || count($arIBCode) <= 0) {
$arIBCode = array();
}
} else {
$arIBCode = array();
}
if (in_array($arIBlock["CODE"], $arIBCode)) {
$entity_url = str_replace("#SITE_DIR#", $arSite["DIR"], $arIBlock["LIST_PAGE_URL"]);
if (strpos($entity_url, "/") === 0) {
$entity_url = "/" . ltrim($entity_url, "/");
}
$url = str_replace(array("#SITE_DIR#", "#ID#", "#CODE#"), array($arSite["DIR"], $arFields["ID"], $arFields["CODE"]), $arIBlock["DETAIL_PAGE_URL"]);
if (strpos($url, "/") === 0) {
$url = "/" . ltrim($url, "/");
}
$val = COption::GetOptionString("intranet", "sonet_log_news_iblock_forum");
if (strlen($val) > 0) {
$arIBlockForum = unserialize($val);
} else {
$arIBlockForum = array();
}
$strMessage = strlen($arFields["DETAIL_TEXT"]) > 0 ? $arFields["DETAIL_TEXT_TYPE"] == "text" ? htmlspecialcharsbx($arFields["DETAIL_TEXT"]) : $arFields["DETAIL_TEXT"] : ($arFields["PREVIEW_TEXT_TYPE"] == "text" ? htmlspecialcharsbx($arFields["PREVIEW_TEXT"]) : $arFields["PREVIEW_TEXT"]);
$dtFormatSite = defined("ADMIN_SECTION") && ADMIN_SECTION === true ? SITE_ID : $site_id;
$dtValue = strlen($arFields["ACTIVE_FROM"]) > 0 ? MakeTimeStamp($arFields["ACTIVE_FROM"], CSite::GetDateFormat("FULL", $dtFormatSite)) > time() ? $GLOBALS["DB"]->CharToDateFunction($arFields["ACTIVE_FROM"], "FULL", $dtFormatSite) : $GLOBALS["DB"]->CurrentTimeFunction() : $GLOBALS["DB"]->CurrentTimeFunction();
$arSoFields = array("SITE_ID" => $site_id, "ENTITY_TYPE" => SONET_SUBSCRIBE_ENTITY_NEWS, "ENTITY_ID" => $arIBlock["ID"], "EVENT_ID" => "news", "USER_ID" => $GLOBALS["USER"]->GetID(), "=LOG_DATE" => $dtValue, "=LOG_UPDATE" => $dtValue, "TITLE_TEMPLATE" => GetMessage("INTR_SOCNET_LOG_NEWS_TITLE"), "TITLE" => $arFields["NAME"], "MESSAGE" => $strMessage, "TEXT_MESSAGE" => "", "URL" => $url, "MODULE_ID" => "intranet", "CALLBACK_FUNC" => false, "TMP_ID" => false, "PARAMS" => serialize(array("ENTITY_NAME" => $arIBlock["NAME"], "ENTITY_URL" => $entity_url)), "SOURCE_ID" => $arFields["ID"], "ENABLE_COMMENTS" => array_key_exists($arIBlock["ID"], $arIBlockForum) ? "Y" : "N");
$logID = CSocNetLog::Add($arSoFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
//.........这里部分代码省略.........
示例11: SendMessageToSocNet
protected static function SendMessageToSocNet($arFields, $bSpawnedByAgent, $arChanges = null, $arTask = null, array $parameters = array())
{
global $USER, $DB;
$effectiveUserId = self::getEffectiveUserId($arFields, array(), $bSpawnedByAgent, $parameters);
if (!CModule::IncludeModule('socialnetwork')) {
return null;
}
$bCrmTask = isset($arTask) && isset($arTask["UF_CRM_TASK"]) && (is_array($arTask["UF_CRM_TASK"]) && (isset($arTask["UF_CRM_TASK"][0]) && strlen($arTask["UF_CRM_TASK"][0]) > 0) || !is_array($arTask["UF_CRM_TASK"]) && strlen($arTask["UF_CRM_TASK"]) > 0);
$arLogFilter = false;
if (!$bCrmTask) {
$arLogFilter = array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]);
} elseif (CModule::IncludeModule("crm")) {
$dbCrmActivity = CCrmActivity::GetList(array(), array('TYPE_ID' => CCrmActivityType::Task, 'ASSOCIATED_ENTITY_ID' => $arTask["ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
if ($arCrmActivity = $dbCrmActivity->Fetch()) {
$arLogFilter = array("EVENT_ID" => "crm_activity_add", "ENTITY_ID" => $arCrmActivity["ID"]);
}
}
if (!$arLogFilter) {
return null;
}
static $arCheckedUsers = array();
// users that checked for their existing
static $cachedSiteTimeFormat = -1;
// select "real" author
$occurAsUserId = CTasksTools::getOccurAsUserId();
if (!$occurAsUserId) {
$occurAsUserId = $effectiveUserId;
}
if ($cachedSiteTimeFormat === -1) {
$cachedSiteTimeFormat = CSite::GetDateFormat('FULL', SITE_ID);
}
static $cachedAllSitesIds = -1;
if ($cachedAllSitesIds === -1) {
$cachedAllSitesIds = array();
$dbSite = CSite::GetList($by = 'sort', $order = 'desc', array('ACTIVE' => 'Y'));
while ($arSite = $dbSite->Fetch()) {
$cachedAllSitesIds[] = $arSite['ID'];
}
}
// Check that user exists
if (!in_array((int) $arFields["CREATED_BY"], $arCheckedUsers, true)) {
$rsUser = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => $arFields["CREATED_BY"]), array('FIELDS' => array('ID')));
if (!($arUser = $rsUser->Fetch())) {
return false;
}
$arCheckedUsers[] = (int) $arFields["CREATED_BY"];
}
if (is_array($arChanges)) {
if (count($arChanges) == 0) {
$rsSocNetLogItems = CSocNetLog::GetList(array("ID" => "DESC"), $arLogFilter, false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
while ($arRes = $rsSocNetLogItems->Fetch()) {
$authorUserId = false;
if (isset($arFields['CREATED_BY'])) {
$authorUserId = (int) $arFields['CREATED_BY'];
} elseif (isset($arTask['CREATED_BY'])) {
$authorUserId = (int) $arTask['CREATED_BY'];
}
// Add author to list of users that view log about task in livefeed
// But only when some other person change task
// or if added FORUM_TOPIC_ID
if ($authorUserId !== $effectiveUserId || $arTask['FORUM_TOPIC_ID'] == 0 && isset($arFields['FORUM_TOPIC_ID']) && $arFields['FORUM_TOPIC_ID'] > 0) {
$authorGroupCode = 'U' . $authorUserId;
$rsRights = CSocNetLogRights::GetList(array(), array('LOG_ID' => $arRes['ID'], 'GROUP_CODE' => $authorGroupCode));
// If task's author hasn't rights yet, give them
if (!($arRights = $rsRights->fetch())) {
CSocNetLogRights::Add($arRes["ID"], array($authorGroupCode));
}
}
}
return null;
} elseif (count($arChanges) == 1 && isset($arChanges['STATUS'])) {
return null;
// if only status changes - don't send message, because it will be sent by SendStatusMessage()
}
}
if ($bSpawnedByAgent === 'Y') {
$bSpawnedByAgent = true;
} elseif ($bSpawnedByAgent === 'N') {
$bSpawnedByAgent = false;
}
if (!is_bool($bSpawnedByAgent)) {
return false;
}
$taskId = false;
if (is_array($arFields) && isset($arFields['ID']) && $arFields['ID'] > 0) {
$taskId = $arFields['ID'];
} elseif (is_array($arTask) && isset($arTask['ID']) && $arTask['ID'] > 0) {
$taskId = $arTask['ID'];
}
// We will mark this to false, if we send update message and log item already exists
$bSocNetAddNewItem = true;
$logDate = $DB->CurrentTimeFunction();
$curTimeTimestamp = time() + CTimeZone::GetOffset();
if (!$bCrmTask) {
$arSoFields = array('EVENT_ID' => 'tasks', 'TITLE' => $arFields['TITLE'], 'MESSAGE' => '', 'MODULE_ID' => 'tasks');
} else {
$arSoFields = array();
}
// If changes and task data given => we are prepare "update" message,
// or "add" message otherwise
//.........这里部分代码省略.........
示例12: SocnetLogMessageAdd
public static function SocnetLogMessageAdd($arParams, $arMessageFields, $action = "")
{
static $parser = null;
if ($parser == null) {
$parser = new forumTextParser();
}
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "SMILES" => "N", "UPLOAD" => "Y", "NL2BR" => "N", "TABLE" => "N", "ALIGN" => "N");
// $arParams["LOG_ID"], $arParams["LANG"] ....
$arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $arParams["ENTITY_ID"], "EVENT_ID" => "forum", "=LOG_DATE" => !!$arMessageFields["DATE_CREATE"] ? $arMessageFields["DATE_CREATE"] : $GLOBALS["DB"]->CurrentTimeFunction(), "LOG_UPDATE" => !!$arMessageFields["POST_DATE"] ? $arMessageFields["POST_DATE"] : null, "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $arMessageFields["AUTHOR_NAME"], CForumEmail::GetLangMessage("FORUM_MAIL_SOCNET_TITLE_TOPIC", $arParams["LANG"])), "TITLE" => $arMessageFields["TITLE"], "MESSAGE" => $parser->convert($arMessageFields["POST_MESSAGE"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($arMessageFields["POST_MESSAGE"]), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $arMessageFields["AUTHOR_ID"], "FID" => $arMessageFields["FORUM_ID"], "TID" => $arMessageFields["TOPIC_ID"], "TITLE_SEO" => $arMessageFields["TOPIC_ID"], "MID" => $arMessageFields["ID"])), "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $arMessageFields["TOPIC_ID"])))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arMessageFields["ID"], "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => $arMessageFields["TOPIC_ID"]);
if ($arMessageFields["AUTHOR_ID"] > 0) {
$arFieldsForSocnet["USER_ID"] = $arMessageFields["AUTHOR_ID"];
}
$db_res = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $arMessageFields["ID"]));
$ufFileID = array();
while ($res = $db_res->Fetch()) {
$ufFileID[] = $res["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $arMessageFields["ID"], LANGUAGE_ID);
$logID = $arParams["LOG_ID"];
if ($logID <= 0) {
if (!empty($ufFileID)) {
$arFieldsForSocnet["UF_SONET_LOG_FILE"] = $ufFileID;
}
if ($ufDocID) {
$arFieldsForSocnet["UF_SONET_LOG_DOC"] = $ufDocID;
}
$logID = CSocNetLog::Add($arFieldsForSocnet, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
CSocNetLogRights::SetForSonet($logID, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true);
if ($action == "SEND_EVENT") {
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
}
}
}
if ($logID > 0 && $action == "ADD_COMMENT") {
if (!empty($ufFileID)) {
$arFieldsForSocnet["UF_SONET_COM_FILE"] = $ufFileID;
}
if ($ufDocID) {
$arFieldsForSocnet["UF_SONET_COM_DOC"] = $ufDocID;
}
$arFieldsForSocnet["LOG_ID"] = $logID;
$arFieldsForSocnet["RATING_TYPE_ID"] = "FORUM_POST";
$arFieldsForSocnet["RATING_ENTITY_ID"] = $arMessageFields["ID"];
$commentID = CSocNetLogComments::Add($arFieldsForSocnet);
CSocNetLog::CounterIncrement($commentID, false, false, "LC");
return $commentID;
}
return $logID;
}
示例13: __InTaskAdd2Log
function __InTaskAdd2Log($entityType, $entityId, $type, $title, $message, $url)
{
if ($type == "add") {
$template = GetMessage("INTASK_2LOG_ADD");
} elseif ($type == "update") {
$template = GetMessage("INTASK_2LOG_UPDATE");
} elseif ($type == "delete") {
$template = GetMessage("INTASK_2LOG_DELETE");
}
$logID = CSocNetLog::Add(array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityId, "EVENT_ID" => "tasks", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $template, "TITLE" => $title, "MESSAGE" => nl2br($message), "TEXT_MESSAGE" => $message, "URL" => $url, "MODULE_ID" => false, "CALLBACK_FUNC" => false));
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
}
}
示例14: DeleteRelation
function DeleteRelation($userID, $groupID)
{
global $APPLICATION;
$userID = IntVal($userID);
if ($userID <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_USERID"), "ERROR_USER_ID");
return false;
}
$groupID = IntVal($groupID);
if ($groupID <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_GROUPID"), "ERROR_GROUPID");
return false;
}
$dbResult = CSocNetUserToGroup::GetList(
array(),
array(
"GROUP_ID" => $groupID,
"USER_ID" => $userID,
),
false,
false,
array("ID", "ROLE", "GROUP_VISIBLE")
);
if ($arResult = $dbResult->Fetch())
{
if ($arResult["ROLE"] != SONET_ROLES_USER && $arResult["ROLE"] != SONET_ROLES_MODERATOR)
return false;
if (CSocNetUserToGroup::Delete($arResult["ID"]))
{
$arGroupSiteID = array();
$rsGroupSite = CSocNetGroup::GetSite($groupID);
while($arGroupSite = $rsGroupSite->Fetch())
{
$arGroupSiteID[] = $arGroupSite["LID"];
//get server name
$rsSites = CSite::GetByID($arGroupSite["LID"]);
$arSite = $rsSites->Fetch();
$serverName = $arSite["SERVER_NAME"];
if (strlen($serverName) <= 0)
{
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
$serverName = SITE_SERVER_NAME;
else
$serverName = COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]);
}
if (strlen($serverName) > 0)
{
$protocol = (CMain::IsHTTPS() ? "https" : "http");
$serverName = $protocol."://".$serverName;
}
}
$fullWorkgroupsUrl = $serverName.COption::GetOptionString("socialnetwork", "workgroups_page", false, $arGroupSiteID["0"]);
$logID = CSocNetLog::Add(
array(
"ENTITY_TYPE" => SONET_ENTITY_GROUP,
"ENTITY_ID" => $groupID,
"EVENT_ID" => "system",
"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
"TITLE_TEMPLATE" => false,
"TITLE" => "unjoin",
"MESSAGE" => $userID,
"URL" => $fullWorkgroupsUrl,
"MODULE_ID" => false,
"CALLBACK_FUNC" => false,
"USER_ID" => $userID,
"SITE_ID" => $arGroupSiteID
),
false
);
if (intval($logID) > 0)
{
$tmpID = $logID;
CSocNetLog::Update($logID, array("TMP_ID" => $tmpID));
CSocNetLogRights::Add($logID, array("SA", "U".$userID, "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", $tmpID);
}
}
else
{
$errorMessage = "";
if ($e = $APPLICATION->GetException())
$errorMessage = $e->GetString();
if (StrLen($errorMessage) <= 0)
$errorMessage = GetMessage("SONET_UR_ERROR_CREATE_USER2GROUP");
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_DELETE_RELATION");
return false;
}
}
//.........这里部分代码省略.........
示例15: CheckRequest
function CheckRequest()
{
global $DB;
$result = "";
if (!CModule::IncludeModule("socialnetwork")) {
return $result;
}
$current_time = time();
$time_of_exec = false;
$rsScheme = CXDILFScheme::GetList(array(), array("ACTIVE" => "Y", "AUTO" => "Y"));
while (($arScheme = $rsScheme->Fetch()) && $time_of_exec === false) {
if ($arScheme["LAST_EXECUTED"] == '') {
continue;
}
$last_executed = MakeTimeStamp(ConvertDateTime($arScheme["LAST_EXECUTED"], "DD.MM.YYYY HH:MI:SS"), "DD.MM.YYYY HH:MI:SS");
if ($last_executed <= 0) {
continue;
}
$arEventTmp = CSocNetLogTools::FindLogEventByID($arScheme["EVENT_ID"]);
if (array_key_exists("REAL_EVENT_ID", $arEventTmp) && strlen($arEventTmp["REAL_EVENT_ID"]) > 0) {
$arScheme["EVENT_ID"] = $arEventTmp["REAL_EVENT_ID"];
}
//parse schedule
$arDoM = CXDImport::ParseDaysOfMonth($arScheme["DAYS_OF_MONTH"]);
$arDoW = CXDImport::ParseDaysOfWeek($arScheme["DAYS_OF_WEEK"]);
$arToD = CXDImport::ParseTimesOfDay($arScheme["TIMES_OF_DAY"]);
if ($arToD) {
sort($arToD, SORT_NUMERIC);
}
$arSDate = localtime($last_executed);
//sdate = truncate(last_execute)
$sdate = mktime(0, 0, 0, $arSDate[4] + 1, $arSDate[3], $arSDate[5] + 1900);
while ($sdate < $current_time && $time_of_exec === false) {
$arSDate = localtime($sdate);
if ($arSDate[6] == 0) {
$arSDate[6] = 7;
}
//determine if date is good for execution
if ($arDoM) {
$flag = array_search($arSDate[3], $arDoM);
if ($arDoW) {
$flag = array_search($arSDate[6], $arDoW);
}
} elseif ($arDoW) {
$flag = array_search($arSDate[6], $arDoW);
} else {
$flag = false;
}
if ($flag !== false && $arToD) {
foreach ($arToD as $intToD) {
if ($sdate + $intToD > $last_executed && $sdate + $intToD <= $current_time) {
$time_of_exec = $sdate + $intToD;
break;
}
}
}
$sdate = mktime(0, 0, 0, date("m", $sdate), date("d", $sdate) + 1, date("Y", $sdate));
//next day
}
if ($time_of_exec !== false) {
if ($arScheme["TYPE"] == "XML") {
$arParams = array();
if (strlen($arScheme["PARAMS"]) > 0) {
$arTmp = explode("&", $arScheme["PARAMS"]);
if (is_array($arTmp) && count($arTmp) > 0) {
foreach ($arTmp as $pair) {
list($key, $value) = explode("=", $pair);
$arParams[$key] = $value;
}
}
}
$arResponse = CXDILFSchemeXML::Request($arScheme["HOST"], $arScheme["PAGE"], $arScheme["PORT"], $arScheme["METHOD"], "http://" . $arScheme["HOST"], $arScheme["LOGIN"], $arScheme["PASSWORD"], $arParams);
if ($arResponse && is_array($arResponse)) {
if (XDI_DEBUG) {
CXDImport::WriteToLog("Successful webservice response, scheme ID: " . $arScheme["ID"], "RXML");
}
$entityName = $arScheme["NAME"];
if ($arScheme["EVENT_ID"] == "news") {
$rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y", "TYPE" => "news", "ID" => $arScheme["ENTITY_ID"]));
if ($arIBlock = $rsIBlock->Fetch()) {
$entityName = $arIBlock["NAME"];
}
}
$arLogParams = array("ENTITY_NAME" => $entityName, "ENTITY_URL" => $arResponse["URL"]);
$arSonetFields = array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "ENABLE_COMMENTS" => $arScheme["ENABLE_COMMENTS"], "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $arResponse["TITLE"], "TITLE" => $arResponse["TITLE"], "MESSAGE" => $arResponse["MESSAGE"], "TEXT_MESSAGE" => $arResponse["TEXT_MESSAGE"], "URL" => $arResponse["URL"], "PARAMS" => serialize($arLogParams), "MODULE_ID" => false, "CALLBACK_FUNC" => false);
$logID = CSocNetLog::Add($arSonetFields, false);
if (intval($logID) > 0) {
$arUpdateFields = array("TMP_ID" => $logID, "RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logID);
CSocNetLog::Update($logID, $arUpdateFields);
CXDILFScheme::SetSonetLogRights($logID, $arScheme["ENTITY_TYPE"], $arScheme["ENTITY_ID"], $arScheme["EVENT_ID"]);
CSocNetLog::CounterIncrement($logID);
if ($arScheme["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arScheme["ENTITY_ID"]) > 0) {
$notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arScheme["NAME"]);
$notify_title = TruncateText($notify_title_tmp, 100);
$notify_title_out = TruncateText($notify_title_tmp, 255);
$arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arScheme["ENTITY_ID"]), "NOTIFY_MESSAGE" => "", "URL" => "", "MESSAGE" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title)), "MESSAGE_OUT" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title_out)), "EXCLUDE_USERS" => array());
CSocNetSubscription::NotifyGroup($arNotifyParams);
}
}
} else {
//.........这里部分代码省略.........