Example #1
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $APPLICATION;
     $errors = null;
     if (CModule::IncludeModule("socialnetwork")) {
         $dbLog = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => array("R", "T"), "EVENT_ID" => array("timeman_entry", "report")), false, false, array("ID"));
         while ($arLog = $dbLog->Fetch()) {
             CSocNetLog::Delete($arLog["ID"]);
         }
     }
     if (true == array_key_exists("savedata", $arParams) && $arParams["savedata"] != 'Y') {
         $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/' . $this->MODULE_ID . '/install/db/' . strtolower($DB->type) . '/uninstall.sql');
         if (!empty($errors)) {
             $APPLICATION->ThrowException(implode("", $errors));
             return false;
         }
         $this->UnInstallTasks();
     }
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogEvents', 'timeman', 'CReportNotifications', 'AddEvent');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetAllowedSubscribeEntityTypes', 'timeman', 'CReportNotifications', 'OnFillSocNetAllowedSubscribeEntityTypes');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogEvents', 'timeman', 'CTimeManNotify', 'OnFillSocNetLogEvents');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetAllowedSubscribeEntityTypes', 'timeman', 'CTimeManNotify', 'OnFillSocNetAllowedSubscribeEntityTypes');
     UnRegisterModuleDependences("im", "OnGetNotifySchema", "timeman", "CTimemanNotifySchema", "OnGetNotifySchema");
     UnRegisterModuleDependences('main', 'OnAfterUserUpdate', 'timeman', 'CTimeManNotify', 'OnAfterUserUpdate');
     UnRegisterModuleDependences('main', 'OnAfterUserUpdate', 'timeman', 'CReportNotifications', 'OnAfterUserUpdate');
     UnRegisterModule($this->MODULE_ID);
     return true;
 }
Example #2
0
 public function OnAfterIBlockElementDelete($fields)
 {
     $errors = array();
     if (Loader::includeModule('socialnetwork')) {
         $states = CBPStateService::getDocumentStates(array('lists', 'BizprocDocument', $fields['ID']));
         foreach ($states as $workflowId => $state) {
             $sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
             $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID'));
             while ($log = $resultQuery->fetch()) {
                 CSocNetLog::Delete($log['ID']);
             }
         }
     }
     CBPDocument::OnDocumentDelete(array('lists', 'BizprocDocument', $fields['ID']), $errors);
 }
Example #3
0
 public static function DeleteLogEvents($params, $options = array())
 {
     if (!CModule::IncludeModule('socialnetwork')) {
         return false;
     }
     $entityTypeID = isset($params['ENTITY_TYPE_ID']) ? intval($params['ENTITY_TYPE_ID']) : CCrmOwnerType::Undefined;
     $liveFeedEntityType = CCrmLiveFeedEntity::GetByEntityTypeID($entityTypeID);
     if ($liveFeedEntityType === CCrmLiveFeedEntity::Undefined) {
         return false;
     }
     $entityID = isset($params['ENTITY_ID']) ? intval($params['ENTITY_ID']) : 0;
     if ($entityID <= 0) {
         return false;
     }
     $dbRes = CSocNetLog::GetList(array('ID' => 'DESC'), array('ENTITY_TYPE' => $liveFeedEntityType, 'ENTITY_ID' => $entityID), false, false, array('ID'));
     while ($arRes = $dbRes->Fetch()) {
         CSocNetLog::Delete($arRes['ID']);
     }
     if (!is_array($options)) {
         $options = array();
     }
     $unregisterRelation = !(isset($options['UNREGISTER_RELATION']) && $options['UNREGISTER_RELATION'] === false);
     if ($unregisterRelation) {
         CCrmSonetRelation::UnRegisterRelationsByEntity($entityTypeID, $entityID);
     }
 }
Example #4
0
 private function RemoveMessage($MessageId = false)
 {
     $arNotification = $this->Notify->getNotification();
     
     //Remove comments
     $oComment = CBlogComment::GetList(
         array(), 
         array(
             "POST_ID" => $MessageId?$MessageId:$arNotification["ID"], 
         ),
         false,
         false,
         array("ID")
     );
     while ($arComment = $oComment->Fetch())
         $this->RemoveComment($arComment["ID"]);
     
     //Remove message
     $oLogMessage = CSocNetLog::GetList(            
         array("ID" => "DESC"),
         array("SOURCE_ID" => $MessageId?$MessageId:$arNotification["ID"]),
         false,
         false,
         array("ID")
     );
     while($arLogMessage = $oLogMessage->Fetch())
         CSocNetLog::Delete($arLogMessage["ID"]);
 }
Example #5
0
 public function OnAfterPhotoCommentDeleteBlog($ID)
 {
     if (!$this->IsSocnet) {
         return;
     }
     if (intval($ID) > 0) {
         $dbRes = CSocNetLogComments::GetList(array("ID" => "DESC"), array("EVENT_ID" => "photo_comment", "SOURCE_ID" => $ID), false, false, array("ID", "LOG_ID"));
         if ($arRes = $dbRes->Fetch()) {
             $res = CSocNetLogComments::Delete($arRes["ID"]);
             if ($res) {
                 $dbResult = CSocNetLog::GetList(array(), array("ID" => $arRes["LOG_ID"]), false, false, array("ID", "COMMENTS_COUNT"));
                 if ($arLog = $dbResult->Fetch()) {
                     if ($arLog["COMMENTS_COUNT"] == 0) {
                         CSocNetLog::Delete($arRes["LOG_ID"]);
                     }
                 }
             }
         }
     }
 }
Example #6
0
 public static function OnDeleteCalendarEventEntry($eventId, $arFields = array())
 {
     if (CModule::IncludeModule("socialnetwork")) {
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "calendar", "SOURCE_ID" => $eventId), false, false, array("ID"));
         while ($arRes = $dbRes->Fetch()) {
             CSocNetLog::Delete($arRes["ID"]);
         }
     }
 }
