made the options in urlExists a hashref for future expandability
This commit is contained in:
parent
480cb392eb
commit
0b6c500a16
1 changed files with 10 additions and 6 deletions
|
|
@ -411,7 +411,7 @@ sub fixUrl {
|
||||||
) {
|
) {
|
||||||
$url .= ".".$self->session->setting->get("urlExtension");
|
$url .= ".".$self->session->setting->get("urlExtension");
|
||||||
}
|
}
|
||||||
if ($self->urlExists($self->session, $url, $self->getId)) {
|
if ($self->urlExists($self->session, $url, {assetId=>$self->getId})) {
|
||||||
my @parts = split(/\./,$url);
|
my @parts = split(/\./,$url);
|
||||||
if ($parts[0] =~ /(.*)(\d+$)/) {
|
if ($parts[0] =~ /(.*)(\d+$)/) {
|
||||||
$parts[0] = $1.($2+1);
|
$parts[0] = $1.($2+1);
|
||||||
|
|
@ -1867,7 +1867,7 @@ sub update {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
=head2 urlExists ( session, url [, assetId] )
|
=head2 urlExists ( session, url [, options] )
|
||||||
|
|
||||||
Returns true if the asset URL is used within the system. This is a class method.
|
Returns true if the asset URL is used within the system. This is a class method.
|
||||||
|
|
||||||
|
|
@ -1879,7 +1879,11 @@ head3 url
|
||||||
|
|
||||||
The asset url you'd like to check for.
|
The asset url you'd like to check for.
|
||||||
|
|
||||||
head3 assetId
|
head3 options
|
||||||
|
|
||||||
|
A hash reference of optional parameters.
|
||||||
|
|
||||||
|
head4 assetId
|
||||||
|
|
||||||
Limit the search to a specific assetId to see if that url exists for that asset.
|
Limit the search to a specific assetId to see if that url exists for that asset.
|
||||||
|
|
||||||
|
|
@ -1889,12 +1893,12 @@ sub urlExists {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my $url = lc(shift);
|
my $url = lc(shift);
|
||||||
my $assetId = shift;
|
my $options = shift || {};
|
||||||
my $limit = "";
|
my $limit = "";
|
||||||
if (defined $assetId) {
|
if (defined $options->{assetId}) {
|
||||||
$limit = "and assetId<>?"
|
$limit = "and assetId<>?"
|
||||||
}
|
}
|
||||||
my ($test) = $session->db->quickArray("select count(url) from assetData where url=? $limit", [$url, $assetId]);
|
my ($test) = $session->db->quickArray("select count(url) from assetData where url=? $limit", [$url, $options->{assetId}]);
|
||||||
return $test;
|
return $test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue