public function actionCreateServer($name = '', $port = 0, $base = '', $players = 0, $no_commands = 0, $no_setup_script = 0) { $this->check(); $model = $this->create('Server', array('name' => $name, 'port' => $port, 'dir' => $base, 'players' => $players), 'superuser'); $cfg = new ServerConfig(); $cfg->server_id = $model->id; $cfg->scenario = 'create'; if (!$cfg->save()) { $this->end($cfg->errors); } else { if (!$no_commands) { $model->createDefaultCommands(); } if (!$no_setup_script) { McBridge::get()->serverCmd($model->id, 'run_s:builtin:script setup'); } $this->success(); } }
public function actionCreate() { $model = new Server('superuser'); $settings = new ServerConfig('superuser'); $this->performAjaxValidation($model); $adv = false; if (isset($_POST['Server'])) { $model->attributes = $_POST['Server']; $settings->attributes = $_POST['ServerConfig']; $settings->give_role = @$_POST['cheat_role']; $settings->tp_role = @$_POST['cheat_role']; $model->sendData = @$_POST['send_data']; if ($model->validate() && $settings->validate()) { $model->save(false); $settings->server_id = $model->id; $settings->scenario = 'create'; $settings->save(); Yii::log('Created server ' . $model->id); $user = User::model()->findByPk((int) $_POST['user-assign']); $model->setOwner($user); if ($user) { $user->setServerFtpAccess($model->id, 'rw'); } $model->createDefaultCommands(); McBridge::get()->serverCmd($model->id, 'run_s:builtin:script setup'); $this->redirect(array('view', 'id' => $model->id)); } else { $adv = true; } } $this->render('view', array('model' => $model, 'settings' => $settings, 'edit' => true, 'jars' => $this->listJars(), 'advanced' => $adv, 'my' => false)); }