Пример #1
0
 public function testCreate()
 {
     $admin = $this->admins('Test');
     $server = $this->servers('127.0.0.1');
     $model = new SBBan();
     $model->name = 'Tester';
     $model->type = SBBan::TYPE_STEAM;
     $model->steam = 'STEAM_0:1:2';
     $model->reason = 'Testing';
     $model->length = 5;
     $model->server_id = $server->id;
     $model->admin_id = $admin->id;
     $this->assertTrue($model->save());
 }
Пример #2
0
 /**
  * Displays the bans page
  */
 public function actionBans()
 {
     $this->pageTitle = Yii::t('sourcebans', 'controllers.default.bans.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.default.bans.title'));
     $hideInactive = Yii::app()->request->getQuery('hideinactive', 'false') == 'true';
     $search = Yii::app()->request->getQuery('q');
     $ban = new SBBan();
     $bans = new SBBan('search');
     $bans->unsetAttributes();
     // clear any default values
     if (isset($_GET['SBBan'])) {
         $bans->attributes = $_GET['SBBan'];
     }
     $comment = new SBComment();
     $comment->object_type = SBComment::TYPE_BAN;
     $this->render('bans', array('ban' => $ban, 'bans' => $bans, 'comment' => $comment, 'hideInactive' => $hideInactive, 'search' => $search, 'total_bans' => SBBan::model()->count(array('scopes' => $hideInactive ? 'active' : null))));
 }
Пример #3
0
 /**
  * Displays the admin page
  */
 public function actionIndex()
 {
     $this->layout = '//layouts/column1';
     $this->pageTitle = Yii::t('sourcebans', 'controllers.admin.index.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.admin.index.title'));
     $this->menu = array(array('label' => Yii::t('sourcebans', 'controllers.admin.admins.title'), 'url' => array('admin/admins'), 'itemOptions' => array('class' => 'admins'), 'visible' => Yii::app()->user->data->hasPermission('ADD_ADMINS', 'DELETE_ADMINS', 'EDIT_ADMINS', 'LIST_ADMINS')), array('label' => Yii::t('sourcebans', 'controllers.admin.bans.title'), 'url' => array('admin/bans'), 'itemOptions' => array('class' => 'bans'), 'visible' => Yii::app()->user->data->hasPermission('ADD_BANS', 'IMPORT_BANS', 'BAN_APPEALS', 'BAN_REPORTS')), array('label' => Yii::t('sourcebans', 'controllers.admin.groups.title'), 'url' => array('admin/groups'), 'itemOptions' => array('class' => 'groups'), 'visible' => Yii::app()->user->data->hasPermission('ADD_GROUPS', 'DELETE_GROUPS', 'EDIT_GROUPS', 'LIST_GROUPS')), array('label' => Yii::t('sourcebans', 'controllers.admin.servers.title'), 'url' => array('admin/servers'), 'itemOptions' => array('class' => 'servers'), 'visible' => Yii::app()->user->data->hasPermission('ADD_SERVERS', 'DELETE_SERVERS', 'EDIT_SERVERS', 'LIST_SERVERS')), array('label' => Yii::t('sourcebans', 'controllers.admin.games.title'), 'url' => array('admin/games'), 'itemOptions' => array('class' => 'games'), 'visible' => Yii::app()->user->data->hasPermission('ADD_GAMES', 'DELETE_GAMES', 'EDIT_GAMES', 'LIST_GAMES')), array('label' => Yii::t('sourcebans', 'controllers.admin.settings.title'), 'url' => array('admin/settings'), 'itemOptions' => array('class' => 'settings'), 'visible' => Yii::app()->user->data->hasPermission('SETTINGS')));
     $demosize = Helpers::getDirectorySize(Yii::getPathOfAlias('webroot.demos'));
     $this->render('index', array('demosize' => Yii::app()->format->formatSize($demosize['size']), 'total_admins' => SBAdmin::model()->count(), 'total_archived_appeals' => SBAppeal::model()->countByAttributes(array('archived' => true)), 'total_archived_reports' => SBReport::model()->countByAttributes(array('archived' => true)), 'total_bans' => SBBan::model()->count(), 'total_blocks' => SBBlock::model()->count(), 'total_appeals' => SBAppeal::model()->countByAttributes(array('archived' => false)), 'total_servers' => SBServer::model()->count(), 'total_reports' => SBReport::model()->countByAttributes(array('archived' => false))));
 }
Пример #4
0
      <?php 
echo $form->textArea($model, 'reason', array('size' => 60, 'maxlength' => 255));
?>
      <?php 
echo $form->error($model, 'reason');
?>
    </div>
  </div>

  <div class="control-group">
    <?php 
echo $form->label($model, 'length', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->dropDownList($model, 'length', SBBan::getTimes());
?>
      <?php 
echo $form->error($model, 'length');
?>
    </div>
  </div>

<?php 
if ($model->isNewRecord) {
    ?>
  <div class="control-group">
    <?php 
    echo CHtml::label($model->getAttributeLabel('demo.filename'), 'SBDemo_filename', array('class' => 'control-label'));
    ?>
    <div class="controls">
Пример #5
0
 public function actionBanGroup($id)
 {
     $group = new SteamGroup($id);
     $members = $group->members;
     do {
         // SteamProfile::getSummaries is limited to 100 Steam IDs,
         // so repeatedly remove the first 100 until the array is empty.
         $steamids = array_splice($members, 0, 100);
         $profiles = SteamProfile::getSummaries($steamids);
         $steamids = Helpers::getSteamId($steamids);
         foreach ($profiles as $i => $member) {
             $ban = new SBBan();
             $ban->type = SBBan::TYPE_STEAM;
             $ban->steam = $steamids[$i];
             $ban->name = $member['personaname'];
             $ban->reason = 'Member of Steam Community group "' . $group->groupName . '"';
             $ban->length = 0;
             $ban->save();
         }
     } while (!empty($members));
 }
Пример #6
0
echo $form->label($model, 'create_time', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->textField($model, 'create_time');
?>
    </div>
  </div>

  <div class="control-group">
    <?php 
echo $form->label($model, 'length', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->dropDownList($model, 'length', SBBan::getTimes(), array('empty' => '- ' . Yii::t('sourcebans', 'None') . ' -'));
?>
    </div>
  </div>

  <div class="control-group">
    <?php 
echo $form->label($model, 'admin_id', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->dropDownList($model, 'admin_id', CHtml::listData(SBAdmin::model()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '- ' . Yii::t('sourcebans', 'None') . ' -'));
?>
    </div>
  </div>
Пример #7
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 SBBan the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SBBan::model()->with('admin')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }