45 lines
1.8 KiB
PHP
45 lines
1.8 KiB
PHP
<?php
|
|
/*+***********************************************************************************
|
|
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
|
* ("License"); You may not use this file except in compliance with the License
|
|
* The Original Code is: vtiger CRM Open Source
|
|
* The Initial Developer of the Original Code is vtiger.
|
|
* Portions created by vtiger are Copyright (C) vtiger.
|
|
* All Rights Reserved.
|
|
*************************************************************************************/
|
|
|
|
class ModComments_DeleteAjax_View extends Vtiger_IndexAjax_View {
|
|
|
|
public function process(Vtiger_Request $request) {
|
|
$record = $request->get('record');
|
|
$moduleName = $request->getModule();
|
|
|
|
// Логируем запрос на удаление
|
|
$logstring = date('Y-m-d H:i:s').' DELETE COMMENT REQUEST: record='.$record.', module='.$moduleName.PHP_EOL;
|
|
file_put_contents('debug.log', $logstring, FILE_APPEND);
|
|
|
|
// Получаем модель записи
|
|
$recordModel = ModComments_Record_Model::getInstanceById($record);
|
|
|
|
if(!$recordModel) {
|
|
$logstring = date('Y-m-d H:i:s').' DELETE COMMENT ERROR: Record not found, ID='.$record.PHP_EOL;
|
|
file_put_contents('debug.log', $logstring, FILE_APPEND);
|
|
|
|
$response = new Vtiger_Response();
|
|
$response->setError('Record not found');
|
|
$response->emit();
|
|
return;
|
|
}
|
|
|
|
// Удаляем комментарий (без проверки прав - любой может удалить)
|
|
$recordModel->delete();
|
|
|
|
$logstring = date('Y-m-d H:i:s').' DELETE COMMENT SUCCESS: record='.$record.' deleted successfully'.PHP_EOL;
|
|
file_put_contents('debug.log', $logstring, FILE_APPEND);
|
|
|
|
$response = new Vtiger_Response();
|
|
$response->setResult(array('success' => true));
|
|
$response->emit();
|
|
}
|
|
}
|