Ejemplo n.º 1
0
         $arFilterDel = array();
         if (!$actionData['ALL_ROWS']) {
             $arFilterDel = array('ID' => $actionData['ID']);
         } else {
             // Fix for issue #26628
             $arFilterDel += $arFilter;
         }
         $obRes = CCrmContact::GetListEx(array(), $arFilterDel, false, false, array('ID'));
         while ($arContact = $obRes->Fetch()) {
             $ID = $arContact['ID'];
             $arEntityAttr = $CCrmPerms->GetEntityAttr('CONTACT', array($ID));
             if (!$CCrmPerms->CheckEnityAccess('CONTACT', 'DELETE', $arEntityAttr[$ID])) {
                 continue;
             }
             $DB->StartTransaction();
             if ($CCrmBizProc->Delete($ID, $arEntityAttr[$ID]) && $CCrmContact->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('CONTACT', array($ID));
             if (!$CCrmPerms->CheckEnityAccess('CONTACT', 'WRITE', $arEntityAttr[$ID])) {
                 continue;
             }
             $arUpdateData = array();
             reset($arResult['HEADERS']);
Ejemplo n.º 2
0
} elseif ($action === 'DELETE_ENTITY') {
    __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
    $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : '';
    if ($typeName !== 'CONTACT') {
        __CrmMobileContactEditEndResonse(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) {
        __CrmMobileContactEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND')));
    }
    if (!CCrmContact::CheckDeletePermission($ID)) {
        __CrmMobileContactEditEndResonse(array('ERROR' => GetMessage('CRM_ACCESS_DENIED')));
    }
    $entity = new CCrmContact(false);
    //$DB->StartTransaction();
    $successed = $entity->Delete($ID);
    if ($successed) {
        //$DB->Commit();
        __CrmMobileContactEditEndResonse(array('DELETED_ENTITY_ID' => $ID));
    } else {
        //$DB->Rollback();
        __CrmMobileContactEditEndResonse(array('ERROR' => GetMessage('CRM_CONTACT_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 !== 'CONTACT') {
        __CrmMobileContactEditEndResonse(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) {
Ejemplo n.º 3
0
                //save
                LocalRedirect(isset($_REQUEST['backurl']) && $_REQUEST['backurl'] !== '' ? $_REQUEST['backurl'] : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_LIST'], array()));
            }
        }
    } else {
        if (isset($_GET['delete']) && check_bitrix_sessid()) {
            if ($isEditMode) {
                $arResult['ERROR_MESSAGE'] = '';
                if (!CCrmContact::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']) && !$CCrmContact->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_CONTACT_LIST']));
                } else {
                    ShowError($arResult['ERROR_MESSAGE']);
                    return;
                }
            } else {
                ShowError(GetMessage('CRM_DELETE_ERROR'));
                return;
            }
        }
    }
}
Ejemplo n.º 4
0
 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"));
         }
     }
 }