diff --git a/admin_autoupdate.php b/admin_autoupdate.php
index 4c034a62..ddcea413 100644
--- a/admin_autoupdate.php
+++ b/admin_autoupdate.php
@@ -25,7 +25,7 @@ use Froxlor\Http\HttpClient;
use Froxlor\UI\Panel\UI;
// define update-uri
-define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $version);
+define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . \Froxlor\Froxlor::VERSION);
define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip");
define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256");
@@ -66,7 +66,7 @@ if ($page == 'overview') {
// add the branding so debian guys are not gettings confused
// about their version-number
- $version_label = $_version . $branding;
+ $version_label = $_version . \Froxlor\Froxlor::BRANDING;
$version_link = $_link;
$message_addinfo = $_message;
@@ -78,7 +78,7 @@ if ($page == 'overview') {
'page' => 'error',
'errno' => 3
));
- } elseif (\Froxlor\Froxlor::versionCompare2($version, $_version) == -1) {
+ } elseif (\Froxlor\Froxlor::versionCompare2(\Froxlor\Froxlor::VERSION, $_version) == -1) {
// there is a newer version - yay
$isnewerversion = 1;
} else {
@@ -89,7 +89,7 @@ if ($page == 'overview') {
// anzeige über version-status mit ggfls. formular
// zum update schritt #1 -> download
if ($isnewerversion == 1) {
- $text = 'There is a newer version available. Update to version ' . $_version . ' now?
(Your current version is: ' . $version . ')';
+ $text = 'There is a newer version available. Update to version ' . $_version . ' now?
(Your current version is: ' . \Froxlor\Froxlor::VERSION . ')';
$upd_formfield = [
'updates' => [
diff --git a/admin_settings.php b/admin_settings.php
index e20ac722..86c69eeb 100644
--- a/admin_settings.php
+++ b/admin_settings.php
@@ -273,7 +273,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
- header('Content-disposition: attachment; filename=Froxlor_settings-' . $version . '-' . $dbversion . '_' . date('d.m.Y') . '.json');
+ header('Content-disposition: attachment; filename=Froxlor_settings-' . \Froxlor\Froxlor::VERSION . '-' . \Froxlor\Froxlor::DBVERSION . '_' . date('d.m.Y') . '.json');
header('Content-type: application/json');
echo $json_export;
exit();
diff --git a/admin_updates.php b/admin_updates.php
index 850cae80..9d3e66e1 100644
--- a/admin_updates.php
+++ b/admin_updates.php
@@ -80,11 +80,11 @@ if ($page == 'overview') {
if (empty($current_db_version)) {
$current_db_version = "0";
}
- $new_version = $version;
- $new_db_version = $dbversion;
+ $new_version = \Froxlor\Froxlor::VERSION;
+ $new_db_version = \Froxlor\Froxlor::DBVERSION;
$ui_text = $lng['update']['update_information']['part_a'];
- if ($version != $current_version) {
+ if (\Froxlor\Froxlor::VERSION != $current_version) {
$ui_text = str_replace('%curversion', $current_version, $ui_text);
$ui_text = str_replace('%newversion', $new_version, $ui_text);
} else {
diff --git a/error_report.php b/error_report.php
index 2f186bad..f11437b8 100644
--- a/error_report.php
+++ b/error_report.php
@@ -54,8 +54,8 @@ if (!empty($errid)) {
$mail_body .= "Trace:\n" . trim($_error['trace']) . "\n\n";
$mail_body .= "-------------------------------------------------------------\n\n";
$mail_body .= "User-Area: " . AREA . "\n";
- $mail_body .= "Froxlor-version: " . $version . "\n";
- $mail_body .= "DB-version: " . $dbversion . "\n\n";
+ $mail_body .= "Froxlor-version: " . \Froxlor\Froxlor::VERSION . "\n";
+ $mail_body .= "DB-version: " . \Froxlor\Froxlor::DBVERSION . "\n\n";
$mail_body .= "End of report";
$mail_html = nl2br($mail_body);
diff --git a/install/froxlor.sql b/install/froxlor.sql
index 17c692a0..59ecdf65 100644
--- a/install/froxlor.sql
+++ b/install/froxlor.sql
@@ -1053,3 +1053,13 @@ CREATE TABLE `api_keys` (
KEY customerid (customerid)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
+DROP TABLE IF EXISTS `panel_usercolumns`;
+CREATE TABLE `panel_usercolumns` (
+ `adminid` int(11) NOT NULL default '0',
+ `customerid` int(11) NOT NULL default '0',
+ `section` varchar(500) NOT NULL default '',
+ `columns` text NOT NULL,
+ UNIQUE KEY `user_section` (`adminid`, `customerid`, `section`),
+ KEY adminid (adminid),
+ KEY customerid (customerid)
+) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
diff --git a/install/updates/froxlor/0.11/update_0.11.inc.php b/install/updates/froxlor/0.11/update_0.11.inc.php
index 98247b63..0abcd805 100644
--- a/install/updates/froxlor/0.11/update_0.11.inc.php
+++ b/install/updates/froxlor/0.11/update_0.11.inc.php
@@ -38,6 +38,21 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
Settings::Set('panel.default_theme', 'Froxlor');
lastStepStatus(0);
+ showUpdateStep("Creating new tables");
+ Database::query("DROP TABLE IF EXISTS `panel_usercolumns`;");
+ $sql = "CREATE TABLE `panel_usercolumns` (
+ `adminid` int(11) NOT NULL default '0',
+ `customerid` int(11) NOT NULL default '0',
+ `section` varchar(500) NOT NULL default '',
+ `columns` text NOT NULL,
+ UNIQUE KEY `user_section` (`adminid`, `customerid`, `section`),
+ KEY adminid (adminid),
+ KEY customerid (customerid)
+ ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;";
+ Database::query($sql);
+ lastStepStatus(0);
+
+
showUpdateStep("Cleaning up old files");
$to_clean = array(
"templates/Sparkle",
diff --git a/lib/Froxlor/Ajax/GlobalSearch.php b/lib/Froxlor/Ajax/GlobalSearch.php
index 4bfafda8..b079b562 100644
--- a/lib/Froxlor/Ajax/GlobalSearch.php
+++ b/lib/Froxlor/Ajax/GlobalSearch.php
@@ -77,10 +77,17 @@ class GlobalSearch
$processed = [];
$stparts = explode(" ", $searchtext);
+ $module = "";
foreach ($stparts as $searchtext) {
+
$searchtext = trim($searchtext);
+ if (preg_match('/^([a-z]+):$/', $searchtext, $matches)) {
+ $module = $matches[1];
+ continue;
+ }
+
// admin
if (isset($userinfo['adminsession']) && $userinfo['adminsession'] == 1) {
@@ -262,6 +269,12 @@ class GlobalSearch
];
}
+ // module specific search
+ if (!empty($module)) {
+ $modSearch = $toSearch[$module] ?? [];
+ $toSearch = [$module => $modSearch];
+ }
+
foreach ($toSearch as $entity => $edata) {
$collection = (new Collection($edata['class'], $userinfo))
diff --git a/lib/Froxlor/UI/Listing.php b/lib/Froxlor/UI/Listing.php
index 654ca5a8..3257d9a5 100644
--- a/lib/Froxlor/UI/Listing.php
+++ b/lib/Froxlor/UI/Listing.php
@@ -2,8 +2,10 @@
namespace Froxlor\UI;
+use Froxlor\Database\Database;
use Froxlor\UI\Panel\UI;
-use Exception;
+use InvalidArgumentException;
+use Froxlor\CurrentUser;
/**
* This file is part of the Froxlor project.
@@ -38,7 +40,8 @@ class Listing
'empty_msg' => $tabellisting['empty_msg'] ?? null,
'total_entries' => ($collection->getPagination() instanceof Pagination) ? $collection->getPagination()->getEntries() : 0,
'is_search' => ($collection->getPagination() instanceof Pagination) ? $collection->getPagination()->isSearchResult() : false,
- 'self_overview' => $tabellisting['self_overview'] ?? []
+ 'self_overview' => $tabellisting['self_overview'] ?? [],
+ 'available_columns' => self::getAvailableColumnsForListing($tabellisting)
];
}
@@ -110,7 +113,7 @@ class Listing
} elseif ($field) {
$rows[$row]['td'][$col]['data'] = $data;
} else {
- throw new Exception('The visible column "' . $visible_column . '" has neither a "callback" nor a "field" set.');
+ throw new InvalidArgumentException('The visible column "' . $visible_column . '" has neither a "callback" nor a "field" set.');
}
// Set class for table-row if defined
@@ -173,12 +176,75 @@ class Listing
return $actions;
}
+ private static function getAvailableColumnsForListing(array $tabellisting): array
+ {
+ $result = [];
+ if (isset($tabellisting['columns'])) {
+ foreach ($tabellisting['columns'] as $column => $coldata) {
+ $result[$column] = $coldata['label'];
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * store column listing selection of user to database
+ * the selection array should look like this:
+ * [
+ * 'section_name' => [
+ * 'column_name',
+ * 'column_name',
+ * 'column_name'
+ * ]
+ * ]
+ *
+ * @param array $tablelisting
+ *
+ * @return bool
+ */
+ public static function storeColumnListingForUser(array $tabellisting): bool
+ {
+ $section = array_key_first($tabellisting);
+ if (empty($section) || !is_array($tabellisting[$section]) || empty($tabellisting[$section])) {
+ throw new InvalidArgumentException("Invalid selection array for " . __METHOD__);
+ }
+ $userid = 'customerid';
+ if (CurrentUser::isAdmin()) {
+ $userid = 'adminid';
+ }
+ // delete possible existing entry
+ $del_stmt = Database::prepare("
+ DELETE FROM `" . TABLE_PANEL_USERCOLUMNS . "` WHERE `" . $userid . "` = :uid AND `section` = :section
+ ");
+ Database::pexecute($del_stmt, ['uid' => CurrentUser::getData($userid), 'section' => $section]);
+ // add new entry
+ $ins_stmt = Database::prepare("
+ INSERT INTO `" . TABLE_PANEL_USERCOLUMNS . "` SET
+ `" . $userid . "` = :uid,
+ `section` = :section,
+ `columns` = :cols
+ ");
+ Database::pexecute($ins_stmt, [
+ 'uid' => CurrentUser::getData($userid),
+ 'section' => $section,
+ 'cols' => json_encode($tabellisting[$section])
+ ]);
+ return true;
+ }
+
public static function getVisibleColumnsForListing(string $listing, array $default_columns): array
{
- // Here would come the logic that pulls this from the DB ...
- // alternatively, it takes the $default_columns if no entry is
- // defined in the DB
-
+ $userid = 'customerid';
+ if (CurrentUser::isAdmin()) {
+ $userid = 'adminid';
+ }
+ $sel_stmt = Database::prepare("
+ SELECT `columns` FROM `" . TABLE_PANEL_USERCOLUMNS . "` WHERE `" . $userid . "` = :uid AND `section` = :section
+ ");
+ $columns_json = Database::pexecute_first($sel_stmt, ['uid' => CurrentUser::getData($userid), 'section' => $listing]);
+ if ($columns_json && isset($columns_json['columns'])) {
+ return json_decode($columns_json['columns'], true);
+ }
return $default_columns;
}
diff --git a/lib/tablelisting/admin/tablelisting.admins.php b/lib/tablelisting/admin/tablelisting.admins.php
index f07a1d65..73964613 100644
--- a/lib/tablelisting/admin/tablelisting.admins.php
+++ b/lib/tablelisting/admin/tablelisting.admins.php
@@ -30,7 +30,7 @@ return [
'self_overview' => ['section' => 'admins', 'page' => 'admins'],
'columns' => [
'adminid' => [
- 'label' => '#',
+ 'label' => 'ID',
'field' => 'adminid',
'sortable' => true,
],
diff --git a/lib/tables.inc.php b/lib/tables.inc.php
index 13c0d2d9..d653b9e7 100644
--- a/lib/tables.inc.php
+++ b/lib/tables.inc.php
@@ -50,5 +50,4 @@ const TABLE_DOMAIN_DNS = 'domain_dns_entries';
const TABLE_PANEL_FPMDAEMONS = 'panel_fpmdaemons';
const TABLE_PANEL_PLANS = 'panel_plans';
const TABLE_API_KEYS = 'api_keys';
-
-require dirname(__FILE__) . '/version.inc.php';
+const TABLE_PANEL_USERCOLUMNS = 'panel_usercolumns';
diff --git a/lib/version.inc.php b/lib/version.inc.php
deleted file mode 100644
index 8766d185..00000000
--- a/lib/version.inc.php
+++ /dev/null
@@ -1,25 +0,0 @@
- (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package System
- *
- */
-
-// Main version variable
-$version = \Froxlor\Froxlor::VERSION;
-
-// Database version (YYYYMMDDC where C is a daily counter)
-$dbversion = \Froxlor\Froxlor::DBVERSION;
-
-// Distribution branding-tag (used for Debian etc.)
-$branding = \Froxlor\Froxlor::BRANDING;