#!/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: group.html,v 1.49 2002/07/15 20:33:10 inf Exp $ ########################################### # # # MimerDesk: Projects - Info # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Oy 1999 - 2001 # # # # Programmed by: Teemu Arina # # Modified by: Hannes Muurinen # # # ########################################### # Asetukset ################################## use strict; use vars qw ($APPLICATION $ACTIVEGRP $USER $IP $LAST_ACT %FILEPICS $IMAGEDIR $FORWARDED $index_news_count $DESKTOP $TIME_USED $IDLE $form $ref $sth @months @days %ltoggles %rtoggles @DESKTOP $trans); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; sub print_template; sub create_box; sub get_members; sub get_files; sub get_links; sub get_calevents; sub get_posts; sub dicsort; sub get_groupinfo; sub toggle; sub get_vote; $index_news_count = 10; $APPLICATION = "Group - Group Info"; my %FILEPICS = ( default => 'rf-default.gif', # Images # Sounds jpg => 'rf-image.gif', wav => 'rf-audio.gif', gif => 'rf-image.gif', au => 'rf-audio.gif', png => 'rf-image.gif', aiff => 'rf-audio.gif', pcx => 'rf-image.gif', aif => 'rf-audio.gif', bmp => 'rf-image.gif', snd => 'rf-audio.gif', tiff => 'rf-image.gif', raw => 'rf-audio.gif', tif => 'rf-image.gif', xm => 'rf-audio.gif', tga => 'rf-image.gif', s3m => 'rf-audio.gif', xpm => 'rf-image.gif', it => 'rf-audio.gif', psd => 'rf-ps.gif', midi => 'rf-midi.gif', cdr => 'rf-corel.gif', mid => 'rf-midi.gif', cfl => 'rf-corel.gif', mp3 => 'rf-mp3.gif', bpt => 'rf-corel.gif', pls => 'rf-mp3.gif', cmv => 'rf-corel.gif', rd3 => 'rf-corel.gif', shw => 'rf-corel.gif', # Documents # Sourcecode html => 'rf-webdoc.gif', c => 'rf-source.gif', htm => 'rf-webdoc.gif', pl => 'rf-source.gif', xml => 'rf-webdoc.gif', py => 'rf-source.gif', css => 'rf-webdoc.gif', java => 'rf-source.gif', pdf => 'rf-acrobat.gif', sh => 'rf-source.gif', sgml => 'rf-text.gif', jar => 'rf-source.gif', latex => 'rf-text.gif', hxx => 'rf-source.gif', tex => 'rf-text.gif', h => 'rf-source.gif', lyx => 'rf-text.gif', hpp => 'rf-source.gif', txt => 'rf-text.gif', cpp => 'rf-source.gif', faq => 'rf-text.gif', cxx => 'rf-source.gif', nfo => 'rf-text.gif', js => 'rf-source.gif', ps => 'rf-acrobat.gif', awk => 'rf-source.gif', doc => 'rf-doc.gif', cfm => 'rf-source.gif', rtf => 'rf-rtf.gif', asm => 'rf-source.gif', xls => 'rf-xls.gif', pm => 'rf-source.gif', ppt => 'rf-ppt.gif', pps => 'rf-ppt.gif', ksp => 'rf-xls.gif', swf => 'rf-flash.gif', # Packages # Video zip => 'rf-zip.gif', ram => 'rf-real.gif', rar => 'rf-zip.gif', ra => 'rf-real.gif', arj => 'rf-zip.gif', avi => 'rf-video.gif', gz => 'rf-zip.gif', mpg => 'rf-video.gif', tar => 'rf-zip.gif', mpeg => 'rf-video.gif', bz2 => 'rf-zip.gif', mov => 'rf-video.gif', ace => 'rf-zip.gif', vfw => 'rf-video.gif', tgz => 'rf-zip.gif', # Other exe => 'rf-app.gif', class => 'rf-app.gif', com => 'rf-app.gif', bat => 'rf-app.gif', ini => 'rf-ini.gif', cfg => 'rf-ini.gif', mmp => 'rf-visio.gif', vss => 'rf-visio.gif', vsd => 'rf-visio.gif', vsw => 'rf-visio.gif', plt => 'rf-autocad.gif', ); # Program ################################## read_config('../config/mimerdesk.cfg'); $IMAGEDIR = $config{'loc_pictures'}; $IMAGEDIR =~ s/([^\/]*)$//; $IMAGEDIR .= 'files'; 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 => 'groupdesk',language => $config{'language'}); $APPLICATION = $trans->gettext("Group - Group Info"); %ltoggles = ( files => [1, 1, $trans->gettext('Latest files'), 0,'latestfiles.gif'], voting => [1, 2, $trans->gettext('Latest vote topic'), 1, 'tasks.gif'], links => [1, 3, $trans->gettext('Latest links'), 2,'latestlinks.gif'], members => [1, 4, $trans->gettext('Other online group members'), 3,'currentusers.gif'], ); %rtoggles = ( calevents => [1, 1, $trans->gettext('Upcoming calendar events'), 4,'cocaevents.gif'], groupinfo => [1, 2, $trans->gettext('Group information'), 5,'mygroups.gif'], posts => [1, 3, $trans->gettext('Latest posts to the forums'), 6,'latestposts.gif'], news => [1, 4, $trans->gettext('Latest news headlines'), 7,'laneheadlines.gif'], ); @months = ( '', $trans->gettext('January'), $trans->gettext('February'), $trans->gettext('March'), $trans->gettext('April'), $trans->gettext('May'), $trans->gettext('June'), $trans->gettext('July'), $trans->gettext('August'), $trans->gettext('September'), $trans->gettext('October'), $trans->gettext('November'), $trans->gettext('December') ); @days = ( $trans->gettext('Sunday'), $trans->gettext('Monday'), $trans->gettext('Tuesday'), $trans->gettext('Wednesday'), $trans->gettext('Thursday'), $trans->gettext('Friday'), $trans->gettext('Saturday') ); if ($form->{'toggle'} =~ /[0-9]/) { if (($ref) = db_select("GRPNAME,DESCRIPTION","groups","GID = '$ACTIVEGRP'")) { ($DESKTOP) = db_select("DESKTOP","groupusers","GID = '$ACTIVEGRP' and USER = '$USER'"); @DESKTOP = split //, $DESKTOP->{'DESKTOP'}; $DESKTOP = $DESKTOP->{'DESKTOP'}; toggle($form->{'toggle'}); print_template("$config{'theme'}_group",$ref); } else {print_template("$config{'theme'}_nogroup");} } else { if (($ref) = db_select("GRPNAME,DESCRIPTION","groups","GID = '$ACTIVEGRP'")) { ($DESKTOP) = db_select("DESKTOP","groupusers","GID = '$ACTIVEGRP' and USER = '$USER'"); @DESKTOP = split //, $DESKTOP->{'DESKTOP'}; $DESKTOP = $DESKTOP->{'DESKTOP'}; print_template("$config{'theme'}_group",$ref); } else {print_template("$config{'theme'}_nogroup");} } ################## # Toggle boxes # ################## sub toggle { my ($toggle) = shift; my $right = keys %rtoggles; my $left = keys %ltoggles; if (@DESKTOP != ($left + $right)) { @DESKTOP = (); foreach (keys %rtoggles) {push @DESKTOP, $rtoggles{$_}->[0];} foreach (keys %ltoggles) {push @DESKTOP, $ltoggles{$_}->[0];} } if (@DESKTOP[$toggle] eq '0') {@DESKTOP[$toggle] = '1';} elsif (@DESKTOP[$toggle] eq '1') {@DESKTOP[$toggle] = '0';} $DESKTOP = join "", @DESKTOP; lock_tables('WRITE', 'groupusers'); db_update('groupusers',{DESKTOP => $DESKTOP},"GID = '$ACTIVEGRP' and USER = '$USER'"); unlock_tables(); } ################################## # Create a box for the desktop # ################################## sub create_box { my ($title,$toggle,$content,$box,$link,$startimage,$buttons) = @_; if ($toggle) { $buttons .= tagged('a', { href => "group.html?ID=$form->{'ID'}&auth=$form->{'auth'}&toggle=$box&grouptool=$ACTIVEGRP", content => image(src => "$config{'loc_pictures2'}/minea/maximize.gif", height => 20, width => 20, align => 'absmiddle', alt => $trans->gettext('Minimize this box') ) }); } else { $buttons .= tagged('a', { href => "group.html?ID=$form->{'ID'}&auth=$form->{'auth'}&toggle=$box&grouptool=$ACTIVEGRP", content => image(src => "$config{'loc_pictures2'}/minea/minimize.gif", height => 20, width => 20, align => 'absmiddle', alt => $trans->gettext('Maximize this box') ) }); } if ($link) { $title = tagged('a',{href => "$config{'bin_dir'}/${link}auth=$form->{'auth'}&ID=$form->{'ID'}&grouptool=$ACTIVEGRP", onMouseOver => 'doClock(); return true', class => 'blackTitleLink', content => $title}); } $startimage = column(width => '1%',content => image(align => 'absmiddle', width => 20, height => 20, src => "$config{'loc_pictures'}/$startimage")) if $startimage; my $box = starttable(width => '95%',align => 'center',cellspacing => 1,cellpadding => 4,gridcolor => 'black'). startrow(). column(bgcolor => '#CEDFE8', content => starttable(). startrow(). $startimage. column(width => '94%',class => 'blackTitle', content => ' '.$title). column(width => '5%',align => 'right', content => $buttons). endrow(). endtable() ). endrow(). startrow(bgcolor => 'white'); if ($toggle) { $box .= column(valign => 'top', class => 'content', content => $content); } $box .= endrow(). endtable('hasgrid').tag('br'); return $box; } ############################## # Get members of the group # ############################## sub get_members { my ($number_of_logged, @users, %onlinetimes,$members); lock_tables('READ', 'sessions','users','groupusers'); db_list("select sessions.USER,users.info,sessions.LAST_ACT from sessions,users,groupusers where groupusers.GID = '$ACTIVEGRP' and sessions.USER = users.nimi and users.nimi = groupusers.USER order by users.info"); while (my $ref = $sth->fetchrow_hashref()) { my $idleTime = time() - $ref->{'LAST_ACT'}; $idleTime = $idleTime / 60; $idleTime = int ($idleTime + 0.5); next if $idleTime > $config{'idle_limit'}; push @users, [$ref->{'USER'},$ref->{'info'}] if $ref->{'USER'} ne $USER && !exists($onlinetimes{$ref->{'USER'}}); $onlinetimes{$ref->{'USER'}} = $idleTime if !exists($onlinetimes{$ref->{'USER'}}) || $onlinetimes{$ref->{'USER'}} > $idleTime; } db_end(); unlock_tables(); $number_of_logged = @users; if (@users) { $members = starttable(); foreach (@users) { $members .= startrow(). column(class => 'content',width => '1%',content => tagged('a', {href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$_->[0]", onMouseOver => 'doClock(); return true', class=> 'blackTitleSec', content => $_->[0]})). column(class => 'content',width => '98%',content => ' '.' '.' '.tagged('a', {class => 'contentLinkBlue', href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$_->[0]", onMouseOver => 'doClock(); return true', content => $_->[1]})). column(class => 'content', align => 'right', width => '1%', content => ' '.tagged('font',{color => 'grey', content => "$onlinetimes{$_->[0]} ". $trans->gettext('min'). " ". $trans->gettext('idle') })). endrow(); } $members .= endtable(); $members .= tagged('span',{class => 'graySmall', content => sprintf($trans->gettext('Total: %s'),$number_of_logged)}) if $number_of_logged; } $members = $trans->gettext('No other group members online.') if !$number_of_logged; return $members; } ############################ # Get files of the group # ############################ sub get_files { my ($files, $filelink, $filepic, $counter); lock_tables('READ', "${ACTIVEGRP}_filedescs"); db_list("select FILENAME,UPLOADER,MODIFIED,REVISION,PATH from ${ACTIVEGRP}_filedescs order by MODIFIED DESC"); while (my $ref = $sth->fetchrow_hashref()) { unless (-e "$config{'file_dir'}/groups/$ACTIVEGRP$ref->{'PATH'}$ref->{'FILENAME'}") { write_log("Error accessing $config{'file_dir'}/groups/$ACTIVEGRP$ref->{'PATH'}$ref->{'FILENAME'}!: $!",'error'); next; } next unless -f _; $counter++; ($ref->{'PATH'},$filelink) = encodeurl($ref->{'PATH'},$ref->{'FILENAME'}); my @fileinfo = stat(_); my (undef,undef,undef,$mday,$mon,$year) = utc_epoch2date($fileinfo[9]); my $myext = get_extension($ref->{'FILENAME'}); if ($FILEPICS{$myext}) {$filepic = $FILEPICS{$myext};} else {$filepic = $FILEPICS{'default'};} $files .= startrow(). column(class => 'content', valign=>'top', content => image(src => "$IMAGEDIR/$filepic", align => 'absmiddle').' '. tagged('a',{href => "files.html?auth=$form->{'auth'}&ID=$form->{'ID'}&edit=1&cat=$ref->{'PATH'}&dl=$filelink&grouptool=$ACTIVEGRP", class => 'contentLinkBlue', content => $ref->{'FILENAME'}} )). column(class => 'content', valign=>'top', content =>tagged('center',{content => $ref->{'REVISION'} })). column(class => 'content', valign=>'top', content =>tagged('center',{content => "$year/$mon/$mday" })). endrow(); last if $counter == 5; } db_end(); unlock_tables(); $files = starttable(cellpadding => 2). startrow(). column(class => 'blackTitle',content => $trans->gettext('Filename')). column(class => 'blackTitle',content => tagged('center',{content => $trans->gettext('Version')})). column(class => 'blackTitle',content => tagged('center',{content => $trans->gettext('Date')})). endrow().$files.endtable() if $files; $files = $trans->gettext('No files.') if !$files; return $files; } ############################ # Get links of the group # ############################ sub get_links { my ($links); lock_tables('READ', "${ACTIVEGRP}_resindex"); db_list("select link_url,link_name from ${ACTIVEGRP}_resindex order by number DESC LIMIT 5"); while (my $ref = $sth->fetchrow_hashref()) { my $domain = $ref->{'link_url'}; $domain =~ s/^.+?:\/\///; $domain =~ s/^(.+?)\/.*$/$1/ if $domain =~ /\//; my @domain = split /\./, $domain; $domain = "$domain[-2].$domain[-1]"; $links .= tagged('a',{href => "$ref->{'link_url'}", class => 'contentLinkBlue', target => 'blank_', content => $ref->{'link_name'} }). ' - '. tagged('span',{ class => 'graySmall', content => $domain}). tag('br'); } db_end(); unlock_tables(); $links =~ s/(.*)
$/$1/ if $links; $links = $trans->gettext('No links.') if !$links; return $links; } ############ # Vote # ############ sub get_vote { my(@votes, @uservid, $vid, $cnt, $votedesk, %voteinfo, @vars, $ref,$count); lock_tables('READ', "${ACTIVEGRP}_votes", "${ACTIVEGRP}_vote_users"); db_list("select VID, EXPIRATION, STATUS from ${ACTIVEGRP}_votes order by vid desc"); while ($ref = $sth->fetchrow_hashref()) { if ($ref->{'EXPIRATION'} < time() || $ref->{'STATUS'} == 0) { next; } else { push @votes, $ref->{'VID'}; } } db_end(); db_list("select VID from ${ACTIVEGRP}_vote_users where user = '$USER' order by vid desc"); while ($ref = $sth->fetchrow_hashref()) { push @uservid, $ref->{'VID'}; } db_end(); foreach my $voteid (@votes) { if (!grep {$_ eq $voteid} @uservid) { $vid = $voteid; last; } } unlock_tables(); return $trans->gettext('No new votes.') if !$vid; lock_tables('READ', "${ACTIVEGRP}_vote_vars", "${ACTIVEGRP}_votes"); db_list("select ${ACTIVEGRP}_votes.TOPIC,${ACTIVEGRP}_vote_vars.VID,${ACTIVEGRP}_vote_vars.VAR from ${ACTIVEGRP}_vote_vars,${ACTIVEGRP}_votes where ${ACTIVEGRP}_votes.VID = '$vid' and ${ACTIVEGRP}_vote_vars.VID = ${ACTIVEGRP}_votes.VID order by ${ACTIVEGRP}_vote_vars.VARID"); while ($ref = $sth->fetchrow_hashref()) { $voteinfo{'topic'} = $ref->{'TOPIC'}; $voteinfo{'vid'} = $ref->{'VID'}; push @vars, $ref->{'VAR'}; } db_end(); unlock_tables(); $votedesk .= tagged('a',{href => "vote.html?auth=$form->{'auth'}&ID=$form->{'ID'}&vid=$voteinfo{'vid'}&grouptool=$ACTIVEGRP", class => 'blackTitleLink', content => $voteinfo{'topic'}}).hrline().tag('br'); $cnt = 0; foreach (@vars) { $count++; $votedesk .= "$count. ". tagged('a', {href => "vote.html?ID=$form->{'ID'}&auth=$form->{'auth'}&vid=$voteinfo{'vid'}&vote=$cnt&grouptool=$ACTIVEGRP", content => $_.' '}). tag('br'); $cnt++; } unlock_tables(); return ($votedesk); } ###################################### # Get calendar events of the group # ###################################### sub get_calevents { my ($i,$new,$calevents,$day,$last,$endday); my $current_epoch = time(); lock_tables('READ', "${ACTIVEGRP}_calendar"); foreach $ref (db_select("epoch,time,end_epoch,summary,IDnumber","${ACTIVEGRP}_calendar","epoch >= '$current_epoch'","epoch")) { $i++; last if $i > $index_news_count; my (undef,$lmin,$lhour,$lday,$lmonth,$lyear,$day_of_week) = utc_epoch2date($ref->{'epoch'}); my (undef,$emin,$ehour,$eday,$emonth,$eyear,$eday_of_week) = utc_epoch2date($ref->{'end_epoch'}); $day = "$months[$lmonth] $lyear"; if ($last ne $day) { $calevents .= endtable() if $calevents; $calevents .= tag('br') if $last; $calevents .= tagged('a',{href => "calendar.html?auth=$form->{'auth'}&ID=$form->{'ID'}&view=month&year=$lyear&month=$lmonth&grouptool=$ACTIVEGRP", class => 'blackTitleLink', content => $day}). hrline().tag('br'); $calevents .= starttable(width => '100%'); } $last = $day; if ($lday eq $eday && $lmonth eq $emonth) {$endday = "$ehour:$emin";} else { $endday = tagged('a',{href => "calendar.html?auth=$form->{'auth'}&ID=$form->{'ID'}&view=day&year=$eyear&month=$emonth&day=$eday&grouptool=$ACTIVEGRP", class => 'graySmall', content => $eday } ) . '.' . tagged('a',{href => "calendar.html?auth=$form->{'auth'}&ID=$form->{'ID'}&view=month&year=$eyear&month=$emonth&grouptool=$ACTIVEGRP", class => 'graySmall', content => $emonth } ) . " $ehour:$emin"; } my ($clock_and_end); $clock_and_end = "$lhour:$lmin~$endday" if $ref->{'time'} ne 'full'; $calevents .= startrow(). column(valign => 'top', width => 1, class => 'graySmall', content => "  " . tagged('a',{href => "calendar.html?auth=$form->{'auth'}&ID=$form->{'ID'}&view=day&year=$lyear&month=$lmonth&day=$lday&grouptool=$ACTIVEGRP", class => 'graySmall', content => $days[$day_of_week] } ) . " " ). column(valign => 'top', width => 120, class => 'graySmall', content => tagged('a',{href => "calendar.html?auth=$form->{'auth'}&ID=$form->{'ID'}&view=day&year=$lyear&month=$lmonth&day=$lday&grouptool=$ACTIVEGRP", class => 'graySmall', content => $lday } ) . " $clock_and_end   " ). column(valign => 'top', width => '90%', class => 'content', content => tagged('a',{href => "calendar.html?selectedGO=View&auth=$form->{'auth'}&ID=$form->{'ID'}&numofcheckboxes=1&checkb0=$ref->{'IDnumber'}&grouptool=$ACTIVEGRP", class => 'contentLinkBlue', content => $ref->{'summary'} } ) ). endrow(); } unlock_tables(); $calevents .= endtable() if $calevents; $calevents = $trans->gettext('No upcoming calendar events.') if !$calevents; return $calevents; } ###################### # Get list of news # ###################### sub get_news { my ($new,$headlines,$day,$last,%months); my $lastvisit = shift; lock_tables('READ', "${ACTIVEGRP}_md_news", 'users'); foreach $ref (db_select("${ACTIVEGRP}_md_news.headline,${ACTIVEGRP}_md_news.IDnumber,${ACTIVEGRP}_md_news.epoch,users.nimi,users.info","${ACTIVEGRP}_md_news, users","${ACTIVEGRP}_md_news.senderID = users.UID","${ACTIVEGRP}_md_news.epoch DESC","$index_news_count")) { my (undef,undef,undef,undef,$lmonth,$lyear) = utc_epoch2date($ref->{'epoch'}); $day = local_date2date_string(undef,undef,undef,undef,$lmonth,$lyear,'%sm %y'); $headlines .= tag('br') if $last && $last ne $day; $headlines .= tagged('a',{href => "md_news.html?month=$lmonth&year=$lyear&auth=$form->{'auth'}&ID=$form->{'ID'}&grouptool=${ACTIVEGRP}", class => 'blackTitleLink', content => $day}). hrline().tag('br') if $last ne $day; $last = $day; if ($ref->{'submitted'} > $lastvisit) {$new = tagged('font',{color => 'red',content => '*'});} else {$new = '  ';} $headlines .= $new. tagged('a',{href => "md_news.html?month=$lmonth&year=$lyear&auth=$form->{'auth'}&ID=$form->{'ID'}&newsID=$ref->{'IDnumber'}&grouptool=${ACTIVEGRP}", class => 'contentLinkBlue', content => $ref->{'headline'} } ). tagged('span',{class => 'graySmall', content => " - "}). tagged('a', {href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$ref->{'nimi'}", onMouseOver => 'doClock(); return true', class=> 'graySmall', content => $ref->{'info'}}). tag('br'); } unlock_tables(); $headlines = $trans->gettext('No news.') if !$headlines; return $headlines; } ############################ # Get posts of the group # ############################ sub get_posts { my ($new,$posts,%forums,$postings,@forums,%forumids); my $lastvisit = shift; lock_tables('READ', "${ACTIVEGRP}_mboards","${ACTIVEGRP}_boardconfig",'users','unreadMSG'); foreach $ref (db_select("${ACTIVEGRP}_mboards.forum as forum,users.info,users.nimi,${ACTIVEGRP}_mboards.postdate,${ACTIVEGRP}_mboards.id,${ACTIVEGRP}_mboards.thread_id,${ACTIVEGRP}_mboards.topic,${ACTIVEGRP}_boardconfig.forum as forum2","${ACTIVEGRP}_mboards,${ACTIVEGRP}_boardconfig,users,unreadMSG","${ACTIVEGRP}_mboards.forum = ${ACTIVEGRP}_boardconfig.id and ${ACTIVEGRP}_mboards.sender = users.nimi and unreadMSG.user='$USER' and unreadMSG.msgID=${ACTIVEGRP}_mboards.id and unreadMSG.msgTable='${ACTIVEGRP}_mboards'","${ACTIVEGRP}_mboards.postdate DESC","$index_news_count")) { $ref->{'id'} = $ref->{'thread_id'} if $ref->{'thread_id'}; if (length($ref->{'topic'}) > 50) { $ref->{'topic'} = substr $ref->{'topic'}, 0, 48; $ref->{'topic'} .= "..."; } if ($ref->{'postdate'} > $lastvisit) {$new = tagged('font',{color => 'red',content => '*'});} else {$new = '  ';} $posts = $new. tagged('a',{href => "boards.html?board=$ref->{'forum'}&mid=$ref->{'id'}&auth=$form->{'auth'}&ID=$form->{'ID'}&grouptool=$ACTIVEGRP&record=yes", class => 'contentLink', content => tagged('font',{class => 'contentLinkBlue', content => $ref->{'topic'} } ) } ). tagged('span',{class => 'graySmall', content => " - "}). tagged('a', {href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$ref->{'nimi'}", onMouseOver => 'doClock(); return true', class=> 'graySmall', content => $ref->{'info'}}). tag('br'); push @{$forums{$ref->{'forum2'}}}, $posts; $forumids{$ref->{'forum2'}} = $ref->{'forum'}; } unlock_tables(); foreach (sort dicsort keys %forums) { $postings = tagged('a',{href => "boards.html?board=$forumids{$_}&auth=$form->{'auth'}&ID=$form->{'ID'}&grouptool=$ACTIVEGRP", class => 'blackTitleLink', content => $_}). hrline().tag('br'); foreach (@{$forums{$_}}) {$postings .= $_;} push @forums, $postings; } $postings = join tag('br'), @forums; $postings = $trans->gettext('No posts.') if !$postings; return $postings; } #"""""""""""""""""""""""""""""""""""""""# # dicsort - Use dictionary sort # #---------------------------------------# # sort dicsort @array # #_______________________________________# sub dicsort { # Someone should write this function again so # that it will use some kind of sorting algorithm! my $da = lc $a; my $db = lc $b; $da =~ s/[\W_]+//g; $db =~ s/[\W_]+//g; $da cmp $db; } ########################### # Get group information # ########################### sub get_groupinfo { my $groupinfo = starttable(); lock_tables('READ','groups','users'); db_list("select groups.DESCRIPTION,groups.CREATED,groups.EMAIL,groups.HOMEPAGE,groups.ADDRESS,groups.PHONE,groups.CREATOR,users.info from groups,users where users.nimi = groups.CREATOR and groups.GID = '$ACTIVEGRP'"); while (my $ref = $sth->fetchrow_hashref()) { my (undef,undef,undef,$mday,$mon,$year) = utc_epoch2date($ref->{'CREATED'}); my $age = time() - $ref->{'CREATED'}; $age /= 60; $age /= 60; $age /= 24; $age = int($age); $age = $trans->gettext("One day old") if $age < 2; $age = sprintf($trans->gettext("%s days old"), $age) if $age > 1; if ($age > 0) { $ref->{'CREATED'} = "$year/$mon/$mday ($age)"; } else { $ref->{'CREATED'} = "$year/$mon/$mday"; } $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Group admin').'   '})). column(class => 'content',width => '99%',content => tagged('a', {href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$ref->{'CREATOR'}", onMouseOver => 'doClock(); return true', class=> 'contentLinkBlue', content => $ref->{'CREATOR'}})." ($ref->{'info'})"). endrow(); $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Group created').'   '})). column(class => 'content',width => '99%',content => $ref->{'CREATED'}). endrow(); $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('E-mail').'   '})). column(class => 'content',width => '99%',content => tagged('a', { href => "mailto:$ref->{'EMAIL'}", content => $ref->{'EMAIL'} } )). endrow() if $ref->{'EMAIL'}; $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Homepage').'   '})). column(class => 'content',width => '99%',content => urlify($ref->{'HOMEPAGE'})). endrow() if $ref->{'HOMEPAGE'}; $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Address').'   '})). column(class => 'content',width => '99%',content => $ref->{'ADDRESS'}). endrow() if $ref->{'ADDRESS'}; $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Phone').'   '})). column(class => 'content',width => '99%',content => $ref->{'PHONE'}). endrow() if $ref->{'PHONE'}; $groupinfo .= startrow(). column(class => 'content',valign => 'top',width => '1%',content => tagged('b',{content => $trans->gettext('Description').'   '})). column(class => 'content',width => '99%',content => itag_replacer($ref->{'DESCRIPTION'})). endrow() if $ref->{'DESCRIPTION'}; } db_end(); unlock_tables(); $groupinfo .= endtable(); return $groupinfo; } ################################## # Read template and process it # ################################## sub print_template { my ($template,$ref,$fulltemplate,$current_date,@RIGHT,@LEFT,$lastvisit,$tools); $template = shift; my $groupinfo = shift; print_header('pragma'); $ref = get_template('maintemplate',$template); $ref->{'maintemplate'} =~ s/<>/$ref->{$template}/m; $fulltemplate = $ref->{'maintemplate'}; $ref = get_template('js_doClock', 'js_help', 'js_gotosite'); my $stuff = join "", ($ref->{'js_doClock'},$ref->{'js_help'},$ref->{'js_gotosite'}); $fulltemplate =~ s/<>/$stuff/ms; $fulltemplate = create_buttons($fulltemplate, 'Group', 'Group Info', $form); $fulltemplate =~ s/<>/minea/gm; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; if ($template eq "$config{'theme'}_group") { lock_tables('READ','users','groups'); db_list("SELECT lastpage FROM users where nimi = '$USER'"); while (my $ref = $sth->fetchrow_hashref()) {$lastvisit = $ref->{'lastpage'};} db_end(); db_list("SELECT TOOLS FROM groups where GID = '$ACTIVEGRP'"); while (my $ref = $sth->fetchrow_hashref()) {$tools = $ref->{'TOOLS'};} db_end(); unlock_tables(); foreach (keys %ltoggles) { next if !$ltoggles{$_}->[0]; if ($_ eq 'members') { $LEFT[$ltoggles{$_}->[1]] = create_box($ltoggles{$_}->[2],$DESKTOP[3],get_members(), $ltoggles{$_}->[3],'',$ltoggles{$_}->[4]); } elsif ($_ eq 'files' && $tools =~ /F/) { $LEFT[$ltoggles{$_}->[1]] = create_box($ltoggles{$_}->[2],$DESKTOP[0],get_files(), $ltoggles{$_}->[3], 'files.html?',$ltoggles{$_}->[4]); } elsif ($_ eq 'voting' && $tools =~ /V/) { $LEFT[$ltoggles{$_}->[1]] = create_box($ltoggles{$_}->[2], $DESKTOP[1],get_vote(), $ltoggles{$_}->[3], 'vote.html?', $ltoggles{$_}->[4]); } elsif ($_ eq 'links' && $tools =~ /L/) { $LEFT[$ltoggles{$_}->[1]] = create_box($ltoggles{$_}->[2],$DESKTOP[2],get_links(), $ltoggles{$_}->[3], 'resources.html?',$ltoggles{$_}->[4]); } } foreach (keys %rtoggles) { next if !$rtoggles{$_}->[0]; if ($_ eq 'calevents' && $tools =~ /C/) { $RIGHT[$rtoggles{$_}->[1]] = create_box($rtoggles{$_}->[2],$DESKTOP[4],get_calevents(),$rtoggles{$_}->[3], 'calendar.html?',$rtoggles{$_}->[4]); } elsif ($_ eq 'groupinfo') { $RIGHT[$rtoggles{$_}->[1]] = create_box($rtoggles{$_}->[2],$DESKTOP[5],get_groupinfo(),$rtoggles{$_}->[3], "groups.html?info=info&GID=$ACTIVEGRP&",$rtoggles{$_}->[4]); } elsif ($_ eq 'news' && $tools =~ /N/) { # my $latestnews = get_news($lastvisit) if $DESKTOP[6]; $RIGHT[$rtoggles{$_}->[1]] = create_box($rtoggles{$_}->[2],$DESKTOP[7],get_news($lastvisit),$rtoggles{$_}->[3], "md_news.html?",$rtoggles{$_}->[4]); } elsif ($_ eq 'posts' && $tools =~ /M/) { $RIGHT[$rtoggles{$_}->[1]] = create_box($rtoggles{$_}->[2],$DESKTOP[6],get_posts($lastvisit),$rtoggles{$_}->[3], 'boards.html?',$rtoggles{$_}->[4]); } } ($ref->{'DESCRIPTION'}) = itag_replacer($ref->{'DESCRIPTION'}); $fulltemplate =~ s/<>/$groupinfo->{'GRPNAME'}/m; $fulltemplate =~ s/<>/$groupinfo->{'DESCRIPTION'}/m; my $RIGHT = join "", @RIGHT; my $LEFT = join "", @LEFT; $fulltemplate =~ s/<>/$LEFT/m; $fulltemplate =~ s/<>/$RIGHT/m; my ($sec,$min,$hour,$mday,$mon,$year,$day_of_week) = utc_epoch2date(time()); $current_date = "$days[$day_of_week] $mday @months[$mon] $year"; $fulltemplate =~ s/<>/$current_date/gm; } else { my $nogroup = $trans->gettext('No active group'); $fulltemplate =~ s/<>/$nogroup/m; my $error = $trans->gettext('You have no active group selected! Select a group to activate from the Active group drop-down menu in the upper right corner. If you are not a member of any group, go to the Projects -> Group Manager and find a group to join.'); $fulltemplate =~ s/<>/
$error<\/div>/m; } $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; }