Code Duplication    Length = 5-19 lines in 18 locations

main/session/session_course_user.php 1 location

@@ 83-87 (lines=5) @@
80
        exit;
81
    }
82
83
    if (count($CourseList) == count($existingCourses)) {
84
        Display::addFlash(Display::return_message(get_lang('MaybeYouWantToDeleteThisUserFromSession')));
85
        header('Location: session_course_user.php?id_session='.$id_session.'&id_user='.$id_user);
86
        exit;
87
    }
88
89
    foreach ($CourseList as $enreg_course) {
90
        $exists = false;

main/admin/user_update_import.php 1 location

@@ 411-416 (lines=6) @@
408
    // if the warning message is too long then we display the warning message trough a session
409
    Display::addFlash(Display::return_message($warning_message, 'warning', false));
410
411
    if ($error_kind_file) {
412
        Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'error', false));
413
    } else {
414
        header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_list.php?sec_token='.$tok);
415
        exit;
416
    }
417
418
}
419
Display :: display_header($tool_name);

main/badge/assign.php 2 locations

@@ 127-134 (lines=8) @@
124
125
    $skill = $skillRepo->find($values['skill']);
126
127
    if (!$skill) {
128
        Display::addFlash(
129
            Display::return_message(get_lang('SkillNotFound'), 'error')
130
        );
131
132
        header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()]));
133
        exit;
134
    }
135
136
    if ($user->hasSkill($skill)) {
137
        Display::addFlash(
@@ 31-38 (lines=8) @@
28
$skillUserRepo = $entityManager->getRepository('ChamiloCoreBundle:SkillRelUser');
29
$user = $entityManager->find('ChamiloUserBundle:User', $_REQUEST['user']);
30
31
if (!$user) {
32
    Display::addFlash(
33
        Display::return_message(get_lang('NoUser'), 'error')
34
    );
35
36
    header('Location: ' . api_get_path(WEB_PATH));
37
    exit;
38
}
39
40
$skills = $skillRepo->findBy([
41
    'status' => Skill::STATUS_ENABLED

main/auth/lostPassword.php 1 location

@@ 101-107 (lines=7) @@
98
        exit;
99
    }
100
101
    if ($user['auth_source'] == 'extldap') {
102
        Display::addFlash(
103
            Display::return_message(get_lang('CouldNotResetPasswordBecauseLDAP'), 'info', false)
104
        );
105
        header('Location: ' . api_get_path(WEB_PATH));
106
        exit;
107
    }
108
109
    $userResetPasswordSetting = api_get_setting('user_reset_password');
110

main/badge/issued.php 2 locations

@@ 24-31 (lines=8) @@
21
$skillRepo = $entityManager->getRepository('ChamiloCoreBundle:Skill');
22
$skillLevelRepo = $entityManager->getRepository('ChamiloSkillBundle:Level');
23
24
if (!$skillIssue) {
25
    Display::addFlash(
26
        Display::return_message(get_lang('TheUserXNotYetAchievedTheSkillX'), 'error')
27
    );
28
29
    header('Location: ' . api_get_path(WEB_PATH));
30
    exit;
31
}
32
33
$user = $skillIssue->getUser();
34
$skill = $skillIssue->getSkill();
@@ 36-43 (lines=8) @@
33
$user = $skillIssue->getUser();
34
$skill = $skillIssue->getSkill();
35
36
if (!$user || !$skill) {
37
    Display::addFlash(
38
        Display::return_message(get_lang('NoResults'), 'error')
39
    );
40
41
    header('Location: ' . api_get_path(WEB_PATH));
42
    exit;
43
}
44
45
$userInfo = [
46
    'id' => $user->getId(),

main/exercise/exercise_report.php 1 location

@@ 247-253 (lines=7) @@
244
            api_get_user_id()
245
        );
246
247
        if ($allowCoachFeedbackExercises) {
248
            Display::addFlash(
249
                Display::return_message(get_lang('MessageSent'))
250
            );
251
            header('Location: ' . api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId);
252
            exit;
253
        }
254
    }
255
256
    // Updating LP score here

main/badge/issued_all.php 1 location

@@ 28-35 (lines=8) @@
25
26
$currentUserId = api_get_user_id();
27
28
if (!$user || !$skill) {
29
    Display::addFlash(
30
        Display::return_message(get_lang('NoResults'), 'error')
31
    );
32
33
    header('Location: ' . api_get_path(WEB_PATH));
34
    exit;
35
}
36
37
$userSkills = $skillUserRepo->findBy([
38
    'user' => $user,

main/auth/external_login/facebook.inc.php 1 location

@@ 139-146 (lines=8) @@
136
        // We have to create the user
137
        $chamilo_uid = external_add_user($u);
138
139
        if ($chamilo_uid === false) {
140
            Display::addFlash(
141
                Display::return_message(get_lang('UserNotRegistered'), 'error')
142
            );
143
144
            header('Location: ' . api_get_path(WEB_PATH));
145
            exit;
146
        }
147
148
        $_user['user_id'] = $chamilo_uid;
149
        $_SESSION['_user'] = $_user;

main/admin/user_import.php 1 location

@@ 457-462 (lines=6) @@
454
    Display::addFlash(Display::return_message($warning_message, 'warning', false));
455
    Display::addFlash(Display::return_message($see_message_import, 'confirmation', false));
456
457
    if ($error_kind_file) {
458
        Display::addFlash(
459
            Display::return_message(
460
                get_lang('YouMustImportAFileAccordingToSelectedOption'),
461
                'error',
462
                false
463
            )
464
        );
465
    } else {

main/badge/criteria.php 1 location

@@ 14-21 (lines=8) @@
11
$entityManager = Database::getManager();
12
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $_GET['id']);
13
14
if (!$skill) {
15
    Display::addFlash(
16
        Display::return_message(get_lang('SkillNotFound'), 'error')
17
    );
18
19
    header('Location: ' . api_get_path(WEB_PATH));
20
    exit;
21
}
22
23
$skillInfo = [
24
    'name' => $skill->getName(),

main/gradebook/gradebook_view_result.php 2 locations

@@ 177-182 (lines=6) @@
174
                    $nr_results_added++;
175
                }
176
            }
177
        } else {
178
            header('Location: ' . api_get_self() . '?import=&selecteval=' . $select_eval . '&importnofile=');
179
            Display::addFlash(Display::return_message(get_lang('ImportNoFile'), 'warning', false));
180
181
            exit;
182
        }
183
        if ($overwritescore != 0) {
184
            header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&importoverwritescore=' . $overwritescore);
185
            Display::addFlash(Display::return_message(get_lang('ImportOverWriteScore') . ' ' . $overwritescore));
@@ 188-192 (lines=5) @@
185
            Display::addFlash(Display::return_message(get_lang('ImportOverWriteScore') . ' ' . $overwritescore));
186
            exit;
187
        }
188
        if ($nr_results_added == 0) {
189
            Display::addFlash(Display::return_message(get_lang('ProblemUploadingFile'), 'warning', false));
190
            header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&nothingadded=');
191
            exit;
192
        }
193
        Display::addFlash(Display::return_message(get_lang('FileUploadComplete'), 'success', false));
194
        header('Location: ' . api_get_self() . '?selecteval=' . $select_eval . '&importok=');
195
        exit;

main/lp/lp_add_category.php 1 location

@@ 51-57 (lines=7) @@
48
        Display::addFlash(Display::return_message(get_lang('Updated')));
49
        header('Location: '.$url);
50
        exit;
51
    } else {
52
        learnpath::createCategory($values);
53
        Display::addFlash(Display::return_message(get_lang('Added')));
54
        $url = api_get_self().'?action=list&'.api_get_cidreq();
55
        header('Location: '.$url);
56
        exit;
57
    }
58
} else {
59
    $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
60

main/inc/lib/usermanager.lib.php 1 location

@@ 285-303 (lines=19) @@
282
            }
