/usr/share/perl5/SyncBBDB/pilotBBDBRecMap.pm is in syncbbdb 2.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | #------------------------------------------------------------------------------
# $Date: 2001/11/04 13:17:57 $
# RCS: $Id: pilotBBDBRecMap.pm,v 1.1.1.1 2001/11/04 13:17:57 tdeweese Exp $
#------------------------------------------------------------------------------
package pilotBBDBRecMap;
use strict;
use SyncBBDB::pilotBBDBFieldMap;
sub new
{
my $type = shift;
my $self = {};
$self->{'id'} = shift;
$self->{'category'} = shift;
$self->{'name'} = shift if (scalar @_);
$self->{'mappings'} = [];
bless($self, $type);
return $self;
}
sub copy {
my $self = shift;
my $nid = shift;
my $ret = new pilotBBDBRecMap($nid || 0, $self->{'category'});
$ret->{'name'} = $self->{'name'} if (defined $self->{'name'});
foreach my $ent (@{$self->{'mappings'}}) {
push(@{$ret->{'mappings'}}, $ent->copy());
}
return $ret;
}
sub isFieldFree {
my $self = shift;
my $field = shift;
foreach my $ent (@{$self->{'mappings'}}) {
return "" if ($ent->{'pilot'} eq $field);
}
return 1;
}
sub firstFree {
my $self = shift;
my $pbbdb = shift;
my $type = shift;
my $pname = shift;
my $ret = undef;
if (($type eq "Title") || ($type eq "Note")) {
return $type if ($self->isFieldFree($type));
}
elsif ($type eq "Field") {
foreach my $i (1..5) {
if ($self->isFieldFree("Field".$i)) {
if (defined $pbbdb->{'phoneLabelsHash'}{$pname}) {
return ($type.$i, $pbbdb->{'phoneLabelsHash'}{$pname});
} else {
return ($type.$i, undef);
}
}
}
} elsif (($type eq "Custom") && (defined $pname)) {
# print ("Lables: '" .
# join("', '", keys %{$pbbdb->{'labelsHash'}}).
# "'\n");
if (defined $pbbdb->{'labelsHash'}{$pname}) {
my $num = $pbbdb->{'labelsHash'}{$pname};
my $field = $pbbdb->{'Fields'}[$num];
return $field if ($self->isFieldFree($field));
}
} elsif ($type eq "Custom") {
# Not given a name so we are just looking for an open custom field..
# regardless of what it's label is...
foreach my $i (1..4) {
return "Custom".$i if ($self->isFieldFree("Custom".$i));
}
}
return undef;
}
sub leftFree {
my $self = shift;
my $pbbdb = shift;
my $num=0;
foreach my $i (1..5) {
$num++ if ($self->isFieldFree("Field".$i));
}
return $num;
}
sub addBBDB {
my $self = shift;
my $pbbdb = shift;
my $btype = shift;
my $bname = shift;
my $pname = shift;
my $force = shift;
my $ptype;
if (defined $pbbdb->{'phoneLabelsHash'}{$pname}) {
$ptype = "Field";
} else {
$ptype = "Custom";
}
if (($ptype eq "Field") || ($force && ($btype eq "phone"))) {
my ($p,$pl) = $self->firstFree($pbbdb, "Field", $pname);
if (defined $p) {
if (defined $pl) {
push(@{$self->{'mappings'}},
new pilotBBDBFieldMap($btype, $bname, $p, $pl));
} elsif ($force) {
push(@{$self->{'mappings'}},
new pilotBBDBFieldMap($btype, $bname, $p, -1));
}
}
} else {
my $free = $self->firstFree($pbbdb, $ptype, $pname);
if (defined $free) {
push(@{$self->{'mappings'}},
new pilotBBDBFieldMap($btype, $bname, $free));
} elsif ($force) {
$free = $self->firstFree($pbbdb, $ptype);
push(@{$self->{'mappings'}},
new pilotBBDBFieldMap($btype, $bname, $free));
}
}
}
sub addMapping {
my $self = shift;
push(@{$self->{'mappings'}}, shift);
}
sub getUsedBBDBFields {
my $self = shift;
my %ret;
foreach my $ent (@{$self->{'mappings'}}) {
$ret{$ent->getBBDB()} = 1;
}
return \%ret;
}
sub removeBBDBMapping {
my $self = shift;
my $field = shift;
my @result;
foreach my $ent (@{$self->{'mappings'}}) {
next if ($ent->getBBDB() eq $field);
push(@result, $ent);
}
$self->{'mappings'} = \@result;
}
sub removePilotMapping {
my $self = shift;
my $field = shift;
my @result;
foreach my $ent (@{$self->{'mappings'}}) {
next if ($ent->getPilot() eq $field);
push(@result, $ent);
}
$self->{'mappings'} = \@result;
}
1;
|