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


PHP CForumTopic::Delete方法代码示例

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


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

示例1: foreach

    $forumID = CForumNew::Add($arForum);
    if ($forumID < 1 || !isset($arForum["TOPICS"]) || !is_array($arForum["TOPICS"])) {
        continue;
    }
    foreach ($arForum["TOPICS"] as $arTopic) {
        $arTopic["FORUM_ID"] = $forumID;
        $topicID = CForumTopic::Add($arTopic);
        if ($topicID < 1 || !isset($arTopic["MESSAGES"]) || !is_array($arTopic["MESSAGES"])) {
            continue;
        }
        foreach ($arTopic["MESSAGES"] as $arMessage) {
            $arMessage["FORUM_ID"] = $forumID;
            $arMessage["TOPIC_ID"] = $topicID;
            $messageID = CForumMessage::Add($arMessage, false);
            if ($messageID < 1) {
                CForumTopic::Delete($topicID);
                continue 2;
            }
        }
        CForumTopic::SetStat($topicID);
    }
}
$fidParameter = "";
$dbForum = CForumNew::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID));
while ($arForum = $dbForum->Fetch()) {
    if ($arForum["FORUM_GROUP_ID"] != $arGroupID["HIDDEN"] && $arForum["FORUM_GROUP_ID"] != $arGroupID["COMMENTS"]) {
        $fidParameter .= $arForum["ID"] . ",";
    }
}
$fidParameter = rtrim($fidParameter, ",");
$forum_theme = 'blue';
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:index.php