Example #7
0
     case "DELETE":
         $arLogID = array();
         foreach ($arTopic as $topic_id_tmp) {
             // delete message log records
             $dbForumMessage = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $topic_id_tmp));
             while ($arForumMessage = $dbForumMessage->Fetch()) {
                 $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "forum", "SOURCE_ID" => $arForumMessage["ID"]), false, false, array("ID", "PARAMS"));
                 while ($arRes = $dbRes->Fetch()) {
                     $arLogID[] = $arRes["ID"];
                 }
             }
         }
         $result = ForumDeleteTopic($arTopic, $strErrorMessage, $strOkMessage, array("PERMISSION" => $arParams["PERMISSION"]));
         if ($result) {
             foreach ($arLogID as $log_id) {
                 CSocNetLog::Delete($log_id);
             }
         }
         break;
     case "STATE_Y":
     case "STATE_N":
     case "CLOSE":
     case "OPEN":
         $ACTION = $ACTION == "STATE_Y" ? "OPEN" : ($ACTION == "STATE_N" ? "CLOSE" : $ACTION);
         $state = $ACTION == "OPEN" ? "Y" : "N";
         $result = ForumOpenCloseTopic($arTopic, $ACTION, $strErrorMessage, $strOkMessage, array("PERMISSION" => $arParams["PERMISSION"]));
         break;
     default:
         $arError[] = array("id" => "bad action", "text" => $ACTION);
         break;
 }
Example #8
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
         $rsUserType = CUserTypeEntity::getList(array(), array('ENTITY_ID' => 'TASKS_TASK', 'FIELD_NAME' => 'UF_TASK_WEBDAV_FILES'));
         if ($arUserType = $rsUserType->fetch()) {
             $obUserField = new CUserTypeEntity();
             $obUserField->Delete($arUserType['ID']);
         }
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/tasks/install/db/" . strtolower($DB->type) . "/uninstall.sql");
     }
     //delete agents
     CAgent::RemoveModuleAgents("tasks");
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("tasks");
     }
     UnRegisterModule("tasks");
     UnRegisterModuleDependences("search", "OnReindex", "tasks", "CTasks", "OnSearchReindex");
     UnRegisterModuleDependences("main", "OnUserDelete", "tasks", "CTasks", "OnUserDelete");
     UnRegisterModuleDependences("im", "OnGetNotifySchema", "tasks", "CTasksNotifySchema", "OnGetNotifySchema");
     UnRegisterModuleDependences('main', 'OnBeforeUserDelete', 'tasks', 'CTasks', 'OnBeforeUserDelete');
     UnRegisterModuleDependences("pull", "OnGetDependentModule", "tasks", "CTasksPullSchema", "OnGetDependentModule");
     UnRegisterModuleDependences('search', 'BeforeIndex', 'tasks', 'CTasksTools', 'FixForumCommentURL');
     UnRegisterModuleDependences('intranet', 'OnPlannerInit', 'tasks', 'CTaskPlannerMaintance', 'OnPlannerInit');
     UnRegisterModuleDependences('intranet', 'OnPlannerAction', 'tasks', 'CTaskPlannerMaintance', 'OnPlannerAction');
     UnRegisterModuleDependences('rest', 'OnRestServiceBuildDescription', 'tasks', 'CTaskRestService', 'OnRestServiceBuildDescription');
     UnRegisterModuleDependences('forum', 'OnCommentTopicAdd', 'tasks', 'CTaskComments', 'onCommentTopicAdd');
     UnRegisterModuleDependences('forum', 'OnAfterCommentTopicAdd', 'tasks', 'CTaskComments', 'onAfterCommentTopicAdd');
     UnRegisterModuleDependences('forum', 'OnAfterCommentAdd', 'tasks', 'CTaskComments', 'onAfterCommentAdd');
     UnRegisterModuleDependences('forum', 'OnAfterCommentUpdate', 'tasks', 'CTaskComments', 'onAfterCommentUpdate');
     UnRegisterModuleDependences('forum', 'OnModuleUnInstall', 'tasks', 'CTasksRarelyTools', 'onForumUninstall');
     UnRegisterModuleDependences('webdav', 'OnModuleUnInstall', 'tasks', 'CTasksRarelyTools', 'onWebdavUninstall');
     UnRegisterModuleDependences('intranet', 'OnModuleUnInstall', 'tasks', 'CTasksRarelyTools', 'onIntranetUninstall');
     UnRegisterModuleDependences('timeman', 'OnAfterTMDayStart', 'tasks', 'CTaskPlannerMaintance', 'OnAfterTMDayStart');
     UnRegisterModuleDependences('timeman', 'OnAfterTMDayStart', 'tasks', 'CTaskCountersNotifier', 'onAfterTimeManagerDayStart');
     UnRegisterModuleDependences('timeman', 'OnAfterTMEntryUpdate', 'tasks', 'CTaskTimerManager', 'onAfterTMEntryUpdate');
     UnRegisterModuleDependences('tasks', 'OnBeforeTaskUpdate', 'tasks', 'CTaskTimerManager', 'onBeforeTaskUpdate');
     UnRegisterModuleDependences('tasks', 'OnBeforeTaskDelete', 'tasks', 'CTaskTimerManager', 'onBeforeTaskDelete');
     UnRegisterModuleDependences('socialnetwork', 'OnBeforeSocNetGroupDelete', 'tasks', 'CTasks', 'onBeforeSocNetGroupDelete');
     UnRegisterModuleDependences("main", "OnAfterRegisterModule", "main", "tasks", "InstallUserFields", "/modules/tasks/install/index.php");
     // check webdav UF
     UnRegisterModuleDependences("main", "OnBeforeUserTypeAdd", "tasks", "CTasksRarelyTools", "onBeforeUserTypeAdd");
     UnRegisterModuleDependences("main", "OnBeforeUserTypeUpdate", "tasks", "CTasksRarelyTools", "onBeforeUserTypeUpdate");
     UnRegisterModuleDependences("main", "OnBeforeUserTypeDelete", "tasks", "CTasksRarelyTools", "onBeforeUserTypeDelete");
     // im "ilike"
     UnRegisterModuleDependences("main", "OnGetRatingContentOwner", "tasks", "CTaskNotifications", "OnGetRatingContentOwner");
     UnRegisterModuleDependences("im", "OnGetMessageRatingVote", "tasks", "CTaskNotifications", "OnGetMessageRatingVote");
     if ((!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") && IsModuleInstalled('socialnetwork') && CModule::IncludeModule('socialnetwork')) {
         $dbRes = CSocNetLog::GetList(array(), array("EVENT_ID" => "tasks"), false, false, array("ID"));
         if ($dbRes) {
             while ($arRes = $dbRes->Fetch()) {
                 CSocNetLog::Delete($arRes["ID"]);
             }
         }
     }
     // Remove tasks from IM
     if (IsModuleInstalled('im') && CModule::IncludeModule('im')) {
         if (method_exists('CIMNotify', 'DeleteByModule')) {
             CIMNotify::DeleteByModule('tasks');
         }
     }
     // remove comment edit flags
     COption::RemoveOption('tasks', 'task_comment_allow_edit', '');
     COption::RemoveOption('tasks', 'task_comment_allow_remove', '');
     return true;
 }
