3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2012, StatusNet, Inc.
6 * ModLog.php -- data object to store moderation logs
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.
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.
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/>.
23 * @category Moderation
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/
31 if (!defined('STATUSNET')) {
38 * @category Category here
40 * @author Evan Prodromou <evan@status.net>
41 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42 * @link http://status.net/
47 class ModLog extends Managed_DataObject
49 public $__table = 'mod_log'; // table name
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
59 * Get an instance by key
61 * @param string $k Key to use to lookup (usually 'user_id' for this class)
62 * @param mixed $v Value to lookup
64 * @return TagSub object found, or null for no hits
67 function staticGet($k, $v=null)
69 return Managed_DataObject::staticGet('ModLog', $k, $v);
73 * Get an instance by compound key
75 * @param array $kv array of key-value mappings
77 * @return TagSub object found, or null for no hits
82 return Managed_DataObject::pkeyGet('ModLog', $kv);
86 * The One True Thingy that must be defined and declared.
88 public static function schemaDef()
90 return array('description' => 'Log of moderation events',
92 'id' => array('type' => 'varchar',
95 'description' => 'unique event ID'),
96 'profile_id' => array('type' => 'int',
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',
104 'description' => 'role granted or revoked'),
105 'is_grant' => array('type' => 'int',
108 'description' => 'Was this a grant or revocation of a role'),
109 'created' => array('type' => 'datetime',
111 'description' => 'date this record was created')
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'))
119 'mod_log_profile_id_created_idx' => array('profile_id', 'created'),