示例2: addCommentLists

 public static function addCommentLists($fields)
 {
     if (!CModule::IncludeModule('forum') || !CModule::IncludeModule('bizproc')) {
         return false;
     }
     $ufFileId = array();
     $ufDocId = array();
     $fieldsMessage = array();
     $messageId = array();
     $error = array();
     $note = array();
     $sonetLogQuery = CSocNetLog::GetList(array(), array('ID' => $fields['LOG_ID']), false, false, array('ID', 'SOURCE_ID', 'SITE_ID', 'MESSAGE', 'USER_ID'));
     if ($sonetLog = $sonetLogQuery->fetch()) {
         $users = CBPTaskService::getWorkflowParticipants($sonetLog['MESSAGE'], CBPTaskUserStatus::Waiting);
         if (preg_match_all("/(?<=\\[USER=)(?P<id>[0-9]+)(?=\\])/", $fields['TEXT_MESSAGE'], $matches)) {
             $users = array_unique(array_merge($users, $matches['id']));
         }
         $users[] = $sonetLog['USER_ID'];
         self::setSocnetFollow($users, $sonetLog['ID'], 'Y', false, true);
         $forumId = CBPHelper::getForumId();
         if ($forumId) {
             $topicQuery = CForumTopic::GetList(array(), array('FORUM_ID' => $forumId, 'XML_ID' => 'WF_' . $sonetLog['MESSAGE']));
             if ($topicQuery && ($topic = $topicQuery->fetch())) {
                 $topicId = $topic['ID'];
             } else {
                 $arTopic = array('AUTHOR_ID' => 0, 'TITLE' => 'WF_' . $sonetLog['MESSAGE'], 'TAGS' => '', 'MESSAGE' => 'WF_' . $sonetLog['MESSAGE'], 'XML_ID' => 'WF_' . $sonetLog['MESSAGE']);
                 $arUserStart = array("ID" => $arTopic["AUTHOR_ID"], "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
                 $GLOBALS["DB"]->StartTransaction();
                 $arTopicFields = array("TITLE" => $arTopic["TITLE"], "TAGS" => $arTopic["TAGS"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "XML_ID" => $arTopic["XML_ID"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => 'Q', "PERMISSION" => 'Y');
                 $topicId = CForumTopic::Add($arTopicFields);
                 if (intval($topicId) > 0) {
                     $arTopic['MESSAGE'] = strip_tags($arTopic['MESSAGE']);
                     $arFields = array("POST_MESSAGE" => $arTopic['MESSAGE'], "AUTHOR_ID" => $arUserStart["ID"], "AUTHOR_NAME" => $arUserStart["NAME"], "FORUM_ID" => $forumId, "TOPIC_ID" => $topicId, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "WF", "PARAM2" => 0, "PERMISSION_EXTERNAL" => 'Q', "PERMISSION" => 'Y');
                     $startMessageId = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
                     if (intVal($startMessageId) <= 0) {
                         CForumTopic::Delete($topicId);
                         $topicId = 0;
                     }
                 }
                 if (intval($topicId) <= 0) {
                     $GLOBALS["DB"]->Rollback();
                 } else {
                     $GLOBALS["DB"]->Commit();
                 }
             }
             if ($topicId) {
                 $fieldsMessage = array('POST_MESSAGE' => $fields['TEXT_MESSAGE'], 'USE_SMILES' => 'Y', 'PERMISSION_EXTERNAL' => 'Q', 'PERMISSION' => 'Y', 'APPROVED' => 'Y');
                 $tmp = false;
                 $GLOBALS['USER_FIELD_MANAGER']->editFormAddFields('SONET_COMMENT', $tmp);
                 if (is_array($tmp)) {
                     if (array_key_exists('UF_SONET_COM_DOC', $tmp)) {
                         $GLOBALS['UF_FORUM_MESSAGE_DOC'] = $tmp['UF_SONET_COM_DOC'];
                     } elseif (array_key_exists('UF_SONET_COM_FILE', $tmp)) {
                         $fieldsMessage['FILES'] = array();
                         foreach ($tmp['UF_SONET_COM_FILE'] as $fileId) {
                             $fieldsMessage['FILES'][] = array('FILE_ID' => $fileId);
                         }
                     }
                     if (array_key_exists("UF_SONET_COM_URL_PRV", $tmp)) {
                         $GLOBALS["UF_FORUM_MES_URL_PRV"] = $tmp["UF_SONET_COM_URL_PRV"];
                     }
                 }
                 $messageId = ForumAddMessage("REPLY", $forumId, $topicId, 0, $fieldsMessage, $error, $note);
                 if ($messageId > 0) {
                     $addedMessageFilesQuery = CForumFiles::getList(array('ID' => 'ASC'), array('MESSAGE_ID' => $messageId));
                     while ($addedMessageFiles = $addedMessageFilesQuery->fetch()) {
                         $ufFileId[] = $addedMessageFiles['FILE_ID'];
                     }
                     $ufDocId = $GLOBALS['USER_FIELD_MANAGER']->getUserFieldValue('FORUM_MESSAGE', 'UF_FORUM_MESSAGE_DOC', $messageId, LANGUAGE_ID);
                     $ufUrlPreview = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MES_URL_PRV", $messageID, LANGUAGE_ID);
                 }
             }
         }
     }
     if (!$messageId) {
         $error = Loc::getMessage('LISTS_LF_ADD_COMMENT_SOURCE_ERROR');
     }
     return array('SOURCE_ID' => $messageId, 'MESSAGE' => $fieldsMessage ? $fieldsMessage['POST_MESSAGE'] : false, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => $messageId, 'ERROR' => $error, 'NOTES' => $note, 'UF' => array('FILE' => $ufFileId, 'DOC' => $ufDocId, 'URL_PREVIEW' => $ufUrlPreview));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:79,代码来源:livefeed.php

示例3: SocnetEMailMessageAdd


//.........这里部分代码省略.........
     }
     if (!empty($arMessageFields["FIELD_BCC"])) {
         $arRes[] = "Bcc: " . $arMessageFields["FIELD_BCC"];
     }
     $arRes[] = "Subject: " . $arMessageFields["SUBJECT"];
     $arRes[] = "Date: " . $arMessageFields["FIELD_DATE"];
     $arFields["MAIL_HEADER"] = implode("\r\n", $arRes);
     preg_match_all('#Received:\\s+from\\s+(.*)by.*#i', $arMessageFields["HEADER"], $regs);
     if (is_array($regs) && is_array($regs[1])) {
         $arFields["AUTHOR_IP"] = $arFields["AUTHOR_REAL_IP"] = '<email: ' . $regs[1][count($regs[1]) - 1] . '>';
     } else {
         $arFields["AUTHOR_IP"] = $arFields["AUTHOR_REAL_IP"] = '<email: no address>';
     }
     /*
     
     $AUTHOR_IP = ForumGetRealIP();
     $AUTHOR_IP_tmp = $AUTHOR_IP;
     $AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR'];
     if (COption::GetOptionString("forum", "FORUM_GETHOSTBYADDR", "N") == "Y")
     {
     	$AUTHOR_IP = @gethostbyaddr($AUTHOR_IP);
     
     	if ($AUTHOR_IP_tmp==$AUTHOR_REAL_IP)
     		$AUTHOR_REAL_IP = $AUTHOR_IP;
     	else
     		$AUTHOR_REAL_IP = @gethostbyaddr($AUTHOR_REAL_IP);
     }
     
     $arFields["AUTHOR_IP"] = ($AUTHOR_IP!==False) ? $AUTHOR_IP : "<no address>";
     $arFields["AUTHOR_REAL_IP"] = ($AUTHOR_REAL_IP!==False) ? $AUTHOR_REAL_IP : "<no address>";
     */
     $strErrorMessage = '';
     $MESSAGE_ID = CForumMessage::Add($arFields, false);
     if (intVal($MESSAGE_ID) <= 0) {
         $str = $GLOBALS['APPLICATION']->GetException();
         if ($str && $str->GetString()) {
             $strErrorMessage .= "[" . $str->GetString() . "]";
         }
         if ($arFields["NEW_TOPIC"] == 'Y') {
             CForumTopic::Delete($TOPIC_ID);
         }
         CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR5") . " " . $strErrorMessage));
     }
     if ($MESSAGE_ID > 0) {
         CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_COMPLETE", "MESSAGE" => GetMessage("FORUM_MAIL_OK") . " " . $MESSAGE_ID . " (TID#" . $TOPIC_ID . ")"));
         CForumMessage::SendMailMessage($MESSAGE_ID, array(), false, "NEW_FORUM_MESSAGE");
         $dbSite = CSite::GetById($arMessageFields["LID"]);
         if ($arSite = $dbSite->Fetch()) {
             $lang = $arSite['LANGUAGE_ID'];
         } else {
             $lang = $LANGUAGE_ID;
         }
         $parser = new forumTextParser();
         $arForum = CForumNew::GetByID($FORUM_ID);
         $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "SMILES" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "TABLE" => "N", "ALIGN" => "N");
         if ($arFields["NEW_TOPIC"] == "Y") {
             $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $AUTHOR_NAME, CForumEmail::GetLangMessage("FORUM_MAIL_SOCNET_TITLE_TOPIC", $lang)), "TITLE" => $subject, "MESSAGE" => $parser->convert($body, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($body), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $AUTHOR_USER_ID, "FID" => $FORUM_ID, "TID" => $TOPIC_ID, "MID" => $MESSAGE_ID)), "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $TOPIC_ID)))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $MESSAGE_ID, "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => intval($TOPIC_ID));
             if (intVal($AUTHOR_USER_ID) > 0) {
                 $arFieldsForSocnet["USER_ID"] = $AUTHOR_USER_ID;
             }
             $logID = CSocNetLog::Add($arFieldsForSocnet, false);
             if (intval($logID) > 0) {
                 CSocNetLog::Update($logID, array("TMP_ID" => $logID));
                 CSocNetLogRights::SetForSonet($logID, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true);
                 CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
             }
         } else {
             $dbForumMessage = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID));
             if ($arForumMessage = $dbForumMessage->Fetch()) {
                 $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "forum", "SOURCE_ID" => $arForumMessage["ID"]), false, false, array("ID", "TMP_ID"));
                 if ($arRes = $dbRes->Fetch()) {
                     $log_id = $arRes["TMP_ID"];
                 } else {
                     $dbFirstMessage = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $arForumMessage["TOPIC_ID"]), false, 1);
                     if ($arFirstMessage = $dbFirstMessage->Fetch()) {
                         $arTopic = CForumTopic::GetByID($arFirstMessage["TOPIC_ID"]);
                         $sFirstMessageText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arFirstMessage["POST_MESSAGE_FILTER"] : $arFirstMessage["POST_MESSAGE"];
                         $sFirstMessageURL = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $arFirstMessage["AUTHOR_ID"], "FID" => $arFirstMessage["FORUM_ID"], "TID" => $arFirstMessage["TOPIC_ID"], "MID" => $arFirstMessage["ID"]));
                         $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "LOG_DATE" => $arFirstMessage["POST_DATE"], "LOG_UPDATE" => $arFirstMessage["POST_DATE"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $arFirstMessage["AUTHOR_NAME"], GetMessage("SONET_FORUM_LOG_TOPIC_TEMPLATE")), "TITLE" => $arTopic["TITLE"], "MESSAGE" => $parser->convert($sFirstMessageText, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($sFirstMessageText), "URL" => $sFirstMessageURL, "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $arFirstMessage["TOPIC_ID"])))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arFirstMessage["ID"], "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => intval($arFirstMessage["TOPIC_ID"]));
                         if (intVal($arFirstMessage["AUTHOR_ID"]) > 0) {
                             $arFieldsForSocnet["USER_ID"] = $arFirstMessage["AUTHOR_ID"];
                         }
                         $log_id = CSocNetLog::Add($arFieldsForSocnet, false);
                         if (intval($log_id) > 0) {
                             CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
                             CSocNetLogRights::SetForSonet($log_id, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true);
                         }
                     }
                 }
                 if (intval($log_id) > 0) {
                     $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "LOG_ID" => $log_id, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert($body, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($body), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $AUTHOR_USER_ID, "FID" => $FORUM_ID, "TID" => $TOPIC_ID, "MID" => $MESSAGE_ID)), "MODULE_ID" => false, "SOURCE_ID" => $MESSAGE_ID, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => intval($MESSAGE_ID));
                     if (intVal($AUTHOR_USER_ID) > 0) {
                         $arFieldsForSocnet["USER_ID"] = $AUTHOR_USER_ID;
                     }
                     CSocNetLogComments::Add($arFieldsForSocnet);
                 }
             }
         }
     }
 }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: ForumGetRealIP

        }
        if (strlen($strErrorMessage) <= 0) {
            $AUTHOR_IP = ForumGetRealIP();
            $AUTHOR_IP_tmp = $AUTHOR_IP;
            $AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR'];
            $AUTHOR_IP = @gethostbyaddr($AUTHOR_IP);
            if ($AUTHOR_IP_tmp == $AUTHOR_REAL_IP) {
                $AUTHOR_REAL_IP = $AUTHOR_IP;
            } else {
                $AUTHOR_REAL_IP = @gethostbyaddr($AUTHOR_REAL_IP);
            }
            $arFields = array("POST_MESSAGE" => $strDescription, "AUTHOR_NAME" => $_POST["comment_author"], "AUTHOR_EMAIL" => $_POST["comment_email"], "FORUM_ID" => $INQUERY_FORUM_ID, "TOPIC_ID" => $TID1, "AUTHOR_IP" => $AUTHOR_IP !== False ? $AUTHOR_IP : "<no address>", "AUTHOR_REAL_IP" => $AUTHOR_REAL_IP !== False ? $AUTHOR_REAL_IP : "<no address>", "NEW_TOPIC" => "Y", "GUEST_ID" => $_SESSION["SESS_GUEST_ID"]);
            $MID1 = CForumMessage::Add($arFields);
            if (IntVal($MID1) <= 0) {
                $strErrorMessage .= GetMessage("ADDMESS_ERROR_ADD_MESSAGE") . ". \n";
                CForumTopic::Delete($TID1);
                $TID1 = 0;
            }
        }
        if (strlen($strErrorMessage) <= 0) {
            $DB->Commit();
            $strOKMessage .= GetMessage("COMM_COMMENT_OK") . ". ";
        } else {
            if ($sTransStarted) {
                $DB->Rollback();
            }
        }
    }
    ?>

