3 * Copyright 2011, Sabri LABBENE - Institut Télécom
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once '../../../env.inc.php';
24 require_once $gfwww.'include/pre.php';
26 $user_id = getIntFromPost('user_id');
27 $login_name = getStringFromPost('login_name');
28 $account_password = getStringFromPost('account_password');
29 $forge_software = getIntFromPost('forge_software');
30 $account_domain = getStringFromPost('account_domain');
31 $account_uri = getStringFromPost('account_uri');
32 $account_is_foaf = getIntFromPost('account_is_foaf');
33 $oslc_uri = getStringFromPost('oslc_uri');
34 $rss_uri = getStringFromPost('rss_uri');
35 $soap_wsdl = getStringFromPost('soap_wsdl');
36 $projects_discovery = getIntFromPost('projects_discovery_method');
37 $artifacts_discovery = getIntFromPost('artifacts_discovery_method');
39 $user = session_get_user();
40 if($user->getID() != $user_id) {
41 session_redirect( '/plugins/globaldashboard/admin/manage_accounts.php?type=user&id='.$user_id.'&pluginname=globaldashboard&error_msg='. urlencode(_('You can add remote accounts ONLY for yourself !!!')));
44 $t_account_table = "plugin_globaldashboard_user_forge_account";
46 $t_query = "INSERT INTO $t_account_table "
48 ."forge_account_login_name, "
49 ."forge_account_password, "
51 ."forge_account_domain, "
52 ."forge_account_uri, "
53 ."forge_account_is_foaf, "
54 ."forge_oslc_discovery_uri, "
55 ."forge_account_rss_uri, "
56 ."forge_account_soap_wsdl_uri ) "
57 ."VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 )";
59 $result = db_query_params($t_query, array($user_id, $login_name, $account_password, $forge_software, $account_domain, $account_uri, $account_is_foaf, $oslc_uri, $rss_uri, $soap_wsdl));
62 $t_discovery_table = "plugin_globaldashboard_account_discovery";
63 $t_disc_query = "INSERT INTO $t_discovery_table "
65 ."projects_discovery_method, "
66 ."artifacts_discovery_method ) "
67 ."VALUES ( $1, $2, $3)";
68 $disc_result = db_query_params($t_disc_query, array(db_insertid($result, $t_account_table, 'account_id'), $projects_discovery, $artifacts_discovery));
70 session_redirect( '/plugins/globaldashboard/admin/manage_accounts.php?type=user&id='.$user_id.'&pluginname=globaldashboard&feedback='. urlencode(_('Remote Account successfully created')));
72 session_redirect( '/plugins/globaldashboard/admin/manage_accounts.php?type=user&id='.$user_id.'&pluginname=globaldashboard&error_msg='. urlencode(printf('Remote account created but unable to create remote associated discovery parameters: '.db_error())));
75 session_redirect( '/plugins/globaldashboard/admin/manage_accounts.php?type=user&id='.$user_id.'&pluginname=globaldashboard&error_msg='. urlencode(printf('Unable to create remote account: '.db_error())));