4 * Manage OAuth consumers
6 * This file is (c) Copyright 2010 by Olivier BERGER, Madhumita DHAR, Institut TELECOM
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program 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
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * This program has been developed in the frame of the COCLICO
23 * project with financial support of its funders.
28 require_once('../../env.inc.php');
29 require_once $gfwww.'include/pre.php';
31 require_once 'checks.php';
33 oauthprovider_CheckUser();
35 $user = session_get_user(); // get the session user
36 $t_consumers = OauthAuthzConsumer::load_all();
38 $t_can_manage = false;
39 if(forge_check_global_perm ('forge_admin')) $t_can_manage = true;
41 // FIXME : use $HTML->boxTop() and likes bellow
42 if(count($t_consumers)>0) {
43 echo $HTML->boxTop(_('OAuth consumers'));
45 echo $HTML->listTableTop(array(_('Consumer'), _('URL'), _('Description'), _('Email'), _('Key'), _('Secret'), '', ''));
48 foreach( $t_consumers as $t_consumer ) { ?>
49 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
50 <td><?php echo ( $t_consumer->getName() ) ?></td>
51 <td class="center"><?php echo ( $t_consumer->getURL() ) ?></td>
52 <td class="center"><?php echo ( $t_consumer->getDesc() ) ?></td>
53 <td class="center"><?php echo ( $t_consumer->getEmail() ) ?></td>
54 <td><?php echo ( $t_consumer->key) ?></td>
56 echo ( $t_consumer->secret);
60 if ( $t_can_manage ) {
61 print util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_consumer->getId() , _('Manage'));
67 if ( $t_can_manage ) {
68 print util_make_link('/plugins/'.$pluginname.'/consumer_delete.php?consumer_id=' . $t_consumer->getId() . '&plugin_oauthprovider_consumer_delete_token='.form_generate_key(), _('Delete'));
71 echo $HTML->listTableBottom();
73 echo $HTML->boxBottom();
77 echo '<p>'. _('There are currently no OAuth consumers registered in the database').'</p>';
80 if ( $t_can_manage ) {
82 $f_consumer_name = getStringFromPost( 'consumer_name' );
83 $f_consumer_url = getStringFromPost( 'consumer_url' );
84 $f_consumer_desc = getStringFromPost( 'consumer_desc' );
85 $f_consumer_email = getStringFromPost( 'consumer_email' );
89 <form action="consumer_create.php" method="post">
90 <?php echo '<input type="hidden" name="plugin_oauthprovider_consumer_create_token" value="'.form_generate_key().'"/>' ?>
91 <table class="width50" align="center" cellspacing="1">
94 <td class="form-title" colspan="2"><?php echo _('Create Consumer') ?></td>
98 <td class="category"><?php echo _('Name') ?></td>
99 <td><input name="consumer_name" maxlength="128" size="40" value="<?php echo $f_consumer_name ?>"/></td>
103 <td class="category"><?php echo _('URL') ?></td>
104 <td><input name="consumer_url" maxlength="250" size="40" value="<?php echo $f_consumer_url ?>"/></td>
108 <td class="category"><?php echo _('Description') ?></td>
109 <td><input name="consumer_desc" maxlength="250" size="40" value="<?php echo $f_consumer_desc ?>"/></td>
113 <td class="category"><?php echo _('Email') ?></td>
114 <td><input name="consumer_email" maxlength="250" size="40" value="<?php echo $f_consumer_email ?>"/></td>
120 <td class="center" colspan="2"><input type="submit" value="<?php echo _('Create Consumer') ?>"/></td>
128 site_project_footer(array());
132 // c-file-style: "bsd"