<br><a name="cm">
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: Delete

 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $arMessage = array();
     if ($ID > 0) {
         $arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
     }
     if (empty($arMessage)) {
         return false;
     }
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onBeforeMessageDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     $AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
     $TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
     $FORUM_ID = intVal($arMessage["FORUM_ID"]);
     $DB->StartTransaction();
     // delete votes
     if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")) {
         CModule::IncludeModule("vote");
         CVote::Delete($arMessage["PARAM2"]);
     }
     // delete files
     CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
     // delete message
     $DB->Query("DELETE FROM b_forum_message WHERE ID=" . $ID);
     // after delete
     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
     $res = false;
     if (!($db_res && ($res = $db_res->Fetch()))) {
         CForumTopic::Delete($TOPIC_ID);
     } else {
         // if deleted message was first
         if ($arMessage["NEW_TOPIC"] == "Y") {
             $DB->Update('b_forum_message', array('NEW_TOPIC' => '"Y"'), "WHERE ID=" . $res["ID"]);
         }
         CForumTopic::SetStat($TOPIC_ID);
     }
     $DB->Commit();
     $GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);
     if ($AUTHOR_ID > 0) {
         CForumUser::SetStat($AUTHOR_ID);
     }
     CForumNew::SetStat($FORUM_ID);
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onAfterMessageDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
     }
     /***************** /Event ******************************************/
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", $ID);
         if (is_array($res) && !empty($res)) {
             CForumMessage::Reindex($res["ID"], $res);
         }
     }
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:62,代码来源:message.php

