Skip to content

Commit

Permalink
feat(user): added new flag if user data should be visible (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Mar 27, 2020
1 parent fc26eef commit 3410ab4
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
phpMyFAQ 3.1.0-dev
phpMyFAQ 3.1.0-alpha
Codename "Poseidon"

CHANGELOG

This is a log of major user-visible changes in each phpMyFAQ release.

Version 3.1.0-dev
Version 3.1.0-alpha
- changed PHP requirement to PHP 7.3+ (Thorsten)
- added support for Elasticsearch v6+ (Thorsten)
- removed REST API v1 (Thorsten)
Expand Down
2 changes: 2 additions & 0 deletions phpmyfaq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@
//
if (($action === 'faq') || ($action === 'show') || ($action === 'main')) {
$sidebarTemplate = 'sidebar-tagcloud.html';
} else {
$sidebarTemplate = '';
}

//
Expand Down
9 changes: 9 additions & 0 deletions phpmyfaq/setup/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,15 @@
// UPDATES FROM 3.1.0-alpha
//

if (version_compare($version, '3.1.0-alpha', '<=')) {
// Add isVisible flag for user data
if ('sqlite3' === $DB['type']) {
$query[] = 'ALTER TABLE ' . $prefix . 'faquserdata ADD COLUMN is_visible INT(1) DEFAULT 0';
} else {
$query[] = 'ALTER TABLE '.$prefix.'faquserdata ADD is_visible INTEGER DEFAULT 0';
}
}

// Always the last step: Update version number
if (version_compare($version, System::getVersion(), '<')) {
$faqConfig->update(['main.currentApiVersion' => System::getApiVersion()]);
Expand Down
3 changes: 2 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ class Mysqli extends Database implements Driver
user_id INT(11) NOT NULL,
last_modified VARCHAR(14) NULL,
display_name VARCHAR(128) NULL,
email VARCHAR(128) NULL)',
email VARCHAR(128) NULL,
is_visible INT(1) NULL DEFAULT 0)',

'faquserlogin' => 'CREATE TABLE %sfaquserlogin (
login VARCHAR(128) NOT NULL,
Expand Down
3 changes: 2 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ class Pgsql extends Database implements Driver
user_id SERIAL NOT NULL,
last_modified VARCHAR(14) NULL,
display_name VARCHAR(128) NULL,
email VARCHAR(128) NULL)',
email VARCHAR(128) NULL,
is_visible SMALLINT NULL DEFAULT 0)',

'faquserlogin' => 'CREATE TABLE %sfaquserlogin (
login VARCHAR(128) NOT NULL,
Expand Down
3 changes: 2 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ class Sqlite3 extends Database implements Driver
user_id INTEGER NOT NULL,
last_modified VARCHAR(14) NULL,
display_name VARCHAR(128) NULL,
email VARCHAR(128) NULL)',
email VARCHAR(128) NULL,
is_visible INT(1) NULL DEFAULT 0)',

'faquserlogin' => 'CREATE TABLE %sfaquserlogin (
login VARCHAR(128) NOT NULL,
Expand Down
3 changes: 2 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ class Sqlsrv extends Database implements Driver
user_id INTEGER NOT NULL,
last_modified VARCHAR(14) NULL,
display_name VARCHAR(128) NULL,
email VARCHAR(128) NULL)',
email VARCHAR(128) NULL,
is_visible INTEGER NULL DEFAULT 0)',

'faquserlogin' => 'CREATE TABLE %sfaquserlogin (
login VARCHAR(128) NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class System
/**
* Pre-release version.
*/
private const VERSION_PRE_RELEASE = 'dev';
private const VERSION_PRE_RELEASE = 'alpha';

/**
* API version.
Expand Down
11 changes: 7 additions & 4 deletions phpmyfaq/src/phpMyFAQ/User/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ public function load($userId)
SELECT
last_modified,
display_name,
email
email,
is_visible
FROM
%sfaquserdata
WHERE
Expand Down Expand Up @@ -221,13 +222,15 @@ public function save()
SET
last_modified = '%s',
display_name = '%s',
email = '%s'
email = '%s',
is_visible = %d
WHERE
user_id = %d",
Database::getTablePrefix(),
date('YmdHis', $_SERVER['REQUEST_TIME']),
$this->config->getDb()->escape($this->data['display_name']),
$this->config->getDb()->escape($this->data['email']),
$this->data['is_visible'],
$this->userId
);

Expand Down Expand Up @@ -259,9 +262,9 @@ public function add($userId)
"
INSERT INTO
%sfaquserdata
(user_id, last_modified)
(user_id, last_modified, is_visible)
VALUES
(%d, '%s')",
(%d, '%s', 1)",
Database::getTablePrefix(),
$this->userId,
date('YmdHis', $_SERVER['REQUEST_TIME'])
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
if [ "x${PMF_VERSION}" = "x" ]; then
PMF_VERSION="3.0.2"
PMF_VERSION="3.1.0-alpha"
fi

0 comments on commit 3410ab4

Please sign in to comment.