BxDolAIToolCmtsDelete.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. use NeuronAI\Tools\PropertyType;
  10. use NeuronAI\Tools\ToolProperty;
  11. class BxDolAIToolCmtsDelete extends BxDolAITool
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct(
  16. 'comments_delete',
  17. 'Use this tool to delete comments.',
  18. );
  19. }
  20. protected function properties(): array
  21. {
  22. return [
  23. new ToolProperty(
  24. name: 'module',
  25. type: PropertyType::STRING,
  26. description: 'The module name to perform content changes on. Use "system" for site accounts. ',
  27. required: true
  28. ),
  29. new ToolProperty(
  30. name: 'content_id',
  31. type: PropertyType::INTEGER,
  32. description: 'Content ID to post comments for.',
  33. required: true
  34. ),
  35. new ToolProperty(
  36. name: 'comment_id',
  37. type: PropertyType::INTEGER,
  38. description: 'Comment ID to update.',
  39. required: true
  40. ),
  41. ];
  42. }
  43. public function __invoke(string $module, int $content_id, int $comment_id): array
  44. {
  45. $a = [];
  46. $o = BxDolCmts::getObjectInstance($module, $content_id);
  47. if ($o) {
  48. $a = $o->remove($comment_id);
  49. unset($a['count']);
  50. unset($a['countf']);
  51. }
  52. else {
  53. $a = ['msg' => '_sys_txt_not_found', 'code' => 404];
  54. }
  55. return $a;
  56. }
  57. }