Example #9
0
 function DeleteLog($postID, $bMicroblog = false)
 {
     if (!CModule::IncludeModule('socialnetwork')) {
         return;
     }
     $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $postID), false, false, array("ID"));
     while ($arComment = $dbComment->Fetch()) {
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_comment", "blog_comment_micro"), "SOURCE_ID" => $arComment["ID"]), false, false, array("ID"));
         while ($arRes = $dbRes->Fetch()) {
             CSocNetLog::Delete($arRes["ID"]);
         }
     }
     $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post_micro", "blog_post"), "SOURCE_ID" => $postID), false, false, array("ID"));
     while ($arRes = $dbRes->Fetch()) {
         CSocNetLog::Delete($arRes["ID"]);
     }
 }
Example #10
0
 function SendDeleteMessage($arFields)
 {
     global $USER;
     $cacheWasEnabled = CTaskNotifications::enableStaticCache();
     $arRecipientsIDs = CTaskNotifications::GetRecipientsIDs($arFields);
     if (sizeof($arRecipientsIDs) && (is_object($USER) && $USER->GetID() || $arFields["CREATED_BY"])) {
         $occurAsUserId = CTasksTools::getOccurAsUserId();
         if (!$occurAsUserId) {
             $occurAsUserId = is_object($USER) && $USER->GetID() ? $USER->GetID() : $arFields["CREATED_BY"];
         }
         $messageInstant = str_replace("#TASK_TITLE#", self::formatTaskName($arFields['ID'], $arFields['TITLE'], $arFields['GROUP_ID'], false), self::getGenderMessage($occurAsUserId, 'TASKS_TASK_DELETED_MESSAGE'));
         CTaskNotifications::sendMessageEx($arFields["ID"], $occurAsUserId, $arRecipientsIDs, array('INSTANT' => $messageInstant, 'PUSH' => CTaskNotifications::makePushMessage('TASKS_TASK_DELETED_MESSAGE', $occurAsUserId, $arFields)), array('EVENT_DATA' => array('ACTION' => 'TASK_DELETE', 'arFields' => $arFields)));
         /*
         CTaskNotifications::SendMessage($occurAsUserId, $arRecipientsIDs, 
         	$message, $arFields['ID'], null,
         	array(
         		'ACTION'   => 'TASK_DELETE',
         		'arFields' => $arFields
         	)
         );
         */
     }
     // sonet log
     if (CModule::IncludeModule("socialnetwork")) {
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arFields["ID"]), false, false, array("ID"));
         while ($arRes = $dbRes->Fetch()) {
             CSocNetLog::Delete($arRes["ID"]);
         }
     }
     if ($cacheWasEnabled) {
         CTaskNotifications::disableStaticCache();
     }
 }
Example #11
0
}
$SocNetGroupID = false;
$db_blog_group = CBlogGroup::GetList(array("ID" => "ASC"), array("SITE_ID" => WIZARD_SITE_ID, "NAME" => "[" . WIZARD_SITE_ID . "] " . GetMessage("BLOG_DEMO_GROUP_SOCNET")));
if ($res_blog_group = $db_blog_group->Fetch()) {
    $SocNetGroupID = $res_blog_group["ID"];
    if (WIZARD_INSTALL_DEMO_DATA) {
        $db_blog = CBlog::GetList(array(), array("GROUP_ID" => $res_blog_group["ID"]), false, false, array("ID"));
        if ($res_blog = $db_blog->Fetch()) {
            do {
                CBlog::Delete($res_blog["ID"]);
            } while ($res_blog = $db_blog->Fetch());
        }
        if (CModule::IncludeModule("socialnetwork")) {
            $db_log = CSocNetLog::GetList(array("ID" => "DESC"), array("SITE_ID" => WIZARD_SITE_ID, "EVENT_ID" => array("blog", "blog_post", "blog_comment")), false, false, array("ID"));
            while ($arLog = $db_log->Fetch()) {
                CSocNetLog::Delete($arLog["ID"]);
            }
        }
        BXClearCache(True, "/" . WIZARD_SITE_ID . "/blog/");
    } else {
        CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/_index.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
        CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/index.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
        CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/people/user.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
        CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/groups/group.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
        CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/blogs/index.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
        return;
    }
}
COption::SetOptionString('blog', 'avatar_max_size', '30000');
COption::SetOptionString('blog', 'avatar_max_width', '100');
COption::SetOptionString('blog', 'avatar_max_height', '100');
Example #12
0
 public function SocnetLogFileDelete($arParams)
 {
     if ($arLog = $this->GetSocnetLogByFileID($arParams["ELEMENT"]["id"], $this->event_id)) {
         CSocNetLog::Delete($arLog['ID']);
     }
 }
