Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with plugin status on install/uninstall #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions web/application/controllers/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,35 @@ public function actionInstall($id)

try
{
$plugin->runInstall();
$plugin->status=!$plugin->canDisable()
?SBPlugin::STATUS_ENABLED
:SBPlugin::STATUS_INSTALLED;
$plugin->save();
SourceBans::log('Plugin installed', 'Plugin "' . $plugin->name . '" was installed');
if($plugin->runInstall()!==false)
{
$result=true;
$plugin->status=!$plugin->canDisable()
?SBPlugin::STATUS_ENABLED
:SBPlugin::STATUS_INSTALLED;
$plugin->save();
SourceBans::log('Plugin installed', 'Plugin "' . $plugin->name . '" was installed');
}
else
{
$result=array(
'error' => array(
'message' => Yii::t('sourcebans', 'Installation failed'),
),
);
}
}
catch(Exception $e)
{
Yii::app()->end(CJSON::encode(array(
$result=array(
'error' => array(
'code' => $e->getCode(),
'message' => $e->getMessage(),
),
)));
);
}

Yii::app()->end(CJSON::encode(true));
Yii::app()->end(CJSON::encode($result));
}

public function actionSettings($id)
Expand Down Expand Up @@ -110,22 +121,33 @@ public function actionUninstall($id)

try
{
$plugin->runUninstall();
$plugin->status=0;
$plugin->save();
SourceBans::log('Plugin uninstalled', 'Plugin "' . $plugin->name . '" was uninstalled', SBLog::WARNING_TYPE);
if($plugin->runUninstall()!==false)
{
$result=true;
$plugin->status=0;
$plugin->save();
SourceBans::log('Plugin uninstalled', 'Plugin "' . $plugin->name . '" was uninstalled', SBLog::WARNING_TYPE);
}
else
{
$result=array(
'error' => array(
'message' => Yii::t('sourcebans', 'Uninstallation failed'),
),
);
}
}
catch(Exception $e)
{
Yii::app()->end(CJSON::encode(array(
$result=array(
'error' => array(
'code' => $e->getCode(),
'message' => $e->getMessage(),
),
)));
);
}

Yii::app()->end(CJSON::encode(true));
Yii::app()->end(CJSON::encode($result));
}

/**
Expand Down
2 changes: 2 additions & 0 deletions web/application/messages/cs/sourcebans.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Imported successfully' => '',
'Information' => 'Informace',
'Install' => '',
'Installation failed' => '',
'Invoked on' => 'Uděleno dne',
'Join game' => '',
'Kick player' => '',
Expand Down Expand Up @@ -179,6 +180,7 @@
'Unban reason' => '',
'Unbanned by' => '',
'Uninstall' => '',
'Uninstallation failed' => '',
'Unknown' => 'Neznámý',
'Version' => 'Verze',
'View Steam Profile' => '',
Expand Down
2 changes: 2 additions & 0 deletions web/application/messages/de/sourcebans.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Imported successfully' => '',
'Information' => 'Information',
'Install' => 'Installieren',
'Installation failed' => '',
'Invoked on' => 'Ausgesprochen am',
'Join game' => 'Verbinden',
'Kick player' => 'Spieler kicken',
Expand Down Expand Up @@ -179,6 +180,7 @@
'Unban reason' => 'Entbanngrund',
'Unbanned by' => '@@Entbannt von@@',
'Uninstall' => 'Deinstallieren',
'Uninstallation failed' => '',
'Unknown' => 'Unbekannt',
'Version' => 'Version',
'View Steam Profile' => 'Steam-Profil anzeigen',
Expand Down
2 changes: 2 additions & 0 deletions web/application/messages/en/sourcebans.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Imported successfully' => '',
'Information' => 'Information',
'Install' => 'Install',
'Installation failed' => 'Installation failed',
'Invoked on' => 'Invoked on',
'Join game' => 'Join game',
'Kick player' => 'Kick player',
Expand Down Expand Up @@ -179,6 +180,7 @@
'Unban reason' => 'Unban reason',
'Unbanned by' => '@@Unbanned by@@',
'Uninstall' => 'Uninstall',
'Uninstallation failed' => 'Uninstallation failed',
'Unknown' => 'Unknown',
'Version' => 'Version',
'View Steam Profile' => 'View Steam Profile',
Expand Down
2 changes: 2 additions & 0 deletions web/application/messages/nl/sourcebans.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Imported successfully' => 'Succesvol geïmporteerd',
'Information' => 'Informatie',
'Install' => 'Installeren',
'Installation failed' => '',
'Invoked on' => 'Ingeroepen op',
'Join game' => 'Meespelen',
'Kick player' => 'Kick speler',
Expand Down Expand Up @@ -179,6 +180,7 @@
'Unban reason' => 'Unban reden',
'Unbanned by' => '@@Unbanned by@@',
'Uninstall' => 'Deïnstalleren',
'Uninstallation failed' => '',
'Unknown' => 'Onbekend',
'Version' => 'Versie',
'View Steam Profile' => 'Steam-profiel weergeven',
Expand Down
2 changes: 2 additions & 0 deletions web/application/messages/ru/sourcebans.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Imported successfully' => '',
'Information' => 'Информация',
'Install' => 'Установка',
'Installation failed' => 'Не удалось установить',
'Invoked on' => 'Выдано',
'Join game' => 'Присоединиться',
'Kick player' => 'Отключить игрока',
Expand Down Expand Up @@ -179,6 +180,7 @@
'Unban reason' => 'Причина разбана',
'Unbanned by' => '@@Разбанил(а)@@',
'Uninstall' => 'Удалить',
'Uninstallation failed' => 'Не удалось удалить',
'Unknown' => 'Неизвестно',
'Version' => 'Версия',
'View Steam Profile' => 'Посмотреть профиль Steam',
Expand Down