"Fossies" - the Fresh Open Source Software Archive

Member "metadot/metadot/Gizmo/Application.pm" (1 Jul 2005, 7356 Bytes) of package /linux/www/old/Metadot6.4.5.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Application.pm" see the Fossies "Dox" file reference documentation.

    1 ###########################################################################
    2 # <LICENSEINFO>
    3 # Copyright (C) Daniel Guermeur - 1999-2001
    4 # Copyright (C) Metadot Corporation - 2001-2005
    5 #
    6 # This file is part of Metadot Portal Server software $Name: Release_6_4_5_4 $
    7 #
    8 # Metadot Portal Server software is free software; you can
    9 # redistribute it and/or modify it under the terms of the GNU General Public
   10 # License as published by the Free Software Foundation; either version 2 of
   11 # the License, or (at your option) any later version.
   12 #
   13 # Metadot Portal Server software is distributed in the hope that it
   14 # will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   15 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
   16 # Public License for more details.
   17 #
   18 # You should have received a copy of the GNU General Public License along with
   19 # Metadot Portal Server; if not, write to the Free Software
   20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21 #
   22 # For more information, please contact info@metadot.com.
   23 #</LICENSEINFO>
   24 ############################################################################
   25 package Application;
   26 
   27 use Metadot qw($USER %FORM $PARAMS);
   28 
   29 use GizmoBuilder;
   30 use strict;
   31 use vars qw(@ISA);
   32 use CGI qw/escapeHTML unescapeHTML/;
   33 @ISA=qw(GizmoBuilder);
   34 my $version = "4.5";
   35 
   36 
   37 sub get_version {
   38     return $version;
   39 }
   40 
   41 
   42 my $AC =
   43   {
   44    BUNDLES => {
   45            MOD => { DESC => 'Edit',
   46             OPS => [qw(create modify save up down paste delfile delfileok)],
   47             DEFAULT_LEVEL => 8,
   48             MIN_LEVEL => 8,
   49               },
   50            DEL => { DESC => 'Delete and Cut',
   51             OPS => [qw(delete delete_ok cut)],
   52             DEFAULT_LEVEL => 8,
   53             MIN_LEVEL => 8,
   54             PARENT_DEP => {cut => 'MOD'},
   55               },
   56            DISP => { DESC => 'View',
   57              OPS => [qw(show)],
   58              DEFAULT_LEVEL => 2,
   59              MIN_LEVEL => 2,
   60              DEFAULTS_TO => 'on',
   61                },
   62            EDITP => { DESC => 'Change<br />Permissions',
   63               OPS => [qw(edit_permissions set_permissions change_owner)],
   64               DEFAULT_LEVEL => 8,
   65               MIN_LEVEL => 8,
   66             },
   67           },
   68    DISPLAY_ORDER => [qw(DISP MOD DEL EDITP)],
   69   };
   70 
   71 ###
   72 ### ACCESS CONTROL METHODS
   73 ###
   74 sub get_AC {
   75   my $self = shift;
   76   my $class = ref $self || $self;
   77 
   78   die "&get_AC should be overridden in class $class"
   79     unless ($class eq __PACKAGE__);
   80 
   81   return $AC;
   82 }
   83 
   84 
   85 ####################################
   86 sub initialize {
   87     my $self = shift;
   88     my $args = Utility->coerce_hashref(@_);
   89     $self->SUPER::initialize(@_);
   90 
   91   $self->{cool}='No';
   92 
   93   $self->set_field_info (
   94         "name",        "<b>Application Name</b>", 1,
   95         "description", "<b>Description</b>", 0,
   96         "keywords",    "<b>Keywords and Synonyms</b>", 0,
   97         "cool",        "<b>Star this Item</b>", 0,
   98        );
   99 
  100   my $info_string = "This is a temporary interface, which in subsequent releases will
  101 be made more automated and conceal Application creation from non-admin users.
  102 Only developers/system admins should use this feature.
  103 <p>The name of the application must correspond to the name of
  104 an existing App module (as described in the Metadot Developers' Guide).
  105 The name is case-sensitive.  Do not add the &quot;.pm&quot;
  106 suffix for the module.  For example, &quot;Basic&quot; is a module name.";
  107   $self->set_intro_text($info_string);
  108 }
  109 
  110 
  111 sub get_is_public {
  112     my $class = shift;
  113 
  114     if ($PARAMS->{use_application_gizmo}) {
  115     return "Yes";
  116     }
  117     else {
  118     return "No";
  119     }
  120 }
  121 
  122 ##################################
  123 sub process_edit_form() {
  124     my $self  = shift;
  125     my $error = undef;
  126 
  127     my $name = $FORM{name};
  128     $self->require_app($name);
  129 
  130     ## check for required fields
  131     foreach my $field (keys (%{$self->{fields}})) {
  132         if ($self->{fields}->{$field}->{required} &&
  133         (!$FORM{$field} || !($FORM{$field} =~ /\S/)) # field is not just whitespace
  134         ) {
  135             $error .= $self->{fields}->{$field}->{label} .
  136         " is a required field.\n";
  137         }
  138     }
  139 
  140     my $iid = $self->get_iid();
  141 
  142     if (defined($error) && $iid){ ## if error and updating
  143         $self->www_modify($error);
  144     }
  145     elsif (defined($error)) {   ## if error and saving new
  146         my $parentid = $self->parent_id();
  147         my $parent = Gizmo->restore($parentid);
  148 #   print STDERR "in gizmo::process_edit_form, calling parent add child on error\n";
  149         $parent->www_add_child($error, $self->is_a);
  150     }
  151     else {          ## no errors
  152     my $checked_reqs = 1;
  153         $self->www_save($checked_reqs);
  154     }
  155 }
  156 
  157 ###################################
  158 sub show_application_bar {
  159     my $class = shift;
  160 
  161     my $output = undef;
  162     my $app_list = undef;
  163     my $categorytitlebgcolor = $PARAMS->{'categorytitlebgcolor'};
  164 #    my $fileuploaddir = $PARAMS->{'fileuploaddir'};
  165     my $fileuploaddir = undef;
  166     my $appcount = 0;
  167 
  168     my ($result) = DBAccess->sqlSelectMany("iid", "instance", "isa='Application'");
  169 
  170     $output = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" "
  171                  ."bgcolor='#$categorytitlebgcolor'><tr>\n";
  172 
  173     while (my ($iid) = $result->fetchrow()) {
  174     $appcount++;
  175         my $app = $class->new($iid);
  176         my $edit = $app->show_edit_button();
  177         my $perm = $app->show_ac_button();
  178         my $delete = $app->show_del_button();
  179         my $app_root = $app->parent_id();
  180         my $name = $app->name();
  181         my $img = $app->file1();
  182 
  183         if ($app->is_allowed_to_do('show', $USER)){
  184             $app_list .= "<td valign='bottom' align='center'> "
  185                         ."<a class='catheader' href='index.pl?iid=$app_root&amp;app=$name'>";
  186             if($img){
  187                 $app_list .="<img src='$fileuploaddir/$iid/$img' border=\"0\"><br />";
  188             }
  189 
  190             $ app_list.= "$name</a> $edit $perm $delete </td>";
  191         }
  192     }
  193 
  194     $output .= ($app_list)? $app_list : "<td>&nbsp;</td>";
  195 
  196     $output .= "</tr></table>";
  197     if ($appcount) {
  198     return $output;
  199     }
  200     else {          # if no apps, don't return the containing table.
  201     return "";
  202     }
  203 
  204 }
  205 
  206 1;
  207 
  208 __END__
  209 
  210 =head1 NAME
  211 
  212 Application - gizmo for creating a link to an application. This link will appear above the
  213               category listing on the main page.
  214 
  215 =head1 SYNOPSIS
  216 
  217     $application = Application->new($id)
  218 
  219     $AC = $application->get_AC();
  220     $boolean = $application->get_is_public();
  221     $html = $application->show();
  222     $html = Application->show_application_bar();
  223     Application->get_version();
  224 
  225 =head1 DESCRIPTION
  226 
  227 This gizmo creates a link for Applications to appear in an application bar above the category
  228 bar on the default layout of the system.
  229 
  230 =head1 Methods
  231 
  232 constructor
  233 
  234     Gizmo::Application->new($id);
  235 
  236 Called by the metadot framework, this method should not be called.
  237 
  238     $AC = $application->get_AC();
  239 
  240 Called by the metadot framework. This method is used to determine if a gizmo should appear in
  241 the dropdown list of gizmos.
  242 
  243     $boolean = $application->get_is_public();
  244 
  245 This class method gets all applications that have been created and builds the application
  246 bar out of them.
  247 
  248     $html = Application->show_application_bar();
  249 
  250 This class method retrieves the version of the gizmo:
  251 
  252     Application->get_version();
  253 
  254 
  255 =cut