Beispiel #1
0
 function OnBeforeUserDeleteHandler($user_id)
 {
     \CModule::IncludeModule("iblock");
     \CModule::IncludeModule("sale");
     //Привязки к соц. сетям
     $arrFilter = array("IBLOCK_ID" => USER_SOCIAL_IB, "PROPERTY_USER_ID" => $user_id);
     $arSelect = array("ID");
     $rsRes = \CIBlockElement::GetList($arOrder, $arrFilter, false, false, $arSelect);
     while ($arItem = $rsRes->GetNext()) {
         \CIBlockElement::Delete($arItem["ID"]);
     }
     //Удаляем записи
     $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_USER_ID" => $user_id), 'select' => array("ID")));
     while ($arRecord = $result->fetch()) {
         \CRecordEx::delete($arRecord["ID"]);
     }
     //Удаляем счет
     if ($arAccount = \CSaleUserAccount::GetByUserID($user_id, "RUR")) {
         \CSaleUserAccount::Delete($arAccount["ID"]);
     }
     //Удаляем заказы
     $arFilter = array("USER_ID" => $user_id);
     $db_sales = \CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
     while ($ar_sales = $db_sales->Fetch()) {
         \CSaleOrder::Delete($ar_sales["ID"]);
     }
     //Удаляем подписки
     $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_USER_ID" => $user_id), 'select' => array("ID")));
     if ($arSub = $result->fetch()) {
         \Hawkart\Megatv\SubscribeTable::delete($arSub["ID"]);
     }
 }
Beispiel #2
0
	/**
	 * Удаление остатков привязанных к каталогу
	 * 
	 * @param int $ID - идентификатор удаляемого элемента
	 */
	public function OnIBlockElementDelete($ID)
	{
		global $APPLICATION;

		if(!CModule::IncludeModule("iblock"))
			return;
			
		$rs = CIBlockElement::GetList(
			array(),
			array("IBLOCK_ID" => REMAINS_IBLOCK_ID, "PROPERTY_ELEMENT_ID" => $ID),
			false,
			false,
			array("ID", "IBLOCK_ID"));
		
		while($ar = $rs -> Fetch())
			CIBlockElement::Delete($ar["ID"]);
			
		$rs = CIBlockElement::GetList(
			array(),
			array("IBLOCK_ID" => REMAINS_IBLOCK_ID, "PROPERTY_ELEMENT_ID" => $ID),
			false,
			false,
			array("ID", "IBLOCK_ID"));
			
		if($rs -> SelectedRowsCount())
			return false;
		
		return true;
	}
Beispiel #3
0
/**
 * [removeProjects description]
 * @param  int $id
 * @return bool
 */
function removeProjects($id)
{
    if (!CModule::IncludeModule('iblock')) {
        return false;
    }
    return CIBlockElement::Delete($id);
}
 /**
  * Удаляет элемент
  *
  * @param int $id
  *
  * @return bool
  *
  * @throws DeleteException
  */
 public function delete($id)
 {
     global $APPLICATION;
     if ($this->iBEGateway->Delete($id)) {
         return true;
     }
     $internalException = $APPLICATION->GetException();
     throw new DeleteException($internalException ? $internalException->GetString() : 'Undefined exception', $id, $internalException ? $internalException->GetID() : 0);
 }
Beispiel #5
0
function clear_section($iblock_id, $section_id)
{
    $items_raw = CIBlockElement::GetList(array("SORT" => "ASC"), array("SECTION_ID" => $section_id));
    while ($el = $items_raw->GetNext()) {
        $id = $el["ID"];
        //test_dump($el);
        //echo $id . "<br>";
        CIBlockElement::Delete($id);
    }
}
 function executeDown()
 {
     CModule::IncludeModule('iblock');
     $obj_ib_element = new CIBlockElement();
     $r = $obj_ib_element->Delete(2);
     if (!$r) {
         throw new \Exception('Fail do remove element with id = 1');
     }
     return true;
 }
Beispiel #7
0
	/**
	 * [delProducts description]
	 * @param array $arProducts
	 * @return bool
	 */
	protected function delProducts($arProducts){
		if (!CModule::IncludeModule("iblock")):
			return false;
		endif;
		foreach ($arProducts as $key => $prod) :
			if (!CIBlockElement::Delete($prod["ID"])):
				return false;
			endif;
		endforeach;
		return true;	
	}
Beispiel #8
0
 /**
  * <p>Метод удаляет Wiki-страницу. Динамичный метод.</p>
  *
  *
  * @param int $ID  Идентификатор Wiki-страницы
  *
  * @param int $IBLOCK_ID  Идентификатор Инфо.блока. <br> До версии 10.0.0 назывался <b>BLOCK_ID</b>.
  *
  * @return bool 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?<br>// Удалим Wiki-страницу с идентификатором 13 в инфо.блоке с идентификатором 2<br>$ID = 13;<br>$IBLOCK_ID = 2;<br><br>$CWiki = new CWiki();<br>if (!$CWiki-&gt;Delete($ID, $IBLOCK_ID))<br>	echo 'Ошибка. Страница не удалена.';<br>?&gt;
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/wiki/classes/cwiki/Delete.php
  * @author Bitrix
  */
 public function Delete($ID, $IBLOCK_ID)
 {
     $rIBlock = CIBlock::getList(array(), array('ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'));
     $arIBlock = $rIBlock->GetNext();
     // erase the history of changes
     if ($arIBlock['BIZPROC'] == 'Y' && CModule::IncludeModule('bizproc')) {
         $historyService = new CBPHistoryService();
         $historyService->DeleteHistoryByDocument(array('iblock', 'CWikiDocument', $ID));
     }
     $this->CleanCacheById($ID, $IBLOCK_ID);
     // delete item
     $bResult = $this->cIB_E->Delete($ID);
     return $bResult;
 }
 public function down()
 {
     //Удаляем все элементы по 10 штук за раз
     $helper = new IblockHelper();
     $iblockId1 = $helper->getIblockId('content_news');
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $dbRes = \CIBlockElement::GetList(array(), array('IBLOCK_ID' => $iblockId1), false, array('nTopCount' => 10));
     $bFound = 0;
     while ($aItem = $dbRes->Fetch()) {
         \CIBlockElement::Delete($aItem['ID']);
         $this->out('deleted %d', $aItem['ID']);
         $bFound++;
     }
     if ($bFound) {
         $this->restart();
     }
 }
Beispiel #10
0
function __InTaskDeleteTask($delTaskId, $iblockId, $taskType, $ownerId, $arParams)
{
    $delTaskId = IntVal($delTaskId);
    $iblockId = IntVal($iblockId);
    $ownerId = IntVal($ownerId);
    if ($delTaskId <= 0 || $iblockId <= 0 || $ownerId <= 0) {
        return "";
    }
    $errorMessage = "";
    if (StrLen($errorMessage) <= 0) {
        $sectionId = 0;
        $dbElementSections = CIBlockElement::GetElementGroups($delTaskId);
        while ($arElementSection = $dbElementSections->Fetch()) {
            if ($arElementSection["IBLOCK_ID"] == $iblockId) {
                $sectionId = $arElementSection["ID"];
                break;
            }
        }
        if ($sectionId <= 0) {
            $errorMessage .= GetMessage("INTL_TASK_NOT_FOUND") . ".";
        }
    }
    if (StrLen($errorMessage) <= 0) {
        $dbSectionsChain = CIBlockSection::GetNavChain($iblockId, $sectionId);
        if ($arSect = $dbSectionsChain->GetNext()) {
            if ($taskType == 'group' && $arSect["XML_ID"] != $ownerId) {
                $errorMessage .= GetMessage("INTL_TASK_INTERNAL_ERROR") . " GTK003" . ". ";
            } elseif ($taskType != 'group' && $arSect["XML_ID"] != "users_tasks") {
                $errorMessage .= GetMessage("INTL_TASK_INTERNAL_ERROR") . " GTK004" . ". ";
            }
        } else {
            $errorMessage .= GetMessage("INTL_FOLDER_NOT_FOUND") . ". ";
        }
    }
    if (StrLen($errorMessage) <= 0) {
        if (!CIBlockElement::Delete($delTaskId)) {
            $errorMessage .= GetMessage("INTL_ERROR_DELETE_TASK") . ". ";
        }
        CAgent::RemoveAgent("CIntranetTasks::SendRemindEventAgent(" . $iblockId . ", " . $delTaskId . ", \"" . $arParams[$taskType == "user" ? "PATH_TO_USER_TASKS_TASK" : "PATH_TO_GROUP_TASKS_TASK"] . "\");", "intranet");
    }
    return $errorMessage;
}
Beispiel #11
0
 /**
  * ћетод публикует документ. “о есть делает его доступным в публичной части сайта.
  *
  * @param string $documentId - код документа.
  */
 public function PublishDocument($documentId)
 {
     global $DB;
     $ID = intval($documentId);
     $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID"));
     if ($ar_element = $db_element->Fetch()) {
         $PARENT_ID = intval($ar_element["WF_PARENT_ELEMENT_ID"]);
         if ($PARENT_ID) {
             // TODO: ≈сли в документе $documentId поле WF_PARENT_ELEMENT_ID не NULL, то при публикации нужно перенести данные
             // (скопировать документ) из документа $documentId в документ WF_PARENT_ELEMENT_ID,
             $obElement = new CIBlockElement();
             $ar_element["WF_PARENT_ELEMENT_ID"] = false;
             if ($ar_element["PREVIEW_PICTURE"]) {
                 $ar_element["PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element["PREVIEW_PICTURE"]);
             } else {
                 $ar_element["PREVIEW_PICTURE"] = array("tmp_name" => "", "del" => "Y");
             }
             if ($ar_element["DETAIL_PICTURE"]) {
                 $ar_element["DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element["DETAIL_PICTURE"]);
             } else {
                 $ar_element["DETAIL_PICTURE"] = array("tmp_name" => "", "del" => "Y");
             }
             $ar_element["IBLOCK_SECTION"] = array();
             if ($ar_element["IN_SECTIONS"] == "Y") {
                 $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
                 while ($arSection = $rsSections->Fetch()) {
                     $ar_element["IBLOCK_SECTION"][] = $arSection["ID"];
                 }
             }
             $ar_element["PROPERTY_VALUES"] = array();
             $arProps =& $ar_element["PROPERTY_VALUES"];
             //Delete old files
             $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $PARENT_ID, array("value_id" => "asc"), array("PROPERTY_TYPE" => "F", "EMPTY" => "N"));
             while ($arProp = $rsProps->Fetch()) {
                 if (!array_key_exists($arProp["ID"], $arProps)) {
                     $arProps[$arProp["ID"]] = array();
                 }
                 $arProps[$arProp["ID"]][$arProp["PROPERTY_VALUE_ID"]] = array("VALUE" => array("tmp_name" => "", "del" => "Y"), "DESCRIPTION" => false);
             }
             //Add new proiperty values
             $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_element["ID"], array("value_id" => "asc"));
             $i = 0;
             while ($arProp = $rsProps->Fetch()) {
                 $i++;
                 if (!array_key_exists($arProp["ID"], $arProps)) {
                     $arProps[$arProp["ID"]] = array();
                 }
                 if ($arProp["PROPERTY_VALUE_ID"]) {
                     if ($arProp["PROPERTY_TYPE"] == "F") {
                         $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => CFile::MakeFileArray($arProp["VALUE"]), "DESCRIPTION" => $arProp["DESCRIPTION"]);
                     } else {
                         $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]);
                     }
                 }
             }
             $obElement->Update($PARENT_ID, $ar_element);
             // вызвать CBPDocument::MergeDocuments(WF_PARENT_ELEMENT_ID, $documentId) дл¤ переноса состо¤ний и истории Ѕѕ,
             CBPDocument::MergeDocuments(array("iblock", "CIBlockDocument", $PARENT_ID), array("iblock", "CIBlockDocument", $documentId));
             // грохнуть документ $documentId,
             CIBlockElement::Delete($ID);
             // опубликовать документ WF_PARENT_ELEMENT_ID
             CIBlockElement::WF_CleanUpHistoryCopies($PARENT_ID, 0);
             $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $PARENT_ID . " AND WF_PARENT_ELEMENT_ID IS NULL";
             $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
             CIBlockElement::UpdateSearch($PARENT_ID);
             return $PARENT_ID;
         } else {
             // ≈сли WF_PARENT_ELEMENT_ID равно NULL, то все как раньше.
             CIBlockElement::WF_CleanUpHistoryCopies($ID, 0);
             $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $ID . " AND WF_PARENT_ELEMENT_ID IS NULL";
             $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
             CIBlockElement::UpdateSearch($ID);
             return $ID;
         }
     }
     return false;
 }
