[Fusionforge-commits] r12920 - in trunk/src/plugins/oauthprovider/www: . admin

Olivier Berger olberger at fusionforge.org
Fri Mar 25 19:47:43 CET 2011


Author: olberger
Date: 2011-03-25 19:47:42 +0100 (Fri, 25 Mar 2011)
New Revision: 12920

Modified:
   trunk/src/plugins/oauthprovider/www/access_tokens.php
   trunk/src/plugins/oauthprovider/www/admin/index.php
   trunk/src/plugins/oauthprovider/www/checks.php
   trunk/src/plugins/oauthprovider/www/consumer.php
   trunk/src/plugins/oauthprovider/www/consumer_create.php
   trunk/src/plugins/oauthprovider/www/consumer_delete.php
   trunk/src/plugins/oauthprovider/www/consumer_manage.php
   trunk/src/plugins/oauthprovider/www/consumer_update.php
   trunk/src/plugins/oauthprovider/www/consumer_update_page.php
   trunk/src/plugins/oauthprovider/www/index.php
Log:
Bunch of changes to get rid of mantis related arg passing and stuff

Modified: trunk/src/plugins/oauthprovider/www/access_tokens.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/access_tokens.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/access_tokens.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -29,13 +29,19 @@
 
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
 $user_id = user_getid();
+// TODO : remove $id
+$id = $user_id;
 
 if(forge_check_global_perm ('forge_admin'))	$admin_access=true;
 
 if($admin_access)	{
+	oauthprovider_CheckSiteAdmin();
 	$t_tokens = OauthAuthzAccessToken::load_all();
 }else {
+	oauthprovider_CheckUser();
 	$t_tokens = OauthAuthzAccessToken::load_all($user_id);
 }
 

Modified: trunk/src/plugins/oauthprovider/www/admin/index.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/admin/index.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/admin/index.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -27,7 +27,8 @@
 require_once('../../../env.inc.php');
 require_once '../checks.php';	
 
-	
+oauthprovider_CheckUser();
+
 ?>
 
 <h3>OAuth endpoints</h3>

Modified: trunk/src/plugins/oauthprovider/www/checks.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/checks.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/checks.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -12,9 +12,9 @@
 
 require_once $gfwww.'include/pre.php';
 require $gfconfig.'/plugins/oauthprovider/config.php';
+require_once $gfwww.'admin/admin_utils.php';
 
 
-
 // the header that displays for the project portion of the plugin
 function oauthprovider_Project_Header($params) {                                                                                                                                         
 	global $DOCUMENT_ROOT,$HTML,$id, $group_id;
@@ -38,6 +38,12 @@
 	site_user_header($params);    
 }
 
+function oauthprovider_Admin_Header() {
+	site_admin_header(array('title'=>_('OAuth')));
+}
+
+			
+function oauthprovider_CheckGroup() {
 	if (!session_loggedin()) {
 		exit_not_logged_in();
 	}	
@@ -47,18 +53,13 @@
 	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
 		exit_error("Invalid User, Cannot Process your request for this user.", 'oauthprovider');
 	}
-
-	$type = getStringFromRequest('type');
-	$id = getStringFromRequest('id');
+	
 	$name = getStringFromRequest('name');
+	if ((!$name)&&(!$id)) {
+		exit_error("Cannot Process your request: No NAME or ID specified",'oauthprovider');
+	}
 	$pluginname = 'oauthprovider';
 	
