Merge commit '4635b91554' into WebGUI8. Syntax clean up to 7.10.2

This commit is contained in:
Colin Kuskie 2010-10-27 15:59:33 -07:00
commit 87326192a3
46 changed files with 956 additions and 969 deletions

View file

@ -82,7 +82,8 @@ sub appendCategoryVars {
$var->{'profile_category_'.$categoryId."_shortLabel"} = $shortCategoryLabel;
$var->{'profile_category_'.$categoryId."_index" } = $index;
$var->{'profile_category_'.$categoryId."_fields" } = $fields;
$var->{'can_edit_profile' } = $self->uid eq $self->session->user->userId;
#Update the isActive flag to determine the default active tab
$self->store->{hasActiveTab} = ($self->store->{hasActiveTab} || $isActive);
@ -471,8 +472,6 @@ sub www_view {
$self->appendCommonVars($var);
$var->{'can_edit_profile' } = $uid eq $session->user->userId;
my $privacySetting = $user->profileField('publicProfile') || 'none';
$var->{"profile_privacy_$privacySetting"} = "true";

View file

@ -2642,7 +2642,7 @@ sub www_changeUrl {
my $i18n = WebGUI::International->new($self->session, "Asset");
my $f = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
$f->hidden(name=>"func", value=>"changeUrlConfirm");
$f->hidden(name=>"proceed", value=>$self->session->form->param("proceed"));
$f->hidden(name=>"proceed", value=>scalar($self->session->form->param("proceed")));
$f->text(name=>"url", value=>$self->get('url'), label=>$i18n->get("104"), hoverHelp=>$i18n->get('104 description'));
$f->yesNo(name=>"confirm", value=>0, label=>$i18n->get("confirm change"), hoverHelp=>$i18n->get("confirm change url message"), subtext=>'<br />'.$i18n->get("confirm change url message"));
$f->submit;

View file

@ -1440,7 +1440,7 @@ override processEditForm => sub {
my $assetId = $self->getId;
my $revisionDate = $self->revisionDate;
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[($form->param('sequenceNumber') || $top_val), $assetId, $revisionDate]);
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[(scalar($form->param('sequenceNumber')) || $top_val), $assetId, $revisionDate]);
# Pre-process Related Links and manage changes

View file

@ -90,6 +90,9 @@ sub _drawQueryBuilder {
"!=" => $i18n->get("isnt")
};
}
$operator{checkList} = {
"+~" => $i18n->get("contains"),
};
$operator{integer} = {
"=" => $i18n->get("equal to"),
"!=" => $i18n->get("not equal to"),
@ -145,6 +148,8 @@ sub _drawQueryBuilder {
# The value select field
my $valFieldName = "val_field".$i;
my $options = $fields->{$field}{possibleValues};
##Only allow one at a time to be selected, and work with current JS for choosing which one.
$fieldType = 'radioList' if $fieldType eq 'checkList';
my $valueField = WebGUI::Form::dynamicField($session,
fieldType=>$fieldType,
name=>$valFieldName,
@ -374,7 +379,6 @@ sub getFieldsList {
foreach my $field (@{WebGUI::ProfileField->getFields($session)}) {
my $fieldId = $field->getId;
next if $fieldId =~ /contentPositions/;
$session->log->warn($fieldId);
$fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']';
}
$output .= '<table cellspacing="0" cellpadding="3" border="1"><tr><td><table cellspacing="0" cellpadding="3" border="0">';
@ -388,8 +392,6 @@ sub getFieldsList {
-vertical=>1,
-uiLevel=>9
);
$session->log->warn($list->get('uiLevel'));
$session->log->warn($list->passUiLevelCheck);
$output .= $list->toHtmlWithWrapper;
$output .= '</table></td><td><table cellspacing="0" cellpadding="3" border="0">';
my @prefFieldsToImport = $self->getPrefFieldsToImport;
@ -601,8 +603,8 @@ sub getShortcutByCriteria {
# | | |
# |- $field |_ $operator |- $value
# |_ $attribute |_ $attribute
my $operator = qr/<>|!=|=|>=|<=|>|<|like/i;
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
my $operator = qr/<>|!=|=|>=|<=|>|<|like|\+~/i;
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
my $constraint = $criteria;
@ -610,6 +612,7 @@ sub getShortcutByCriteria {
my $db = $self->session->db;
my $counter = "b";
my @joins = ();
##Transform the expression into valid SQL
foreach my $expression ($criteria =~ /($attribute\s*$operator\s*$attribute)/gi) {
# $expression will match "State = Wisconsin"
@ -617,9 +620,10 @@ sub getShortcutByCriteria {
# We need it later.
push(@joins," left join metaData_values ".$counter."_v on a.assetId=".$counter."_v.assetId ");
# Get the field (State) and the value (Wisconsin) from the $expression.
$expression =~ /($attribute)\s*$operator\s*($attribute)/gi;
$expression =~ /($attribute)\s*($operator)\s*($attribute)/gi;
my $field = $1;
my $value = $2;
my $current_operator = $2;
my $value = $3;
# quote the field / value variables.
my $quotedField = $field;
@ -627,18 +631,21 @@ sub getShortcutByCriteria {
unless ($field =~ /^\s*['"].*['"]\s*/) {
$quotedField = $db->quote($field);
}
unless ($value =~ /^\s*['"].*['"]\s*/) {
$quotedValue = $db->quote($value);
}
unless ($value =~ /^\s*['"].*['"]\s*/) {
$quotedValue = $db->quote($value);
}
# transform replacement from "State = Wisconsin" to
# "(fieldname=State and value = Wisconsin)"
my $clause = "(".$counter."_p.fieldName=".$quotedField." and ".$counter."_v.value ";
$replacement =~ s/\Q$field/$clause/;
$replacement =~ s/\Q$value/$quotedValue )/i;
$replacement =~ s/\Q$field/$clause/;
$replacement =~ s/\Q$value/$quotedValue )/i;
# replace $expression with the new $replacement in $constraint.
$constraint =~ s/\Q$expression/$replacement/;
$constraint =~ s/\Q$expression/$replacement/;
if ($current_operator eq '+~') {
$constraint =~ s/and ${counter}_v\.value\s*\+~\s*$quotedValue/and FIND_IN_SET($quotedValue, REPLACE(${counter}_v.value,"\\n",","))/;
}
push (@joins, " left join metaData_properties ".$counter."_p on ".$counter."_p.fieldId=".$counter."_v.fieldId ");
$counter++;
}

View file

@ -2023,7 +2023,7 @@ sub www_importEvents {
-label => $i18n->get('ignore first line'),
-name => 'ignore_first_line',
-hoverHelp => $i18n->get('import hoverhelp first line'),
-defaultValue => $form->param('ignore_first_line'),
-defaultValue => scalar $form->param('ignore_first_line'),
);
# create the std & meta fields part of the form
@ -2040,7 +2040,7 @@ sub www_importEvents {
name => 'fieldsToImport',
defaultValue => \@defaultImportableFields,
options => \%importableFields,
value => $form->get('fieldsToImport'),
value => scalar $form->get('fieldsToImport'),
);
$f->submit(-value=>$i18n->get('import events'));

View file

@ -2610,7 +2610,7 @@ sub www_editThingDataSaveViaAjax {
return '{}';
}
else {
warn "thingId not found in thingProperties\n";
$session->log->warn("thingId ".$thingProperties->{thingId}." not found in thingProperties");
$session->http->setStatus(404);
return JSON->new->encode({message => "The thingId you requested can not be found."});
}

View file

@ -196,6 +196,7 @@ use WebGUI::International;
use HTML::Parser;
use URI::Escape;
use WebGUI::Form;
use WebGUI::Search;
use Clone qw/clone/;
#-------------------------------------------------------------------
@ -993,7 +994,7 @@ sub www_search {
mostPopularUrl=>$self->getUrl("func=mostPopular"),
mostPopularLabel=>$i18n->get("mostPopularLabel"),
wikiHomeUrl=>$self->getUrl,
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$queryString),
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$self->session->url->escape($queryString)),
};
$self->appendSearchBoxVars($var, $queryString);
if (length $queryString) {

View file

@ -1056,10 +1056,13 @@ sub showMessageOnLogin {
WebGUI::Macro::process( $self->session, \$output );
# Add the link to continue
my $session = $self->session;
$session->log->warn("returnUrl: >".$self->session->form->get( 'returnUrl' )."<");
$session->log->warn("redirectAfterLoginUrl: >".$self->session->form->get( 'returnUrl' )."<");
my $redirectUrl = $self->session->form->get( 'returnUrl' )
|| $self->session->setting->get("redirectAfterLoginUrl")
|| $self->session->scratch->get( 'redirectAfterLogin' )
|| $self->session->url->getSiteURL . $self->session->url->gateway()
|| $self->session->url->getBackToSiteURL
;
$output .= '<p><a href="' . $redirectUrl . '">' . $i18n->get( 'showMessageOnLogin return' )

View file

@ -16,7 +16,6 @@ package WebGUI::Form::Codearea;
use strict;
use base 'WebGUI::Form::Textarea';
use HTML::Entities qw(encode_entities decode_entities);
use WebGUI::International;
=head1 NAME
@ -90,18 +89,6 @@ sub definition {
#-------------------------------------------------------------------
=head2 getDatabaseFieldType ( )
Returns "MEDIUMTEXT".
=cut
sub getDatabaseFieldType {
return "MEDIUMTEXT";
}
#-------------------------------------------------------------------
=head2 getName ( session )
Returns the human readable name of this control.
@ -113,101 +100,4 @@ sub getName {
return WebGUI::International->new($session, 'WebGUI')->get('codearea');
}
#-------------------------------------------------------------------
=head2 getValue ( [value] )
Return the value, HTML decoded
=cut
sub getValue {
my ( $self, @args ) = @_;
my $value = $self->SUPER::getValue( @args );
return decode_entities( $value );
}
#-------------------------------------------------------------------
=head2 headTags ( )
Set the head tags for this form plugin
=cut
sub headTags {
my $self = shift;
my ($style, $url) = $self->session->quick(qw(style url));
$style->setCss($url->extras("yui/build/resize/assets/skins/sam/resize.css"));
$style->setCss($url->extras("yui/build/assets/skins/sam/skin.css"));
$style->setScript($url->extras("yui/build/utilities/utilities.js"));
$style->setScript($url->extras("yui/build/container/container_core-min.js"));
$style->setScript($url->extras("yui/build/menu/menu-min.js"));
$style->setScript($url->extras("yui/build/button/button-min.js"));
$style->setScript($url->extras("yui/build/resize/resize-min.js"));
$style->setScript($url->extras("yui/build/editor/editor-min.js"));
$style->setScript($url->extras("yui-webgui/build/code-editor/code-editor.js"));
#$style->setCss($url->extras("yui/build/logger/assets/logger.css"));
#$style->setCss($url->extras("yui/build/logger/assets/skins/sam/logger.css"));
#$style->setScript($url->extras("yui/build/logger/logger.js"));
$self->SUPER::headTags();
}
#-------------------------------------------------------------------
=head2 isDynamicCompatible ( )
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
=cut
sub isDynamicCompatible {
return 1;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a code area field.
=cut
sub toHtml {
my $self = shift;
my $value = encode_entities( $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue))) );
my $width = $self->get('width');
if ( $width !~ /%|px/ ) {
$width .= 'px';
}
my $height = $self->get('height');
if ( $height !~ /%|px/ ) {
$height .= 'px';
}
my $id = $self->get('id');
my $name = $self->get('name');
my $extras = $self->get('extras');
my $syntax = $self->get('syntax');
my $styleAttr = $self->get('style');
my $codeCss = $self->session->url->extras("yui-webgui/build/code-editor/code.css");
my $out = <<"END_HTML";
<textarea id="$id" name="$name" $extras rows="10" cols="60" style="font-family: monospace; $styleAttr; height: 100%; width: 100%; resize: none;">$value</textarea>
<script type="text/javascript">
(function(){
YAHOO.util.Event.onDOMReady( function () {
var myeditor = new YAHOO.widget.CodeEditor('${id}', { toggleButton: true, handleSubmit: true, css_url: '${codeCss}', height: '${height}', width: '${width}', status: true, resize: true });
myeditor.render();
//var myLogReader = new YAHOO.widget.LogReader();
} );
}());
</script>
END_HTML
return $out;
}
1;

View file

@ -18,6 +18,7 @@ use strict;
use base 'WebGUI::Form::Text';
use WebGUI::Form::Hidden;
use WebGUI::International;
use Scalar::Util qw/blessed/;
my $isaEpoch = qr/^-?\d+$/;
@ -241,8 +242,11 @@ sub toHtml {
$value = $self->set("value",'');
}
else {
$value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate; };
$value = WebGUI::DateTime->new($session,0)->toMysqlDate if $value eq '';
my $originalValue = $self->getOriginalValue;
my $dt = eval { WebGUI::DateTime->new($session, $originalValue); };
$dt = WebGUI::DateTime->new($session,0) if ! (blessed $dt && $dt->isa('DateTime')); ##Parsing error
$dt->set_time_zone($session->datetime->getTimeZone);
$value = $dt->toMysqlDate;
}
my $field = WebGUI::Form::Text->new($self->session,

View file

@ -197,7 +197,6 @@ sub toHtml {
$self->set("extras", $self->get('extras') . q{ onblur="fixChars(this.form['}.$self->get("name").q{'])" mce_editable="true" });
$self->set("resizable", 0);
return $self->SUPER::toHtml.$self->{_richEdit}->getRichEditor($self->get('id'));
}
#-------------------------------------------------------------------

View file

@ -276,7 +276,7 @@ sub headTags {
=head2 toHtml ( )
Renders an input tag of type text.
Set the head tags for this form plugin
=cut

View file

@ -163,16 +163,9 @@ Renders an input tag of type text.
sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
my $width = $self->get('width') || '100%';
if ( $width !~ /%|px/ ) {
$width .= 'px';
}
my $height = $self->get('height') || '100%';
if ( $height !~ /%|px/ ) {
$height .= 'px';
}
my ($style, $url, $stow) = $self->session->quick(qw(style url stow));
my $sizeStyle = ' width: ' . $width . '; height: ' . $height . ';';
my $width = $self->get('width') || 400;
my $height = $self->get('height') || 150;
my $sizeStyle = ' width: ' . $width . 'px; height: ' . $height . 'px;';
my $out
= '<textarea id="' . $self->get('id') . '"'
. ' name="' . $self->get("name") . '"'

View file

@ -1980,7 +1980,7 @@ sub vitalGroup {
if (! $groupId && ref $class ) {
$groupId = $class->getId;
}
return $groupId ~~ [ map { "$_" } (1..17), 15, 16, 17, qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 /];
return $groupId ~~ [ map { "$_" } (1..13), 15, 16, 17, qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 /];
}
1;

View file

@ -308,6 +308,9 @@ sub www_runCronJob {
# Run the instance
my $error = $instance->start( 1 );
if ($error) {
##Unable to communicate with spectre. Delete this instance to it does not get stuck.
$session->log->error("Unable to communicate with spectre: $error about taskId: $taskId. Deleting instanceId: ". $instance->getId);
$instance->delete();
return "error";
}
$task->delete( 1 ) if ( $task->get("runOnce") );

View file

@ -53,7 +53,8 @@ around BUILDARGS => sub {
=head2 adjust ( amount, [ comment ] )
Adjusts the amount of credit this user has by a specified amount.
Adjusts the amount of credit this user has by a specified amount. Returns 0 if the current user is Visitor.
Otherwise, returns the amount set.
=head3 amount
@ -157,6 +158,20 @@ A unique id for a user that you want to adjust the credit of. Defaults to the cu
#-------------------------------------------------------------------
=head2 purge ( )
Removes all shop credit for the current user.
=cut
sub purge {
my ($self) = @_;
$self->session->db->write("delete from shopCredit where userId = ?",[$self->userId]);
return 1;
}
#-------------------------------------------------------------------
=head2 session ()
Returns a reference to the current session.

View file

@ -146,7 +146,7 @@ sub appendCartVariables {
my $session = $self->session;
my $credit = WebGUI::Shop::Credit->new($session, $cart->getPosUser->userId);
$var->{inShopCreditAvailable} = $credit->getSum;
$var->{inShopCreditDeduction} = $credit->calculateDeduction($var->{totalPrice});
$var->{inShopCreditDeduction} = $credit->calculateDeduction($totalPrice);
$var->{totalPrice } = $cart->formatCurrency($totalPrice + $var->{inShopCreditDeduction});
return $self;
}

View file

@ -18,6 +18,7 @@ use strict;
use WebGUI::Group;
use WebGUI::Workflow::Instance;
use JSON ();
use WebGUI::Exception;
use WebGUI::ProfileField;
use Scalar::Util qw( weaken );
use Net::CIDR::Lite;
@ -418,6 +419,10 @@ sub delete {
$book->delete;
}
require WebGUI::Shop::Credit;
my $credit = WebGUI::Shop::Credit->new($session, $userId);
$credit->purge;
# remove user itself
$db->write("DELETE FROM userProfileData WHERE userId=?",[$userId]);
$db->write("DELETE FROM users WHERE userId=?",[$userId]);

View file

@ -102,8 +102,9 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $self = shift;
my $start = time();
my $stop = $start + $self->getTTL;
# kill temporary assets
my $tempspace = WebGUI::Asset->getTempspace($self->session);
@ -125,11 +126,11 @@ sub execute {
}
}
# taking too long, give up
return $self->WAITING(1) if (time() - $start > $self->getTTL);
return $self->WAITING(1) if (time() > $stop);
}
# kill temporary files
return $self->recurseFileSystem($start, $self->session->config->get("uploadsPath")."/temp");
return $self->recurseFileSystem($stop, $self->session->config->get("uploadsPath")."/temp");
}
@ -147,7 +148,7 @@ The starting path.
sub recurseFileSystem {
my $self = shift;
my $start = shift;
my $stop = shift;
my $path = shift;
if (opendir(DIR,$path)) {
my @filelist = readdir(DIR);
@ -155,10 +156,10 @@ sub recurseFileSystem {
foreach my $file (@filelist) {
unless ($file eq "." || $file eq "..") {
# taking too long, time to abort
return $self->WAITING(1) if (time() - $start > 50);
return $self->WAITING(1) if (time() > $stop);
# must search for children
$self->recurseFileSystem($start, $path."/".$file);
$self->recurseFileSystem($stop, $path."/".$file);
# if it's old enough, let's kill it
if ($self->checkFileAge($path."/".$file)) {

View file

@ -111,7 +111,7 @@ sub execute {
$msg->addHtml( $self->get('notificationMessage') );
$msg->queue;
if ( time - $time > 60 ) {
if ( time - $time > $self->getTTL ) {
return $self->WAITING(1);
}
}

View file

@ -65,7 +65,7 @@ See WebGUI::Workflow::Activity::execute() for details.
sub execute {
my ( $self, $obj, $instance ) = @_;
my $timeLimit = time + 55;
my $timeLimit = time + $self->getTTL;
my $piped = $instance->getScratch('recurrences')
|| $self->generateRecurrenceList();

View file

@ -49,6 +49,12 @@ our $I18N = {
lastUpdated => 1053183804
},
'contains' => {
message => q|contains|,
lastUpdated => 1053183804,
context => q|to be a member of a set, inclusive|,
},
'1' => {
message => q|Asset to Mirror|,
lastUpdated => 1031514049