SHARE
TWEET

Untitled

a guest Apr 5th, 2010 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package WebGUI::Account::DMNAccount;
  2.  
  3. use strict;
  4.  
  5. use WebGUI::iContactV2;
  6.  
  7. use WebGUI::Exception;
  8. use WebGUI::International;
  9. use WebGUI::Pluggable;
  10. use WebGUI::Utility;
  11. use base qw/WebGUI::Account/;
  12.  
  13. =head1 NAME
  14.  
  15. Package WebGUI::Account::DMNAccount
  16.  
  17. =head1 DESCRIPTION
  18.  
  19. Describe your New Account Module's functionality and features here.
  20.  
  21. =head1 SYNOPSIS
  22.  
  23. use WebGUI::Account::DMNAccount;
  24.  
  25.  
  26. =head1 METHODS
  27.  
  28. These methods are available from this class:
  29.  
  30. =cut
  31.  
  32. #-------------------------------------------------------------------
  33.  
  34. =head2 canView ( )
  35.  
  36. Returns whether or not the user can view the the tab for this module
  37.  
  38. =cut
  39.  
  40. sub canView {
  41.     my $self  = shift;
  42.     return 1;
  43. }
  44.  
  45. #-------------------------------------------------------------------
  46.  
  47. =head2 editSettingsForm ( )
  48.  
  49. Creates form elements for user settings page custom to this account module
  50.  
  51. =cut
  52.  
  53. sub editSettingsForm {
  54.     my $self    = shift;
  55.     my $session = $self->session;
  56.     my $setting = $session->setting;
  57.     #my $i18n    = WebGUI::International->new($session,'Account_DMN');
  58.     my $f       = WebGUI::HTMLForm->new($session);
  59.  
  60.  
  61.     $f->template(
  62.     name      => "dmnStyleTemplateId",
  63.     value     => $self->getStyleTemplateId,
  64.     namespace => "style",
  65.     label     => "Style Template",
  66.     hoverHelp => "DMN Account style template",
  67.     #label     => $i18n->get("DMN Account style template label"),
  68.     #    hoverHelp => $i18n->get("DMN Account style template hoverHelp")
  69.     );
  70.     $f->template(
  71.     name      => "dmnLayoutTemplateId",
  72.     value     => $self->getLayoutTemplateId,
  73.     namespace => "Account/Layout",
  74.     label     => "Layout Template",
  75.     hoverHelp => "DMN Account Layout template",
  76.     #label     => $i18n->get("DMN Account layout template label"),
  77.     #    hoverHelp => $i18n->get("DMN Account layout template hoverHelp")
  78.     );
  79.     $f->template(
  80.     name      => "dmnEditTemplateId",
  81.     value     => $self->getEditTemplateId,
  82.     namespace => "Account/DMN",
  83.     label     => "Edit Template",
  84.     hoverHelp => "DMN Account edit template",
  85.     #label     => $i18n->get("DMN Account edit template label"),
  86.     #    hoverHelp => $i18n->get("DMN Account edit template hoverHelp")
  87.     );
  88.     $f->template(
  89.     name      => "dmnViewTemplateId",
  90.     value     => $self->getViewTemplateId,
  91.     namespace => "Account/DMN",
  92.     label     => "View Template",
  93.     hoverHelp => "DMN Account view template",
  94.     #label     => $i18n->get("DMN Account view template label"),
  95.     #    hoverHelp => $i18n->get("DMN Account view template hoverHelp")
  96.     );
  97.  
  98.     $f->template(
  99.         name      => "dmnErrorTemplateId",
  100.         value     => $self->getErrorTemplateId,
  101.         namespace => "Account/DMN",
  102.         label     => "Error Template",
  103.         hoverHelp => "DMN Account error template",
  104.         #label     => $i18n->get("DMN Account error template label"),
  105.         #hoverHelp => $i18n->get("DMN Account error template hoverHelp")
  106.     );
  107.  
  108.     return $f->printRowsOnly;
  109.  
  110.  
  111.  
  112.  
  113.  
  114. }
  115.  
  116. #-------------------------------------------------------------------
  117.  
  118. =head2 editSettingsFormSave ( )
  119.  
  120. Save form elements from the settings.
  121.  
  122. =cut
  123.  
  124. sub editSettingsFormSave {
  125.     my $self    = shift;
  126.     my $session = $self->session;
  127.     my $setting = $session->setting;
  128.     my $form    = $session->form;
  129.  
  130.     $setting->set("dmnStyleTemplateId",  $form->process("dmnStyleTemplateId","template"));
  131.     $setting->set("dmnLayoutTemplateId", $form->process("dmnLayoutTemplateId","template"));
  132.     $setting->set("dmnEditTemplateId",   $form->process("dmnEditTemplateId","template"));
  133.     $setting->set("dmnViewTemplateId",   $form->process("dmnViewTemplateId","template"));
  134.     $setting->set("dmnErrorTemplateId",  $form->process("dmnErrorTemplateId","template"));
  135. }
  136.  
  137.  
  138. #-------------------------------------------------------------------
  139.  
  140. =head2 getStyleTemplateId ( )
  141.  
  142. This method returns the template ID for the main style.
  143.  
  144. =cut
  145.  
  146. sub getStyleTemplateId {
  147.     my $self = shift;
  148.     return $self->session->setting->get("dmnStyleTemplateId") || 'iOYdbpn2_iGLmfEGaZZSJg';
  149. }
  150.  
  151. #-------------------------------------------------------------------
  152.  
  153. =head2 getLayoutTemplateId ( )
  154.  
  155. This method returns the templateId for the layout of your new dmn.
  156.  
  157. =cut
  158.  
  159. sub getLayoutTemplateId {
  160.     my $self = shift;
  161.     return $self->session->setting->get("dmnLayoutTemplateId") || '8wcPfKvhuDbs2KCsWzT4Uw';
  162. }
  163.  
  164. #-------------------------------------------------------------------
  165.  
  166. =head2 getEditTemplateId ( )
  167.  
  168. This method returns the templateId for the layout of your new dmn.
  169.  
  170. =cut
  171.  
  172. sub getEditTemplateId {
  173.     my $self = shift;
  174.     return $self->session->setting->get("dmnEditTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg';
  175. }
  176.  
  177. #-------------------------------------------------------------------
  178.  
  179. =head2 getViewTemplateId ( )
  180.  
  181. This method returns the templateId for the layout of your new dmn.
  182.  
  183. =cut
  184.  
  185. sub getViewTemplateId {
  186.     my $self = shift;
  187.     return $self->session->setting->get("dmnViewTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg';
  188. }
  189.  
  190.  
  191. #-------------------------------------------------------------------
  192.  
  193. =head2 getErrorTemplateId ( )
  194.  
  195. This method returns the templateId for the layout of your new dmn.
  196.  
  197. =cut
  198.  
  199. sub getErrorTemplateId {
  200.     my $self = shift;
  201.     return $self->session->setting->get("dmnErrorTemplateId") || 'Pfz7hMOY-guuy3ZibH1rxg' ;
  202. }
  203.  
  204.  
  205.  
  206.  
  207. #-------------------------------------------------------------------
  208.  
  209. =head2 www_edit ( )
  210.  
  211. The edit page for the user's profile.
  212.  
  213. =cut
  214.  
  215. sub www_edit {
  216.     my $self        = shift;
  217.     my $errors      = shift || {};
  218.     my $session     = $self->session;
  219.     my $user        = $session->user;
  220.     my $email       = $user->get('email');
  221.     my $var         = {};
  222.  
  223.     #Handle errors
  224.     my @errorFields          = ();
  225.     #$var->{'dmn_account_errors'} = [];
  226.     $var->{'dmn_test1'} = 'DMN TEST 1!!';
  227.  
  228.     #if( scalar(keys %{$errors}) ) {
  229.     #    #Warnings and errors are the same here - set the fields so we can tell which fields errored
  230.     #    @errorFields = (@{$errors->{errorFields}},@{$errors->{warningFields}});
  231.     #    #Build the error message loop
  232.     #    map {
  233.     #        push( @{$var->{'dmn_account_errors'}},{ error_message => $_ })
  234.     #    }  @{$errors->{errors}};
  235.     #}
  236.  
  237.  
  238.     #my $count = 0;
  239.  
  240.     #Set the active flag to the default.  We'll know more later
  241.     #$self->store->{hasActiveTab} = 0;    
  242.    
  243.  
  244.     #my @fields;
  245.     #my $fieldForm = WebGUI::Form::radio($session,{ name    => "dmn_subscribed",
  246.     #                                               options => { 'no' => 0, 'yes' => 1 },
  247.     #                                               value   => 'yes',
  248.     #                                              });
  249.     #my $fieldLabel    = 'subscribed';
  250.     #my $fieldRequired = '';
  251.  
  252.     ##Create a seperate template var for each field
  253.     #push(@fields, {
  254.     #    'dmn_account_field_id'                             => 'subscribed',
  255.     #    'dmn_account_field_form'                           => $fieldForm,
  256.     #    'dmn_account_field_label'                          => 'subscribed',
  257.     #    'dmn_account_field_required'                       => $fieldRequired,
  258.     #});
  259.  
  260.  
  261.     #$var->{'dmn_account_fields_loop'}   = \@fields;
  262.     $var->{'dmn_test'}                  = 'DMN TEST';
  263.  
  264.     #Call the superclass common vars method cause we don't need to build the categories again
  265.     #$self->SUPER::appendCommonVars($var);
  266.  
  267.     return $self->processTemplate($var,$self->getEditTemplateId);
  268. }
  269.  
  270.  
  271.  
  272.  
  273. #-------------------------------------------------------------------
  274.  
  275. =head2 appendCategoryVars ( var, category [,fields, errors] )
  276.  
  277. Appends cateogry variables to the hash ref passed in
  278.  
  279. =head3 var
  280.  
  281. The hash reference to append template variables to
  282.  
  283. =head3 category
  284.  
  285. WebGUI::ProfileCategory object to append variables for
  286.  
  287. =head3 fields
  288.  
  289. Optional array ref of fields in this category
  290.  
  291. =head3 errors
  292.  
  293. Optional array ref of errors to attach to the category loop
  294.  
  295. =cut
  296.  
  297. sub appendCategoryVars {
  298.     my $self     = shift;
  299.     my $var      = shift || {};
  300.     my $category = shift;
  301.     my $fields   = shift;
  302.     my $errors   = shift;
  303.  
  304.     my $selected = $self->store->{selected} || $self->session->form->get("selected");
  305.    
  306.     #my $categoryId         = $category->getId;
  307.     #my $categoryLabel      = $category->getLabel;
  308.     #my $shortCategoryLabel = $category->getShortLabel;
  309.     #my $isActive           = $categoryId eq $selected;
  310.  
  311.     #my $index  = scalar(@{$var->{'profile_category_loop'}}) + 1;
  312.  
  313.     push(@{ $var->{'dmn_account_loop'} }, {
  314.         #'profile_category_id'              => $categoryId,
  315.         #'profile_category_isActive'        => $isActive,
  316.         #'profile_category_is_'.$categoryId => "true",  #Test so users can tell what category they are at in the loop
  317.         #'profile_category_label'           => $categoryLabel,
  318.         #'profile_category_shortLabel'      => $shortCategoryLabel,
  319.         #'profile_category_index'           => $index,
  320.         'dmn_account_fields_loop'              => $fields,
  321.         'dmn_account_errors'                   => $errors,
  322.         'dmn_test'                             => 'DMN TEST',
  323.     });
  324.  
  325.     #$var->{'profile_category_'.$categoryId."_isActive"  } = $isActive;
  326.     #$var->{'profile_category_'.$categoryId."_label"     } = $categoryLabel;
  327.     #$var->{'profile_category_'.$categoryId."_shortLabel"} = $shortCategoryLabel;
  328.     #$var->{'profile_category_'.$categoryId."_index"     } = $index;
  329.     #$var->{'profile_category_'.$categoryId."_fields"    } = $fields;
  330.    
  331.  
  332.     #Update the isActive flag to determine the default active tab
  333.     #$self->store->{hasActiveTab} = ($self->store->{hasActiveTab} || $isActive);
  334.  
  335.     #return $index;
  336. }
  337.  
  338.  
  339.  
  340. #-------------------------------------------------------------------
  341.  
  342. =head2 appendCommonVars ( var )
  343.  
  344. Appends common template variables that all profile templates use
  345.  
  346. =head3 var
  347.  
  348. The hash reference to append template variables to
  349.  
  350. =cut
  351.  
  352. sub appendCommonVars {
  353.     my $self          = shift;
  354.     my $var           = shift;
  355.     my $session       = $self->session;
  356.     my $user          = $session->user;
  357.     my $pageUrl       = $session->url->page;
  358.  
  359.     #NOT Used ?
  360.     return;
  361.  
  362.     $self->SUPER::appendCommonVars($var);
  363.  
  364.     $var->{'edit_profile_url'     } = $self->getUrl("module=profile;do=edit");
  365.     $var->{'invitations_enabled'  } = $session->user->profileField('ableToBeFriend');
  366.     $var->{'profile_category_loop'} = [];
  367.  
  368.     #Append the categories
  369.     my $categories = WebGUI::ProfileCategory->getCategories($session, { editable=>1 } );
  370.     map { $self->appendCategoryVars($var,$_) } @ { $categories };
  371.     unless ($self->store->{hasActiveTab}) {
  372.         $var->{'profile_category_loop'}->[0]->{'profile_category_isActive'} = 1;
  373.     }    
  374.  
  375.     #Append the form submit if it's in edit mode
  376.     if($self->method eq "edit" || $self->uid eq "") {
  377.         $var->{'is_edit'      } = "true";
  378.         $var->{'form_header'  } = WebGUI::Form::formHeader($session,{
  379.             action => $self->getUrl("module=profile;do=editSave")
  380.         });
  381.         $var->{'form_footer'  } = WebGUI::Form::formFooter($session);
  382.     }
  383. }
  384.  
  385.  
  386.  
  387.  
  388.  
  389. #-------------------------------------------------------------------
  390.  
  391. =head2 www_view ( )
  392.  
  393. The main view page for editing the user's profile.
  394.  
  395. =cut
  396.  
  397. sub www_view {
  398.     my $self    = shift;
  399.     my $session = $self->session;
  400.     my $var     = {};
  401.  
  402.     return $self->processTemplate($var,$session->setting->get("dmnViewTemplateId"));
  403.  
  404.  
  405. }
  406.  
  407.  
  408. 1;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top