/** * Saves the map image using the given values in the model. * @return boolean whether save is successful */ public function save() { $this->filename = CUploadedFile::getInstance($this, 'filename'); if (!$this->validate()) { return false; } $game = SBGame::model()->findByPk($this->game_id); if ($game === null) { return false; } return $this->filename->saveAs(Yii::getPathOfAlias('webroot.images.maps') . '/' . $game->folder . '/' . $this->filename); }
<?php echo $form->passwordField($model, 'rcon', array('size' => 32, 'maxlength' => 32)); ?> <?php echo $form->error($model, 'rcon'); ?> </div> </div> <div class="control-group"> <?php echo $form->label($model, 'game_id', array('class' => 'control-label')); ?> <div class="controls"> <?php echo $form->dropDownList($model, 'game_id', CHtml::listData(SBGame::model()->findAll(array('order' => 't.name')), 'id', 'name')); ?> </div> </div> <div class="control-group"> <div class="controls"> <?php $enabled = $form->checkBox($model, 'enabled') . $model->getAttributeLabel('enabled'); ?> <?php echo CHtml::label($enabled, 'SBServer_enabled', array('class' => 'checkbox')); ?> </div> </div>
/** * Displays the report player page */ public function actionReport() { $this->pageTitle = Yii::t('sourcebans', 'controllers.default.report.title'); $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.default.report.title')); $model = new SBReport(); $model->steam = 'STEAM_'; // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'report-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['SBReport'])) { $model->attributes = $_POST['SBReport']; if ($model->save()) { SourceBans::log('Report added', 'Player "' . $model->name . '" was reported'); Yii::app()->user->setFlash('success', Yii::t('sourcebans', 'Saved successfully')); $this->refresh(); } } $games = SBGame::model()->with('servers:enabled')->findAll(array('condition' => 'servers.id IS NOT NULL', 'order' => 'name, servers.host, servers.port')); $this->render('report', array('model' => $model, 'games' => $games)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return SBGame the loaded model * @throws CHttpException */ public function loadModel($id) { $model = SBGame::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }