#!/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: groups.html,v 1.39 2002/07/29 19:34:58 inf Exp $ ########################################### # # # MimerDesk: Groups - Manage Groups # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Oy 1999 - 2001 # # # # Programmed by: Teemu Arina # # # ########################################### # Asetukset ################################## use strict; use vars qw ($APPLICATION $ACTIVEGRP $USER $IP $LAST_ACT $GROUPACTIVOR $ADMIN_RIGHTS $FORWARDED $TIME_USED $IDLE $form $ref $sth %create $default_admin_rights $gettext); use File::Path qw(rmtree); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; $APPLICATION = "Projects - Manage Groups"; $default_admin_rights = 'G0M0F0L0C0V0R0N0A0'; %create = ( 'boardconfig' => "id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, category varchar(100) NULL, forum varchar(100) NULL, moderator varchar(100) binary not NULL, description text NULL, monitors text NULL", 'mboards' => "id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, forum numeric(10,0) NULL, msg text NULL,postdate int unsigned NULL, topic varchar(100) NULL, sender varchar(80) binary not NULL, thread_id numeric(20,0) NULL, timesread numeric(20,0) default '0', rate numeric(1,0) NULL, type varchar(30) default 'smallnormal'", 'rescat' => "category varchar(50) DEFAULT '' NOT NULL PRIMARY KEY, description text", 'resindex' => "number int(10) unsigned DEFAULT '0' NOT NULL auto_increment PRIMARY KEY, category varchar(50) DEFAULT '' NOT NULL, link_url text, link_name text, description text", 'votes' => "VID int unsigned not null primary key auto_increment, DATE int unsigned not null, EXPIRATION int unsigned not null, ORGANIZER varchar(15) binary not null, STATUS int unsigned not null, TOPIC text null, DESCRIPTION text null", 'vote_users' => "VID int unsigned not null, USER varchar(15) binary not null, TIME int unsigned not null", 'vote_vars' => "VID int unsigned not null, VARID int unsigned not null, VAR text null, RESULT int unsigned not null default 0", 'calendar' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, user VARCHAR(25) binary not null, epoch INT, time VARCHAR(5), end_epoch INT, type VARCHAR(20), recrule VARCHAR(50), prevrec INT UNSIGNED, nextrec INT UNSIGNED, summary VARCHAR(100), text text, reminderID INT UNSIGNED", 'review_comment' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, user VARCHAR(15) binary not null, datetime INT, reviewID INT UNSIGNED, comment text", 'product_category' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), category VARCHAR(100), c0_name VARCHAR(50), c1_name VARCHAR(50), c2_name VARCHAR(50), c3_name VARCHAR(50), c4_name VARCHAR(50), description text null, moderator varchar(100) binary not null", 'product_info' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), custom0 VARCHAR(100), custom1 VARCHAR(100), custom2 VARCHAR(100), custom3 VARCHAR(100), custom4 VARCHAR(100), pub_datetime int, other_info text, picture VARCHAR(255), sender VARCHAR(15) binary not null, categoryID int unsigned", 'product_review' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, user VARCHAR(15) binary not null, datetime INT, productID INT UNSIGNED, review text, headline VARCHAR(255), rating INT UNSIGNED", 'md_news' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, senderID INT UNSIGNED NOT NULL, epoch INT UNSIGNED, headline varchar(150) NOT NULL, summary text NOT NULL, article text NOT NULL, category VARCHAR(50)", 'md_news_comment' => "IDnumber INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, newsID INT UNSIGNED NOT NULL, senderID INT UNSIGNED NOT NULL, epoch INT UNSIGNED, headline varchar(150) NOT NULL, article text NOT NULL", 'filedescs' => "FID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, FILENAME text NOT NULL, MODIFIED int unsigned not null, PATH text NOT NULL, REVISION varchar(10) default '1.0' not null, DOWNCOUNT int unsigned not NULL default 0, LOCKED int unsigned not NULL default 0, DATELOCKED int unsigned not NULL default 0, UPLOADER int unsigned NOT NULL, DESCRIPTION text NULL", 'revisionlog' => "FID INT UNSIGNED NOT NULL, REVISION varchar(10) default '1.0' not null, DESCRIPTION text NULL", 'filerights' => "FID INT UNSIGNED NOT NULL PRIMARY KEY, MODE int unsigned NOT NULL, USER int unsigned NOT NULL", 'addressbook' => "ID int(10) unsigned NOT NULL auto_increment primary key, GID int(10) unsigned NOT NULL, USER varchar(25) binary NOT NULL default '', NAME varchar(100) default NULL, FIRSTNAME varchar(100) default NULL, MIDDLENAME varchar(100) default NULL, LASTNAME varchar(100) default NULL, TITLE varchar(200) default NULL, STATUS varchar(200) default NULL, COMPANY varchar(200) default NULL, ADDRESS varchar(200) default NULL, POSTAL varchar(10) default NULL, CITY varchar(50) default NULL, PHONE varchar(30) default NULL, HOMEPHONE varchar(30) default NULL, MOBILE varchar(30) default NULL, FAX varchar(30) default NULL, EMAIL varchar(200) default NULL, WEBPAGE varchar(200) default NULL, INFO text, CATEGORY varchar(100) default NULL", ); sub print_template; sub add_group; sub remove_group; sub edit_group; sub join_group; sub part_group; sub invite_users; sub remove_members; # Program ################################## 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'}); $gettext = lib::MimerDesk->new_gettext(program => 'groupmanager',language => $config{'language'}); $APPLICATION = $gettext->gettext('Projects - Manage Groups'); if ($form->{'grouptool'} =~ /^\d+$/) { my ($test); lock_tables('READ', 'groupusers'); db_list("SELECT groupusers.USER FROM groupusers where groupusers.USER = '$USER' and groupusers.GID = '$form->{'grouptool'}'"); while (my $ref = $sth->fetchrow_hashref()) { $GROUPACTIVOR = $ref->{'USER'}; } db_end(); unlock_tables(); } lock_tables('READ', 'users'); db_list("SELECT flags FROM users where nimi = '$USER'"); while (my $ref = $sth->fetchrow_hashref()) {$ADMIN_RIGHTS = $ref->{'flags'};} db_end(); unlock_tables(); if ($form->{'quit'}) {redirect("$config{'loc_server'}$config{'bin_dir'}/index.html?ID=$form->{'ID'}&auth=$form->{'auth'}&quit=quit");} elsif ($form->{'create'}) { if ($ADMIN_RIGHTS =~ /G0/ || $config{'all_create_groups'} eq 'yes') { print_template("$config{'theme'}_groupcreate"); } } elsif ($form->{'newgroup'}) { if ($ADMIN_RIGHTS =~ /G0/ || $config{'all_create_groups'} eq 'yes') { add_group(); } } elsif ($form->{'GID'} =~ /^\d+$/) { my ($rights); lock_tables('READ', 'groupusers'); db_list("SELECT RIGHTS FROM groupusers where GID='$form->{'GID'}' and USER = '$USER'"); while (my $ref = $sth->fetchrow_hashref()) {$rights = $ref->{'RIGHTS'};} db_end(); unlock_tables(); if ($form->{'join'}) {join_group();} elsif ($form->{'part'}) {print_template("$config{'theme'}_grouppartconfirm");} elsif ($form->{'parted'}) {part_group();} elsif ($form->{'info'}) {print_template("$config{'theme'}_groupinfo");} if ($rights =~ /G0/ || $ADMIN_RIGHTS =~ /G0/) { if ($form->{'remove'}) {print_template("$config{'theme'}_groupconfirm");} elsif ($form->{'rmconfirm'}) {remove_group();} elsif ($form->{'manage'}) {print_template("$config{'theme'}_groupmanage");} elsif ($form->{'edit'}) {edit_group();} elsif ($form->{'invite'}) {print_template("$config{'theme'}_groupinvite");} elsif ($form->{'membremove'}) {print_template("$config{'theme'}_groupkick");} elsif ($form->{'startinvite'} && $form->{'invite_these'} =~ tr/a-z0-9_ //c == 0) {invite_users();} elsif ($form->{'removemembers'} && $form->{'invite_these'} =~ tr/a-z0-9_ //c == 0) {remove_members();} else {print_template("$config{'theme'}_grouplist");} } else {print_template("$config{'theme'}_grouplist");} } else {print_template("$config{'theme'}_grouplist");} #""""""""""""""# # join_group() # #--------------# # Join group # #______________# sub join_group { my ($nimi); lock_tables('READ', 'groupusers','groups','messages'); my ($user) = db_select('groupusers.USER','groupusers,groups',"groupusers.GID = '$form->{'GID'}' and groupusers.GID = groups.GID"); print_template("$config{'theme'}_grouplist") if !$user->{'USER'}; if(db_select('MESSAGE','messages',"TYPE = 'JOING' and SENDER = '$USER' and MESSAGE = '$form->{'GID'}'")) { unlock_tables(); print_template("$config{'theme'}_grouprejoin"); } unlock_tables(); lock_tables('WRITE', 'messages'); my $time = time(); db_list("insert into messages (TARGET,SENDER,TIME,STATUS,MESSAGE,TYPE) values ('$user->{'USER'}', '$USER', '$time', 'no','$form->{'GID'}','JOING')"); db_end(); unlock_tables(); print_template("$config{'theme'}_groupjoin"); } #""""""""""""""""# # invite_users() # #----------------# # Invite users # #________________# sub invite_users { my ($message); lock_tables('WRITE', 'messages'); $form->{'reason'} = substr $form->{'reason'}, 0, 800; $form->{'reason'} = prepare_fordb($form->{'reason'}); my $time = time(); foreach (split / /, $form->{'invite_these'}) { my ($nimi); next if db_select('MESSAGE','messages',"TYPE = 'INVITE' and TARGET = '$_' and MESSAGE like '$form->{'GID'},%'"); db_list("insert into messages (TARGET,SENDER,TIME,STATUS,MESSAGE,TYPE) values ('$_', '$USER', '$time', 'no','$form->{'GID'},$form->{'reason'}','INVITE')"); db_end(); } unlock_tables(); # Error ja success viestit eri väreillä?! if (!$form->{'invite_these'}) {$message = tag('div',{class => 'error'}).$gettext->gettext('You must select at least one user to invite!').endtag('div');} else { $form->{'invite_these'} =~ s/ /, /g; $message = tag('div',{class => 'success'}).$gettext->gettext('The following users have been invited: '). $form->{'invite_these'} . endtag('div'); } print_template("$config{'theme'}_groupinvite", $message); } #""""""""""""""""""# # remove_members() # #------------------# # Remove members # #__________________# sub remove_members { my ($message); lock_tables('READ', 'groups'); my ($user) = db_select('GRPNAME','groups',"GID = '$form->{'GID'}'"); unlock_tables(); lock_tables('WRITE', 'messages','groupusers'); $form->{'reason'} = substr $form->{'reason'}, 0, 800; $form->{'reason'} = prepare_fordb($form->{'reason'}); my $time = time(); my $message = sprintf($gettext->gettext('[B]You have been removed from the group %s![/B]\n\nThe reason was: %s'),$user->{'GRPNAME'},$form->{'reason'}); foreach (split / /, $form->{'invite_these'}) { my ($nimi); db_delete('groupusers',"USER = '$_' and GID = '$form->{'GID'}'"); db_list("insert into messages (TARGET,SENDER,TIME,STATUS,MESSAGE,TYPE) values ('$_', '$USER', '$time', 'no','$message','SHORT')"); db_end(); db_delete(); } unlock_tables(); # Error ja success viestit eri väreillä?! if (!$form->{'invite_these'}) {$message = tag('div',{class => 'error'}).$gettext->gettext('You must select at least one member to remove!').endtag('div');} else { $form->{'invite_these'} =~ s/ /, /g; $message = tag('div',{class => 'success'}).$gettext->gettext('The following members have been removed: '). $form->{'invite_these'}. endtag('div'); } print_template("$config{'theme'}_groupkick", $message); } #""""""""""""""# # part_group() # #--------------# # Part group # #______________# sub part_group { my ($nimi,$owner); lock_tables('READ', 'groupusers','groups'); my ($user) = db_select('groupusers.USER,groups.GRPNAME','groupusers,groups',"groupusers.GID = '$form->{'GID'}' and groupusers.GID = groups.GID and groupusers.USER = '$USER'"); unlock_tables(); print_template("$config{'theme'}_grouplist") if !$user->{'USER'}; unlock_tables(); lock_tables('WRITE', 'groupusers','messages'); my $time = time(); db_delete('groupusers',"USER = '$USER' and GID = '$form->{'GID'}'"); db_list("select USER from groupusers where GID = '$form->{'GID'}'and RIGHTS like '%G0%'"); while (my $ref = $sth->fetchrow_hashref()) {$owner = $ref->{'USER'};} db_end(); my $message = sprintf($gettext->gettext('[B]I have parted the group %s![/B]'),$user->{'GRPNAME'}); db_list("insert into messages (LINE,TARGET,SENDER,TIME,STATUS,MESSAGE,TYPE) values ('NULL', '$owner', '$USER', '$time', 'no', '$message','SHORT')"); db_end(); unlock_tables(); print_template("$config{'theme'}_grouppart"); } #"""""""""""""# # add_group() # #-------------# # Add group # #_____________# sub add_group { my ($tools,$public,$gid); for (my $n = 0;$n <= $form->{'toolcounter'};$n++) { $tools .= $form->{"act_$n"} if $form->{"act_$n"} =~ /^\D$/; $public .= $form->{"pub_$n"} if $form->{"pub_$n"} =~ /^\D$/ && $form->{"act_$n"} =~ /^\D$/; } if (length($form->{'groupname'}) < 1 || length($form->{'description'}) < 1) { my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, ); foreach (keys %db) {($db{$_}) = html_escape($db{$_});}; my $error = $gettext->gettext('You didn\'t fill all the required fields!
Please correct the above error and try again.'); print_template("$config{'theme'}_groupcreate", \%db, $error); } else { my $found = undef; lock_tables('READ','groups'); db_list("select GRPNAME from groups where GRPNAME = '$form->{'groupname'}'"); while (my $ref = $sth->fetchrow_hashref()) {$found = 'yes';} db_end(); unlock_tables(); if ($found) { my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, ); foreach (keys %db) {($db{$_}) = html_escape($db{$_});}; my $error = sprintf($gettext->gettext('Group %s already exists!
Please correct the above error and try again.'),$form->{'groupname'}); print_template("$config{'theme'}_groupcreate", \%db, $error); } } $form->{'groupname'} =~ s/,//gms; my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, 'CREATOR' => $USER, 'TOOLS' => $tools, 'PUBLIC' => $public, 'CREATED' => time(), 'QUOTA' => $config{'group_quota'} ); foreach (keys %db) {($db{$_}) = prepare_fordb($db{$_});} lock_tables('WRITE','groups','groupusers'); db_insert("groups",\%db); db_list("select LAST_INSERT_ID() as id"); while (my $ref = $sth->fetchrow_hashref()) {$gid = $ref->{'id'};} db_end(); my %gusers = ( 'USER' => $USER, 'GID' => $gid, 'RIGHTS' => $default_admin_rights ); db_insert("groupusers",\%gusers); unlock_tables(); mkdir "$config{'file_dir'}/forums/groups/$gid", 0700 or write_log("Cannot create directory $config{'file_dir'}/forums/groups/$gid. $!") unless -d "$config{'file_dir'}/forums/groups/$gid"; mkdir "$config{'file_dir'}/groups/$gid", 0700 or write_log("Cannot create directory $config{'file_dir'}/groups/$gid. $!") unless -d "$config{'file_dir'}/groups/$gid"; foreach (keys %create) {create_table("${gid}_$_", $create{$_});} print_template("$config{'theme'}_grouplist"); } #""""""""""""""# # edit_group() # #--------------# # Edit group # #______________# sub edit_group { my ($tools,$public,$gid); for (my $n = 0;$n <= $form->{'toolcounter'};$n++) { $tools .= $form->{"act_$n"} if $form->{"act_$n"} =~ /^\D$/; $public .= $form->{"pub_$n"} if $form->{"pub_$n"} =~ /^\D$/ && $form->{"act_$n"} =~ /^\D$/; } if (length($form->{'groupname'}) < 1 || length($form->{'description'}) < 1) { my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, ); foreach (keys %db) {($db{$_}) = html_escape($db{$_});}; my $error = $gettext->gettext('You didn\'t fill all the required fields!
Please correct the above error and try again.'); print_template("$config{'theme'}_groupmanage", \%db, $error); } else { my $found = undef; lock_tables('READ','groups'); db_list("select GRPNAME,GID from groups where GRPNAME = '$form->{'groupname'}'"); while (my $ref = $sth->fetchrow_hashref()) {$found = 'yes' if $ref->{'GID'} ne $form->{'GID'};} db_end(); unlock_tables(); if ($found) { my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, ); foreach (keys %db) {($db{$_}) = html_escape($db{$_});}; my $error = sprintf($gettext->gettext('Group %s already exists!
Please correct the above error and try again.'),$form->{'groupname'}); print_template("$config{'theme'}_groupmanage", \%db, $error); } } $form->{'groupname'} =~ s/,//gms; my %db = ( 'GRPNAME' => $form->{'groupname'}, 'DESCRIPTION' => $form->{'description'}, 'EMAIL' => $form->{'email'}, 'HOMEPAGE' => $form->{'homepage'}, 'ADDRESS' => $form->{'address'}, 'PHONE' => $form->{'phone'}, 'TOOLS' => $tools, 'PUBLIC' => $public ); foreach (keys %db) {($db{$_}) = prepare_fordb($db{$_});} my @tables = get_tables(); foreach my $db (keys %create) { if (!grep {$_ eq "$form->{'GID'}_$db"} @tables) { create_table("$form->{'GID'}_$db", $create{$db}); } } lock_tables('WRITE','groups','groupusers'); db_update("groupusers",{RIGHTS => $default_admin_rights},"RIGHTS like '%G0%' and GID='$form->{'GID'}'"); db_update("groups",\%db,"GID='$form->{'GID'}'"); unlock_tables(); print_template("$config{'theme'}_groupinfo"); } #""""""""""""""""# # remove_group() # #----------------# # Remove group # #________________# # 1. Check if user has rights to remove a group # 2. Delete short messages send by group # 3. Delete group # 4. Delte group user rights # 5. Delte files owned by group # 6. Remove database tables the group owned sub remove_group { my ($access); lock_tables('WRITE','groups','groupusers'); db_list("select RIGHTS from groupusers where USER = '$USER' and GID = '$form->{'GID'}'"); while (my $ref = $sth->fetchrow_hashref()) {$access = 'yes' if $ref->{'RIGHTS'} =~ /G0/;} db_end(); if (!$access) { unlock_tables(); print_template("$config{'theme'}_grouplist"); } db_delete('messages',"MESSAGE like '$form->{'GID'},%' and TYPE != 'SHORT'"); db_delete('groups',"GID = '$form->{'GID'}'"); db_delete('groupusers',"GID = '$form->{'GID'}'"); if (!rmtree("$config{'file_dir'}/groups/$form->{'GID'}")) { write_log( "$USER: Error deleting directory $config{'file_dir'}/groups/$form->{'GID'}. $!", 'error' ); } if (!rmtree("$config{'file_dir'}/forums/groups/$form->{'GID'}")) { write_log( "$USER: Error deleting directory $config{'file_dir'}/forums/groups/$form->{'GID'}. $!", 'error' ); } foreach (keys %create) {drop_table("$form->{'GID'}_$_");} unlock_tables(); print_template("$config{'theme'}_groupremoved"); } ################################## # Read template and process it # ################################## sub print_template { my ($template,$ref,$fulltemplate,$groups,$number_of_groups,$createbutton,$group,@tools,%tools,@public,$tools,$toolcounter,@users); my $nb = '  '; $template = 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'}); lock_tables('READ','toolrights','groupusers','groups','users'); db_list("select SYMBOL,PROG from toolrights"); while (my $ref = $sth->fetchrow_hashref()) {$tools{$ref->{'SYMBOL'}} = $ref->{'PROG'};} db_end(); if ($template eq "$config{'theme'}_grouplist") { my @array = db_select("GRPNAME,GID,PUBLIC","groups",undef,"GRPNAME"); foreach $group (@array) { my ($public,$users,@public,@users) = (); $number_of_groups++; $groups .= ""; db_list("select users.info from groupusers,users where groupusers.GID = '$group->{'GID'}' and users.nimi = groupusers.USER and groupusers.RIGHTS like '%G0%' order by users.info"); while (my $ref = $sth->fetchrow_hashref()) {push @users, $ref->{'info'};} db_end(); foreach (split //, $group->{'PUBLIC'}) {push @public, $tools{$_};} $public = join ", ", sort @public; $users = join ", ", sort @users; $groups .= qq[$group->{'GRPNAME'}$nb\n]; $groups .= "$users$nb\n"; # Disabled atm # $groups .= "$public$nb\n"; # $groups .= "100%$nb\n"; # $groups .= "100%$nb\n"; $groups .= ""; } if (!$number_of_groups) { $groups = "$nb$nb".$gettext->gettext('No groups found!').""; $number_of_groups = '0'; } $createbutton = picbutton(name => 'create', image => 'createnewgroup.gif', form => 'grouplist') if $ADMIN_RIGHTS =~ /G0/ || $config{'all_create_groups'} eq 'yes'; $fulltemplate =~ s/<>/$createbutton/ms; $fulltemplate =~ s/<>/$groups/ms; $fulltemplate =~ s/<>/$number_of_groups/ms; } elsif ($template eq "$config{'theme'}_groupinfo") { my ($is_member,$is_owner,$buttons); my ($group) = db_select("groups.TOOLS,groups.PUBLIC,groups.CREATOR,groups.CREATED,groups.GRPNAME,groups.PHONE,groups.ADDRESS,groups.HOMEPAGE,groups.EMAIL,groups.DESCRIPTION,users.info","groups,users","groups.GID = '$form->{'GID'}' and groups.CREATOR = users.nimi"); db_list("select users.info,users.nimi,groupusers.RIGHTS from groupusers,users where groupusers.GID = '$form->{'GID'}' and users.nimi = groupusers.USER order by users.nimi"); while (my $ref = $sth->fetchrow_hashref()) { push @users, tagged('a',{href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$ref->{'nimi'}", content => "$ref->{'nimi'} ($ref->{'info'})"}); if ($ref->{'nimi'} eq $USER) { $is_member = 'yes'; $is_owner = 'yes' if $ref->{'RIGHTS'} =~ /G0/; } } db_end(); my $number_of_users = @users; @users = sort @users; my $users = join "
", @users; foreach (split //, $group->{'PUBLIC'}) {push @public, $tools{$_};} my $public = join ", ", sort @public; foreach (split //, $group->{'TOOLS'}) {push @tools, $tools{$_};} my $tools = join ", ", sort @tools; my (undef,undef,undef,$day_of_month,$month,$year) = utc_epoch2date($group->{'CREATED'}); if ($is_member && !$is_owner) {$buttons .= picbutton(name => 'part', image => 'part.gif', form => 'grouplist');} elsif (!$is_owner) {$buttons .= picbutton(name => 'join', image => 'join.gif', form => 'grouplist');} $is_owner = 'yes' if $ADMIN_RIGHTS =~ /G0/; if ($is_owner) { $buttons .= ' ' x 2; $buttons .= picbutton(name => 'remove', image => 'removegroup.gif', form => 'grouplist'); $buttons .= ' ' x 2; $buttons .= picbutton(name => 'manage', image => 'editgroup.gif', form => 'grouplist'); $buttons .= ' ' x 2; $buttons .= picbutton(name => 'invite', image => 'inviteusers.gif', form => 'grouplist'); $buttons .= ' ' x 2; $buttons .= picbutton(name => 'membremove', image => 'removemembers.gif', form => 'grouplist'); } ($group->{'HOMEPAGE'}) = urlify($group->{'HOMEPAGE'}); $fulltemplate =~ s/<>/$group->{'GRPNAME'}$nb/m; $fulltemplate =~ s/<>/$users$nb/m; $fulltemplate =~ s/<>/$number_of_users$nb/m; my $created_translated_text = sprintf($gettext->gettext('by %s (%s)'),$group->{'CREATOR'},$group->{'info'}); $fulltemplate =~ s/<>/$day_of_month.$month.$year $created_translated_text$nb/m; $fulltemplate =~ s/<>/$group->{'EMAIL'}$nb/m; $fulltemplate =~ s/<
>/$group->{'ADDRESS'}$nb/m; $fulltemplate =~ s/<>/$group->{'PHONE'}$nb/m; $fulltemplate =~ s/<>/$group->{'HOMEPAGE'}$nb/m; $fulltemplate =~ s/<>/$tools$nb/m; $fulltemplate =~ s/<>/$public$nb/m; $fulltemplate =~ s/<>/100\%$nb/m; $fulltemplate =~ s/<>/100\%$nb/m; ($group->{'DESCRIPTION'}) = itag_replacer($group->{'DESCRIPTION'}); $fulltemplate =~ s/<>/$group->{'DESCRIPTION'}$nb/m; $fulltemplate =~ s/<>/$buttons/m; $fulltemplate =~ s/<>/$form->{'GID'}/m; } elsif ($template eq "$config{'theme'}_groupcreate" || $template eq "$config{'theme'}_groupmanage") { my $redo = $_[0]; my $error = $_[1]; ($redo) = db_select("*","groups","GID = '$form->{'GID'}'") if $template eq "$config{'theme'}_groupmanage" && !$error; my ($act_check,$pub_check); db_list("select * from toolrights order by PROG"); while (my $ref = $sth->fetchrow_hashref()) { $toolcounter++; if ($template eq "$config{'theme'}_groupmanage" && !$error) { foreach (split //, $redo->{'PUBLIC'}) { if ($ref->{'SYMBOL'} eq $_) {$form->{"pub_$toolcounter"} = '1';} } foreach (split //, $redo->{'TOOLS'}) { if ($ref->{'SYMBOL'} eq $_) {$form->{"act_$toolcounter"} = '1';} } } if ($form->{"act_$toolcounter"}) {$act_check = 'checked';} else {$act_check = undef;} if ($form->{"pub_$toolcounter"}) {$pub_check = 'checked';} else {$pub_check = undef;} $tools .= "\n"; $tools .= "$ref->{'PROG'}\n"; $tools .= qq[$ref->{'DESCRIPTION'}\n]; $tools .= qq[\n]; # Disabled # # $tools .= qq[\n]; $tools .= "\n"; } db_end(); $fulltemplate =~ s/<>/$error/m; $fulltemplate =~ s/<>/$redo->{'GRPNAME'}/mg; $fulltemplate =~ s/<>/$redo->{'DESCRIPTION'}/m; $fulltemplate =~ s/<>/$redo->{'EMAIL'}/m; $fulltemplate =~ s/<>/$redo->{'HOMEPAGE'}/m; $fulltemplate =~ s/<
>/$redo->{'ADDRESS'}/m; $fulltemplate =~ s/<>/$redo->{'PHONE'}/m; $fulltemplate =~ s/<>/$tools/m; $fulltemplate =~ s/<>/$form->{'GID'}/m; $fulltemplate =~ s/<>/$toolcounter/m; } elsif ($template eq "$config{'theme'}_groupinvite" || $template eq "$config{'theme'}_groupkick") { my $error = $_[0]; my ($users,@groupusers); if ($template eq "$config{'theme'}_groupkick") { db_list("select groupusers.USER,groupusers.RIGHTS,users.info from groupusers,users where groupusers.USER = users.nimi and groupusers.GID = '$form->{'GID'}' order by groupusers.USER"); while (my $ref = $sth->fetchrow_hashref()) { if(!(grep {$_ eq $ref->{'USER'}} @groupusers) && $ref->{'RIGHTS'} !~ /G0/) {$users .= qq[\n];} } db_end(); } else { db_list("select USER from groupusers where groupusers.GID = '$form->{'GID'}'"); while (my $ref = $sth->fetchrow_hashref()) {push @groupusers, $ref->{'USER'};} db_end(); db_list("select nimi,info from users order by nimi"); while (my $ref = $sth->fetchrow_hashref()) { if(!(grep {$_ eq $ref->{'nimi'}} @groupusers)) {$users .= qq[\n];} } db_end(); } foreach (db_select("GRPNAME","groups","GID = '$form->{'GID'}'")) {$fulltemplate =~ s/<>/$_->{'GRPNAME'}/m;} $fulltemplate =~ s/<>/$error/m; $fulltemplate =~ s/<>/$form->{'GID'}/m; $fulltemplate =~ s/<>/$users/m; } elsif ($template =~ /^$config{'theme'}_group(re)?(join)|(part)$/) { foreach (db_select("GRPNAME","groups","GID = '$form->{'GID'}'")) {$fulltemplate =~ s/<>/$_->{'GRPNAME'}/m;} } else {$fulltemplate =~ s/<>/$form->{'GID'}/m;} unlock_tables(); $fulltemplate =~ s/<>/$stuff/ms; if ($GROUPACTIVOR && !$form->{'parted'} && !$form->{'rmconfirm'} && !$form->{'list'}) {$fulltemplate = create_buttons($fulltemplate, 'Group', 'Modify Group', $form);} else {$fulltemplate = create_buttons($fulltemplate, 'Projects', 'Manage Groups', $form);} $fulltemplate =~ s/<>/minea/gm; $fulltemplate =~ s/<>/$form->{'grouptool'}/m; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; $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; }