Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WebGUI::Account::DMNAccount;
- use strict;
- use WebGUI::iContactV2;
- use WebGUI::Exception;
- use WebGUI::International;
- use WebGUI::Pluggable;
- use WebGUI::Utility;
- use base qw/WebGUI::Account/;
- =head1 NAME
- Package WebGUI::Account::DMNAccount
- =head1 DESCRIPTION
- Describe your New Account Module's functionality and features here.
- =head1 SYNOPSIS
- use WebGUI::Account::DMNAccount;
- =head1 METHODS
- These methods are available from this class:
- =cut
- #-------------------------------------------------------------------
- =head2 canView ( )
- Returns whether or not the user can view the the tab for this module
- =cut
- sub canView {
- my $self = shift;
- return 1;
- }
- #-------------------------------------------------------------------
- =head2 editSettingsForm ( )
- Creates form elements for user settings page custom to this account module
- =cut
- sub editSettingsForm {
- my $self = shift;
- my $session = $self->session;
- my $setting = $session->setting;
- #my $i18n = WebGUI::International->new($session,'Account_DMN');
- my $f = WebGUI::HTMLForm->new($session);
- $f->template(
- name => "dmnStyleTemplateId",
- value => $self->getStyleTemplateId,
- namespace => "style",
- label => "Style Template",
- hoverHelp => "DMN Account style template",
- #label => $i18n->get("DMN Account style template label"),
- # hoverHelp => $i18n->get("DMN Account style template hoverHelp")
- );
- $f->template(
- name => "dmnLayoutTemplateId",
- value => $self->getLayoutTemplateId,
- namespace => "Account/Layout",
- label => "Layout Template",
- hoverHelp => "DMN Account Layout template",
- #label => $i18n->get("DMN Account layout template label"),
- # hoverHelp => $i18n->get("DMN Account layout template hoverHelp")
- );
- $f->template(
- name => "dmnEditTemplateId",
- value => $self->getEditTemplateId,
- namespace => "Account/DMN",
- label => "Edit Template",
- hoverHelp => "DMN Account edit template",
- #label => $i18n->get("DMN Account edit template label"),
- # hoverHelp => $i18n->get("DMN Account edit template hoverHelp")
- );
- $f->template(
- name => "dmnViewTemplateId",
- value => $self->getViewTemplateId,
- namespace => "Account/DMN",
- label => "View Template",
- hoverHelp => "DMN Account view template",
- #label => $i18n->get("DMN Account view template label"),
- # hoverHelp => $i18n->get("DMN Account view template hoverHelp")
- );
- $f->template(
- name => "dmnErrorTemplateId",
- value => $self->getErrorTemplateId,
- namespace => "Account/DMN",
- label => "Error Template",
- hoverHelp => "DMN Account error template",
- #label => $i18n->get("DMN Account error template label"),
- #hoverHelp => $i18n->get("DMN Account error template hoverHelp")
- );
- return $f->printRowsOnly;
- }
- #-------------------------------------------------------------------
- =head2 editSettingsFormSave ( )
- Save form elements from the settings.
- =cut
- sub editSettingsFormSave {
- my $self = shift;
- my $session = $self->session;
- my $setting = $session->setting;
- my $form = $session->form;
- $setting->set("dmnStyleTemplateId", $form->process("dmnStyleTemplateId","template"));
- $setting->set("dmnLayoutTemplateId", $form->process("dmnLayoutTemplateId","template"));
- $setting->set("dmnEditTemplateId", $form->process("dmnEditTemplateId","template"));
- $setting->set("dmnViewTemplateId", $form->process("dmnViewTemplateId","template"));
- $setting->set("dmnErrorTemplateId", $form->process("dmnErrorTemplateId","template"));
- }
- #-------------------------------------------------------------------
- =head2 getStyleTemplateId ( )
- This method returns the template ID for the main style.
- =cut
- sub getStyleTemplateId {
- my $self = shift;
- return $self->session->setting->get("dmnStyleTemplateId") || 'iOYdbpn2_iGLmfEGaZZSJg';
- }
- #-------------------------------------------------------------------
- =head2 getLayoutTemplateId ( )
- This method returns the templateId for the layout of your new dmn.
- =cut
- sub getLayoutTemplateId {
- my $self = shift;
- return $self->session->setting->get("dmnLayoutTemplateId") || '8wcPfKvhuDbs2KCsWzT4Uw';
- }
- #-------------------------------------------------------------------
- =head2 getEditTemplateId ( )
- This method returns the templateId for the layout of your new dmn.
- =cut
- sub getEditTemplateId {
- my $self = shift;
- return $self->session->setting->get("dmnEditTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg';
- }
- #-------------------------------------------------------------------
- =head2 getViewTemplateId ( )
- This method returns the templateId for the layout of your new dmn.
- =cut
- sub getViewTemplateId {
- my $self = shift;
- return $self->session->setting->get("dmnViewTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg';
- }
- #-------------------------------------------------------------------
- =head2 getErrorTemplateId ( )
- This method returns the templateId for the layout of your new dmn.
- =cut
- sub getErrorTemplateId {
- my $self = shift;
- return $self->session->setting->get("dmnErrorTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg' ;
- }
- #-------------------------------------------------------------------
- =head2 www_edit ( )
- The edit page for the user's profile.
- =cut
- sub www_edit {
- my $self = shift;
- my $errors = shift || {};
- my $session = $self->session;
- my $user = $session->user;
- my $email = $user->get('email');
- my $var = {};
- #Handle errors
- my @errorFields = ();
- #$var->{'dmn_account_errors'} = [];
- $var->{'dmn_test1'} = 'DMN TEST 1!!';
- #if( scalar(keys %{$errors}) ) {
- # #Warnings and errors are the same here - set the fields so we can tell which fields errored
- # @errorFields = (@{$errors->{errorFields}},@{$errors->{warningFields}});
- # #Build the error message loop
- # map {
- # push( @{$var->{'dmn_account_errors'}},{ error_message => $_ })
- # } @{$errors->{errors}};
- #}
- #my $count = 0;
- #Set the active flag to the default. We'll know more later
- #$self->store->{hasActiveTab} = 0;
- #my @fields;
- #my $fieldForm = WebGUI::Form::radio($session,{ name => "dmn_subscribed",
- # options => { 'no' => 0, 'yes' => 1 },
- # value => 'yes',
- # });
- #my $fieldLabel = 'subscribed';
- #my $fieldRequired = '';
- ##Create a seperate template var for each field
- #push(@fields, {
- # 'dmn_account_field_id' => 'subscribed',
- # 'dmn_account_field_form' => $fieldForm,
- # 'dmn_account_field_label' => 'subscribed',
- # 'dmn_account_field_required' => $fieldRequired,
- #});
- #$var->{'dmn_account_fields_loop'} = \@fields;
- $var->{'dmn_test'} = 'DMN TEST';
- #Call the superclass common vars method cause we don't need to build the categories again
- #$self->SUPER::appendCommonVars($var);
- return $self->processTemplate($var,$self->getEditTemplateId);
- }
- #-------------------------------------------------------------------
- =head2 appendCategoryVars ( var, category [,fields, errors] )
- Appends cateogry variables to the hash ref passed in
- =head3 var
- The hash reference to append template variables to
- =head3 category
- WebGUI::ProfileCategory object to append variables for
- =head3 fields
- Optional array ref of fields in this category
- =head3 errors
- Optional array ref of errors to attach to the category loop
- =cut
- sub appendCategoryVars {
- my $self = shift;
- my $var = shift || {};
- my $category = shift;
- my $fields = shift;
- my $errors = shift;
- my $selected = $self->store->{selected} || $self->session->form->get("selected");
- #my $categoryId = $category->getId;
- #my $categoryLabel = $category->getLabel;
- #my $shortCategoryLabel = $category->getShortLabel;
- #my $isActive = $categoryId eq $selected;
- #my $index = scalar(@{$var->{'profile_category_loop'}}) + 1;
- push(@{ $var->{'dmn_account_loop'} }, {
- #'profile_category_id' => $categoryId,
- #'profile_category_isActive' => $isActive,
- #'profile_category_is_'.$categoryId => "true", #Test so users can tell what category they are at in the loop
- #'profile_category_label' => $categoryLabel,
- #'profile_category_shortLabel' => $shortCategoryLabel,
- #'profile_category_index' => $index,
- 'dmn_account_fields_loop' => $fields,
- 'dmn_account_errors' => $errors,
- 'dmn_test' => 'DMN TEST',
- });
- #$var->{'profile_category_'.$categoryId."_isActive" } = $isActive;
- #$var->{'profile_category_'.$categoryId."_label" } = $categoryLabel;
- #$var->{'profile_category_'.$categoryId."_shortLabel"} = $shortCategoryLabel;
- #$var->{'profile_category_'.$categoryId."_index" } = $index;
- #$var->{'profile_category_'.$categoryId."_fields" } = $fields;
- #Update the isActive flag to determine the default active tab
- #$self->store->{hasActiveTab} = ($self->store->{hasActiveTab} || $isActive);
- #return $index;
- }
- #-------------------------------------------------------------------
- =head2 appendCommonVars ( var )
- Appends common template variables that all profile templates use
- =head3 var
- The hash reference to append template variables to
- =cut
- sub appendCommonVars {
- my $self = shift;
- my $var = shift;
- my $session = $self->session;
- my $user = $session->user;
- my $pageUrl = $session->url->page;
- #NOT Used ?
- return;
- $self->SUPER::appendCommonVars($var);
- $var->{'edit_profile_url' } = $self->getUrl("module=profile;do=edit");
- $var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend');
- $var->{'profile_category_loop'} = [];
- #Append the categories
- my $categories = WebGUI::ProfileCategory->getCategories($session, { editable=>1 } );
- map { $self->appendCategoryVars($var,$_) } @ { $categories };
- unless ($self->store->{hasActiveTab}) {
- $var->{'profile_category_loop'}->[0]->{'profile_category_isActive'} = 1;
- }
- #Append the form submit if it's in edit mode
- if($self->method eq "edit" || $self->uid eq "") {
- $var->{'is_edit' } = "true";
- $var->{'form_header' } = WebGUI::Form::formHeader($session,{
- action => $self->getUrl("module=profile;do=editSave")
- });
- $var->{'form_footer' } = WebGUI::Form::formFooter($session);
- }
- }
- #-------------------------------------------------------------------
- =head2 www_view ( )
- The main view page for editing the user's profile.
- =cut
- sub www_view {
- my $self = shift;
- my $session = $self->session;
- my $var = {};
- return $self->processTemplate($var,$session->setting->get("dmnViewTemplateId"));
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement