4 * Copyright 2011, Sabri LABBENE - Institut Télécom
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 along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * Gets remote accounts hold by a user from the database.
27 * @param array $params contain user_id and account fetching method
29 * @return array array of remote accounts hold by the user.
31 function getDBStoredRemoteAccountsByUserId($user_id) {
32 $t_accounts_table = "plugin_globaldashboard_user_forge_account";
33 $t_result = db_query_params(
34 "SELECT * FROM $t_accounts_table ".
36 "ORDER BY forge_account_login_name ASC",
37 array( (int) $user_id));
41 while ( $t_row = db_fetch_array( $t_result ) ) {
49 * Fetches a remote account from FF DB knowing its id.
51 * @param integer $account_id account id.
52 * @return array $t_row array of account data.
54 function getDBStoredRemoteAccountById($account_id) {
55 $t_accounts_table = "plugin_globaldashboard_user_forge_account";
56 $t_result = db_query_params(
57 "SELECT * FROM $t_accounts_table ".
58 "WHERE account_id=$1", array( (int) $account_id)
61 if (!$t_result || ( db_numrows( $t_result ) < 1 )) {
62 exit_error( "Remote account not found", 'Global Dashboard' );
65 $t_row = db_fetch_array( $t_result );
71 * Fetches Forge Software for a remote account identified by its id.
73 * @param integer $account_id
75 function getDBForgeSoftwareByAccountId($account_id) {
76 $t_account_table = "plugin_globaldashboard_user_forge_account";
77 $t_result = db_query_params(
78 "SELECT forge_software FROM $t_account_table ".
79 "WHERE account_id=$1", array((int) $account_id)
81 if (db_numrows($t_result)) {
82 $forge_software = db_result($t_result, 0, 'forge_software');
84 return $forge_software;
89 * Fetches account discovery params from DB knowing account id
91 * @param integer $account_id
93 * @return array $t_row array of discovery data.
95 function getDBAccountDiscoveryByAccountId($account_id) {
96 $t_discovery_table = "plugin_globaldashboard_account_discovery";
97 $t_result = db_query_params(
98 "SELECT * FROM $t_discovery_table ".
99 "WHERE account_id=$1", array( (int) $account_id)
102 if (!$t_result || ( db_numrows( $t_result ) < 1 )) {
103 exit_error( "Remote account not found", 'Global Dashboard' );
106 $t_row = db_fetch_array( $t_result );
112 * returns the fetch method for a ressource (projects, artifacts, etc.)
113 * @param integer $account_id
114 * @param string $ressource_type (projects | artifacts | ...)
116 function getDBFetchMethod($account_id, $ressource_type) {
117 $t_account_discovery_table = "plugin_globaldashboard_account_discovery";
118 $t_result = db_query_params(
119 "SELECT * FROM $t_account_discovery_table ".
120 "WHERE account_id=$1",
121 array( (int) $account_id)
124 if(!$t_result || (db_numrows( $t_result ) < 1)) {
127 $t_row = db_fetch_array($t_result);
129 switch ($ressource_type) {
131 return $t_row['projects_discovery_method'];
133 return $t_row['artifacts_discovery_method'];
142 * Gets the remote accounts of a user from its foaf profile
144 * @param string $user_profile_url Url of the user foaf profile.
146 * @return array array of user accounts
148 function getUserRdfRemoteAccounts($user_profile_url) {
149 // TODO fetch user accounts from its foaf profile using