.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Gantry::Utils::CRUDHelp 3" .TH Gantry::Utils::CRUDHelp 3 "2008-01-18" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" Gantry::Utils::CRUDHelp \- helper routines for CRUD plugins .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Gantry::Utils::CRUDHelp; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Exports helper functions useful when writing \s-1CRUD\s0 plugins. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .IP "clean_params" 4 .IX Item "clean_params" Pass a hash of form parameters and the fields list from a \&\f(CW\*(C`Gantry::Plugins::AutoCRUD \*(C'\fR style form method. Any field with key is whose value is not boolean is examined in the params hash. If its value is false, that value is changed to undef. This keeps the \s-1ORM\s0 from trying to insert a blank string into a date and integer fields which is fatal, at least for DBIx::Class inserting into Postgres. .IP "clean_dates" 4 .IX Item "clean_dates" Pass a hash of form parameters and the fields list from a \&\f(CW\*(C`Gantry::Plugins::AutoCRUD \*(C'\fR style form method. Any field with key is whose value is date is examined in the params hash. If its value is false, that value is changed to undef. This keeps the \s-1ORM\s0 from trying to insert a blank string into a date field which is fatal, at least for Class::DBI inserting into Postgres. .IP "form_profile" 4 .IX Item "form_profile" Pass in the fields list from a \f(CW\*(C`Gantry::Plugins::AutoCRUD \*(C'\fR style _form method. Returns a hash reference suitable for passing to the check method of Data::FormValidator. .IP "verify_permission" 4 .IX Item "verify_permission" Use this method if you want to enforce crudcrudcrud style table permissions. .Sp Returns: undef if the permissions allow the requested action .Sp Dies: when user is barred by permissions from performing the requested action .Sp Parameters: .Sp Pass the parameters in a hashref with these keys: .RS 4 .IP "site" 4 .IX Item "site" Your gantry site object. .IP "row" 4 .IX Item "row" [Optional] For use with edit and delete actions. This must be an \s-1ORM\s0 object which responds to the \f(CW\*(C`user_id\*(C'\fR method. Usually, that happens when your table has a column of that name. .IP "params" 4 .IX Item "params" [Optional] The hash of form parameters. If you like, this method can enforce rules for \f(CW\*(C`user_id\*(C'\fR's. These are the rules it enforces: .RS 4 .IP "during add" 4 .IX Item "during add" If there is a logged in user, their id becomes the user_id in params. Otherwise, the user_id in params becomes 0. .IP "during edit (and delete)" 4 .IX Item "during edit (and delete)" The user_id key of the params hash is deleted to avoid form spoofing changes to row ownership. .RE .RS 4 .Sp AutoCRUD uses this approach. In your \s-1CRUD\s0 controller, you could choose to do something different. Like, you could allow admin users to alter the user_id of an existing row. To do something like that, simply do not pass your params hash to this method. .RE .IP "action" 4 .IX Item "action" [optional] What the user is trying to do. Pick from: add, edit, or delete. Yes, these should have had names from the \s-1CRUD\s0 acronym. .Sp By default the action comes from calling \f(CW\*(C`action\*(C'\fR on <$site> and stripping the leading \f(CW\*(C`do_\*(C'\fR. So, if your method is called \f(CW\*(C`do_delete\*(C'\fR, the action default will be \f(CW\*(C`delete\*(C'\fR. .IP "permissions" 4 .IX Item "permissions" [optional, see Default below] .Sp This must be a hash like this: .Sp .Vb 4 \& { \& 'group' => 'admin', \& 'bits' => 'crud-rudcr--' \& }; .Ve .Sp The group is optional. If present, logged in users who are members of the named group will have group rights to the table. .Sp The bits are actually 12 characters, each of which is flag. If all the letters are there, everyone can do everything and you might as well not use this method. To turn off a permission, replace the letter with a dash (although anything other than the expected letter would actually work). This is common: crudcrud\-r\-\-. It allows row owners and members of the table's group to do anything, but only allows read access for others. .Sp The example above allows row owners and admin group members to do anything (the missing c for group members is more than covered by the c for owner and others). All users (whether logged in or not) can create rows and retrieve all rows. .Sp The letters in the string must be lower case. .Sp Default: .Sp If you don't supply this parameter, it will be the \f(CW\*(C`permissions\*(C'\fR key returned by a call \f(CW\*(C`controller_config\*(C'\fR on your \f(CW\*(C`site\*(C'\fR object. .RE .RS 4 .RE .Sh "write_file(
, );" .IX Subsection "write_file( , );" write_file provides the code to collect a file from the form and write it to disk. This is to be called in the edit_post_action or add_post_action callback. .PP \fIusage\fR .IX Subsection "usage" .PP .Vb 2 \& sub edit_post_action { \& my( $self, $row ) = @_; .Ve .PP .Vb 1 \& my %params = $self->get_param_hash; .Ve .PP .Vb 1 \& if ( defined %params{'myfile'} ) { .Ve .PP .Vb 4 \& my $u = $self->write_file( 'myfile', '/home/html/images' ); \& $row->update( $u ); \& } \& } .Ve .PP \fIrecommend database fields\fR .IX Subsection "recommend database fields" .PP .Vb 6 \& varchar -- /path to file>/11677952634.59186549016706.jpg \& _ident varchar -- 11677952634.59186549016706.jpg ( unique ) \& _suffix varchar -- .txt \& _mime varchar -- text/html \& _name varchar -- originalfilename.txt \& _size int -- 2323 .Ve .PP \fIreturns\fR .IX Subsection "returns" .PP will produce a hash ref .PP .Vb 8 \& { \& '' => '/home/archive/11677952634.59186549016706.jpg', \& '_ident' => '11677952634.59186549016706.jpg', \& '_suffix' => '.txt', \& '_mime' => 'text/html', \& '_name' => 'originalfilename.txt', \& '_size' => '2323', \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 2 \& Gantry::Plugins::AutoCRUD (for simpler situations) \& Gantry::Plugins::CRUD (for slightly more complex situations) .Ve .SH "AUTHOR" .IX Header "AUTHOR" Phil Crow .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2005, Phil Crow. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.