本文整理汇总了PHP中CSearch::DeleteIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::DeleteIndex方法的具体用法?PHP CSearch::DeleteIndex怎么用?PHP CSearch::DeleteIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::DeleteIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BXDeleteFromSystem
function BXDeleteFromSystem($absoluteFilePath, $path, $site)
{
$io = CBXVirtualIo::GetInstance();
$f = $io->GetFile($absoluteFilePath);
$f->MarkWritable();
if (COption::GetOptionInt("main", "disk_space") > 0) {
$file_size = $f->GetFileSize();
$quota = new CDiskQuota();
$quota->UpdateDiskQuota("file", $file_size, "delete");
}
$sucess = $io->Delete($absoluteFilePath);
if (!$sucess) {
return false;
}
if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") {
$res_log['path'] = substr($path, 1);
CEventLog::Log("content", "PAGE_DELETE", "main", "", serialize($res_log));
}
$GLOBALS["APPLICATION"]->RemoveFileAccessPermission(array($site, $path));
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("main", $site . "|" . $path);
}
//Delete from rewrite rule
CUrlRewriter::Delete(array("SITE_ID" => $site, "PATH" => $path));
if (class_exists("\\Bitrix\\Main\\Application", false)) {
\Bitrix\Main\Component\ParametersTable::deleteByFilter(array("SITE_ID" => $site, "REAL_PATH" => $path));
}
return true;
}
示例2: SetGroupPerms
function SetGroupPerms($ID, $blogID, $postID = 0, $permission = BLOG_PERMS_DENY, $permsType = BLOG_PERMS_POST)
{
global $DB;
$ID = IntVal($ID);
$blogID = IntVal($blogID);
$postID = IntVal($postID);
$arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]);
if (!in_array($permission, $arAvailPerms)) {
$permission = $arAvailPerms[0];
}
$permsType = $permsType == BLOG_PERMS_COMMENT ? BLOG_PERMS_COMMENT : BLOG_PERMS_POST;
$bSuccess = True;
$arUserGroup = CBlogUserGroup::GetByID($ID);
if (!$arUserGroup) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("BLG_GUG_ERROR_NO_USER_GROUP")), "ERROR_NO_USER_GROUP");
$bSuccess = False;
}
if ($bSuccess) {
$arBlog = CBlog::GetByID($blogID);
if (!$arBlog) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $blogID, GetMessage("BLG_GUG_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
$bSuccess = False;
}
}
if ($bSuccess) {
if ($postID > 0) {
$arPost = CBlogPost::GetByID($postID);
if (!$arPost) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $postID, GetMessage("BLG_GUG_ERROR_NO_POST")), "ERROR_NO_POST");
$bSuccess = False;
}
}
}
if ($bSuccess) {
$oldGroupPerms = CBlogUserGroup::GetGroupPerms(1, $blogID, 0, BLOG_PERMS_POST);
$DB->StartTransaction();
$currentPerms = CBlogUserGroup::GetGroupPerms($ID, $blogID, $postID, $permsType);
if ($currentPerms) {
if ($currentPerms != $permission) {
if ($postID > 0) {
$DB->Query("UPDATE b_blog_user_group_perms SET " . "\tPERMS = '" . $DB->ForSql($permission) . "' " . "WHERE BLOG_ID = " . $blogID . " " . "\tAND POST_ID = " . $postID . " " . "\tAND USER_GROUP_ID = " . $ID . "" . "\tAND PERMS_TYPE = '" . $DB->ForSql($permsType) . "'");
} else {
$DB->Query("UPDATE b_blog_user_group_perms SET " . "\tPERMS = '" . $DB->ForSql($permission) . "' " . "WHERE BLOG_ID = " . $blogID . " " . "\tAND USER_GROUP_ID = " . $ID . " " . "\tAND PERMS_TYPE = '" . $DB->ForSql($permsType) . "'" . "\tAND POST_ID IS NULL ");
}
}
} else {
if ($postID > 0) {
$DB->Query("INSERT INTO b_blog_user_group_perms (BLOG_ID, USER_GROUP_ID, PERMS_TYPE, POST_ID, PERMS) " . "VALUES (" . $blogID . ", " . $ID . ", '" . $DB->ForSql($permsType) . "', " . $postID . ", '" . $DB->ForSql($permission) . "') ");
} else {
$DB->Query("INSERT INTO b_blog_user_group_perms (BLOG_ID, USER_GROUP_ID, PERMS_TYPE, POST_ID, PERMS) " . "VALUES (" . $blogID . ", " . $ID . ", '" . $DB->ForSql($permsType) . "', null, '" . $DB->ForSql($permission) . "') ");
}
}
$DB->Commit();
unset($GLOBALS["BLOG_USER_GROUP"]["BLOG_GROUP_PERMS_CACHE_" . $blogID . "_" . $postID . "_" . $permsType . "_" . $ID]);
unset($GLOBALS["BLOG_USER_GROUP"]["BLOG_USER_PERMS_CACHE_" . $blogID . "_" . $postID . "_" . $permsType]);
}
if ($bSuccess) {
if (CModule::IncludeModule("search")) {
$newGroupPerms = CBlogUserGroup::GetGroupPerms(1, $blogID, 0, BLOG_PERMS_POST);
if ($oldGroupPerms >= BLOG_PERMS_READ && $newGroupPerms < BLOG_PERMS_READ) {
CSearch::DeleteIndex("blog", false, $blogID);
} elseif ($oldGroupPerms < BLOG_PERMS_READ && $newGroupPerms >= BLOG_PERMS_READ) {
}
}
}
return $bSuccess;
}
示例3: Delete
public static final function Delete($lesson_id)
{
global $USER_FIELD_MANAGER;
list($lesson_id, $simulate, $check_permissions, $user_id) = self::_funcDelete_ParseOptions($lesson_id);
if ($check_permissions) {
$oAccess = CLearnAccess::GetInstance($user_id);
if (!$oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_REMOVE)) {
throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
}
// Parents and childs of the lesson
$arNeighboursEdges = self::ListImmediateNeighbours($lesson_id);
// precache rights for lesson
if ($check_permissions) {
$IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
$IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
}
foreach (GetModuleEvents('learning', 'OnBeforeLessonDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($lesson_id));
}
foreach ($arNeighboursEdges as $arEdge) {
$child_lesson_id = (int) $arEdge['CHILD_LESSON'];
$parent_lesson_id = (int) $arEdge['PARENT_LESSON'];
if ($check_permissions) {
$IsLessonAccessible = false;
if ($child_lesson_id === $lesson_id) {
// if we will be remove edge to parent - use precached rights for OP_LESSON_UNLINK_FROM_PARENTS
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS && $oAccess->IsLessonAccessible($parent_lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
} elseif ($parent_lesson_id === $lesson_id) {
// if we will be remove edge to child - use precached rights for OP_LESSON_UNLINK_DESCENDANTS
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS && $oAccess->IsLessonAccessible($child_lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
} else {
throw new LearnException('EA_FATAL: $lesson_id (' . $lesson_id . ') not equal to one of: $child_lesson_id (' . $child_lesson_id . '), $parent_lesson_id (' . $parent_lesson_id . ')', LearnException::EXC_ERR_ALL_LOGIC | LearnException::EXC_ERR_ALL_GIVEUP);
}
if (!$IsLessonAccessible) {
throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
if ($simulate === false) {
self::RelationRemove($parent_lesson_id, $child_lesson_id);
}
}
}
$linkedCourseId = self::GetLinkedCourse($lesson_id);
// If lesson is course, remove course
if ($linkedCourseId !== false) {
global $DB;
if ($simulate === false) {
if (!$DB->Query("DELETE FROM b_learn_course_site WHERE COURSE_ID = " . (int) $linkedCourseId, true)) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
$rc = self::CourseBecomeLesson($linkedCourseId);
// if course cannot be converted to lesson - don't remove lesson
if ($rc === false) {
throw new LearnException('EA_OTHER: lesson is unremovable because linked course is in use.', LearnException::EXC_ERR_LL_UNREMOVABLE_CL);
}
// reload cache of LINKED_LESSON_ID -> COURSE_ID
self::GetCourseToLessonMap_ReloadCache();
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("learning", false, "C" . $linkedCourseId);
CSearch::DeleteIndex("learning", "C" . $linkedCourseId);
}
}
}
// And remove lesson
if ($simulate === false) {
global $DB;
$r = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE \n\t\t\t\tFROM b_learn_lesson \n\t\t\t\tWHERE ID = " . (int) $lesson_id, true);
if ($r === false) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
$arRes = $r->Fetch();
if (!$arRes) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
CFile::Delete($arRes['PREVIEW_PICTURE']);
CFile::Delete($arRes['DETAIL_PICTURE']);
// Remove questions
$q = CLQuestion::GetList(array(), array('LESSON_ID' => $lesson_id));
while ($arQ = $q->Fetch()) {
if (!CLQuestion::Delete($arQ['ID'])) {
throw new LearnException('EA_QUESTION_NOT_REMOVED', LearnException::EXC_ERR_ALL_GIVEUP);
}
}
CLearnGraphNode::Remove($lesson_id);
$USER_FIELD_MANAGER->delete('LEARNING_LESSONS', $lesson_id);
CLearnCacheOfLessonTreeComponent::MarkAsDirty();
CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'L #' . $lesson_id, 'DESCRIPTION' => 'lesson removed'));
if (CModule::IncludeModule('search')) {
CSearch::DeleteIndex('learning', false, 'L' . $lesson_id);
CSearch::DeleteIndex('learning', 'L' . $lesson_id);
}
}
if ($simulate === false) {
foreach (GetModuleEvents('learning', 'OnAfterLessonDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($lesson_id));
}
}
}
示例4: UpdateSearch
//.........这里部分代码省略.........
if (strlen($ar["USER_TYPE"]) > 0) {
$arUT = CIBlockProperty::GetUserType($ar["USER_TYPE"]);
if (array_key_exists("GetSearchContent", $arUT)) {
$ar["GetSearchContent"] = $arUT["GetSearchContent"];
} elseif (array_key_exists("GetPublicViewHTML", $arUT)) {
$ar["GetSearchContent"] = $arUT["GetPublicViewHTML"];
}
}
$arProperties[$IBLOCK_ID][$ar["ID"]] = $ar;
}
}
//Read current property values from database
$strProperties = "";
if (count($arProperties[$IBLOCK_ID]) > 0) {
if ($arIBlockElement["VERSION"] == 1) {
$rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_property\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID in (" . implode(", ", array_keys($arProperties[$IBLOCK_ID])) . ")\n\t\t\t\t\t");
while ($ar = $rs->Fetch()) {
$strProperties .= "\r\n";
$arProperty = $arProperties[$IBLOCK_ID][$ar["IBLOCK_PROPERTY_ID"]];
if ($arProperty["GetSearchContent"]) {
$strProperties .= CSearch::KillTags(call_user_func_array($arProperty["GetSearchContent"], array($arProperty, array("VALUE" => $ar["VALUE"]), array())));
} elseif ($arProperty["PROPERTY_TYPE"] == 'L') {
$arEnum = CIBlockPropertyEnum::GetByID($ar["VALUE"]);
if ($arEnum !== false) {
$strProperties .= $arEnum["VALUE"];
}
} elseif ($arProperty["PROPERTY_TYPE"] == 'F') {
$arFile = CIBlockElement::__GetFileContent($ar["VALUE"]);
if (is_array($arFile)) {
$strProperties .= $arFile["CONTENT"];
$arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
}
} else {
$strProperties .= $ar["VALUE"];
}
}
} else {
$rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_prop_m" . $IBLOCK_ID . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID in (" . implode(", ", array_keys($arProperties[$IBLOCK_ID])) . ")\n\t\t\t\t\t");
while ($ar = $rs->Fetch()) {
$strProperties .= "\r\n";
$arProperty = $arProperties[$IBLOCK_ID][$ar["IBLOCK_PROPERTY_ID"]];
if ($arProperty["GetSearchContent"]) {
$strProperties .= CSearch::KillTags(call_user_func_array($arProperty["GetSearchContent"], array($arProperty, array("VALUE" => $ar["VALUE"]), array())));
} elseif ($arProperty["PROPERTY_TYPE"] == 'L') {
$arEnum = CIBlockPropertyEnum::GetByID($ar["VALUE"]);
if ($arEnum !== false) {
$strProperties .= $arEnum["VALUE"];
}
} elseif ($arProperty["PROPERTY_TYPE"] == 'F') {
$arFile = CIBlockElement::__GetFileContent($ar["VALUE"]);
if (is_array($arFile)) {
$strProperties .= $arFile["CONTENT"];
$arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
}
} else {
$strProperties .= $ar["VALUE"];
}
}
$rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_prop_s" . $IBLOCK_ID . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t");
if ($ar = $rs->Fetch()) {
foreach ($arProperties[$IBLOCK_ID] as $property_id => $property) {
if (array_key_exists("PROPERTY_" . $property_id, $ar) && $property["MULTIPLE"] == "N" && strlen($ar["PROPERTY_" . $property_id]) > 0) {
$strProperties .= "\r\n";
if ($property["GetSearchContent"]) {
$strProperties .= CSearch::KillTags(call_user_func_array($property["GetSearchContent"], array($property, array("VALUE" => $ar["PROPERTY_" . $property_id]), array())));
} elseif ($property["PROPERTY_TYPE"] == 'L') {
$arEnum = CIBlockPropertyEnum::GetByID($ar["PROPERTY_" . $property_id]);
if ($arEnum !== false) {
$strProperties .= $arEnum["VALUE"];
}
} elseif ($property["PROPERTY_TYPE"] == 'F') {
$arFile = CIBlockElement::__GetFileContent($ar["PROPERTY_" . $property_id]);
if (is_array($arFile)) {
$strProperties .= $arFile["CONTENT"];
$arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
}
} else {
$strProperties .= $ar["PROPERTY_" . $property_id];
}
}
}
}
}
}
$BODY .= $strProperties;
if ($arIBlockElement["RIGHTS_MODE"] !== "E") {
$arPermissions = $arGroups[$IBLOCK_ID];
} else {
$obElementRights = new CIBlockElementRights($IBLOCK_ID, $arIBlockElement["ID"]);
$arPermissions = $obElementRights->GetGroups(array("element_read"));
}
$arFields = array("LAST_MODIFIED" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : $arIBlockElement["LAST_MODIFIED"], "DATE_FROM" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : false, "DATE_TO" => strlen($arIBlockElement["DATE_TO"]) > 0 ? $arIBlockElement["DATE_TO"] : false, "TITLE" => $arIBlockElement["NAME"], "PARAM1" => $arIBlockElement["IBLOCK_TYPE_ID"], "PARAM2" => $IBLOCK_ID, "SITE_ID" => $arSITE[$IBLOCK_ID], "PERMISSIONS" => $arPermissions, "URL" => $DETAIL_URL, "BODY" => $BODY, "TAGS" => $arIBlockElement["TAGS"]);
if ($arIBlockElement["SOCNET_GROUP_ID"] > 0) {
$arFields["PARAMS"] = array("socnet_group" => $arIBlockElement["SOCNET_GROUP_ID"]);
}
CSearch::Index("iblock", $ID, $arFields, $bOverWrite);
} else {
CSearch::DeleteIndex("iblock", $ID);
}
}
示例5: UnInstallDB
function UnInstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
$arSQLErrors = array();
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("iblock");
}
if (!CModule::IncludeModule("iblock")) {
return false;
}
$arSql = $arErr = array();
if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
$rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array(), false);
while ($arIBlock = $rsIBlock->Fetch()) {
if ($arIBlock["VERSION"] == 2) {
$arSql[] = "DROP TABLE b_iblock_element_prop_s" . $arIBlock["ID"];
$arSql[] = "DROP TABLE b_iblock_element_prop_m" . $arIBlock["ID"];
if ($DBType == "oracle") {
$arSql[] = "DROP SEQUENCE sq_b_iblock_element_prop_m" . $arIBlock["ID"];
}
}
$GLOBALS["USER_FIELD_MANAGER"]->OnEntityDelete("IBLOCK_" . $arIBlock["ID"] . "._SECTION");
}
foreach ($arSql as $strSql) {
if (!$DB->Query($strSql, true)) {
$arSQLErrors[] = "<hr><pre>Query:\n" . $strSql . "\n\nError:\n<font color=red>" . $DB->db_Error . "</font></pre>";
}
}
$db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'iblock'");
while ($arRes = $db_res->Fetch()) {
CFile::Delete($arRes["ID"]);
}
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/iblock/install/db/" . $DBType . "/uninstall.sql");
$this->UnInstallTasks();
}
if (is_array($this->errors)) {
$arSQLErrors = array_merge($arSQLErrors, $this->errors);
}
if (!empty($arSQLErrors)) {
$this->errors = $arSQLErrors;
$APPLICATION->ThrowException(implode("", $arSQLErrors));
return false;
}
UnRegisterModuleDependences("main", "OnGroupDelete", "iblock", "CIBlock", "OnGroupDelete");
UnRegisterModuleDependences("main", "OnBeforeLangDelete", "iblock", "CIBlock", "OnBeforeLangDelete");
UnRegisterModuleDependences("main", "OnLangDelete", "iblock", "CIBlock", "OnLangDelete");
UnRegisterModuleDependences("main", "OnUserTypeRightsCheck", "iblock", "CIBlockSection", "UserTypeRightsCheck");
UnRegisterModuleDependences("search", "OnReindex", "iblock", "CIBlock", "OnSearchReindex");
UnRegisterModuleDependences("search", "OnSearchGetURL", "iblock", "CIBlock", "OnSearchGetURL");
UnRegisterModuleDependences("main", "OnEventLogGetAuditTypes", "iblock", "CIBlock", "GetAuditTypes");
UnRegisterModuleDependences("main", "OnEventLogGetAuditHandlers", "iblock", "CEventIBlock", "MakeIBlockObject");
UnRegisterModuleDependences("main", "OnGetRatingContentOwner", "iblock", "CRatingsComponentsIBlock", "OnGetRatingContentOwner");
UnRegisterModuleDependences("main", "OnTaskOperationsChanged", "iblock", "CIBlockRightsStorage", "OnTaskOperationsChanged");
UnRegisterModuleDependences("main", "OnGroupDelete", "iblock", "CIBlockRightsStorage", "OnGroupDelete");
UnRegisterModuleDependences("main", "OnUserDelete", "iblock", "CIBlockRightsStorage", "OnUserDelete");
UnRegisterModuleDependences("perfmon", "OnGetTableSchema", "iblock", "iblock", "OnGetTableSchema");
UnRegisterModuleDependences("sender", "OnConnectorList", "iblock", "\\Bitrix\\Iblock\\SenderEventHandler", "onConnectorListIblock");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_DateTime_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_XmlID_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_FileMan_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_HTML_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_ElementList_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_Sequence_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_ElementAutoComplete_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_SKU_GetUserTypeDescription");
UnRegisterModuleDependences("iblock", "OnIBlockPropertyBuildList", "iblock", "CIBlockProperty", "_SectionAutoComplete_GetUserTypeDescription");
UnRegisterModule("iblock");
return true;
}
示例6: UnInstallDB
function UnInstallDB($arParams = Array())
{
global $DB, $DBType, $APPLICATION;
if(array_key_exists("savedata", $arParams) && $arParams["savedata"] != "Y")
{
$errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/blog/install/".$DBType."/uninstall.sql");
if (!empty($errors))
{
$APPLICATION->ThrowException(implode("", $errors));
return false;
}
else
{
$this->UnInstallUserFields();
}
}
if (CModule::IncludeModule("search"))
CSearch::DeleteIndex("blog");
UnRegisterModuleDependences("search", "OnReindex", "blog", "CBlogSearch", "OnSearchReindex");
UnRegisterModuleDependences("main", "OnUserDelete", "blog", "CBlogUser", "Delete");
UnRegisterModuleDependences("main", "OnSiteDelete", "blog", "CBlogSitePath", "DeleteBySiteID");
UnRegisterModuleDependences("socialnetwork", "OnSocNetGroupDelete", "blog", "CBlogSoNetPost", "OnGroupDelete");
UnRegisterModuleDependences("socialnetwork", "OnSocNetFeaturesAdd", "blog", "CBlogSearch", "SetSoNetFeatureIndexSearch");
UnRegisterModuleDependences("socialnetwork", "OnSocNetFeaturesUpdate", "blog", "CBlogSearch", "SetSoNetFeatureIndexSearch");
UnRegisterModuleDependences("socialnetwork", "OnSocNetFeaturesPermsAdd", "blog", "CBlogSearch", "SetSoNetFeaturePermIndexSearch");
UnRegisterModuleDependences("socialnetwork", "OnSocNetFeaturesPermsUpdate", "blog", "CBlogSearch", "SetSoNetFeaturePermIndexSearch");
UnRegisterModuleDependences("main", "OnAfterAddRating", "blog", "CRatingsComponentsBlog", "OnAfterAddRating");
UnRegisterModuleDependences("main", "OnAfterUpdateRating", "blog", "CRatingsComponentsBlog", "OnAfterUpdateRating");
UnRegisterModuleDependences("main", "OnSetRatingsConfigs", "blog", "CRatingsComponentsBlog", "OnSetRatingConfigs");
UnRegisterModuleDependences("main", "OnGetRatingsConfigs", "blog", "CRatingsComponentsBlog", "OnGetRatingConfigs");
UnRegisterModuleDependences("main", "OnGetRatingsObjects", "blog", "CRatingsComponentsBlog", "OnGetRatingObject");
UnRegisterModuleDependences("main", "OnGetRatingContentOwner", "blog", "CRatingsComponentsBlog", "OnGetRatingContentOwner");
UnRegisterModuleDependences("im", "OnGetNotifySchema", "blog", "CBlogNotifySchema", "OnGetNotifySchema");
UnRegisterModuleDependences("main", "OnAfterRegisterModule", "main", "blog", "installUserFields", "/modules/blog/install/index.php"); // check UF
UnRegisterModuleDependences('conversion', 'OnGetCounterTypes' , 'blog', '\Bitrix\Blog\Internals\ConversionHandlers', 'onGetCounterTypes');
UnRegisterModuleDependences('conversion', 'OnGetRateTypes' , 'blog', '\Bitrix\Blog\Internals\ConversionHandlers', 'onGetRateTypes');
UnRegisterModuleDependences('blog', 'OnPostAdd', 'blog', '\Bitrix\Blog\Internals\ConversionHandlers', 'onPostAdd');
UnRegisterModule("blog");
return true;
}
示例7: Update
//.........这里部分代码省略.........
}
if (is_set($arFields, "SITE_ID")) {
$arFields["LID"] = $arFields["SITE_ID"];
}
if (is_set($arFields, "SECTION_PROPERTY")) {
$arFields["SECTION_PROPERTY"] = "Y";
}
$RIGHTS_MODE = CIBlock::GetArrayByID($ID, "RIGHTS_MODE");
if (!$this->CheckFields($arFields, $ID)) {
$Result = false;
$arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR;
} else {
$arLID = array();
$str_LID = "";
if (is_set($arFields, "LID")) {
if (is_array($arFields["LID"])) {
$arLID = $arFields["LID"];
} else {
$arLID[] = $arFields["LID"];
}
$arFields["LID"] = false;
$str_LID = "''";
foreach ($arLID as $v) {
$arFields["LID"] = $v;
$str_LID .= ", '" . $DB->ForSql($v) . "'";
}
}
unset($arFields["ID"]);
unset($arFields["VERSION"]);
if (array_key_exists("PICTURE", $arFields)) {
$SAVED_PICTURE = $arFields["PICTURE"];
CFile::SaveForDB($arFields, "PICTURE", "iblock");
}
$strUpdate = $DB->PrepareUpdate("b_iblock", $arFields, "iblock");
if (array_key_exists("PICTURE", $arFields)) {
$arFields["PICTURE"] = $SAVED_PICTURE;
}
$arBinds = array();
if (is_set($arFields, "DESCRIPTION")) {
$arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"];
}
if (strlen($strUpdate) > 0) {
$strSql = "UPDATE b_iblock SET " . $strUpdate . " WHERE ID=" . $ID;
$DB->QueryBind($strSql, $arBinds);
}
$this->SetMessages($ID, $arFields);
if (isset($arFields["FIELDS"]) && is_array($arFields["FIELDS"])) {
$this->SetFields($ID, $arFields["FIELDS"]);
}
if (array_key_exists("RIGHTS_MODE", $arFields)) {
if ($arFields["RIGHTS_MODE"] === "E" && $RIGHTS_MODE !== "E") {
CIBlock::SetPermission($ID, array());
} elseif ($arFields["RIGHTS_MODE"] !== "E" && $RIGHTS_MODE === "E") {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->DeleteAllRights();
}
if ($arFields["RIGHTS_MODE"] === "E") {
$RIGHTS_MODE = "E";
}
}
if ($RIGHTS_MODE === "E") {
if (!array_key_exists("RIGHTS", $arFields) && array_key_exists("GROUP_ID", $arFields) && is_array($arFields["GROUP_ID"])) {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->SetRights($obIBlockRights->ConvertGroups($arFields["GROUP_ID"]));
} elseif (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->SetRights($arFields["RIGHTS"]);
}
} else {
if (array_key_exists("GROUP_ID", $arFields) && is_array($arFields["GROUP_ID"])) {
CIBlock::SetPermission($ID, $arFields["GROUP_ID"]);
}
}
if (!empty($arLID)) {
$strSql = "DELETE FROM b_iblock_site WHERE IBLOCK_ID=" . $ID;
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$strSql = "INSERT INTO b_iblock_site(IBLOCK_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
}
if (CModule::IncludeModule("search")) {
$dbAfter = $DB->Query("SELECT ACTIVE FROM b_iblock WHERE ID=" . $ID);
$arAfter = $dbAfter->Fetch();
if ($arAfter["ACTIVE"] != "Y") {
CSearch::DeleteIndex("iblock", false, false, $ID);
}
}
$_SESSION["SESS_RECOUNT_DB"] = "Y";
$Result = true;
}
$this->CleanCache($ID);
$arFields["ID"] = $ID;
$arFields["RESULT"] =& $Result;
foreach (GetModuleEvents("iblock", "OnAfterIBlockUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->ClearByTag("iblock_id_" . $ID);
}
return $Result;
}
示例8: Delete
//.........这里部分代码省略.........
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
return false;
}
}
$arGroup = CSocNetGroup::GetByID($ID);
if (!$arGroup) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_NO_GROUP"), "ERROR_NO_GROUP");
return false;
}
$DB->StartTransaction();
$events = GetModuleEvents("socialnetwork", "OnSocNetGroupDelete");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID));
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_user2group WHERE GROUP_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccessTmp = true;
$dbResult = CSocNetFeatures::GetList(array(), array("ENTITY_ID" => $ID, "ENTITY_TYPE" => SONET_ENTITY_GROUP));
while ($arResult = $dbResult->Fetch()) {
$bSuccessTmp = $DB->Query("DELETE FROM b_sonet_features2perms WHERE FEATURE_ID = " . $arResult["ID"] . "", true);
if (!$bSuccessTmp) {
break;
}
}
if (!$bSuccessTmp) {
$bSuccess = false;
}
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_features WHERE ENTITY_ID = " . $ID . " AND ENTITY_TYPE = '" . $DB->ForSql(SONET_ENTITY_GROUP, 1) . "'", true);
}
if ($bSuccess) {
$dbResult = CSocNetLog::GetList(array(), array("ENTITY_ID" => $ID, "ENTITY_TYPE" => SONET_ENTITY_GROUP), false, false, array("ID"));
while ($arResult = $dbResult->Fetch()) {
$bSuccessTmp = $DB->Query("DELETE FROM b_sonet_log_site WHERE LOG_ID = " . $arResult["ID"] . "", true);
if (!$bSuccessTmp) {
break;
}
$bSuccessTmp = $DB->Query("DELETE FROM b_sonet_log_right WHERE LOG_ID = " . $arResult["ID"] . "", true);
if (!$bSuccessTmp) {
break;
}
}
if (!$bSuccessTmp) {
$bSuccess = false;
}
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_log WHERE ENTITY_TYPE = '" . SONET_ENTITY_GROUP . "' AND ENTITY_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = CSocNetLog::DeleteSystemEventsByGroupID($ID);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_log_events WHERE ENTITY_TYPE = 'G' AND ENTITY_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_group_site WHERE GROUP_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_sonet_log_right WHERE GROUP_CODE LIKE 'SG" . $ID . "\\_%' OR GROUP_CODE = 'SG" . $ID . "'", true);
}
if ($bSuccess) {
$bSuccess = CSocNetSubscription::DeleteEx(false, "SG" . $ID);
}
if ($bSuccess) {
CFile::Delete($arGroup["IMAGE_ID"]);
$bSuccess = $DB->Query("DELETE FROM b_sonet_group WHERE ID = " . $ID . "", true);
}
if ($bSuccess) {
CUserOptions::DeleteOption("socialnetwork", "~menu_" . SONET_ENTITY_GROUP . "_" . $ID, false, 0);
unset($GLOBALS["SONET_GROUP_CACHE"][$ID]);
}
if ($bSuccess) {
$DB->Commit();
} else {
$DB->Rollback();
}
if ($bSuccess) {
unset($GLOBALS["SONET_GROUP_CACHE"][$ID]);
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_user2group_G" . $ID);
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_user2group");
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_group_" . $ID);
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_group");
}
}
if ($bSuccess && CModule::IncludeModule("search")) {
CSearch::DeleteIndex("socialnetwork", "G" . $ID);
}
if ($bSuccess) {
$DB->Query("DELETE FROM b_sonet_event_user_view WHERE ENTITY_TYPE = '" . SONET_ENTITY_GROUP . "' AND ENTITY_ID = " . $ID, true);
}
if ($bSuccess) {
$GLOBALS["USER_FIELD_MANAGER"]->Delete("SONET_GROUP", $ID);
}
return $bSuccess;
}
示例9: Update
function Update($ID, $arFields)
{
global $DB;
if (is_set($arFields, "EXTERNAL_ID")) {
$arFields["XML_ID"] = $arFields["EXTERNAL_ID"];
}
if (is_set($arFields, "PICTURE")) {
if (strlen($arFields["PICTURE"]["name"]) <= 0 && strlen($arFields["PICTURE"]["del"]) <= 0) {
unset($arFields["PICTURE"]);
} else {
$pic_res = $DB->Query("SELECT PICTURE FROM b_iblock WHERE ID=" . $ID);
if ($pic_res = $pic_res->Fetch()) {
$arFields["PICTURE"]["old_file"] = $pic_res["PICTURE"];
}
}
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "INDEX_SECTION") && $arFields["INDEX_SECTION"] != "Y") {
$arFields["INDEX_SECTION"] = "N";
}
if (is_set($arFields, "INDEX_ELEMENT") && $arFields["INDEX_ELEMENT"] != "Y") {
$arFields["INDEX_ELEMENT"] = "N";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (!$this->CheckFields(&$arFields, $ID)) {
$Result = false;
$arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR;
} else {
$arLID = array();
if (is_set($arFields, "LID")) {
if (is_array($arFields["LID"])) {
$arLID = $arFields["LID"];
} else {
$arLID[] = $arFields["LID"];
}
$arFields["LID"] = false;
$str_LID = "''";
foreach ($arLID as $v) {
$arFields["LID"] = $v;
$str_LID .= ", '" . $DB->ForSql($v) . "'";
}
}
unset($arFields["ID"]);
unset($arFields["VERSION"]);
$strUpdate = $DB->PrepareUpdate("b_iblock", $arFields, "iblock");
$arBinds = array();
if (is_set($arFields, "DESCRIPTION")) {
$arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"];
}
$strSql = "UPDATE b_iblock SET " . $strUpdate . " WHERE ID=" . $ID;
$DB->QueryBind($strSql, $arBinds);
if (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
CIBlock::SetPermission($ID, $arFields["GROUP_ID"]);
}
if (count($arLID) > 0) {
$strSql = "DELETE FROM b_iblock_site WHERE IBLOCK_ID=" . $ID;
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$strSql = "INSERT INTO b_iblock_site(IBLOCK_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
}
if (CModule::IncludeModule("search")) {
$dbafter = $DB->Query("SELECT ACTIVE, DETAIL_PAGE_URL, LID FROM b_iblock WHERE ID=" . $ID);
$arAfter = $dbafter->Fetch();
if ($arAfter["ACTIVE"] != "Y") {
CSearch::DeleteIndex("iblock", false, false, $ID);
} else {
if (is_set($arFields, "GROUP_ID")) {
$arPerms = array();
$arGroupsPerm = $arFields["GROUP_ID"];
$arGroups = array_keys($arGroupsPerm);
for ($i = 0; $i < count($arGroups); $i++) {
if ($arGroupsPerm[$arGroups[$i]] >= "R") {
if ($arGroups[$i] == 2) {
$arPerms = array(2);
break;
}
$arPerms[] = $arGroups[$i];
}
}
CSearch::ChangePermission("iblock", $arPerms, false, false, $ID);
}
}
}
$Result = true;
}
$arFields["ID"] = $ID;
$arFields["RESULT"] =& $Result;
$events = GetModuleEvents("iblock", "OnAfterIBlockUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEvent($arEvent, &$arFields);
}
return $Result;
}
示例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;
}
示例11: DeleteSearch
public static function DeleteSearch($ENTITY_TYPE, $ENTITY_ID)
{
if (CModule::IncludeModule('search')) {
CSearch::DeleteIndex('crm', $ENTITY_TYPE . '.' . $ENTITY_ID);
}
}
示例12: UnInstallDB
function UnInstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/learning/install/db/" . strtolower($DB->type) . "/uninstall.sql");
// remove module permissions data
self::_RightsModelPurge();
}
//delete agents
CAgent::RemoveModuleAgents("learning");
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("learning");
}
UnRegisterModuleDependences("search", "OnReindex", "learning", "CCourse", "OnSearchReindex");
UnRegisterModuleDependences("main", "OnGroupDelete", "learning", "CCourse", "OnGroupDelete");
UnRegisterModuleDependences("main", "OnBeforeLangDelete", "learning", "CCourse", "OnBeforeLangDelete");
UnRegisterModuleDependences("main", "OnUserDelete", "learning", "CCourse", "OnUserDelete");
UnRegisterModuleDependences("main", "OnGetRatingContentOwner", "learning", "CRatingsComponentsLearning", "OnGetRatingContentOwner");
UnRegisterModuleDependences("main", "OnAddRatingVote", "learning", "CRatingsComponentsLearning", "OnAddRatingVote");
UnRegisterModuleDependences("main", "OnCancelRatingVote", "learning", "CRatingsComponentsLearning", "OnCancelRatingVote");
UnRegisterModuleDependences("main", "OnEventLogGetAuditTypes", "learning", "CLearningEvent", "GetAuditTypes");
UnRegisterModuleDependences("main", "OnEventLogGetAuditHandlers", "learning", "CLearningEvent", "MakeMainObject");
UnRegisterModuleDependences("learning", "OnAfterLearningGroupDelete", "learning", "CLearningGroupMember", "onAfterLearningGroupDelete");
UnRegisterModuleDependences("learning", "OnAfterLearningGroupDelete", "learning", "CLearningGroupLesson", "onAfterLearningGroupDelete");
UnRegisterModule("learning");
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
}
return true;
}
示例13: InstallModule
private static function InstallModule($_1232657444, $_648941904)
{
if (IsModuleInstalled($_1232657444) == $_648941904) {
return true;
}
$_1446218066 = $_SERVER[___916150341(192)] . ___916150341(193) . $_1232657444 . ___916150341(194);
if (!$GLOBALS['____1171756193'][88]($_1446218066)) {
return false;
}
include_once $_1446218066;
$_1473549090 = $GLOBALS['____1171756193'][89](___916150341(195), ___916150341(196), $_1232657444);
if (!$GLOBALS['____1171756193'][90]($_1473549090)) {
return false;
}
$_1184539036 = new $_1473549090();
if ($_648941904) {
if (!$_1184539036->InstallDB()) {
return false;
}
$_1184539036->InstallEvents();
if (!$_1184539036->InstallFiles()) {
return false;
}
} else {
if (CModule::$GLOBALS['_____1046378448'][17](___916150341(197))) {
CSearch::DeleteIndex($_1232657444);
}
UnRegisterModule($_1232657444);
}
return true;
}
示例14: 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;
}
示例15: Delete
function Delete($ID)
{
global $DB;
$ID = IntVal($ID);
$bSuccess = True;
$db_events = GetModuleEvents("blog", "OnBeforeBlogDelete");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
return false;
}
}
$events = GetModuleEvents("blog", "OnBlogDelete");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID));
}
$arBlog = CBlog::GetByID($ID);
$DB->StartTransaction();
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_user2blog WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_user_group_perms WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_user2user_group WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_user_group WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_trackback WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_comment WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_post WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog_category WHERE BLOG_ID = " . $ID . "", true);
}
if ($bSuccess) {
unset($GLOBALS["BLOG"]["BLOG_CACHE_" . $ID]);
unset($GLOBALS["BLOG"]["BLOG4OWNER_CACHE_" . $arBlog["OWNER_ID"]]);
}
if ($bSuccess) {
$bSuccess = $DB->Query("DELETE FROM b_blog WHERE ID = " . $ID . "", true);
}
if ($bSuccess) {
$DB->Commit();
} else {
$DB->Rollback();
}
if ($bSuccess) {
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("blog", false, "COMMENT", $ID . "|%");
CSearch::DeleteIndex("blog", false, "POST", $ID);
CSearch::DeleteIndex("blog", "B" . $ID);
}
}
if ($bSuccess) {
$res = CBlogImage::GetList(array(), array("BLOG_ID" => $ID));
while ($aImg = $res->Fetch()) {
CBlogImage::Delete($aImg['ID']);
}
}
if ($bSuccess) {
$GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_BLOG", $ID);
}
CBlog::DeleteSocnetRead($ID);
return $bSuccess;
}