From 2098cbd8222fe7657fec5538798426495a9b9888 Mon Sep 17 00:00:00 2001
From: Aamir Khan <ak4u2009@gmail.com>
Date: Sat, 25 Jun 2011 01:14:28 +0530
Subject: [PATCH] redirect_url to be respected in linkTo function

---
 lib/helper.php | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 lib/helper.php

diff --git a/lib/helper.php b/lib/helper.php
old mode 100644
new mode 100755
index 8cd6ebf75a..96d5bfad82
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -29,11 +29,12 @@ class OC_HELPER {
 	 * @brief Creates an url
 	 * @param $app app
 	 * @param $file file
+	 * @param $redirect_url redirect_url variable is appended to the URL
 	 * @returns the url
 	 *
 	 * Returns a url to the given app and file.
 	 */
-	public static function linkTo( $app, $file ){
+	public static function linkTo( $app, $file , $redirect_url=NULL ){
 		global $WEBROOT;
 		global $SERVERROOT;
 		
@@ -41,20 +42,26 @@ class OC_HELPER {
 			$app .= '/';
 			// Check if the app is in the app folder
 			if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){
-				return $WEBROOT . '/apps/' . $app . $file;
+				$urlLinkTo =  $WEBROOT . '/apps/' . $app . $file;
 			}
 			else{
-				return $WEBROOT . '/' . $app . $file;
+				$urlLinkTo =  $WEBROOT . '/' . $app . $file;
 			}
 		}
 		else{
 			if( file_exists( $SERVERROOT . '/core/'. $file )){
-				return $WEBROOT . '/core/'.$file;
+				$urlLinkTo =  $WEBROOT . '/core/'.$file;
 			}
 			else{
-				return $WEBROOT . '/'.$file;
+				$urlLinkTo =  $WEBROOT . '/'.$file;
 			}
 		}
+
+		if($redirect_url)
+			return $urlLinkTo.'?redirect_url='.$redirect_url;
+		else
+			return $urlLinkTo;
+
 	}
 
 	/**
-- 
GitLab