3 * Copyright 2004 (c) GForge LLC
4 * Copyright 2006 (c) Sogeti : Fabien Regnier
5 * Copyright 2010 (c) Capgemini : Franck Villaume
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FusionForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 require_once '../../env.inc.php';
25 require_once $gfwww.'include/pre.php';
27 $group_id = getIntFromRequest('group_id');
28 $sub_project_id = getIntFromRequest('sub_project_id');
29 $com = getStringFromRequest('com');
31 session_require_perm ('project_admin', $group_id) ;
32 //add link between two projects
34 db_query_params ('INSERT INTO plugin_projects_hierarchy (project_id ,sub_project_id,link_type,com) VALUES ($1 , $2, $3,$4)',
38 $com)) or die(db_error());
41 // send mail to admin of the son project for validation
42 $project_name_res = db_query_params ('SELECT group_name from groups where group_id=$1',
43 array ( $group_id ) );
45 $row =& db_fetch_array($project_name_res);
47 $project_name = $row['group_name'];
49 $child_project_name_res = db_query_params ('SELECT group_name from groups where group_id=$1',
50 array ( $sub_project_id ) );
52 $row =& db_fetch_array($child_project_name_res);
54 $child_project_name = $row['group_name'];
56 $message = sprintf(_('New Parent Relation Submitted
58 Parent Project Full Name: %1$s
59 Child Project Full Name: %2$s
61 Please visit the following URL %3$s'), $project_name,$child_project_name,util_make_url ('project/admin/index.php?group_id='.$sub_project_id));
63 $res = db_query_params ('SELECT users.email, users.language, users.user_id
64 FROM users, user_group
66 AND user_group.admin_flags=$2
67 AND users.user_id=user_group.user_id',
68 array ($sub_project_id,'A'));
70 if (db_numrows($res) < 1) {
71 $this->setError(_("There is no administrator to send the mail."));
75 for ($i=0; $i<db_numrows($res) ; $i++) {
76 $admin_email = db_result($res,$i,'email') ;
78 util_send_message($admin_email,sprintf(_('New Parent %1$s Relation Submitted'), $project_name), $message);
81 header("Location: ".util_make_url ('/project/admin/index.php?group_id='.$group_id));