-	if (!$type) {
-		exit_error("Cannot Process your request: No TYPE specified ",'oauthprovider'); // you can create items in Base.tab and customize this messages
-	} elseif ((!$name)&&(!$id)) {
-		exit_error("Cannot Process your request: No NAME or ID specified",'oauthprovider');
-	} else {
-		if ($type == 'group') {
 			if($name)	{
 				$group = group_get_object_by_name($name);
 				$id = $group->getID();
@@ -80,8 +81,29 @@
 			// DO THE STUFF FOR THE PROJECT PART HERE
 						
 			echo "We are in the Project oauthprovider plugin page for group (project) $id <br><br>";
-			
-		} elseif ($type == 'user') {
+}
+
+function oauthprovider_CheckUser() {
+	if (!session_loggedin()) {
+		exit_not_logged_in();
+	}	
+
+	$user = session_get_user(); // get the session user
+
+	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+		exit_error("Invalid User, Cannot Process your request for trequire_once $gfwww.'admin/admin_utils.php';
+		his user.", 'oauthprovider');
+	}
+
+	$name = getStringFromRequest('name');
+	//$id = getStringFromRequest('id');
+	$id = $user->getID();
+	
+	if ((!$name)&&(!$id)) {
+		exit_error("Cannot Process your request: No NAME or ID specified",'oauthprovider');
+	}
+	$pluginname = 'oauthprovider';
+	
 			if($name) $realuser = user_get_object_by_name($name);
 			else  $realuser = user_get_object($id);
 			if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
@@ -90,11 +112,70 @@
 			if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private oauthprovider part of this user
 				exit_error("Access Denied, You cannot access other user's personal $pluginname", 'oauthprovider');
 			}
-			oauthprovider_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));    
+			oauthprovider_User_Header(array('title'=>'Personal page for OAuth','pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));    
 			// DO THE STUFF FOR THE USER PART HERE
 			echo "We are in the User oauthprovider plugin page for user <br><br>";
+}
+
+function oauthprovider_CheckProjectAdmin() {
+
+	if (!session_loggedin()) {
+		exit_not_logged_in();
+	}	
+
+	$user = session_get_user(); // get the session user
+
+	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+		exit_error("Invalid User, Cannot Process your request for this user.", 'oauthprovider');
+	}
+
+	$name = getStringFromRequest('name');
+	$pluginname = 'oauthprovider';
+	
+			if($name)	{
+				$group = group_get_object_by_name($name);
+				$id = $group->getID();
+			}
+			else $group = group_get_object($id);
 			
-		} elseif ($type == 'admin') {
+			if ( !$group) {
+				exit_error("Invalid Project", 'oauthprovider');
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oauthprovider plugin active
+				exit_error("Error, First activate the $pluginname plugin through the Project's Admin Interface", 'oauthprovider');			
+			}
+			
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied, You are not a member of this project", 'oauthprovider');
+			}
+			
+			//only project admin can access here
+			if ( $userperm->isAdmin() ) {
+				oauthprovider_Project_Header(array('group'=>$id, 'title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+				// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+				//echo "We are in the Project oauthprovider plugin page for <font color=\"#ff0000\">ADMINISTRATION</font> <br><br>";
+				
+			} else {
+				exit_error("Access Denied, You are not a project Admin", 'oauthprovider');
+			}
+}
+
+function oauthprovider_CheckSiteAdmin() {
+
+	if (!session_loggedin()) {
+		exit_not_logged_in();
+	}	
+
+	$user = session_get_user(); // get the session user
+
+	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+		exit_error("Invalid User, Cannot Process your request for this user.", 'oauthprovider');
+	}
+
+	$name = getStringFromRequest('name');
+	$pluginname = 'oauthprovider';
+	/*
 			if($name)	{
 				$group = group_get_object_by_name($name);
 				$id = $group->getID();
@@ -107,10 +188,12 @@
 			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oauthprovider plugin active
 				exit_error("Error, First activate the $pluginname plugin through the Project's Admin Interface", 'oauthprovider');			
 			}
+			
 			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
 			if ( !$userperm->IsMember()) {
 				exit_error("Access Denied, You are not a member of this project", 'oauthprovider');
 			}
+			
 			//only project admin can access here
 			if ( $userperm->isAdmin() ) {
 				oauthprovider_Project_Header(array('group'=>$id, 'title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
@@ -120,11 +203,14 @@
 			} else {
 				exit_error("Access Denied, You are not a project Admin", 'oauthprovider');
 			}
-		}
-		else {
-			exit_error("Cannot Process your request: Invalid TYPE specified", 'oauthprovider');
-		}
+			*/
+	if(! forge_check_global_perm ('forge_admin')) {
+		exit_error("Access Denied, You are not a site Admin", 'oauthprovider');
 	}
-	$i = 0;
 	
+	oauthprovider_Admin_Header();
+	
+	
+}
+
 ?>
