trying to make image form controls optionally force image file types... not quite working yet
This commit is contained in:
parent
9791c99d3b
commit
0ad578ffb9
4 changed files with 23 additions and 1 deletions
|
|
@ -28,11 +28,19 @@ addLastExportedAs($session);
|
|||
addDeletionWorkflows($session);
|
||||
addRSSFromParent($session);
|
||||
reorderSurveyCollateral($session);
|
||||
addNewProfileSetting($session);
|
||||
deleteFiles($session);
|
||||
fixAds($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
#--------------------------------------------------
|
||||
sub addNewProfileSetting {
|
||||
my $session = shift;
|
||||
print "\tAdding new profile setting to force image only uploads on image form controls.\n" unless ($quiet);
|
||||
$session->db->write("alter table userProfileField add column forceImageOnly int(11) default 1");
|
||||
}
|
||||
|
||||
#--------------------------------------------------
|
||||
sub deleteFiles {
|
||||
my $session = shift;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ sub definition {
|
|||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
forceImageOnly=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -142,7 +145,7 @@ sub getValueFromPost {
|
|||
if ($storage->isImage($file)) {
|
||||
$storage->generateThumbnail($file);
|
||||
}
|
||||
else {
|
||||
elsif ($self->get("forceImageOnly")) {
|
||||
$storage->delete;
|
||||
$id = undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,6 +266,15 @@ sub www_editProfileField {
|
|||
-hoverHelp=>$i18n->get('474 description'),
|
||||
-value=>$data->{required}
|
||||
);
|
||||
if ($data->{fieldType} eq "Image") {
|
||||
$f->yesNo(
|
||||
-name=>"forceImageOnly",
|
||||
-label=>$i18n->echo("Force Image Only Uploads"),
|
||||
-hoverHelp=>$i18n->echo("If set to yes, this form control will only allow image file types to be uploaded through it."),
|
||||
-value=>$data->{forceImageOnly},
|
||||
-defaultValue=>1,
|
||||
);
|
||||
}
|
||||
my $fieldType = WebGUI::Form::FieldType->new($session,
|
||||
-name=>"fieldType",
|
||||
-label=>$i18n->get(486),
|
||||
|
|
@ -330,6 +339,7 @@ sub www_editProfileFieldSave {
|
|||
possibleValues=>$session->form->textarea("possibleValues"),
|
||||
dataDefault=>$session->form->textarea("dataDefault"),
|
||||
fieldType=>$session->form->fieldType("fieldType"),
|
||||
forceImageOnly=>$session->form->fieldType("yesNo"),
|
||||
);
|
||||
my $categoryId = $session->form->selectBox("profileCategoryId");
|
||||
if ($session->form->process("new")) {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ sub formField {
|
|||
$orderedValues->{$ov} = $values->{$ov};
|
||||
}
|
||||
$properties->{options} = $orderedValues;
|
||||
$properties->{forceImageOnly} = $self->get("forceImageOnly");
|
||||
my $default;
|
||||
if ($skipDefault) {
|
||||
} elsif (defined $self->session->form->process($properties->{name})) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue