#!/usr/bin/perl # MimerDesk # Web based groupware and eLearning environment # www.mimerdesk.org # # Copyright (C) 2001 Ionstream Ltd. # www.ionstream.fi # # 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. # # This program is distributed with a hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # $Id: editmail.html,v 1.8 2002/06/06 14:58:02 inf Exp $ ################################################# # # # MimerDesk: Users - Edit mail message # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Oy 1999 - 2001 # # # # Programmed by: Teemu Arina # # # ################################################# # Configuration ################################## use strict; use vars qw ($APPLICATION $ARTICLE $MONTH $USER $IP $LAST_ACT $FORWARDED $TIME_USED $IDLE $form $ref $sth $trans $htmlcolors $admin_status); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; $APPLICATION = 'Tools - Users'; sub print_template; sub update_message; sub get_message; # Program ################################## read_config('../config/mimerdesk.cfg'); $htmlcolors = initialize('colors'); $form = decode_multipart(); $form->{'ID'} =~ tr/0-9//cd; $form->{'auth'} =~ tr/0-9a-z//cd; ($USER, $IP, $LAST_ACT, $FORWARDED, $TIME_USED, $IDLE) = authenticate($form->{'ID'}, $form->{'auth'}); $trans = lib::MimerDesk->new_gettext(program => 'users',language => $config{'language'}); $APPLICATION = $trans->gettext("Tools - Users"); lock_tables('READ', 'users'); db_list("SELECT * FROM users where nimi = '$USER'"); while (my $ref = $sth->fetchrow_hashref()) {$admin_status = $ref->{'flags'};} db_end(); unlock_tables(); print_template("$config{'theme'}_accfailure") if $admin_status !~ /U0/; if ($form->{'edit'}) { update_message($form->{'subject'}, $form->{'message'}); my ($subject, $message) = get_message(); print_template("$config{'theme'}_editmailmessage", $subject, $message, 'success',$trans->gettext('Saved changes.') ); } else { my ($subject, $message) = get_message(); print_template("$config{'theme'}_editmailmessage", $subject, $message); } # Subroutines ################################## ################## # update message # ################## sub update_message { my ($subject,$message) = @_; ($subject,$message) = prepare_fordb($subject,$message); lock_tables('WRITE', 'mailmessages'); db_update('mailmessages',{subject => $subject, message => $message},"MID='1'"); unlock_tables(); } ############### # Get message # ############### sub get_message { my ($subject, $message); lock_tables('READ', 'mailmessages'); db_list("select * from mailmessages where MID = '1'"); while (my $ref = $sth->fetchrow_hashref()) { $subject = $ref->{'subject'}; $message = $ref->{'message'}; } db_end(); unlock_tables(); return ($subject, $message); } ############################ # Read template and print # ############################ sub print_template { my ($fulltemplate); my ($template, $subject, $message, $mode, $popuptext) = @_; print_header('pragma'); $ref = get_template($template); $fulltemplate = $ref->{$template}; $fulltemplate =~ s/<>/$mode/m; $fulltemplate =~ s/<>/$popuptext/m; $fulltemplate =~ s/<>/minea/gm; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; $fulltemplate = replace_tags($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}, $TIME_USED); ($subject, $message) = html_escape($subject, $message); $fulltemplate =~ s/<>/$subject/gm; $fulltemplate =~ s/<>/$message/gm; print $fulltemplate; db_end('disconnect'); exit; }