\ No newline at end of file

Modified: trunk/src/plugins/oauthprovider/www/consumer.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -1,6 +1,8 @@
 <?php
 
 /**
+ * Manage OAuth consumers
+ * 
  * This file is (c) Copyright 2010 by Olivier BERGER, Madhumita DHAR, Institut TELECOM
  *
  * This program is free software; you can redistribute it and/or
@@ -27,6 +29,10 @@
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
+oauthprovider_CheckSiteAdmin();
+
 $user = session_get_user(); // get the session user
 $t_consumers = OauthAuthzConsumer::load_all();
 
@@ -35,28 +41,11 @@
 
 // FIXME : use $HTML->boxTop() and likes bellow
 if(count($t_consumers)>0)	{	
-?>
+	echo $HTML->boxTop(_('OAuth consumers'));
 
-<br/>
-<table align="center" cellspacing="1">
-
-  <tr>
-  <td class="form-title"><?php echo $plugin_oauthprovider_consumers ?></td>
-  </tr>
-
-  <tr class="row-category">
-  <td><?php echo $plugin_oauthprovider_consumer ?></td>
-  <td><?php echo $plugin_oauthprovider_url ?></td>
-  <td><?php echo $plugin_oauthprovider_desc ?></td>
-  <td><?php echo $plugin_oauthprovider_email ?></td>
-  <td><?php echo $plugin_oauthprovider_key ?></td>
-  <td><?php echo $plugin_oauthprovider_secret ?></td>  
-  <td></td>
-  <td></td>
-  </tr>
-
-<?php
-			
+	echo $HTML->listTableTop(array(_('Consumer'), _('URL'), _('Description'), _('Email'), _('Key'), _('Secret'), '', ''));
+	
+	$i = 0;
 	foreach( $t_consumers as $t_consumer ) { ?>
 	<tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
     <td><?php echo ( $t_consumer->getName() ) ?></td>
@@ -73,65 +62,67 @@
 	}*/ ?></td>
 	<td class="center">
       <?php 
-	if ( $t_can_manage ) {
-	  
-	  print util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname . '&consumer_id=' . $t_consumer->getId() , $plugin_oauthprovider_manage);
+	if ( $t_can_manage ) {	  
+	  print util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_consumer->getId() , _('Manage'));
 	}
       ?>
     </td>
     <td class="center">
       <?php 
 	if ( $t_can_manage ) {
-	  print util_make_link('/plugins/'.$pluginname.'/consumer_delete.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname . '&consumer_id=' . $t_consumer->getId() . '&plugin_oauthprovider_consumer_delete_token='.form_generate_key(), $plugin_oauthprovider_delete);
-	  
+	  print util_make_link('/plugins/'.$pluginname.'/consumer_delete.php?consumer_id=' . $t_consumer->getId() . '&plugin_oauthprovider_consumer_delete_token='.form_generate_key(), _('Delete'));
 	}
-      ?>
-    </td>    
-  </tr>
-<?php } ?>
+    } 
+    echo $HTML->listTableBottom();
+    
+echo $HTML->boxBottom();
 
-</table>
-
-<?php
 }
 else {
-	echo '<p>There are currently no customers in the database.</p>';
+	echo '<p>'. _('There are currently no OAuth consumers registered in the database').'</p>';
 }
 
