public function delete(Vtiger_Request $request) { $response = new Vtiger_Response(); $blockId = $request->get('blockid'); $checkIfFieldsExists = Vtiger_Block_Model::checkFieldsExists($blockId); if ($checkIfFieldsExists) { $response->setError('502', vtranslate('LBL_FIELDS_EXISTS_IN_BLOCK', $request->getModule(false))); $response->emit(); return; } $blockInstance = Vtiger_Block_Model::getInstance($blockId); if (!$blockInstance->isCustomized()) { $response->setError('502', vtranslate('LBL_DELETE_CUSTOM_BLOCKS', $request->getModule(false))); $response->emit(); return; } try { $blockInstance->delete(false); $response->setResult(array('success' => true)); } catch (Exception $e) { $response->setError($e->getCode(), $e->getMessage()); } $response->emit(); }
public function delete(Vtiger_Request $request) { $response = new Vtiger_Response(); $blockId = $request->get('blockid'); $checkIfFieldsExists = Vtiger_Block_Model::checkFieldsExists($blockId); if ($checkIfFieldsExists) { $response->setError('502', 'Fields exists for the block'); $response->emit(); return; } $blockInstance = Vtiger_Block_Model::getInstance($blockId); if (!$blockInstance->isCustomized()) { $response->setError('502', 'Cannot delete non custom blocks'); $response->emit(); return; } try { $blockInstance->delete(false); $response->setResult(array('success' => true)); } catch (Exception $e) { $response->setError($e->getCode(), $e->getMessage()); } $response->emit(); }
public function deleteBlocks($blocks) { global $log; $log->debug("Entering YetiForceUpdate::deleteBlocks() method ..."); foreach ($blocks as $block) { $checkIfFieldsExists = Vtiger_Block_Model::checkFieldsExists($block); if (!$checkIfFieldsExists && $block) { $blockInstance = Vtiger_Block_Model::getInstance((int) $block); try { $blockInstance->delete(false); } catch (Exception $e) { $log->debug("ERROR YetiForceUpdate::deleteBlocks: code " . $e->getCode() . " message " . $e->getMessage()); } } } $log->debug("Exiting YetiForceUpdate::deleteBlocks() method ..."); }