Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 9 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
View
1 backend/bin/dbtoria.pl
@@ -1,4 +1,3 @@
-#!/usr/sepp/bin/perl-5.12.3-to
#!/usr/bin/env perl
use strict;
use warnings;
View
42 backend/lib/DbToRia/DBI/Pg.pm
@@ -55,7 +55,8 @@ Returns a list of tables and views available from the system.
sub getAllTables {
my $self = shift;
- return $self->{tableList} if $self->{tableList};
+ my $username = $self->username;
+ return $self->{tableList}{$username} if $self->{tableList}{$username};
my $dbh = $self->getDbh();
my $sth = $dbh->table_info('',$self->schema,'', 'TABLE,VIEW');
my %tables;
@@ -70,12 +71,11 @@ sub getAllTables {
type => $table->{TABLE_TYPE},
name => $table->{REMARKS} || $tableName,
readOnly => $readOnly ? $Mojo::JSON::TRUE : $Mojo::JSON::FALSE,
-# readOnly => ! $readWrite,
};
}
- $self->{tableList} = \%tables;
- use Data::Dumper; print STDERR Dumper "tables=", \%tables;
- return $self->{tableList};
+ $self->{tableList}{$username} = \%tables;
+ # use Data::Dumper; print STDERR Dumper "tables=", \%tables;
+ return $self->{tableList}{$username};
}
=head2 getFilterOpsArray()
@@ -137,9 +137,6 @@ sub getTableStructure {
my $self = shift;
my $table = shift;
-# $self->getTablePrivileges($table);
-# use Data::Dumper; print STDERR Dumper "tablePrivileges($table)=", $self->{tablePrivileges}{$table};
-
return $self->{tableStructure}{$table} if exists $self->{tableStructure}{$table};
my $dbh = $self->getDbh();
@@ -263,6 +260,35 @@ sub getDefaults {
}
+=head2 getTablePrivileged(table)
+
+Returns permission information about the table directly from he
+database.
+
+=cut
+
+sub getTablePrivileges {
+ my $self = shift;
+ my $tableId = shift;
+ my $username = $self->username;
+ if (not exists $self->{tablePrivileges}{$tableId}{$username}){
+ my $dbh = $self->getDbh();
+ my $sth = $dbh->prepare(<<'SQL');
+SELECT privilege_type
+ FROM information_schema.table_privileges
+ WHERE table_name = ? AND grantee IN ( SELECT role_name FROM information_schema.enabled_roles )
+SQL
+ $sth->execute($tableId);
+ my $row;
+ my %priv;
+ while ($row = $sth->fetchrow_hashref) {
+ $priv{$row->{privilege_type}} = 1;
+ }
+ $self->{tablePrivileges}{$tableId}{$username} = \%priv;
+ }
+ return $self->{tablePrivileges}{$tableId}{$username};
+}
+
=head2 getTableDataChunk(table,firstRow,lastRow,columns,optMap)
Returns the selected columns from the table. Using firstRow and
View
28 backend/lib/DbToRia/DBI/base.pm
@@ -232,35 +232,21 @@ sub getTableStructure {
=head2 getTablePrivileged(table)
-Returns permission information about the table directly from he
-database.
+Returns permission information about the table for the current user.
=cut
sub getTablePrivileges {
my $self = shift;
my $table = shift;
-
- return $self->{tablePrivileges}{$table} if exists $self->{tablePrivileges}{$table};
-
- my $dbh = $self->getDbh();
- my %tablePrivileges;
-
- my $sth = $dbh->prepare("SELECT privilege_type FROM information_schema.table_privileges WHERE table_name = '$table'");
- $sth->execute();
- my $row;
- while ($row = $sth->fetchrow_arrayref) {
- $tablePrivileges{$row->[0]} = 1;
- }
-# for my $engine (@{$self->metaEngines}){
-# $engine->massageTableStructure($table,$self->{tableStructure}{$table});
-# }
- $self->{tablePrivileges}{$table} = \%tablePrivileges;
- return $self->{tablePrivileges}{$table};
+ return {
+ UPDATE => 1,
+ INSERT => 1,
+ DELETE => 1,
+ SELECT => 1
+ };
}
-
-
=head2 getRecord (table,recordId)
Returns hash of data for the record matching the indicated key. Data
View
25 frontend/source/class/dbtoria/module/database/RecordEdit.js
@@ -46,7 +46,7 @@ qx.Class.define("dbtoria.module.database.RecordEdit", {
this.set({
icon : 'icon/16/apps/utilities-text-editor.png',
showMinimize : true,
- showClose : false,
+ showClose : true,
contentPaddingLeft : 20,
contentPaddingRight : 20,
contentPaddingTop : 20,
@@ -75,7 +75,7 @@ qx.Class.define("dbtoria.module.database.RecordEdit", {
this.add(this.__createNavigation(readOnly));
// this.addListener("close", function(e) {
- // this.__close();
+ // this.close();
// }, this);
this.addListener('keyup', function(e) {
@@ -85,7 +85,7 @@ qx.Class.define("dbtoria.module.database.RecordEdit", {
if (e.getKeyIdentifier() == 'Escape') {
this.cancel();
}
- });
+ },this);
},
@@ -125,9 +125,18 @@ qx.Class.define("dbtoria.module.database.RecordEdit", {
// }
// },
- // __close: function() {
- // this.addListenerOnce('saveRecord', this.__closeHandler, this);
- // this.saveRecord();
+ // close: function() {
+ // if (false) {
+ // this.base.close(arguments);
+ // }
+ // var that=this;
+ // var handler = function(arguments) {
+ // that.base(arguments);
+ // };
+ // var mbox = dbtoria.ui.dialog.MsgBox.getInstance();
+ // mbox.warn(this.tr('Unsaved data.'),
+ // this.tr('Do you really want to close the edit form and loose your changes?'),
+ // handler);
// },
__okHandler: function(e) {
@@ -192,9 +201,7 @@ qx.Class.define("dbtoria.module.database.RecordEdit", {
var btnCnl = new dbtoria.ui.form.Button(this.tr("Cancel"), "icon/16/actions/dialog-cancel.png",
this.tr('Abort editing without saving'));
- btnCnl.addListener("execute", function(e) {
- this.cancel();
- }, this);
+ btnCnl.addListener("execute", this.cancel, this);
var btnApp = new dbtoria.ui.form.Button(this.tr("Apply"), "icon/16/actions/dialog-apply.png",
this.tr('Save form content to backend'));
2 setup
@@ -1 +1 @@
-Subproject commit 207b38c13115c072d94112e62b4b3aa3fa015739
+Subproject commit ba281fde193e7911698b8bdedd8c32d5754d4d69

No commit comments for this range

Something went wrong with that request. Please try again.