Browse Source

Minor - format code.

jmontoyaa 7 years ago
parent
commit
1b1aba20f9
2 changed files with 172 additions and 44 deletions
  1. 32 6
      main/admin/course_list.php
  2. 140 38
      main/admin/user_list.php

+ 32 - 6
main/admin/course_list.php

@@ -321,8 +321,14 @@ $actions = '';
 
 if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
     // Get all course categories
-    $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-    $interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
+    $interbreadcrumb[] = array(
+        'url' => 'index.php',
+        'name' => get_lang('PlatformAdmin')
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'course_list.php',
+        'name' => get_lang('CourseList')
+    );
     $tool_name = get_lang('SearchACourse');
     $form = new FormValidator('advanced_course_search', 'get');
     $form->addElement('header', $tool_name);
@@ -364,7 +370,10 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
     $form->setDefaults($defaults);
     $content .= $form->returnForm();
 } else {
-    $interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
+    $interbreadcrumb[] = array(
+        'url' => 'index.php',
+        "name" => get_lang('PlatformAdmin')
+    );
     $tool_name = get_lang('CourseList');
     if (isset($_GET['delete_course'])) {
         CourseManager::delete_course($_GET['delete_course']);
@@ -391,7 +400,14 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
     $advanced = '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/course_list.php?search=advanced"><em class="fa fa-search"></em> '.get_lang('AdvancedSearch').'</a>';
 
     // Create a filter by session
-    $sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
+    $sessionFilter = new FormValidator(
+        'course_filter',
+        'get',
+        '',
+        '',
+        array(),
+        FormValidator::LAYOUT_INLINE
+    );
     $url = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_session';
     $sessionSelect = $sessionFilter->addElement(
         'select_ajax',
@@ -408,13 +424,23 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
 
     $courseListUrl = api_get_self();
     $actions1 = Display::url(
-        Display::return_icon('new_course.png', get_lang('AddCourse'), [], ICON_SIZE_MEDIUM),
+        Display::return_icon(
+            'new_course.png',
+            get_lang('AddCourse'),
+            [],
+            ICON_SIZE_MEDIUM
+        ),
         api_get_path(WEB_CODE_PATH).'admin/course_add.php'
     );
 
     if (api_get_setting('course_validation') === 'true') {
         $actions1 .= Display::url(
-            Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests'), [], ICON_SIZE_MEDIUM),
+            Display::return_icon(
+                'course_request_pending.png',
+                get_lang('ReviewCourseRequests'),
+                [],
+                ICON_SIZE_MEDIUM
+            ),
             api_get_path(WEB_CODE_PATH).'admin/course_request_review.php'
         );
     }

+ 140 - 38
main/admin/user_list.php

@@ -14,8 +14,8 @@ require_once __DIR__.'/../inc/global.inc.php';
 
 api_protect_admin_script(true);
 
-$current_access_url_id = api_get_current_access_url_id();
-$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null;
+$urlId = api_get_current_access_url_id();
+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
 
 // Blocks the possibility to delete a user
 $deleteUserAvailable = true;
@@ -316,9 +316,13 @@ function prepare_user_sql_query($is_count)
             $keyword_extra_value
         ";
 
-        if (isset($keywordListValues['keyword_active']) && !isset($keywordListValues['keyword_inactive'])) {
+        if (isset($keywordListValues['keyword_active']) &&
+            !isset($keywordListValues['keyword_inactive'])
+        ) {
             $sql .= " AND u.active = 1";
-        } elseif (isset($keywordListValues['keyword_inactive']) && !isset($keywordListValues['keyword_active'])) {
+        } elseif (isset($keywordListValues['keyword_inactive']) &&
+            !isset($keywordListValues['keyword_active'])
+        ) {
             $sql .= " AND u.active = 0";
         }
         $sql .= " ) ";
@@ -385,8 +389,8 @@ function prepare_user_sql_query($is_count)
     }
 
     // adding the filter to see the user's only of the current access_url
-    if ((api_is_platform_admin() || api_is_session_admin())
-        && api_get_multiple_access_url()
+    if ((api_is_platform_admin() || api_is_session_admin()) &&
+        api_get_multiple_access_url()
     ) {
         $sql .= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
     }
@@ -439,7 +443,10 @@ function get_user_data($from, $number_of_items, $column, $direction)
     $users = array();
     $t = time();
     while ($user = Database::fetch_row($res)) {
-        $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
+        $userPicture = UserManager::getUserPicture(
+            $user[0],
+            USER_IMAGE_SIZE_SMALL
+        );
         $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
 
         if ($user[7] == 1 && !empty($user[10])) {
@@ -559,17 +566,36 @@ function modify_filter($user_id, $url_params, $row)
     }
 
     if ($current_user_status_label != $statusname[STUDENT]) {
-        $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).'&nbsp;';
+        $result .= Display::return_icon(
+            'statistics_na.gif',
+            get_lang('Reporting')
+        ).'&nbsp;';
     } else {
-        $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>&nbsp;';
+        $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.
+            Display::return_icon('statistics.gif', get_lang('Reporting')).
+            '</a>&nbsp;';
     }
 
     if (api_is_platform_admin(true)) {
         $editProfileUrl = Display::getProfileEditionLink($user_id, true);
-        if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
-            $result .= '<a href="'.$editProfileUrl.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
+        if (!$user_is_anonymous &&
+            api_global_admin_can_edit_admin($user_id, null, true)
+        ) {
+            $result .= '<a href="'.$editProfileUrl.'">'.
+                Display::return_icon(
+                    'edit.png',
+                    get_lang('Edit'),
+                    array(),
+                    ICON_SIZE_SMALL
+                ).
+                '</a>&nbsp;';
         } else {
-            $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
+            $result .= Display::return_icon(
+                'edit_na.png',
+                get_lang('Edit'),
+                array(),
+                ICON_SIZE_SMALL
+            ).'</a>&nbsp;';
         }
     }
 
@@ -577,7 +603,12 @@ function modify_filter($user_id, $url_params, $row)
 
     if ($allowAssignSkill) {
         $result .= Display::url(
-            Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_SMALL),
+            Display::return_icon(
+                'skill-badges.png',
+                get_lang('AssignSkill'),
+                null,
+                ICON_SIZE_SMALL
+            ),
             api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $user_id])
         );
     }
@@ -589,14 +620,20 @@ function modify_filter($user_id, $url_params, $row)
             array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL)
         );
     } else {
-        $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
+        $result .= Display::return_icon(
+            'admin_star_na.png',
+            get_lang('IsNotAdministrator')
+        );
     }
 
     // actions for assigning sessions, courses or users
     if (!api_is_session_admin()) {
         if ($current_user_status_label == $statusname[SESSIONADMIN]) {
             $result .= Display::url(
-                Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
+                Display::return_icon(
+                    'view_more_stats.gif',
+                    get_lang('AssignSessions')
+                ),
                 "dashboard_add_sessions_to_user.php?user={$user_id}"
             );
         } else {
@@ -605,19 +642,30 @@ function modify_filter($user_id, $url_params, $row)
                 $current_user_status_label == $statusname[STUDENT_BOSS]
             ) {
                 $result .= Display::url(
-                    Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL),
+                    Display::return_icon(
+                        'user_subscribe_course.png',
+                        get_lang('AssignUsers'),
+                        '',
+                        ICON_SIZE_SMALL
+                    ),
                     "dashboard_add_users_to_user.php?user={$user_id}"
                 );
             }
 
             if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) {
                 $result .= Display::url(
-                    Display::return_icon('course_add.gif', get_lang('AssignCourses')),
+                    Display::return_icon(
+                        'course_add.gif',
+                        get_lang('AssignCourses')
+                    ),
                     "dashboard_add_courses_to_user.php?user={$user_id}"
                 );
 
                 $result .= Display::url(
-                    Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
+                    Display::return_icon(
+                        'view_more_stats.gif',
+                        get_lang('AssignSessions')
+                    ),
                     "dashboard_add_sessions_to_user.php?user={$user_id}"
                 );
             }
