Example #1
0
 static function create($data, $user)
 {
     if (property_exists($data, 'id')) {
         $tournament = Tournament::get($data->id);
         if ($tournament != null) {
             return $tournament;
         }
     }
     $options = Tournament::check_create($data);
     if (is_string($options)) {
         return $options;
     }
     global $db;
     $data->status = 1;
     $data->data = $options;
     $data->min_players = intval($data->min_players);
     $data->id = $db->insert("INSERT INTO\n\t\t\t`tournament` ( `type`, `name`, `min_players`, `status`, `data` )\n\t\t\tVALUES ( '{$data->format}', '" . $db->escape($data->name) . "',\n\t\t\t{$data->min_players}, {$data->status},\n\t\t\t'" . $db->escape(json_encode($options)) . "' );");
     $tournament = new Tournament($data);
     $tournament->log($user->player_id, 'create', $user->nick);
     return $tournament;
 }