Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Minekus committed Nov 17, 2013
1 parent e61a81a commit bcdf0c5
Show file tree
Hide file tree
Showing 35 changed files with 209 additions and 199 deletions.
22 changes: 22 additions & 0 deletions web/application/behaviors/UserIdBehavior.php
@@ -0,0 +1,22 @@
<?php
class UserIdBehavior extends CActiveRecordBehavior
{
public $attributes = null;


public function beforeSave($event)
{
if(!$this->owner->isNewRecord)
return;

if(Yii::app() instanceof CConsoleApplication || Yii::app()->user->isGuest)
return;

$id = Yii::app()->user->id;

foreach((array)$this->attributes as $attribute)
{
$this->owner->{$attribute} = $id;
}
}
}
21 changes: 21 additions & 0 deletions web/application/behaviors/UserIpBehavior.php
@@ -0,0 +1,21 @@
<?php
class UserIpBehavior extends CActiveRecordBehavior
{
public $attributes = null;


public function beforeSave($event)
{
if(!$this->owner->isNewRecord)
return;

$ip = Yii::app() instanceof CConsoleApplication
? '127.0.0.1'
: Yii::app()->request->userHostAddress;

foreach((array)$this->attributes as $attribute)
{
$this->owner->{$attribute} = $ip;
}
}
}
1 change: 1 addition & 0 deletions web/application/config/main.php
Expand Up @@ -17,6 +17,7 @@
'import'=>array(
'application.models.*',
'application.components.*',
'application.utils.*',
),

// application components
Expand Down
27 changes: 15 additions & 12 deletions web/application/controllers/AdminController.php
Expand Up @@ -331,20 +331,23 @@ public function actionSettings()

$plugin=new SBPlugin;
$plugin->class=$class;

try
{
$plugin->save();
}
catch(CDbException $e)
{
// Ignore duplicate keys
if($e->errorInfo[1] != 1062)
throw $e;
}
$plugin->save();
}

$plugins=SBPlugin::model()->findAll();
$plugins=new CArrayDataProvider(SBPlugin::model()->findAll(), array(
'keyField'=>'class',
'sort'=>array(
'attributes'=>array(
'author',
'name',
'version',
'*',
),
'defaultOrder'=>array(
'name'=>CSort::SORT_ASC,
),
),
));

$logs=new SBLog('search');
$logs->unsetAttributes(); // clear any default values
Expand Down
7 changes: 6 additions & 1 deletion web/application/controllers/ServersController.php
Expand Up @@ -294,7 +294,12 @@ public function actionConfig()
array('label'=>Yii::t('sourcebans', 'Back'), 'url'=>array('admin/servers')),
);

$this->render('config');
preg_match_all('/([a-z_]+)=([^;]+)/i', Yii::app()->db->connectionString, $dsn);
$db = array_combine($dsn[1], $dsn[2]);

$this->render('config', array(
'db'=>$db,
));
}

