chamilo/chamilo-lms

View on GitHub
public/main/admin/dashboard_add_sessions_to_user.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '65', column '27').
Open

    $xajax_response = new xajaxResponse();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method search_sessions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $sql = "SELECT s.id, s.name FROM $tbl_session s
                    WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Variable "this_section" is not in valid camel caps format
Open

$this_section = SECTION_PLATFORM_ADMIN;

Variable "user_id" is not in valid camel caps format
Open

$user = api_get_user_entity($user_id);

Consider putting global function "search_sessions" in a static class
Open

function search_sessions($needle, $type)

Missing function doc comment
Open

function search_sessions($needle, $type)

Variable "tbl_session" is not in valid camel caps format
Open

    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);

Variable "tbl_session_rel_access_url" is not in valid camel caps format
Open

                     LEFT JOIN $tbl_session_rel_access_url a

Variable "assigned_sessions_id" is not in valid camel caps format
Open

$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);

Variable "assigned_sessions_id" is not in valid camel caps format
Open

if (count($assigned_sessions_id) > 0) {

Variable "without_assigned_sessions" is not in valid camel caps format
Open

            WHERE  s.name LIKE '$needle%' $without_assigned_sessions

Variable "tbl_session_rel_access_url" is not in valid camel caps format
Open

$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

Variable "user_id" is not in valid camel caps format
Open

if (UserManager::is_admin($user_id)) {

Variable "assigned_sessions_id" is not in valid camel caps format
Open

        if (count($assigned_sessions_id) > 0) {

Variable "ajax_search" is not in valid camel caps format
Open

                if ($ajax_search) {

Variable "add_type" is not in valid camel caps format
Open

$add_type = 'multiple';

Variable "user_id" is not in valid camel caps format
Open

    $userInfo = api_get_user_info($user_id);

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

        $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);

Variable "user_id" is not in valid camel caps format
Open

<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id; ?>" style="margin:0px;" <?php if ($ajax_search) {

Variable "tbl_session" is not in valid camel caps format
Open

            $sql = " SELECT s.id, s.name FROM $tbl_session s

Variable "user_id" is not in valid camel caps format
Open

$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);

Variable "current_user_id" is not in valid camel caps format
Open

$current_user_id = api_get_user_id();

Variable "tool_name" is not in valid camel caps format
Open

    $tool_name = get_lang('Assign sessions to Human Resources manager');

Variable "xajax_response" is not in valid camel caps format
Open

    $xajax_response = new xajaxResponse();

Variable "without_assigned_sessions" is not in valid camel caps format
Open

            $without_assigned_sessions = ' AND s.id NOT IN('.implode(',', $assigned_sessions_id).')';

Variable "xajax_response" is not in valid camel caps format
Open

        $xajax_response->addAssign(

Variable "user_anonymous" is not in valid camel caps format
Open

$user_anonymous = api_get_anonymous_id();

Variable "add_type" is not in valid camel caps format
Open

    $add_type = Security::remove_XSS($_REQUEST['add_type']);

Variable "user_id" is not in valid camel caps format
Open

    $actionsLeft = '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.

Variable "without_assigned_sessions" is not in valid camel caps format
Open

    $without_assigned_sessions = ' AND s.id NOT IN ('.implode(',', $assigned_sessions_id).') ';

Variable "tbl_session" is not in valid camel caps format
Open

            FROM $tbl_session s

Variable "tbl_session_rel_access_url" is not in valid camel caps format
Open

            LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)

Variable "tbl_session" is not in valid camel caps format
Open

    $sql = "SELECT s.id, s.name FROM $tbl_session s

Variable "ajax_search" is not in valid camel caps format
Open

<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id; ?>" style="margin:0px;" <?php if ($ajax_search) {

Variable "without_assigned_sessions" is not in valid camel caps format
Open

        $without_assigned_sessions = '';

Variable "tool_name" is not in valid camel caps format
Open

    $tool_name = get_lang('Assign sessions to platform administrator');

Variable "tbl_session" is not in valid camel caps format
Open

            $sql = "SELECT s.id, s.name FROM $tbl_session s

Variable "affected_rows" is not in valid camel caps format
Open

    $affected_rows = SessionManager::subscribeSessionsToDrh(

Variable "user_id" is not in valid camel caps format
Open

    $actionsLeft .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.

Variable "without_assigned_sessions" is not in valid camel caps format
Open

                s.name LIKE '$needle%' $without_assigned_sessions AND

Variable "tool_name" is not in valid camel caps format
Open

                echo '<button class="btn btn--success" type="button" value="" onclick="valide()" >'.$tool_name.'</button>';

Variable "tbl_session" is not in valid camel caps format
Open

$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);

Variable "user_id" is not in valid camel caps format
Open

        $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);

Variable "without_assigned_sessions" is not in valid camel caps format
Open

                        s.name LIKE '$needle%' $without_assigned_sessions AND

Variable "without_assigned_sessions" is not in valid camel caps format
Open

                    WHERE  s.name LIKE '$needle%' $without_assigned_sessions ";

Variable "sessions_list" is not in valid camel caps format
Open

        $sessions_list

Variable "user_id" is not in valid camel caps format
Open

                if (UserManager::is_admin($user_id)) {

Variable "tbl_session_rel_access_url" is not in valid camel caps format
Open

    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

        $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);

Variable "UserList" is not in valid camel caps format
Open

$UserList = [];

Variable "add_type" is not in valid camel caps format
Open

                <?php if ('multiple' == $add_type) {

Variable "ajax_search" is not in valid camel caps format
Open

$ajax_search = false;

Variable "user_id" is not in valid camel caps format
Open

    global $user_id;

Variable "assigned_sessions_id" is not in valid camel caps format
Open

            $without_assigned_sessions = ' AND s.id NOT IN('.implode(',', $assigned_sessions_id).')';

Variable "sessions_list" is not in valid camel caps format
Open

    $sessions_list = $_POST['SessionsList'];

Variable "affected_rows" is not in valid camel caps format
Open

    if ($affected_rows) {

Variable "assigned_sessions_id" is not in valid camel caps format
Open

    $without_assigned_sessions = ' AND s.id NOT IN ('.implode(',', $assigned_sessions_id).') ';

Variable "assigned_sessions_id" is not in valid camel caps format
Open

        $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);

Variable "tool_name" is not in valid camel caps format
Open

Display::display_header($tool_name);

Variable "without_assigned_sessions" is not in valid camel caps format
Open

$without_assigned_sessions = '';

Variable "user_id" is not in valid camel caps format
Open

$user_id = isset($_GET['user']) ? (int) ($_GET['user']) : null;

Variable "tool_name" is not in valid camel caps format
Open

    $tool_name = get_lang('Assign sessions to sessions administrator');

Variable "xajax_response" is not in valid camel caps format
Open

    return $xajax_response;

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);

Closing brace indented incorrectly; expected 16 spaces, found 20
Open

                    } ?>

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

                if (is_array($assigned_sessions_to_hrm)) {

Variable "assigned_sessions_to_hrm" is not in valid camel caps format
Open

                    foreach ($assigned_sessions_to_hrm as $enreg) {

Closing brace indented incorrectly; expected 46 spaces, found 0
Open

}?>>

Line indented incorrectly; expected 0 spaces, found 20
Open

                    } ?>

Closing brace indented incorrectly; expected 16 spaces, found 20
Open

                    } ?>

Line indented incorrectly; expected 12 spaces, found 16
Open

                } else {

Line indented incorrectly; expected 12 spaces, found 16
Open

                if ($ajax_search) {

Line indented incorrectly; expected 12 spaces, found 16
Open

                }

The variable $xajax_response is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_id is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $assigned_sessions_id is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tbl_session is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tbl_session_rel_access_url is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tbl_session is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $without_assigned_sessions is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $xajax_response is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $assigned_sessions_id is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $without_assigned_sessions is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $assigned_sessions_id is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $without_assigned_sessions is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $xajax_response is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $assigned_sessions_to_hrm is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tbl_session is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_id is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tbl_session_rel_access_url is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $without_assigned_sessions is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $assigned_sessions_to_hrm is not named in camelCase.
Open

function search_sessions($needle, $type)
{
    global $user_id;
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status