} elseif ($action === 'DELETE_ENTITY') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : ''; if ($typeName !== CCrmOwnerType::DealName) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_TYPE_NOT_SUPPORTED', array('#ENTITY_TYPE#' => $typeName)))); } $ID = isset($_REQUEST['ENTITY_ID']) ? intval($_REQUEST['ENTITY_ID']) : 0; if ($ID <= 0) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND'))); } if (!CCrmDeal::CheckDeletePermission($ID)) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ACCESS_DENIED'))); } $entity = new CCrmDeal(false); //$DB->StartTransaction(); $successed = $entity->Delete($ID); if ($successed) { //$DB->Commit(); __CrmMobileDealEditEndResonse(array('DELETED_ENTITY_ID' => $ID)); } else { //$DB->Rollback(); __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_DEAL_COULD_NOT_DELETE'))); } } elseif ($action === 'GET_ENTITY') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : ''; if ($typeName !== CCrmOwnerType::DealName) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_TYPE_NOT_SUPPORTED', array('#ENTITY_TYPE#' => $typeName)))); } $ID = isset($_REQUEST['ENTITY_ID']) ? intval($_REQUEST['ENTITY_ID']) : 0; if ($ID <= 0) {
$arFilterDel = array(); if (!$actionData['ALL_ROWS']) { $arFilterDel = array('ID' => $actionData['ID']); } else { // Fix for issue #26628 $arFilterDel += $arFilter; } $obRes = CCrmDeal::GetListEx(array(), $arFilterDel, false, false, array('ID')); while ($arDeal = $obRes->Fetch()) { $ID = $arDeal['ID']; $arEntityAttr = $CCrmPerms->GetEntityAttr('DEAL', array($ID)); if (!$CCrmPerms->CheckEnityAccess('DEAL', 'DELETE', $arEntityAttr[$ID])) { continue; } $DB->StartTransaction(); if ($CCrmBizProc->Delete($ID, $arEntityAttr[$ID]) && $CCrmDeal->Delete($ID, array('PROCESS_BIZPROC' => false))) { $DB->Commit(); } else { $DB->Rollback(); } } } } elseif ($actionData['NAME'] == 'edit') { if (isset($actionData['FIELDS']) && is_array($actionData['FIELDS'])) { foreach ($actionData['FIELDS'] as $ID => $arSrcData) { $arEntityAttr = $CCrmPerms->GetEntityAttr('DEAL', array($ID)); if (!$CCrmPerms->CheckEnityAccess('DEAL', 'WRITE', $arEntityAttr[$ID])) { continue; } $arUpdateData = array(); reset($arResult['HEADERS']);
} // save LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_LIST'], array())); } } } elseif (isset($_GET['delete']) && check_bitrix_sessid()) { if ($bEdit) { $arResult['ERROR_MESSAGE'] = ''; if (!CCrmDeal::CheckDeletePermission($arParams['ELEMENT_ID'], $userPermissions)) { $arResult['ERROR_MESSAGE'] .= GetMessage('CRM_PERMISSION_DENIED') . '<br />'; } $bDeleteError = !$CCrmBizProc->Delete($arResult['ELEMENT']['ID'], $arEntityAttr[$arParams['ELEMENT_ID']]); if ($bDeleteError) { $arResult['ERROR_MESSAGE'] .= $CCrmBizProc->LAST_ERROR; } if (empty($arResult['ERROR_MESSAGE']) && !$CCrmDeal->Delete($arResult['ELEMENT']['ID'], array('PROCESS_BIZPROC' => false))) { $arResult['ERROR_MESSAGE'] = GetMessage('CRM_DELETE_ERROR'); } if (empty($arResult['ERROR_MESSAGE'])) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_LIST'])); } else { ShowError($arResult['ERROR_MESSAGE']); } return; } else { ShowError(GetMessage('CRM_DELETE_ERROR')); return; } } } $arResult['BACK_URL'] = $arParams['PATH_TO_DEAL_LIST'];
function InstallService($serviceID, $serviceStage) { $wizard =& $this->GetWizard(); if (CModule::IncludeModule("iblock")) { $type = substr($serviceID, 0, -1); if ($type == "iblockElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } } elseif ($type == "iblockSectionElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockSection::Delete($arItem["ID"]); } } elseif ($serviceID == "iblockDepartmentsElement") { $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => "departments")); while ($arItem = $dbItem->Fetch()) { if ($arItem["DEPTH_LEVEL"] > 2) { CIBlockSection::Delete($arItem["ID"]); } } } elseif ($serviceID == "tasks") { if (CModule::IncludeModule("tasks")) { $dbItem = CTasks::GetList(array(), array("SITE_ID" => $wizard->GetVar("siteID"))); while ($arItem = $dbItem->Fetch()) { CTasks::Delete($arItem["ID"]); } } } elseif ($serviceID == "calendar") { if (CModule::IncludeModule("calendar")) { $dbItem = CCalendarEvent::GetList(); foreach ($dbItem as $arItem) { CCalendarEvent::Delete(array("id" => $arItem["ID"])); } } } elseif ($serviceID == "meeting") { if (CModule::IncludeModule("meeting")) { $dbItem = CMeeting::GetList(array(), array()); while ($arItem = $dbItem->Fetch()) { if ($arItem["ID"]) { CMeeting::Delete($arItem["ID"]); } } } } elseif ($serviceID == "user") { if ($serviceStage == "user") { $dbUser = CUser::GetList($by = "ID", $order = "DESC", array(">ID" => 1)); while ($arUser = $dbUser->Fetch()) { CUser::Delete($arUser["ID"]); } } } elseif ($serviceID == "crm") { if ($serviceStage == "crm") { if (CModule::IncludeModule('crm')) { $CCrmLead = new CCrmLead(); $resLead = CCrmLead::GetList(array(), array(), array(), false); while ($rowLead = $resLead->Fetch()) { $CCrmLead->Delete($rowLead["ID"]); } $CCrmContact = new CCrmContact(); $resContact = CCrmContact::GetList(array(), array(), array(), false); while ($rowContact = $resContact->Fetch()) { $CCrmContact->Delete($rowContact["ID"]); } $CCrmCompany = new CCrmCompany(); $resCompany = CCrmCompany::GetList(array(), array(), array(), false); while ($rowCompany = $resCompany->Fetch()) { $CCrmCompany->Delete($rowCompany["ID"]); } $CCrmDeal = new CCrmDeal(); $resDeal = CCrmDeal::GetList(array(), array(), array(), false); while ($rowDeal = $resDeal->Fetch()) { $CCrmDeal->Delete($rowDeal["ID"]); } } } } elseif ($serviceID == "cache") { require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_html.php"; if ($serviceStage == "cache1") { BXClearCache(true); } elseif ($serviceStage == "cache2") { $GLOBALS["CACHE_MANAGER"]->CleanAll(); } elseif ($serviceStage == "cache3") { $GLOBALS["stackCacheManager"]->CleanAll(); } elseif ($serviceStage == "cache4") { CHTMLPagesCache::CleanAll(); } COption::SetOptionString("main", "wizard_clear_exec", "Y", false, $wizard->GetVar("siteID")); } } }