abuse_update_1

Definition

abuse_update_1()
abuse/abuse.install, line 135

Code

<?php
function abuse_update_1() {
  $items = array();
  if (!db_table_exists('abuse_reasons')) {
    $result1 = db_query("
      CREATE TABLE {abuse_reasons} (
        arid int(11) unsigned NOT NULL,
        reason varchar(72) NOT NULL DEFAULT '',
        description text NOT NULL DEFAULT '',
        argumentation text NOT NULL DEFAULT '',
        PRIMARY KEY (arid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
    ");
  
    $sql_template = "INSERT INTO {abuse_reasons} (arid, reason, description, argumentation) VALUES (%d, '%s', '%s', '%s')";
    $result2 = db_query($sql_template, db_next_id('{abuse_reasons}_arid'), "foul language", t('The user wrote very mean things'), t('Please refrain from writing such mean things'));
    $result3 = db_query($sql_template, db_next_id('{abuse_reasons}_arid'), "adult themes", t('The user\'s wrote very explicit language'), t('Please refrain from writing such mean things'));
    $result4 = db_query($sql_template, db_next_id('{abuse_reasons}_arid'), "racist or sexist language", t('The user wrote very derogatory comments'), t('Please refrain from writing such mean things'));
    $result5 = db_query($sql_template, db_next_id('{abuse_reasons}_arid'), "contains private information", t('The user wrote about private information'), t('Please refrain from writing such mean things'));
    $result6 = db_query($sql_template, db_next_id('{abuse_reasons}_arid'), "other", t('The user wrote about other types of mean things'), t('Please refrain from writing such mean things'));
    if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
      drupal_set_message('Abuse reason table installation was a success');
    } 
    else {
      drupal_set_message('Retry from the start (remove abuse sequence and abuse reasons table)');
    }
  }
  return $items;
}
?>