Example #13
0
        $arLogComments[] = $arLog;
    }
    foreach ($arLogComments as $arLogComment) {
        if (intval($arLogComment["SOURCE_ID"]) > 0) {
            $log_tmp_id = false;
            $arBlogComment = CBlogComment::GetByID($arLogComment["SOURCE_ID"]);
            if ($arBlogComment) {
                $dbLog = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "blog_post", "SOURCE_ID" => $arBlogComment["POST_ID"]), false, array("nTopCount" => 1), array("ID", "TMP_ID"));
                if ($arLog = $dbLog->Fetch()) {
                    $log_tmp_id = $arLog["TMP_ID"];
                }
            }
            if (intval($log_tmp_id) > 0) {
                $arFields = array("ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => "blog_comment", "LOG_DATE" => $arLogComment["LOG_DATE"], "MESSAGE" => $arLogComment["MESSAGE"], "TEXT_MESSAGE" => $arLogComment["TEXT_MESSAGE"], "URL" => $arLogComment["URL"], "MODULE_ID" => false, "SOURCE_ID" => $arLogComment["SOURCE_ID"], "LOG_ID" => $log_tmp_id, "USER_ID" => $arLogComment["USER_ID"]);
                CSocNetLogComments::Add($arFields, false, false, false);
                CSocNetLog::Delete($arLogComment["ID"]);
            }
        }
    }
}
$dbLog = CSocNetLog::GetList(array("LOG_DATE" => "ASC"), array("COMMENTS_COUNT" => false), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "SOURCE_ID", "USER_ID"));
while ($arLog = $dbLog->Fetch()) {
    CSocNetLog::Update($arLog["ID"], array("LOG_UPDATE" => $arLog["LOG_DATE"]));
}
if (IsModuleInstalled("intranet")) {
    $dbResult = CSocNetEventUserView::GetList(array("ENTITY_ID" => "ASC"), array("ENTITY_TYPE" => "N"));
    $arResult = $dbResult->Fetch();
    if (!$arResult) {
        CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
        CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news_comment", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
    }
Example #14
0
 function SendDeleteMessage($arFields)
 {
     global $USER;
     $arRecipientsIDs = CTaskNotifications::GetRecipientsIDs($arFields);
     if (sizeof($arRecipientsIDs) && (is_object($USER) && $USER->GetID() || $arFields["CREATED_BY"])) {
         $message = str_replace("#TASK_TITLE#", self::formatTaskName($arFields['ID'], $arFields['TITLE'], $arFields['GROUP_ID']), GetMessage("TASKS_TASK_DELETED_MESSAGE"));
         $occurAsUserId = CTasksTools::getOccurAsUserId();
         if (!$occurAsUserId) {
             $occurAsUserId = is_object($USER) && $USER->GetID() ? $USER->GetID() : $arFields["CREATED_BY"];
         }
         CTaskNotifications::SendMessage($occurAsUserId, $arRecipientsIDs, $message, 0, null, array('ACTION' => 'TASK_DELETE', 'arFields' => $arFields));
     }
     // sonet log
     if (CModule::IncludeModule("socialnetwork")) {
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arFields["ID"]), false, false, array("ID"));
         while ($arRes = $dbRes->Fetch()) {
             CSocNetLog::Delete($arRes["ID"]);
         }
     }
 }
Example #15
0
 function OnUserDelete($USER_ID)
 {
     $arIBlockList = array('iblock_absence', 'iblock_honour', 'iblock_state_history');
     foreach ($arIBlockList as $var_name) {
         $IBLOCK_ID = COption::GetOptionInt('intranet', $var_name);
         if ($IBLOCK_ID > 0) {
             $dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $IBLOCK_ID, 'PROPERTY_USER' => $USER_ID), false, false, array('ID', 'IBLOCK_ID'));
             while ($arRes = $dbRes->Fetch()) {
                 CIBlockElement::Delete($arRes['ID']);
             }
         }
     }
     if (CModule::IncludeModule('socialnetwork')) {
         $dbRes = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => SONET_INTRANET_NEW_USER_ENTITY, 'EVENT_ID' => SONET_INTRANET_NEW_USER_EVENT_ID, 'ENTITY_ID' => $USER_ID, 'SOURCE_ID' => $USER_ID), false, array('ID'));
         $arRes = $dbRes->Fetch();
         if ($arRes) {
             CSocNetLog::Delete($arRes['ID']);
         }
     }
     if (CModule::IncludeModule('iblock')) {
         $IBLOCK_ID = COption::GetOptionInt('intranet', 'iblock_structure');
         if ($IBLOCK_ID > 0) {
             $dbRes = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $IBLOCK_ID, 'UF_HEAD' => $USER_ID), false, array('ID', 'IBLOCK_ID'));
             $obSection = new CIBlockSection();
             while ($arRes = $dbRes->Fetch()) {
                 $obSection->Update($arRes['ID'], array('UF_HEAD' => ''));
             }
         }
     }
 }
