ModLog.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Data object to store moderation logs
  18. *
  19. * @category Moderation
  20. * @package GNUsocial
  21. * @author Evan Prodromou <evan@status.net>
  22. * @copyright 2012 StatusNet, Inc.
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * @copyright 2012 StatusNet, Inc.
  28. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  29. *
  30. * @see DB_DataObject
  31. */
  32. class ModLog extends Managed_DataObject
  33. {
  34. public $__table = 'mod_log'; // table name
  35. public $id; // UUID
  36. public $profile_id; // profile id
  37. public $moderator_id; // profile id
  38. public $role; // the role
  39. public $is_grant; // true = grant, false = revoke
  40. public $created; // datetime
  41. /**
  42. * The One True Thingy that must be defined and declared.
  43. */
  44. public static function schemaDef()
  45. {
  46. return [
  47. 'description' => 'Log of moderation events',
  48. 'fields' => [
  49. 'id' => [
  50. 'type' => 'varchar',
  51. 'length' => 36,
  52. 'not null' => true,
  53. 'description' => 'unique event ID',
  54. ],
  55. 'profile_id' => [
  56. 'type' => 'int',
  57. 'not null' => true,
  58. 'description' => 'profile getting the role',
  59. ],
  60. 'moderator_id' => [
  61. 'type' => 'int',
  62. 'description' => 'profile granting or revoking the role',
  63. ],
  64. 'role' => [
  65. 'type' => 'varchar',
  66. 'length' => 32,
  67. 'not null' => true,
  68. 'description' => 'role granted or revoked',
  69. ],
  70. 'is_grant' => [
  71. 'type' => 'bool',
  72. 'default' => true,
  73. 'description' => 'Was this a grant or revocation of a role',
  74. ],
  75. 'created' => [
  76. 'type' => 'datetime',
  77. 'not null' => true,
  78. 'description' => 'date this record was created',
  79. ],
  80. ],
  81. 'primary key' => ['id'],
  82. 'foreign keys' => [
  83. 'modlog_profile_id_fkey' => ['profile', ['profile_id' => 'id']],
  84. 'modlog_moderator_id_fkey' => ['user', ['moderator_id' => 'id']],
  85. ],
  86. 'indexes' => [
  87. 'modlog_profile_id_created_idx' => ['profile_id', 'created'],
  88. 'modlog_moderator_id_idx' => ['moderator_id'],
  89. ],
  90. ];
  91. }
  92. }