283
        }
284
285
        if (empty($password)) {
286
            if ($authSource === PLATFORM_AUTH_SOURCE) {
287
                Display::addFlash(
288
                    Display::return_message(
289
                        get_lang('ThisFieldIsRequired').': '.get_lang(
290
                            'Password'
291
                        ),
292
                        'warning'
293
                    )
294
                );
295
296
                return false;
297
            }
298
299
            // We use the authSource as password.
300
            // The real validation will be by processed by the auth
301
            // source not Chamilo
302
            $password = $authSource;
303
        }
304
305
        // database table definition
306
        $table_user = Database::get_main_table(TABLE_MAIN_USER);

plugin/ims_lti/edit.php 1 location

@@ 18-25 (lines=8) @@
15
$plugin = ImsLtiPlugin::create();
16
$tool = ImsLtiTool::fetch($toolId);
17
18
if (empty($tool)) {
19
    Display::addFlash(
20
        Display::return_message($plugin->get_lang('NoTool'), 'error')
21
    );
22
23
    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php');
24
    exit;
25
}
26
27
$form = new FormValidator('ims_lti_edit_tool');
28
$form->addText('name', get_lang('Name'));

main/inc/lib/fileUpload.lib.php 1 location

@@ 282-290 (lines=9) @@
279
280
            // At least if the directory doesn't exist, tell so
281
            if (!is_dir($whereToSave)) {
282
                if (!mkdir($whereToSave, api_get_permissions_for_new_directories())) {
283
                    if ($output) {
284
                        Display::addFlash(
285
                            Display::return_message(get_lang('DestDirectoryDoesntExist').' ('.$uploadPath.')', 'error')
286
                        );
287
                    }
288
289
                    return false;
290
                }
291
            }
292
293
            // Just upload the file "as is"