-if ( $t_can_manage ) { ?>
+if ( $t_can_manage ) { 
+
+$f_consumer_name = getStringFromPost( 'consumer_name' );
+$f_consumer_url = getStringFromPost( 'consumer_url' );
+$f_consumer_desc = getStringFromPost( 'consumer_desc' );
+$f_consumer_email = getStringFromPost( 'consumer_email' );
+	
+	?>
 <br/>
-<form action="<?php echo 'consumer_create.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname ?>" method="post">
+<form action="consumer_create.php" method="post">
 <?php echo '<input type="hidden" name="plugin_oauthprovider_consumer_create_token" value="'.form_generate_key().'"/>' ?>
 <table class="width50" align="center" cellspacing="1">
 
 <tr>
-<td class="form-title" colspan="2"><?php echo $plugin_oauthprovider_create_consumer ?></td>
+<td class="form-title" colspan="2"><?php echo _('Create Consumer') ?></td>
 </tr>
 
-<tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_name ?></td>
-<td><input name="consumer_name" maxlength="128" size="40"/></td>
+<tr>
+<td class="category"><?php echo _('Name') ?></td>
+<td><input name="consumer_name" maxlength="128" size="40" value="<?php echo $f_consumer_name ?>"/></td>
 </tr>
 
-<tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_url ?></td>
-<td><input name="consumer_url" maxlength="250" size="40"/></td>
+<tr>
+<td class="category"><?php echo _('URL') ?></td>
+<td><input name="consumer_url" maxlength="250" size="40" value="<?php echo $f_consumer_url ?>"/></td>
 </tr>
 
-<tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_desc ?></td>
-<td><input name="consumer_desc" maxlength="250" size="40"/></td>
+<tr>
+<td class="category"><?php echo _('Description') ?></td>
+<td><input name="consumer_desc" maxlength="250" size="40" value="<?php echo $f_consumer_desc ?>"/></td>
 </tr>
 
-<tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_email ?></td>
-<td><input name="consumer_email" maxlength="250" size="40"/></td>
+<tr>
+<td class="category"><?php echo _('Email') ?></td>
+<td><input name="consumer_email" maxlength="250" size="40" value="<?php echo $f_consumer_email ?>"/></td>
 </tr>
 
 
 
 <tr>
-<td class="center" colspan="2"><input type="submit" value="<?php echo $plugin_oauthprovider_create_consumer ?>"/></td>
+<td class="center" colspan="2"><input type="submit" value="<?php echo _('Create Consumer') ?>"/></td>
 </tr>
 
 </table>

Modified: trunk/src/plugins/oauthprovider/www/consumer_create.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_create.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer_create.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -28,7 +28,10 @@
 
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
 
+global $feedback;
+
 if(!form_key_is_valid(getStringFromRequest('plugin_oauthprovider_consumer_create_token')))	{
 	exit_form_double_submit('admin');
 }
@@ -43,9 +46,12 @@
 
 	if (($msg=OauthAuthzConsumer::check_consumer_values($f_consumer_name, $f_consumer_url, $f_consumer_desc, $f_consumer_email))!=null) {
 		//$missing_params[] = _('"Consumer Name"');
-		echo "<p><font color=\"#ff0000\">.$msg.</font></p>"; 
+		$feedback .= $msg; 
 		//exit_missing_param('', $missing_params,'oauthprovider');
 		form_release_key(getStringFromRequest('plugin_oauthprovider_consumer_create_token'));
+		
+		//site_admin_header(array('title'=>_('Create OAuth consumer')));
+		
 		include 'consumer.php';
 	}
 	else {
@@ -60,5 +66,5 @@
 
 		form_release_key(getStringFromRequest('plugin_oauthprovider_consumer_create_token'));
 
-		session_redirect( '/plugins/'.$pluginname.'/consumer.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname);
+		session_redirect( '/plugins/'.$pluginname.'/consumer.php');
 	}
\ No newline at end of file

Modified: trunk/src/plugins/oauthprovider/www/consumer_delete.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_delete.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer_delete.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -26,6 +26,7 @@
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
 
 form_key_is_valid(getStringFromRequest('plugin_oauthprovider_consumer_delete_token'));
 
@@ -41,4 +42,4 @@
 $t_consumer->delete();
 
 form_release_key(getStringFromRequest('plugin_oauthprovider_consumer_delete_token'));
-session_redirect( '/plugins/'.$pluginname.'/index.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname);
+session_redirect( '/plugins/'.$pluginname.'/consumer.php');

Modified: trunk/src/plugins/oauthprovider/www/consumer_manage.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_manage.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer_manage.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -26,6 +26,10 @@
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
+oauthprovider_CheckSiteAdmin();
+
 session_require_global_perm('forge_admin');
 
 $f_consumer_id = getIntFromGet( 'consumer_id' );
@@ -39,41 +43,42 @@
 <table class="width75" align="center" cellspacing="1">
 
 <tr>
-<td class="form-title" colspan="2"><?php echo $plugin_oauthprovider_manage_consumer ?></td>
+<td class="form-title" colspan="2"><?php echo _('Manage Consumer') ?></td>
 <td class="right">
 <?php
-	print util_make_link('/plugins/'.$pluginname.'/index.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname , $plugin_oauthprovider_back);
+	print util_make_link('/plugins/'.$pluginname.'/consumer.php' , _('Back'));
 ?>
 </td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_name ?></td>
+
+<td class="category"><?php echo _('Name') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->getName() ) ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_url ?></td>
+<td class="category"><?php echo _('URL') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->getUrl() ) ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_desc ?></td>
+<td class="category"><?php echo _('Description') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->getDesc() ) ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_email ?></td>
+<td class="category"><?php echo _('Email') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->getEmail() ) ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_key ?></td>
+<td class="category"><?php echo _('Key') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->key ) ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_secret ?></td>
+<td class="category"><?php echo _('Secret') ?></td>
 <td colspan="2"><?php echo ( $t_consumer->secret ) ?></td>
 </tr>
 
