diff --git a/README.md b/README.md
index 9812dfe8..237fc0ab 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
PHP Censor
----------
-PHP Censor is a fork of PHPCI (And B8Framework). PHP Censor is a free and open source (BSD-2-Clause license) continuous
+PHP Censor is a fork of PHPCI (And B8Framework) and is a free and open source (BSD-2-Clause license) continuous
integration tool specifically designed for PHP. We've built it with simplicity in mind, so whilst it doesn't
do *everything* Jenkins can do, it is a breeze to set up and use.
@@ -23,11 +23,6 @@ What it doesn't do (yet)
* Install PEAR or PECL extensions.
* Deployments
-Documentation
-=============
-
-[PHP Censor documentation](docs/README.md)
-
Tests
=====
@@ -40,7 +35,29 @@ For Phar plugin tests set 'phar.readonly' setting to Off (0) in `php.ini` config
For database B8Framework tests create empty 'b8_test' MySQL database on 'localhost' with user/password: `root/root`.
+Migrations
+==========
+
+Run to apply latest migrations:
+
+```bash
+cd /path/to/php-censor
+./bin/console php-censor-migrations:migrate
+```
+
+Run to create new migration:
+
+```bash
+cd /path/to/php-censor
+./bin/console php-censor-migrations:create NewMigrationName
+```
+
+Documentation
+=============
+
+[PHP Censor documentation](docs/README.md)
+
License
=======
-The PHP Censor is open source software licensed under the BSD-2-Clause license.
+PHP Censor is open source software licensed under the BSD-2-Clause license.
diff --git a/app/config.example.yml b/app/config.example.yml
index fba80e9d..8542ba01 100644
--- a/app/config.example.yml
+++ b/app/config.example.yml
@@ -8,7 +8,9 @@ b8:
username: php-censor-user
password: php-censor-password
php-censor:
- url: 'http://php-censor.local'
+ language: en
+ per_page: 10
+ url: 'http://php-censor.local'
worker:
host: localhost
queue: php-censor-queue
diff --git a/app/phinx.php b/app/phinx.php
deleted file mode 100644
index e2a5dc7e..00000000
--- a/app/phinx.php
+++ /dev/null
@@ -1,36 +0,0 @@
-get('b8.database.servers.write');
-
-if (!is_array($writeServers)) {
- $writeServers = [$writeServers];
-}
-
-$conf = [
- 'paths' => [
- 'migrations' => 'src/PHPCensor/Migrations',
- ],
- 'environments' => [
- 'default_migration_table' => 'migration',
- 'default_database' => 'php-censor',
- 'php-censor' => [
- 'adapter' => 'mysql',
- 'host' => end($writeServers),
- 'name' => $config->get('b8.database.name'),
- 'user' => $config->get('b8.database.username'),
- 'pass' => $config->get('b8.database.password'),
- ],
- ],
-];
-
-return $conf;
diff --git a/bin/console b/bin/console
index 4d1cddd7..9360d461 100755
--- a/bin/console
+++ b/bin/console
@@ -11,7 +11,6 @@
use PHPCensor\Command\RunCommand;
use PHPCensor\Command\RebuildCommand;
-use PHPCensor\Command\UpdateCommand;
use PHPCensor\Command\InstallCommand;
use PHPCensor\Command\DaemonCommand;
use PHPCensor\Command\PollCommand;
@@ -20,8 +19,8 @@ use PHPCensor\Command\CreateBuildCommand;
use PHPCensor\Command\WorkerCommand;
use PHPCensor\Command\RebuildQueueCommand;
use PHPCensor\Service\BuildService;
-use Symfony\Component\Console\Application;
use b8\Store\Factory;
+use PHPCensor\Console\Application;
define('IS_CONSOLE', true);
@@ -32,7 +31,6 @@ $application = new Application();
$application->add(new RunCommand($loggerConfig->getFor('RunCommand')));
$application->add(new RebuildCommand($loggerConfig->getFor('RunCommand')));
$application->add(new InstallCommand);
-$application->add(new UpdateCommand($loggerConfig->getFor('UpdateCommand')));
$application->add(new DaemonCommand($loggerConfig->getFor('DaemonCommand')));
$application->add(new PollCommand($loggerConfig->getFor('PollCommand')));
$application->add(new CreateAdminCommand(Factory::getStore('User')));
diff --git a/docs/en/installing.md b/docs/en/installing.md
index 0880aab1..d3814259 100644
--- a/docs/en/installing.md
+++ b/docs/en/installing.md
@@ -19,7 +19,7 @@ Installing PHP Censor from Composer
* Download Composer if you haven't already: `curl -sS https://getcomposer.org/installer | php`
* Download PHP Censor: `./composer.phar create-project corpsee/php-censor php-censor --keep-vcs --no-dev`
* Go to the newly created PHP Censor directory, and install Composer dependencies: `cd php-censor && ../composer.phar install`
-* Run the PHP Censor installer: `./console php-censor:install`
+* Run the PHP Censor installer: `./bin/console php-censor:install`
* [Add a virtual host to your web server](virtual_host.md), pointing to the `public` directory within your new PHP Censor directory. You'll need to set up rewrite rules to point all non-existent requests to PHP Censor.
* [Set up the PHP Censor Worker](workers/worker.md), or you can run builds using the [daemon](workers/daemon.md) or [a cron-job](workers/cron.md) to run PHP Censor builds.
@@ -30,6 +30,6 @@ Installing PHP Censor Manually
* [Download PHP Censor](https://github.com/corpsee/php-censor/releases/latest) and unzip it.
* Go to the PHP Censor directory: `cd /var/www/php-censor`
* Install dependencies using Composer: `composer install`
-* Install PHP Censor itself: `./console php-censor:install`
+* Install PHP Censor itself: `./bin/console php-censor:install`
* [Add a virtual host to your web server](virtual_host.md), pointing to the `public` directory within your new PHP Censor directory. You'll need to set up rewrite rules to point all non-existent requests to PHP Censor.
* [Set up the PHP Censor Worker](workers/worker.md), or you can run builds using the [daemon](workers/daemon.md) or [a cron-job](workers/cron.md) to run PHP Censor builds.
diff --git a/docs/en/updating.md b/docs/en/updating.md
index 74a5380c..33bb8e8c 100644
--- a/docs/en/updating.md
+++ b/docs/en/updating.md
@@ -5,7 +5,7 @@ Updating PHP Censor to the latest release, or even dev-master updates is somethi
1. Go to your PHP Censor root folder in a Terminal.
2. Pull the latest code. This would look like this: `git pull`
-3. Update the PHP Censor database: `./console php-censor:update`
+3. Update the PHP Censor database: `./bin/console php-censor-migrations:migrate`
4. Update the composer and its packages: `composer self-update && composer update`
5. Return to the PHP Censor admin screens and check your desired plugins are still installed correctly.
7. Run a build to make sure everything is working as expected.
diff --git a/docs/en/workers/cron.md b/docs/en/workers/cron.md
index d0a2da1f..d3c69f08 100644
--- a/docs/en/workers/cron.md
+++ b/docs/en/workers/cron.md
@@ -11,7 +11,7 @@ Setting up the Cron Job
You'll want to set up PHP Censor to run as a regular cronjob, so run `crontab -e` and enter the following:
```sh
-* * * * * /usr/bin/php /path/to/php-censor/console php-censor:run-builds
+* * * * * /usr/bin/php /path/to/php-censor/bin/console php-censor:run-builds
```
**Note:** Make sure you change the `/path/to/php-censor` to the directory in which you installed PHP Censor, and update the PHP path if necessary.
diff --git a/docs/en/workers/worker.md b/docs/en/workers/worker.md
index 07be7937..c9ea6a71 100644
--- a/docs/en/workers/worker.md
+++ b/docs/en/workers/worker.md
@@ -37,7 +37,7 @@ Using your preferred text editor, create a file named `php-censor.conf` under `/
```
[program:php-censor]
-command=/path/to/php-censor/latest/console php-censor:worker
+command=/path/to/php-censor/bin/console php-censor:worker
process_name=%(program_name)s_%(process_num)02d
stdout_logfile=/var/log/php-censor.log
stderr_logfile=/var/log/php-censor-err.log
diff --git a/public/assets/js/app.js b/public/assets/js/app.js
index df0fa789..d5dad8ad 100644
--- a/public/assets/js/app.js
+++ b/public/assets/js/app.js
@@ -45,7 +45,7 @@ var PHPCensor = {
getProjectBuilds: function () {
$.ajax({
- url: APP_URL + 'project/builds/' + PROJECT_ID + '?branch=' + PROJECT_BRANCH,
+ url: APP_URL + 'project/builds/' + PROJECT_ID + '?branch=' + PROJECT_BRANCH + '&per_page=' + PER_PAGE,
success: function (data) {
$('#latest-builds').html(data);
diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php
index e0a27aa2..dbff37b3 100644
--- a/src/PHPCensor/Command/InstallCommand.php
+++ b/src/PHPCensor/Command/InstallCommand.php
@@ -192,7 +192,7 @@ class InstallCommand extends Command
}
if (!$adminName = $input->getOption('admin-name')) {
- $questionName = new Question(Lang::get('admin-name'));
+ $questionName = new Question(Lang::get('admin_name'));
$adminName = $helper->ask($input, $output, $questionName);
}
@@ -240,6 +240,9 @@ class InstallCommand extends Command
$url = $helper->ask($input, $output, $question);
}
+ $config['language'] = 'en';
+ $config['per_page'] = 10;
+
$config['url'] = $url;
$config['worker'] = $this->getQueueInformation($input, $output, $helper);
@@ -382,9 +385,7 @@ class InstallCommand extends Command
{
$output->write(Lang::get('setting_up_db'));
- $phinxBinary = escapeshellarg(ROOT_DIR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'phinx');
- $phinxScript = escapeshellarg(APP_DIR . 'phinx.php');
- shell_exec($phinxBinary . ' migrate -c ' . $phinxScript);
+ shell_exec(ROOT_DIR . 'bin/console php-censor-migrations:migrate');
$output->writeln(''.Lang::get('ok').'');
}
diff --git a/src/PHPCensor/Command/UpdateCommand.php b/src/PHPCensor/Command/UpdateCommand.php
deleted file mode 100644
index 180460d1..00000000
--- a/src/PHPCensor/Command/UpdateCommand.php
+++ /dev/null
@@ -1,68 +0,0 @@
-
- * @package PHPCI
- * @subpackage Console
- */
-class UpdateCommand extends Command
-{
- /**
- * @var \Monolog\Logger
- */
- protected $logger;
-
- public function __construct(Logger $logger, $name = null)
- {
- parent::__construct($name);
- $this->logger = $logger;
- }
-
- protected function configure()
- {
- $this
- ->setName('php-censor:update')
- ->setDescription(Lang::get('update_app'));
- }
-
- /**
- * Generates Model and Store classes by reading database meta data.
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if (!$this->verifyInstalled()) {
- return;
- }
-
- $output->write(Lang::get('updating_app'));
-
- shell_exec(ROOT_DIR . 'vendor/bin/phinx migrate -c "' . APP_DIR . 'phinx.php"');
-
- $output->writeln(''.Lang::get('ok').'');
- }
-
- protected function verifyInstalled()
- {
- $config = Config::getInstance();
- $url = $config->get('php-censor.url');
-
- return !empty($url);
- }
-}
diff --git a/src/PHPCensor/Console/Application.php b/src/PHPCensor/Console/Application.php
new file mode 100644
index 00000000..5df1c378
--- /dev/null
+++ b/src/PHPCensor/Console/Application.php
@@ -0,0 +1,68 @@
+get('b8.database', []);
+
+ $phinxSettings = [
+ 'paths' => [
+ 'migrations' => 'src/PHPCensor/Migrations',
+ ],
+ 'environments' => [
+ 'default_migration_table' => 'migration',
+ 'default_database' => 'php-censor',
+ 'php-censor' => [
+ 'adapter' => 'mysql',
+ 'host' => $databaseSettings['servers']['write'],
+ 'name' => $databaseSettings['name'],
+ 'user' => $databaseSettings['username'],
+ 'pass' => $databaseSettings['password'],
+ ],
+ ],
+ ];
+
+ $phinxConfig = new PhinxConfig($phinxSettings);
+
+ $this->add(
+ (new Create())
+ ->setConfig($phinxConfig)
+ ->setName('php-censor-migrations:create')
+ );
+ $this->add(
+ (new Migrate())
+ ->setConfig($phinxConfig)
+ ->setName('php-censor-migrations:migrate')
+ );
+ $this->add(
+ (new Rollback())
+ ->setConfig($phinxConfig)
+ ->setName('php-censor-migrations:rollback')
+ );
+ $this->add(
+ (new Status())
+ ->setConfig($phinxConfig)
+ ->setName('php-censor-migrations:status')
+ );
+ }
+}
diff --git a/src/PHPCensor/Controller/BuildController.php b/src/PHPCensor/Controller/BuildController.php
index 73a15f47..6bc2d353 100644
--- a/src/PHPCensor/Controller/BuildController.php
+++ b/src/PHPCensor/Controller/BuildController.php
@@ -1,4 +1,5 @@
getFinalPerPage();
$page = $this->getParam('p', 1);
- $builds = $this->getLatestBuildsHtml($projectId, urldecode($branch), (($page - 1) * $per_page));
- $pages = $builds[1] == 0 ? 1 : ceil($builds[1] / $per_page);
+ $builds = $this->getLatestBuildsHtml($projectId, urldecode($branch), (($page - 1) * $perPage), $perPage);
+ $pages = $builds[1] == 0 ? 1 : ceil($builds[1] / $perPage);
if ($page > $pages) {
$response = new b8\Http\Response\RedirectResponse();
@@ -90,8 +91,9 @@ class ProjectController extends PHPCensor\Controller
$this->view->branches = $this->projectStore->getKnownBranches($projectId);
$this->view->page = $page;
$this->view->pages = $pages;
+ $this->view->perPage = $perPage;
- $this->layout->title = $project->getTitle();
+ $this->layout->title = $project->getTitle();
$this->layout->subtitle = $this->view->branch;
return $this->view->render();
@@ -141,12 +143,17 @@ class ProjectController extends PHPCensor\Controller
}
/**
- * AJAX get latest builds.
- */
+ * AJAX get latest builds.
+ *
+ * @param int $projectId
+ *
+ * @return b8\Http\Response
+ */
public function builds($projectId)
{
- $branch = $this->getParam('branch', '');
- $builds = $this->getLatestBuildsHtml($projectId, urldecode($branch));
+ $branch = $this->getParam('branch', '');
+ $perPage = (integer)$this->getParam('per_page', 10);
+ $builds = $this->getLatestBuildsHtml($projectId, urldecode($branch), 0, $perPage);
$this->response->disableLayout();
$this->response->setContent($builds[0]);
@@ -156,12 +163,14 @@ class ProjectController extends PHPCensor\Controller
/**
* Render latest builds for project as HTML table.
*
- * @param $projectId
- * @param string $branch A urldecoded branch name.
- * @param int $start
+ * @param int $projectId
+ * @param string $branch A urldecoded branch name.
+ * @param int $start
+ * @param int $perPage
+ *
* @return array
*/
- protected function getLatestBuildsHtml($projectId, $branch = '', $start = 0)
+ protected function getLatestBuildsHtml($projectId, $branch = '', $start = 0, $perPage = 10)
{
$criteria = ['project_id' => $projectId];
if (!empty($branch)) {
@@ -169,7 +178,7 @@ class ProjectController extends PHPCensor\Controller
}
$order = ['id' => 'DESC'];
- $builds = $this->buildStore->getWhere($criteria, 10, $start, [], $order);
+ $builds = $this->buildStore->getWhere($criteria, $perPage, $start, [], $order);
$view = new b8\View('BuildsTable');
foreach ($builds['items'] as &$build) {
diff --git a/src/PHPCensor/Controller/SessionController.php b/src/PHPCensor/Controller/SessionController.php
index c760dfca..51e3afe8 100644
--- a/src/PHPCensor/Controller/SessionController.php
+++ b/src/PHPCensor/Controller/SessionController.php
@@ -1,4 +1,5 @@
request->getMethod() == 'POST') {
- $name = $this->getParam('name', null);
- $email = $this->getParam('email', null);
+ $name = $this->getParam('name', null);
+ $email = $this->getParam('email', null);
$password = $this->getParam('password', null);
+ $language = $this->getParam('language', null);
+ $perPage = $this->getParam('per_page', null);
- $currentLang = Lang::getLanguage();
- $chosenLang = $this->getParam('language', $currentLang);
-
- if ($chosenLang !== $currentLang) {
- setcookie('php-censor-language', $chosenLang, time() + (10 * 365 * 24 * 60 * 60), '/');
- Lang::setLanguage($chosenLang);
- }
-
- $_SESSION['php-censor-user'] = $this->userService->updateUser($user, $name, $email, $password);
- $user = $_SESSION['php-censor-user'];
+ $_SESSION['php-censor-user'] = $this->userService->updateUser($user, $name, $email, $password, null, $language, $perPage);
+ $user = $_SESSION['php-censor-user'];
$this->view->updated = 1;
}
- $this->layout->title = $user->getName();
+ $this->layout->title = $user->getName();
$this->layout->subtitle = Lang::get('edit_profile');
- $values = $user->getDataArray();
-
- if (array_key_exists('php-censor-language', $_COOKIE)) {
- $values['language'] = $_COOKIE['php-censor-language'];
- }
-
$form = new Form();
$form->setAction(APP_URL.'user/profile');
$form->setMethod('POST');
@@ -100,6 +90,7 @@ class UserController extends Controller
$name->setContainerClass('form-group');
$name->setLabel(Lang::get('name'));
$name->setRequired(true);
+ $name->setValue($user->getName());
$form->addField($name);
$email = new Form\Element\Email('email');
@@ -107,6 +98,7 @@ class UserController extends Controller
$email->setContainerClass('form-group');
$email->setLabel(Lang::get('email_address'));
$email->setRequired(true);
+ $email->setValue($user->getEmail());
$form->addField($email);
$password = new Form\Element\Password('password');
@@ -114,24 +106,41 @@ class UserController extends Controller
$password->setContainerClass('form-group');
$password->setLabel(Lang::get('password_change'));
$password->setRequired(false);
+ $password->setValue(null);
$form->addField($password);
- $lang = new Form\Element\Select('language');
- $lang->setClass('form-control');
- $lang->setContainerClass('form-group');
- $lang->setLabel(Lang::get('language'));
- $lang->setRequired(true);
- $lang->setOptions(Lang::getLanguageOptions());
- $lang->setValue(Lang::getLanguage());
- $form->addField($lang);
+ $language = new Form\Element\Select('language');
+ $language->setClass('form-control');
+ $language->setContainerClass('form-group');
+ $language->setLabel(Lang::get('language'));
+ $language->setRequired(true);
+ $language->setOptions(array_merge(
+ ['' => Lang::get('default') . ' (' . b8\Config::getInstance()->get('php-censor.language') . ')'],
+ Lang::getLanguageOptions())
+ );
+ $language->setValue($user->getLanguage());
+ $form->addField($language);
+
+ $perPage = new Form\Element\Select('per_page');
+ $perPage->setClass('form-control');
+ $perPage->setContainerClass('form-group');
+ $perPage->setLabel(Lang::get('per_page'));
+ $perPage->setRequired(true);
+ $perPage->setOptions([
+ null => Lang::get('default') . ' (' . b8\Config::getInstance()->get('php-censor.per_page') . ')',
+ 10 => 10,
+ 25 => 25,
+ 50 => 50,
+ 100 => 100,
+ ]);
+ $perPage->setValue($user->getPerPage());
+ $form->addField($perPage);
$submit = new Form\Element\Submit();
$submit->setClass('btn btn-success');
$submit->setValue(Lang::get('save'));
$form->addField($submit);
- $form->setValues($values);
-
$this->view->form = $form;
return $this->view->render();
diff --git a/src/PHPCensor/Controller/WebhookController.php b/src/PHPCensor/Controller/WebhookController.php
index 4b29a35d..ca1a6f57 100644
--- a/src/PHPCensor/Controller/WebhookController.php
+++ b/src/PHPCensor/Controller/WebhookController.php
@@ -1,4 +1,5 @@
get('php-censor.basic.language', null);
+ $language = $user->getLanguage();
if (self::setLanguage($language)) {
return;
}
- // Fall back to English:
- self::$language = 'en';
- self::$strings = self::loadLanguage();
+ // Try the installation default language:
+ $language = $config->get('php-censor.language', self::DEFAULT_LANGUAGE);
+ if (self::setLanguage($language)) {
+ return;
+ }
}
/**
diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php
index 92bdb05a..b63abeb5 100644
--- a/src/PHPCensor/Languages/lang.en.php
+++ b/src/PHPCensor/Languages/lang.en.php
@@ -9,7 +9,9 @@
return [
'language_name' => 'English',
- 'language' => 'Language',
+ 'language' => 'Language',
+ 'per_page' => 'Items per page',
+ 'default' => 'Default',
// Log in:
'log_in_to_app' => 'Log in to PHP Censor',
diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php
index e0bbf670..a96f87ca 100644
--- a/src/PHPCensor/Languages/lang.ru.php
+++ b/src/PHPCensor/Languages/lang.ru.php
@@ -9,7 +9,9 @@
return [
'language_name' => 'Pусский',
- 'language' => 'язык',
+ 'language' => 'Язык',
+ 'per_page' => 'Количество элементов на странице',
+ 'default' => 'По умолчанию',
// Log in:
'log_in_to_app' => 'Войти в PHP Censor',
diff --git a/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php b/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php
new file mode 100644
index 00000000..b6352b19
--- /dev/null
+++ b/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php
@@ -0,0 +1,32 @@
+table('user');
+
+ if (!$table->hasColumn('language')) {
+ $table->addColumn('language', 'string', ['limit' => 5, 'null' => true])->save();
+ }
+
+ if (!$table->hasColumn('per_page')) {
+ $table->addColumn('per_page', 'integer', ['null' => true])->save();
+ }
+ }
+
+ public function down()
+ {
+ $table = $this->table('user');
+
+ if ($table->hasColumn('language')) {
+ $table->removeColumn('language')->save();
+ }
+
+ if ($table->hasColumn('per_page')) {
+ $table->removeColumn('per_page')->save();
+ }
+ }
+}
diff --git a/src/PHPCensor/Model/Base/UserBase.php b/src/PHPCensor/Model/Base/UserBase.php
index 1b97883d..99aedeb2 100644
--- a/src/PHPCensor/Model/Base/UserBase.php
+++ b/src/PHPCensor/Model/Base/UserBase.php
@@ -6,6 +6,7 @@
namespace PHPCensor\Model\Base;
+use b8\Config;
use PHPCensor\Model;
/**
@@ -37,6 +38,8 @@ class UserBase extends Model
'hash' => null,
'is_admin' => null,
'name' => null,
+ 'language' => null,
+ 'per_page' => null,
];
/**
@@ -49,6 +52,8 @@ class UserBase extends Model
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
+ 'language' => 'getLanguage',
+ 'per_page' => 'getPerPage',
// Foreign key getters:
];
@@ -62,6 +67,8 @@ class UserBase extends Model
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
+ 'language' => 'setLanguage',
+ 'per_page' => 'setPerPage',
// Foreign key setters:
];
@@ -95,6 +102,16 @@ class UserBase extends Model
'length' => 250,
'default' => null,
],
+ 'language' => [
+ 'type' => 'varchar',
+ 'length' => 5,
+ 'default' => null,
+ ],
+ 'per_page' => [
+ 'type' => 'int',
+ 'length' => 11,
+ 'default' => null,
+ ],
];
/**
@@ -119,7 +136,7 @@ class UserBase extends Model
*/
public function getId()
{
- $rtn = $this->data['id'];
+ $rtn = $this->data['id'];
return $rtn;
}
@@ -131,7 +148,7 @@ class UserBase extends Model
*/
public function getEmail()
{
- $rtn = $this->data['email'];
+ $rtn = $this->data['email'];
return $rtn;
}
@@ -143,7 +160,7 @@ class UserBase extends Model
*/
public function getHash()
{
- $rtn = $this->data['hash'];
+ $rtn = $this->data['hash'];
return $rtn;
}
@@ -155,7 +172,7 @@ class UserBase extends Model
*/
public function getIsAdmin()
{
- $rtn = $this->data['is_admin'];
+ $rtn = $this->data['is_admin'];
return $rtn;
}
@@ -167,7 +184,31 @@ class UserBase extends Model
*/
public function getName()
{
- $rtn = $this->data['name'];
+ $rtn = $this->data['name'];
+
+ return $rtn;
+ }
+
+ /**
+ * Get the value of Language / language.
+ *
+ * @return string
+ */
+ public function getLanguage()
+ {
+ $rtn = $this->data['language'];
+
+ return $rtn;
+ }
+
+ /**
+ * Get the value of PerPage / per_page.
+ *
+ * @return string
+ */
+ public function getPerPage()
+ {
+ $rtn = $this->data['per_page'];
return $rtn;
}
@@ -271,4 +312,51 @@ class UserBase extends Model
$this->_setModified('name');
}
+
+ /**
+ * Set the value of Language / language.
+ *
+ * Must not be null.
+ * @param $value string
+ */
+ public function setLanguage($value)
+ {
+ if ($this->data['language'] === $value) {
+ return;
+ }
+
+ $this->data['language'] = $value;
+
+ $this->_setModified('language');
+ }
+
+ /**
+ * Set the value of PerPage / per_page.
+ *
+ * Must not be null.
+ * @param $value string
+ */
+ public function setPerPage($value)
+ {
+ if ($this->data['per_page'] === $value) {
+ return;
+ }
+
+ $this->data['per_page'] = $value;
+
+ $this->_setModified('per_page');
+ }
+
+ /**
+ * @return integer
+ */
+ public function getFinalPerPage()
+ {
+ $perPage = $this->getPerPage();
+ if ($perPage) {
+ return (integer)$perPage;
+ }
+
+ return (integer)Config::getInstance()->get('php-censor.per_page', 10);
+ }
}
diff --git a/src/PHPCensor/Model/User.php b/src/PHPCensor/Model/User.php
index 65c8954b..e3afe0f1 100644
--- a/src/PHPCensor/Model/User.php
+++ b/src/PHPCensor/Model/User.php
@@ -1,4 +1,5 @@
setName($name);
$user->setEmail($emailAddress);
$user->setHash(password_hash($password, PASSWORD_DEFAULT));
$user->setIsAdmin(($isAdmin ? 1 : 0));
+ $user->setLanguage($language);
+ $user->setPerPage($perPage);
return $this->store->save($user);
}
/**
* Update a user.
- * @param User $user
- * @param $name
- * @param $emailAddress
- * @param null $password
- * @param null $isAdmin
- * @return \PHPCensor\Model\User
+ *
+ * @param User $user
+ * @param string $name
+ * @param string $emailAddress
+ * @param string $password
+ * @param bool $isAdmin
+ * @param string $language
+ * @param integer $perPage
+ *
+ * @return User
*/
- public function updateUser(User $user, $name, $emailAddress, $password = null, $isAdmin = null)
+ public function updateUser(User $user, $name, $emailAddress, $password = null, $isAdmin = null, $language = null, $perPage = null)
{
$user->setName($name);
$user->setEmail($emailAddress);
@@ -73,6 +84,9 @@ class UserService
$user->setIsAdmin(($isAdmin ? 1 : 0));
}
+ $user->setLanguage($language);
+ $user->setPerPage($perPage);
+
return $this->store->save($user);
}
diff --git a/src/PHPCensor/View/Project/view.phtml b/src/PHPCensor/View/Project/view.phtml
index 58071311..3483eb6d 100644
--- a/src/PHPCensor/View/Project/view.phtml
+++ b/src/PHPCensor/View/Project/view.phtml
@@ -2,6 +2,7 @@