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.
27 require_once '../../env.inc.php';
28 require_once $gfwww.'include/pre.php';
30 require_once 'checks.php';
32 oauthprovider_CheckUser();
34 $user = session_get_user(); // get the session user
35 $t_consumers = OauthAuthzConsumer::load_all();
37 $t_can_manage = false;
38 if(forge_check_global_perm ('forge_admin')) $t_can_manage = true;
40 // FIXME : use $HTML->boxTop() and likes bellow
41 if(count($t_consumers)>0) {
42 echo $HTML->boxTop(_('OAuth consumers'));
44 echo $HTML->listTableTop(array(_('Consumer'), _('URL'), _('Description'), _('Email'), _('Key'), _('Secret'), '', ''));
47 foreach( $t_consumers as $t_consumer ) { ?>
49 <td><?php echo ( $t_consumer->getName() ) ?></td>
50 <td class="center"><?php echo ( $t_consumer->getURL() ) ?></td>
51 <td class="center"><?php echo ( $t_consumer->getDesc() ) ?></td>
52 <td class="center"><?php echo ( $t_consumer->getEmail() ) ?></td>
53 <td><?php echo ( $t_consumer->key) ?></td>
55 echo ( $t_consumer->secret);
59 if ( $t_can_manage ) { ?>
61 <?php print util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_consumer->getId() , _('Manage'));
65 if ( $t_can_manage ) { ?>
67 <?php print util_make_link('/plugins/'.$pluginname.'/consumer_delete.php?consumer_id=' . $t_consumer->getId() . '&plugin_oauthprovider_consumer_delete_token='.form_generate_key(), _('Delete'));
72 echo $HTML->listTableBottom();
74 echo $HTML->boxBottom();
78 echo '<p>'. _('There are currently no OAuth consumers registered in the database').'</p>';
81 if ( $t_can_manage ) {
83 $f_consumer_name = getStringFromPost( 'consumer_name' );
84 $f_consumer_url = getStringFromPost( 'consumer_url' );
85 $f_consumer_desc = getStringFromPost( 'consumer_desc' );
86 $f_consumer_email = getStringFromPost( 'consumer_email' );
90 <form action="consumer_create.php" method="post">
91 <?php echo '<input type="hidden" name="plugin_oauthprovider_consumer_create_token" value="'.form_generate_key().'"/>' ?>
92 <table class="width50" align="center" cellspacing="1">
95 <td class="form-title" colspan="2"><?php echo _('Create Consumer') ?></td>
99 <td class="category"><?php echo _('Name') ?></td>
100 <td><input name="consumer_name" maxlength="128" size="40" value="<?php echo $f_consumer_name ?>"/></td>
104 <td class="category"><?php echo _('URL') ?></td>
105 <td><input name="consumer_url" maxlength="250" size="40" value="<?php echo $f_consumer_url ?>"/></td>
109 <td class="category"><?php echo _('Description') ?></td>
110 <td><input name="consumer_desc" maxlength="250" size="40" value="<?php echo $f_consumer_desc ?>"/></td>
114 <td class="category"><?php echo _('Email') ?></td>
115 <td><input name="consumer_email" maxlength="250" size="40" value="<?php echo $f_consumer_email ?>"/></td>
119 <td class="center" colspan="2"><input type="submit" value="<?php echo _('Create Consumer') ?>"/></td>
126 site_project_footer();
130 // c-file-style: "bsd"