@@ -85,14 +90,14 @@
 
 <tr>
 <td colspan="1">
-<form action="<?php echo 'consumer_update_page.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname . '&consumer_id=' . $t_consumer->getId() ?>" method="post">
-	<input type="submit" value="<?php echo $plugin_oauthprovider_update_consumer ?>"/>
+<form action="<?php echo 'consumer_update_page.php?consumer_id=' . $t_consumer->getId() ?>" method="post">
+	<input type="submit" value="<?php echo _('Update Consumer') ?>"/>
 </form>
 </td>
 <td colspan="1">
-<form action="<?php echo 'consumer_delete.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname . '&consumer_id=' . $t_consumer->getId() ?>" method="post">
+<form action="<?php echo 'consumer_delete.php?consumer_id=' . $t_consumer->getId() ?>" method="post">
 	<?php echo '<input type="hidden" name="plugin_oauthprovider_consumer_delete_token" value="'.form_generate_key().'"/>' ?>
-	<input type="submit" value="<?php echo $plugin_oauthprovider_delete_consumer ?>"/>
+	<input type="submit" value="<?php echo _('Delete Consumer') ?>"/>
 </form>
 </td>
 </tr>

Modified: trunk/src/plugins/oauthprovider/www/consumer_update.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_update.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer_update.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -27,6 +27,8 @@
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
 form_key_is_valid(getStringFromRequest( 'plugin_oauthprovider_consumer_update_token' ));
 
 //access_ensure_global_level( plugin_config_get( 'manage_threshold' ) ); // equivalent function to be added later for ff
@@ -59,4 +61,4 @@
 
 form_release_key(getStringFromRequest( 'plugin_oauthprovider_consumer_update_token' ));
 
