| 1 |
<?php
|
| 2 |
|
| 3 |
function abuse_install() {
|
| 4 |
drupal_install_schema('abuse');
|
| 5 |
abuse_install_default_reasons();
|
| 6 |
}
|
| 7 |
|
| 8 |
function abuse_uninstall() {
|
| 9 |
drupal_uninstall_schema('abuse');
|
| 10 |
db_query("DELETE FROM {variable} WHERE name LIKE 'abuse_%'");
|
| 11 |
}
|
| 12 |
|
| 13 |
function abuse_schema() {
|
| 14 |
$schema = array();
|
| 15 |
$schema['abuse'] = array(
|
| 16 |
'description' => t('A way to associate a flag for content by a user'),
|
| 17 |
'fields' => array(
|
| 18 |
'aid' => array(
|
| 19 |
'description' => t('ID of the flag'),
|
| 20 |
'type' => 'serial',
|
| 21 |
'unsigned' => TRUE,
|
| 22 |
'not null' => TRUE,
|
| 23 |
),
|
| 24 |
'oid' => array(
|
| 25 |
'description' => t('Original content ID'),
|
| 26 |
'type' => 'int',
|
| 27 |
'unsigned' => TRUE,
|
| 28 |
'not null' => TRUE,
|
| 29 |
),
|
| 30 |
'type' => array(
|
| 31 |
'description' => t('Content Type'),
|
| 32 |
'type' => 'varchar',
|
| 33 |
'length' => 128,
|
| 34 |
'not null' => TRUE,
|
| 35 |
'default' => 'node',
|
| 36 |
),
|
| 37 |
'uid' => array(
|
| 38 |
'description' => t('ID of user flagging content'),
|
| 39 |
'type' => 'int',
|
| 40 |
'unsigned' => TRUE,
|
| 41 |
'not null' => TRUE,
|
| 42 |
'default' => 0,
|
| 43 |
),
|
| 44 |
'name' => array(
|
| 45 |
'description' => t('Name of user'),
|
| 46 |
'type' => 'varchar',
|
| 47 |
'length' => 255,
|
| 48 |
'not null' => TRUE,
|
| 49 |
'default' => ''
|
| 50 |
),
|
| 51 |
'mail' => array(
|
| 52 |
'description' => t('Name of user'),
|
| 53 |
'type' => 'varchar',
|
| 54 |
'length' => 255,
|
| 55 |
'not null' => TRUE,
|
| 56 |
'default' => ''
|
| 57 |
),
|
| 58 |
'reason' => array(
|
| 59 |
'description' => t('General reason for flagging content'),
|
| 60 |
'type' => 'varchar',
|
| 61 |
'length' => 255,
|
| 62 |
'not null' => TRUE,
|
| 63 |
'default' => '',
|
| 64 |
),
|
| 65 |
'body' => array(
|
| 66 |
'description' => t('Text from user on what is wrong with content'),
|
| 67 |
'type' => 'text',
|
| 68 |
'not null' => TRUE,
|
| 69 |
'default' => '',
|
| 70 |
),
|
| 71 |
'valid' => array(
|
| 72 |
'description' => t('Check that the flag is valid'),
|
| 73 |
'type' => 'int',
|
| 74 |
'size' => 'medium',
|
| 75 |
'unsigned' => TRUE,
|
| 76 |
'not null' => TRUE,
|
| 77 |
'default' => 0,
|
| 78 |
),
|
| 79 |
'created' => array(
|
| 80 |
'description' => t('Timestamp'),
|
| 81 |
'type' => 'int',
|
| 82 |
'unsigned' => TRUE,
|
| 83 |
'not null' => TRUE,
|
| 84 |
),
|
| 85 |
|
| 86 |
),
|
| 87 |
'primary key' => array('aid'),
|
| 88 |
'indexes' => array('oid_type' => array('oid', 'type'), 'uid' => array('uid')),
|
| 89 |
);
|
| 90 |
|
| 91 |
$schema['abuse_warnings'] = array(
|
| 92 |
'description' => t('A list of warnings that have been sent out to users for inappropriate content'),
|
| 93 |
'fields' => array(
|
| 94 |
'oid' => array(
|
| 95 |
'description' => t('Original content ID'),
|
| 96 |
'type' => 'int',
|
| 97 |
'unsigned' => TRUE,
|
| 98 |
'not null' => TRUE,
|
| 99 |
),
|
| 100 |
'type' => array(
|
| 101 |
'description' => t('Content Type'),
|
| 102 |
'type' => 'varchar',
|
| 103 |
'length' => 128,
|
| 104 |
'not null' => TRUE,
|
| 105 |
'default' => 'node',
|
| 106 |
),
|
| 107 |
'uid' => array(
|
| 108 |
'description' => t('Flagged content user ID'),
|
| 109 |
'type' => 'int',
|
| 110 |
'unsigned' => TRUE,
|
| 111 |
'not null' => TRUE,
|
| 112 |
'default' => 0,
|
| 113 |
),
|
| 114 |
'sent_by_uid' => array(
|
| 115 |
'description' => t('Flagged content user ID'),
|
| 116 |
'type' => 'int',
|
| 117 |
'unsigned' => TRUE,
|
| 118 |
'not null' => TRUE,
|
| 119 |
'default' => 0,
|
| 120 |
),
|
| 121 |
'created' => array(
|
| 122 |
'description' => t('Timestamp'),
|
| 123 |
'type' => 'int',
|
| 124 |
'unsigned' => TRUE,
|
| 125 |
'not null' => TRUE,
|
| 126 |
),
|
| 127 |
),
|
| 128 |
'indexes' => array(
|
| 129 |
'oid_type_created' => array('oid', 'type', 'created'),
|
| 130 |
'uid' => array('uid'),
|
| 131 |
'sent_by_uid' => array('sent_by_uid')
|
| 132 |
),
|
| 133 |
);
|
| 134 |
$schema['abuse_status'] = array(
|
| 135 |
'description' => t('Current status of a particular piece of content'),
|
| 136 |
'fields' => array(
|
| 137 |
'oid' => array(
|
| 138 |
'description' => t('Original content ID'),
|
| 139 |
'type' => 'int',
|
| 140 |
'unsigned' => TRUE,
|
| 141 |
'not null' => TRUE,
|
| 142 |
),
|
| 143 |
'type' => array(
|
| 144 |
'description' => t('Content Type'),
|
| 145 |
'type' => 'varchar',
|
| 146 |
'length' => 128,
|
| 147 |
'not null' => TRUE,
|
| 148 |
'default' => 'node',
|
| 149 |
),
|
| 150 |
'assigned_to_uid' => array(
|
| 151 |
'description' => t('Moderating user content has been assigned to'),
|
| 152 |
'type' => 'int',
|
| 153 |
'unsigned' => TRUE,
|
| 154 |
'not null' => TRUE,
|
| 155 |
'default' => 0,
|
| 156 |
),
|
| 157 |
'changed' => array(
|
| 158 |
'description' => t('Last timestamp of when content status was added/changed'),
|
| 159 |
'type' => 'int',
|
| 160 |
'unsigned' => TRUE,
|
| 161 |
'not null' => TRUE,
|
| 162 |
'default' => 0,
|
| 163 |
),
|
| 164 |
'status' => array(
|
| 165 |
'description' => t('Current status of the content'),
|
| 166 |
'type' => 'int',
|
| 167 |
'size' => 'small',
|
| 168 |
'unsigned' => TRUE,
|
| 169 |
'not null' => TRUE,
|
| 170 |
'default' => 0,
|
| 171 |
),
|
| 172 |
|
| 173 |
),
|
| 174 |
'primary key' => array('oid', 'type'),
|
| 175 |
'indexes' => array(
|
| 176 |
'assigned_to_uid_oid' => array('assigned_to_uid', 'oid'),
|
| 177 |
'oid_type' => array('oid', 'type'),
|
| 178 |
'status_oid' => array('status', 'oid'),
|
| 179 |
),
|
| 180 |
);
|
| 181 |
$schema['abuse_status_log'] = array(
|
| 182 |
'description' => t('A log of the change to the status of a given content'),
|
| 183 |
'fields' => array(
|
| 184 |
'oid' => array(
|
| 185 |
'description' => t('Original content ID'),
|
| 186 |
'type' => 'int',
|
| 187 |
'unsigned' => TRUE,
|
| 188 |
'not null' => TRUE,
|
| 189 |
),
|
| 190 |
'type' => array(
|
| 191 |
'description' => t('Content Type'),
|
| 192 |
'type' => 'varchar',
|
| 193 |
'length' => 128,
|
| 194 |
'not null' => TRUE,
|
| 195 |
'default' => 'node',
|
| 196 |
),
|
| 197 |
'uid' => array(
|
| 198 |
'description' => t('Flagged content user ID'),
|
| 199 |
'type' => 'int',
|
| 200 |
'unsigned' => TRUE,
|
| 201 |
'not null' => TRUE,
|
| 202 |
'default' => 0,
|
| 203 |
),
|
| 204 |
'status' => array(
|
| 205 |
'description' => t('Status of the content'),
|
| 206 |
'type' => 'int',
|
| 207 |
'size' => 'small',
|
| 208 |
'unsigned' => TRUE,
|
| 209 |
'not null' => TRUE,
|
| 210 |
'default' => 0,
|
| 211 |
),
|
| 212 |
'timestamp' => array(
|
| 213 |
'description' => t('Timestamp'),
|
| 214 |
'type' => 'int',
|
| 215 |
'unsigned' => TRUE,
|
| 216 |
'not null' => TRUE,
|
| 217 |
),
|
| 218 |
|
| 219 |
),
|
| 220 |
'indexes' => array(
|
| 221 |
'uid' => array('uid'),
|
| 222 |
'oid_type_timestamp' => array('oid', 'type', 'timestamp'),
|
| 223 |
),
|
| 224 |
);
|
| 225 |
$schema['abuse_reasons'] = array(
|
| 226 |
'description' => t('A customizable reasons (categories) for flagging content on the site'),
|
| 227 |
'fields' => array(
|
| 228 |
'arid' => array(
|
| 229 |
'description' => t('Reason ID'),
|
| 230 |
'type' => 'serial',
|
| 231 |
'unsigned' => TRUE,
|
| 232 |
'not null' => TRUE,
|
| 233 |
),
|
| 234 |
'reason' => array(
|
| 235 |
'description' => t('Short sentence of reason for flagging content'),
|
| 236 |
'type' => 'varchar',
|
| 237 |
'length' => 255,
|
| 238 |
'not null' => TRUE,
|
| 239 |
'default' => 'other',
|
| 240 |
),
|
| 241 |
'description' => array(
|
| 242 |
'description' => t('A description for admins on what this reason is'),
|
| 243 |
'type' => 'text',
|
| 244 |
'size' => 'medium',
|
| 245 |
'not null' => TRUE,
|
| 246 |
'default' => '',
|
| 247 |
),
|
| 248 |
'argumentation' => array(
|
| 249 |
'description' => t('Text that will be added to the email body'),
|
| 250 |
'type' => 'text',
|
| 251 |
'size' => 'medium',
|
| 252 |
'not null' => TRUE,
|
| 253 |
'default' => '',
|
| 254 |
),
|
| 255 |
),
|
| 256 |
'primary key' => array('arid'),
|
| 257 |
);
|
| 258 |
|
| 259 |
return $schema;
|
| 260 |
}
|
| 261 |
|
| 262 |
function abuse_install_default_reasons() {
|
| 263 |
$sql_template = "INSERT INTO {abuse_reasons} (reason, description, argumentation) VALUES ('%s', '%s', '%s')";
|
| 264 |
|
| 265 |
$result1 = db_query($sql_template, "foul language", t('The user wrote very mean things'), t('Please refrain from writing such mean things'));
|
| 266 |
$result2 = db_query($sql_template, "adult themes", t('The user\'s wrote very explicit language'), t('Please refrain from writing such mean things'));
|
| 267 |
$result3 = db_query($sql_template, "racist or sexist language", t('The user wrote very derogatory comments'), t('Please refrain from writing such mean things'));
|
| 268 |
$result4 = db_query($sql_template, "contains private information", t('The user wrote about private information'), t('Please refrain from writing such mean things'));
|
| 269 |
$result5 = db_query($sql_template, "other", t('The user wrote about other types of mean things'), t('Please refrain from writing such mean things'));
|
| 270 |
|
| 271 |
if ($result1 && $result2 && $result3 && $result4 && $result5) {
|
| 272 |
drupal_set_message('Abuse reason table installation was a success');
|
| 273 |
} else {
|
| 274 |
drupal_set_message('Retry from the start (remove abuse sequence and abuse reasons table)');
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
| 278 |
?>
|