[-] Fix bug #PSCFI-5839 delete attached file from curstomer thread deletion
This commit is contained in:
@@ -105,5 +105,10 @@ class CustomerMessageCore extends ObjectModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
if (!empty($this->file_name))
|
||||||
|
@unlink(_PS_UPLOAD_DIR_.$this->file_name);
|
||||||
|
return parent::delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,11 +97,27 @@ class CustomerThreadCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!Validate::isUnsignedId($this->id))
|
if (!Validate::isUnsignedId($this->id))
|
||||||
return false;
|
return false;
|
||||||
Db::getInstance()->execute('
|
|
||||||
DELETE FROM `'._DB_PREFIX_.'customer_message`
|
$return = true;
|
||||||
|
$result = Db::getInstance()->executeS('
|
||||||
|
SELECT `id_customer_message`
|
||||||
|
FROM `'._DB_PREFIX_.'customer_message`
|
||||||
WHERE `id_customer_thread` = '.(int)$this->id
|
WHERE `id_customer_thread` = '.(int)$this->id
|
||||||
);
|
);
|
||||||
return (parent::delete());
|
|
||||||
|
if( count($result))
|
||||||
|
{
|
||||||
|
foreach ($result AS $res)
|
||||||
|
{
|
||||||
|
$message = new CustomerMessage((int)$res['id_customer_message']);
|
||||||
|
if (!Validate::isLoadedObject($message))
|
||||||
|
$return = false;
|
||||||
|
else
|
||||||
|
$return &= $message->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return &= parent::delete();
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCustomerMessages($id_customer, $read = null)
|
public static function getCustomerMessages($id_customer, $read = null)
|
||||||
@@ -205,4 +221,3 @@ class CustomerThreadCore extends ObjectModel
|
|||||||
');
|
');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user