#!/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: chatconfig.html #"""""""""""""""""""""""""""""""""""""""""# # # # MimerDesk: chat configtool # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream OY 1999 - 2001 # # # # Programmed by: Teemu Vainio # # # #_________________________________________# use strict; use vars qw ($APPLICATION $ACTIVEGRP $ARTICLE $MONTH $USER $IP $LAST_ACT $FORWARDED $TIME_USED $IDLE $form $ref $sth $chatroomlist $trans); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; sub print_chatconfig; sub print_template; $APPLICATION='Tools - Chatconfig'; ###################### # # Main program # # 1. Does the basic i-system stuff # 2. If order isn't given, use the default values.. # 3. Gets chatroomlist from database # 4. Prints template read_config('../config/mimerdesk.cfg'); initialize(); $form = decode_multipart(); $form->{'ID'} =~ tr/0-9//cd; $form->{'auth'} =~ tr/0-9a-z//cd; ($USER, $IP, $LAST_ACT, $FORWARDED, $TIME_USED, $IDLE, $ACTIVEGRP) = authenticate($form->{'ID'}, $form->{'auth'}, $form->{'changeGroup'}); $trans = lib::MimerDesk->new_gettext(program => 'chatconfig',language => $config{'language'}); $APPLICATION = $trans->gettext('Tools - Chatconfig'); my $admin_status; 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 !~ /C0/; $chatroomlist=''; if ($form->{'order'} eq ''){$form->{'order'} = 'NAME';} print_chatconfig(); print_template("$config{'theme'}_chatconfig"); ########################## # ____ # # ___ | | | \ ___ # # / \ | | | / / \ # # \___ | | |--< \___ # # \ | | | \ \ # # \___/ \__/ |___/ \___/ # # # ########################## ############## # print_chatconfig # # Gets chatroom information from db and forms it for viewing # # 1. Gets information from db # 2. Forms complete chatroom list and saves it into $chatroomlist # sub print_chatconfig { my ($name, $topic, $founder, $id, @row); lock_tables('READ','chatrooms'); db_list("SELECT * FROM chatrooms order by '$form->{'order'}'"); while (my $ref = $sth->fetchrow_hashref()) { $name = $ref->{'NAME'}; $topic = $ref->{'TOPIC'}; $founder = $ref->{'FOUNDER'}; $id = $ref->{'ID'}; $topic =~ s/^(<.+?>)//; $topic = urlify($topic); ($name, $founder) = html_escape ($name, $founder); $name = tagged('a',{href => "chatconfig_add.html?auth=$form->{'auth'}&ID=$form->{'ID'}&action=edit&number=$id&order=$form->{'order'}", content => $name}); $chatroomlist .= startrow(); $chatroomlist .= column(bgcolor => 'white', class => 'content', content => $name); $chatroomlist .= column(bgcolor => 'white', class => 'content', content => $founder); $chatroomlist .= column(bgcolor => 'white', class => 'content', content => $topic); $chatroomlist .= endrow(); } db_end(); unlock_tables(); unless ($chatroomlist) { $chatroomlist .= startrow(). column(colspan => '3', class => 'content', bgcolor => 'white', align => 'center', content => tagged('b',{content => $trans->gettext('No chat channels.') })). endrow(); } } ############################# # print_template # # Prints template # sub print_template { my ($template, $ref, $fulltemplate); $template = shift; print_header('pragma'); $ref = get_template('maintemplate',$template); $ref->{'maintemplate'} =~ s/<>/$ref->{$template}/m; $fulltemplate = $ref->{'maintemplate'}; $fulltemplate = create_buttons($fulltemplate, 'Communication', 'Chat', $form); $fulltemplate =~ s/<>/minea/gm; $ref = get_template('js_doClock', 'js_help', 'js_gotosite'); my $stuff = $ref->{'js_doClock'}.$ref->{'js_help'}.$ref->{'js_gotosite'}; $fulltemplate =~ s/<>/$stuff/ms; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; $fulltemplate =~ s/<>/$chatroomlist/ms; $fulltemplate =~ s/<>/$form->{'order'}/gm; $fulltemplate = replace_tags($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}, $TIME_USED); $fulltemplate = add_popups($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}); print $fulltemplate; db_end('disconnect'); exit; }