Browse Source

[svn r22217] Allow direct login form when requesting auth/profile.php (improved integration with Drupal without affecting other code)

Yannick Warnier 15 years ago
parent
commit
4951bf87c8
2 changed files with 7 additions and 3 deletions
  1. 5 2
      main/auth/profile.php
  2. 2 1
      main/inc/lib/main_api.lib.php

+ 5 - 2
main/auth/profile.php

@@ -1,4 +1,4 @@
-<?php // $Id: profile.php 22027 2009-07-13 11:03:41Z ivantcholakov $
+<?php // $Id: profile.php 22217 2009-07-19 06:59:14Z yannoo $
 /* For licensing terms, see /dokeos_license.txt */
 /**
 ==============================================================================
@@ -26,7 +26,10 @@ if (!isset($_GET['show'])) {
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 $this_section = SECTION_MYPROFILE;
 $_SESSION['this_section']=$this_section;
-api_block_anonymous_users();
+
+if (!(isset ($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'],true)) {
+    api_not_allowed(true);
+}
 
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">

+ 2 - 1
main/inc/lib/main_api.lib.php

@@ -1857,6 +1857,7 @@ function api_not_allowed($print_headers = false) {
 	$home_url = api_get_path(WEB_PATH);
 	$user = api_get_user_id();
 	$course = api_get_course_id();
+    global $this_section;
 	
 	$origin = isset($_GET['origin'])?$_GET['origin']:'';
 	
@@ -1882,7 +1883,7 @@ function api_not_allowed($print_headers = false) {
 		echo '</div>';
 		if ($print_headers && $origin != 'learnpath'){Display::display_footer();}
 		die();
-	} elseif (!empty($_SERVER['REQUEST_URI']) && !empty($_GET['cidReq'])) {
+	} elseif (!empty($_SERVER['REQUEST_URI']) && (!empty($_GET['cidReq']) || $this_section == SECTION_MYPROFILE)) {
 		//only display form and return to the previous URL if there was a course ID included
 		if (!empty($user) && !api_is_anonymous()) {
 			if ((!headers_sent() or $print_headers) && $origin != 'learnpath') { Display::display_header('');}