Beispiel #12
0
 }
 /*Take action*/
 if ($_POST["action_button_" . $arResult["GRID_ID"]] == "section") {
     if (!$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockSectionRights::UserHasRightTo($arIBlock["ID"], $_POST["section_to_move"], "section_element_bind"))) {
         $rsElements = CIBlockElement::GetList(array(), $arFilter, false, false, array("ID"));
         while ($arElement = $rsElements->Fetch()) {
             $obElement->SetElementSection($arElement["ID"], array($_POST["section_to_move"]), false, $arIBlock["RIGHTS_MODE"] == "E" ? $arIBlock["ID"] : 0);
         }
     }
 } elseif ($_POST["action_button_" . $arResult["GRID_ID"]] == "delete" && isset($_POST["ID"]) && is_array($_POST["ID"])) {
     $rsElements = CIBlockElement::GetList(array(), $arFilter, false, false, array("ID"));
     while ($arElement = $rsElements->Fetch()) {
         if (!$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockElementRights::UserHasRightTo($arIBlock["ID"], $arElement["ID"], "element_delete"))) {
             $DB->StartTransaction();
             $APPLICATION->ResetException();
             if (!$obElement->Delete($arElement["ID"])) {
                 $DB->Rollback();
                 if ($ex = $APPLICATION->GetException()) {
                     $strError = GetMessage("CC_BLL_DELETE_ERROR") . " " . $ex->GetString();
                 } else {
                     $strError = GetMessage("CC_BLL_DELETE_ERROR") . " " . GetMessage("CC_BLL_UNKNOWN_ERROR");
                 }
                 break;
             } else {
                 $DB->Commit();
             }
         }
     }
 }
 if (!isset($_POST["AJAX_CALL"])) {
     if ($strError) {
Beispiel #13
0
********************************************************************/
/********************************************************************
				Action
********************************************************************/
if ($_REQUEST["edit"] == "Y" || $arParams["ACTION"] == "DROP") {
    array_walk($_REQUEST, '__UnEscape');
    $arError = array();
    $result = array();
    if (!check_bitrix_sessid()) {
        $arError[] = array("id" => "bad sessid", "text" => GetMessage("IBLOCK_WRONG_SESSION"));
    } elseif ($arParams["ACTION"] == "DROP") {
        $arResult["ELEMENT"]["PROPERTIES"]["REAL_PICTURE"] = CFile::GetFileArray($arResult["ELEMENT"]["PROPERTIES"]["REAL_PICTURE"]);
        $iFileSize = intVal($arResult["ELEMENT"]["PROPERTIES"]["REAL_PICTURE"]["FILE_SIZE"]);
        @set_time_limit(0);
        $APPLICATION->ResetException();
        if (!CIBlockElement::Delete($arParams["ELEMENT_ID"])) {
            if ($ex = $APPLICATION->GetException()) {
                $arError[] = array("id" => "delete", "text" => $ex->GetString());
            } else {
                $arError[] = array("id" => "delete", "text" => "Element was droped with error.");
            }
        } else {
            $result = array("url" => $arResult["~SECTION_LINK"]);
            $arResult["URL"] = $arResult["~SECTION_LINK"];
        }
    } else {
        $arFields = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_SECTION" => $_REQUEST["TO_SECTION_ID"], "TAGS" => $_REQUEST["TAGS"], "NAME" => $_REQUEST["TITLE"], "PREVIEW_TEXT" => $_REQUEST["DESCRIPTION"], "DETAIL_TEXT" => $_REQUEST["DESCRIPTION"], "DATE_CREATE" => $_REQUEST["DATE_CREATE"], "DETAIL_TEXT_TYPE" => "text", "PREVIEW_TEXT_TYPE" => "text");
        if ($arParams["BEHAVIOUR"] == "USER") {
            $_REQUEST["ACTIVE"] = $_REQUEST["ACTIVE"] == "Y" ? "Y" : "N";
            if ($arParams["ABS_PERMISSION"] >= "U" && $arResult["ELEMENT"]["ACTIVE"] != $_REQUEST["ACTIVE"]) {
                $arFields["ACTIVE"] = $_REQUEST["ACTIVE"];
Beispiel #14
0
 function DeactivateElement($action, $start_time, $interval)
 {
     $counter = array("DEL" => 0, "DEA" => 0, "NON" => 0);
     if (array_key_exists("bUpdateOnly", $this->next_step) && $this->next_step["bUpdateOnly"]) {
         return $counter;
     }
     if ($action != "D" && $action != "A") {
         return $counter;
     }
     $bDelete = $action == "D";
     //This will protect us from deactivating when next_step is lost
     $IBLOCK_ID = intval($this->next_step["IBLOCK_ID"]);
     if ($IBLOCK_ID < 1) {
         return $counter;
     }
     $arFilter = array(">ID" => $this->next_step["LAST_ID"], "IBLOCK_ID" => $IBLOCK_ID);
     if (!$bDelete) {
         $arFilter["ACTIVE"] = "Y";
     }
     $obElement = new CIBlockElement();
     $rsElement = $obElement->GetList(array("ID" => "asc"), $arFilter, false, false, array("ID", "ACTIVE"));
     while ($arElement = $rsElement->Fetch()) {
         $rs = $this->_xml_file->GetList(array(), array("PARENT_ID+0" => 0, "LEFT_MARGIN" => $arElement["ID"]), array("ID"));
         $ar = $rs->Fetch();
         if (!$ar) {
             if ($bDelete) {
                 $obElement->Delete($arElement["ID"]);
                 $counter["DEL"]++;
             } else {
                 $obElement->Update($arElement["ID"], array("ACTIVE" => "N"));
                 $counter["DEA"]++;
             }
         } else {
             $counter["NON"]++;
         }
         $this->next_step["LAST_ID"] = $arElement["ID"];
         if ($interval > 0 && time() - $start_time > $interval) {
             break;
         }
     }
     return $counter;
 }
Beispiel #15
0
 function WF_CleanUpHistoryCopies($ELEMENT_ID = false, $HISTORY_COPIES = false)
 {
     if (CModule::IncludeModule("workflow")) {
         $err_mess = "FILE: " . __FILE__ . "<br>LINE: ";
         global $DB;
         if ($HISTORY_COPIES === false) {
             $HISTORY_COPIES = intval(COption::GetOptionString("workflow", "HISTORY_COPIES", "10"));
         }
         $strSqlSearch = '';
         $ELEMENT_ID = (int) $ELEMENT_ID;
         if ($ELEMENT_ID > 0) {
             $strSqlSearch = " AND ID = {$ELEMENT_ID} ";
         }
         $strSql = "SELECT ID FROM b_iblock_element " . "WHERE (ID=WF_PARENT_ELEMENT_ID or (WF_PARENT_ELEMENT_ID IS NULL AND WF_STATUS_ID=1)) " . $strSqlSearch;
         $z = $DB->Query($strSql, false, $err_mess . __LINE__);
         while ($zr = $z->Fetch()) {
             $DID = $zr["ID"];
             $strSql = "SELECT ID, WF_NEW, WF_PARENT_ELEMENT_ID " . "FROM b_iblock_element " . "WHERE WF_PARENT_ELEMENT_ID = " . $DID . " " . "\tAND WF_PARENT_ELEMENT_ID<>ID " . "\tAND (WF_NEW<>'Y' or WF_NEW is null) " . "ORDER BY ID desc";
             $t = $DB->Query($strSql, false, $err_mess . __LINE__);
             while ($tr = $t->Fetch()) {
                 $i++;
                 if ($i > $HISTORY_COPIES) {
                     $LAST_ID = CIBlockElement::WF_GetLast($DID);
                     if ($LAST_ID != $tr["ID"]) {
                         CIBlockElement::Delete($tr["ID"]);
                     }
                 }
             }
         }
     }
 }
Beispiel #16
0
         $bPermissions = true;
     }
 } else {
     $bPermissions = true;
 }
 if (!$bPermissions) {
     $lAdmin->AddGroupError(GetMessage("IBEL_A_UPDERR3") . " (ID:" . $subID . ")", $subID);
     continue;
 }
 switch ($_REQUEST['action']) {
     case "delete":
         if (CIBlockElementRights::UserHasRightTo($intSubIBlockID, $subID, "element_delete")) {
             @set_time_limit(0);
             $DB->StartTransaction();
             $APPLICATION->ResetException();
             if (!CIBlockElement::Delete($subID)) {
                 $DB->Rollback();
                 if ($ex = $APPLICATION->GetException()) {
                     $lAdmin->AddGroupError(GetMessage("IBLOCK_DELETE_ERROR") . " [" . $ex->GetString() . "]", $subID);
                 } else {
                     $lAdmin->AddGroupError(GetMessage("IBLOCK_DELETE_ERROR"), $subID);
                 }
             } else {
                 $DB->Commit();
             }
         } else {
             $lAdmin->AddGroupError(GetMessage("IBLOCK_DELETE_ERROR") . " [" . $subID . "]", $subID);
         }
         break;
     case "activate":
     case "deactivate":
Beispiel #17
0
 //echo "<pre>"; print_r($arParams); echo "</pre>";
 if ($arParams["ELEMENT_ASSOC"] == "PROPERTY_ID" && intval($arParams["ELEMENT_ASSOC_PROPERTY"]) > 0 && in_array($arParams["ELEMENT_ASSOC_PROPERTY"], $arPropertyIDs)) {
     $arFilter["PROPERTY_" . $arParams["ELEMENT_ASSOC_PROPERTY"]] = $USER->GetID();
 } else {
     $arFilter["CREATED_BY"] = $USER->GetID();
 }
 //echo "<pre>"; print_r($arFilter); echo "</pre>";
 // deleteting element
 if (check_bitrix_sessid() && $_REQUEST["delete"] == "Y" && $arResult["CAN_DELETE"]) {
     $arParams["ID"] = intval($_REQUEST["CODE"]);
     // try to get element with id, for user and for iblock
     $rsElement = CIBLockElement::GetList(array(), array_merge($arFilter, array("ID" => $arParams["ID"])));
     if ($arElement = $rsElement->GetNext()) {
         // delete one
         $DB->StartTransaction();
         if (!CIBlockElement::Delete($arElement["ID"])) {
             $DB->Rollback();
         } else {
             $DB->Commit();
         }
     }
 }
 if ($bWorkflowIncluded) {
     $rsWFStatus = CWorkflowStatus::GetList($by = "c_sort", $order = "asc", array("ACTIVE" => "Y"), $is_filtered);
     $arResult["WF_STATUS"] = array();
     while ($arStatus = $rsWFStatus->GetNext()) {
         $arResult["WF_STATUS"][$arStatus["ID"]] = $arStatus["TITLE"];
     }
 } else {
     $arResult["ACTIVE_STATUS"] = array("Y" => GetMessage("IBLOCK_FORM_STATUS_ACTIVE"), "N" => GetMessage("IBLOCK_FORM_STATUS_INACTIVE"));
 }
Beispiel #18
0
 public function deleteElementIfExists($iblockId, $code)
 {
     $aItem = $this->getElement($iblockId, $code);
     if (!$aItem) {
         return false;
     }
     $ib = new \CIBlockElement();
     if ($ib->Delete($aItem['ID'])) {
         return true;
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
Beispiel #19
0
					{
						$DB->Commit();
					}
				}
				else
				{
					$lAdmin->AddGroupError(GetMessage("IBLIST_A_SECTION_DELETE_ERROR", array("#ID#" => $ID)), $TYPE.$ID);
				}
			}
			elseif($TYPE=="E")
			{
				if(CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_delete"))
				{
					$DB->StartTransaction();
					$APPLICATION->ResetException();
					if(!CIBlockElement::Delete($ID))
					{
						$DB->Rollback();
						if($ex = $APPLICATION->GetException())
							$lAdmin->AddGroupError(GetMessage("IBLIST_A_ELEMENT_DELETE_ERROR", array("#ID#" => $ID))." [".$ex->GetString()."]", $TYPE.$ID);
						else
							$lAdmin->AddGroupError(GetMessage("IBLIST_A_ELEMENT_DELETE_ERROR", array("#ID#" => $ID)), $TYPE.$ID);
					}
					else
					{
						$DB->Commit();
					}
				}
				else
				{
					$lAdmin->AddGroupError(GetMessage("IBLIST_A_ELEMENT_DELETE_ERROR", array("#ID#" => $ID)), $TYPE.$ID);
Beispiel #20
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$id = intval($_GET["event_id"]);
$like = intval($_GET["like"]);
$UID = $USER->GetID();
$ib_id = 6;
$resObj = CIBlockElement::GetByID($id);
$item = $resObj->GetNextElement(true, false);
/*$propItems = $item->GetProperty("USERS");*/
if ($like) {
    $el = new CIBlockElement();
    $PROP = array();
    $PROP['LIKE'] = array("n0" => array("VALUE" => $id, "DESCRIPTION" => ""));
    $PROP['USER'] = array("n0" => array("VALUE" => $UID, "DESCRIPTION" => ""));
    $arLoadProductArray = array("IBLOCK_SECTION" => false, "IBLOCK_ID" => $ib_id, "PROPERTY_VALUES" => $PROP, "NAME" => "like");
    $PRODUCT_ID = id_element;
    $res = $el->Add($arLoadProductArray);
} else {
    $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => 6, "PROPERTY_LIKE" => $id, "PROPERTY_USER" => $USER->GetID()));
    $ob = $res->GetNextElement();
    //echo "<xmp>";print_r($ob);echo "</xmp>";
    if ($ob) {
        $obs = $ob->GetFields();
        $ELEMENT_ID = $obs["ID"];
        CIBlockElement::Delete($ELEMENT_ID);
    }
}
Beispiel #21
0
function DeleteAbsence($absenceID)
{
    if (CModule::IncludeModule('iblock')) {
        CIBlockElement::Delete(intval($absenceID));
    }
}
Beispiel #22
0
                    CIBlockElement::SetPropertyValues($item, $arParams["IBLOCK_ID"], "Y", "PUBLIC_ELEMENT");
                } else {
                    CIBlockElement::SetPropertyValues($item, $arParams["IBLOCK_ID"], "N", "APPROVE_ELEMENT");
                }
                if ($res["ACTIVE"] != "Y") {
                    $_REQUEST["ACTION"] = "active";
                }
                PClearComponentCacheEx($arParams["IBLOCK_ID"]);
            }
            if ($_REQUEST["ACTION"] == "active" || $_REQUEST["ACTION"] == "drop") {
                if ($_REQUEST["ACTION"] == "active") {
                    $arFields = array("ACTIVE" => "Y");
                    $be = new CIBlockElement();
                    $be->Update($item, $arFields);
                } else {
                    CIBlockElement::Delete($item);
                }
                // section
                if (is_set($arSections, $res["IBLOCK_SECTION_ID"])) {
                    $res = $arSections[$res["IBLOCK_SECTION_ID"]];
                }
                PClearComponentCacheEx($arParams["IBLOCK_ID"], array(0, $res["ID"], $res["IBLOCK_SECTION_ID"]));
            }
        }
        LocalRedirect($_REQUEST["from_detail_list"]);
    }
}
$arParams["SHOW_BEST_ELEMENT"] = $arParams["SHOW_BEST_ELEMENT"] == "N" ? "N" : "Y";
$arResult["MENU_VARIABLES"] = array();
if ($this->__page !== "menu") {
    // Include breadcrumbs navigation to the top of all component pages
Beispiel #23
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' => ''));
             }
         }
     }
 }
