profile — set UserDB profile
Attribute | Pos. | Req. | Default | Description |
---|---|---|---|---|
name | profile name | |||
tag |
default
|
|||
restore | ||||
joiner | ||||
run | ||||
set | ||||
failure | return value in case of failure | |||
success | return value in case of success | |||
interpolate | 0 | interpolate output? | ||
hide | 0 | Hide the tag return value? |
Interchange 5.9.0:
Source: code/SystemTag/profile.coretag
Lines: 14
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: profile.coretag,v 1.5 2007-03-30 23:40:49 pajamian Exp $ UserTag profile Order name UserTag profile addAttr UserTag profile PosNumber 1 UserTag profile Version $Revision: 1.5 $ UserTag profile MapRoutine Vend::Interpolate::tag_profile
Source: lib/Vend/Interpolate.pm
Lines: 1444
sub tag_profile { my($profile, $opt) = @_; #::logDebug("in tag_profile=$profile opt=" . uneval_it($opt)); $opt = {} if ! $opt; my $tag = $opt->{tag} || 'default'; if(! $profile) { if($opt->{restore}) { restore_profile(); if(ref $Vend::Session->{Autoload}) { @{$Vend::Session->{Autoload}} = grep $_ !~ /^$tag-/, @{$Vend::Session->{Autoload}}; } } return if ! ref $Vend::Session->{Autoload}; $opt->{joiner} = ' ' unless defined $opt->{joiner}; return join $opt->{joiner}, grep /^\w+-\w+$/, @{ $Vend::Session->{Autoload} }; } if($profile =~ s/(\w+)-//) { $opt->{tag} = $1; $opt->{run} = 1; } elsif (! $opt->{set} and ! $opt->{run}) { $opt->{set} = $opt->{run} = 1; } if( "$profile$tag" =~ /\W/ ) { logError( "profile: invalid characters (tag=%s profile=%s), must be [A-Za-z_]+", $tag, $profile, ); return $opt->{failure}; } if($opt->{run}) { #::logDebug("running profile=$profile tag=$tag"); my $prof = $Vend::Cfg->{Profile_repository}{$profile}; if (not $prof) { logError( "profile %s (%s) non-existant.", $profile, $tag ); return $opt->{failure}; } #::logDebug("found profile=$profile"); $Vend::Cfg->{Profile} = $prof; restore_profile(); #::logDebug("restored profile"); PROFSET: for my $one (keys %$prof) { #::logDebug("doing profile $one"); next unless defined $Vend::Cfg->{$one}; my $string; my $val = $prof->{$one}; if( ! ref $Vend::Cfg->{$one} ) { # Do nothing } elsif( ref($Vend::Cfg->{$one}) eq 'HASH') { if( ref($val) ne 'HASH') { $string = '{' . $prof->{$one} . '}' unless $prof->{$one} =~ /^{/ and $prof->{$one} =~ /}\s*$/; } } elsif( ref($Vend::Cfg->{$one}) eq 'ARRAY') { if( ref($val) ne 'ARRAY') { $string = '[' . $prof->{$one} . ']' unless $prof->{$one} =~ /^\[/ and $prof->{$one} =~ /]\s*$/; } } else { logError( "profile: cannot handle object of type %s.", $Vend::Cfg->{$one}, ); logError("profile: profile for $one not changed."); next; } #::logDebug("profile value=$val, string=$string"); undef $@; $val = $ready_safe->reval($string) if $string; if($@) { logError( "profile: bad object %s: %s", $one, $string ); next; } $Vend::Session->{Profile_save}{$one} = $Vend::Cfg->{$one} unless defined $Vend::Session->{Profile_save}{$one}; #::logDebug("set $one to value=$val, string=$string"); $Vend::Cfg->{$one} = $val; } return $opt->{success} unless $opt->{set}; }
Source: lib/Vend/Interpolate.pm
Lines: 1444
sub tag_profile { my($profile, $opt) = @_; #::logDebug("in tag_profile=$profile opt=" . uneval_it($opt)); $opt = {} if ! $opt; my $tag = $opt->{tag} || 'default'; if(! $profile) { if($opt->{restore}) { restore_profile(); if(ref $Vend::Session->{Autoload}) { @{$Vend::Session->{Autoload}} = grep $_ !~ /^$tag-/, @{$Vend::Session->{Autoload}}; } } return if ! ref $Vend::Session->{Autoload}; $opt->{joiner} = ' ' unless defined $opt->{joiner}; return join $opt->{joiner}, grep /^\w+-\w+$/, @{ $Vend::Session->{Autoload} }; } if($profile =~ s/(\w+)-//) { $opt->{tag} = $1; $opt->{run} = 1; } elsif (! $opt->{set} and ! $opt->{run}) { $opt->{set} = $opt->{run} = 1; } if( "$profile$tag" =~ /\W/ ) { logError( "profile: invalid characters (tag=%s profile=%s), must be [A-Za-z_]+", $tag, $profile, ); return $opt->{failure}; } if($opt->{run}) { #::logDebug("running profile=$profile tag=$tag"); my $prof = $Vend::Cfg->{Profile_repository}{$profile}; if (not $prof) { logError( "profile %s (%s) non-existant.", $profile, $tag ); return $opt->{failure}; } #::logDebug("found profile=$profile"); $Vend::Cfg->{Profile} = $prof; restore_profile(); #::logDebug("restored profile"); PROFSET: for my $one (keys %$prof) { #::logDebug("doing profile $one"); next unless defined $Vend::Cfg->{$one}; my $string; my $val = $prof->{$one}; if( ! ref $Vend::Cfg->{$one} ) { # Do nothing } elsif( ref($Vend::Cfg->{$one}) eq 'HASH') { if( ref($val) ne 'HASH') { $string = '{' . $prof->{$one} . '}' unless $prof->{$one} =~ /^{/ and $prof->{$one} =~ /}\s*$/; } } elsif( ref($Vend::Cfg->{$one}) eq 'ARRAY') { if( ref($val) ne 'ARRAY') { $string = '[' . $prof->{$one} . ']' unless $prof->{$one} =~ /^\[/ and $prof->{$one} =~ /]\s*$/; } } else { logError( "profile: cannot handle object of type %s.", $Vend::Cfg->{$one}, ); logError("profile: profile for $one not changed."); next; } #::logDebug("profile value=$val, string=$string"); undef $@; $val = $ready_safe->reval($string) if $string; if($@) { logError( "profile: bad object %s: %s", $one, $string ); next; } $Vend::Session->{Profile_save}{$one} = $Vend::Cfg->{$one} unless defined $Vend::Session->{Profile_save}{$one}; #::logDebug("set $one to value=$val, string=$string"); $Vend::Cfg->{$one} = $val; } return $opt->{success} unless $opt->{set}; }