]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModLog/ModLog.php
b2c654683852220cfcd3dfa0039ddf3801dea87f
[quix0rs-gnu-social.git] / plugins / ModLog / ModLog.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2012, StatusNet, Inc.
5  *
6  * ModLog.php -- data object to store moderation logs
7  * 
8  * PHP version 5
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Moderation
24  * @package   StatusNet
25  * @author    Evan Prodromou <evan@status.net>
26  * @copyright 2012 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * Class comment here
37  *
38  * @category Category here
39  * @package  StatusNet
40  * @author   Evan Prodromou <evan@status.net>
41  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42  * @link     http://status.net/
43  *
44  * @see      DB_DataObject
45  */
46
47 class ModLog extends Managed_DataObject
48 {
49     public $__table = 'mod_log'; // table name
50
51     public $id;           // UUID
52     public $profile_id;   // profile id
53     public $moderator_id; // profile id
54     public $role;         // the role
55     public $grant;        // 1 = grant, 0 = revoke
56     public $created;      // datetime
57
58     /**
59      * Get an instance by key
60      *
61      * @param string $k Key to use to lookup (usually 'user_id' for this class)
62      * @param mixed  $v Value to lookup
63      *
64      * @return TagSub object found, or null for no hits
65      *
66      */
67     function staticGet($k, $v=null)
68     {
69         return Managed_DataObject::staticGet('ModLog', $k, $v);
70     }
71
72     /**
73      * Get an instance by compound key
74      *
75      * @param array $kv array of key-value mappings
76      *
77      * @return TagSub object found, or null for no hits
78      *
79      */
80     function pkeyGet($kv)
81     {
82         return Managed_DataObject::pkeyGet('ModLog', $kv);
83     }
84
85     /**
86      * The One True Thingy that must be defined and declared.
87      */
88     public static function schemaDef()
89     {
90         return array('description' => 'Log of moderation events',
91                      'fields' => array(
92                                        'id' => array('type' => 'varchar',
93                                                      'length' => 36,
94                                                      'not null' => true,
95                                                      'description' => 'unique event ID'),
96                                        'profile_id' => array('type' => 'int',
97                                                              'not null' => true,
98                                                              'description' => 'profile getting the role'),
99                                        'moderator_id' => array('type' => 'int',
100                                                                'description' => 'profile granting or revoking the role'),
101                                        'role' => array('type' => 'varchar',
102                                                        'length' => 32,
103                                                        'not null' => true,
104                                                        'description' => 'role granted or revoked'),
105                                        'is_grant' => array('type' => 'int',
106                                                            'size' => 'tiny',
107                                                            'default' => 1,
108                                                            'description' => 'Was this a grant or revocation of a role'),
109                                        'created' => array('type' => 'datetime',
110                                                           'not null' => true,
111                                                           'description' => 'date this record was created')
112                                        ),
113                      'primary key' => array('id'),
114                      'foreign keys' => array(
115                                              'mod_log_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
116                                              'mod_log_moderator_id_fkey' => array('user', array('user_id' => 'id'))
117                                              ),
118                      'indexes' => array(
119                                         'mod_log_profile_id_created_idx' => array('profile_id', 'created'),
120                                         ),
121                      );
122     }
123 }