add.php
$is_submitted = $this->request->has('submit'); $team = $form->parse($this->request, $is_submitted); $user = cmsUser::getInstance(); if ($is_submitted){ $errors = $form->validate($this, $team); if (!$errors){ $tournament = $this->model->getTournament($tournament_id); $team['tournament_id'] = $tournament_id; $team['user_id'] = $user->id; $team['team_name'] = $tournament['tournament_name']; $team['sport_system'] = $sport; $this->model->addTeam($team); $team = $this->model->getItemById('sport_teams', $tournament_id); $this->model->update('users', $user->id, array('tournament_id' => $tournament_id, 'tournament_name' => $tournament['tournament_name'])); $teams_name = $team['tournament_name']; //if ($tournament['users_count'] >= $tournament['min_users']){ //$this->model->setTournamentStatus($tournament_id, sport::STATUS_MODERATION); //} 'subject_id' => $tournament_id, 'team_id' => $tournament_id, 'subject_title' => $team['tournament_name'], 'subject_url' => href_to_rel($this->name, 'team', $tournament_id) )); } if ($errors){ cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } }
/* Вступление в команду */ public function addTeam($team){ $team_id = $this->insert('sport_team_info', $team); $this->filterEqual('id', $team['tournament_id']); $this->increment('sport_teams','users_count'); return $team_id; }