00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: quitproject.php 5397 2006-02-15 22:55:15Z yeupou $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Wallace Lee
00009 #
00010 # Copyright 2004-2006 (c) Mathieu Roy <yeupou--gnu.org>
00011 #
00012 # The Savane project is free software; you can redistribute it and/or
00013 # modify it under the terms of the GNU General Public License
00014 # as published by the Free Software Foundation; either version 2
00015 # of the License, or (at your option) any later version.
00016 #
00017 # The Savane project is distributed in the hope that it will be useful,
00018 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 # GNU General Public License for more details.
00021 #
00022 # You should have received a copy of the GNU General Public License
00023 # along with the Savane project; if not, write to the Free Software
00024 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00025
00026
00027 require "../include/pre.php";
00028
00029 session_require(array('isloggedin'=>'1'));
00030
00031 # Make sure the user is actually member of the project
00032 if (!$pending && !member_check(0,$quitting_group_id))
00033 {
00034 exit_error("You are not member of this group.");
00035 }
00036 if ($pending && !member_check_pending(0,$quitting_group_id))
00037 {
00038 exit_error("You have not requested inclusion in this group.");
00039 }
00040
00041 if ($cancel)
00042 {
00043 session_redirect($GLOBALS['sys_home']."my/groups.php");
00044 }
00045
00046 # If we get here, the user is actually member of the group
00047 # Ask him to confirm he understood what he is doing.
00048 # If it is just a removal from a pending for inclusion request, no need
00049 # to confirm, the loss is not worth it.
00050 if (!$confirm && !$pending)
00051 {
00052 site_user_header(array('title'=>_("Quit a group"),
00053 'context'=>'mygroups'));
00054
00055 print '<form action="'.$GLOBALS[PHP_SELF].'" method="post">';
00056 print '<input type="hidden" name="quitting_group_id" value="'.$quitting_group_id.'" />';
00057 print '<span class="preinput">'.sprintf(_("You are about to leave the group %s, please confirm:"), group_getname($quitting_group_id)).'</span>';
00058 print '<div class="center"><input type="submit" name="confirm" value="'._("Confirm").'" /> <input type="submit" name="cancel" value="'._("Cancel").'" /></div>';
00059 print '</form>';
00060 }
00061 else
00062 {
00063 db_query("DELETE FROM user_group WHERE user_id='".user_getid()."' AND group_id='$quitting_group_id'");
00064
00065 # Mail the changes so the admins know what happened
00066 # unless it is a request for inclusion cancelled
00067 if ($pending)
00068 {
00069 $res_admin = db_query("SELECT user.user_id AS user_id, user.email AS email, user.user_name AS user_name FROM user,user_group "
00070 . "WHERE user_group.user_id=user.user_id AND user_group.group_id=$quitting_group_id AND "
00071 . "user_group.admin_flags = 'A'");
00072
00073 while ($row_admin = db_fetch_array($res_admin))
00074 {
00075 $to .= "$row_admin[email],";
00076 }
00077 if ($to)
00078 {
00079 $to = substr($to,0,-1);
00080 $message = "This message is being sent to notify the administrator(s) of". "\nproject ".group_getname($quitting_group_id)." that ".user_getname(0,1)." <".user_getname().">\n".
00081 "has chosen to remove him/herself from the project.\n";
00082 }
00083 else
00084 {
00085 # No admin? The project is admin orphan, it will require the assistance
00086 # of site admins
00087 $to = $GLOBALS[sys_mail_admin]."@".$GLOBALS[sys_mail_domain];
00088 $message = "This message is being sent to notify the site administrator(s)\n".
00089 "that the last administrator of the project ".group_getname($quitting_group_id)." (".user_getname(0,1)." <".user_getname().">)\n".
00090 "has chosen to remove him/herself from the project.\n\n".
00091 "As result, the project is administrator-orphan.\n";
00092 }
00093
00094 $from = $GLOBALS[sys_mail_replyto]."@".$GLOBALS[sys_mail_domain];
00095 $subject = user_getname(0,1)." quitted the project ".group_getname($quitting_group_id);
00096 sendmail_mail($from,$to,$subject,$message);
00097 }
00098
00099 session_redirect($GLOBALS['sys_home']."my/groups.php");
00100 }
00101
00102 ?>