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';
25 require_once $gfplugins.'globaldashboard/include/globalDashboard_utils.php';
26 require_once $gfplugins.'globaldashboard/include/globalDashboardConstants.php';
27 require_once $gfplugins.'globaldashboard/common/manage_accounts_db_utils.php';
29 $user = session_get_user(); // get the user session
31 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
32 exit_error("Invalid User", "Cannot Process your request for this user.");
35 $type = getStringFromRequest('type');
36 $id = getStringFromRequest('id');
37 $pluginname = getStringFromRequest('pluginname');
40 exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
42 exit_error("Cannot Process your request","No ID specified");
44 if ($type == 'user') {
45 $realuser = user_get_object($id);//
46 if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
47 exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
49 if ( (!$user) || ($user->getID() != $id)) {
50 // if someone else tried to access the private GlobalDashboard part of this user
51 exit_error("Access Denied", "You cannot access other user's personal $pluginname");
54 globaldashboard_header(array('title'=> _('Global Dashboard Configuration')));
55 globaldashboard_toolbar();
57 listStoredRemoteAccounts($user->getID());
58 createNewAccountForm($user->getID());
61 site_project_footer(array());
65 * Displays the list of all stored remote accounts of the user.
67 * @param integer $user_id user id.
69 function listStoredRemoteAccounts($user_id) {
70 global $HTML, $feedback;
72 //echo 'Here are stored accounts list';
74 $accounts = getDBStoredRemoteAccountsByUserId($user_id);
75 if (count($accounts) > 0) {
78 echo '<legend> ' . _('Stored remote accounts') . ' </legend>';
80 $tablearr = array(_("User Name"), _("Remote site"), _("User account URL"), _("Action") );
81 $html .= $HTML->listTableTop($tablearr);
83 foreach ($accounts as $account) {
85 <tr ' . $HTML->boxGetAltRowStyle($i++) . '>
86 <td><a href="'.$account['forge_account_uri'].'">'.$account['forge_account_login_name'].'</a>
88 <td><a href="'.$account['forge_account_domain'].'">'.$account['forge_account_domain'].'</a>
90 <td><a href="'.$account['forge_account_uri'].'">'.$account['forge_account_uri'].'</a>
92 <td><a href="/plugins/globaldashboard/admin/edit_account_page.php?type=user&id='.$user_id.'&pluginname=globaldashboard&action=edit&account_id='.$account['account_id'].'"> '. _("Edit") . ' </a>
93 <a href="/plugins/globaldashboard/admin/delete_account.php?account_id='.$account['account_id'].'&user_id='.$account['user_id'].'"> '. _("Delete") . ' </a>
97 $html .= $HTML->listTableBottom();
106 * Form to add new remote accounts
108 function createNewAccountForm($user_id) {
110 <form action="add_account.php" method="POST">';
113 <legend> '. _('Create a new remote account') . ' </legend>
116 <td>' . _('User Name') . ': <span class="requiredfield">*</span> </td>
118 <input type="hidden" value="'. $user_id .'" name="user_id">
119 <input type="text" name="login_name">
123 <td>' . _('Account password') . ': <span class="requiredfield">*</span> </td>
125 <input type="password" name="account_password">
129 <td>' . _('Remote Forge Software') . ': <span class="requiredfield">*</span> </td>
131 <select name="forge_software">
132 <option value="'. REMOTE_FORGE_SOFTWARE_FUSIONFORGE .'" selected="selected"> FusionForge </option>
133 <option value="'. REMOTE_FORGE_SOFTWARE_CODENDI .'"> Codendi </option>
134 <option value="'. REMOTE_FORGE_SOFTWARE_TULEAP .'"> Tuleap </option>
135 <option value="'. REMOTE_FORGE_SOFTWARE_REDMINE .'"> Redmine </option>
136 <option value="'. REMOTE_FORGE_SOFTWARE_TRACK .'"> Track </option>
141 <td>' . _('Account domain') . ': <span class="requiredfield">*</span> </td>
143 <input type="text" size="60" name="account_domain">
147 <td>' . _('Account URI') . ': <span class="requiredfield">*</span> </td>
149 <input type="text" size="60" name="account_uri">
150 <input type="checkbox" name="account_is_foaf"> '. _("Is account FOAF enabled ?").'
154 <td>' . _('OSLC Discovery URI') . ': </td>
156 <input type="text" size="60" name="oslc_uri">
160 <td>' . _('RSS Stream URI') . ': </td>
162 <input type="text" size="60" name="rss_uri">
166 <td>' . _('SOAP WSDL URI') . ': </td>
168 <input type="text" size="60" name="soap_wsdl">
175 <legend>' . _('Ressources Discovery Parameters') . '</legend>
178 <td>' . _('Projects discovery method') . ': </td>
180 <select name="projects_discovery_method">
181 <option value="'. USER_PROJECTS_FETCH_METHOD_NONE .'" selected="selected"> None </option>
182 <option value="'. USER_PROJECTS_FETCH_METHOD_SOAP .'"> SOAP </option>
183 <option value="'. USER_PROJECTS_FETCH_METHOD_OSLC .'"> OSLC-CM </option>
184 <option value="'. USER_PROJECTS_FETCH_METHOD_FOAF .'"> FOAF </option>
189 <td>' . _('Artifacts discovery method') . ': </td>
191 <select name="artifacts_discovery_method">
192 <option value="'. USER_ARTIFACTS_FETCH_METHOD_NONE .'" selected="selected"> None </option>
193 <option value="'. USER_ARTIFACTS_FETCH_METHOD_SOAP .'"> SOAP </option>
194 <option value="'. USER_ARTIFACTS_FETCH_METHOD_OSLC .'"> OSLC-CM </option>
201 echo ' <p style="text-align: center;">
202 <input type="submit" value="submit new account"/>