aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-10 03:44:45 -0700
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-10 03:44:45 -0700
commitadc5f8c578f70f10b779fb6b8b029fe3cdd62e36 (patch)
tree77cf3e073733bcf715b9ae462094f732d321f228
parent4d7ce1e4d1b060cecc0e3aad5cb24ddbbb651a5a (diff)
downloadbugs-adc5f8c578f70f10b779fb6b8b029fe3cdd62e36.tar
bugs-adc5f8c578f70f10b779fb6b8b029fe3cdd62e36.tar.gz
bugs-adc5f8c578f70f10b779fb6b8b029fe3cdd62e36.tar.bz2
bugs-adc5f8c578f70f10b779fb6b8b029fe3cdd62e36.tar.xz
bugs-adc5f8c578f70f10b779fb6b8b029fe3cdd62e36.zip
Bug 577805: Make chart_fields into an accessor in Search.pm
r=mkanat, a=mkanat (module owner)
-rw-r--r--Bugzilla/Search.pm52
1 files changed, 29 insertions, 23 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index daec751d2..ab6c38a1e 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -434,6 +434,22 @@ sub REPORT_COLUMNS {
# Internal Accessors #
######################
+sub _chart_fields {
+ my ($self) = @_;
+
+ if (!$self->{chart_fields}) {
+ my $chart_fields = Bugzilla->fields({ by_name => 1 });
+
+ if (!Bugzilla->user->is_timetracker) {
+ foreach my $tt_field (TIMETRACKING_FIELDS) {
+ delete $chart_fields->{$tt_field};
+ }
+ }
+ $self->{chart_fields} = $chart_fields;
+ }
+ return $self->{chart_fields};
+}
+
sub _multi_select_fields {
my ($self) = @_;
$self->{multi_select_fields} ||= Bugzilla->fields({
@@ -753,7 +769,7 @@ sub init {
}
$bug_creation_clause = "(" . join(' AND ', @l) . ")";
} else {
- push(@actlist, get_field_id($f));
+ push(@actlist, $self->_chart_fields->{$f}->id);
}
}
@@ -956,15 +972,6 @@ sub init {
# chart to merge the ON sections of each.
# $suppstring = String which is pasted into query containing all table names
- # get a list of field names to verify the user-submitted chart fields against
- my $chart_fields = Bugzilla->fields({ by_name => 1 });
-
- if (!$user->is_timetracker) {
- foreach my $tt_field (TIMETRACKING_FIELDS) {
- delete $chart_fields->{$tt_field};
- }
- }
-
my ($sequence, $chartid);
$row = 0;
for ($chart=-1 ;
@@ -992,12 +999,12 @@ sub init {
# chart -1 is generated by other code above, not from the user-
# submitted form, so we'll blindly accept any values in chart -1
- if (!$chart_fields->{$field} and $chart != -1) {
+ if (!$self->_chart_fields->{$field} and $chart != -1) {
ThrowCodeError("invalid_field_name", { field => $field });
}
# This is either from the internal chart (in which case we
- # already know about it), or it was in $chart_fields, so it is
+ # already know about it), or it was in _chart_fields, so it is
# a valid field name, which means that it's ok.
trick_taint($field);
my $quoted = $dbh->quote($value);
@@ -1017,7 +1024,6 @@ sub init {
having => \@having,
group_by => \@groupby,
fields => \@fields,
- chart_fields => $chart_fields,
);
# This should add a "term" selement to %search_args.
$self->do_search_function(\%search_args);
@@ -2177,7 +2183,7 @@ sub _owner_idle_time_greater_less {
push(@$joins, $comments_join);
my $act_table = "activity_$table";
- my $assigned_fieldid = get_field_id('assigned_to');
+ my $assigned_fieldid = $self->_chart_fields->{'assigned_to'}->id;
# XXX Why are we joining using $assignedto_fieldid here? It shouldn't
# matter when or if the assignee changed.
@@ -2377,13 +2383,13 @@ sub _nowords {
sub _changedbefore_changedafter {
my ($self, $args) = @_;
- my ($chart_id, $joins, $field, $operator, $value, $chart_fields) =
- @$args{qw(chart_id joins field operator value chart_fields)};
+ my ($chart_id, $joins, $field, $operator, $value) =
+ @$args{qw(chart_id joins field operator value)};
my $dbh = Bugzilla->dbh;
my $sql_operator = ($operator =~ /before/) ? '<' : '>';
my $table = "act_$chart_id";
- my $field_object = $chart_fields->{$field}
+ my $field_object = $self->_chart_fields->{$field}
|| ThrowCodeError("invalid_field_name", { field => $field });
my $field_id = $field_object->id;
@@ -2398,12 +2404,12 @@ sub _changedbefore_changedafter {
sub _changedfrom_changedto {
my ($self, $args) = @_;
- my ($chart_id, $joins, $field, $operator, $quoted, $chart_fields) =
- @$args{qw(chart_id joins field operator quoted chart_fields)};
+ my ($chart_id, $joins, $field, $operator, $quoted) =
+ @$args{qw(chart_id joins field operator quoted)};
my $column = ($operator =~ /from/) ? 'removed' : 'added';
my $table = "act_$chart_id";
- my $field_object = $chart_fields->{$field}
+ my $field_object = $self->_chart_fields->{$field}
|| ThrowCodeError("invalid_field_name", { field => $field });
my $field_id = $field_object->id;
push(@$joins,
@@ -2416,11 +2422,11 @@ sub _changedfrom_changedto {
sub _changedby {
my ($self, $args) = @_;
- my ($chart_id, $joins, $field, $operator, $value, $chart_fields) =
- @$args{qw(chart_id joins field operator value chart_fields)};
+ my ($chart_id, $joins, $field, $operator, $value) =
+ @$args{qw(chart_id joins field operator value)};
my $table = "act_$chart_id";
- my $field_object = $chart_fields->{$field}
+ my $field_object = $self->_chart_fields->{$field}
|| ThrowCodeError("invalid_field_name", { field => $field });
my $field_id = $field_object->id;
my $user_id = login_to_id($value, THROW_ERROR);
>271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
package install2; # $Id$

use diagnostics;
use strict;
use vars qw($o $version);

#-######################################################################################
#- misc imports
#-######################################################################################
use steps;
use common;
use install_any qw(:all);
use install_steps;
use install_any;
use lang;
use keyboard;
use mouse;
use fsedit;
use devices;
use partition_table qw(:types);
use modules;
use detect_devices;
use run_program;
use any;
use log;
use fs;
#-$::corporate=1;


#-#######################################################################################
#-$O
#-the big struct which contain, well everything (globals + the interactive methods ...)
#-if you want to do a kickstart file, you just have to add all the required fields (see for example
#-the variable $default)
#-#######################################################################################
$o = $::o = {
#    bootloader => { linear => 0, message => 1, timeout => 5, restricted => 0 },
#-    packages   => [ qw() ],
    partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0 }, #-, readonly => 0 },
    authentication => { md5 => 1, shadow => 1 },
    locale         => { lang => 'en_US' },
#-    isUpgrade    => 0,
    toRemove     => [],
    toSave       => [],
#-    simple_themes => 1,

    timezone => {
#-                   timezone => "Europe/Paris",
#-                   UTC      => 1,
                },
#-    superuser => { password => 'a', shell => '/bin/bash', realname => 'God' },
#-    user => { name => 'foo', password => 'bar', home => '/home/foo', shell => '/bin/bash', realname => 'really, it is foo' },

#-    keyboard => 'de',
#-    display => "192.168.1.19:1",
    steps        => \%steps::installSteps,
    orderedSteps => \@steps::orderedInstallSteps,

#- for the list of fields available for user and superuser, see @etc_pass_fields in install_steps.pm
#-    intf => { eth0 => { DEVICE => "eth0", IPADDR => '1.2.3.4', NETMASK => '255.255.255.128' } },

    netc => {},
    intf => {},
             
#-step : the current one
#-prefix
#-mouse
#-keyboard
#-netc
#-methods
#-packages compss
#-printer haveone entry(cf printer.pm)

};


sub installStepsCall {
    my ($o, $auto, $fun, @args) = @_;
    $fun = "install_steps::$fun" if $auto;
    $o->$fun(@args);
}

#-######################################################################################
#- Steps Functions
#- each step function are called with two arguments : clicked(because if you are a
#- beginner you can force the the step) and the entered number
#-######################################################################################

#------------------------------------------------------------------------------
sub selectLanguage {
    my ($_clicked, $ent_number, $auto) = @_;

    installStepsCall($o, $auto, 'selectLanguage', $ent_number == 1);
}

sub acceptLicense {
    my ($_clicked, $_ent_number, $auto) = @_;
    installStepsCall($o, $auto, 'acceptLicense') if !$o->{useless_thing_accepted};
}

#------------------------------------------------------------------------------
sub selectMouse {
    my ($clicked, $ent_number, $auto) = @_;

    require pkgs;
    my ($first_time) = $ent_number == 1;

    installStepsCall($o, $auto, 'selectMouse', !$first_time || $clicked);

    addToBeDone { mouse::write($o, $o->{mouse}) if !$o->{isUpgrade} || $clicked } 'installPackages';
}

#------------------------------------------------------------------------------
sub setupSCSI {
    my ($clicked, $_ent_number, $auto) = @_;

    if (!$o->{blank} && !$::testing && !$::uml_install) {
	-d '/lib/modules/' . c::kernel_version() ||
	  -s modules::cz_file() or die \N("Can't access kernel modules corresponding to your kernel (file %s is missing), this generally means your boot floppy in not in sync with the Installation medium (please create a newer boot floppy)", modules::cz_file());
    }

    installStepsCall($o, $auto, 'setupSCSI', $clicked);
}

#------------------------------------------------------------------------------
sub selectKeyboard {
    my ($clicked, $_ent_number, $auto) = @_;

    installStepsCall($o, $auto, 'selectKeyboard', $clicked);

    #- read keyboard ASAP (so that summary displays ok)
    addToBeDone {	
	$o->{keyboard}{unsafe} or return;
	if (my $keyboard = keyboard::read()) {
	    $o->{keyboard} = $keyboard;
	}
    } 'formatPartitions';
}

#------------------------------------------------------------------------------
sub selectInstallClass {
    my ($clicked, $_ent_number, $auto) = @_;

    installStepsCall($o, $auto, 'selectInstallClass', $clicked);

    if ($o->{isUpgrade}) {
	$o->{keepConfiguration} and @{$o->{orderedSteps}} = grep { !/selectMouse|selectKeyboard|miscellaneous|setRootPassword|addUser|configureNetwork|installUpdates|summary|configureServices|configureX/ } @{$o->{orderedSteps}};
    }
}

#------------------------------------------------------------------------------
sub doPartitionDisks {
    my ($_clicked, $_ent_number, $auto) = @_;
    $o->{steps}{formatPartitions}{done} = 0;
    installStepsCall($o, $auto, 'doPartitionDisksBefore');
    installStepsCall($o, $auto, 'doPartitionDisks');
    installStepsCall($o, $auto, 'doPartitionDisksAfter');
}

sub formatPartitions {
    my ($_clicked, $_ent_number, $auto) = @_;

    $o->{steps}{choosePackages}{done} = 0;
    installStepsCall($o, $auto, 'choosePartitionsToFormat', $o->{fstab}) if !$o->{isUpgrade};
    my $want_root_formated = fsedit::get_root($o->{fstab})->{toFormat};
    if ($want_root_formated) {
	foreach ('/usr') {
	    my $part = fsedit::mntpoint2part($_, $o->{fstab}) or next;
	    $part->{toFormat} or die \N("You must also format %s", $_);
	}
    }
    installStepsCall($o, $auto, 'formatMountPartitions', $o->{fstab}) if !$::testing;

    if ($want_root_formated) {
	#- we formatted /, ensure /var/lib/rpm is cleaned otherwise bad things can happen
	#- (especially when /var is *not* formatted)
	eval { rm_rf("$o->{prefix}/var/lib/rpm") };
    }

    mkdir "$o->{prefix}/$_", 0755 foreach 
      qw(dev etc etc/profile.d etc/rpm etc/sysconfig etc/sysconfig/console 
	etc/sysconfig/network-scripts etc/sysconfig/console/consolefonts 
	etc/sysconfig/console/consoletrans
	home mnt tmp var var/tmp var/lib var/lib/rpm var/lib/urpmi);
    mkdir "$o->{prefix}/$_", 0700 foreach qw(root root/tmp root/drakx);

    devices::make("$o->{prefix}/dev/null");
    chmod 0666, "$o->{prefix}/dev/null";

    common::screenshot_dir__and_move();

    any::rotate_logs($o->{prefix});

    if (any { $_->{usb_media_type} && any { $_->{mntpoint} } partition_table::get_normal_parts($_) } @{$o->{all_hds}{hds}}) {
	log::l("we use a usb-storage based drive, so keep it as a normal scsi_hostadapter");
    } else {
	log::l("we don't need usb-storage for booting system, rely on hotplug");
	#- when usb-storage is in scsi_hostadapter, 
	#- hotplug + scsimon do not load sd_mod/sr_mod when needed
	#- (eg: when plugging a usb key)
	modules::remove_probeall('scsi_hostadapter', 'usb-storage');
    }

    require raid;
    raid::prepare_prefixed($o->{all_hds}{raids}, $o->{prefix});

    #- needed by lilo
    if (my @vgs = map { $_->{VG_name} } @{$o->{all_hds}{lvms}}) {
	cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs;
    }
}

#------------------------------------------------------------------------------
sub choosePackages {
    my ($_clicked, $ent_number, $auto) = @_;
    require pkgs;

    #- always setPackages as it may have to copy hdlist files and synthesis files.
    installStepsCall($o, $auto, 'setPackages', $o->{isUpgrade} && $ent_number == 1);
    installStepsCall($o, $auto, 'choosePackages', $o->{packages}, $o->{compssUsers}, $ent_number == 1);
    log::l("compssUsersChoice's: ", join(" ", grep { $o->{compssUsersChoice}{$_} } keys %{$o->{compssUsersChoice}}));

    #- check pre-condition where base backage has to be selected.
    pkgs::packageByName($o->{packages}, 'basesystem')->flag_available or die "basesystem package not selected";

    #- check if there are package that need installation.
    $o->{steps}{installPackages}{done} = 0 if $o->{steps}{installPackages}{done} && pkgs::packagesToInstall($o->{packages}) > 0;
}

#------------------------------------------------------------------------------
sub installPackages {
    my ($_clicked, $ent_number, $auto) = @_;

    installStepsCall($o, $auto, 'readBootloaderConfigBeforeInstall') if $ent_number == 1;

    installStepsCall($o, $auto, 'beforeInstallPackages');
    installStepsCall($o, $auto, 'installPackages');
    installStepsCall($o, $auto, 'afterInstallPackages');
}
#------------------------------------------------------------------------------
sub miscellaneous {
    my ($clicked, $_ent_number, $auto) = @_;

    installStepsCall($o, $auto, 'miscellaneousBefore', $clicked);
    installStepsCall($o, $auto, 'miscellaneous', $clicked);
    installStepsCall($o, $auto, 'miscellaneousAfter', $clicked);
}

#------------------------------------------------------------------------------
sub summary {
    my ($_clicked, $ent_number, $auto) = @_;
    installStepsCall($o, $auto, 'summaryBefore');
    installStepsCall($o, $auto, 'summary', $ent_number == 1);
    installStepsCall($o, $auto, 'summaryAfter');
}
#------------------------------------------------------------------------------
sub configureNetwork {
    my ($_clicked, $_ent_number, $auto) = @_;
    #- get current configuration of network device.
    require network::network;
    eval { network::network::read_all_conf($o->{prefix}, $o->{netc}, $o->{intf}) };
    installStepsCall($o, $auto, 'configureNetwork') if !$o->{isUpgrade};
}