Пример #1
0
 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
0
 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
0
 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
0
 /**
  * @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;
 }
 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
0
 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
0
 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
0
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
0
 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
0
	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
0
	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
0
 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
0
 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;
 }
 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
0
 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;
 }
Пример #16
0
	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("perfmon", "OnGetTableSchema", "pull", "CPullTableSchema", "OnGetTableSchema");
		RegisterModuleDependences("main", "OnAfterRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
		RegisterModuleDependences("main", "OnAfterUnRegisterModule", "pull", "CPullOptions", "ClearCheckCache");

		COption::SetOptionString("pull", "path_to_listener", (CMain::IsHTTPS() ? "https" : "http")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/sub/');
		COption::SetOptionString("pull", "path_to_websocket", (CMain::IsHTTPS() ? "wss" : "ws")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/subws/');
		COption::SetOptionString("pull", "path_to_publish", 'http://127.0.0.1:8895/bitrix/pub/');
		COption::SetOptionString("pull", "websocket", 'N');
		COption::SetOptionString("pull", "nginx", 'N');
		COption::SetOptionString("pull", "push", 'N');

		CAgent::AddAgent("CPullOptions::ClearAgent();", "pull", "N", 30, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+30, "FULL"));

		return true;
	}
Пример #17
0
 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;
     }
 }
Пример #18
0
 /**
  * Возвращает список часовых поясов
  * @return array
  */
 protected static function getTimezones()
 {
     if (self::$_timezones === null) {
         $timeZonesList = \CTimeZone::GetZones();
         unset($timeZonesList['']);
         self::$_timezones = $timeZonesList;
     }
     return self::$_timezones;
 }
Пример #19
0
	public static function Get($userId, $reOpen = false)
	{
		global $DB;
		$nginxStatus = CPullOptions::GetNginxStatus();
		$webSocketStatus = CPullOptions::GetWebSocketStatus();

		CTimeZone::Disable();
		$strSql = "
				SELECT CHANNEL_ID, LAST_ID, ".$DB->DateToCharFunction('DATE_CREATE')." DATE_CREATE
				FROM b_pull_channel
				WHERE USER_ID = ".intval($userId);
		CTimeZone::Enable();

		$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		if ($arRes = $dbRes->Fetch())
		{
			if (MakeTimeStamp($arRes['DATE_CREATE'])+43200 > time())
			{
				if ($nginxStatus && $reOpen)
				{
					$arData = Array(
						'module_id' => 'pull',
						'command' => 'reopen',
						'params' => Array(),
					);
					$channelId = $arRes['CHANNEL_ID'];
					$CHTTP = new CHTTP();
					$CHTTP->http_timeout = 10;
					$CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), CUtil::PhpToJsObject(Array('MESSAGE' => Array($arData), 'ERROR' => '')));
				}

				return Array(
					'CHANNEL_ID' => $arRes['CHANNEL_ID'],
					'CHANNEL_DT' => MakeTimeStamp($arRes['DATE_CREATE']),
					'LAST_ID' => intval($arRes['LAST_ID']),
					'PATH' => ($nginxStatus? CPullOptions::GetListenUrl($arRes['CHANNEL_ID']): '/bitrix/components/bitrix/pull.request/ajax.php'),
					'PATH_WS' => ($nginxStatus && $webSocketStatus? CPullOptions::GetWebSocketUrl($arRes['CHANNEL_ID']): ''),
					'METHOD' => ($nginxStatus? 'LONG': 'PULL'),
				);
			}
			else
			{
				self::Delete($arRes['CHANNEL_ID']);
			}
		}

		$channelId = self::Add($userId);
		return $channelId? Array(
			'CHANNEL_ID' => $channelId,
			'CHANNEL_DT' => time(),
			'LAST_ID' => 0,
			'PATH' => ($nginxStatus? CPullOptions::GetListenUrl($channelId): '/bitrix/components/bitrix/pull.request/ajax.php'),
			'PATH_WS' => ($nginxStatus && $webSocketStatus? CPullOptions::GetWebSocketUrl($channelId): ''),
			'METHOD' => ($nginxStatus? 'LONG': 'PULL')
		): false;
	}
