chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '64', 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_courses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $sql = "SELECT c.code, c.title
                    FROM $tbl_course c
                    WHERE
                        c.code LIKE '$needle%'

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 "tool_name" is not in valid camel caps format
Open

    $tool_name = get_lang('Assign courses to session\'s administrator');

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

                        c.code LIKE '$needle%' $without_assigned_courses AND

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

                        $without_assigned_courses ";

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

                    LEFT JOIN $tbl_course_rel_access_url a

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

    $courses_list = isset($_POST['CoursesList']) ? $_POST['CoursesList'] : [];

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

        $without_assigned_courses = '';

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

            $without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';

Closing brace indented incorrectly; expected 8 spaces, found 4
Open

    } ?>

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

                foreach ($assigned_courses_to_hrm as $enreg) {

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

    return $xajax_response;

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

                c.code LIKE '$needle' $without_assigned_courses AND

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

            FROM $tbl_course c

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

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

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

$this_section = SECTION_PLATFORM_ADMIN;

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

$tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);

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

    global $tbl_course, $tbl_course_rel_access_url, $user_id;

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

        $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);

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

Display::display_header($tool_name);

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

    $without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';

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

$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);

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

    $tool_name = get_lang('Assign courses to platform\'s administrator');

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

    global $tbl_course, $tbl_course_rel_access_url, $user_id;

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

        $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);

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

                    FROM $tbl_course c

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

            LEFT JOIN $tbl_course_rel_access_url a

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

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

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

    $xajax_response = new xajaxResponse();

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

        if (count($assigned_courses_code) > 0) {

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

        $xajax_response->addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));

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_courses" is not in valid camel caps format
Open

$without_assigned_courses = '';

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;">

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

$user_anonymous = api_get_anonymous_id();

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

$current_user_id = api_get_user_id();

Missing function doc comment
Open

function search_courses($needle, $type)

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

        foreach ($assigned_courses_code as &$value) {

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

$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);

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

    global $tbl_course, $tbl_course_rel_access_url, $user_id;

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

        $assigned_courses_code = array_keys($assigned_courses_to_hrm);

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

    if ($affected_rows) {

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

$assigned_courses_code = array_keys($assigned_courses_to_hrm);

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

            FROM $tbl_course c

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

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

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

$add_type = 'multiple';

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

$UserList = [];

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

    $affected_rows = CourseManager::subscribeCoursesToDrhManager($user_id, $courses_list);

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

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

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

    $tool_name = get_lang('Assign courses to HR manager');

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

        $assigned_courses_code = array_keys($assigned_courses_to_hrm);

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

    $affected_rows = CourseManager::subscribeCoursesToDrhManager($user_id, $courses_list);

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

    $affected_rows = CourseManager::subscribeCoursesToDrhManager($user_id, $courses_list);

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

$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);

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

foreach ($assigned_courses_code as &$value) {

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

            if (is_array($assigned_courses_to_hrm)) {

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

$user_id = (int) ($_GET['user']);

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

$user = api_get_user_entity($user_id);

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

$assigned_courses_code = array_keys($assigned_courses_to_hrm);

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

$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);

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

function search_courses($needle, $type)

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

            $without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';

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

                    FROM $tbl_course c

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

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

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

    $without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';

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

            WHERE  c.code LIKE '$needle' $without_assigned_courses

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

} ?>

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

if (count($assigned_courses_code) > 0) {

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

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

Line indented incorrectly; expected 0 spaces, found 4
Open

    } ?>

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

} ?>

Closing brace indented incorrectly; expected 8 spaces, found 4
Open

    } ?>

The variable $tbl_course is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_code is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_to_hrm is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_course_rel_access_url is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_code is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_course is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_course is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_code is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_to_hrm is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses_code is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_course_rel_access_url is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses is not named in camelCase.
Open

function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;

    $xajax_response = new xajaxResponse();

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