Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
      <?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>
Exemplo n.º 3
0
 /**
  * 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));
 }
Exemplo n.º 4
0
 /**
  * Displays the 'games' admin page
  */
 public function actionGames()
 {
     $this->pageTitle = Yii::t('sourcebans', 'controllers.admin.games.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.admin.index.title') => array('admin/index'), Yii::t('sourcebans', 'controllers.admin.games.title'));
     $this->menu = array(array('label' => Yii::t('sourcebans', 'controllers.admin.games.menu.list'), 'url' => '#list', 'visible' => Yii::app()->user->data->hasPermission('LIST_GAMES')), array('label' => Yii::t('sourcebans', 'controllers.admin.games.menu.add'), 'url' => '#add', 'visible' => Yii::app()->user->data->hasPermission('ADD_GAMES')), array('label' => Yii::t('sourcebans', 'controllers.admin.games.menu.map-image'), 'url' => '#map-image', 'visible' => Yii::app()->user->data->hasPermission('ADD_GAMES')));
     $game = new SBGame();
     $map_image = new MapImageForm();
     $games = new SBGame('search');
     $games->unsetAttributes();
     // clear any default values
     if (isset($_GET['SBGame'])) {
         $games->attributes = $_GET['SBGame'];
     }
     $this->render('games', array('game' => $game, 'games' => $games, 'map_image' => $map_image));
 }
Exemplo n.º 5
0
 /**
  * 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;
 }