view release on metacpan or search on metacpan
lib/ARSObject.pm view on Meta::CPAN
636465666768697071727374757677787980818283,
-metaid
=> {}
# Commonly used fields with common names and value translation
,
-metadn
=> {}
# {fieldId | fieldName =>
# {fieldName=>'name',FieldId=>id
# ,strIn=>sub(self,form,{field},$_=val){}
# ,strOut=>sub(self,form,{field},$_=val){}
# },...}
,
-maxRetrieve
=> 0
# ARS::ars_GetListEntry(maxRetrieve)
,
-entryNo
=>
undef
# Logical number of entry inserted
,
-strFields
=> 1
# Translate fields data using 'strIn'/'strOut'/'-meta'?
# 1 - 'enumLimits', 2 - 'fieldLbvl' before 'enumLimits'
,
-cmd
=>
''
# Command running, for err messages, script local $s->{-cmd}
,
-die
=>
undef
# Error die/warn, 'Carp' or 'CGI::Carp...'
# ,-diemsg => undef #
,
-warn
=>
undef
# , see set() and connect() below
# ,-warnmsg => undef #
,
-cpcon
=>
undef
# Translation to console codepage sub{}(self, args) -> translated
,
-echo
=>0
# Echo printout switch
,
-dbi
=>
undef
# DBI object, by dbiconnect()
,
-dbiconnect
=>
undef
#
,
-cgi
=>
undef
# CGI object, by cgi()
,
-smtp
=>
undef
lib/ARSObject.pm view on Meta::CPAN
192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
my
$v
=$^O eq
'MSWin32'
?
scalar
(Win32::GetFullPathName($0)) : $0;
$s
->{-vfbase} =
$v
=~/^(.+?[\\\/])[^\\\/]+$/ ? $1 .
$a
{-vfbase} :
$a
{-vfbase};
}
}
$s
}
sub
ineval {
# is inside eval{}?
# for PerlEx and mod_perl
# see CGI::Carp::ineval comments and errors
return
$^S
if
!(
$ENV
{GATEWAY_INTERFACE}
&& (
$ENV
{GATEWAY_INTERFACE} =~/PerlEx/))
&& !
$ENV
{MOD_PERL};
my
(
$i
,
@a
) =(1);
while
(
@a
=
caller
(
$i
)) {
return
(0)
if
$a
[0] =~/^(?:PerlEx::|Apache::Perl|Apache::Registry|Apache::ROOT)/i;
return
(1)
if
$a
[3] eq
'(eval)'
;
$i
+=1;
}
$^S
}
# error message form ??? use ???
# (err/var, command, operation, function, args)
sub
efmt {
efmt1(
@_
)
}
sub
efmt0 {
my
(
$s
,
$e
,
$c
,
$o
,
$f
,
@a
) =
@_
;
cpcon(
$s
,
join
(
': '
,(
$c
?
$c
: ())
,(
$f
?
$f
.
'('
.
join
(
','
,
map
{
$s
->dsquot(
$_
)}
@a
) .
')'
: ())
,(
$o
?
$o
: ())
)
.(
$e
&& (
$e
eq
'$!'
) && $^E ? (
' -> '
.$! .
' / '
.$^E) : (
' -> '
.(
$e
||
'unknown error'
)))
)
}
sub
efmt1 {
my
(
$s
,
$e
,
$c
,
$o
,
$f
,
@a
) =
@_
;
cpcon(
$s
,
join
(
' # '
,(
$e
&& (
$e
eq
'$!'
) && $^E ? ($! .
' / '
.$^E) : (
$e
||
'unknown error'
))
,(
$o
?
$o
: ())
,(
$f
?
$f
.
'('
.
join
(
','
,
map
{
$s
->dsquot(
$_
)}
@a
) .
')'
: ())
,(
$c
?
$c
: ())
)
)
}
sub
strquot {
# Quote and Escape string enclosing in ''
my
$v
=
$_
[1];
# (string) -> escaped
lib/ARSObject.pm view on Meta::CPAN
848849850851852853854855856857858859860861862863864865866867868$s
->set(
@_
);
$s
->set(
-die
=>
'Carp'
)
if
!
$s
->{-
die
};
local
$s
->{-cmd} =
"connect()"
;
return
(
$s
)
if
$s
->{-ctrl};
$s
->cpcon(
"connect()\n"
)
if
$s
->{-echo};
return
(
$s
)
if
$s
->{-ctrl} && ARS::ars_VerifyUser(
$s
->{-ctrl});
$s
->{-ctrl} =ARS::ars_Login(
$s
->{-srv},
$s
->{-usr},
$s
->{-pswd},
$s
->{-lang}
,
''
# , join('-', ($ENV{COMPUTERNAME} ||$ENV{HOSTNAME} ||eval('use Sys::Hostname;hostname') ||'localhost'), getlogin() || $> || '', $$, $^T, time())
, 0, 0)
||
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_Login'
,
map
{
$_
=>
$s
->{
$_
}}
qw(-srv -usr -lang)
)));
$s
->{-ctrl} && ARS::ars_SetSessionConfiguration(
$s
->{-ctrl},
&ARS::AR_SESS_OVERRIDE_PREV_IP
, 1);
$s
->arsmeta();
$s
}
sub
disconnect {
# Disconnect data servers
my
$s
=
shift
;
$s
->{-ctrl} &&
eval
{ars_Logoff(
$s
->{-ctrl})};
$s
->{-ctrl}=
undef
;
lib/ARSObject.pm view on Meta::CPAN
895896897898899900901902903904905906907908909910911912913914915
$s
->vfload(
'-meta'
);
$vfs
=
$s
->{-schgen} >2
? 0
: ([
stat
$s
->vfname(
'-meta'
)]->[9] ||0);
}
else
{
$s
->{-meta} ={};
}
foreach
my
$f
(
ref
(
$s
->{-schgen}) ? @{
$s
->{-schgen}} : @{
$s
->{-schema}}){
my
$fa
=ARS::ars_GetSchema(
$s
->{-ctrl},
$f
);
!
$fa
&&
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetSchema'
,
$f
)));
if
(
$vfs
&&
$s
->{-meta}->{
$f
}) {
#print $s->strtime($fa->{timestamp}),'/',$s->strtime($vfs), "\n", $s->cpcon($s->dsdump($fa)), "\n"; exit(0);
next
if
$s
->{-meta}->{
$f
} &&
$s
->{-meta}->{
$f
}->{timestamp}
? ((
$s
->{-meta}->{
$f
}->{timestamp}||0) >=(
$fa
->{timestamp}||0))
&& (
$vfs
>=(
$fa
->{timestamp}||0))
:
$vfs
>=(
$fa
->{timestamp}||0 +60*60);
}
$vfu
=1;
$s
->{-meta}->{
$f
} ={};
# {} || $fa
$s
->{-meta}->{
$f
}->{-fields} ={};
lib/ARSObject.pm view on Meta::CPAN
918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956# $s->{-meta}->{$f}->{getListFields} =$fa->{getListFields};
# $s->{-meta}->{$f}->{sortList} =$fa->{sortList};
my
(
$cyr
,
$vli
,
$vll
) =1 &&
$s
->{-lang} && (
$s
->{-lang} =~/^(?:ru)/i);
if
(!
$cyr
&&
$s
->{-lang}) {
my
$vlc
;
my
$ull
=
$s
->{-lang} =~/^([A-Za-z]+)/ ? $1 :
$s
->{-lang};
my
$ulc
=
$s
->{-lang} =~/^([A-Za-z_]+)/ ? $1 :
$s
->{-lang};
my
$i
=0;
foreach
my
$vi
(ars_GetListVUI(
$s
->{-ctrl},
$f
, 0)) {
my
$vw
=ars_GetVUI(
$s
->{-ctrl},
$f
,
$vi
);
# language[_territory[.codeset]][@modifier]
# en_US.ISO8859-15@euro
$vli
=
$i
if
!
defined
(
$vli
) && !
$vw
->{locale};
$vlc
=
$i
if
!
defined
(
$vlc
) &&
$vw
->{locale} && (
$vw
->{locale} =~/^\Q
$ulc
\E/);
$vll
=
$i
if
!
defined
(
$vll
) &&
$vw
->{locale} && (
$vw
->{locale} =~/^\Q
$ull
\E/);
last
if
defined
(
$vli
) &&
defined
(
$vlc
) &&
defined
(
$vll
);
$i
++
}
$vll
=
$vlc
if
defined
(
$vlc
);
}
my
$ix
={
map
{
$_
->{unique}
&& (
scalar
(@{
$_
->{fieldIds}}) ==1)
? (
$_
->{fieldIds}->[0] => 1)
: ()} @{
$fa
->{indexList}}};
my
%ff
=ARS::ars_GetFieldTable(
$s
->{-ctrl},
$f
);
!
%ff
&&
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetFieldTable'
,
$f
)));
foreach
my
$ff
(
sort
keys
%ff
) {
my
$fm
=ARS::ars_GetField(
$s
->{-ctrl},
$f
,
$ff
{
$ff
})
||
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetField'
,
$f
,
$ff
)));
# 'fieldId', 'fieldName', 'dataType'
next
if
!
$fm
->{dataType}
|| (
$fm
->{dataType} =~/^(trim|control|table|column|page)/);
next
if
!
$s
->{-schfdo} &&
$fm
->{option} && (
$fm
->{option} == 4);
# AR_FIELD_OPTION_DISPLAY
$s
->{-meta}->{
$f
}->{-fields}->{
$ff
} =
$fm
;
$s
->{-meta}->{
$f
}->{-fields}->{
$ff
}->{indexUnique} =
$fm
->{fieldId}
if
$ix
->{
$fm
->{fieldId}}
|| (
$fm
->{fieldId} eq
'1'
);
# || '179'?
if
(
$fm
->{displayInstanceList}->{dInstanceList}
) {
lib/ARSObject.pm view on Meta::CPAN
1332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
};
$s
->{
'-meta-sql'
}->{
$tn
}->{-cols}->{
$tc
} =
$tch
;
$s
->{
'-meta-sql'
}->{
$tn
}->{-fields}->{
$ff
} =
$tc
;
$s
->{
'-meta-sql'
}->{
$tn
}->{-ids}->{
$ffh
->{fieldId}} =
$tc
if
$ffh
->{fieldId};
}
$tc
}
sub
ars_errstr {
# Last ARS error
$ARS::ars_errstr
}
sub
schema {
# Schema by form name
# (schema) -> {schema descr}
# () -> {schemaName=>{descr}}
$_
[1]
?
$_
[0]->{-meta}->{
ref
(
$_
[1]) ?
$_
[1]->{schemaName} :
$_
[1]}
:
$_
[0]->{-meta};
lib/ARSObject.pm view on Meta::CPAN
165616571658165916601661166216631664166516661667166816691670167116721673167416751676
if
$x
}
my
$q
=
$s
->_qsubst(
''
,
$a
{-qual} ||
$a
{-query} ||
$a
{-where},
$f
);
$s
->{-cmd} .=
": subst(-from=>'$f'"
.(
@$fl
?
',-fields=>'
.
join
(
', '
,
map
{
ref
(
$_
) ?
"'"
.
$_
->{fieldId} .
"'("
.
$_
->{columnWidth} .
")"
:
"'$_'"
}
@$fl
) :
''
)
.(
$q
?
",-where=>$q"
:
''
)
.(
@fs
?
',-order=>'
.
join
(
', '
,
map
{
"'$_'"
}
@fs
) :
''
)
.
")"
if
0;
$q
=ARS::ars_LoadQualifier(
$s
->{-ctrl},
$f
,
$q
);
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd})))
if
!
$q
;
$s
->{-cmd} .=
": qual"
.
$s
->dsquot(ARS::ars_perl_qualifier(
$s
->{-ctrl},
$q
))
if
0;
$s
->cpcon(
join
(
";\n"
,
split
/\):\s/,
$s
->{-cmd})),
"\n"
if
exists
(
$a
{-echo}) ?
$a
{-echo} :
$s
->{-echo};
if
(
$c
&&
$a
{-fields} && !
ref
(
$a
{-fields}->[0])) {
my
$id
;
local
$_
;
lib/ARSObject.pm view on Meta::CPAN
1681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
,
@fs
)) {
if
(!
ref
(
$e
)) {
$_
=
$id
=
$e
}
elsif
(!
defined
(
eval
{
&$c
(
$s
,
$f
,
$_
=
$id
, entryOut(
$s
,
$f
,
$e
))}) && $@) {
last
if
$@ =~/^
last
[\r\n]*$/;
next
if
$@ =~/^
next
[\r\n]*$/;
return
(&{
$s
->{-
die
}}(
$s
->efmt($@,
$s
->{-cmd},
'eval(-for)'
)));
}
}
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
'undef'
,
'ars_GetListEntryWithFields'
)))
if
!
defined
(
$id
) &&
$ARS::ars_errstr
;
return
(
$s
);
}
elsif
(
$c
) {
my
$i
=
undef
;
local
$_
=
''
;
foreach
my
$e
(ARS::ars_GetListEntry(
$s
->{-ctrl},
$f
,
$q
,
$a
{-limit} ||
$a
{-max} ||
$s
->{-maxRetrieve} ||0
,
$a
{-first} ||
$a
{-start} ||0
,
$fl
,
@fs
)) {
lib/ARSObject.pm view on Meta::CPAN
171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
if
(!
defined
(
eval
{
&$c
(
$s
,
$f
,
$_
,
$a
{-fetch}
?
$s
->entry(
-from
=>
$f
,
-id
=>
$_
,
ref
(
$a
{-fetch}) ? (
-fields
=>
$a
{-fetch}) : ())
: ())}) && $@) {
last
if
$@ =~/^
last
[\r\n]*$/;
next
if
$@ =~/^
next
[\r\n]*$/;
return
(&{
$s
->{-
die
}}(
$s
->efmt($@,
$s
->{-cmd},
'eval(-for)'
)));
}
}
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetListEntry'
)))
if
!
defined
(
$i
) &&
$ARS::ars_errstr
;
return
(
$s
)
}
elsif
(
$a
{-fields} && !
ref
(
$a
{-fields}->[0])) {
my
@r
=ARS::ars_GetListEntryWithFields(
$s
->{-ctrl},
$f
,
$q
,
$a
{-limit} ||
$a
{-max} ||
$s
->{-maxRetrieve} ||0
,
$a
{-first} ||
$a
{-start} ||0
,
$fl
,
@fs
);
if
(
@r
) {
my
@rr
;
for
(
my
$i
=0;
$i
<
$#r
;
$i
+=2) {
push
@rr
, entryOut(
$s
,
$f
,
$r
[
$i
+1])
}
return
(
@rr
)
}
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetListEntryWithFields'
)))
if
$ARS::ars_errstr
;
return
(())
}
else
{
my
@r
=ARS::ars_GetListEntry(
$s
->{-ctrl},
$f
,
$q
,
$a
{-limit} ||
$a
{-max} ||
$s
->{-maxRetrieve} ||0
,
$a
{-first} ||
$a
{-start} ||0
,
$fl
,
@fs
);
if
(
@r
) {
my
@rr
;
lib/ARSObject.pm view on Meta::CPAN
1761176217631764176517661767176817691770177117721773177417751776177717781779178017811782
push
@rr
,
$s
->entry(
-from
=>
$f
,
-id
=>
$r
[
$i
]
,
ref
(
$a
{-fetch}) ? (
-fields
=>
$a
{-fetch}) : ())
}
}
else
{
for
(
my
$i
=0;
$i
<
$#r
;
$i
+=2) {
push
@rr
,
$r
[
$i
] }
}
return
(
@rr
)
}
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'ars_GetListEntry'
)))
if
$ARS::ars_errstr
;
return
(())
}
}
sub
_qsubst {
# query condition string substitutions
# (''|char, expr string, form) -> translated
my
(
$s
,
$c
,
$q
,
$f
) =
@_
;
return
(
$q
)
if
!
defined
(
$q
) ||(
$q
eq
''
);
my
$r
=
''
;
lib/ARSObject.pm view on Meta::CPAN
1889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
:
$ff
->{strOut}
? &{
$ff
->{strOut}}(
$s
,
$f
,
$ff
,
$_
=
$r
{
$id
})
: strOut(
$s
,
$f
,
$id
,
$r
{
$id
})
}
else
{
$rr
->{
$id
} =
$r
{
$id
}
}
}
return
(
$rr
)
}
return
(
$ARS::ars_errstr
? &{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd},
undef
,
'entry'
,
-form
=>
$f
,
-id
=>
$a
{-id}))
: {})
}
sub
entryOut {
# Format entry hash ref for output
# (schema, entry, ?sample) -> entry
my
(
$s
,
$f
,
$r
,
$rr
) =
@_
;
if
(
$rr
) {
undef
(@{
$rr
}{
keys
%$rr
})
if
%$rr
;
}
lib/ARSObject.pm view on Meta::CPAN
20272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049
my
$ii
=schdn(
$s
,
$f
,
'Incident Number'
)->{fieldId};
$a
{
$ii
} =
$s
->entryIns(
-form
=>
'HPD:CFG Ticket Num Generator'
,
'DataTags'
=>
'za'
)
if
length
(
$a
{
$ii
}) <2;
$s
->{-entryNo} =
$a
{
$ii
};
$r
=ARS::ars_CreateEntry(
$s
->{-ctrl},
$f
,
%a
)
}
else
{
$r
=
$s
->{-entryNo} =ARS::ars_CreateEntry(
$s
->{-ctrl},
$f
,
%a
)
}
if
(!
$r
) {
my
$t
=
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd});
return
(&{
$s
->{-
die
}}(
$t
))
if
!
$r
&&
$ARS::ars_errstr
;
# warn($t) if !$r && !$ARS::ars_errstr;
}
$r
||
$s
}
sub
entryUpd {
# ars_SetEntry(ctrl,schema,entry_id,getTime,...)
# (-form=>form, -id=>entryId, field=>value) -> id
# ?-echo=>1
#
# ??? ARMergeEntry()/ars_MergeEntry(ctrl, schema, mergeType, ...)
lib/ARSObject.pm view on Meta::CPAN
207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108
my
$ff
=schdn(
$s
,
$f
,
$k
);
$k
=
$ff
->{fieldId};
$v
=
$ff
->{strIn}
? &{
$ff
->{strIn}}(
$s
,
$f
,
$ff
,
$_
=
$v
)
: strIn(
$s
,
$f
,
$k
,
$v
)
if
$s
->{-strFields}
}
(
$k
=>
$v
)
}
keys
%a
;
my
$r
=ARS::ars_SetEntry(
$s
->{-ctrl},
$f
,
$id
, 0,
%a
);
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
$s
->{-cmd})))
if
!
$r
&&
$ARS::ars_errstr
;
$id
}
sub
entryDel {
# ars_DeleteEntry
# (-form=>form, -id=>entryId) -> id
# ?-echo=>1
my
(
$s
,
%a
) =
@_
;
my
$f
=
$a
{-schema} ||
$a
{-form} ||
$a
{-from} ||
$a
{-into};
my
$id
=
$a
{-id};
$s
->cpcon(
"entryDel(-form=>'$f',-id=>'$id')\n"
)
if
exists
(
$a
{-echo}) ?
$a
{-echo} :
$s
->{-echo};
delete
@a
{
qw(-schema -form -from -into -id -echo)
};
my
$r
=ARS::ars_DeleteEntry(
$s
->{-ctrl},
$f
,
$id
);
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
"entryDel(-form=>'$f',-id=>'$id')"
)))
if
!
$r
&&
$ARS::ars_errstr
;
$id
}
sub
entryBLOB {
# BLOB field retrieve/update
# (-form=>form, -id=>entryId, -field=>fieldId|fieldName
# ,?-set=>data
# ,?-file=>filePath, ?-set=>boolean
my
(
$s
,
%a
) =
@_
;
my
$f
=
$a
{-schema} ||
$a
{-form} ||
$a
{-from} ||
$a
{-into};
lib/ARSObject.pm view on Meta::CPAN
211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187
,
$a
{-field}
, {
$a
{-file}
? (
'file'
=>
$a
{-file},
'size'
=> -s
$a
{-file})
: (
'buffer'
=>
$a
{-set},
'size'
=>
length
(
$a
{-set}))
}))
}
else
{
my
$r
=ARS::ars_GetEntryBLOB(
$s
->{-ctrl},
$f
,
$a
{-id}
,
$a
{-field} =~/^\d+$/ ?
$a
{-field} : schdn(
$s
,
$f
,
$a
{-field})->{fieldId}
,
$a
{-file} ? (ARS::AR_LOC_FILENAME(),
$a
{-file}) : (ARS::AR_LOC_BUFFER()));
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$ARS::ars_errstr
,
"entryBLOB(-form=>'$f',-id=>'"
.
$a
{-id} .
"',-field=>"
.
$a
{-field} .
"')"
)))
if
!
defined
(
$r
) &&
$ARS::ars_errstr
;
return
(!
$a
{-file} ?
$r
:
$r
?
$a
{-id} :
$r
)
}
}
sub
dbi {
# DBI connection object
return
(
$_
[0]->{-dbi})
if
$_
[0]->{-dbi};
dbiconnect(
@_
)
}
sub
dbiconnect {
# DBI connect to any database
# (-dbiconnect=>[]) -> dbi object
set(
@_
);
set(
$_
[0],
-die
=>
'Carp'
)
if
!
$_
[0]->{-
die
};
$_
[0]->cpcon(
"dbiconnect()\n"
)
if
$_
[0]->{-echo};
eval
(
'use DBI; 1'
) ||
return
(&{
$_
[0]->{-
die
}}(
$_
[0]->efmt(
'No DBI'
)));
$_
[0]->{-dbi} =DBI->
connect
(
ref
(
$_
[0]->{-dbiconnect}) ? @{
$_
[0]->{-dbiconnect}} :
$_
[0]->{-dbiconnect})
|| &{
$_
[0]->{-
die
}}(
$_
[0]->efmt(DBI->errstr,
undef
,
undef
,
'dbiconnect'
) .
"\n"
);
}
sub
dbiquery {
# DBI query
# (dbi query args) -> dbi cursor object
# (-echo=>1,...)
my
(
$s
,
@q
) =
@_
;
my
(
%a
);
while
(
$#q
&& (
$q
[0] =~/^-/)) {
$a
{
$q
[0]} =
$q
[1];
shift
@q
;
shift
@q
};
$s
->cpcon(
"dbiquery($q[0])\n"
)
if
exists
(
$a
{-echo}) ?
$a
{-echo} :
$s
->{-echo};
my
$op
=
$s
->{-dbi}->prepare(
@q
)
||
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
undef
,
undef
,
'dbiprepair'
,
@q
)));
$op
->execute()
||
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
undef
,
undef
,
'dbiexecute'
,
@q
)));
$op
;
}
sub
dbido {
# DBI do
# (dbi do args) -> dbi cursor object
# (-echo=>1,...)
my
(
$s
,
@q
) =
@_
;
my
(
%a
);
while
(
$#q
&& (
$q
[0] =~/^-/)) {
$a
{
$q
[0]} =
$q
[1];
shift
@q
;
shift
@q
};
$s
->cpcon(
"dbiquery($q[0])\n"
)
if
exists
(
$a
{-echo}) ?
$a
{-echo} :
$s
->{-echo};
$s
->{-dbi}->
do
(
@q
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
undef
,
undef
,
'dbido'
,
@q
));
}
sub
dbierrstr {
# Last DBI error
$_
[0]->{-dbi}->errstr
}
sub
dbitables {
# DBI tables array
my
(
$s
,
$sch
,
$tbl
) =
@_
;
my
@t
=
$s
->dbi()->tables(
''
,
$sch
||
$s
->{-sqlschema}||
''
,
$tbl
||
'%'
);
if
(!
scalar
(
@t
)
&& (((
ref
(
$s
->{-dbiconnect}) ?
$s
->{-dbiconnect}->[0] :
$s
->{-dbiconnect})||
''
) =~/^dbi:ADO:/i)) {
$sch
=
$sch
||
$s
->{-sqlschema};
@t
=
$sch
lib/ARSObject.pm view on Meta::CPAN
227922802281228222832284228522862287228822892290229122922293229422952296229722982299
push
@sql
,
'ALTER TABLE '
.
join
(
'.'
,
map
{
defined
(
$_
) ?
$_
: ()}
$s
->{-sqlschema},
$tbl
)
.
' ALTER COLUMN '
.
$r
;
}
}
}
foreach
my
$r
(
@sql
) {
"$r;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
$s
->dbi()->
do
(
$r
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
$r
,
undef
,
'dbidsmetasync'
));
}
}
$s
;
}
sub
dbidsrpl {
# DBI datastore - load data from ARS
my
(
$s
,
%arg
) =
@_
;
$arg
{-form} =
$arg
{-from} ||
$arg
{-schema}
if
!
$arg
{-form};
$arg
{-query} =
$arg
{-where} ||
$arg
{-qual}
if
!
$arg
{-query};
lib/ARSObject.pm view on Meta::CPAN
246524662467246824692470247124722473247424752476247724782479248024812482248324842485
? (
'DELETE FROM '
.
$tbc
.
' WHERE '
.
$s
->{-dbi}->quote_identifier(
$fpk
->{COLUMN_NAME}) .
' ='
.
$s
->{-dbi}->quote(
$rd
->{
$fpk
->{COLUMN_NAME}}))
: (
'UPDATE '
.
$tbc
.
' SET '
.
join
(
', '
,
map
{ !
exists
(
$rd
->{
$_
})
? ()
: (
$s
->{-dbi}->quote_identifier(
$_
) .
' =NULL'
)
}
'_arsobject_insert'
,
'_arsobject_update'
,
'_arsobject_delete'
)
.
' WHERE '
.
$s
->{-dbi}->quote_identifier(
$fpk
->{COLUMN_NAME}) .
' ='
.
$s
->{-dbi}->quote(
$rd
->{
$fpk
->{COLUMN_NAME}}));
"$sql;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
$s
->{-dbi}->
do
(
$sql
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
$sql
,
undef
,
'dbidsrpl'
,
$arg
{-form}));
}
@rq
=();
}
}
if
(
$arg
{-ckdel}) {
my
$cnl
=
''
;
my
$dbr
=[];
while
(
$dbr
) {
my
$sql
=
'SELECT '
.
$s
->{-dbi}->quote_identifier(
$fpk
->{COLUMN_NAME})
.
' FROM '
.
$tbc
lib/ARSObject.pm view on Meta::CPAN
25242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546
@cnd
=();
sleep
(
$arg
{-
sleep
} ||0);
if
(
scalar
(
@del
)) {
$dbq
->finish();
last
;
}
}
}
foreach
$sql
(
@rms
) {
"$sql;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
$@ =
'Unknown error'
;
$s
->{-dbi}->
do
(
$sql
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
$sql
,
undef
,
'dbidsrpl'
,
$arg
{-form}));
}
}
}
if
(!
exists
(
$arg
{-ckupd}) ||
$arg
{-ckupd}) {
my
$sqlm
=0;
local
$s
->{-strFields} =0;
my
$fpksql
=
'SELECT * FROM '
.
$tbc
.
' WHERE '
.
$fpk
->{COLUMN_NAME} .
'='
;
my
$lm
;
if
(
$arg
{-master} &&
$arg
{-master_fk} &&
$fts
) {
my
$mtb
=
$s
->sqlname(
$arg
{-master});
lib/ARSObject.pm view on Meta::CPAN
2598259926002601260226032604260526062607260826092610261126122613261426152616261726182619
.
'>='
.
$s
->{-dbi}->quote(
$mtv
)
.(
$mpv
?
' AND '
.
$s
->{-dbi}->quote_identifier(
$mpk
)
.
'>='
.
$s
->{-dbi}->quote(
$mpv
)
:
''
)
:
''
)
.
' ORDER BY '
.
$s
->{-dbi}->quote_identifier(
$mts
) .
' ASC '
.
', '
.
$s
->{-dbi}->quote_identifier(
$mpk
) .
' ASC '
;
"$sql;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
$lm
=
$s
->{-dbi}->selectcol_arrayref(
$sql
,{
'MaxRows'
=>
$arg
{-lim_rf}});
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
undef
,
undef
,
'selectcol_arrayref'
,
$sql
)))
if
!
$lm
&&
$s
->{-dbi}->errstr;
# print $s->dsquot($lm),"\n";
# die('TEST')
# -form=>'HPD:HelpDesk_AuditLogSystem'
# ,-master=>'HPD:Help Desk', -master_pk=>'Entry ID',-master_fk=>'Original Request ID', -master_ts=>'Last Modified Date'
}
my
(
$rw
,
$rd
) =({});
my
(
$cs
,
$cw
) =(
$cts
,0);
while
(
$lm
?
scalar
(
@$lm
) : 1) {
$cw
++;
foreach
my
$r
(
$s
->query(
-form
=>
$arg
{-form}
lib/ARSObject.pm view on Meta::CPAN
27142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754
:
$s
->{-dbi}->quote(
$rw
->{
$_
->{fieldName}})
))
}
@flds
)
.
' WHERE '
.
$s
->{-dbi}->quote_identifier(
$fpk
->{COLUMN_NAME}) .
' ='
.
$s
->{-dbi}->quote(
$rw
->{
$fpk
->{fieldName}});
$cu
++
}
if
(
$sql
) {
# local $s->{-dbi}->{LongTruncOk} =1;
"$sql;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
$s
->{-dbi}->
do
(
$sql
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
$sql
,
undef
,
'dbidsrpl'
,
$arg
{-form}));
}
}
if
(!
$fts
&& (
$cs
==
$cw
*$arg
{-lim_rf})) {
sleep
(
$arg
{-
sleep
} ||0);
next
;
}
elsif
(
$lm
) {
sleep
(
$arg
{-
sleep
} ||0);
next
;
}
last
;
}
if
(
$arg
{-unused} && (
$fts
?
$vts
: 1)) {
my
$sql
=
'DELETE FROM '
.
$tbc
.
' WHERE '
.dbidsqq(
$s
,
$vts
&&
$fts
?
'('
.
$fts
->{COLUMN_NAME} .
'<'
.
$s
->{-dbi}->quote(
$s
->strtime(
$vts
||0)) .
') AND ('
.
$arg
{-unused} .
')'
:
$arg
{-unused}
,
$s
->{
'-meta-sql'
}->{
$tbl
});
"$sql;\n"
if
exists
(
$arg
{-echo}) ?
$arg
{-echo} :
$s
->{-echo};
my
$n
=
$s
->{-dbi}->
do
(
$sql
)
|| &{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-dbi}->errstr,
$sql
,
undef
,
'dbidsrpl'
,
$arg
{-form}));
$cd
+=
$n
;
}
}
join
(
', '
,
map
{
$_
?
$_
: ()}
$ci
&&
"new $ci"
,
$cu
&&
"upd $cu"
,
$cd
&&
"del $cd"
)
||
'up-to-date'
}
sub
dbidsquery {
# DBI datastore - query data alike ARS
my
(
$s
,
%arg
) =
@_
;
lib/ARSObject.pm view on Meta::CPAN
2920292129222923292429252926292729282929293029312932293329342935293629372938293929402941local
$^W =0;
$ENV
{HTTP_USER_AGENT} =
$ENV
{HTTP_USER_AGENT}||
''
;
$ENV
{PERLXS} =
'PerlIS'
if
!
$ENV
{PERLXS} && ($^O eq
'MSWin32'
) && $0 =~/[\\\/]perlis\.dll$/i;
eval
(
'use CGI; 1'
)
||
return
(&{
$s
->{-
die
}}(
$s
->efmt(
'No CGI'
)));
$s
->{-cgi} =
$CGI::Q
=
$CGI::Q
=
eval
{CGI->new(
@_
)}
||
return
(
$s
->{-
die
}
? &{
$s
->{-
die
}}(
$s
->efmt($@,
undef
,
undef
,
'cgi'
))
: CORE::
die
(
$s
->efmt($@,
undef
,
undef
,
'cgi'
)));
$s
->set(
-die
=>
'CGI::Carp fatalsToBrowser'
)
if
!
$s
->{-
die
};
return
(&{
$s
->{-
die
}}(
$s
->efmt(
$s
->{-cgi}->{
'.cgi_error'
},
undef
,
undef
,
'cgi'
)))
if
$s
->{-cgi}->{
'.cgi_error'
};
if
(1) {
# parse parameters
# __C_ change(d),
# __O_ open, __L_ listbox choise, __S_ set, __X_ close
# __P_ previous value
# __B_ button for javascript
foreach
my
$p
(
$s
->{-cgi}->param) {
if
(
$p
=~/^(.+?)__S_$/) {
$s
->{-cgi}->param($1,
$s
->{-cgi}->param(
"$1__L_"
));
$s
->{-cgi}->param(
"$1__C_"
, 1);
$s
->{-cgi}->
delete
(
"$1__L_"
);
lib/ARSObject.pm view on Meta::CPAN
299429952996299729982999300030013002300330043005300630073008300930103011301230133014
.
$ENV
{SCRIPT_NAME}
if
(
$v
!~/\w\/\w/) &&
$ENV
{SCRIPT_NAME};
}
return
(
$v
)
}
}
sub
cgitext {
# CGI textarea field
$_
[0]->{-cgi}->textarea(
@_
[1..
$#_
])
# -default=>$v, -override=>1
}
sub
cgistring {
# CGI string field
$_
[0]->{-cgi}->textfield(
@_
[1..
$#_
])
}
sub
cgiselect {
# CGI selection field composition
# -onchange=>1 reloads form
lib/ARSObject.pm view on Meta::CPAN
305830593060306130623063306430653066306730683069307030713072307330743075307630773078
next
if
!
$a
{
$e
};
foreach
my
$k
(
keys
%{
$a
{
$e
}}) {
$a
{-labels}->{
$k
} =
$a
{
$e
}->{
$k
}
}
}
$a
{-
values
}
};
my
$ac
=
$a
{-class} ?
' class="'
.
$a
{-class} .
'"'
:
''
;
my
$as
=
$a
{-style} ?
' style="'
.
$a
{-style} .
'"'
:
''
;
my
$aw
=
$a
{-size} ||80;
my
$v
=!
defined
(
$s
->{-cgi}->param(
$n
)) ||
$a
{-
override
}
?
$a
{-
default
}
:
$s
->{-cgi}->param(
$n
);
$v
=
&$av
()->[0]
if
$a
{-strict} && (!
defined
(
$v
) || !
grep
/^\Q
$v
\E$/, @{
&$av
()});
$s
->{-cgi}->param(
$n
,
defined
(
$v
) ?
$v
:
''
);
my
$ek
=
$s
->{-cgi}->user_agent(
'MSIE'
) ?
'window.event.keyCode'
:
'event.which'
;
my
$fs
=
sub
{
'{var k;'
.
"var l=window.document.forms[0].$nl;"
.
"if(l.style.display=='none'){"
lib/ARSObject.pm view on Meta::CPAN
311331143115311631173118311931203121312231233124312531263127312831293130313131323133(
$s
->{-cgi}->param(
"${n}__O_"
)
?
"<div><script for=\"$n\" event=\"onkeypress\">"
.
&$fs
(0) .
"</script>\n"
:
''
)
.
$s
->{-cgi}->textfield((
map
{
defined
(
$_
) &&
defined
(
$a
{
$_
})
? (
$_
=>
$a
{
$_
})
:
$a
{-textfield} &&
$a
{-textfield}->{
$_
} && !
$s
->{-cgi}->param(
"${n}__O_"
)
? (
$_
=>
$a
{-textfield}->{
$_
})
: ()
}
qw(-name -title -class -style -size -maxlength)
)
,
-default
=>
$v
,
-override
=>1
, (
$a
{-strict} && !
$s
->{-cgi}->param(
"${n}__O_"
)
? (
-readonly
=>1)
# ,-hidefocus=>0, -disabled=>0
: ())
)
.(
$s
->{-cgi}->param(
"${n}__O_"
)
? (
"<input type=\"submit\" name=\"${n}__X_\" value=\"X\" title=\"close\"$ac$as />"
.
"<input type=\"hidden\" name=\"${n}__P_\" value=\""
.(
defined
(
$v
) ?
$s
->{-cgi}->escapeHTML(
$v
) :
''
) .
"\"$ac$as />\n"
.
"<br />\n"
.
"<select name=\"${n}__L_\" title=\"select value\" size=\"10\""
.
"$ac$as"
lib/ARSObject.pm view on Meta::CPAN
396939703971397239733974397539763977397839793980398139823983398439853986398739883989my
$fs
=
$f
->{-vfname} ||
$af
->{-vfname};
$r
=
eval
{
$s
->
connect
()
&&
$s
->entryIns(
-form
=>
$frm
,
map
{
&$ffc
(
$s
,
$_
) ||(
exists
(
$_
->{-entryIns}) && !
$_
->{-entryIns})
? ()
: (
$_
->{-namedb} =>
&$fvu
(
$s
,
$_
))
} cfpused(
$s
))}
if
$frm
;
$r
=1
if
ref
(
$r
);
if
(!
$r
) {
$@ =
"Unknown 'entryIns' error"
if
!$@
}
elsif
(!
$fs
||!
$f
->{-key}) {
}
elsif
((
$af
->{-vfclear} ||
$f
->{-vfclear}) &&
$s
->{
"${fs}-calc"
}) {
$s
->vfclear(
$fs
);
}
elsif
((
$af
->{-vfrenew} ||
$f
->{-vfrenew}) &&
$s
->{
"${fs}-store"
}) {
eval
{
$s
->vfclear(
$fs
);
$s
->vfrenew(
$fs
)}
}
elsif
(
$af
->{-vfedit} ||
$f
->{-vfedit}) {
lib/ARSObject.pm view on Meta::CPAN
400340044005400640074008400940104011401240134014401540164017401840194020402140224023elsif
(
$ae
eq
'entryUpd'
) {
# -action
my
$fs
=
$f
->{-vfname} ||
$af
->{-vfname};
$r
=
eval
{
$s
->
connect
()
&&
$s
->entryUpd(
-form
=>
$frm
,
-id
=>cfpvv(
$s
,
$f
)
,
map
{
&$ffc
(
$s
,
$_
) ||(
exists
(
$_
->{-entryUpd}) && !
$_
->{-entryUpd})
? ()
: (
$_
->{-namedb} =>
&$fvu
(
$s
,
$_
))
} cfpused(
$s
))}
if
$frm
&& cfpvv(
$s
,
$f
);
if
(!
$r
) {
$@ =
"Unknown 'entryUpd' error"
if
!$@
}
elsif
(!
$f
->{-key} ||!
$fs
) {
}
elsif
((
$af
->{-vfclear} ||
$f
->{-vfclear}) &&
$s
->{
"${fs}-calc"
}) {
$s
->vfclear(
$fs
);
}
elsif
((
$af
->{-vfrenew} ||
$f
->{-vfrenew}) &&
$s
->{
"${fs}-store"
}) {
eval
{
$s
->vfclear(
$fs
);
$s
->vfrenew(
$fs
)}
}
elsif
(
$af
->{-vfedit} ||
$f
->{-vfedit}) {
lib/ARSObject.pm view on Meta::CPAN
403740384039404040414042404340444045404640474048404940504051405240534054405540564057
$s
->vfclear(
$fs
);
}
}
elsif
(
$act
eq
'entryDel'
) {
# -action
my
$fs
=
$f
->{-vfname} ||
$af
->{-vfname};
$r
=
eval
{
$s
->
connect
()
&&
$s
->entryDel(
-form
=>
$frm
,
-id
=>cfpvv(
$s
,
$f
))}
if
$frm
&& cfpvv(
$s
,
$f
);
if
(!
$r
) {
$@ =
"Unknown 'entryDel' error"
if
!$@
}
elsif
(!
$fs
||!
$f
->{-key}) {
}
elsif
((
$af
->{-vfclear} ||
$f
->{-vfclear}) &&
$s
->{
"${fs}-calc"
}) {
$s
->vfclear(
$fs
);
}
elsif
((
$af
->{-vfrenew} ||
$f
->{-vfrenew}) &&
$s
->{
"${fs}-store"
}) {
eval
{
$s
->vfclear(
$fs
);
$s
->vfrenew(
$fs
)}
}
elsif
(
$af
->{-vfedit} ||
$f
->{-vfedit}) {
lib/ARSObject.pm view on Meta::CPAN
416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212
.
"</th>\n<td align=\"left\" valign=\"top\">"
.
$_
[2]
.
"</td></tr>"
}
if
!
$cfld
;
$cfld0
=
"\n<table>"
if
!
$cfld0
;
$cfld1
=
"\n</table>"
if
!
$cfld1
;
$s
->cgi();
cfpinit(
$s
);
local
$s
->{-fpmsg} =
$cmsg
;
my
$err
;
my
$act
;
my
$acf
;
my
$aec
;
my
$arv
;
foreach
my
$f
(@{
$s
->{-fpl}}) {
next
if
(
ref
(
$f
) ne
'HASH'
)
|| (
exists
(
$f
->{-used}) && !
$f
->{-used});
if
(
$f
->{-preact} && (
$f
->{-preact} !~/^\d$/) && cfpvv(
$s
,
$f
)) {
$acf
=1;
$act
=[]
if
!
$act
;
push
@$act
,
$f
}
if
(
$f
->{-action} && (
$f
->{-action} !~/^\d$/) && cfpvv(
$s
,
$f
)) {
$aec
=cfpvv(
$s
,
$f
);
}
if
(
$f
->{-key} &&
$act
&& !
$err
) {
$arv
=1;
foreach
my
$a
(
@$act
) {
$arv
=cfpaction(
$s
,
$a
,
'-preact'
,
$arv
,
$f
);
next
if
$arv
;
$err
=$@;
last
}
$act
=
undef
;
if
(!
$arv
) {
&$emsg
(
$s
,
$err
||
"Unknown 'cfpaction' error"
);
$err
=1;
last
;
}
}
if
(
$f
->{-key}) {
$act
=
undef
;
}
next
if
!cfpused(
$s
,
$f
);
my
$fn
=cfpn(
$s
,
$f
);
if
(!
$f
->{-
reset
}
?
undef
lib/ARSObject.pm view on Meta::CPAN
42884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367
defined
(
$c
->{
$k
})
?
$s
->{-cgi}->param(cfpn(
$s
,
$k
)
,
ref
(
$c
->{
$k
}) eq
'CODE'
? &{
$c
->{
$k
}}(
$s
,
$f
,
$_
=
$fv
)
:
$c
->{
$k
}
)
:
$s
->{-cgi}->
delete
(cfpn(
$s
,
$k
))
}
}
}
if
(
my
$ev
=!
$aec
|| !
$f
->{-error}
?
undef
:
ref
(
$f
->{-error}) eq
'CODE'
? &{
$f
->{-error}}(
$s
,
$f
,
$_
=
$fv
, cfpvp(
$s
,
$f
),
$aec
)
: !
ref
(
$f
->{-error}) && (!
defined
(
$fv
) || (
$fv
eq
''
))
?
$f
->{-error}
:
undef
) {
&$cmsg
(
$s
,
'Error'
,
"'"
.
$f
->{-namelbl} .
"' - $ev"
);
$err
=1;
}
if
(
my
$ev
=!
$f
->{-
warn
}
?
undef
:
ref
(
$f
->{-
warn
}) eq
'CODE'
? &{
$f
->{-
warn
}}(
$s
,
$f
,
$_
=
$fv
, cfpvp(
$s
,
$f
),
$aec
)
: !
ref
(
$f
->{-
warn
}) && (!
defined
(
$fv
) || (
$fv
eq
''
))
?
$f
->{-
warn
}
:
undef
) {
&$cmsg
(
$s
,
'Warning'
,
"'"
.
$f
->{-namelbl} .
"' - $ev"
);
}
}
return
(
undef
)
if
$err
;
$act
=
$acf
=
$arv
=
undef
;
foreach
my
$f
(@{
$s
->{-fpl}}) {
next
if
(
ref
(
$f
) ne
'HASH'
)
|| (
exists
(
$f
->{-used}) && !
$f
->{-used});
next
if
!cfpused(
$s
,
$f
);
if
(
$f
->{-action} && (
$f
->{-action} !~/^\d$/) && cfpvv(
$s
,
$f
)) {
$acf
=1;
$act
=[]
if
!
$act
;
push
@$act
,
$f
}
if
(
$f
->{-key} &&
$act
&& !
$err
) {
$arv
=1;
foreach
my
$a
(
@$act
) {
&$cmsg
(
$s
,
'Executing'
, (
$a
->{-namelbl} ||
$a
->{-namecgi} ||
''
) .
' '
,
$arv
)
if
$a
->{-namelbl} ||
$a
->{-namecgi};
$arv
=cfpaction(
$s
,
$a
,
'-action'
,
$arv
,
$f
);
next
if
$arv
;
$err
=$@;
last
;
}
$act
=
undef
;
if
(!
$arv
) {
&$emsg
(
$s
,
$err
||
"Unknown 'cfpaction' error"
);
$err
=1;
last
;
}
}
if
(
$f
->{-key}) {
$act
=
undef
;
}
}
if
(
$acf
) {
&$cmsg
(
$s
,
'Done'
,
$err
? (
'Error'
, $@) : (
'Success'
,
$arv
))
}
return
(
undef
)
if
$err
;
return
(1)
if
$acf
;
foreach
my
$f
(@{
$s
->{-fpl}}) {
next
if
(
ref
(
$f
) ne
'HASH'
)
|| (
exists
(
$f
->{-used}) && !
$f
->{-used});
next
if
exists
(
$f
->{-widget}) && !
defined
(
$f
->{-widget});
next
if
!
$f
->{-namecgi};
my
$u
=cfpused(
$s
,
$f
);
next
if
$u
&& !(
$f
->{-hidden} ||((
ref
(
$f
->{-
values
}) eq
'ARRAY'
) && !
scalar
(@{
$f
->{-
values
}})));
defined
(cfpvp(
$s
,
$f
))
lib/ARSObject.pm view on Meta::CPAN
447844794480448144824483448444854486448744884489
:
ref
(
$f
->{-widget1}) eq
'CODE'
? &{
$f
->{-widget1}}(
$s
,
$f
, cfpvv(
$s
,
$f
), cfpvp(
$s
,
$f
))
:
$f
->{-widget1})
);
}
if
(
$bb
) {
&$cfld
(
$s
, {},
$bb
);
$bb
=
''
;
}
ref
(
$cfld1
) ? &{
$cfld1
}(
$s
) :
$cfld1
;
$err
?
undef
: 1
}
lib/ARSObject.pod view on Meta::CPAN
76777879808182838485868788899091929394=item Creation and Configuration
C<new>, C<set>, C<Slots>
=item Error Processing and Echo
C<-die>, C<-warn>, C<-echo>, C<-cpcon>/C<cpcon>;
C<ars_errstr>, C<dbierrstr>
=item Connection
C<connect>(C<-srv> => server, C<-usr> => name, C<-pswd> => password, C<-lang> => language);
C<-ctrl>
C<dbiconnect>(C<-dbiconnect>); C<-dbi>
lib/ARSObject.pod view on Meta::CPAN
134135136137138139140141142143144145146147148149150151152153C<fopen>, C<fload>, C<fstore>, C<fdirls>;
C<soon>
=item Utility Objects
C<dbi>, C<-dbi>, C<dbiconnect>, C<-dbiconnect>;
C<dbiquery>, C<dbido>; C<dbierrstr>
C<cgi>, C<-cgi>, C<cgiconnect>;
C<cgipar>, C<cgiesc>, C<cgitfrm>, C<cgitext>, C<cgistring>, C<cgiselect>, C<cgiddlb>
C<smtp>, C<-smtp>, C<smtpconnect>, C<-smtphost>; C<smtpsend>
=item SQL Data Store Methods
lib/ARSObject.pod view on Meta::CPAN
217218219220221222223224225226227228229230231232233234235236237C<-computed>, C<-value> => value || [
'field from'
] ||
sub
{} -> value
C<-
undef
> => value
C<-
values
> => [value,..] ||
sub
{}, C<-labels> => {
value
=> label,..} ||
sub
{}; C<-lbtran>, C<-lbadd> => boolean
C<-
reset
> =>
'field name'
|| [
'field'
,...] || condition
sub
{}
C<-change> => {set field
values
}
C<-error>, C<-
warn
> =>
sub
{} ->
'text'
C<-widget> => {definitions
for
cgi field in the C<Utility Objects>} || html ||
sub
{}->html
Field definitions may be used also:
C<-action> => 1;
C<-labels>, C<-
values
>;
C<-disabled>, C<-readonly>, C<-hidden>, C<-onchange> => boolean.
C<-widget0> => html above C<-widget> ||
sub
{} -> html
C<-widget1> => html below C<-widget> ||
sub
{} -> html
lib/ARSObject.pod view on Meta::CPAN
297298299300301302303304305306307308309310311312313314315316(C<CGI Form Presenter - Field Definitions>)
Computed field value evaluator.
See also C<-value>.
=item -cpcon
=> undef || sub{}(self, arg,...) -> translated
(C<Error Processing and Echo>)
Translation sub{} for error messages and C<-echo> printout.
I.e. sub{$_[0]->C<cptran>('ansi'=>'oem',@_[1..$#_])}
=item -ctrl
=> undef || ARS control struct
(C<Connection>)
ARS control struct from ARS::ars_Login()
lib/ARSObject.pod view on Meta::CPAN
332333334335336337338339340341342343344345346347348349350351=item -die
=> undef || sub{}
=> set(-die => 'Carp' || 'CGI::Carp' || 'CGI::Carp qw(fatalsToBrowser warningsToBrowser)' || 'CGI::Die')
(C<Error Processing and Echo>)
Error die sub{}.
The most C<Methods> dies when error.
Call C<set>(C<-die> => 'Carp') to use L<Carp|Carp> module.
Call C<set>(C<-die> => 'CGI::Carp fatalsToBrowser') to use L<CGI::Carp|CGI/Carp> module.
See also C<-diemsg>, C<-warn>, C<-cpcon>
=item -diemsg
=> undef || sub{}(string)
lib/ARSObject.pod view on Meta::CPAN
367368369370371372373374375376377378379380381382383384385386387388389390391392393394=item -entryNo
=> entryIns()
(C<ARS methods>)
The logical number of the entry inserted by C<entryIns>().
=item -error
=> not exists
|| sub{}({self}, {field}, $_ =field value, previous value) -> 'error text'
|| 'error text for empty field'
(C<CGI Form Presenter - Field Definitions>)
Field value error evaluator
See also C<-warn>.
=item -fpl
=> [-formdb=>'...',-record=>'...'
, {action field},.. {view/edit field},.., {button field},..}]
=item -fphc
lib/ARSObject.pod view on Meta::CPAN
861862863864865866867868869870871872873874875876877878879=item -warn
=> not exists
|| sub{}({self}, {field}, $_ =field value, previous value) -> 'warning text'
|| 'warning text for empty field'
(C<CGI Form Presenter - Field Definitions>)
Field value warning evaluator.
See also C<-error>.
=item -warnmsg
=> undef || sub{}(string)
Message for C<-warn>, alike C<-diemsg>.
lib/ARSObject.pod view on Meta::CPAN
920921922923924925926927928929930931932933934935936937938939940941942=head1 METHODS
=over
=item Methods
=item ars_errstr () -> $ARS::ars_errstr
(C<Error Processing and Echo>)
Last ARS error.
=item arsmeta (-param => value,...)
(C<Metadata>)
Load/refresh ARS metadata (C<vfload>/C<vfstore>(C<-meta>), C<-metadn>, C<-metaid>).
Called from C<connect>.
May be called without C<connect> if metadata file exists.
See also C<arsmetamin>.
lib/ARSObject.pod view on Meta::CPAN
100710081009101010111012101310141015101610171018101910201021102210231024102510261027=item cfpp ('field name' || {field definition}) -> previous field value
(C<CGI Form Presenter>)
Previous value of the field, may be used in sub{}s executed by C<cfprun>.
=item cfprun (? msg sub{}(self, 'label', 'comment'), ? form row sub{}(self, {field}, 'html'), ? 'form start html', ? 'form end html') -> success
(C<CGI Form Presenter>)
Evaluate C<-fpl> and present html form with actions.
The order of the fields is important, it is preferred to refer from
the field definition to previous fields, not to subsequent.
=item cfpv ('field name' || {field definition}) -> current field value
(C<CGI Form Presenter>)
Current value of the field, may be used in sub{}s executed by C<cfprun>.
=item cfpvv ('field name' || {field definition}) -> current or default field value
lib/ARSObject.pod view on Meta::CPAN
104110421043104410451046104710481049105010511052105310541055105610571058105910601061=item cgiconnect (CGI args) -> CGI object
(C<Utility Objects>)
Connect to L<CGI|CGI>.
=item cgiddlb (-name=>name, ?-title=>comment, ?-values=>[values], ?-labels=>{value=>display,..}, ?-default=>value, ?-override=>bool,...) -> drop-down list box HTML
(C<Utility Objects>)
Generate drop-down list box HTML using L<CGI|CGI> widgets.
This is alike C<cgiselect>, but more complex.
-strict=> - disable text editing, allow only to choose value from list
=item cgiesc (string) -> escaped string
lib/ARSObject.pod view on Meta::CPAN
1078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114=item cgipar(name) -> value
=item cgipar(name, value)
(C<Utility Objects>)
Get or set L<CGI|CGI> parameter - L<CGI|CGI>->param(@_)
=item cgiselect (-name=>name, ?-title=>comment, ?-values=>[values], ?-labels=>{value=>display,..}, ?-default=>value, ?-override=>bool,...) -> selection HTML field
(C<Utility Objects>)
Generate selection field HTML using L<CGI|CGI>->popup_menu(@_)
-onchange=>1 - reload form when value changed
=item cgistring (-name=>name, ?-title=>comment, ?-default=>value, ?-override=>bool, ?-size=>number, ?-maxlength=>number,...) -> text HTML field
(C<Utility Objects>)
Generate text field HTML using L<CGI|CGI>->textfield(@_)
=item cgitext(-name=>name, ?-title=>comment, ?-default=>value, ?-override=>bool, ?-rows=>number, ?-columns=>number,...) -> textarea HTML field
(C<Utility Objects>)
Generate HTML textarea field using L<CGI|CGI>->textarea(@_)
=item connect (-param => value,...) -> connected
(C<Connection>)
lib/ARSObject.pod view on Meta::CPAN
1230123112321233123412351236123712381239124012411242124312441245124612471248124912501251-filter
=>
undef
|| filter
sub
{}(self, {
fieldName
=> fieldValue,...}) -> allow
-order
=> [fieldName||
fieldId
=> 1||2,... colName||
colNumber
=>
'asc'
||
'desc'
,...] ||
'SQL ORDER BY clause'
-undefs
=>
undef
|| 1 || 0 - include undefined
values
to records returned
"ARS form name"
,
"ARS field name"
,
"ARS form name"
.
"ARS field name"
may be used
in
'-fields'
and
'-query'
.
=item dbierrstr () -> dbi->errstr
(C<Error Processing and Echo>)
Last L<DBI|DBI> error, <dbi>->errstr
=item dbiquery (dbi query args, ?-echo=>1) -> dbi cursor object
(C<Utility Objects>)
Query L<DBI|DBI> database using C<dbi>, 'prepare', 'execute'.
Use -echo=>1 to output command to STDOUT.