-session_redirect( '/plugins/'.$pluginname.'/consumer_manage.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname. '&consumer_id=' . $t_consumer->getId()  );
+session_redirect( '/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_consumer->getId()  );

Modified: trunk/src/plugins/oauthprovider/www/consumer_update_page.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_update_page.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/consumer_update_page.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -22,11 +22,14 @@
  *
  */
 
-
 require_once('../../env.inc.php');
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
+oauthprovider_CheckSiteAdmin();
+
 session_require_global_perm('forge_admin');
 
 $f_consumer_id = getIntFromGet( 'consumer_id' );
@@ -38,49 +41,49 @@
 ?>
 
 <br/>
-<form action="<?php echo 'consumer_update.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname ?>" method="post">
+<form action="consumer_update.php" method="post">
 <?php echo '<input type="hidden" name="plugin_oauthprovider_consumer_update_token" value="'.form_generate_key().'"/>' ?>
 <input type="hidden" name="consumer_id" value="<?php echo $t_consumer->getId() ?>"/>
 <table class="width60" align="center" cellspacing="1">
 
 <tr>
-<td class="form-title"><?php echo $plugin_oauthprovider_update_consumer ?></td>
-<td class="right"><?php print util_make_link("/plugins/".$pluginname.'/consumer_manage.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname. '&consumer_id=' . $t_consumer->getId(), $plugin_oauthprovider_back_consumer ); ?></td>
+<td class="form-title"><?php echo _('Update Consumer') ?></td>
+<td class="right"><?php print util_make_link("/plugins/".$pluginname.'/consumer_manage.php?consumer_id=' . $t_consumer->getId(), _('Cancel') ); ?></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_name ?></td>
+<td class="category"><?php echo _('Name') ?></td>
 <td><input name="consumer_name" maxlength="128" size="40" value="<?php echo ( $t_consumer->getName() ) ?>"/></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_url ?></td>
+<td class="category"><?php echo _('URL') ?></td>
 <td><input name="consumer_url" maxlength="250" size="40" value="<?php echo ( $t_consumer->getUrl() ) ?>"/></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_desc ?></td>
+<td class="category"><?php echo _('Description') ?></td>
 <td><input name="consumer_desc" maxlength="250" size="40" value="<?php echo ( $t_consumer->getDesc() ) ?>"/></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_email ?></td>
+<td class="category"><?php echo _('Email') ?></td>
 <td><input name="consumer_email" maxlength="250" size="40" value="<?php echo ( $t_consumer->getEmail() ) ?>"/></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_key ?></td>
+<td class="category"><?php echo _('Key') ?></td>
 <td><input name="consumer_key" readonly="readonly" maxlength="250" size="40" value="<?php echo ( $t_consumer->key ) ?>"/></td>
 </tr>
 
 <tr <?php echo $HTML->boxGetAltRowStyle($i++) ?>>
-<td class="category"><?php echo $plugin_oauthprovider_secret ?></td>
+<td class="category"><?php echo _('Secret') ?></td>
 <td><input name="consumer_secret" readonly="readonly" maxlength="250" size="40" value="<?php echo ( $t_consumer->secret ) ?>"/></td>
 </tr>
 
 <tr>
-<td class="center" colspan="1"><input type="submit" name="update" value="<?php echo  $plugin_oauthprovider_update_consumer ?>"/></td>
-<td class="center" colspan="1"><input type="submit" name="keys_update" value="<?php echo  $plugin_oauthprovider_renew_keys_update_consumer ?>"/></td>
+<td class="center" colspan="1"><input type="submit" name="update" value="<?php echo  _('Update Consumer') ?>"/></td>
+<td class="center" colspan="1"><input type="submit" name="keys_update" value="<?php echo  _('Regenerate keys & Update Consumer') ?>"/></td>
 </tr>
 </table>
 </form>

Modified: trunk/src/plugins/oauthprovider/www/index.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/index.php	2011-03-25 18:47:30 UTC (rev 12919)
+++ trunk/src/plugins/oauthprovider/www/index.php	2011-03-25 18:47:42 UTC (rev 12920)
@@ -25,6 +25,10 @@
 require_once('../../env.inc.php');
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
+oauthprovider_CheckUser();
+
 ?>
 
 <h3>OAuth endpoints</h3>
@@ -59,13 +63,13 @@
 <?php
 //global $plugin_oauthprovider_consumers, $plugin_oauthprovider_request_tokens;
 # Create a basic href link to the manage.php plugin page
-if(($type == 'admin')||(forge_check_global_perm ('forge_admin'))	){
-	echo '<a href="', '/plugins/'.$pluginname.'/consumer.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname , '">', 'Consumers', '</a> <br>';
+if( forge_check_global_perm ('forge_admin') ){
+	echo util_make_link('/plugins/'.$pluginname.'/consumer.php', _('Consumers')). ' <br />';
 }
 
 
-echo '<a href="', '/plugins/'.$pluginname.'/request_tokens.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname , '">', 'Request tokens', '</a><br> ';
-echo '<a href="', '/plugins/'.$pluginname.'/access_tokens.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname , '">', 'Access tokens', '</a><br> ';
+echo '<a href="', '/plugins/'.$pluginname.'/request_tokens.php?type='.$type.'&id='.$id , '">', 'Request tokens', '</a><br> ';
+echo util_make_link('/plugins/'.$pluginname.'/access_tokens.php', _('Access tokens')).'<br /> ';
 
 //html_page_bottom();
 site_project_footer(array());




More information about the Fusionforge-commits mailing list