Skip to content

Commit 9fc0fa8

Browse files
committed
Removed get_unapproved_driver/printer due to removal of approval tables
1 parent 7f771e5 commit 9fc0fa8

2 files changed

Lines changed: 15 additions & 149 deletions

File tree

lib/Foomatic/DB.pm

Lines changed: 15 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -168,58 +168,6 @@ sub driver_approved_in_sql_db {
168168
}
169169
}
170170

171-
sub get_unapproved_printers_from_sql_db {
172-
my ($this) = @_;
173-
if ($this->{'dbh'} && $this->{'dbtype'} eq 'mysql') {
174-
# Get list of unapproved printers
175-
my $unapprovedprinterquerystr =
176-
"SELECT id FROM printer_approval " .
177-
"WHERE (approved IS NULL OR approved=0 OR approved='' OR " .
178-
"(rejected IS NOT NULL AND rejected!=0 AND rejected!='') OR " .
179-
"(showentry IS NOT NULL AND showentry!='' AND showentry!=1 AND " .
180-
"showentry>CAST(NOW() AS DATE))) " .
181-
"ORDER BY id;";
182-
my $sth = $this->{'dbh'}->prepare($unapprovedprinterquerystr);
183-
if ($sth->execute()) {
184-
my @upl = ();
185-
while (my @row = $sth->fetchrow_array) {
186-
push(@upl, $row[0]);
187-
}
188-
return @upl;
189-
} else {
190-
return ();
191-
}
192-
} else {
193-
return ();
194-
}
195-
}
196-
197-
sub get_unapproved_drivers_from_sql_db {
198-
my ($this) = @_;
199-
if ($this->{'dbh'} && $this->{'dbtype'} eq 'mysql') {
200-
# Get list of unapproved drivers
201-
my $unapproveddriverquerystr =
202-
"SELECT id FROM driver_approval " .
203-
"WHERE (approved IS NULL OR approved=0 OR approved='' OR " .
204-
"(rejected IS NOT NULL AND rejected!=0 AND rejected!='') OR " .
205-
"(showentry IS NOT NULL AND showentry!='' AND showentry!=1 AND " .
206-
"showentry>CAST(NOW() AS DATE))) " .
207-
"ORDER BY id;";
208-
my $sth = $this->{'dbh'}->prepare($unapproveddriverquerystr);
209-
if ($sth->execute()) {
210-
my @udl = ();
211-
while (my @row = $sth->fetchrow_array) {
212-
push(@udl, $row[0]);
213-
}
214-
return @udl;
215-
} else {
216-
return ();
217-
}
218-
} else {
219-
return ();
220-
}
221-
}
222-
223171
sub get_translation_from_sql_db {
224172
my ($this, $table, $pkeys, $fields) = @_;
225173
if ($this->{'dbh'} &&
@@ -337,8 +285,6 @@ sub get_overview_from_sql_db {
337285
my ($this, $cupsppds, $speedmode) = @_;
338286
$speedmode = 0 if !$speedmode;
339287
if ($this->{'dbh'}) {
340-
my @upl = $this->get_unapproved_printers_from_sql_db();
341-
my @udl = $this->get_unapproved_drivers_from_sql_db();
342288
my $printerquerystr = "SELECT printer.id, " .
343289
"printer.make, printer.model, printer.functionality, " .
344290
"printer.unverified, printer.default_driver, " .
@@ -395,14 +341,10 @@ sub get_overview_from_sql_db {
395341
"driver_printer_assoc.driver_id;";
396342
$sthd = $this->{'dbh'}->prepare($driverquerystr);
397343
$sthd->execute();
398-
do {
399-
@drow = $sthd->fetchrow_array;
400-
} while (@udl && @drow && member($drow[1], @udl));
344+
@drow = $sthd->fetchrow_array;
401345
}
402346
my @prow;
403-
do {
404-
@prow = $sthp->fetchrow_array;
405-
} while (@upl && @prow && member($prow[0], @upl));
347+
@prow = $sthp->fetchrow_array;
406348
my $overview = [];
407349
while ( 1 ) {
408350
last if !@prow && !@drow;
@@ -475,9 +417,7 @@ sub get_overview_from_sql_db {
475417
if defined($prow[25]) && ($prow[25] ne "");
476418

477419
# Current row in printer list treated, advance
478-
do {
479-
@prow = $sthp->fetchrow_array;
480-
} while (@upl && @prow && member($prow[0], @upl));
420+
@prow = $sthp->fetchrow_array;
481421
}
482422

483423
# Fill make and model fields if there was no appropriate
@@ -607,9 +547,7 @@ sub get_overview_from_sql_db {
607547
}
608548

609549
# Current row in printer/driver list treated, advance
610-
do {
611-
@drow = $sthd->fetchrow_array;
612-
} while (@udl && @drow && member($drow[1], @udl));
550+
@drow = $sthd->fetchrow_array;
613551
}
614552
} else {
615553
# There is no driver for this printer. Skip this printer
@@ -632,7 +570,6 @@ sub get_driverlist_from_sql_db {
632570
my ($this) = @_;
633571
if ($this->{'dbh'}) {
634572
if (!defined($this->{"names-source/driver"})) {
635-
my @udl = $this->get_unapproved_drivers_from_sql_db();
636573
# Get driver list
637574
my $driverquerystr =
638575
"SELECT id " .
@@ -641,8 +578,7 @@ sub get_driverlist_from_sql_db {
641578
$sth->execute();
642579
$this->{"names-source/driver"} = [];
643580
while (my @row = $sth->fetchrow_array) {
644-
push(@{$this->{"names-source/driver"}}, $row[0]) if
645-
(!@udl || !member($row[0], @udl));
581+
push(@{$this->{"names-source/driver"}}, $row[0]);
646582
}
647583
}
648584
}
@@ -653,7 +589,6 @@ sub get_printerlist_from_sql_db {
653589
my ($this) = @_;
654590
if ($this->{'dbh'}) {
655591
if (!defined($this->{"names-source/printer"})) {
656-
my @upl = $this->get_unapproved_printers_from_sql_db();
657592
# Get printer list
658593
my $printerquerystr =
659594
"SELECT id " .
@@ -662,8 +597,7 @@ sub get_printerlist_from_sql_db {
662597
$sth->execute();
663598
$this->{"names-source/printer"} = [];
664599
while (my @row = $sth->fetchrow_array) {
665-
push(@{$this->{"names-source/printer"}}, $row[0]) if
666-
(!@upl || !member($row[0], @upl));
600+
push(@{$this->{"names-source/printer"}}, $row[0]);
667601
}
668602
}
669603
}
@@ -1092,30 +1026,10 @@ sub make_exists_in_sql_db {
10921026
# Check whether a printer entry for this make exists in the database
10931027
if ($this->{'dbh'}) {
10941028
my $printerquerystr;
1095-
my @upl = $this->get_unapproved_printers_from_sql_db();
1096-
if (@upl) {
1097-
$printerquerystr =
1098-
"SELECT id " .
1099-
"FROM printer LEFT JOIN printer_approval " .
1100-
"ON printer.id=printer_approval.id " .
1101-
"WHERE printer.make=\"$make\" AND " .
1102-
"(printer_approval.id IS NULL OR " .
1103-
"(printer_approval.approved IS NOT NULL AND " .
1104-
"printer_approval.approved!=0 AND " .
1105-
"printer_approval.approved!='' AND " .
1106-
"(printer_approval.rejected IS NULL OR " .
1107-
"printer_approval.rejected=0 OR " .
1108-
"printer_approval.rejected='') AND " .
1109-
"(printer_approval.showentry IS NULL OR " .
1110-
"printer_approval.showentry='' OR " .
1111-
"printer_approval.showentry=1 OR " .
1112-
"printer_approval.showentry<=CAST(NOW() AS DATE))));";
1113-
} else {
1114-
$printerquerystr =
1115-
"SELECT id " .
1116-
"FROM printer " .
1117-
"WHERE make=\"$make\";";
1118-
}
1029+
$printerquerystr =
1030+
"SELECT id " .
1031+
"FROM printer " .
1032+
"WHERE make=\"$make\";";
11191033
my $sth = $this->{'dbh'}->prepare($printerquerystr);
11201034
$sth->execute();
11211035
my @prow = $sth->fetchrow_array;
@@ -1171,7 +1085,6 @@ sub get_printers_for_driver_from_sql_db {
11711085
my @printerlist = ();
11721086
if ($this->{'dbh'}) {
11731087
return () if !$this->driver_approved_in_sql_db($drv);
1174-
my @upl = $this->get_unapproved_printers_from_sql_db();
11751088
# Get printer IDs of printer/driver combos with the given driver
11761089
my $querystr =
11771090
"SELECT printer_id " .
@@ -1180,8 +1093,7 @@ sub get_printers_for_driver_from_sql_db {
11801093
my $sth = $this->{'dbh'}->prepare($querystr);
11811094
$sth->execute();
11821095
while (my @row = $sth->fetchrow_array) {
1183-
push(@printerlist, $row[0]) if
1184-
(!@upl || !member($row[0], @upl));
1096+
push(@printerlist, $row[0]);
11851097
}
11861098
}
11871099
return @printerlist;
@@ -1192,7 +1104,6 @@ sub get_drivers_for_printer_from_sql_db {
11921104
my @driverlist = ();
11931105
if ($this->{'dbh'}) {
11941106
return () if !$this->printer_approved_in_sql_db($poid);
1195-
my @udl = $this->get_unapproved_drivers_from_sql_db();
11961107
# Get drivers of printer/driver combos with the given printer ID
11971108
my $querystr =
11981109
"SELECT driver_id " .
@@ -1202,8 +1113,7 @@ sub get_drivers_for_printer_from_sql_db {
12021113
$sth->execute();
12031114

12041115
while (my @row = $sth->fetchrow_array) {
1205-
push(@driverlist, $row[0]) if
1206-
(!@udl || !member($row[0], @udl));
1116+
push(@driverlist, $row[0]);
12071117
}
12081118
}
12091119
return @driverlist;
@@ -1556,28 +1466,8 @@ sub get_makes_from_sql_db {
15561466
if ($this->{'dbh'}) {
15571467
# Get list of manufacturers
15581468
my $querystr;
1559-
my @upl = $this->get_unapproved_printers_from_sql_db();
1560-
if (@upl) {
1561-
$querystr =
1562-
"SELECT make " .
1563-
"FROM printer LEFT JOIN printer_approval " .
1564-
"ON printer.id=printer_approval.id " .
1565-
"WHERE (printer_approval.id IS NULL OR " .
1566-
"(printer_approval.approved IS NOT NULL AND " .
1567-
"printer_approval.approved!=0 AND " .
1568-
"printer_approval.approved!='' AND " .
1569-
"(printer_approval.rejected IS NULL OR " .
1570-
"printer_approval.rejected=0 OR " .
1571-
"printer_approval.rejected='') AND " .
1572-
"(printer_approval.showentry IS NULL OR " .
1573-
"printer_approval.showentry='' OR " .
1574-
"printer_approval.showentry=1 OR " .
1575-
"printer_approval.showentry<=CAST(NOW() AS DATE)))) " .
1576-
"GROUP BY make ORDER BY make;";
1577-
} else {
1578-
$querystr =
1579-
"SELECT make FROM printer GROUP BY make ORDER BY make;";
1580-
}
1469+
$querystr =
1470+
"SELECT make FROM printer GROUP BY make ORDER BY make;";
15811471
my $sth = $this->{'dbh'}->prepare($querystr);
15821472
$sth->execute();
15831473
while (my @row = $sth->fetchrow_array) {
@@ -1591,15 +1481,13 @@ sub get_models_by_make_from_sql_db {
15911481
my ($this, $wantmake) = @_;
15921482
my @models;
15931483
if ($this->{'dbh'}) {
1594-
my @upl = $this->get_unapproved_printers_from_sql_db();
15951484
# Get list of models for a given manufacturer
15961485
my $querystr =
15971486
"SELECT id, model FROM printer WHERE make=\"$wantmake\";";
15981487
my $sth = $this->{'dbh'}->prepare($querystr);
15991488
$sth->execute();
16001489
while (my @row = $sth->fetchrow_array) {
1601-
push(@models, $row[1]) if
1602-
(!@upl || !member($row[0], @upl));
1490+
push(@models, $row[1]);
16031491
}
16041492
}
16051493
return @models;

lib/Foomatic/filters/phonebook.pm

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -466,34 +466,12 @@ my $schemaPhonebook =
466466
"description" text,
467467
CONSTRAINT "driver_support_contact_translation_ibfk_1" FOREIGN KEY ("driver_id", "url", "level") REFERENCES "driver_support_contact" ("driver_id", "url", "level") ON DELETE CASCADE
468468
)',
469-
'driver_approval' => 'CREATE TABLE "driver_approval" (
470-
"id" varchar(50) NOT NULL,
471-
"contributor" varchar(40) DEFAULT NULL,
472-
"submitted" datetime DEFAULT NULL,
473-
"showentry" datetime DEFAULT NULL,
474-
"approved" datetime DEFAULT NULL,
475-
"rejected" datetime DEFAULT NULL,
476-
"approver" varchar(40) DEFAULT NULL,
477-
"comment" text,
478-
CONSTRAINT "driver_approval_ibfk_1" FOREIGN KEY ("id") REFERENCES "driver" ("id") ON DELETE CASCADE
479-
)',
480469
'driver_dependency' => 'CREATE TABLE "driver_dependency" (
481470
"driver_id" varchar(50) NOT NULL,
482471
"required_driver" varchar(50) NOT NULL,
483472
"version" varchar(50) DEFAULT NULL,
484473
CONSTRAINT "driver_dependency_ibfk_1" FOREIGN KEY ("driver_id") REFERENCES "driver" ("id") ON DELETE CASCADE
485474
)',
486-
'printer_approval' => 'CREATE TABLE "printer_approval" (
487-
"id" varchar(50) NOT NULL,
488-
"contributor" varchar(40) DEFAULT NULL,
489-
"submitted" datetime DEFAULT NULL,
490-
"showentry" datetime DEFAULT NULL,
491-
"approved" datetime DEFAULT NULL,
492-
"rejected" datetime DEFAULT NULL,
493-
"approver" varchar(40) DEFAULT NULL,
494-
"comment" text,
495-
CONSTRAINT "printer_approval_ibfk_1" FOREIGN KEY ("id") REFERENCES "printer" ("id") ON DELETE CASCADE
496-
)',
497475
'driver_package' => 'CREATE TABLE "driver_package" (
498476
"driver_id" varchar(50) NOT NULL,
499477
"scope" varchar(255) NOT NULL,

0 commit comments

Comments
 (0)