Bläddra i källkod

Removed condition for login_as using parameters not yet defined

Yannick Warnier 11 år sedan
förälder
incheckning
ba31509bd6
1 ändrade filer med 66 tillägg och 21 borttagningar
  1. 66 21
      main/admin/user_information.php

+ 66 - 21
main/admin/user_information.php

@@ -1,10 +1,13 @@
 <?php
 <?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 /**
 /**
- *    @author Bart Mollet
- *    @package chamilo.admin
+ * Script showing information about a user (name, e-mail, courses and sessions)
+ * @author Bart Mollet
+ * @package chamilo.admin
+ */
+/**
+ * INIT SECTION
  */
  */
-/* INIT SECTION */
 // name of the language file that needs to be included
 // name of the language file that needs to be included
 $language_file = 'admin';
 $language_file = 'admin';
 $cidReset = true;
 $cidReset = true;
@@ -20,6 +23,10 @@ if (!isset($_GET['user_id'])) {
 }
 }
 $user = api_get_user_info($_GET['user_id']);
 $user = api_get_user_info($_GET['user_id']);
 $tool_name = $user['complete_name'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
 $tool_name = $user['complete_name'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
+
+/**
+ * Display
+ */
 Display::display_header($tool_name);
 Display::display_header($tool_name);
 
 
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -37,15 +44,25 @@ if (isset($_GET['action'])) {
     }
     }
 }
 }
 // only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
 // only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
-$statusname = api_get_status_langvars();
 $login_as_icon = null;
 $login_as_icon = null;
 $editUser = null;
 $editUser = null;
-if (api_is_platform_admin() || (api_is_session_admin() && $row['6'] == $statusname[STUDENT])) {
-    $login_as_icon = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user['user_id'].'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>';
-    $editUser = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array()), api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user['user_id']);
+if (api_is_platform_admin()) {
+    $login_as_icon =
+        '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php'
+        .'?action=login_as&amp;user_id='.$user['user_id'].'&amp;'
+        .'sec_token='.$_SESSION['sec_token'].'">'
+        .Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>';
+    $editUser = Display::url(
+        Display::return_icon(
+            'edit.png',
+            get_lang('Edit'),
+            array()
+        ),
+        api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user['user_id']
+    );
 }
 }
 echo '<div class="actions">
 echo '<div class="actions">
-        <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.intval($_GET['user_id']).'" title="'.get_lang('Reporting').'">'.Display::return_icon('statistics.png',get_lang('Reporting'),'',  ICON_SIZE_MEDIUM).'
+        <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.intval($_GET['user_id']).'" title="'.get_lang('Reporting').'">'.Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM).'
         </a>
         </a>
         '.$login_as_icon.'
         '.$login_as_icon.'
         '.$editUser.'
         '.$editUser.'
@@ -54,9 +71,9 @@ echo '<div class="actions">
 echo Display::page_header($tool_name);
 echo Display::page_header($tool_name);
 
 
 // Getting the user image
 // Getting the user image
-$sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'system',false,true);
+$sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'system', false, true);
 $sysdir = $sysdir_array['dir'];
 $sysdir = $sysdir_array['dir'];
-$webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'web',false,true);
+$webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
 $webdir = $webdir_array['dir'];
 $webdir = $webdir_array['dir'];
 $fullurl = $webdir.$webdir_array['file'];
 $fullurl = $webdir.$webdir_array['file'];
 $system_image_path = $sysdir.$webdir_array['file'];
 $system_image_path = $sysdir.$webdir_array['file'];
@@ -65,9 +82,15 @@ $resizing = (($height > 200) ? 'height="200"' : '');
 $height += 30;
 $height += 30;
 $width += 30;
 $width += 30;
 $window_name = 'window'.uniqid('');
 $window_name = 'window'.uniqid('');
-$onclick = $window_name."=window.open('".$fullurl."','".$window_name."','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=".$width.",height=".$height.",left=200,top=20'); return false;";
-echo '<a href="javascript: void(0);" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
-echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
+$onclick = $window_name."=window.open('".$fullurl."','".$window_name
+    ."','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,"
+    ."location=no,directories=no,status=no,menubar=no,scrollbars=no,"
+    ."resizable=no,width=".$width.",height=".$height.",left=200,top=20');"
+    ." return false;";
+echo '<a href="javascript: void(0);" onclick="'.$onclick.'" >'
+    .'<img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
+echo '<p>'.($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student'))
+    .'</p>';
 echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
 echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
 
 
 /**
 /**
@@ -139,10 +162,21 @@ if (count($sessions) > 0) {
             $session_item['date_end'] = null;
             $session_item['date_end'] = null;
         }
         }
 
 
-        $dates = array_filter(array($session_item['date_start'], $session_item['date_end']));
-        echo Display::page_subheader($session_item['session_name'], ' '.implode(' - ', $dates));
-
-        Display :: display_sortable_table($header, $data, array (), array(), array ('user_id' => intval($_GET['user_id'])));
+        $dates = array_filter(
+            array($session_item['date_start'], $session_item['date_end'])
+        );
+        echo Display::page_subheader(
+            $session_item['session_name'],
+            ' '.implode(' - ', $dates)
+        );
+
+        Display :: display_sortable_table(
+            $header,
+            $data,
+            array (),
+            array(),
+            array ('user_id' => intval($_GET['user_id']))
+        );
     }
     }
 } else {
 } else {
     echo '<p>'.get_lang('NoSessionsForThisUser').'</p>';
     echo '<p>'.get_lang('NoSessionsForThisUser').'</p>';
@@ -171,15 +205,20 @@ if (Database::num_rows($res) > 0) {
         $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
         $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
                 '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
                 '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
                 '<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
                 '<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
-        if ( $course->status == STUDENT ) {
+        if ($course->status == STUDENT) {
             $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
             $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
-
         }
         }
         $row[] = $tools;
         $row[] = $tools;
         $data[] = $row;
         $data[] = $row;
     }
     }
     echo Display::page_subheader(get_lang('Courses'));
     echo Display::page_subheader(get_lang('Courses'));
-    Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
+    Display :: display_sortable_table(
+        $header,
+        $data,
+        array (),
+        array (),
+        array ('user_id' => intval($_GET['user_id']))
+    );
 } else {
 } else {
     echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
     echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
 }
 }
@@ -198,7 +237,13 @@ if (api_is_multiple_url_enabled()) {
             $data[] = $row;
             $data[] = $row;
         }
         }
         echo '<p><b>'.get_lang('URLList').'</b></p>';
         echo '<p><b>'.get_lang('URLList').'</b></p>';
-        Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
+        Display :: display_sortable_table(
+            $header,
+            $data,
+            array (),
+            array (),
+            array ('user_id' => intval($_GET['user_id']))
+        );
     } else {
     } else {
         echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
         echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
     }
     }