11 |
column name => |
column name => |
12 |
type is 'text', |
type is 'text', |
13 |
label is 'Name of query', |
label is 'Name of query', |
14 |
distinct, |
is distinct, |
15 |
hints is 'Short name for this query', |
hints is 'Short name for this query', |
16 |
mandatory; |
is not_null; |
17 |
|
|
18 |
column sql_query => |
column sql_query => |
19 |
type is 'text', |
type is 'text', |
20 |
label is 'SQL query', |
label is 'SQL query', |
21 |
mandatory, |
is not_null, |
|
distinct, |
|
22 |
hints is 'Use this area to enter SQL query', |
hints is 'Use this area to enter SQL query', |
23 |
render as 'textarea'; |
render as 'textarea'; |
24 |
|
|
25 |
column on_database => |
column on_database => |
26 |
refers_to SQLSession::Model::Database by 'id', |
refers_to SQLSession::Model::Database by 'id', |
27 |
label is 'on database', |
label is 'on database', |
28 |
mandatory; |
is not_null; |
29 |
|
|
30 |
column note => |
column note => |
31 |
type is 'text', |
type is 'text', |
36 |
column visible => |
column visible => |
37 |
type is 'boolean', |
type is 'boolean', |
38 |
default is 1, |
default is 1, |
39 |
indexed, |
is indexed, |
40 |
since '0.0.3'; |
since '0.0.3'; |
41 |
|
|
42 |
column owner => |
column owner => |
51 |
default is defer { DateTime->now }, |
default is defer { DateTime->now }, |
52 |
filters are 'Jifty::DBI::Filter::DateTime', |
filters are 'Jifty::DBI::Filter::DateTime', |
53 |
since '0.0.6'; |
since '0.0.6'; |
54 |
|
|
55 |
|
column parent => |
56 |
|
refers_to SQLSession::Model::Query by 'id', |
57 |
|
label is 'Originator query', |
58 |
|
is indexed, |
59 |
|
since '0.0.7'; |
60 |
|
|
61 |
}; |
}; |
62 |
|
|
63 |
|
sub since { '0.0.1' } |
64 |
|
|
65 |
# Your model-specific methods go here. |
# Your model-specific methods go here. |
66 |
|
|
67 |
sub current_user_can { |
sub current_user_can { |
69 |
|
|
70 |
my ($action,$item,$name) = @_; |
my ($action,$item,$name) = @_; |
71 |
|
|
72 |
|
# warn "current_user_can $action | $item | ", $name ? $name : 'NO NAME', "\n"; |
73 |
|
|
74 |
# prevent deep recursion for next rule |
# prevent deep recursion for next rule |
75 |
if ( $action && $item && $name && |
if ( $action && $item && $action eq 'read' && $item eq 'column' ) { |
76 |
$action eq 'read' && $item eq 'column' && ( $name eq 'owner' || $name eq 'visible' ) |
# return 1 if !defined($name); # special case for my group by query -- might be security hole! |
77 |
) { |
return 1 if ( $name && $name =~ m/^(owner|visible)$/ ); |
|
return 1; |
|
78 |
} |
} |
79 |
|
|
80 |
if ( $self->visible || $self->owner == $self->current_user->id ) { |
if ( $self->visible || $self->owner == $self->current_user->id ) { |
81 |
return 1; |
return 1; |
82 |
}; |
}; |
83 |
|
|
84 |
return 1 if ( $self->visible && self->current_user->role('edit')); |
return 1 if ( $self->visible && $self->current_user->role('edit')); |
85 |
|
return 1 if ( $action eq 'create' && $self->current_user->role('edit')); |
86 |
|
|
87 |
return 1 if ( $self->current_user->is_superuser ); |
return 1 if ( $self->current_user->is_superuser ); |
88 |
|
|