本文整理汇总了PHP中CIBlockElement::Delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::Delete方法的具体用法?PHP CIBlockElement::Delete怎么用?PHP CIBlockElement::Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::Delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnBeforeUserDeleteHandler
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"]);
}
}
示例2: OnIBlockElementDelete
/**
* Удаление остатков привязанных к каталогу
*
* @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;
}
示例3: removeProjects
/**
* [removeProjects description]
* @param int $id
* @return bool
*/
function removeProjects($id)
{
if (!CModule::IncludeModule('iblock')) {
return false;
}
return CIBlockElement::Delete($id);
}
示例4: delete
/**
* Удаляет элемент
*
* @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);
}
示例5: clear_section
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);
}
}
示例6: executeDown
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;
}
示例7: delProducts
/**
* [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;
}
示例8: Delete
/**
* <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>
* <?<br>// Удалим Wiki-страницу с идентификатором 13 в инфо.блоке с идентификатором 2<br>$ID = 13;<br>$IBLOCK_ID = 2;<br><br>$CWiki = new CWiki();<br>if (!$CWiki->Delete($ID, $IBLOCK_ID))<br> echo 'Ошибка. Страница не удалена.';<br>?>
* </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;
}
示例9: down
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();
}
}
示例10: __InTaskDeleteTask
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;
}
示例11: PublishDocument
/**
* ћетод публикует документ. “о есть делает его доступным в публичной части сайта.
*
* @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;
}
示例12: array
}
/*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) {
示例13: DeactivateElement
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;
}
示例14: WF_CleanUpHistoryCopies
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"]);
}
}
}
}
}
}
示例15: intval
//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"));
}