Beispiel #24
0
    public static function OnBeforePrologHandler()
    {
        global $USER_FIELD_MANAGER;
        if (isset($_REQUEST['action_button']) && !isset($_REQUEST['action'])) {
            $_REQUEST['action'] = $_REQUEST['action_button'];
        }
        if (!isset($_REQUEST['action'])) {
            return;
        }
        $BID = isset($_REQUEST['ID']) ? (int) $_REQUEST['ID'] : 0;
        if ($_REQUEST['action'] == 'asd_prop_export' && $BID > 0 && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($BID)) {
            $strPath = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/tmp/asd.iblock/';
            $strName = 'asd_props_export_' . $BID . '_' . md5(LICENSE_KEY) . '.xml';
            CheckDirPath($strPath);
            if ($hdlOutput = fopen($strPath . $strName, 'wb')) {
                fwrite($hdlOutput, '<?xml version="1.0" encoding="' . SITE_CHARSET . '"?>' . "\n");
                fwrite($hdlOutput, '<asd_iblock_props>' . "\n");
                fwrite($hdlOutput, CASDiblockTools::ExportPropsToXML($BID, $_REQUEST['p']));
                if ($_REQUEST['forms'] == 'Y') {
                    fwrite($hdlOutput, CASDiblockTools::ExportSettingsToXML($BID, array('forms')));
                }
                fwrite($hdlOutput, '</asd_iblock_props>' . "\n");
                fclose($hdlOutput);
            }
            ?>
<script type="text/javascript">
				top.BX.closeWait(); top.BX.WindowManager.Get().AllowClose(); top.BX.WindowManager.Get().Close();
				window.location.href = '/bitrix/tools/asd.iblock/props_export.php?ID=<?php 
            echo $BID;
            ?>
';
			</script><?php 
            die;
        }
        if ($_REQUEST['action'] == 'asd_prop_import' && $BID > 0 && !$_FILES['xml_file']['error'] && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($BID)) {
            CASDiblockTools::ImportPropsFromXML($BID, $_FILES['xml_file']['tmp_name'], $arOldNewID);
            CASDiblockTools::ImportFormsFromXML($BID, $_FILES['xml_file']['tmp_name'], $arOldNewID);
            LocalRedirect('/bitrix/admin/iblock_edit.php?type=' . $_REQUEST['type'] . '&tabControl_active_tab=edit2&lang=' . LANGUAGE_ID . '&ID=' . $BID . '&admin=Y');
        }
        $IBLOCK_ID = 0;
        if (isset($_REQUEST['IBLOCK_ID'])) {
            $IBLOCK_ID = (int) $_REQUEST['IBLOCK_ID'];
            if ($IBLOCK_ID < 0) {
                $IBLOCK_ID = 0;
            }
        }
        if ($_REQUEST['action'] == 'asd_reverse' && $IBLOCK_ID > 0 && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($IBLOCK_ID)) {
            $LIST_MODE = CIBlock::GetArrayByID($IBLOCK_ID, 'LIST_MODE');
            if (!strlen($LIST_MODE)) {
                $LIST_MODE = COption::GetOptionString('iblock', 'combined_list_mode', 'N') == 'Y' ? 'C' : 'S';
            }
            $LIST_MODE = $LIST_MODE == 'C' ? 'S' : 'C';
            $ib = new CIBlock();
            $ib->Update($IBLOCK_ID, array('LIST_MODE' => $LIST_MODE));
            LocalRedirect('/bitrix/admin/' . ($LIST_MODE == 'S' ? 'iblock_element_admin' : 'iblock_list_admin') . '.php?IBLOCK_ID=' . $IBLOCK_ID . '&type=' . htmlspecialcharsbx($_REQUEST['type']) . '&find_section_section=' . intval($_REQUEST['find_section_section']) . '&lang=' . LANGUAGE_ID);
        }
        $strCurPage = $GLOBALS['APPLICATION']->GetCurPage();
        $bElemPage = $strCurPage == '/bitrix/admin/iblock_element_admin.php' || $strCurPage == '/bitrix/admin/cat_product_admin.php';
        $bSectPage = $strCurPage == '/bitrix/admin/iblock_section_admin.php' || $strCurPage == '/bitrix/admin/cat_section_admin.php';
        $bMixPage = $strCurPage == '/bitrix/admin/iblock_list_admin.php';
        $bRightPage = $bElemPage || $bSectPage || $bMixPage;
        $successRedirect = false;
        if ($bRightPage && $_REQUEST['action'] == 'asd_copy_in_list' && strlen($_REQUEST['ID']) > 0) {
            $bDoAction = true;
            $_REQUEST['action'] = 'asd_copy';
            $_REQUEST['asd_ib_dest'] = $IBLOCK_ID;
            $_REQUEST['ID'] = array($_REQUEST['ID']);
        } else {
            $bDoAction = false;
        }
        if ($bRightPage && check_bitrix_sessid() && !empty($_REQUEST['ID']) && ($_SERVER['REQUEST_METHOD'] == 'POST' || $bDoAction) && CModule::IncludeModule('iblock') && ($_REQUEST['action'] == 'asd_copy' || $_REQUEST['action'] == 'asd_move') && isset($_REQUEST['asd_ib_dest']) && (int) $_REQUEST['asd_ib_dest'] > 0 && CASDIblockRights::IsIBlockDisplay($_REQUEST['asd_ib_dest'])) {
            $intSrcIBlockID = $IBLOCK_ID;
            $intDestIBlockID = (int) $_REQUEST['asd_ib_dest'];
            $intSetSectID = 0;
            if (isset($_REQUEST['asd_sect_dest'])) {
                $intSetSectID = (int) $_REQUEST['asd_sect_dest'];
                if ($intSetSectID < 0) {
                    $intSetSectID = 0;
                }
            }
            $boolCreateElement = false;
            $boolCreateSection = false;
            if ($bElemPage || $bMixPage) {
                $boolCreateElement = CASDIblockRights::IsSectionElementCreate($intDestIBlockID, $intSetSectID);
            }
            if ($bSectPage || $bMixPage) {
                $boolCreateSection = CASDIblockRights::IsSectionSectionCreate($intDestIBlockID, $intSetSectID);
            }
            if ($boolCreateElement || $boolCreateSection) {
                $arPropListCache = array();
                $arOldPropListCache = array();
                $arNamePropListCache = array();
                $arOldNamePropListCache = array();
                $boolUFListCache = false;
                $arUFListCache = array();
                $arOldUFListCache = array();
                $arUFEnumCache = array();
                $arOldUFEnumCache = array();
                $arUFNameEnumCache = array();
                $arOldUFNameEnumCache = array();
                $arDestIBlock = CIBlock::GetArrayByID($intDestIBlockID);
                $arDestIBFields = $arDestIBlock['FIELDS'];
                $boolCodeUnique = false;
                if ($arDestIBFields['CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
                    $boolCodeUnique = $intSrcIBlockID == $intDestIBlockID;
                }
                $boolSectCodeUnique = false;
                if ($arDestIBFields['SECTION_CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
                    $boolSectCodeUnique = $intSrcIBlockID == $intDestIBlockID;
                }
                $boolCatalog = CModule::IncludeModule('catalog');
                $boolCopyCatalog = false;
                $boolNewCatalog = false;
                if ($boolCatalog) {
                    $boolCopyCatalog = is_array(CCatalog::GetByID($intDestIBlockID));
                    $boolNewCatalog = $boolCopyCatalog;
                    if ($boolCopyCatalog) {
                        $boolCopyCatalog = is_array(CCatalog::GetByID($intSrcIBlockID));
                    }
                }
                $el = new CIBlockElement();
                $sc = new CIBlockSection();
                $obEnum = new CUserFieldEnum();
                foreach ($_REQUEST['ID'] as $eID) {
                    $boolCopyElem = false;
                    $boolCopySect = false;
                    if ($bMixPage) {
                        if (substr($eID, 0, 1) != 'E') {
                            $boolCopySect = true;
                        } else {
                            $boolCopyElem = true;
                        }
                        $ID = (int) substr($eID, 1);
                    } else {
                        $boolCopyElem = $bElemPage;
                        $boolCopySect = $bSectPage;
                        $ID = (int) $eID;
                    }
                    if ($boolCreateElement && $boolCopyElem) {
                        if ($obSrc = CIBlockElement::GetByID($ID)->GetNextElement()) {
                            $arSrc = $obSrc->GetFields();
                            $arSrcPr = $obSrc->GetProperties(false, array('EMPTY' => 'N'));
                            $arSrc['PREVIEW_PICTURE'] = (int) $arSrc['PREVIEW_PICTURE'];
                            if ($arSrc['PREVIEW_PICTURE'] > 0) {
                                $arSrc['PREVIEW_PICTURE'] = CFile::MakeFileArray($arSrc['PREVIEW_PICTURE']);
                                if (empty($arSrc['PREVIEW_PICTURE'])) {
                                    $arSrc['PREVIEW_PICTURE'] = false;
                                } else {
                                    $arSrc['PREVIEW_PICTURE']['COPY_FILE'] = 'Y';
                                }
                            } else {
                                $arSrc['PREVIEW_PICTURE'] = false;
                            }
                            $arSrc['DETAIL_PICTURE'] = (int) $arSrc['DETAIL_PICTURE'];
                            if ($arSrc['DETAIL_PICTURE'] > 0) {
                                $arSrc['DETAIL_PICTURE'] = CFile::MakeFileArray($arSrc['DETAIL_PICTURE']);
                                if (empty($arSrc['DETAIL_PICTURE'])) {
                                    $arSrc['DETAIL_PICTURE'] = false;
                                } else {
                                    $arSrc['DETAIL_PICTURE']['COPY_FILE'] = 'Y';
                                }
                            } else {
                                $arSrc['DETAIL_PICTURE'] = false;
                            }
                            $arSrc = array('IBLOCK_ID' => $intDestIBlockID, 'ACTIVE' => $arSrc['ACTIVE'], 'ACTIVE_FROM' => $arSrc['ACTIVE_FROM'], 'ACTIVE_TO' => $arSrc['ACTIVE_TO'], 'SORT' => $arSrc['SORT'], 'NAME' => $arSrc['~NAME'], 'PREVIEW_PICTURE' => $arSrc['PREVIEW_PICTURE'], 'PREVIEW_TEXT' => $arSrc['~PREVIEW_TEXT'], 'PREVIEW_TEXT_TYPE' => $arSrc['PREVIEW_TEXT_TYPE'], 'DETAIL_TEXT' => $arSrc['~DETAIL_TEXT'], 'DETAIL_TEXT_TYPE' => $arSrc['DETAIL_TEXT_TYPE'], 'DETAIL_PICTURE' => $arSrc['DETAIL_PICTURE'], 'WF_STATUS_ID' => $arSrc['WF_STATUS_ID'], 'CODE' => $arSrc['~CODE'], 'TAGS' => $arSrc['~TAGS'], 'XML_ID' => $arSrc['~XML_ID'], 'PROPERTY_VALUES' => array());
                            if ($arDestIBFields['CODE']['IS_REQUIRED'] == 'Y') {
                                if (!strlen($arSrc['CODE'])) {
                                    $arSrc['CODE'] = mt_rand(100000, 1000000);
                                }
                            }
                            if ($arDestIBFields['CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
                                $boolElCodeUnique = $boolCodeUnique;
                                if (!$boolCodeUnique) {
                                    $rsCheckItems = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, '=CODE' => $arSrc['CODE'], 'CHECK_PERMISSIONS' => 'N'), false, array('nTopCount' => 1), array('ID', 'IBLOCK_ID'));
                                    if ($arCheck = $rsCheckItems->Fetch()) {
                                        $boolElCodeUnique = true;
                                    }
                                }
                                if ($boolElCodeUnique) {
                                    $arSrc['CODE'] .= mt_rand(100, 10000);
                                }
                            }
                            if ($intSetSectID > 0) {
                                $arSrc['IBLOCK_SECTION_ID'] = $intSetSectID;
                            } elseif ($intSrcIBlockID == $intDestIBlockID) {
                                $arSectionList = array();
                                $rsSections = CIBlockElement::GetElementGroups($ID, true);
                                while ($arSection = $rsSections->Fetch()) {
                                    $arSectionList[] = $arSection['ID'];
                                }
                                $arSrc['IBLOCK_SECTION'] = $arSectionList;
                            }
                            if ($intSrcIBlockID != $intDestIBlockID) {
                                if (empty($arPropListCache)) {
                                    $rsProps = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, 'PROPERTY_TYPE' => 'L', 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'));
                                    while ($arProp = $rsProps->Fetch()) {
                                        $arValueList = array();
                                        $arNameList = array();
                                        $rsValues = CIBlockProperty::GetPropertyEnum($arProp['ID']);
                                        while ($arValue = $rsValues->Fetch()) {
                                            $arValueList[$arValue['XML_ID']] = $arValue['ID'];
                                            $arNameList[$arValue['ID']] = trim($arValue['VALUE']);
                                        }
                                        if (!empty($arValueList)) {
                                            $arPropListCache[$arProp['CODE']] = $arValueList;
                                        }
                                        if (!empty($arNameList)) {
                                            $arNamePropListCache[$arProp['CODE']] = $arNameList;
                                        }
                                    }
                                }
                                if (empty($arOldPropListCache)) {
                                    $rsProps = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $intSrcIBlockID, 'PROPERTY_TYPE' => 'L', 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'));
                                    while ($arProp = $rsProps->Fetch()) {
                                        $arValueList = array();
                                        $arNameList = array();
                                        $rsValues = CIBlockProperty::GetPropertyEnum($arProp['ID']);
                                        while ($arValue = $rsValues->Fetch()) {
                                            $arValueList[$arValue['ID']] = $arValue['XML_ID'];
                                            $arNameList[$arValue['ID']] = trim($arValue['VALUE']);
                                        }
                                        if (!empty($arValueList)) {
                                            $arOldPropListCache[$arProp['CODE']] = $arValueList;
                                        }
                                        if (!empty($arNameList)) {
                                            $arOldNamePropListCache[$arProp['CODE']] = $arNameList;
                                        }
                                    }
                                }
                            }
                            foreach ($arSrcPr as &$arProp) {
                                if ($arProp['USER_TYPE'] == 'HTML') {
                                    if (is_array($arProp['~VALUE'])) {
                                        if ($arProp['MULTIPLE'] == 'N') {
                                            $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array('VALUE' => array('TEXT' => $arProp['~VALUE']['TEXT'], 'TYPE' => $arProp['~VALUE']['TYPE']));
                                            if ($arProp['WITH_DESCRIPTION'] == 'Y') {
                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']]['DESCRIPTION'] = $arProp['~DESCRIPTION'];
                                            }
                                        } else {
                                            if (!empty($arProp['~VALUE'])) {
                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array();
                                                foreach ($arProp['~VALUE'] as $propValueKey => $propValue) {
                                                    $oneNewValue = array('VALUE' => array('TEXT' => $propValue['TEXT'], 'TYPE' => $propValue['TYPE']));
                                                    if ($arProp['WITH_DESCRIPTION'] == 'Y') {
                                                        $oneNewValue['DESCRIPTION'] = $arProp['~DESCRIPTION'][$propValueKey];
                                                    }
                                                    $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $oneNewValue;
                                                    unset($oneNewValue);
                                                }
                                                unset($propValue, $propValueKey);
                                            }
                                        }
                                    }
                                } elseif ($arProp['PROPERTY_TYPE'] == 'F') {
                                    if (is_array($arProp['VALUE'])) {
                                        $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array();
                                        foreach ($arProp['VALUE'] as $propValueKey => $file) {
                                            if ($file > 0) {
                                                $tmpValue = CFile::MakeFileArray($file);
                                                if (!is_array($tmpValue)) {
                                                    continue;
                                                }
                                                if ($arProp['WITH_DESCRIPTION'] == 'Y') {
                                                    $tmpValue = array('VALUE' => $tmpValue, 'DESCRIPTION' => $arProp['~DESCRIPTION'][$propValueKey]);
                                                }
                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $tmpValue;
                                            }
                                        }
                                    } elseif ($arProp['VALUE'] > 0) {
                                        $tmpValue = CFile::MakeFileArray($arProp['VALUE']);
                                        if (is_array($tmpValue)) {
                                            if ($arProp['WITH_DESCRIPTION'] == 'Y') {
                                                $tmpValue = array('VALUE' => $tmpValue, 'DESCRIPTION' => $arProp['~DESCRIPTION']);
                                            }
                                            $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $tmpValue;
                                        }
                                    }
                                } elseif ($arProp['PROPERTY_TYPE'] == 'L') {
                                    if (!empty($arProp['VALUE_ENUM_ID'])) {
                                        if ($intSrcIBlockID == $arSrc['IBLOCK_ID']) {
                                            $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['VALUE_ENUM_ID'];
                                        } else {
                                            if (isset($arPropListCache[$arProp['CODE']]) && isset($arOldPropListCache[$arProp['CODE']])) {
                                                if (is_array($arProp['VALUE_ENUM_ID'])) {
                                                    $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array();
                                                    foreach ($arProp['VALUE_ENUM_ID'] as &$intValueID) {
                                                        $strValueXmlID = $arOldPropListCache[$arProp['CODE']][$intValueID];
                                                        if (isset($arPropListCache[$arProp['CODE']][$strValueXmlID])) {
                                                            $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $arPropListCache[$arProp['CODE']][$strValueXmlID];
                                                        } else {
                                                            $strValueName = $arOldNamePropListCache[$arProp['CODE']][$intValueID];
                                                            $intValueKey = array_search($strValueName, $arNamePropListCache[$arProp['CODE']]);
                                                            if ($intValueKey !== false) {
                                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $intValueKey;
                                                            }
                                                        }
                                                    }
                                                    if (isset($intValueID)) {
                                                        unset($intValueID);
                                                    }
                                                    if (empty($arSrc['PROPERTY_VALUES'][$arProp['CODE']])) {
                                                        unset($arSrc['PROPERTY_VALUES'][$arProp['CODE']]);
                                                    }
                                                } else {
                                                    $strValueXmlID = $arOldPropListCache[$arProp['CODE']][$arProp['VALUE_ENUM_ID']];
                                                    if (isset($arPropListCache[$arProp['CODE']][$strValueXmlID])) {
                                                        $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arPropListCache[$arProp['CODE']][$strValueXmlID];
                                                    } else {
                                                        $strValueName = $arOldNamePropListCache[$arProp['CODE']][$arProp['VALUE_ENUM_ID']];
                                                        $intValueKey = array_search($strValueName, $arNamePropListCache[$arProp['CODE']]);
                                                        if ($intValueKey !== false) {
                                                            $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $intValueKey;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } elseif ($arProp['PROPERTY_TYPE'] == 'S' || $arProp['PROPERTY_TYPE'] == 'N') {
                                    if ($arProp['MULTIPLE'] == 'Y') {
                                        if (is_array($arProp['~VALUE'])) {
                                            if ($arProp['WITH_DESCRIPTION'] == 'Y') {
                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array();
                                                foreach ($arProp['~VALUE'] as $propValueKey => $propValue) {
                                                    $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = array('VALUE' => $propValue, 'DESCRIPTION' => $arProp['~DESCRIPTION'][$propValueKey]);
                                                }
                                                unset($propValue, $propValueKey);
                                            } else {
                                                $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE'];
                                            }
                                        }
                                    } else {
                                        $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['WITH_DESCRIPTION'] == 'Y' ? array('VALUE' => $arProp['~VALUE'], 'DESCRIPTION' => $arProp['~DESCRIPTION']) : $arProp['~VALUE'];
                                    }
                                } else {
                                    $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE'];
                                }
                            }
                            if (isset($arProp)) {
                                unset($arProp);
                            }
                            AddMessage2Log($arSrc['PROPERTY_VALUES']);
                            $intNewID = $el->Add($arSrc, true, true, true);
                            if ($intNewID) {
                                if ($boolCatalog && $boolCopyCatalog) {
                                    $priceRes = CPrice::GetListEx(array(), array('PRODUCT_ID' => $ID), false, false, array('PRODUCT_ID', 'EXTRA_ID', 'CATALOG_GROUP_ID', 'PRICE', 'CURRENCY', 'QUANTITY_FROM', 'QUANTITY_TO'));
                                    while ($arPrice = $priceRes->Fetch()) {
                                        $arPrice['PRODUCT_ID'] = $intNewID;
                                        CPrice::Add($arPrice);
                                    }
                                }
                                if ($boolCatalog && $boolNewCatalog) {
                                    $arProduct = array('ID' => $intNewID);
                                    if ($boolCopyCatalog) {
                                        $productRes = CCatalogProduct::GetList(array(), array('ID' => $ID), false, false, array('QUANTITY', 'QUANTITY_TRACE_ORIG', 'CAN_BUY_ZERO_ORIG', 'NEGATIVE_AMOUNT_TRACE_ORIG', 'SUBSCRIBE_ORIG', 'WEIGHT', 'PRICE_TYPE', 'RECUR_SCHEME_TYPE', 'RECUR_SCHEME_LENGTH', 'TRIAL_PRICE_ID', 'WITHOUT_ORDER', 'SELECT_BEST_PRICE', 'VAT_ID', 'VAT_INCLUDED', 'WIDTH', 'LENGTH', 'HEIGHT', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'MEASURE'));
                                        if ($arCurProduct = $productRes->Fetch()) {
                                            $arProduct = $arCurProduct;
                                            $arProduct['ID'] = $intNewID;
                                            $arProduct['QUANTITY_TRACE'] = $arProduct['QUANTITY_TRACE_ORIG'];
                                            $arProduct['CAN_BUY_ZERO'] = $arProduct['CAN_BUY_ZERO_ORIG'];
                                            $arProduct['NEGATIVE_AMOUNT_TRACE'] = $arProduct['NEGATIVE_AMOUNT_TRACE_ORIG'];
                                            if (isset($arProduct['SUBSCRIBE_ORIG'])) {
                                                $arProduct['SUBSCRIBE'] = $arProduct['SUBSCRIBE_ORIG'];
                                            }
                                            foreach ($arProduct as $productKey => $productValue) {
                                                if ($productValue === null) {
                                                    unset($arProduct[$productKey]);
                                                }
                                            }
                                        }
                                    }
                                    CCatalogProduct::Add($arProduct, false);
                                }
                                if ($_REQUEST['action'] == 'asd_move') {
                                    if (CASDIblockRights::IsElementDelete($intSrcIBlockID, $ID)) {
                                        $el->Delete($ID);
                                    } else {
                                        CASDiblock::$error .= '[' . $ID . '] ' . GetMessage('ASD_ACTION_ERR_DELETE_ELEMENT_RIGHTS') . "\n";
                                    }
                                }
                            } else {
                                CASDiblock::$error .= '[' . $ID . '] ' . $el->LAST_ERROR . "\n";
                            }
                        }
                    }
                    if ($boolCreateSection && $boolCopySect) {
                        if ($_REQUEST['action'] == 'asd_move') {
                            continue;
                        }
                        $rsSections = CIBlockSection::GetList(array(), array('ID' => $ID, 'IBLOCK_ID' => $intSrcIBlockID), false, array('ID', 'NAME', 'XML_ID', 'CODE', 'IBLOCK_SECTION_ID', 'IBLOCK_ID', 'ACTIVE', 'SORT', 'PICTURE', 'DESCRIPTION', 'DESCRIPTION_TYPE', 'DETAIL_PICTURE', 'SOCNET_GROUP_ID', 'UF_*'));
                        if ($arSrcSect = $rsSections->Fetch()) {
                            $arDestSect = $arSrcSect;
                            unset($arDestSect['ID']);
                            $arDestSect['IBLOCK_ID'] = $intDestIBlockID;
                            if ($arDestIBFields['SECTION_CODE']['IS_REQUIRED'] == 'Y') {
                                if (!strlen($arDestSect['CODE'])) {
                                    $arDestSect['CODE'] = mt_rand(100000, 1000000);
                                }
                            }
                            if ($arDestIBFields['SECTION_CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
                                $boolScCodeUnique = $boolSectCodeUnique;
                                if (!$boolSectCodeUnique) {
                                    $rsCheckItems = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, '=CODE' => $arSrc['CODE'], 'CHECK_PERMISSIONS' => 'N'), false, array('nTopCount' => 1), array('ID', 'IBLOCK_ID'));
                                    if ($arCheck = $rsCheckItems->Fetch()) {
                                        $boolScCodeUnique = true;
                                    }
                                }
                                if ($boolScCodeUnique) {
                                    $arDestSect['CODE'] .= mt_rand(100, 10000);
                                }
                            }
                            if ($intSetSectID > 0) {
                                $arDestSect['IBLOCK_SECTION_ID'] = $intSetSectID;
                            } elseif ($intSrcIBlockID != $intDestIBlockID) {
                                $arDestSect['IBLOCK_SECTION_ID'] = 0;
                            }
                            $arDestSect['PICTURE'] = (int) $arDestSect['PICTURE'];
                            if ($arDestSect['PICTURE'] > 0) {
                                $arDestSect['PICTURE'] = CFile::MakeFileArray($arDestSect['PICTURE']);
                                if (empty($arDestSect['PICTURE'])) {
                                    $arDestSect['PICTURE'] = false;
                                } else {
                                    $arDestSect['PICTURE']['COPY_FILE'] = 'Y';
                                }
                            } else {
                                $arDestSect['PICTURE'] = false;
                            }
                            $arDestSect['DETAIL_PICTURE'] = (int) $arDestSect['DETAIL_PICTURE'];
                            if ($arDestSect['DETAIL_PICTURE'] > 0) {
                                $arDestSect['DETAIL_PICTURE'] = CFile::MakeFileArray($arDestSect['DETAIL_PICTURE']);
                                if (empty($arDestSect['DETAIL_PICTURE'])) {
                                    $arDestSect['DETAIL_PICTURE'] = false;
                                } else {
                                    $arDestSect['DETAIL_PICTURE']['COPY_FILE'] = 'Y';
                                }
                            } else {
                                $arDestSect['DETAIL_PICTURE'] = false;
                            }
                            if (!$boolUFListCache) {
                                $boolUFListCache = true;
                                $arUFListCache = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $intDestIBlockID . '_SECTION');
                                if (!empty($arUFListCache)) {
                                    if ($intSrcIBlockID != $intDestIBlockID) {
                                        $arOldUFListCache = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $intSrcIBlockID . '_SECTION');
                                        if (empty($arOldUFListCache)) {
                                            $arUFListCache = array();
                                        }
                                    } else {
                                        $arOldUFListCache = $arUFListCache;
                                    }
                                }
                                if (!empty($arUFListCache)) {
                                    if ($intSrcIBlockID != $intDestIBlockID) {
                                        foreach ($arUFListCache as &$arOneUserField) {
                                            if ('enum' == $arOneUserField['USER_TYPE']['BASE_TYPE']) {
                                                $arUFEnumCache[$arOneUserField['FIELD_NAME']] = array();
                                                $arUFNameEnumCache[$arOneUserField['FIELD_NAME']] = array();
                                                $rsEnum = $obEnum->GetList(array(), array('USER_FIELD_ID' => $arOneUserField['ID']));
                                                while ($arEnum = $rsEnum->Fetch()) {
                                                    $arUFEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['XML_ID']] = $arEnum['ID'];
                                                    $arUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = trim($arEnum['VALUE']);
                                                }
                                            }
                                        }
                                        if (isset($arOneUserField)) {
                                            unset($arOneUserField);
                                        }
                                        foreach ($arOldUFListCache as &$arOneUserField) {
                                            if ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'enum') {
                                                $arOldUFEnumCache[$arOneUserField['FIELD_NAME']] = array();
                                                $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']] = array();
                                                $rsEnum = $obEnum->GetList(array(), array('USER_FIELD_ID' => $arOneUserField['ID']));
                                                while ($arEnum = $rsEnum->Fetch()) {
                                                    $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = $arEnum['XML_ID'];
                                                    $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = trim($arEnum['VALUE']);
                                                }
                                            }
                                        }
                                        if (isset($arOneUserField)) {
                                            unset($arOneUserField);
                                        }
                                    }
                                }
                            }
                            if (!empty($arUFListCache)) {
                                foreach ($arUFListCache as &$arOneUserField) {
                                    if (!isset($arDestSect[$arOneUserField['FIELD_NAME']])) {
                                        continue;
                                    }
                                    if ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'file') {
                                        if (!empty($arDestSect[$arOneUserField['FIELD_NAME']])) {
                                            if (is_array($arDestSect[$arOneUserField['FIELD_NAME']])) {
                                                $arNewFileList = array();
                                                foreach ($arDestSect[$arOneUserField['FIELD_NAME']] as &$intFileID) {
                                                    $arNewFile = false;
                                                    $intFileID = (int) $intFileID;
                                                    if ($intFileID > 0) {
                                                        $arNewFile = CFile::MakeFileArray($intFileID);
                                                    }
                                                    if (!empty($arNewFile)) {
                                                        $arNewFileList[] = $arNewFile;
                                                    }
                                                }
                                                if (isset($intFileID)) {
                                                    unset($intFileID);
                                                }
                                                $arDestSect[$arOneUserField['FIELD_NAME']] = !empty($arNewFileList) ? $arNewFileList : false;
                                            } else {
                                                $arNewFile = false;
                                                $intFileID = (int) $arDestSect[$arOneUserField['FIELD_NAME']];
                                                if ($intFileID > 0) {
                                                    $arNewFile = CFile::MakeFileArray($intFileID);
                                                }
                                                $arDestSect[$arOneUserField['FIELD_NAME']] = !empty($arNewFile) ? $arNewFile : false;
                                            }
                                        } else {
                                            $arDestSect[$arOneUserField['FIELD_NAME']] = false;
                                        }
                                    } elseif ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'enum') {
                                        if (!empty($arDestSect[$arOneUserField['FIELD_NAME']])) {
                                            if ($intSrcIBlockID != $intDestIBlockID) {
                                                if (array_key_exists($arOneUserField['FIELD_NAME'], $arUFEnumCache) && array_key_exists($arOneUserField['FIELD_NAME'], $arOldUFEnumCache)) {
                                                    if (is_array($arDestSect[$arOneUserField['FIELD_NAME']])) {
                                                        $arNewEnumList = array();
                                                        foreach ($arDestSect[$arOneUserField['FIELD_NAME']] as &$intValueID) {
                                                            $strValueXmlID = $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$intValueID];
                                                            if (array_key_exists($strValueXmlID, $arUFEnumCache[$arOneUserField['FIELD_NAME']])) {
                                                                $arNewEnumList[] = $arUFEnumCache[$arOneUserField['FIELD_NAME']][$strValueXmlID];
                                                            } else {
                                                                $strValueName = $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$intValueID];
                                                                $intValueKey = array_search($strValueName, $arUFNameEnumCache[$arOneUserField['FIELD_NAME']]);
                                                                if ($intValueKey !== false) {
                                                                    $arNewEnumList[] = $intValueKey;
                                                                }
                                                            }
                                                        }
                                                        if (isset($intValueID)) {
                                                            unset($intValueID);
                                                        }
                                                        if (!empty($arNewEnumList)) {
                                                            $arDestSect[$arOneUserField['FIELD_NAME']] = $arNewEnumList;
                                                        }
                                                    } else {
                                                        $strValueXmlID = $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$arDestSect[$arOneUserField['FIELD_NAME']]];
                                                        if (array_key_exists($strValueXmlID, $arUFEnumCache[$arOneUserField['FIELD_NAME']])) {
                                                            $arDestSect[$arOneUserField['FIELD_NAME']] = $arUFEnumCache[$arOneUserField['FIELD_NAME']][$strValueXmlID];
                                                        } else {
                                                            $strValueName = $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arDestSect[$arOneUserField['FIELD_NAME']]];
                                                            $intValueKey = array_search($strValueName, $arUFNameEnumCache[$arOneUserField['FIELD_NAME']]);
                                                            if ($intValueKey !== false) {
                                                                $arDestSect[$arOneUserField['FIELD_NAME']] = $intValueKey;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        } else {
                                            $arDestSect[$arOneUserField['FIELD_NAME']] = false;
                                        }
                                    }
                                }
                                if (isset($arOneUserField)) {
                                    unset($arOneUserField);
                                }
                            }
                            $intNewID = $sc->Add($arDestSect);
                            if (!$intNewID) {
                                CASDiblock::$error .= '[' . $ID . '] ' . $sc->LAST_ERROR . "\n";
                            }
                        }
                    }
                }
                $successRedirect = true;
            }
            unset($_REQUEST['action']);
            if (isset($_REQUEST['action_button'])) {
                unset($_REQUEST['action_button']);
            }
            if ($successRedirect) {
                LocalRedirect($GLOBALS['APPLICATION']->GetCurPageParam('', array('action', 'action_button', 'asd_ib_dest', 'asd_sect_dest', 'ID')));
            }
        }
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'asd_remove' && $IBLOCK_ID > 0 && isset($_REQUEST['find_section_section']) && check_bitrix_sessid() && CASDIblockRights::IsIBlockDisplay($IBLOCK_ID)) {
            $intSectionID = (int) $_REQUEST['find_section_section'];
            if ($intSectionID > 0) {
                $strCurPage = $GLOBALS['APPLICATION']->GetCurPage();
                $bElemPage = $strCurPage == '/bitrix/admin/iblock_element_admin.php' || $strCurPage == '/bitrix/admin/cat_product_admin.php';
                $bMixPage = $strCurPage == '/bitrix/admin/iblock_list_admin.php';
                if ($bElemPage || $bMixPage) {
                    foreach ($_REQUEST['ID'] as $eID) {
                        if ($bMixPage) {
                            if (substr($eID, 0, 1) != 'E') {
                                continue;
                            }
                            $ID = (int) substr($eID, 1);
                        } else {
                            $ID = (int) $eID;
                        }
                        if ($ID <= 0) {
                            continue;
                        }
                        if (CASDIblockRights::IsElementEdit($IBLOCK_ID, $ID)) {
                            $arSectionList = array();
                            $rsSections = CIBlockElement::GetElementGroups($ID, true);
                            while ($arSection = $rsSections->Fetch()) {
                                $arSection['ID'] = (int) $arSection['ID'];
                                if ($arSection['ID'] != $intSectionID) {
                                    $arSectionList[] = $arSection['ID'];
                                }
                            }
                            CIBlockElement::SetElementSection($ID, $arSectionList, false);
                            $successRedirect = true;
                        }
                    }
                }
            }
            unset($_REQUEST['action']);
            if (isset($_REQUEST['action_button'])) {
                unset($_REQUEST['action_button']);
            }
            if ($successRedirect) {
                LocalRedirect($GLOBALS['APPLICATION']->GetCurPageParam('', array('action', 'action_button')));
            }
        }
    }