示例6: OnSocNetGroupDelete

 public static function OnSocNetGroupDelete($group_id)
 {
     global $DB;
     $group_id = intVal($group_id);
     if ($group_id > 0) {
         if (CModule::IncludeModule("socialnetwork")) {
             $dbRes = $DB->Query("select ID from b_forum_topic where SOCNET_GROUP_ID=" . $group_id);
             while ($arRes = $dbRes->Fetch()) {
                 CForumTopic::Delete($arRes["ID"]);
             }
         }
     }
     return true;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:14,代码来源:user.php

示例7: OnBeforeIBlockElementDelete

 function OnBeforeIBlockElementDelete($ELEMENT_ID)
 {
     $ELEMENT_ID = intVal($ELEMENT_ID);
     if ($ELEMENT_ID > 0 && CModule::IncludeModule("iblock")) {
         $rsElement = CIBlockElement::GetList(array("ID" => "ASC"), array("ID" => $ELEMENT_ID, "SHOW_HISTORY" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array("ID", "WF_PARENT_ELEMENT_ID", "IBLOCK_ID"));
         $arElement = $rsElement->Fetch();
         if (is_array($arElement) && $arElement["WF_PARENT_ELEMENT_ID"] == 0) {
             $rsProperty = CIBlockElement::GetProperty($arElement["IBLOCK_ID"], $arElement["ID"], array(), array("CODE" => "FORUM_TOPIC_ID"));
             if ($rsProperty && ($arProperty = $rsProperty->Fetch())) {
                 if (is_array($arProperty) && $arProperty["VALUE"] > 0) {
                     CForumTopic::Delete($arProperty["VALUE"]);
                 }
             }
         }
     }
     return true;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:17,代码来源:topic.php

示例8: AddComment_Review_CreateRoot_Forum

 function AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage = false, $strFirstMessage = "")
 {
     if (!CModule::IncludeModule("forum")) {
         return false;
     }
     if ($bPostFirstMessage && strlen($strFirstMessage) <= 0) {
         return false;
     }
     // Add Topic
     $arUserStart = array("ID" => intVal($arElement["~CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
     if ($arUserStart["ID"] > 0) {
         $res = array();
         $db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arElement["~CREATED_BY"]));
         if ($db_res && ($res = $db_res->Fetch())) {
             $res["FORUM_USER_ID"] = intVal($res["ID"]);
             $res["ID"] = $res["USER_ID"];
         } else {
             $db_res = CUser::GetByID($arElement["~CREATED_BY"]);
             if ($db_res && ($res = $db_res->Fetch())) {
                 $res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
                 $res["USER_PROFILE"] = "N";
             }
         }
         if (!empty($res)) {
             $arUserStart = $res;
             $sName = $res["SHOW_NAME"] == "Y" ? trim($res["NAME"] . " " . $res["LAST_NAME"]) : "";
             $arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
         }
     }
     $arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
     $GLOBALS["DB"]->StartTransaction();
     $arFields = array("TITLE" => $arElement["~NAME"], "TAGS" => $arElement["~TAGS"], "FORUM_ID" => $forumID, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "XML_ID" => "IBLOCK_" . $arElement["ID"]);
     if (isset($arElement["ENTITY_TYPE"]) && $arElement["ENTITY_TYPE"] == SONET_ENTITY_GROUP && isset($arElement["ENTITY_ID"]) && intval($arElement["ENTITY_ID"]) > 0) {
         $arFields["SOCNET_GROUP_ID"] = intval($arElement["ENTITY_ID"]);
     }
     $TOPIC_ID = CForumTopic::Add($arFields);
     if ($bPostFirstMessage && intVal($TOPIC_ID) > 0) {
         if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
             $strFirstMessage = CFilterUnquotableWords::Filter($strFirstMessage);
         }
         // Add post as new message
         $arFields = array("POST_MESSAGE" => $strFirstMessage, "AUTHOR_ID" => $arUserStart["ID"], "AUTHOR_NAME" => $arUserStart["NAME"], "FORUM_ID" => $forumID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "IB", "PARAM2" => intVal($arElement["ID"]));
         $MID = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
         if (intVal($MID) <= 0) {
             $arError[] = array("code" => "message is not added 1", "title" => GetMessage("F_ERR_ADD_MESSAGE"));
             CForumTopic::Delete($TOPIC_ID);
             $TOPIC_ID = 0;
         } elseif ($arParams["SUBSCRIBE_AUTHOR_ELEMENT"] == "Y" && intVal($arResult["ELEMENT"]["~CREATED_BY"]) > 0) {
             if ($arUserStart["USER_PROFILE"] == "N") {
                 $arUserStart["FORUM_USER_ID"] = CForumUser::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"]));
             }
             if (intVal($arUserStart["FORUM_USER_ID"]) > 0) {
                 CForumSubscribe::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"], "FORUM_ID" => $arParams["FORUM_ID"], "SITE_ID" => SITE_ID, "TOPIC_ID" => $TID, "NEW_TOPIC_ONLY" => "N"));
                 BXClearCache(true, "/bitrix/forum/user/" . $arResult["ELEMENT"]["~CREATED_BY"] . "/subscribe/");
                 // Sorry, Max.
             }
         }
     } elseif (intVal($TOPIC_ID) <= 0) {
         $GLOBALS["DB"]->Rollback();
         return false;
     }
     $GLOBALS["DB"]->Commit();
     return $TOPIC_ID;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:64,代码来源:log_tools.php

示例9: ForumMoveMessage


//.........这里部分代码省略.........
            if ($db_res && ($res = $db_res->Fetch())) {
                $arRes["NAME"] = $res["AUTHOR_NAME"];
                $arRes["ID"] = $res["AUTHOR_ID"];
            }
            $arFieldsTopic = array("TITLE" => $arFields["TITLE"], "TITLE_SEO" => $arFields["TITLE_SEO"], "DESCRIPTION" => $arFields["DESCRIPTION"], "ICON" => $arFields["ICON"], "TAGS" => $arFields["TAGS"], "FORUM_ID" => $FID, "USER_START_ID" => $arRes["ID"], "USER_START_NAME" => $arRes["NAME"], "LAST_POSTER_NAME" => $arRes["NAME"], "LAST_POSTER_ID" => $arRes["ID"], "APPROVED" => $arFields["APPROVED"]);
            $NewTID = CForumTopic::Add($arFieldsTopic);
            if (IntVal($NewTID) <= 0) {
                $arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
            } else {
                $arNewTopic = CForumTopic::GetByID($NewTID);
                if ($arNewTopic) {
                    $NewFID = $FID;
                    $arNewForum = $arForum;
                    $SendSubscribe = true;
                } else {
                    $arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
                }
            }
        }
    }
    if (count($arError) <= 0) {
        // Move message
        $db_res = CForumMessage::GetList(array(), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
        if ($db_res && ($res = $db_res->Fetch())) {
            do {
                //				echo "NewFID: ".$NewFID." -- FID:".$FID."<br/>";
                $arMessage = array();
                if ($NewFID != $FID) {
                    $arMessage["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
                    if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
                        $arMessage["APPROVED"] = "Y";
                    }
                    $arMessage["FORUM_ID"] = $NewFID;
                    $arMessage["POST_MESSAGE_HTML"] = "";
                }
                if ($NewTID != $TID) {
                    $arMessage["NEW_TOPIC"] = "N";
                    $arMessage["TOPIC_ID"] = $NewTID;
                }
                if (count($arMessage) > 0) {
                    $MID = CForumMessage::Update($res["ID"], $arMessage, true);
                    $res_log = $SendSubscribe == true ? GetMessage("F_MESSAGE_WAS_MOVED_TO_NEW") : GetMessage("F_MESSAGE_WAS_MOVED");
                    $res_log = str_replace(array("#ID#", "#TOPIC_TITLE#", "#TOPIC_ID#", "#NEW_TOPIC_TITLE#", "#NEW_TOPIC_ID#"), array($MID, $arTopic["TITLE"], $arTopic["ID"], $arNewTopic['TITLE'], $arNewTopic['ID']), $res_log);
                    $res["TITLE"] = $arNewTopic['TITLE'];
                    $res["TOPIC_ID"] = $arNewTopic['ID'];
                    $res["beforeTITLE"] = $arTopic["TITLE"];
                    $res["DESCRIPTION"] = $res_log;
                    CForumEventLog::Log("message", "move", $MID, serialize($res));
                    $db_res2 = CForumFiles::GetList(array(), array("FILE_MESSAGE_ID" => $res["ID"]));
                    if ($db_res2 && ($res2 = $db_res2->Fetch())) {
                        $arFiles = array();
                        do {
                            $arFiles[] = $res2["FILE_ID"];
                        } while ($res2 = $db_res2->Fetch());
                        CForumFiles::UpdateByID($arFiles, $arMessage);
                    }
                    if (IntVal($MID) <= 0) {
                        $arError[] = str_replace("##", $res["ID"], GetMessage("FMM_NO_MESSAGE_MOVE"));
                        break;
                    }
                }
            } while ($res = $db_res->Fetch());
        }
    }
    if (count($arError) <= 0) {
        $db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $TID), false, 1);
        if (!($db_res && ($res = $db_res->Fetch()))) {
            CForumTopic::Delete($TID);
        } else {
            CForumTopic::SetStat($TID);
        }
        $db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $NewTID), false, 1);
        if (!($db_res && ($res = $db_res->Fetch()))) {
            CForumTopic::Delete($NewTID);
        } else {
            CForumTopic::SetStat($NewTID);
        }
        CForumNew::SetStat($FID);
        if ($NewFID != $FID) {
            CForumNew::SetStat($NewFID);
        }
    }
    if (count($arError) <= 0) {
        $DB->Commit();
    } else {
        $DB->Rollback();
    }
    if (count($arError) > 0) {
        $strErrorMessage .= implode(". \n", $arError) . ". \n";
    } else {
        $strOKMessage .= GetMessage("FMM_YES_MESSAGE_MOVE");
        if ($SendSubscribe) {
            foreach ($Message as $MID) {
                CForumMessage::SendMailMessage($MID, array(), false, "NEW_FORUM_MESSAGE");
            }
        }
        return true;
    }
    return false;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:include.php

