4 * This file is (c) Copyright 2010 by Olivier BERGER, Madhumita DHAR, Institut TELECOM
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * This program has been developed in the frame of the COCLICO
21 * project with financial support of its funders.
25 // Screen which displays a list of access tokens the user has already granted to consumers
27 require_once '../../env.inc.php';
28 require_once $gfwww.'include/pre.php';
30 require_once 'checks.php';
32 $user_id = user_getid();
35 if(oauthprovider_CheckAdmin()==0) {
38 oauthprovider_CheckGroup();
41 $temp_tokens = OauthAuthzAccessToken::load_all();
42 foreach($temp_tokens as $temp_token) {
43 $role = RBACEngine::getInstance()->getRoleById($temp_token->getRoleId());
44 if($role->getHomeProject()->getID() == $id) {
45 $t_tokens[] = $temp_token;
49 oauthprovider_CheckUser();
50 $t_tokens = OauthAuthzAccessToken::load_all($user_id);
64 if(count($t_tokens)>0) {
65 echo $HTML->boxTop(_('Access Tokens'));
66 echo $HTML->listTableTop($headers);
69 foreach( $t_tokens as $t_token ) {
70 $consumer = OauthAuthzConsumer::load($t_token->getConsumerId());
71 echo '<tr '.$HTML->boxGetAltRowStyle($i).'>';
72 if(forge_check_global_perm ('forge_admin')) {
73 echo '<td>'.util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_token->getConsumerId(), $consumer->getName()).'</td>';
75 echo '<td>'.$consumer->getName().'</td>';
77 echo '<td>'.$t_token->key.'</td>';
78 echo '<td>'.$t_token->secret.'</td>';
79 $role_id =$t_token->getRoleId();
81 //echo 'Roleid: '.$role_id;
82 $role = RBACEngine::getInstance()->getRoleById($role_id);
84 echo '<td>'.$role->getName().'</td>';
86 echo '<td>'.'---'.'</td>';
88 if($t_token->getUserId() > 0 ) {
89 $user_object =& user_get_object($t_token->getUserId());
90 $user = $user_object->getRealName().' ('.$user_object->getUnixName().')';
94 echo '<td>'.$user.'</td>';
95 echo '<td>'.date(DATE_RFC822, $t_token->gettime_stamp()) .'</td>';
96 if(forge_check_global_perm ('forge_admin')) {
97 echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?token_id=' . $t_token->getId() . '&token_type=access' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), _('Delete')). '</td>';
98 }elseif($type == 'group') {
99 if(($proj_admin)||($t_token->getUserId() == $user_id)) {
100 echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?token_id=' . $t_token->getId() . '&token_type=access' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), _('Delete')). '</td>';
105 echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?token_id=' . $t_token->getId() . '&token_type=access' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), _('Delete')). '</td>';
110 echo $HTML->listTableBottom();
111 echo $HTML->boxBottom();
113 echo '<p>'. _('No access tokens were found!').'</p>';
118 site_project_footer(array());