/**
Expand Down
49 changes: 23 additions & 26 deletions web/application/messages/cs/sourcebans.php
Expand Up @@ -21,9 +21,9 @@
'<p>Here you will be able to submit a ban for a player who is breaking the rules of the gameserver. When submitting a ban we request you to fill out all the fields to be as descriptive as possible in your comments. This will ensure that your ban submission is processed much faster.</p><p>For a short explanation on how to create a demo, click <a id="demo_howto" href="#">here</a>.</p>' => '@@<p>Zde máš možnost nahlásit hráče, kteří porušují pravidla herního serveru. Při nahlášení hráče prosíme o vyplnění všech polí co možná nejvýstižněji včetně komentářů. Tím zajistíte, že Vaše žádost bude zpracována tak rychle, jak je jen možné. Pro zobrazení krátkého návodu jak vytvořit demo, klikněte <a id="demo_howto" href="#">ZDE</a>.</p>@@',
'A new release is available.' => '',
'Access' => 'Přístup',
'Add comment' => '@@Pridat komentář@@',
'Add comment' => 'Pridat komentář',
'Add to group' => '',
'Admin' => 'Admin',
'Admin Information' => 'Informace o adminovi',
'Admins in group' => 'Admini ve skupině',
'Advanced search' => 'Pokročilé vyhledávání',
'All of the bans in the database can be viewed from here.' => '',
Expand All @@ -32,25 +32,25 @@
'Archived' => '',
'Archived protests' => 'Archivované žádosti o odbanování',
'Archived submissions' => 'Archivované žádosti o ban',
'Are you sure you want to add these items to {name}?' => '',
'Are you sure you want to kick {name}?' => '',
'Are you sure you want to remove these items from {name}?' => '',
'Are you sure you want to uninstall this plugin?\nThis will delete all its data!' => '',
'Authentication type' => '',
'Author' => 'Autor',
'Back' => 'Zpět',
'Ban' => '',
'Ban Information' => 'Informace o banu',
'Ban player' => '',
'Bans' => 'Bany',
'By' => '@@Od@@',
'Change' => '',
'Click' => '@@Klik@@',
'Close' => '',
'Command' => 'Příkaz',
'Command executed' => '',
'Comment' => '@@Komentář@@',
'Comments' => '@@Komentáře@@',
'Comments' => 'Komentáře',
'Confirm' => '@@Potvrdit@@',
'Confirm RCON password' => '@@Podtvrďte RCON heslo@@',
'Players blocked' => '',
'Contact' => '@@Kontakt@@',
'Copy the {section} section below and place it on the game server in {file}, so that it looks similar to this:' => '',
'Country' => 'Stát',
Expand All @@ -59,6 +59,7 @@
'Delete' => 'Smazat',
'Delete comment' => '@@Smazat komentář@@',
'Demo' => '',
'Demos' => '',
'Deny' => 'Odmítnout',
'Description' => '',
'Disable' => '',
Expand All @@ -78,7 +79,6 @@
'File' => 'Soubor',
'File does not exist.' => '@@Soubor neexistuje.@@',
'Filename' => '',
'Flags' => '',
'Folder' => 'Složka',
'Function' => '',
'Game' => '',
Expand All @@ -94,6 +94,7 @@
'Identity' => 'Totožnost',
'Immunity level' => 'Úroveň imunity',
'Import' => '',
'Imported successfully' => '',
'Information' => 'Informace',
'Install' => '',
'Invoked on' => 'Uděleno dne',
Expand All @@ -113,50 +114,46 @@
'Name' => 'Jmeno',
'New' => '@@Nový@@',
'No' => '@@Ne@@',
'No comments' => '',
'No players in the server' => 'Žádní hráči na serveru',
'None' => 'Nikdo',
'Not applicable' => '@@Nebylo použito@@',
'Object' => '',
'Password' => 'Heslo',
'Permanent' => 'Trvalý',
'Players' => 'Hráči',
'Please select an option to administer.' => '',
'Players blocked' => '',
'Please wait' => 'Prosím čekejte',
'Port' => 'Port',
'Powered by' => '@@Poháněno@@',
'Protest Information' => 'Informace o odbanování',
'Protest ban' => 'Žádost o odbanování',
'Query' => '',
'RCON' => '',
'RCON password' => 'RCON heslo',
'Reason' => 'Důvod',
'Reban' => '@@Znovu zabanovat@@',
'Refresh' => 'Obnovit',
'Remove' => 'Remove',
'Remove from group' => '',
'Restore' => '@@Obnovit@@',
'Save' => 'Uložit',
'Saved successfully' => '',
'Score' => 'Skóre',
'Search' => 'Hledat',
'Search bans' => 'Hledat bany',
'See' => '',
'See the {link} for more details.' => '',
'Select' => '',
'Server' => 'Server',
'Server Information' => 'Serverové informace',
'Server group' => 'Serverová skupina',
'Server groups' => 'Serverové skupiny',
'Server password' => '',
'Server permissions' => 'Serverová oprávnění',
'Servers' => 'Servery',
'Servers in group' => 'Servery ve skupině',
'Show inactive bans' => 'Zobrazit neaktivní',
'Status' => '',
'Steam Community ID' => '',
'Steam ID' => '',
'Subject' => '',
'Submission Information' => '',
'Submit' => 'Submit',
'Submit ban' => 'Žádost o ban',
'Submitted on' => '@@Nahlášen dne@@',
'The following is a list of the permissions that you have on this system.' => '',
'The game server needs the following configuration to be able to communicate with the database.' => '',
Expand All @@ -168,13 +165,13 @@
'Timezone' => 'Časová zóna',
'Title' => 'Záhlaví',
'Total' => '@@Celkem@@',
'Total admins' => 'Celkem adminů',
'Total admins' => '@@Celkem adminů@@',
'Total bans' => 'Celkem banů',
'Total demo size' => 'Celková velikost dem',
'Total protests' => 'Celkem žádostí o odbanování',
'Total servers' => 'Celkem serverů',
'Total blocked' => 'Celkem blokovaných připojení',
'Total submissions' => 'Celkem žádostí o ban',
'Total demo size' => '@@Celková velikost dem@@',
'Total protests' => '@@Celkem žádostí o odbanování@@',
'Total servers' => '@@Celkem serverů@@',
'Total submissions' => '@@Celkem žádostí o ban@@',
'Type' => 'Typ',
'Type \'clr\' to clear the console' => '',
'URL' => '',
Expand All @@ -184,14 +181,13 @@
'Uninstall' => '',
'Unknown' => 'Neznámý',
'Version' => 'Verze',
'Version Information' => 'Informace o verzi',
'View Steam Profile' => '',
'Warning' => 'Varování',
'Web group' => 'Webové skupina',
'Web groups' => '@@Webové skupiny@@',
'Web permissions' => 'Webové oprávnění',
'Welcome' => '@@Vítejte@@',
'While you are spectating the offending player, press the ` key on your keyboard. Then type record [demoname] and hit enter. Also type sb_status for extra information in SteamBans servers. The file will be in your game folder.' => 'Zatímco sledujete daného hráče stiskněte klávesu ~ (pod Escape). Pak napište record [názevdema] a stiskněte Enter. Také můžete napsat sb_status pro další informace ze SteamBans serverů. Soubor bude uložen ve složce herního módu.',
'While you are spectating the offending player, press the ` key on your keyboard. Then type record [demoname] and hit enter. Also type sb_status for extra information in SteamBans servers. The file will be in your game folder.' => '@@Zatímco sledujete daného hráče stiskněte klávesu ~ (pod Escape). Pak napište record [názevdema] a stiskněte Enter. Také můžete napsat sb_status pro další informace ze SteamBans serverů. Soubor bude uložen ve složce herního módu.@@',
'Yes' => '@@Ano@@',
'You can submit a demo or screenshot of a suspected cheater here. It will then be up for review by one of the admins.' => 'Zde můžeš vložit demo nebo screenshot, který usvědčuje cheatera a některý z adminů se tím bude zabývat.',
'You have the latest release.' => '',
Expand All @@ -213,8 +209,8 @@
'controllers.admin.bans.menu.submissions' => 'Žádost o ban',
'controllers.admin.bans.title' => 'Bany',
'controllers.admin.games.menu.add' => '',
'controllers.admin.games.menu.map-image' => '',
'controllers.admin.games.menu.list' => '',
'controllers.admin.games.menu.map-image' => '',
'controllers.admin.games.title' => '',
'controllers.admin.groups.menu.add' => 'Přidat skupinu',
'controllers.admin.groups.menu.import' => 'Importovat skupiny',
Expand Down Expand Up @@ -312,6 +308,7 @@
'models.SettingsForm.enable_submit' => '',
'models.SettingsForm.items_per_page' => '',
'models.SettingsForm.language' => 'Jazyk',
'models.SettingsForm.mailer_from' => '',
'models.SettingsForm.password_min_length' => '',
'models.SettingsForm.smtp_host' => '',
'models.SettingsForm.smtp_password' => '',
Expand Down Expand Up @@ -357,12 +354,12 @@
'permissions.unban_own_bans' => 'Odbanovat valstní bany',
'views.admin.bans.protests.active.title' => '',
'views.admin.bans.protests.archive.title' => 'Archiv',
'views.admin.bans.protests.grid.archive' => 'Archiv',
'views.admin.bans.protests.grid.archive' => '@@Archiv@@',
'views.admin.bans.submissions.active.title' => '',
'views.admin.bans.submissions.archive.title' => 'Archiv',
'views.admin.bans.submissions.grid.archive' => 'Archiv',
'views.admin.settings.plugins.grid.settings' => 'Sastavení',
'views.admin.bans.submissions.grid.archive' => '@@Archiv@@',
'views.admin.settings.help.steam_web_api_key' => "",
'views.admin.settings.plugins.grid.settings' => 'Sastavení',
'week' => '@@týden@@',
'weeks' => 'týdny(ů)',
'{n} day|{n} days' => '{n} den|{n} dny(ů)',
Expand Down

0 comments on commit bcdf0c5

Please sign in to comment.