Beispiel #25
0
         } else {
             $bDeactivationStarted = true;
             $bs->Update($arr["ID"], array("NAME" => $arr["NAME"], "ACTIVE" => "N", "TMP_ID" => $tmpid));
         }
         if (!($bAllLinesLoaded = CSVCheckTimeout($max_execution_time))) {
             break;
         }
     }
 }
 // update or delete 'not-in-file' elements
 if ($bAllLinesLoaded && $outFileAction != "F") {
     $arProductArray = array('QUANTITY' => 0, 'QUANTITY_TRACE' => 'Y', 'CAN_BUY_ZERO' => 'N', 'NEGATIVE_AMOUNT_TRACE' => 'N');
     $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, "!TMP_ID" => $tmpid), false, false, array('ID'));
     while ($arr = $res->Fetch()) {
         if ($outFileAction == "D") {
             CIBlockElement::Delete($arr["ID"], "Y", "N");
             $killed_lines++;
         } elseif ($outFileAction == "F") {
         } elseif ($bIBlockIsCatalog && $outFileAction == "M") {
             CCatalogProduct::Update($arr['ID'], $arProductArray);
             $killed_lines++;
         } else {
             $bDeactivationStarted = true;
             $el->Update($arr["ID"], array("ACTIVE" => "N", "TMP_ID" => $tmpid));
             $killed_lines++;
         }
         if (!($bAllLinesLoaded = CSVCheckTimeout($max_execution_time))) {
             break;
         }
     }
 }