@@ -640,7 +688,14 @@ function modify_filter($user_id, $url_params, $row)
                 api_global_admin_can_edit_admin($user_id)
             ) {
                 // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
-                $result .= ' <a href="user_list.php?action=delete_user&user_id='.$user_id.'&'.$url_params.'&sec_token='.Security::getTokenFromSession().'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
+                $result .= ' <a href="user_list.php?action=delete_user&user_id='.$user_id.'&'.$url_params.'&sec_token='.Security::getTokenFromSession().'"  onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;">'.
+                Display::return_icon(
+                    'delete.png',
+                    get_lang('Delete'),
+                    array(),
+                    ICON_SIZE_SMALL
+                ).
+                '</a>';
             } else {
                 $result .= Display::return_icon(
                     'delete_na.png',
@@ -682,9 +737,16 @@ function active_filter($active, $params, $row)
     $result = '';
 
     if ($action === 'edit') {
-        $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16);
+        $result = Display::return_icon(
+            $image.'.png',
+            get_lang('AccountExpired'),
+            array(),
+            16
+        );
     } elseif ($row['0'] <> $_user['user_id']) {
-        // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
+        // you cannot lock yourself out otherwise you could disable all the
+        // accounts including your own => everybody is locked out and nobody
+        // can change it anymore.
         $result = Display::return_icon(
             $image.'.png',
             get_lang(ucfirst($action)),
@@ -727,11 +789,11 @@ if (!empty($action)) {
     if ($check) {
         switch ($action) {
             case 'add_user_to_my_url':
-                $user_id = $_REQUEST["user_id"];
-                $result = UrlManager::add_user_to_url($user_id, $current_access_url_id);
+                $user_id = $_REQUEST['user_id'];
+                $result = UrlManager::add_user_to_url($user_id, $urlId);
                 if ($result) {
                     $user_info = api_get_user_info($user_id);
-                    $message = get_lang('UserAdded').' '.$user_info['firstname'].' '.$user_info['lastname'].' ('.$user_info['username'].')';
+                    $message = get_lang('UserAdded').' '.$user_info['complete_name'].' ('.$user_info['username'].')';
                     $message = Display::return_message($message, 'confirmation');
                 }
                 break;
@@ -741,17 +803,27 @@ if (!empty($action)) {
                     $userToDeleteInfo = api_get_user_info($user_to_delete);
                     $current_user_id = api_get_user_id();
 
-                    if ($userToDeleteInfo && $deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) {
-                        if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) {
-                            $message = Display :: return_message(
+                    if ($userToDeleteInfo && $deleteUserAvailable &&
+                        api_global_admin_can_edit_admin($_GET['user_id'])
+                    ) {
+                        if ($user_to_delete != $current_user_id &&
+                            UserManager::delete_user($_GET['user_id'])
+                        ) {
+                            $message = Display::return_message(
                                 get_lang('UserDeleted').': '.$userToDeleteInfo['complete_name_with_username'],
                                 'confirmation'
                             );
                         } else {
-                            $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
+                            $message = Display::return_message(
+                                get_lang('CannotDeleteUserBecauseOwnsCourse'),
+                                'error'
+                            );
                         }
                     } else {
-                        $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error');
+                        $message = Display::return_message(
+                            get_lang('CannotDeleteUser'),
+                            'error'
+                        );
                     }
                     Display::addFlash($message);
                     header('Location: '.api_get_self());
@@ -772,9 +844,15 @@ if (!empty($action)) {
                         }
                     }
                     if ($number_of_selected_users == $number_of_deleted_users) {
-                        $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation');
+                        $message = Display::return_message(
+                            get_lang('SelectedUsersDeleted'),
+                            'confirmation'
+                        );
                     } else {
-                        $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error');
+                        $message = Display::return_message(
+                            get_lang('SomeUsersNotDeleted'),
+                            'error'
+                        );
                     }
                 }
                 break;
@@ -855,7 +933,12 @@ $status_options[DRH] = get_lang('Drh');
 $status_options[SESSIONADMIN] = get_lang('SessionsAdmin');
 $status_options[PLATFORM_ADMIN] = get_lang('Administrator');
 
-$form->addElement('select', 'keyword_status', get_lang('Profile'), $status_options);
+$form->addElement(
+    'select',
+    'keyword_status',
+    get_lang('Profile'),
+    $status_options
+);
 
 $active_group = array();
 $active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active'));
@@ -915,7 +998,9 @@ $table->set_column_filter(8, 'active_filter');
 $table->set_column_filter(10, 'modify_filter');
 
 // Only show empty actions bar if delete users has been blocked
-if (api_is_platform_admin() && !api_get_configuration_value('deny_delete_users')) {
+if (api_is_platform_admin() &&
+    !api_get_configuration_value('deny_delete_users')
+) {
     $table->set_form_actions(array('delete' => get_lang('DeleteFromPlatform')));
 } else {
     $table->set_form_actions(array('none' => get_lang('NoActionAvailable')));
@@ -929,7 +1014,12 @@ if ($table->get_total_number_of_items() == 0) {
     if (api_get_multiple_access_url() && isset($_REQUEST['keyword'])) {
         $keyword = Database::escape_string($_REQUEST['keyword']);
         $conditions = array('username' => $keyword);
-        $user_list = UserManager::get_user_list($conditions, array(), false, ' OR ');
+        $user_list = UserManager::get_user_list(
+            $conditions,
+            array(),
+            false,
+            ' OR '
+        );
         if (!empty($user_list)) {
             $extra_search_options = Display::page_subheader(get_lang('UsersFoundInOtherPortals'));
 
@@ -950,7 +1040,7 @@ if ($table->get_total_number_of_items() == 0) {
                 $add_user = true;
                 if (!empty($access_info)) {
                     foreach ($access_info as $url_info) {
-                        if ($current_access_url_id == $url_info['access_url_id']) {
+                        if ($urlId == $url_info['access_url_id']) {
                             $add_user = false;
                         }
                         $access_info_to_string .= $url_info['url'].'<br />';
@@ -961,14 +1051,26 @@ if ($table->get_total_number_of_items() == 0) {
                     $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') ';
                     $row_table[] = $access_info_to_string;
                     $url = api_get_self().'?action=add_user_to_my_url&user_id='.$user['id'].'&sec_token='.Security::getTokenFromSession();
-                    $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn'));
+                    $row_table[] = Display::url(
+                        get_lang('AddUserToMyURL'),
+                        $url,
+                        array('class' => 'btn')
+                    );
 
                     foreach ($row_table as $cell) {
                         $table->setCellContents($row, $column, $cell);
-                        $table->updateCellAttributes($row, $column, 'align="center"');
+                        $table->updateCellAttributes(
+                            $row,
+                            $column,
+                            'align="center"'
+                        );
                         $column++;
                     }
-                    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
+                    $table->updateRowAttributes(
+                        $row,
+                        $row % 2 ? 'class="row_even"' : 'class="row_odd"',
+                        true
+                    );
                     $row++;
                 }
             }