redirect_url to be respected in linkTo function

This commit is contained in:
Aamir Khan 2011-06-25 01:14:28 +05:30
parent 7d2784c4c3
commit 2098cbd822
1 changed files with 12 additions and 5 deletions

17
lib/helper.php Normal file → Executable file
View File

@ -29,11 +29,12 @@ class OC_HELPER {
* @brief Creates an url * @brief Creates an url
* @param $app app * @param $app app
* @param $file file * @param $file file
* @param $redirect_url redirect_url variable is appended to the URL
* @returns the url * @returns the url
* *
* Returns a url to the given app and file. * 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 $WEBROOT;
global $SERVERROOT; global $SERVERROOT;
@ -41,20 +42,26 @@ class OC_HELPER {
$app .= '/'; $app .= '/';
// Check if the app is in the app folder // Check if the app is in the app folder
if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){ if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){
return $WEBROOT . '/apps/' . $app . $file; $urlLinkTo = $WEBROOT . '/apps/' . $app . $file;
} }
else{ else{
return $WEBROOT . '/' . $app . $file; $urlLinkTo = $WEBROOT . '/' . $app . $file;
} }
} }
else{ else{
if( file_exists( $SERVERROOT . '/core/'. $file )){ if( file_exists( $SERVERROOT . '/core/'. $file )){
return $WEBROOT . '/core/'.$file; $urlLinkTo = $WEBROOT . '/core/'.$file;
} }
else{ else{
return $WEBROOT . '/'.$file; $urlLinkTo = $WEBROOT . '/'.$file;
} }
} }
if($redirect_url)
return $urlLinkTo.'?redirect_url='.$redirect_url;
else
return $urlLinkTo;
} }
/** /**