Пример #20
0
 public function appendIBlockEntry($url, $modifiedDate, $priority = 0)
 {
     if ($this->isExists()) {
         $this->appendEntry(array('XML_LOC' => $this->settings['PROTOCOL'] . '://' . \CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null) . $url, 'XML_LASTMOD' => date('c', $modifiedDate - \CTimeZone::getOffset()), 'XML_PRIORITY' => $priority ? $priority : self::DEFAULT_PRIORITY));
     } else {
         $this->addHeader();
         $this->addIBlockEntry($url, $modifiedDate, $priority);
         $this->addFooter();
     }
 }
Пример #21
0
 public static function Add($LOG_ID, $GROUP_CODE, $bShare = false, $followSet = true)
 {
     global $DB;
     if (is_array($GROUP_CODE)) {
         foreach ($GROUP_CODE as $GROUP_CODE_TMP) {
             CSocNetLogRights::Add($LOG_ID, $GROUP_CODE_TMP, $bShare, $followSet);
         }
         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), array(), "", true);
         if ($NEW_RIGHT_ID) {
             if (preg_match('/^U(\\d+)$/', $GROUP_CODE, $matches)) {
                 if ($followSet) {
                     CSocNetLogFollow::Set($matches[1], "L" . $LOG_ID, "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
                 }
             } elseif ($bShare && preg_match('/^SG(\\d+)$/', $GROUP_CODE, $matches)) {
                 // get all members who unfollow and set'em unfollow from the date
                 $arUserIDToCheck = array();
                 $rsGroupMembers = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $matches[1], "USER_ACTIVE" => "Y", "<=ROLE" => SONET_ROLES_USER), false, false, array("USER_ID"));
                 while ($arGroupMembers = $rsGroupMembers->Fetch()) {
                     $arUserIDToCheck[] = $arGroupMembers["USER_ID"];
                 }
                 if (!empty($arUserIDToCheck)) {
                     $arUserIDFollowDefault = array("Y" => array(), "N" => array());
                     $arUserIDAlreadySaved = array();
                     $default_follow_type = COption::GetOptionString("socialnetwork", "follow_default_type", "Y");
                     $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arUserIDToCheck, "CODE" => "**"), array("USER_ID", "TYPE"));
                     while ($arFollow = $rsFollow->Fetch()) {
                         $arUserIDFollowDefault[$arFollow["TYPE"]][] = $arFollow["USER_ID"];
                     }
                     $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arUserIDToCheck, "CODE" => "L" . $LOG_ID), array("USER_ID"));
                     while ($arFollow = $rsFollow->Fetch()) {
                         $arUserIDAlreadySaved[] = $arFollow["USER_ID"];
                     }
                     foreach ($arUserIDToCheck as $iUserID) {
                         // for them who not followed by default and not already saved follow/unfollow for the log entry
                         if (!in_array($iUserID, $arUserIDAlreadySaved) && ($default_follow_type == "N" && !in_array($iUserID, $arUserIDFollowDefault["Y"]) || $default_follow_type == "Y" && in_array($iUserID, $arUserIDFollowDefault["N"]))) {
                             CSocNetLogFollow::Add($iUserID, "L" . $LOG_ID, "N", 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;
     }
 }
Пример #22
0
 function _AttemptExists($testID, $attemptID = false)
 {
     $arFields = array("STUDENT_ID" => intval($GLOBALS["USER"]->GetID()), "TEST_ID" => $testID, "STATUS" => array("B", "N"));
     if ($attemptID !== false) {
         $arFields["ID"] = $attemptID;
     }
     CTimeZone::Disable();
     $rsAttempt = CTestAttempt::GetList(array(), $arFields);
     CTimeZone::Enable();
     return $rsAttempt->GetNext();
 }
Пример #23
0
 public static function Enabled()
 {
     if (self::$enabled > 0 && self::Possible()) {
         if (self::$useTimeZones === false) {
             self::$useTimeZones = COption::GetOptionString("main", "use_time_zones", "N");
         }
         if (self::$useTimeZones == "Y") {
             return true;
         }
     }
     return false;
 }
Пример #24
0
 public static function getTimeZoneId($userId = null, $date = null)
 {
     $dateKey = $date === null ? 0 : $date;
     $userIdKey = $userId === null ? 0 : $userId;
     if ($userId === null) {
         $userId = $GLOBALS["USER"]->GetId();
     }
     static $timezoneCache = array();
     if (isset($timezoneCache[$userIdKey]) && isset($timezoneCache[$userIdKey][$dateKey])) {
         return $timezoneCache[$userIdKey][$dateKey];
     }
     $autoTimeZone = $userZone = '';
     $factOffset = 0;
     if ($date === null) {
         $date = time();
     }
     static $userCache = array();
     if ($userId === null) {
         $autoTimeZone = trim($GLOBALS["USER"]->GetParam("AUTO_TIME_ZONE"));
         $userZone = $GLOBALS["USER"]->GetParam("TIME_ZONE");
     } else {
         if (!isset($userCache[$userId])) {
             $dbUser = CUser::GetByID($userId);
             if ($arUser = $dbUser->Fetch()) {
                 $userCache[$userId] = array("AUTO_TIME_ZONE" => trim($arUser["AUTO_TIME_ZONE"]), "TIME_ZONE" => $arUser["TIME_ZONE"], "TIME_ZONE_OFFSET" => $arUser["TIME_ZONE_OFFSET"]);
             }
         }
         if (isset($userCache[$userId])) {
             $autoTimeZone = $userCache[$userId]["AUTO_TIME_ZONE"];
             $userZone = $userCache[$userId]["TIME_ZONE"];
             $factOffset = $userCache[$userId]["TIME_ZONE_OFFSET"];
         }
     }
     if (CTimeZone::IsAutoTimeZone($autoTimeZone)) {
         static $userOffsetCache = array();
         if (!isset($userOffsetCache[$userId === null ? 0 : $userId])) {
             $userOffsetCache[$userIdKey] = CTimeZone::GetOffset($userId);
         }
         $userOffset = $userOffsetCache[$userIdKey];
         $localTime = new DateTime();
         $localOffset = $localTime->getOffset();
         $timezoneCache[$userIdKey][$dateKey] = CDavICalendarTimeZone::getTimezoneByOffset($date, $userOffset + $localOffset);
     } else {
         if ($userZone != '' && isset(self::$arTimeZones[$userZone])) {
             $timezoneCache[$userIdKey][$dateKey] = $userZone;
         } else {
             $localTime = new DateTime();
             $localOffset = $localTime->getOffset();
             $timezoneCache[$userIdKey][$dateKey] = CDavICalendarTimeZone::getTimezoneByOffset($date, $factOffset + $localOffset);
         }
     }
     return $timezoneCache[$userIdKey][$dateKey];
 }
Пример #25
0
 public function SubscribeOnTime($workflowId, $eventName, $expiresAt)
 {
     CTimeZone::Disable();
     $workflowId = preg_replace('#[^a-z0-9.]#i', '', $workflowId);
     $eventName = preg_replace('#[^a-z0-9._-]#i', '', $eventName);
     $minExpiresAt = time() + static::getDelayMinLimit(false);
     if ($minExpiresAt > $expiresAt) {
         $expiresAt = $minExpiresAt;
     }
     $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;
 }
Пример #26
0
 function GetNextStartDate($CHANNEL_ID)
 {
     global $DB;
     $err_mess = CVote::err_mess() . "<br>Function: GetNextStartDate<br>Line: ";
     $CHANNEL_ID = intval($CHANNEL_ID);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\t" . $DB->DateToCharFunction("max(DATE_ADD(DATE_END, INTERVAL 1 SECOND))") . " MIN_DATE_START\n\t\t\tFROM\n\t\t\t\tb_vote\n\t\t\tWHERE\n\t\t\t\tCHANNEL_ID = '{$CHANNEL_ID}'\n\t\t\t";
     $z = $DB->Query($strSql, false, $err_mess . __LINE__);
     $zr = $z->Fetch();
     if (strlen($zr["MIN_DATE_START"]) <= 0) {
         return GetTime(time() + CTimeZone::GetOffset(), "FULL");
     } else {
         return $zr["MIN_DATE_START"];
     }
 }
Пример #27
0
 function checkAction($event)
 {
     $arActionID = array();
     $rsTriggers = CFTrigger::GetList($by = "s_today_hits", $order = "desc", array("EVENT_ID" => $event["ID"]));
     while ($arTrigger = $rsTriggers->GetNext()) {
         $TriggerList[] = $arTrigger;
         $returnValue = unserialize(base64_decode($arTrigger["ACTION_ID"]));
         if (is_array($returnValue)) {
             $arActionID = array_merge($returnValue, $arActionID);
         } else {
             $arActionID[] = $arTrigger["ACTION_ID"];
         }
         $TriggerActionList[$arTrigger["ID"]][] = $returnValue;
     }
     if (!empty($arActionID)) {
         $ActionTypesID = array();
         $rsActions = CFTriggerActions::GetList($order, $by, array("ID" => $arActionID));
         while ($arAction = $rsActions->GetNext()) {
             $ActionList[$arAction["ID"]] = $arAction;
         }
         $rsActionTypes = CFTriggerActionTypes::GetList();
         while ($arActionType = $rsActionTypes->GetNext()) {
             $arActionTypeList[$arActionType["ID"]] = $arActionType["CODE"];
         }
         if (!empty($ActionList)) {
             foreach ($TriggerActionList as $key => $triggerAction) {
                 foreach ($triggerAction as $actionID) {
                     if (is_array($actionID)) {
                         foreach ($actionID as $k => $value) {
                             if (intval($ActionList[$value]["ACTION_TYPE"]) > 0 && isset($arActionTypeList[$ActionList[$value]["ACTION_TYPE"]])) {
                                 //Проверяем и выполняем действие
                                 CFoodclubEventDoAction::doAction(array("ID" => $ActionList[$value]["ID"], "NAME" => $ActionList[$value]["NAME"], "ACTION_TYPE" => $ActionList[$value]["ACTION_TYPE"], "ACTION_CODE" => $arActionTypeList[$ActionList[$value]["ACTION_TYPE"]], "ADDITIONAL_PROPS" => $ActionList[$value]["ADDITIONAL_PROPS"], "BODY_PARAMS" => $ActionList[$value]["BODY_PARAMS"]));
                                 //Заносим в журнал
                                 CFTriggerLog::Add(array("NAME" => $ActionList[$value]["NAME"], "TRIGGER_ID" => $key, "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "CREATED_BY" => CUser::GetID()));
                             }
                         }
                     } else {
                         if (intval($ActionList[$actionID]["ACTION_TYPE"]) > 0 && isset($arActionTypeList[$ActionList[$actionID]["ACTION_TYPE"]])) {
                             //Проверяем и выполняем действие
                             CFoodclubEventDoAction::doAction(array("ID" => $ActionList[$actionID]["ID"], "NAME" => $ActionList[$actionID]["NAME"], "ACTION_TYPE" => $ActionList[$actionID]["ACTION_TYPE"], "ACTION_CODE" => $arActionTypeList[$ActionList[$actionID]["ACTION_TYPE"]], "ADDITIONAL_PROPS" => $ActionList[$actionID]["ADDITIONAL_PROPS"], "BODY_PARAMS" => $ActionList[$actionID]["BODY_PARAMS"]));
                             //Заносим в журнал
                             CFTriggerLog::Add(array("NAME" => $ActionList[$actionID]["NAME"], "TRIGGER_ID" => $key, "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "CREATED_BY" => CUser::GetID()));
                         }
                     }
                 }
             }
         }
     }
 }
Пример #28
0
 /**
  * Creates new section in iblock
  * @param $arParams
  * @param $arResult
  * @param $name
  * @return bool|int
  */
 public static function createAlbum($arParams, $arResult, &$name)
 {
     if (!CModule::IncludeModule("iblock")) {
         return false;
     }
     $name = trim($name);
     $name = strlen($name) > 0 ? $name : GetMessage("P_NEW_ALBUM");
     $name = strlen($name) > 0 ? $name : "New album";
     $arFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $arParams["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $arParams["BEHAVIOUR"] == "USER" ? $arResult["GALLERY"]["ID"] : 0, "DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "UF_DATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset()), "NAME" => $name);
     $GLOBALS["UF_DATE"] = $arFields["UF_DATE"];
     $bs = new CIBlockSection();
     $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arFields);
     $ID = $bs->Add($arFields);
     if ($ID > 0) {
         CIBlockSection::ReSort($arParams["IBLOCK_ID"]);
         $arPropertiesNeed = array();
         // Array of properties to create
         foreach ($arParams['converters'] as $val) {
             if ($val['code'] == "real_picture" || $val['code'] == "thumbnail") {
                 continue;
             }
             $db_res = CIBlock::GetProperties($arParams["IBLOCK_ID"], array(), array("CODE" => $val['code']));
             if (!($db_res && ($res = $db_res->Fetch()))) {
                 $arPropertiesNeed[] = $val['code'];
             }
         }
         if (count($arPropertiesNeed) > 0) {
             $obProperty = new CIBlockProperty();
             foreach ($arPropertiesNeed as $key) {
                 $res = $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "F", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_" . strToUpper($key))) > 0 ? GetMessage("P_" . strToUpper($key)) : strToUpper($key), "CODE" => strToUpper($key), "FILE_TYPE" => "jpg, gif, bmp, png, jpeg"));
             }
         }
         // Check Public property
         $arPropertiesNeed = array();
         foreach (array("PUBLIC_ELEMENT", "APPROVE_ELEMENT") as $key) {
             $db_res = CIBlock::GetProperties($arParams["IBLOCK_ID"], array(), array("CODE" => $key));
             if (!$db_res || !($res = $db_res->Fetch())) {
                 $arPropertiesNeed[] = $key;
             }
         }
         if (count($arPropertiesNeed) > 0) {
             $obProperty = new CIBlockProperty();
             foreach ($arPropertiesNeed as $key) {
                 $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "S", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_" . $key)) > 0 ? GetMessage("P_" . $key) : $key, "DEFAULT_VALUE" => "N", "CODE" => $key));
             }
         }
     }
     return $ID > 0 ? $ID : false;
 }
Пример #29
0
 function GetEditFormHTML($arUserField, $arHtmlControl)
 {
     $arHtmlControl["VALIGN"] = "middle";
     if ($arUserField["EDIT_IN_LIST"] == "Y") {
         if ($arUserField["ENTITY_VALUE_ID"] < 1 && $arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
             if ($arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
                 $arHtmlControl["VALUE"] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
             } else {
                 $arHtmlControl["VALUE"] = str_replace(" 00:00:00", "", CDatabase::FormatDate($arUserField["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL")));
             }
         }
         return CAdminCalendar::CalendarDate($arHtmlControl["NAME"], $arHtmlControl["VALUE"], 20, true);
     } elseif (strlen($arHtmlControl["VALUE"]) > 0) {
         return $arHtmlControl["VALUE"];
     } else {
         return '&nbsp;';
     }
 }
Пример #30
0
 public static function Update($params)
 {
     if (isset($params['DATE_CREATE'])) {
         $params['DATE_CREATE'] = $params['DATE_CREATE'] ? ConvertTimeStamp($params['DATE_CREATE'] + CTimeZone::GetOffset() + date("Z"), 'SHORT') : '';
         COption::SetOptionString("voximplant", "phone_order_date_create", $params['DATE_CREATE']);
     }
     if (isset($params['DATE_MODIFY'])) {
         $params['DATE_MODIFY'] = $params['DATE_MODIFY'] ? ConvertTimeStamp($params['DATE_MODIFY'] + CTimeZone::GetOffset() + date("Z"), 'SHORT') : '';
         COption::SetOptionString("voximplant", "phone_order_date_modify", $params['DATE_MODIFY']);
     }
     if (isset($params['OPERATOR_STATUS'])) {
         COption::SetOptionString("voximplant", "phone_order_operator_status", $params['OPERATOR_STATUS']);
     }
     if (isset($params['OPERATOR_CONTRACT'])) {
         COption::SetOptionString("voximplant", "phone_order_operator_contract", $params['OPERATOR_CONTRACT']);
     }
     return false;
 }