Beispiel #1
0
 protected static function InnerDelete($ID, $options = array())
 {
     global $DB;
     $ID = intval($ID);
     if ($ID <= 0) {
         self::RegisterError(array('text' => 'Invalid arguments are supplied.'));
         return false;
     }
     CCrmEntityHelper::RemoveCached(self::CACHE_NAME, $ID);
     $result = true;
     if (!(isset($options['SKIP_BINDINGS']) && $options['SKIP_BINDINGS'])) {
         $result = self::DeleteBindings($ID);
     }
     if ($result && !(isset($options['SKIP_COMMUNICATIONS']) && $options['SKIP_COMMUNICATIONS'])) {
         $result = self::DeleteCommunications($ID);
     }
     if ($result && !(isset($options['SKIP_FILES']) && $options['SKIP_FILES'])) {
         $result = self::DeleteStorageElements($ID);
         if ($result) {
             $result = $DB->Query('DELETE FROM ' . CCrmActivity::ELEMENT_TABLE_NAME . ' WHERE ACTIVITY_ID = ' . $ID, false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__);
         }
     }
     if ($result) {
         $result = $DB->Query('DELETE FROM ' . CCrmActivity::TABLE_NAME . ' WHERE ID = ' . $ID, true) !== false;
     }
     return $result;
 }
Beispiel #2
0
 public static function Delete($ID)
 {
     global $DB, $APPLICATION;
     $ID = intval($ID);
     $arProduct = self::GetByID($ID);
     if (!is_array($arProduct)) {
         // Is no exists
         return true;
     }
     $rowsCount = CCrmProductRow::GetList(array(), array('PRODUCT_ID' => $ID), array(), false, array());
     if ($rowsCount > 0 || CCrmInvoice::HasProductRows($ID)) {
         self::RegisterError(GetMessage('CRM_COULD_NOT_DELETE_PRODUCT_ROWS_EXIST', array('#NAME#' => $arProduct['~NAME'])));
         return false;
     }
     foreach (GetModuleEvents('crm', 'OnBeforeCrmProductDelete', true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     //$DB->StartTransaction();
     //$APPLICATION->ResetException();
     //		$sql = 'DELETE FROM '.CCrmProduct::TABLE_NAME.' WHERE ID = '.$ID;
     //		if(!$DB->Query($sql, true))
     //		{
     //			//$DB->Rollback();
     //			return false;
     //		}
     CCrmEntityHelper::RemoveCached(self::CACHE_NAME, $ID);
     if (self::IsIBlockElementExists($ID)) {
         $element = new CIBlockElement();
         if (!$element->Delete($ID)) {
             //$DB->Rollback();
             if ($ex = $APPLICATION->GetException()) {
                 self::RegisterError($ex->GetString());
             }
             return false;
         }
     }
     //$DB->Commit();
     foreach (GetModuleEvents('crm', 'OnCrmProductDelete', true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     return true;
 }
 public static function Delete($ID, $checkPerms = true, $regEvent = true)
 {
     global $DB;
     $ID = intval($ID);
     $arParams = self::GetByID($ID);
     if (!is_array($arParams)) {
         self::RegisterError("Could not find CrmProductRow({$ID}).");
         return false;
     }
     if (!$DB->Query('DELETE FROM ' . CCrmProductRow::TABLE_NAME . ' WHERE ID = ' . $ID, true)) {
         self::RegisterError("Could not delete CrmProductRow({$ID}).");
         return false;
     }
     CCrmEntityHelper::RemoveCached(self::CACHE_NAME, $ID);
     if (isset($arParams['OWNER_TYPE']) && isset($arParams['OWNER_ID'])) {
         // Update list of taxes
         self::UpdateTotalInfo($arParams['OWNER_TYPE'], $arParams['OWNER_ID']);
         self::SynchronizeOwner($arParams['OWNER_TYPE'], $arParams['OWNER_ID']);
         if ($regEvent) {
             self::RegisterRemoveEvent($arParams['OWNER_TYPE'], $arParams['OWNER_ID'], $arParams, $checkPerms);
         }
     }
     return true;
 }
Beispiel #4
0
 public static function Delete($ID)
 {
     if (!CModule::IncludeModule('catalog')) {
         return false;
     }
     self::$LAST_ERROR = '';
     global $DB;
     $tableName = CCrmCatalog::TABLE_NAME;
     $ID = intval($ID);
     if (!is_array(self::GetByID($ID))) {
         // Is no exists
         return true;
     }
     $events = GetModuleEvents('crm', 'OnBeforeCrmCatalogDelete');
     while ($arEvent = $events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     $dbRes = CCrmProduct::GetList(array(), array('CATALOG_ID' => $ID), array('ID'));
     while ($arRes = $dbRes->Fetch()) {
         $productID = $arRes['ID'];
         if (!CCrmProduct::Delete($productID)) {
             self::RegisterError(sprintf('Deletion of CrmCatalog(ID=%d) is canceled. Could not delete CrmProduct(ID = %d).', $ID, $productID));
             return false;
         }
     }
     if (!$DB->Query('DELETE FROM ' . $tableName . ' WHERE ID = ' . $ID, true)) {
         return false;
     }
     // -------------- remove from catalog module -------------->
     $CCatalog = new CCatalog();
     if (!$CCatalog->Delete($ID)) {
         return false;
     }
     // <-------------- remove from catalog module --------------
     CCrmEntityHelper::RemoveCached(self::CACHE_NAME, $ID);
     $events = GetModuleEvents('crm', 'OnCrmCatalogDelete');
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     return true;
 }
Beispiel #5
0
 public static function Delete($ID, $options = null)
 {
     global $DB;
     self::ClearErrors();
     $ID = intval($ID);
     /* $options: RFU
     		 * if(!is_array($options))
     		{
     			$options = array();
     		}
     		*/
     $events = GetModuleEvents('crm', 'OnBeforeMailTemplateDelete');
     while ($event = $events->Fetch()) {
         if (ExecuteModuleEventEx($event, array($ID)) === false) {
             return false;
         }
     }
     if (!self::Exists($ID)) {
         self::RegisterError(new CCrmMailTemplateError(CCrmMailTemplateError::NotExists, array('ID' => $ID)));
         return false;
         //is not found
     }
     CCrmEntityHelper::RemoveCached(self::CACHE_NAME, $ID);
     $result = $DB->Query('DELETE FROM ' . CCrmMailTemplate::TABLE_NAME . ' WHERE ID = ' . $ID, true) !== false;
     if ($result) {
         $rsEvents = GetModuleEvents('crm', 'OnMailTemplateDelete');
         while ($arEvent = $rsEvents->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID));
         }
     }
     return $result;
 }