Skip to content

Commit

Permalink
update the default backend credentials (fixes #271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Stenvall committed Nov 25, 2015
1 parent a5467ae commit 15989fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/protected/controllers/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ public function actionCreate()
}
else
{
$model->hostname = 'localhost';
$model->port = 8080;
$model->tcp_port = 9090;
$model->username = 'xbmc';
$model->password = 'xbmc';
$model->setDefaultValues();

// Check "default" if there are no other backends
$backends = Backend::model()->findAll();
Expand Down
18 changes: 18 additions & 0 deletions src/protected/models/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
class Backend extends CActiveRecord
{

const DEFAULT_HOSTNAME = 'localhost';
const DEFAULT_PORT = 8080;
const DEFAULT_TCP_PORT = 9090;
const DEFAULT_USERNAME = 'kodi';
const DEFAULT_PASSWORD = 'kodi';

/**
* Timeout (in seconds) limit while checking if a backend is connectable
*/
Expand Down Expand Up @@ -239,6 +245,18 @@ protected function afterSave()
parent::afterSave();
}

/**
* Resets some attributes to their default values
*/
public function setDefaultValues()
{
$this->hostname = self::DEFAULT_HOSTNAME;
$this->port = self::DEFAULT_PORT;
$this->tcp_port = self::DEFAULT_TCP_PORT;
$this->username = self::DEFAULT_USERNAME;
$this->password = self::DEFAULT_PASSWORD;
}

/**
* @return boolean whether this backend is connectable
* @param int $port the port to try to connect to. Defaults to null, meaning
Expand Down

0 comments on commit 15989fb

Please sign in to comment.