File: User.pm

package info (click to toggle)
libhtml-formfu-model-dbic-perl 0.09002-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,064 kB
  • sloc: perl: 2,270; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package MySchemaRS::User;
use strict;
use warnings;

use base 'DBIx::Class::ResultSet';

sub is_name_available {
	my ($self, $name, $row_id) = @_;

	my $user = $self->find( {name => $name} );
	return 0 if $user && $row_id && $user->id != $row_id; # found user with same name, and not user on stash

	## do extra special-case testing
# 	my $name_reserved = $self->result_source->schema->resultset('NameReserved')->find( {name => $name} );
# 	return 0 if $name_reserved;

	return 0 if $name eq 'xxx';

	return 1;
}


1;