chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

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

    } else {
        $sql = "SELECT
                   code AS col0,
                   title AS col1,
                   category_code AS col2,

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

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

        } else {
            $course_request[4] = api_get_local_time($course_request[4]);
        }

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

The parameter $number_of_items is not named in camelCase.
Open

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

$this_section = SECTION_PLATFORM_ADMIN;

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

$is_error_message = isset($_GET['is_error_message']) ? !empty($_GET['is_error_message']) : '';

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

if ($course_validation_feature) {

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

            $message = sprintf(get_lang('The course request %s has been accepted. A new course %s has been created.'), $course_request_code, $course_code);

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

    } elseif (!empty($reject_course_request)) {

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

            $message = sprintf(get_lang('Additional information about the course request %s has been asked.'), $course_request_code);

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

                        $success &= CourseRequestManager::delete_course_request($course_request_id);

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

    while ($course_request = Database::fetch_row($res)) {

Multi-line function call not indented correctly; expected 0 spaces but found 4
Open

    ).

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

$delete_course_request = isset($_GET['delete_course_request']) ? (int) ($_GET['delete_course_request']) : '';

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

            $is_error_message = true;

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

            $is_error_message = true;

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

            $is_error_message = false;

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

        $course_requests[] = $course_request;

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

$tool_name = get_lang('Review incoming course requests');

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

        $course_id = CourseRequestManager::accept_course_request($accept_course_request);

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

                    foreach ($_POST['course_request'] as $index => $course_request_id) {

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

    $number_of_items = (int) $number_of_items;

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

        $course_requests[] = $course_request;

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

if (!$course_validation_feature) {

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

$request_info = isset($_GET['request_info']) ? (int) ($_GET['request_info']) : '';

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

            $is_error_message = false;

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

        $course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);

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

            $message = sprintf(get_lang('The course request %s has not been rejected due to internal error.'), $course_request_code);

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

        $course_request_code = CourseRequestManager::get_course_request_code($request_info);

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

    $course_requests = [];

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

    if ($is_error_message) {

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

            $is_error_message = true;

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

        $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);

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

        sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('Courses validation'))

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

    $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';

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

function modify_filter($id)

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

    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        StateIcon::COMPLETE,

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

               FROM $course_request_table

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        'ch-tool-icon',

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ICON_SIZE_SMALL,

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

        $course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);

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

        $course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);

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

            $message = sprintf(get_lang('The course request %s has been deleted.'), $course_request_code);

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

function get_request_data($from, $number_of_items, $column, $direction)

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

            $course_request[5] = api_get_local_time($course_request[5]);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        get_lang('Rejected course requests')

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

            $message = sprintf(get_lang('The course request %s has not been accepted due to internal error.'), $course_request_code);

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

            $is_error_message = false;

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

            $is_error_message = true;

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

Display::display_header($tool_name);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        get_lang('Accepted course requests')

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

$course_validation_feature = 'true' == api_get_setting('course_validation');

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

$accept_course_request = isset($_GET['accept_course_request']) ? (int) ($_GET['accept_course_request']) : '';

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

        $course_id = CourseRequestManager::accept_course_request($accept_course_request);

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

            $message = sprintf(get_lang('The course request %s has been rejected.'), $course_request_code);

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

    $number_of_items = (int) $number_of_items;

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

    return $course_requests;

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

function email_filter($teacher)

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        'ch-tool-icon',

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

    } elseif (!empty($delete_course_request)) {

Multi-line function call not indented correctly; expected 0 spaces but found 4
Open

    ).

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

        $course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);

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

            $message = sprintf(get_lang('The course request %s has been accepted. A new course %s has been created.'), $course_request_code, $course_code);

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

        $course_request_code = CourseRequestManager::get_course_request_code($request_info);

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

        $result = CourseRequestManager::delete_course_request($delete_course_request);

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

    $is_error_message = true;

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

function get_request_data($from, $number_of_items, $column, $direction)

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

            $course_request[5] = api_get_local_time($course_request[5]);

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

            $course_request[4] = api_get_local_time($course_request[4]);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        null,

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

            $course_code = CourseManager::get_course_code_from_course_id($course_id);

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

        $result = CourseRequestManager::ask_for_additional_info($request_info);

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

function get_number_of_requests()

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

               FROM $course_request_table

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

    if (!empty($accept_course_request)) {

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

    } elseif (!empty($request_info)) {

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

            $message = sprintf(get_lang('The course request %s has not been deleted due to internal error.'), $course_request_code);

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

            $course_request[4] = api_get_local_time($course_request[4]);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        StateIcon::INCOMPLETE,

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

$reject_course_request = isset($_GET['reject_course_request']) ? (int) ($_GET['reject_course_request']) : '';

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

        $result = CourseRequestManager::reject_course_request($reject_course_request);

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

    $sql .= " LIMIT $from,$number_of_items";

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

        if ($course_id) {

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

            $course_code = CourseManager::get_course_code_from_course_id($course_id);

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

            $message = sprintf(get_lang('Additional information about the course request %s has not been asked due to internal error.'), $course_request_code);

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

        $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);

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

            $is_error_message = false;

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

                $course_requests = $_POST['course_request'];

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

                    $is_error_message = !$success;

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        null,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ICON_SIZE_SMALL,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ICON_SIZE_SMALL,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        get_lang('Rejected course requests')

Multi-line function call not indented correctly; expected 0 spaces but found 4
Open

    ).

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        StateIcon::COMPLETE,

Multi-line function call not indented correctly; expected 0 spaces but found 4
Open

    ).

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        null,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        get_lang('Accepted course requests')

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        StateIcon::INCOMPLETE,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        'ch-tool-icon',

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        'ch-tool-icon',

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ICON_SIZE_SMALL,

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        null,

The variable $course_requests is not named in camelCase.
Open

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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

function get_request_data($from, $number_of_items, $column, $direction)
{
    global $keyword;
    $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);

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