ispman/lib/ISPMan DomainMan.pm,1.64,1.65
Joerg Delker <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/lib/ISPMan
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20906/lib/ISPMan
Modified Files:
DomainMan.pm
Log Message:
some reformating
redesigned getDomainAttribute function to return single as well as array values
some bugfixing with isDomainLocked
Index: DomainMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan/DomainMan.pm,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- DomainMan.pm 1 May 2004 23:48:00 -0000 1.64
+++ DomainMan.pm 2 May 2004 17:11:01 -0000 1.65
@@ -625,25 +625,28 @@
my $self=shift;
my $domain=shift;
- my $attribute=shift;
- my $dn=$self->makeDomainDN($domain);
- return unless $self->entryExists($dn);
-
+ my $attr=shift;
- my $entry=$self->getEntry($dn, 'objectclass=ispmanDomain', $attribute);
+ # FIXME: implement caching here
+ # load domain data
+ my $domaininfo=$self->getDomainInfo($domain);
- # call get_attr_value on ispman object.
- # This will take care of converting utf to lat
- # also it may be useful to do caching etc
- $self->{'domaininfo'}{$domain}{$attribute}=$self->get_attr_value($entry, $attribute);
- return $self->{'domaininfo'}{$domain}{$attribute};
+ # get attrbitute (don't care about undef, return "" in that case)
+ my $val=$domaininfo->{$attr}||"";
+ # return what the caller wants
+ if (ref $val eq "ARRAY") {
+ # attribute is an array, so return whole array or first element
+ return wantarray ? @{$val} : $val->[0];
+ } else {
+ return $val;
+ }
=item B<getDomainAttribute>
requires domain name , attribute name
- returns the value of the attribute for the domain.
+ returns the value(s) of the attribute for the domain.
@@ -718,37 +721,41 @@
sub getDomainInfo {
my $self=shift;
my $domain=shift;
-
+
$self->{'searchFilter'}="objectclass=ispmanDomain";
# Check if there is a session
if ($self->{'session'}) {
- if ($self->{'session'}->param("logintype") eq "reseller") {
- # A reseller should only be able to see the domains where he is marked as
- # the reseller
- $self->{'searchFilter'}=sprintf("&(objectclass=ispmanDomain)(ispmanResellerId=%s)", $self->{'session'}->param("ispmanResellerId"));
- } elsif ($self->{'session'}->param("logintype") eq "client") {
- # A client should only be able to see the domains where he is marked as
- # the client
- $self->{'searchFilter'}=sprintf("&(objectclass=ispmanDomain)(ispmanClientId=%s)", $self->{'session'}->param("ispmanClientId"));
- }
+ if ($self->{'session'}->param("logintype") eq "reseller") {
+ # A reseller should only be able to see the domains where
+ # he is marked as the reseller
+ $self->{'searchFilter'}=
+ sprintf("&(objectclass=ispmanDomain)(ispmanResellerId=%s)",
+ $self->{'session'}->param("ispmanResellerId"));
+ } elsif ($self->{'session'}->param("logintype") eq "client") {
+ # A client should only be able to see the domains where
+ # he is marked as the client
+ $self->{'searchFilter'}=
+ sprintf("&(objectclass=ispmanDomain)(ispmanClientId=%s)",
+ $self->{'session'}->param("ispmanClientId"));
+ }
}
#pass forget if you want fresh result, else you get cached result
+ # FIXME: caching
my $forget=shift;
$forget=1;
my $dn=$self->makeDomainDN($domain);
- $self->{'domaininfo'}{$domain}=$self->getEntryAsHashRef($dn, $self->{'searchFilter'});
+ $self->{'domaininfo'}{$domain}=
+ $self->getEntryAsHashRef($dn, $self->{'searchFilter'});
- #$self->{'domaininfo'}{$domain}=$self->getEntriesAsHashRef($self->getConf("ldapBaseDN"), "uid=$domain");
return $self->{'domaininfo'}{$domain};
+ # FIXME
# the rest is crap. must be removed.
# or it should be rethought.
-
-
if ($self->{'domaininfo'}{$domain}){
#if we were called with a positive value for $forget, we reget the information for this domian.
if ($forget){
@@ -1147,8 +1154,8 @@
my $self=shift;
my $domain=shift;
- my $locked=${$self->getDomainAttribute($domain, "ispmanDomainLocked")}[0]||"";
- return ($locked eq "true")? 1:0;
+ return ($self->getDomainAttribute($domain, "ispmanDomainLocked") eq "true")?
+ 1:0;
=item B<isDomainLocked>
@@ -1551,7 +1558,7 @@
my $_host;
if ($_host=$self->getDomainAttribute($domain, "ispmanDomainDefaultFileServer")){
- return @$_host[0];
+ return $_host;
} elsif ($_host=$self->getHostGroupFirstMember('fileservergroup')) {
return $_host;
} else {
@@ -1568,7 +1575,7 @@
my $_host;
if ($_host=$self->getDomainAttribute($domain, "ispmanDomainDefaultMailDropHost")){
- return @$_host[0];
+ return $_host;
} elsif ($_host=$self->getHostGroupFirstMember('mailstoregroup')) {
return $_host;
} else {
@@ -1578,19 +1585,16 @@
sub getDefaultWebHost {
- my $self=shift;
-
- my ($domain)=@_;
+ my $self=shift;
+ my ($domain)=@_;
- my $_host;
-
- if ($_host=$self->getDomainAttribute($domain, "ispmanDomainDefaultWebHost")){
- return $_host;
- }elsif ($_host=$self->getHostGroupFirstMember('httpgroup')) {
- return $self->as_arrayref($_host);
- } else {
- return 0;
- }
+ my @hosts=$self->getDomainAttribute($domain, "ispmanDomainDefaultWebHost");
+
+ unless (@hosts){
+ @hosts=$self->getHostGroupFirstMember('httpgroup');
+ }
+
+ return wantarray ? @hosts : \@hosts;
}
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click