本文整理汇总了PHP中CTimeZone类的典型用法代码示例。如果您正苦于以下问题:PHP CTimeZone类的具体用法?PHP CTimeZone怎么用?PHP CTimeZone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTimeZone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InstallDB
function InstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
// Database tables creation
if (!$DB->Query("SELECT 'x' FROM b_list_rubric WHERE 1=0", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/subscribe/install/db/" . $DBType . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
} else {
RegisterModule("subscribe");
CModule::IncludeModule("subscribe");
RegisterModuleDependences("main", "OnBeforeLangDelete", "subscribe", "CRubric", "OnBeforeLangDelete");
RegisterModuleDependences("main", "OnUserDelete", "subscribe", "CSubscription", "OnUserDelete");
RegisterModuleDependences("main", "OnUserLogout", "subscribe", "CSubscription", "OnUserLogout");
RegisterModuleDependences("main", "OnGroupDelete", "subscribe", "CPosting", "OnGroupDelete");
//agents
CAgent::RemoveAgent("CSubscription::CleanUp();", "subscribe");
CTimeZone::Disable();
CAgent::Add(array("NAME" => "CSubscription::CleanUp();", "MODULE_ID" => "subscribe", "ACTIVE" => "Y", "NEXT_EXEC" => date("d.m.Y H:i:s", mktime(3, 0, 0, date("m"), date("j") + 1, date("Y"))), "AGENT_INTERVAL" => 86400, "IS_PERIOD" => "Y"));
CTimeZone::Enable();
return true;
}
}
示例2: getList
public static function getList($userId, $taskId, array $parameters = array())
{
$data = array();
$task = static::getTask($userId, $taskId);
if ($task !== null && $task->checkCanRead()) {
$res = \CTaskLog::GetList(array('CREATED_DATE' => 'DESC'), array('TASK_ID' => $taskId));
$tzDisabled = !\CTimeZone::enabled();
if ($tzDisabled) {
\CTimeZone::enable();
}
$tzOffset = \CTimeZone::getOffset();
if ($tzDisabled) {
\CTimeZone::disable();
}
while (true) {
if ($parameters['ESCAPE_DATA']) {
$item = $res->GetNext();
} else {
$item = $res->fetch();
}
if (!$item) {
break;
}
// Adjust unix timestamps to "bitrix timestamps"
if (isset(\CTaskLog::$arComparedFields[$item['FIELD']]) && \CTaskLog::$arComparedFields[$item['FIELD']] === 'date') {
$item['TO_VALUE'] = $item['TO_VALUE'] + $tzOffset;
$item['FROM_VALUE'] = $item['FROM_VALUE'] + $tzOffset;
}
$data[] = $item;
}
}
return array('DATA' => $data, 'CAN' => array());
}
示例3: getGridData
private function getGridData($gridId)
{
$grid = array('ID' => $gridId);
$securityContext = $this->storage->getCurrentUserSecurityContext();
$parameters = array('with' => array('FILE', 'CREATE_USER'), 'filter' => array('IS_EXPIRED' => false, 'OBJECT.STORAGE_ID' => $this->storage->getId(), 'CREATED_BY' => $this->getUser()->getId()));
$parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('OBJECT_ID', 'OBJECT.CREATED_BY'));
$items = ExternalLink::getModelList($parameters);
Collection::sortByColumn($items, array('CREATE_TIME' => array(SORT_NUMERIC, SORT_ASC)));
$urlManager = Driver::getInstance()->getUrlManager();
$rows = array();
foreach ($items as $externalLink) {
/** @var ExternalLink $externalLink */
$exportData = $externalLink->toArray();
$nameSpecialChars = htmlspecialcharsbx($externalLink->getFile()->getName());
$createDateText = htmlspecialcharsbx((string) $externalLink->getCreateTime());
$columnName = "\n\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$externalLink->getId()}\" class=\"draggable bx-file-icon-container-small bx-disk-file-icon\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$externalLink->getId()}\" href=\"\" data-bx-dateModify=\"{$createDateText}\">{$nameSpecialChars}</a></td>\n\t\t\t\t</tr></table>\n\t\t\t";
$createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $externalLink->getCreatedBy()));
$rows[] = array('data' => $exportData, 'columns' => array('CREATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'UPDATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'NAME' => $columnName, 'FORMATTED_SIZE' => CFile::formatSize($externalLink->getFile()->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($externalLink->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t\t"), 'actions' => array(array("PSEUDO_NAME" => "download", "DEFAULT" => true, "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($externalLink->getFile()) . "')"), array("PSEUDO_NAME" => "disable_external_link", "ICONCLASS" => "disable_external_link", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK'), "SHORT_TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK_SHORT'), "ONCLICK" => "BX.Disk['ExternalLinkListClass_{$this->getComponentId()}'].disableExternalLink({$externalLink->getId()}, {$externalLink->getObjectId()})")));
}
unset($externalLink);
$grid['MODE'] = 'list';
$grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'default' => false, 'show_checkbox' => true), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_NAME'), 'default' => true), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_TIME'), 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_USER'), 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_FORMATTED_SIZE'), 'default' => true));
$grid['ROWS'] = $rows;
$grid['ROWS_COUNT'] = count($rows);
$grid['FOOTER'] = array();
return $grid;
}
示例4: canRead
/**
* @param $userId
* @return bool
*/
public function canRead($userId)
{
if ($this->canRead !== null) {
return $this->canRead;
}
if (!Loader::includeModule('socialnetwork')) {
return false;
}
$cacheTtl = 2592000;
$cacheId = 'blog_post_socnet_general_' . $this->entityId . '_' . LANGUAGE_ID;
$timezoneOffset = \CTimeZone::getOffset();
if ($timezoneOffset != 0) {
$cacheId .= "_" . $timezoneOffset;
}
$cacheDir = '/blog/socnet_post/gen/' . intval($this->entityId / 100) . '/' . $this->entityId;
$cache = new \CPHPCache();
if ($cache->initCache($cacheTtl, $cacheId, $cacheDir)) {
$post = $cache->getVars();
} else {
$cache->startDataCache();
$queryPost = \CBlogPost::getList(array(), array("ID" => $this->entityId), false, false, array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR_ID", "ENABLE_COMMENTS", "NUM_COMMENTS", "VIEWS", "CODE", "MICRO", "DETAIL_TEXT", "DATE_PUBLISH", "CATEGORY_ID", "HAS_SOCNET_ALL", "HAS_TAGS", "HAS_IMAGES", "HAS_PROPS", "HAS_COMMENT_IMAGES"));
$post = $queryPost->fetch();
$cache->endDataCache($post);
}
if (!$post) {
$this->canRead = false;
return false;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$this->canRead = \CBlogPost::getSocNetPostPerms($this->entityId, true, $userId, $post["AUTHOR_ID"]) >= BLOG_PERMS_READ;
return $this->canRead;
}
示例5: SubscribeOnTime
public function SubscribeOnTime($workflowId, $eventName, $expiresAt)
{
CTimeZone::Disable();
$result = CAgent::AddAgent("CBPSchedulerService::OnAgent('" . $workflowId . "', '" . $eventName . "', array('SchedulerService' => 'OnAgent'));", "bizproc", "N", 10, "", "Y", date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $expiresAt));
CTimeZone::Enable();
return $result;
}
示例6: Add
public static function Add($settings)
{
global $DB, $USER;
$name = $settings['title'];
$description = $settings['description'];
$owner = $settings['owner'];
unset($settings['title']);
unset($settings['description']);
unset($settings['owner']);
$fields = array('TITLE' => $name, 'DESCRIPTION' => $description, 'OWNER_ID' => $owner, 'CREATED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time() + CTimeZone::GetOffset()), 'CREATED_BY' => $USER->GetID());
if (isset($settings['mark_default'])) {
$fields['MARK_DEFAULT'] = $settings['mark_default'];
unset($settings['mark_default']);
}
$fields['SETTINGS'] = serialize($settings);
// pre-events
foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$fields)) === false) {
return false;
}
}
// save data
$ID = $DB->Add("b_report", $fields, array("SETTINGS", "DESCRIPTION"), "report");
// clear view params
self::clearViewParams($ID);
// post-events
foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, &$fields));
}
return $ID;
}
示例7: InstallDB
function InstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
// Database tables creation
if (!$DB->Query("SELECT 'x' FROM b_sender_contact WHERE 1=0", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sender/install/db/" . $DBType . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
} else {
RegisterModule("sender");
CModule::IncludeModule("sender");
// read and click notifications
RegisterModuleDependences("main", "OnMailEventMailRead", "sender", "bitrix\\sender\\postingmanager", "onMailEventMailRead");
RegisterModuleDependences("main", "OnMailEventMailClick", "sender", "bitrix\\sender\\postingmanager", "onMailEventMailClick");
// unsubscription notifications
RegisterModuleDependences("main", "OnMailEventSubscriptionDisable", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionDisable");
RegisterModuleDependences("main", "OnMailEventSubscriptionEnable", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionEnable");
RegisterModuleDependences("main", "OnMailEventSubscriptionList", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionList");
// connectors of module sender
RegisterModuleDependences("sender", "OnConnectorList", "sender", "bitrix\\sender\\connectormanager", "onConnectorListContact");
RegisterModuleDependences("sender", "OnConnectorList", "sender", "bitrix\\sender\\connectormanager", "onConnectorListRecipient");
// mail templates and blocks
RegisterModuleDependences("sender", "OnPresetTemplateList", "sender", "Bitrix\\Sender\\Preset\\TemplateBase", "onPresetTemplateList");
RegisterModuleDependences("sender", "OnPresetTemplateList", "sender", "Bitrix\\Sender\\TemplateTable", "onPresetTemplateList");
RegisterModuleDependences("sender", "OnPresetMailBlockList", "sender", "Bitrix\\Sender\\Preset\\MailBlockBase", "OnPresetMailBlockList");
CTimeZone::Disable();
\Bitrix\Sender\MailingManager::actualizeAgent();
CAgent::AddAgent(\Bitrix\Sender\MailingManager::getAgentNamePeriod(), "sender", "N", COption::GetOptionString("sender", "reiterate_interval"));
CTimeZone::Enable();
return true;
}
}
示例8: storeResult
function storeResult($arResult, $arParams) {
$iblock = CIBlock::GetList(
array(),
array(
'TYPE' => $arParams['IBLOCK_TYPE'],
'CODE' => $arParams['IBLOCK_CODE'],
)
);
$iblock = $iblock->Fetch();
$el = new CIBlockElement;
$props = array();
foreach ($arResult['FIELDS_LIST'] as $arField) {
if ($arField['FIELD_TYPE'] == 'TEXT' || $arField['FIELD_TYPE'] == 'NUMBER') {
$props[$arField['CODE']] = array(
'VALUE' => $arResult['POST_DATA']['~'.$arField['CODE']],
);
} elseif ($arField['FIELD_TYPE'] == 'TEXTAREA') {
$props[$arField['CODE']] = array(
'VALUE' => array(
'TYPE' => 'text',
'TEXT' => $arResult['POST_DATA']['~'.$arField['CODE']],
),
);
} elseif ($arField['FIELD_TYPE'] == 'LIST') {
$propEnum = CIBlockPropertyEnum::GetList(
array(),
array(
'XML_ID' => $arResult['POST_DATA']['~'.$arField['CODE']],
'CODE' => $arField['CODE'],
'IBLOCK_ID' => $iblock['ID'],
)
);
$propEnum = $propEnum->Fetch();
if ( ! $propEnum) return false;
$props[$arField['CODE']] = array(
'VALUE' => $propEnum['ID'],
);
}
}
$res = $el->Add(array(
'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'],
'IBLOCK_ID' => $iblock['ID'],
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => $props,
'ACTIVE_FROM' => ConvertTimeStamp(time()+CTimeZone::GetOffset(), 'FULL'),
'NAME' => 'Form result', # !!! NEED TO REPLACE TO DEFAULT VALUE
));
if (!$res) {
return array(
'MESSAGE' => $el->LAST_ERROR,
);
}
return true;
}
示例9: Add
public static function Add($userId, $tag)
{
global $DB, $CACHE_MANAGER;
$userId = intval($userId);
if ($userId == 0 || strlen($tag) <= 0) {
return false;
}
$arResult = $CACHE_MANAGER->Read(3600, $cache_id = "b_pw_" . $userId, "b_pull_watch");
if ($arResult) {
$arResult = $CACHE_MANAGER->Get($cache_id);
}
if (!$arResult) {
CTimeZone::Disable();
$strSql = "\n\t\t\t\t\tSELECT ID, USER_ID, TAG, " . $DB->DatetimeToTimestampFunction("DATE_CREATE") . " DATE_CREATE\n\t\t\t\t\tFROM b_pull_watch\n\t\t\t\t\tWHERE USER_ID = " . intval($userId) . "\n\t\t\t";
CTimeZone::Enable();
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$arResult[$arRes["TAG"]] = $arRes;
}
$CACHE_MANAGER->Set($cache_id, $arResult);
}
if ($arResult && $arResult[$tag]) {
if ($arResult[$tag]['DATE_CREATE'] + 1800 > time()) {
self::$arUpdate[intval($arResult[$tag]['ID'])] = intval($arResult[$tag]['ID']);
return true;
} else {
self::Delete($userId, $tag);
return self::Add($userId, $tag);
}
}
$CACHE_MANAGER->Clean("b_pw_" . $userId, "b_pull_watch");
self::$arInsert[trim($tag)] = trim($tag);
return true;
}
示例10: CheckExpireAgent
public static function CheckExpireAgent()
{
global $DB;
if (!CPullOptions::ModuleEnable())
return false;
CAgent::RemoveAgent("CPullWatch::CheckExpireAgent();", "pull");
$strSql = "SELECT count(ID) CNT FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE)";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
{
$strSql = "DELETE FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE) LIMIT 1000";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes['CNT'] > 1000)
{
CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 180, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+180, "FULL"));
return false;
}
}
CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 600, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+600, "FULL"));
return false;
}
示例11: Add
function Add($LOG_ID, $GROUP_CODE)
{
global $DB;
if (is_array($GROUP_CODE))
{
foreach($GROUP_CODE as $GROUP_CODE_TMP)
CSocNetLogRights::Add($LOG_ID, $GROUP_CODE_TMP);
return false;
}
else
{
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogRightsAdd");
while ($arEvent = $db_events->Fetch())
if (ExecuteModuleEventEx($arEvent, array($LOG_ID, &$GROUP_CODE))===false)
return false;
$NEW_RIGHT_ID = $DB->Add("b_sonet_log_right", array(
"LOG_ID" => $LOG_ID,
"GROUP_CODE" => $GROUP_CODE,
));
if (preg_match('/^U(\d+)$/', $GROUP_CODE, $matches))
CSocNetLogFollow::Set($matches[1], "L".$LOG_ID, "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
if(defined("BX_COMP_MANAGED_CACHE"))
$GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_".intval($LOG_ID));
return $NEW_RIGHT_ID;
}
}
示例12: sendOnAfterResultStatusChange
function sendOnAfterResultStatusChange($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID = false, $CHECK_RIGHTS = 'Y')
{
$NEW_STATUS_ID = intval($NEW_STATUS_ID);
$dbRes = CForm::GetByID($WEB_FORM_ID);
if (!($arForm = $dbRes->Fetch())) {
return;
}
CTimeZone::Disable();
$dbRes = CFormResult::GetByID($RESULT_ID);
CTimeZone::Enable();
if (!($arResult = $dbRes->Fetch()) || !$arResult['USER_ID']) {
return;
}
$dbRes = CUser::GetByID($arResult['USER_ID']);
if (!($arUser = $dbRes->Fetch())) {
return;
}
if (!$NEW_STATUS_ID) {
$NEW_STATUS_ID = CFormStatus::GetDefault($WEB_FORM_ID);
}
$dbRes = CFormStatus::GetByID($NEW_STATUS_ID);
if (!($arStatus = $dbRes->Fetch()) || strlen($arStatus['MAIL_EVENT_TYPE']) <= 0) {
return;
}
$arTemplates = CFormStatus::GetMailTemplateArray($NEW_STATUS_ID);
if (!is_array($arTemplates) || count($arTemplates) <= 0) {
return;
}
$arEventFields = array("EMAIL_TO" => $arUser['EMAIL'], "RS_FORM_ID" => $arForm["ID"], "RS_FORM_NAME" => $arForm["NAME"], "RS_FORM_VARNAME" => $arForm["SID"], "RS_FORM_SID" => $arForm["SID"], "RS_RESULT_ID" => $arResult["ID"], "RS_DATE_CREATE" => $arResult["DATE_CREATE"], "RS_USER_ID" => $arResult['USER_ID'], "RS_USER_EMAIL" => $arUser['EMAIL'], "RS_USER_NAME" => $arUser["NAME"] . " " . $arUser["LAST_NAME"], "RS_STATUS_ID" => $arStatus["ID"], "RS_STATUS_NAME" => $arStatus["TITLE"]);
$dbRes = CEventMessage::GetList($by = "id", $order = "asc", array('ID' => implode('|', $arTemplates), "ACTIVE" => "Y", "EVENT_NAME" => $arStatus["MAIL_EVENT_TYPE"]));
while ($arTemplate = $dbRes->Fetch()) {
CEvent::Send($arTemplate["EVENT_NAME"], $arTemplate["SITE_ID"], $arEventFields, "Y", $arTemplate["ID"]);
}
}
示例13: InstallDB
function InstallDB()
{
global $DB, $APPLICATION;
$this->errors = false;
if (!$DB->Query("SELECT 'x' FROM b_pull_stack", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/pull/install/db/" . strtolower($DB->type) . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("", $this->errors));
return false;
}
RegisterModule("pull");
RegisterModuleDependences("main", "OnProlog", "main", "", "", 3, "/modules/pull/ajax_hit.php");
RegisterModuleDependences("main", "OnEpilog", "pull", "CPullWatch", "DeferredSql");
RegisterModuleDependences("main", "OnEpilog", "pull", "CPullOptions", "OnEpilog");
RegisterModuleDependences("perfmon", "OnGetTableSchema", "pull", "CPullTableSchema", "OnGetTableSchema");
RegisterModuleDependences("main", "OnAfterRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
RegisterModuleDependences("main", "OnAfterUnRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
if (IsModuleInstalled('intranet')) {
RegisterModuleDependences("main", "OnAfterUserAuthorize", "pull", "CPullChannel", "OnAfterUserAuthorize");
RegisterModuleDependences("main", "OnAfterUserLogout", "pull", "CPullChannel", "OnAfterUserLogout");
}
CAgent::AddAgent("CPullOptions::ClearAgent();", "pull", "N", 30, "", "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset() + 30, "FULL"));
return true;
}
示例14: CallBack_AddComment
public static function CallBack_AddComment($arFields)
{
if (!CModule::IncludeModule('blog')) {
return false;
}
$arResult = array();
$arLog = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID", "RATING_ENTITY_ID"))->Fetch();
if ($arLog) {
$arIdeaPost = CBlogPost::GetById($arLog["SOURCE_ID"]);
if ($arIdeaPost) {
$UserIP = CBlogUser::GetUserIP();
$IdeaCommentId = CBlogComment::Add(array("BLOG_ID" => $arIdeaPost["BLOG_ID"], "POST_ID" => $arIdeaPost["ID"], "AUTHOR_ID" => $arFields["USER_ID"], "POST_TEXT" => $arFields["MESSAGE"], "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "PARENT_ID" => false, "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1]));
$arResult = array("SOURCE_ID" => $IdeaCommentId);
if ($arLog["RATING_ENTITY_ID"] > 0) {
$arResult["RATING_TYPE_ID"] = "BLOG_COMMENT";
$arResult["RATING_ENTITY_ID"] = $IdeaCommentId;
}
if (intval($IdeaCommentId) == 0) {
global $APPLICATION;
if ($ex = $APPLICATION->GetException()) {
$arResult["ERROR"] = $ex->GetString();
}
} else {
//clear cache on succcess
BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/first_page/");
BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/pages/");
BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/comment/" . $arIdeaPost["ID"] . "/");
BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/post/" . $arIdeaPost["ID"] . "/");
}
}
}
return $arResult;
}
示例15: InstallDB
function InstallDB()
{
global $DB, $APPLICATION;
$this->errors = false;
if (!$DB->Query("SELECT 'x' FROM b_im_chat", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/im/install/db/" . strtolower($DB->type) . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("", $this->errors));
return false;
}
RegisterModule("im");
RegisterModuleDependences('main', 'OnAddRatingVote', 'im', 'CIMEvent', 'OnAddRatingVote');
RegisterModuleDependences('main', 'OnCancelRatingVote', 'im', 'CIMEvent', 'OnCancelRatingVote');
RegisterModuleDependences('main', 'OnAfterUserUpdate', 'im', 'CIMEvent', 'OnAfterUserUpdate');
RegisterModuleDependences('main', 'OnUserDelete', 'im', 'CIMEvent', 'OnUserDelete');
RegisterModuleDependences("pull", "OnGetDependentModule", "im", "CIMEvent", "OnGetDependentModule");
RegisterModuleDependences("main", "OnProlog", "main", "", "", 3, "/modules/im/ajax_hit.php");
RegisterModuleDependences("perfmon", "OnGetTableSchema", "im", "CIMTableSchema", "OnGetTableSchema");
RegisterModuleDependences("im", "OnGetNotifySchema", "im", "CIMNotifySchema", "OnGetNotifySchema");
RegisterModuleDependences("main", "OnFileDelete", "im", "CIMEvent", "OnFileDelete");
RegisterModuleDependences("main", "OnApplicationsBuildList", "im", "DesktopApplication", "OnApplicationsBuildList");
CAgent::AddAgent("CIMMail::MailNotifyAgent();", "im", "N", 600);
CAgent::AddAgent("CIMMail::MailMessageAgent();", "im", "N", 600);
CAgent::AddAgent("CIMDisk::RemoveTmpFileAgent();", "im", "N", 43200);
CModule::IncludeModule("im");
if (CIMConvert::ConvertCount() > 0) {
Cmodule::IncludeModule("im");
CAdminNotify::Add(array("MESSAGE" => GetMessage("IM_CONVERT_MESSAGE", array("#A_TAG_START#" => '<a href="/bitrix/admin/im_convert.php?lang=' . LANGUAGE_ID . '">', "#A_TAG_END#" => "</a>")), "TAG" => "IM_CONVERT", "MODULE_ID" => "IM", "ENABLE_CLOSE" => "Y"));
CAgent::AddAgent("CIMConvert::UndeliveredMessageAgent();", "im", "N", 20, "", "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset() + 20, "FULL"));
}
return true;
}