示例10: Delete

	/**
	 * <p>Удаляет сообщение с кодом <i>ID</i>.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код сообщения, которое необходимо удалить.
	 *
	 *
	 *
	 * @return bool 
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul><li>Перед удалением сообщения следует проверить возможность
	 * удаления методом <a
	 * href="http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/canuserdeletemessage.php">CForumMessage::CanUserDeleteMessage</a>
	 * </li></ul>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/delete.php
	 * @author Bitrix
	 */
	public static function Delete($ID)
	{
		global $DB;
		$ID = intVal($ID);
		$arMessage = array();
		if ($ID > 0)
			$arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
		if (empty($arMessage))
			return false;
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onBeforeMessageDelete");
		while ($arEvent = $events->Fetch())
		{
			if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false)
				return false;
		}
/***************** /Event ******************************************/
		$AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
		$TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
		$FORUM_ID = intVal($arMessage["FORUM_ID"]);

		$DB->StartTransaction();
		// delete votes
		if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")):
			CModule::IncludeModule("vote");
			CVote::Delete($arMessage["PARAM2"]);
		endif;
		// delete files
		CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
		// delete message
		$DB->Query("DELETE FROM b_forum_message WHERE ID=".$ID);
		// after delete
		$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
		$res = false;
		if (!($db_res && $res = $db_res->Fetch())):
			CForumTopic::Delete($TOPIC_ID);
		else:
			// if deleted message was first
			if ($arMessage["NEW_TOPIC"] == "Y"):
				$DB->Query("UPDATE b_forum_message SET NEW_TOPIC='Y' WHERE ID=".$res["ID"]);
			endif;
			CForumTopic::SetStat($TOPIC_ID);
		endif;
		$DB->Commit();

		$GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);

		if ($AUTHOR_ID > 0):
			CForumUser::SetStat($AUTHOR_ID);
		endif;
		CForumNew::SetStat($FORUM_ID);
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onAfterMessageDelete");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
/***************** /Event ******************************************/
		if (CModule::IncludeModule("search"))
		{
			CSearch::DeleteIndex("forum", $ID);
		}
		return true;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:86,代码来源:message.php

