Skip to content

Commit

Permalink
index itemsperpage. globaladmin
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Feb 11, 2020
1 parent 94de45e commit 19fa8c9
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 40 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "oneplace/oneplace-core",
"description": "onePlace Core Application",
"type": "project",
"version": "1.0.19",
"version": "1.0.20",
"license": "BSD-3-Clause",
"keywords": [
"laminas",
Expand Down Expand Up @@ -31,7 +31,7 @@
"laminas/laminas-session": "^2.9.1",
"laminas/laminas-paginator": "^2.8",
"laminas/laminas-mail": "^2.10",
"oneplace/oneplace-user": "^1.0.12"
"oneplace/oneplace-user": "^1.0.13"
},
"autoload": {
"psr-4": {
Expand Down
25 changes: 12 additions & 13 deletions module/Application/data/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ INSERT INTO `settings` (`settings_key`, `settings_value`) VALUES
('noreply-pw', 'EMAILACCOUNTPASS'),
('noreply-server', 'SMTPHOSTNAME');

INSERT INTO `permission` (`permission_key`, `module`, `label`, `nav_label`, `nav_href`, `show_in_menu`) VALUES
('index', 'Application\\Controller\\IndexController', 'Home', 'Home', '/', 0),
('update', 'Application\\Controller\\IndexController', 'Updates', '', '', 0),
('addtheme', 'Application\\Controller\\UploadController', 'Upload Theme', '', '/application/addtheme', 0),
('themes', 'Application\\Controller\\IndexController', 'Theme Selection', '', '/application/themes', 0),
('filepond', 'Application\\Controller\\UploadController', 'Upload Featured Image', '', '', 0),
('uppy', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0),
('togglemediapub', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0),
('updateuppysort', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0),
('quicksearch', 'Application\\Controller\\IndexController', 'Quick Search', '', '', 0),
('updatefieldsort', 'Application\\Controller\\IndexController', 'Update Form Field Sorting', '', '', 0),
('selectbool', 'Application\\Controller\\IndexController', 'Select Yes/No', '', '', 0),
('checkforupdates', 'Application\\Controller\\IndexController', 'Check for Updates', '', '', 0);
INSERT INTO `permission` (`permission_key`, `module`, `label`, `nav_label`, `nav_href`, `show_in_menu`, `needs_globaladmin`) VALUES
('index', 'Application\\Controller\\IndexController', 'Home', 'Home', '/', 0, 0),
('addtheme', 'Application\\Controller\\UploadController', 'Upload Theme', '', '/application/addtheme', 0, 1),
('themes', 'Application\\Controller\\IndexController', 'Theme Selection', '', '/application/themes', 0, 0),
('filepond', 'Application\\Controller\\UploadController', 'Upload Featured Image', '', '', 0, 0),
('uppy', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0, 0),
('togglemediapub', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0, 0),
('updateuppysort', 'Application\\Controller\\UploadController', 'Gallery Upload', '', '', 0, 0),
('quicksearch', 'Application\\Controller\\IndexController', 'Quick Search', '', '', 0, 0),
('updatefieldsort', 'Application\\Controller\\IndexController', 'Update Form Field Sorting', '', '', 0, 0),
('selectbool', 'Application\\Controller\\IndexController', 'Select Yes/No', '', '', 0, 0),
('checkforupdates', 'Application\\Controller\\IndexController', 'Check for Updates', '', '', 0, 1);

--
-- Default Widgets
Expand Down
11 changes: 10 additions & 1 deletion module/Application/src/Controller/CoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,17 @@ public function getFormTabs() {
protected function getPermissions() {
$aPermissionsByModules = [];

$aWhere = [];
$bIsGlobalAdmin = false;
if(CoreController::$oSession->oUser->hasPermission('globaladmin','OnePlace-Core')) {
$bIsGlobalAdmin = true;
}
if(! $bIsGlobalAdmin) {
$aWhere['needs_globaladmin'] = 0;
}

# Load Permissions from database
$oPermsFromDB = CoreController::$aCoreTables['permission']->select();
$oPermsFromDB = CoreController::$aCoreTables['permission']->select($aWhere);
foreach($oPermsFromDB as $oPerm) {
$sModule = str_replace(['\\'],['-'],$oPerm->module);
# Order by module
Expand Down
4 changes: 3 additions & 1 deletion module/Application/src/Controller/CoreEntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public function generateIndexView($sKey) {
$iPage = ($iPage < 1) ? 1 : $iPage;
if($oPaginator) {
$oPaginator->setCurrentPageNumber($iPage);
$oPaginator->setItemCountPerPage(3);
$iItemsPerPage = (CoreEntityController::$oSession->oUser->getSetting($sKey.'-index-items-per-page'))
? CoreEntityController::$oSession->oUser->getSetting($sKey.'-index-items-per-page') : 10;
$oPaginator->setItemCountPerPage($iItemsPerPage);
}

# Log Performance in DB
Expand Down
6 changes: 6 additions & 0 deletions module/Application/src/Controller/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ public function indexAction() {
'permission'=>'settheme',
'module'=>'OnePlace\User\Controller\UserController',
]);
# Globaladmin
$oUserPermTbl->insert([
'user_idfs'=>$iAdminUserID,
'permission'=>'globaladmin',
'module'=>'OnePlace\Core',
]);

/**
* Add Basic Views / Columns / Fields
Expand Down
1 change: 1 addition & 0 deletions module/Application/src/Model/CoreEntityTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Application\Model;

use Application\Controller\CoreController;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Db\TableGateway\TableGateway;
use Laminas\Db\Sql\Select;
Expand Down
10 changes: 9 additions & 1 deletion module/Application/src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Module {
*
* @since 1.0.0
*/
const VERSION = '1.0.19';
const VERSION = '1.0.20';

public function getConfig() : array {
return include __DIR__ . '/../config/module.config.php';
Expand Down Expand Up @@ -72,6 +72,14 @@ public function getControllerConfig() : array
$container
);
},
Controller\UploadController::class => function($container) {
$oDbAdapter = $container->get(AdapterInterface::class);
return new Controller\UploadController(
$oDbAdapter,
false,
$container
);
},
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@

$sUrl = '';
try {
$sModRoute = explode('-',$sModName)[1];
$sModRoute = substr($sModName,strlen($sVendor.'-'));
echo 'try:'.$sModRoute.'-setup';
$sUrl = $this->url($sModRoute.'-setup');
} catch(\RuntimeException $e) {

Expand Down
29 changes: 20 additions & 9 deletions module/Application/view/application/upload/addtheme.phtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>Upload new theme</h2>

<form action="" method="POST" enctype="multipart/form-data">
<div class="form-row">
<label>Theme .zip File</label>
<input type="file" name="zip_file" class="Form-control" />
</div>
<div class="form-row">
<!-- Submit -->
<button type="submit" class="btn btn-primary">Install Theme</button>
<div class="card">
<div class="card-header">
<h2 class="card-title">
<?=$this->translate('Upload new theme')?>
</h2>
</div>
<div class="card-body">
<div class="form-row">
<label>Theme .zip File</label>
<input type="file" name="zip_file" class="Form-control" />
</div>
</div>
<div class="card-footer">
<div class="form-row">
<!-- Submit -->
<button type="submit" class="btn btn-primary">
<?=$this->translate('Install Theme')?>
</button>
</div>
</div>
</div>
</form>
</div>
Expand Down
56 changes: 44 additions & 12 deletions module/Application/view/partial/indexpager.phtml
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
<?php
use Application\Controller\CoreEntityController;

/**
* Print Pagination Control
*/
echo $this->paginationControl(
$iItemsPerPage = (CoreEntityController::$oSession->oUser->getSetting($this->sRoute.'-index-items-per-page'))
? CoreEntityController::$oSession->oUser->getSetting($this->sRoute.'-index-items-per-page') : 10;
?>
<div class="row">
<div class="col-md-1">
<select class="form-control plc-index-list-itemsperpage">
<option<?=($iItemsPerPage == 10) ? ' selected="selected"' : ''?>>10</option>
<option<?=($iItemsPerPage == 25) ? ' selected="selected"' : ''?>>25</option>
<option<?=($iItemsPerPage == 50) ? ' selected="selected"' : ''?>>50</option>
<option<?=($iItemsPerPage == 100) ? ' selected="selected"' : ''?>>100</option>
<option<?=($iItemsPerPage == 250) ? ' selected="selected"' : ''?>>250</option>
</select>
</div>
<div class="col-md-3">
<?php

/**
* Print Pagination Control
*/
echo $this->paginationControl(
// The paginator object:
$this->aItems,
// The scrolling style:
'sliding',
// The partial to use to render the control:
'partial/paginator',
// The route to link to when a user clicks a control link:
['route' => $this->sRoute]
);
$this->aItems,
// The scrolling style:
'sliding',
// The partial to use to render the control:
'partial/paginator',
// The route to link to when a user clicks a control link:
['route' => $this->sRoute]
);

?>
</div>
</div>
<script>
$(function() {
$('.plc-index-list-itemsperpage').on('change',function() {
var iNewVal = $(this).val();
var oData = {setting_name:'<?=$this->sRoute?>-index-items-per-page',setting_value:iNewVal};
$.post('/user/updatesetting',oData,function() {
// act in backgrond
});
});
})
</script>

0 comments on commit 19fa8c9

Please sign in to comment.