Example #16
0
 function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "")
 {
     global $DB;
     $arResult = array();
     //CBlogSearch::Trace('OnSearchReindex', 'NS', $NS);
     if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) {
         $category = substr($NS["ID"], 0, 1);
         $id = intval(substr($NS["ID"], 1));
     } else {
         $category = 'B';
         //start with blogs
         $id = 0;
         //very first id
     }
     //CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id));
     //Reindex blogs
     if ($category == 'B') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             if ($ar["USE_SOCNET"] == "Y") {
                 $Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => "");
             } else {
                 //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
                 $arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
                 //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
                 $Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2));
                 //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
             }
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         //all blogs indexed so let's start index posts
         $category = 'P';
         $id = 0;
     }
     if ($category == 'P') {
         $arUser2Blog = array();
         if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
             $dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID"));
             while ($arB = $dbB->Fetch()) {
                 $arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"];
             }
         }
         $bSonet = false;
         if (IsModuleInstalled("socialnetwork")) {
             $bSonet = true;
         }
         $parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/");
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t";
         /*		AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/
         //AND b.SEARCH_INDEX = 'Y'
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             //Check permissions
             $tag = "";
             if ($ar["USE_SOCNET"] != "Y") {
                 $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST);
                 if ($PostPerms < BLOG_PERMS_READ) {
                     continue;
                 }
             }
             //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
             if (strlen($ar["PATH"]) > 0) {
                 $arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"]));
             } else {
                 $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
             }
             if (strlen($ar["CATEGORY_ID"]) > 0) {
                 $arC = explode(",", $ar["CATEGORY_ID"]);
                 $tag = "";
                 $arTag = array();
                 foreach ($arC as $v) {
                     $arCategory = CBlogCategory::GetByID($v);
                     $arTag[] = $arCategory["NAME"];
                 }
                 $tag = implode(",", $arTag);
             }
             //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
             $Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]);
             if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) {
                 $arF = array();
                 if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
                     if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) {
                         $newBlogId = 0;
                         if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
                             $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
                         } else {
                             $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                             $bRights = false;
                             $rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
                             $arUser = $rsUser->Fetch();
                             if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                                 $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                             } else {
                                 $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                             }
                             $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"];
                             $arFields["OWNER_ID"] = $ar["AUTHOR_ID"];
                             $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                             if ($urlCheck != $arFields["URL"]) {
                                 $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"];
                             }
                             if (CBlog::GetByUrl($arFields["URL"])) {
                                 $uind = 0;
                                 do {
                                     $uind++;
                                     $arFields["URL"] = $arFields["URL"] . $uind;
                                 } while (CBlog::GetByUrl($arFields["URL"]));
                             }
                             $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post");
                             if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                                 $bRights = true;
                             }
                             $blogID = CBlog::Add($arFields);
                             if ($bRights) {
                                 CBlog::AddSocnetRead($blogID);
                             }
                             $newBlogId = $blogID;
                             $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId;
                         }
                         if (intVal($newBlogId) > 0) {
                             $arF = array("BLOG_ID" => $newBlogId, "SOCNET_RIGHTS" => array("SG" . $ar["SOCNET_GROUP_ID"]));
                         }
                         if (IntVal($ar["SLID"]) > 0) {
                             CSocNetLog::Delete($ar["SLID"]);
                             $ar["SLID"] = 0;
                         }
                         $arSites = array();
                         $rsGroupSite = CSocNetGroup::GetSite($ar["SOCNET_GROUP_ID"]);
                         while ($arGroupSite = $rsGroupSite->Fetch()) {
                             $arSites[] = $arGroupSite["LID"];
                         }
                     } else {
                         $newBlogId = 0;
                         if ($ar["OWNER_ID"] != $ar["AUTHOR_ID"]) {
                             if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
                                 $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
                             } else {
                                 $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                                 $bRights = false;
                                 $rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
                                 $arUser = $rsUser->Fetch();
                                 if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                                 } else {
                                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                                 }
                                 $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"];
                                 $arFields["OWNER_ID"] = $ar["AUTHOR_ID"];
                                 $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                                 if ($urlCheck != $arFields["URL"]) {
                                     $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"];
                                 }
                                 if (CBlog::GetByUrl($arFields["URL"])) {
                                     $uind = 0;
                                     do {
                                         $uind++;
                                         $arFields["URL"] = $arFields["URL"] . $uind;
                                     } while (CBlog::GetByUrl($arFields["URL"]));
                                 }
                                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post");
                                 if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                                     $bRights = true;
                                 }
                                 $blogID = CBlog::Add($arFields);
                                 if ($bRights) {
                                     CBlog::AddSocnetRead($blogID);
                                 }
                                 $newBlogId = $blogID;
                                 $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId;
                             }
                             if (IntVal($ar["SLID"]) > 0) {
                                 CSocNetLog::Delete($ar["SLID"]);
                                 $ar["SLID"] = 0;
                             }
                         }
                         $arF = array("SOCNET_RIGHTS" => array());
                         if (intVal($newBlogId) > 0) {
                             $arF["BLOG_ID"] = $newBlogId;
                         }
                         $arSites = array($ar["SITE_ID"]);
                     }
                     if (!empty($arF)) {
                         if (IntVal($arF["BLOG_ID"]) > 0) {
                             $Result["PARAM2"] = $ar["BLOG_ID"];
                             $sqlR = "UPDATE b_blog_post SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_post_category SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_image SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_comment SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         }
                         $sqlR = "SELECT * FROM b_blog_socnet_rights where POST_ID=" . IntVal($ar["ID"]);
                         $dbBB = $DB->Query($sqlR);
                         if (!$dbBB->Fetch()) {
                             $arF["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ar["ID"], $arF["SOCNET_RIGHTS"], array("AUTHOR_ID" => $ar["AUTHOR_ID"]));
                         }
                         if (IntVal($arF["BLOG_ID"]) > 0 && $ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                             $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $ar["ID"]), false, false, array("ID", "POST_ID", "BLOG_ID", "PATH"));
                             if ($arComment = $dbComment->Fetch()) {
                                 $arParamsComment = array("BLOG_ID" => $arF["BLOG_ID"], "POST_ID" => $ar["ID"], "SITE_ID" => $ar["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "USE_SOCNET" => "Y");
                                 CBlogComment::_IndexPostComments($arParamsComment);
                             }
                         }
                     }
                 }
                 if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                     if (empty($arF["SC_PERM"])) {
                         $arF["SC_PERM"] = CBlogPost::GetSocNetPermsCode($ar["ID"]);
                     }
                     $Result["PERMISSIONS"] = $arF["SC_PERM"];
                     if (IntVal($ar["SLID"]) <= 0) {
                         $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
                         $text4message = $parserBlog->convert($ar["DETAIL_TEXT"], false, array(), $arAllow, array("isSonetLog" => true));
                         $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "LOG_UPDATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "TITLE_TEMPLATE" => "#USER_NAME# add post", "TITLE" => $ar["TITLE"], "MESSAGE" => $text4message, "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "SOURCE_ID" => $ar["ID"], "ENABLE_COMMENTS" => "N", "ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $ar["AUTHOR_ID"], "USER_ID" => $ar["AUTHOR_ID"], "URL" => $arSite[$ar["SITE_ID"]], "SITE_ID" => $arSites);
                         $logID = CSocNetLog::Add($arSoFields, false);
                         if (intval($logID) > 0) {
                             $socnetPerms = $arF["SC_PERM"];
                             if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) {
                                 $socnetPerms[] = "U" . $ar["AUTHOR_ID"];
                             }
                             $socnetPerms[] = "SA";
                             // socnet admin
                             CSocNetLog::Update($logID, array("TMP_ID" => $logID, "=LOG_UPDATE" => $arSoFields["LOG_UPDATE"]));
                             CSocNetLogRights::DeleteByLogID($logID);
                             CSocNetLogRights::Add($logID, $socnetPerms);
                         }
                     } else {
                         $socnetPerms = $arF["SC_PERM"];
                         if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) {
                             $socnetPerms[] = "U" . $ar["AUTHOR_ID"];
                         }
                         $socnetPerms[] = "SA";
                         // socnet admin
                         CSocNetLogRights::DeleteByLogID($ar["SLID"]);
                         CSocNetLogRights::Add($ar["SLID"], $socnetPerms);
                     }
                 }
             }
             if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $ar["SEARCH_INDEX"] == "Y") {
                 //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
                 if ($oCallback) {
                     $res = call_user_func(array($oCallback, $callback_method), $Result);
                     if (!$res) {
                         return $Result["ID"];
                     }
                 } else {
                     $arResult[] = $Result;
                 }
             }
         }
         //all blog posts indexed so let's start index users
         $category = 'C';
         $id = 0;
         COption::SetOptionString("blog", "socNetNewPerms", "Y");
     }
     if ($category == 'C') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbc.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,bp.ID as POST_ID\n\t\t\t\t\t,b.URL\n\t\t\t\t\t,bp.TITLE as POST_TITLE\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,bc.TITLE\n\t\t\t\t\t,bc.POST_TEXT\n\t\t\t\t\t,bc.POST_ID\n\t\t\t\t\t,bc.BLOG_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,bc.PATH\n\t\t\t\t\t," . $DB->DateToCharFunction("bc.DATE_CREATE") . " as DATE_CREATE\n\t\t\t\t\t,bc.AUTHOR_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_comment bc\n\t\t\t\t\tINNER JOIN b_blog_post bp ON (bp.ID = bc.POST_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (bc.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tbc.ID > " . $id . " \n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? " AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbc.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             //Check permissions
             $tag = "";
             $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["POST_ID"], BLOG_PERMS_POST);
             if ($PostPerms < BLOG_PERMS_READ) {
                 continue;
             }
             //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
             if (strlen($ar["PATH"]) > 0) {
                 $arSite = array($ar["SITE_ID"] => str_replace("#comment_id#", $ar["ID"], $ar["PATH"]));
             } else {
                 $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["POST_ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
             }
             $Result = array("ID" => "C" . $ar["ID"], "SITE_ID" => $arSite, "LAST_MODIFIED" => $ar["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $ar["BLOG_ID"] . "|" . $ar["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $ar["TITLE"], "BODY" => blogTextParser::killAllTags($ar["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($ar["AUTHOR_ID"]) > 0 ? $ar["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $ar["ID"]);
             if ($ar["USE_SOCNET"] == "Y") {
                 $arSp = CBlogComment::GetSocNetCommentPerms($ar["POST_ID"]);
                 if (is_array($arSp)) {
                     $Result["PERMISSIONS"] = $arSp;
                 }
             }
             if (strlen($ar["TITLE"]) <= 0) {
                 $Result["TITLE"] = substr($Result["BODY"], 0, 100);
             }
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         //all blog posts indexed so let's start index users
         $category = 'U';
         $id = 0;
     }
     if ($category == 'U') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbu.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("bu.LAST_VISIT") . " as LAST_VISIT\n\t\t\t\t\t," . $DB->DateToCharFunction("u.DATE_REGISTER") . " as DATE_REGISTER\n\t\t\t\t\t,bu.ALIAS\n\t\t\t\t\t,bu.DESCRIPTION\n\t\t\t\t\t,bu.INTERESTS\n\t\t\t\t\t,u.NAME\n\t\t\t\t\t,u.LAST_NAME\n\t\t\t\t\t,u.LOGIN\n\t\t\t\t\t,bu.USER_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_user bu\n\t\t\t\t\tINNER JOIN b_user u  ON (u.ID = bu.USER_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (u.ID = b.OWNER_ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bu.ID > " . $id . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbu.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             if ($ar["USE_SOCNET"] == "Y") {
                 $Result = array("ID" => "U" . $ar["ID"], "BODY" => "", "TITLE" => "");
             } else {
                 //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
                 $arSite = array($ar["SITE_ID"] => CBlogUser::PreparePath($ar["USER_ID"], $ar["SITE_ID"]));
                 //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
                 $Result = array("ID" => "U" . $ar["ID"], "LAST_MODIFIED" => $ar["LAST_VISIT"], "TITLE" => CBlogUser::GetUserName($ar["ALIAS"], $ar["NAME"], $ar["LAST_NAME"], $ar["LOGIN"]), "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"] . " " . $ar["INTERESTS"]), "SITE_ID" => $arSite, "PARAM1" => "USER", "PARAM2" => $ar["ID"], "PERMISSIONS" => array(2));
                 if (strlen($Result["LAST_MODIFIED"]) <= 0) {
                     $Result["LAST_MODIFIED"] = $ar["DATE_REGISTER"];
                 }
             }
             //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
     }
     if ($oCallback) {
         return false;
     }
     return $arResult;
 }
Example #17
0
         } else {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                 $arResult["strMessage"] = $e->GetString();
             } else {
                 $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_CANNOT_CHANGE");
             }
             $arResult["bResult"] = "E";
         }
     } else {
         $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_INCORRECT_LOG_ID");
         $arResult["bResult"] = "E";
     }
 } elseif ($action == "delete" && CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)) {
     $log_id = intval($_REQUEST["log_id"]);
     if ($log_id > 0) {
         $arResult["bResult"] = CSocNetLog::Delete($log_id) ? "Y" : "N";
     }
 } elseif ($action == "get_more_destination") {
     $isExtranetInstalled = CModule::IncludeModule("extranet") ? "Y" : "N";
     $isExtranetSite = $isExtranetInstalled == "Y" && CExtranet::IsExtranetSite() ? "Y" : "N";
     $isExtranetUser = $isExtranetInstalled == "Y" && !CExtranet::IsIntranetUser() ? "Y" : "N";
     $isExtranetAdmin = $isExtranetInstalled == "Y" && CExtranet::IsExtranetAdmin() ? "Y" : "N";
     if ($isExtranetUser == "Y") {
         $arUserIdVisible = CExtranet::GetMyGroupsUsersSimple(SITE_ID);
     } elseif ($isExtranetInstalled == "Y" && $isExtranetUser != "Y" && $isExtranetAdmin != "Y") {
         if ($isExtranetAdmin == "Y" && $bCurrentUserIsAdmin) {
             $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsers(SITE_ID);
         } else {
             $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsersSimple(CExtranet::GetExtranetSiteID());
         }
     }
Example #18
0
	function UnInstallDB($arParams = array())
	{
		global $DB, $APPLICATION;
		CAgent::RemoveModuleAgents('calendar');
		$errors = null;
		if ((true == array_key_exists("savedata", $arParams)) && ($arParams["savedata"] != 'Y'))
		{
			$GLOBALS["USER_FIELD_MANAGER"]->OnEntityDelete("CALENDAR_EVENT");
			$errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"].'/bitrix/modules/'.$this->MODULE_ID.'/install/db/'.strtolower($DB->type).'/uninstall.sql');

			if (!empty($errors))
			{
				$APPLICATION->ThrowException(implode("", $errors));
				return false;
			}
			$this->UnInstallTasks();
		}

		UnRegisterModuleDependences("pull", "OnGetDependentModule", "calendar", "CCalendarPullSchema", "OnGetDependentModule");
		UnRegisterModuleDependences("im", "OnGetNotifySchema", "calendar", "CCalendarNotifySchema", "OnGetNotifySchema");
		UnRegisterModuleDependences("im", "OnBeforeConfirmNotify", "calendar", "CCalendar", "HandleImCallback");
		UnRegisterModuleDependences('intranet', 'OnPlannerInit', 'calendar', 'CCalendarEventHandlers', 'OnPlannerInit');
		UnRegisterModuleDependences('intranet', 'OnPlannerAction', 'calendar', 'CCalendarEventHandlers', 'OnPlannerAction');
		UnRegisterModuleDependences('rest', 'OnRestServiceBuildDescription', 'calendar', 'CCalendarRestService', 'OnRestServiceBuildDescription');
		UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetFeaturesList', 'calendar', 'CCalendarLiveFeed', 'AddEvent');
		UnRegisterModuleDependences('socialnetwork', 'OnSonetLogEntryMenuCreate', 'calendar', 'CCalendarLiveFeed', 'OnSonetLogEntryMenuCreate');
		UnRegisterModuleDependences('socialnetwork', 'OnAfterSonetLogEntryAddComment', 'calendar', 'CCalendarLiveFeed', 'OnAfterSonetLogEntryAddComment');
		UnRegisterModuleDependences('socialnetwork', 'OnForumCommentIMNotify', 'calendar', 'CCalendarLiveFeed', 'OnForumCommentIMNotify');
		UnRegisterModuleDependences('socialnetwork', 'onAfterCommentAddAfter', 'calendar', 'CCalendarLiveFeed', 'onAfterCommentAddAfter');
		UnRegisterModuleDependences('socialnetwork', 'onAfterCommentUpdateAfter', 'calendar', 'CCalendarLiveFeed', 'onAfterCommentUpdateAfter');
		UnRegisterModuleDependences('search', 'BeforeIndex', 'calendar', 'CCalendarLiveFeed', 'FixForumCommentURL');

		UnRegisterModule("calendar");

		// Clear cache
		$arPath = array(
			'access_tasks',
			'type_list',
			'section_list',
			'attendees_list',
			'event_list'
		);
		$cache = new CPHPCache;
		foreach($arPath as $path)
			if ($path != '')
				$cache->CleanDir("calendar/".$path);

		// Remove tasks from LiveFeed
		if (
			IsModuleInstalled('socialnetwork')
			&& CModule::IncludeModule('socialnetwork')
		)
		{
			$dbRes = CSocNetLog::GetList(
				array(),
				array("EVENT_ID" => "calendar"),
				false,
				false,
				array("ID")
			);

			if ($dbRes)
			{
				while ($arRes = $dbRes->Fetch())
					CSocNetLog::Delete($arRes["ID"]);
			}
		}

		// Remove tasks from IM
		if (IsModuleInstalled('im') && CModule::IncludeModule('im'))
		{
			if (method_exists('CIMNotify', 'DeleteByModule'))
				CIMNotify::DeleteByModule('calendar');
		}

		return true;
	}
Example #19
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $APPLICATION, $stackCacheManager, $USER_FIELD_MANAGER;
     $this->errors = false;
     if (!array_key_exists('savedata', $arParams) || $arParams['savedata'] != 'Y') {
         // delete extra fields for all entities
         require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/crm/include.php';
         $arEntityIds = CCrmFields::GetEntityTypes();
         foreach ($arEntityIds as $entityId => $ar) {
             $CCrmFields = new CCrmFields($USER_FIELD_MANAGER, $entityId);
             $arFields = $CCrmFields->GetFields();
             foreach ($arFields as $arField) {
                 $CCrmFields->DeleteField($arField['ID']);
             }
         }
         $this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/crm/install/db/' . strtolower($DB->type) . '/uninstall.sql');
         if (CModule::IncludeModule('socialnetwork')) {
             $dbRes = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => CCrmLiveFeedEntity::GetAll()), false, false, array("ID"));
             if ($dbRes) {
                 while ($arRes = $dbRes->Fetch()) {
                     CSocNetLog::Delete($arRes["ID"]);
                 }
             }
         }
     }
     $stackCacheManager->Clear('b_crm_status');
     $stackCacheManager->Clear('b_crm_perms');
     COption::RemoveOption('crm');
     UnRegisterModuleDependences('mail', 'OnGetFilterList', 'crm', 'CCrmEMail', 'OnGetFilterList');
     UnRegisterModuleDependences('main', 'OnUserTypeBuildList', 'crm', 'CUserTypeCrm', 'GetUserTypeDescription');
     UnRegisterModuleDependences('main', 'OnUserTypeBuildList', 'crm', 'CUserTypeCrmStatus', 'GetUserTypeDescription');
     UnRegisterModuleDependences('search', 'OnReindex', 'crm', 'CCrmSearch', 'OnSearchReindex');
     UnRegisterModuleDependences('search', 'OnSearchCheckPermissions', 'crm', 'CCrmSearch', 'OnSearchCheckPermissions');
     UnRegisterModuleDependences('report', 'OnReportAdd', 'crm', 'CCrmReportHelper', 'clearMenuCache');
     UnRegisterModuleDependences('report', 'OnReportUpdate', 'crm', 'CCrmReportHelper', 'clearMenuCache');
     UnRegisterModuleDependences('report', 'OnReportDelete', 'crm', 'CCrmReportHelper', 'clearMenuCache');
     UnRegisterModuleDependences('iblock', 'OnIBlockDelete', 'crm', 'CCrmCatalog', 'OnIBlockDelete');
     UnRegisterModuleDependences('iblock', 'OnAfterIBlockElementDelete', 'crm', 'CAllCrmProduct', 'OnIBlockElementDelete');
     UnRegisterModuleDependences('iblock', 'OnAfterIBlockElementDelete', 'crm', 'CCrmProduct', 'OnIBlockElementDelete');
     UnRegisterModuleDependences("socialnetwork", "OnFillSocNetLogEvents", "crm", "CCrmExternalSaleImport", "OnFillSocNetLogEvents");
     UnRegisterModuleDependences('tasks', 'OnBeforeTaskAdd', 'crm', 'CAllCrmActivity', 'OnBeforeTaskAdd');
     UnRegisterModuleDependences('tasks', 'OnTaskAdd', 'crm', 'CAllCrmActivity', 'OnTaskAdd');
     UnRegisterModuleDependences('tasks', 'OnTaskUpdate', 'crm', 'CAllCrmActivity', 'OnTaskUpdate');
     UnRegisterModuleDependences('tasks', 'OnTaskDelete', 'crm', 'CAllCrmActivity', 'OnTaskDelete');
     UnRegisterModuleDependences('webdav', 'OnFileDelete', 'crm', 'CCrmWebDavHelper', 'OnWebDavFileDelete');
     UnRegisterModuleDependences('subscribe', 'BeforePostingSendMail', 'crm', 'CCrmEMail', 'BeforeSendMail');
     UnRegisterModuleDependences('calendar', 'OnAfterCalendarEventEdit', 'crm', 'CAllCrmActivity', 'OnCalendarEventEdit');
     UnRegisterModuleDependences('calendar', 'OnAfterCalendarEventDelete', 'crm', 'CAllCrmActivity', 'OnCalendarEventDelete');
     UnRegisterModuleDependences('crm', 'OnCrmStatusGetList', 'crm', 'CCrmStatusInvoice', 'getStatusList');
     UnRegisterModuleDependences('crm', 'OnGetEntityTypes', 'crm', 'CCrmStatusInvoice', 'onGetEntityTypes');
     UnRegisterModuleDependences('crm', 'OnBeforeCrmStatusCreate', 'crm', 'CCrmStatusInvoice', 'createCrmStatus');
     UnRegisterModuleDependences('rest', 'onRestServiceBuildDescription', 'crm', 'CCrmRestService', 'onRestServiceBuildDescription');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetAllowedSubscribeEntityTypes', 'crm', 'CCrmLiveFeed', 'OnFillSocNetAllowedSubscribeEntityTypes');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogEvents', 'crm', 'CCrmLiveFeed', 'OnFillSocNetLogEvents');
     UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogFields', 'crm', 'CCrmLiveFeed', 'OnFillSocNetLogFields');
     UnRegisterModuleDependences('socialnetwork', 'OnBuildSocNetLogFilter', 'crm', 'CCrmLiveFeed', 'OnBuildSocNetLogFilter');
     UnRegisterModuleDependences('socialnetwork', 'OnBuildSocNetLogOrder', 'crm', 'CCrmLiveFeed', 'OnBuildSocNetLogOrder');
     UnRegisterModuleDependences('socialnetwork', 'OnSocNetLogFormatDestination', 'crm', 'CCrmLiveFeed', 'OnSocNetLogFormatDestination');
     UnRegisterModuleDependences('socialnetwork', 'OnBuildSocNetLogPerms', 'crm', 'CCrmLiveFeed', 'OnBuildSocNetLogPerms');
     UnRegisterModuleDependences('socialnetwork', 'OnBeforeSocNetLogRightsAdd', 'crm', 'CCrmLiveFeed', 'OnBeforeSocNetLogRightsAdd');
     UnRegisterModuleDependences('socialnetwork', 'OnBeforeSocNetLogCommentCounterIncrement', 'crm', 'CCrmLiveFeed', 'OnBeforeSocNetLogCommentCounterIncrement');
     UnRegisterModuleDependences('socialnetwork', 'OnAfterSocNetLogEntryCommentAdd', 'crm', 'CCrmLiveFeed', 'OnAfterSocNetLogEntryCommentAdd');
     UnRegisterModuleDependences('socialnetwork', 'OnBeforeSocNetLogEntryGetRights', 'crm', 'CCrmLiveFeed', 'OnBeforeSocNetLogEntryGetRights');
     UnRegisterModuleDependences("socialnetwork", "OnSendMentionGetEntityFields", "crm", "CCrmLiveFeed", "OnSendMentionGetEntityFields");
     UnRegisterModuleDependences('main', 'OnAddRatingVote', 'crm', 'CCrmLiveFeed', 'OnAddRatingVote');
     UnRegisterModuleDependences('forum', 'OnAfterCommentAdd', 'crm', 'CCrmLiveFeed', 'onAfterCommentAdd');
     UnRegisterModuleDependences('disk', 'onAfterDeleteFile', 'crm', '\\Bitrix\\Crm\\Integration\\DiskManager', 'OnDiskFileDelete');
     if (CModule::IncludeModule('search')) {
         CSearch::DeleteIndex('crm');
     }
     UnRegisterModule('crm');
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode('<br />', $this->errors));
         return false;
     }
     return true;
 }