Beispiel #26
0
 /**
  * <p>Функция удаляет информационный блок.</p>
  *
  *
  *
  *
  * @param int $ID  Код информационного блока.
  *
  *
  *
  * @return bool <a href="http://dev.1c-bitrix.ru/api_help/iblock/events/onbeforeiblockdelete.php">OnBeforeIBlockDelete</a><a
  * name="examples"></a>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?<br>if($USER-&gt;IsAdmin())<br>{<br>	$DB-&gt;StartTransaction();<br>	if(!CIBlock::Delete($iblock_id))<br>	{<br>		$strWarning .= GetMessage("IBLOCK_DELETE_ERROR");<br>		$DB-&gt;Rollback();<br>	}<br>	else<br>		$DB-&gt;Commit();<br>}<br>?&gt;<br>
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/delete.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     $err_mess = "FILE: " . __FILE__ . "<br>LINE: ";
     /** @global CDatabase $DB */
     global $DB;
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     /** @global CUserTypeManager $USER_FIELD_MANAGER */
     global $USER_FIELD_MANAGER;
     /** @global CCacheManager $CACHE_MANAGER */
     global $CACHE_MANAGER;
     $ID = IntVal($ID);
     $APPLICATION->ResetException();
     foreach (GetModuleEvents("iblock", "OnBeforeIBlockDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             $err = GetMessage("MAIN_BEFORE_DEL_ERR") . ' ' . $arEvent['TO_NAME'];
             $ex = $APPLICATION->GetException();
             if (is_object($ex)) {
                 $err .= ': ' . $ex->GetString();
             }
             $APPLICATION->throwException($err);
             return false;
         }
     }
     foreach (GetModuleEvents("iblock", "OnIBlockDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     $iblockSections = CIBlockSection::GetList(array(), array("IBLOCK_ID" => $ID, "DEPTH_LEVEL" => 1, "CHECK_PERMISSIONS" => "N"), false, array("ID"));
     while ($iblockSection = $iblockSections->Fetch()) {
         if (!CIBlockSection::Delete($iblockSection["ID"], false)) {
             return false;
         }
     }
     $iblockElements = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $ID, "SHOW_NEW" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array("IBLOCK_ID", "ID"));
     while ($iblockElement = $iblockElements->Fetch()) {
         if (!CIBlockElement::Delete($iblockElement["ID"])) {
             return false;
         }
     }
     $props = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $ID, "CHECK_PERMISSIONS" => "N"));
     while ($property = $props->Fetch()) {
         if (!CIBlockProperty::Delete($property["ID"])) {
             return false;
         }
     }
     $seq = new CIBlockSequence($ID);
     $seq->Drop(true);
     $obIBlockRights = new CIBlockRights($ID);
     $obIBlockRights->DeleteAllRights();
     CIBlockSectionPropertyLink::DeleteByIBlock($ID);
     $DB->Query("delete from b_iblock_offers_tmp where PRODUCT_IBLOCK_ID=" . $ID, false, $err_mess . __LINE__);
     $DB->Query("delete from b_iblock_offers_tmp where OFFERS_IBLOCK_ID=" . $ID, false, $err_mess . __LINE__);
     if (!$DB->Query("DELETE FROM b_iblock_messages WHERE IBLOCK_ID = " . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     if (!$DB->Query("DELETE FROM b_iblock_fields WHERE IBLOCK_ID = " . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     $USER_FIELD_MANAGER->OnEntityDelete("IBLOCK_" . $ID . "_SECTION");
     if (!$DB->Query("DELETE FROM b_iblock_group WHERE IBLOCK_ID=" . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     if (!$DB->Query("DELETE FROM b_iblock_rss WHERE IBLOCK_ID=" . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     if (!$DB->Query("DELETE FROM b_iblock_site WHERE IBLOCK_ID=" . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     if (!$DB->Query("DELETE FROM b_iblock WHERE ID=" . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     $DB->Query("DROP TABLE b_iblock_element_prop_s" . $ID, true, $err_mess . __LINE__);
     $DB->Query("DROP TABLE b_iblock_element_prop_m" . $ID, true, $err_mess . __LINE__);
     $DB->Query("DROP SEQUENCE sq_b_iblock_element_prop_m" . $ID, true, $err_mess . __LINE__);
     CIBlock::CleanCache($ID);
     if (defined("BX_COMP_MANAGED_CACHE")) {
         $CACHE_MANAGER->ClearByTag("iblock_id_" . $ID);
     }
     $_SESSION["SESS_RECOUNT_DB"] = "Y";
     return true;
 }
Beispiel #27
0
 public static function ReleaseVideoRoom($Params)
 {
     $arFilter = array("ID" => $Params['mrevid'], "IBLOCK_ID" => $Params['VMiblockId']);
     $res = CIBlockElement::GetList(array(), $arFilter, false, false, array("ID"));
     if ($arElement = $res->Fetch()) {
         $obElement = new CIBlockElement();
         $obElement->Delete($Params['mrevid']);
     }
 }
Beispiel #28
0
 function Delete($ID, $bCheckPermissions = true)
 {
     $err_mess = "FILE: " . __FILE__ . "<br>LINE: ";
     global $DB, $APPLICATION, $USER;
     $ID = IntVal($ID);
     $APPLICATION->ResetException();
     $db_events = GetModuleEvents("iblock", "OnBeforeIBlockSectionDelete");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             $err = GetMessage("MAIN_BEFORE_DEL_ERR") . ' ' . $arEvent['TO_NAME'];
             if ($ex = $APPLICATION->GetException()) {
                 $err .= ': ' . $ex->GetString();
             }
             $APPLICATION->throwException($err);
             return false;
         }
     }
     $s = CIBlockSection::GetList(array(), array("ID" => $ID, "CHECK_PERMISSIONS" => $bCheckPermissions ? "Y" : "N"));
     if ($s = $s->Fetch()) {
         CIBlock::_transaction_lock($s["IBLOCK_ID"]);
         $iblockelements = CIBlockElement::GetList(array(), array("SECTION_ID" => $ID, "SHOW_HISTORY" => "Y", "IBLOCK_ID" => $s["IBLOCK_ID"]), false, false, array("ID", "IBLOCK_ID", "WF_PARENT_ELEMENT_ID"));
         while ($iblockelement = $iblockelements->Fetch()) {
             $strSql = "\n\t\t\t\t\tSELECT IBLOCK_SECTION_ID\n\t\t\t\t\tFROM b_iblock_section_element\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tIBLOCK_ELEMENT_ID = " . $iblockelement["ID"] . "\n\t\t\t\t\t\tAND IBLOCK_SECTION_ID<>" . $ID . "\n\t\t\t\t\t\tAND ADDITIONAL_PROPERTY_ID IS NULL\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tIBLOCK_SECTION_ID\n\t\t\t\t";
             $db_section_element = $DB->Query($strSql);
             if ($ar_section_element = $db_section_element->Fetch()) {
                 $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_element\n\t\t\t\t\t\tSET IBLOCK_SECTION_ID=" . $ar_section_element["IBLOCK_SECTION_ID"] . "\n\t\t\t\t\t\tWHERE ID=" . IntVal($iblockelement["ID"]) . "\n\t\t\t\t\t", false, $err_mess . __LINE__);
             } elseif (IntVal($iblockelement["WF_PARENT_ELEMENT_ID"]) <= 0) {
                 if (!CIBlockElement::Delete($iblockelement["ID"])) {
                     return false;
                 }
             } else {
                 $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_element\n\t\t\t\t\t\tSET IBLOCK_SECTION_ID=NULL, IN_SECTIONS='N'\n\t\t\t\t\t\tWHERE ID=" . IntVal($iblockelement["ID"]) . "\n\t\t\t\t\t", false, $err_mess . __LINE__);
             }
         }
         $iblocksections = CIBlockSection::GetList(array(), array("SECTION_ID" => $ID, "CHECK_PERMISSIONS" => $bCheckPermissions ? "Y" : "N"), false, array("ID"));
         while ($iblocksection = $iblocksections->Fetch()) {
             if (!CIBlockSection::Delete($iblocksection["ID"], $bCheckPermissions)) {
                 return false;
             }
         }
         CFile::Delete($s["PICTURE"]);
         CFile::Delete($s["DETAIL_PICTURE"]);
         static $arDelCache;
         if (!is_array($arDelCache)) {
             $arDelCache = array();
         }
         if (!is_set($arDelCache, $s["IBLOCK_ID"])) {
             $arDelCache[$s["IBLOCK_ID"]] = false;
             $db_ps = $DB->Query("SELECT ID,IBLOCK_ID,VERSION,MULTIPLE FROM b_iblock_property WHERE PROPERTY_TYPE='G' AND (LINK_IBLOCK_ID=" . $s["IBLOCK_ID"] . " OR LINK_IBLOCK_ID=0 OR LINK_IBLOCK_ID IS NULL)", false, $err_mess . __LINE__);
             while ($ar_ps = $db_ps->Fetch()) {
                 if ($ar_ps["VERSION"] == 2) {
                     if ($ar_ps["MULTIPLE"] == "Y") {
                         $strTable = "b_iblock_element_prop_m" . $ar_ps["IBLOCK_ID"];
                     } else {
                         $strTable = "b_iblock_element_prop_s" . $ar_ps["IBLOCK_ID"];
                     }
                 } else {
                     $strTable = "b_iblock_element_property";
                 }
                 $arDelCache[$s["IBLOCK_ID"]][$strTable][] = $ar_ps["ID"];
             }
         }
         if ($arDelCache[$s["IBLOCK_ID"]]) {
             foreach ($arDelCache[$s["IBLOCK_ID"]] as $strTable => $arProps) {
                 if (strncmp("b_iblock_element_prop_s", $strTable, 23) == 0) {
                     foreach ($arProps as $prop_id) {
                         $strSql = "UPDATE " . $strTable . " SET PROPERTY_" . $prop_id . "=null,DESCRIPTION_" . $prop_id . "=null WHERE PROPERTY_" . $prop_id . "=" . $s["ID"];
                         if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                             return false;
                         }
                     }
                 } elseif (strncmp("b_iblock_element_prop_m", $strTable, 23) == 0) {
                     $strSql = "SELECT IBLOCK_PROPERTY_ID, IBLOCK_ELEMENT_ID FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
                     while ($ar = $rs->Fetch()) {
                         $strSql = "\n\t\t\t\t\t\t\t\tUPDATE " . str_replace("prop_m", "prop_s", $strTable) . "\n\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $ar["IBLOCK_PROPERTY_ID"] . "=null,\n\t\t\t\t\t\t\t\t\tDESCRIPTION_" . $ar["IBLOCK_PROPERTY_ID"] . "=null\n\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ar["IBLOCK_ELEMENT_ID"] . "\n\t\t\t\t\t\t\t";
                         if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                             return false;
                         }
                     }
                     $strSql = "DELETE FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                         return false;
                     }
                 } else {
                     $strSql = "DELETE FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                         return false;
                     }
                 }
             }
         }
         CIBlockSectionPropertyLink::DeleteBySection($ID);
         $DB->Query("DELETE FROM b_iblock_section_element WHERE IBLOCK_SECTION_ID=" . IntVal($ID), false, $err_mess . __LINE__);
         if (CModule::IncludeModule("search")) {
             CSearch::DeleteIndex("iblock", "S" . $ID);
         }
         $GLOBALS["USER_FIELD_MANAGER"]->Delete("IBLOCK_" . $s["IBLOCK_ID"] . "_SECTION", $ID);
         //Delete the hole in the tree
         $ss = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tIBLOCK_ID,\n\t\t\t\t\tLEFT_MARGIN,\n\t\t\t\t\tRIGHT_MARGIN\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock_section\n\t\t\t\tWHERE\n\t\t\t\t\tID = " . $s["ID"] . "\n\t\t\t");
         $ss = $ss->Fetch();
         if ($ss["RIGHT_MARGIN"] > 0 && $ss["LEFT_MARGIN"] > 0) {
             $DB->Query("\n\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN - 2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tIBLOCK_ID = " . $ss["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND RIGHT_MARGIN > " . $ss["RIGHT_MARGIN"] . "\n\t\t\t\t");
             $DB->Query("\n\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t,LEFT_MARGIN = LEFT_MARGIN - 2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tIBLOCK_ID = " . $ss["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND LEFT_MARGIN > " . $ss["LEFT_MARGIN"] . "\n\t\t\t\t");
         }
         $obSectionRights = new CIBlockSectionRights($s["IBLOCK_ID"], $ID);
         $obSectionRights->DeleteAllRights();
         /************* QUOTA *************/
         $_SESSION["SESS_RECOUNT_DB"] = "Y";
         /************* QUOTA *************/
         $arIBlockFields = CIBlock::GetArrayByID($s["IBLOCK_ID"], "FIELDS");
         if ($arIBlockFields["LOG_SECTION_DELETE"]["IS_REQUIRED"] == "Y") {
             $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0;
             $db_events = GetModuleEvents("main", "OnBeforeEventLog");
             $arEvent = $db_events->Fetch();
             if (!$arEvent || ExecuteModuleEventEx($arEvent, array($USER_ID)) === false) {
                 $rsSection = CIBlockSection::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => $bCheckPermissions ? "Y" : "N"), false, array("LIST_PAGE_URL", "NAME", "CODE"));
                 $arSection = $rsSection->GetNext();
                 $res = array("ID" => $ID, "CODE" => $arSection["CODE"], "NAME" => $arSection["NAME"], "SECTION_NAME" => CIBlock::GetArrayByID($s["IBLOCK_ID"], "SECTION_NAME"), "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arSection["LIST_PAGE_URL"]);
                 CEventLog::Log("IBLOCK", "IBLOCK_SECTION_DELETE", "iblock", $s["IBLOCK_ID"], serialize($res));
             }
         }
         $res = $DB->Query("DELETE FROM b_iblock_section WHERE ID=" . IntVal($ID), false, $err_mess . __LINE__);
         if ($res) {
             $db_events = GetModuleEvents("iblock", "OnAfterIBlockSectionDelete");
             while ($arEvent = $db_events->Fetch()) {
                 ExecuteModuleEventEx($arEvent, array($s));
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $s["IBLOCK_ID"]);
             }
         }
         return $res;
     }
     return true;
 }
Beispiel #29
0
            } else {
                ?>
<script>
				window.bxph_error = '<?php 
                echo GetMessage("ROTATE_ERROR") . ": " . $bs->LAST_ERROR;
                ?>
';
				</script><?php 
            }
        }
    } elseif ($photo_list_action == 'delete' && $arParams["PERMISSION"] >= "U") {
        CUtil::JSPostUnEscape();
        CModule::IncludeModule("iblock");
        @set_time_limit(0);
        $APPLICATION->ResetException();
        $res = CIBlockElement::Delete($arParams["ELEMENT_ID"]);
        if ($res) {
            $arEventFields = array("ID" => $arParams["ELEMENT_ID"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "SECTION_ID" => $arParams["SECTION_ID"]);
            foreach (GetModuleEvents("photogallery", "OnAfterPhotoDrop", true) as $arEvent) {
                ExecuteModuleEventEx($arEvent, array($arEventFields, $arParams));
            }
            PClearComponentCacheEx($arParams["IBLOCK_ID"], array(0, $arParams["SECTION_ID"]));
        } else {
            ?>
			<script>
				window.bxph_error = '<?php 
            echo GetMessage("DEL_ITEM_ERROR") . ($ex = $APPLICATION->GetException() ? ': ' . $ex->GetString() : '');
            ?>
';
			</script>
			<?php 
Beispiel #30
0
    }
} else {
    $arResult["SECTION_ID"] = false;
}
$tab_name = $arResult["FORM_ID"] . "_active_tab";
//Assume there was no error
$bVarsFromForm = false;
//Form submitted
if ($_SERVER["REQUEST_METHOD"] == "POST" && check_bitrix_sessid() && !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($arParams["CAN_EDIT"] || $ELEMENT_ID > 0 && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ELEMENT_ID, "element_delete"))) {
    $obList->ActualizeDocumentAdminPage(str_replace(array("#list_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_ELEMENT_URL"]));
    if ($arResult["ELEMENT_ID"] && isset($_POST["action"]) && $_POST["action"] === "delete") {
        if ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ELEMENT_ID, "element_delete")) {
            $DB->StartTransaction();
            $APPLICATION->ResetException();
            $obElement = new CIBlockElement();
            if (!$obElement->Delete($arResult["ELEMENT_ID"])) {
                $DB->Rollback();
                if ($ex = $APPLICATION->GetException()) {
                    ShowError(GetMessage("CC_BLEE_DELETE_ERROR") . " " . $ex->GetString());
                } else {
                    ShowError(GetMessage("CC_BLEE_DELETE_ERROR") . " " . GetMessage("CC_BLEE_UNKNOWN_ERROR"));
                }
                $bVarsFromForm = true;
            } else {
                $DB->Commit();
                LocalRedirect($arResult["~LIST_SECTION_URL"]);
            }
        } else {
            ShowError(GetMessage("CC_BLEE_DELETE_ERROR") . " " . GetMessage("CC_BLEE_UNKNOWN_ERROR"));
            $bVarsFromForm = true;
            LocalRedirect($arResult["~LIST_SECTION_URL"]);