示例11: Delete

 /**
  * This method is deprecated. Use CTaskItem::delete() instead.
  * @deprecated
  */
 public static function Delete($ID, $arParams = array())
 {
     global $DB, $CACHE_MANAGER, $USER;
     if (isset($USER) && is_object($USER)) {
         $actorUserId = (int) $USER->getId();
     } else {
         $actorUserId = 1;
     }
     if (isset($arParams['META::EVENT_GUID'])) {
         $eventGUID = $arParams['META::EVENT_GUID'];
         unset($arParams['META::EVENT_GUID']);
     } else {
         $eventGUID = sha1(uniqid('AUTOGUID', true));
     }
     $paramSkipExchangeSync = false;
     if (is_array($arParams)) {
         if (isset($arParams['skipExchangeSync']) && ($arParams['skipExchangeSync'] === 'Y' || $arParams['skipExchangeSync'] === true)) {
             $paramSkipExchangeSync = true;
         }
     }
     $ID = intval($ID);
     if ($ID < 1) {
         return false;
     }
     $rsTask = CTasks::GetByID($ID, false);
     if ($arTask = $rsTask->Fetch()) {
         foreach (GetModuleEvents('tasks', 'OnBeforeTaskDelete', true) as $arEvent) {
             if (ExecuteModuleEventEx($arEvent, array($ID, $arTask)) === false) {
                 return false;
             }
         }
         CTaskCountersProcessor::onBeforeTaskDelete($ID, $arTask);
         CTaskMembers::DeleteByTaskID($ID);
         CTaskFiles::DeleteByTaskID($ID);
         CTaskDependence::DeleteByTaskID($ID);
         CTaskDependence::DeleteByDependsOnID($ID);
         CTaskTags::DeleteByTaskID($ID);
         $strSql = "DELETE FROM b_tasks_viewed WHERE TASK_ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $strSql = "DELETE FROM b_tasks_reminder WHERE TASK_ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         // clear cache
         if ($arTask["GROUP_ID"]) {
             $CACHE_MANAGER->ClearByTag("tasks_group_" . $arTask["GROUP_ID"]);
         }
         $arParticipants = array_unique(array_merge(array($arTask["CREATED_BY"], $arTask["RESPONSIBLE_ID"]), $arTask["ACCOMPLICES"], $arTask["AUDITORS"]));
         foreach ($arParticipants as $userId) {
             $CACHE_MANAGER->ClearByTag("tasks_user_" . $userId);
         }
         $strSql = "UPDATE b_tasks_template SET TASK_ID = NULL WHERE TASK_ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $strSql = "UPDATE b_tasks_template SET PARENT_ID = " . ($arTask["PARENT_ID"] ? $arTask["PARENT_ID"] : "NULL") . " WHERE PARENT_ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $strSql = "UPDATE b_tasks SET PARENT_ID = " . ($arTask["PARENT_ID"] ? $arTask["PARENT_ID"] : "NULL") . " WHERE PARENT_ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $strUpdate = $DB->PrepareUpdate("b_tasks", array('ZOMBIE' => 'Y', 'CHANGED_BY' => $actorUserId, 'CHANGED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat('FULL')), time() + CTasksTools::getTimeZoneOffset())), "tasks");
         $strSql = "UPDATE b_tasks SET " . $strUpdate . " WHERE ID = " . (int) $ID;
         if ($DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
             CTaskNotifications::SendDeleteMessage($arTask);
             if ($arTask["FORUM_TOPIC_ID"] && CModule::IncludeModule("forum")) {
                 CForumTopic::Delete($arTask["FORUM_TOPIC_ID"]);
             }
             if (!$paramSkipExchangeSync) {
                 CTaskSync::DeleteItem($arTask);
             }
             // MS Exchange
             // Emit pull event
             try {
                 $arPullRecipients = array();
                 foreach ($arParticipants as $userId) {
                     $arPullRecipients[] = (int) $userId;
                 }
                 $taskGroupId = 0;
                 // no group
                 if (isset($arTask['GROUP_ID']) && $arTask['GROUP_ID'] > 0) {
                     $taskGroupId = (int) $arTask['GROUP_ID'];
                 }
                 $arPullData = array('TASK_ID' => (int) $ID, 'BEFORE' => array('GROUP_ID' => $taskGroupId), 'TS' => time(), 'event_GUID' => $eventGUID);
                 self::EmitPullWithTagPrefix($arPullRecipients, 'TASKS_GENERAL_', 'task_remove', $arPullData);
                 self::EmitPullWithTag($arPullRecipients, 'TASKS_TASK_' . (int) $ID, 'task_remove', $arPullData);
             } catch (Exception $e) {
             }
             foreach (GetModuleEvents('tasks', 'OnTaskDelete', true) as $arEvent) {
                 ExecuteModuleEventEx($arEvent, array($ID));
             }
             if (CModule::IncludeModule("search")) {
                 CSearch::DeleteIndex("tasks", $ID);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:97,代码来源:task.php

示例12: createTopic

 protected function createTopic()
 {
     $topic = array('TITLE' => $this->entity->getXmlId(), 'TAGS' => '', 'MESSAGE' => $this->entity->getXmlId(), 'AUTHOR_ID' => 0);
     /** @var $request \Bitrix\Main\HttpRequest */
     $request = \Bitrix\Main\Context::getCurrent()->getRequest();
     $post = array_merge($request->getQueryList()->toArray(), $request->getPostList()->toArray());
     $event = new Event("forum", "OnCommentTopicAdd", array($this->entity->getType(), $this->entity->getId(), $post, &$topic));
     $event->send();
     if (strlen($topic["AUTHOR_NAME"]) <= 0) {
         $topic["AUTHOR_NAME"] = $topic["AUTHOR_ID"] <= 0 ? Loc::getMessage("FORUM_USER_SYSTEM") : self::getUserName($topic["AUTHOR_ID"]);
     }
     $topic = array_merge($topic, array("FORUM_ID" => $this->forum["ID"], 'TITLE' => $topic["TITLE"], 'TAGS' => $topic["TAGS"], 'MESSAGE' => $topic["MESSAGE"], "USER_START_ID" => $topic["AUTHOR_ID"], "USER_START_NAME" => $topic["AUTHOR_NAME"], "LAST_POSTER_NAME" => $topic["AUTHOR_NAME"], "XML_ID" => $this->entity->getXmlId(), "APPROVED" => "Y"));
     if (($tid = \CForumTopic::add($topic)) > 0) {
         if ($this->forum["ALLOW_HTML"] != "Y") {
             $topic['MESSAGE'] = strip_tags($topic['MESSAGE']);
         }
         $fields = array("POST_MESSAGE" => $topic['MESSAGE'], "AUTHOR_ID" => $topic["AUTHOR_ID"], "AUTHOR_NAME" => $topic["AUTHOR_NAME"], "FORUM_ID" => $topic["FORUM_ID"], "TOPIC_ID" => $tid, "APPROVED" => $topic["APPROVED"], "NEW_TOPIC" => "Y", "PARAM1" => $this->entity->getType(), "PARAM2" => $this->entity->getId());
         if (\CForumMessage::Add($fields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N")) > 0) {
             $event = new Event("forum", "OnAfterCommentTopicAdd", array($this->entity->getType(), $this->entity->getId(), $tid));
             $event->send();
             self::$topics[$this->entity->getXmlId()] = $topic + array("ID" => $tid);
             return self::$topics[$this->entity->getXmlId()];
         }
         \CForumTopic::Delete($tid);
     }
     $this->errorCollection->add(array(new Error(Loc::getMessage("FORUM_CM_TOPIC_IS_NOT_CREATED"), self::ERROR_PARAMS_TOPIC_ID)));
     return null;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:28,代码来源:baseobject.php


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