Code Duplication    Length = 34-41 lines in 2 locations

main/gradebook/lib/GradebookUtils.php 2 locations

@@ 301-334 (lines=34) @@
298
     * @param int $selectcat id of selected category
299
     * @return string
300
     */
301
    public static function build_edit_icons_eval($eval, $selectcat)
302
    {
303
        $is_locked = $eval->is_locked();
304
        $eval->get_course_code();
305
        $cat = new Category();
306
        $message_eval = $cat->show_message_resource_delete($eval->getCourseId());
307
        $courseParams = api_get_cidreq_params($eval->get_course_code(), $eval->getSessionId());
308
309
        if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
310
            $visibility_icon = ($eval->is_visible() == 0) ? 'invisible' : 'visible';
311
            $visibility_command = ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible';
312
            if ($is_locked && !api_is_platform_admin()) {
313
                $modify_icons = Display::return_icon(
314
                    'edit_na.png',
315
                    get_lang('Modify'),
316
                    '',
317
                    ICON_SIZE_SMALL
318
                );
319
            } else {
320
                $modify_icons = '<a href="gradebook_edit_eval.php?editeval='.$eval->get_id().'&'.$courseParams.'">'.
321
                    Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>';
322
            }
323
324
            $modify_icons .= '&nbsp;<a href="'.api_get_self().'?visibleeval='.$eval->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&'.$courseParams.' ">'.
325
                Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>';
326
            if (api_is_allowed_to_edit(null, true)) {
327
                $modify_icons .= '&nbsp;<a href="gradebook_showlog_eval.php?visiblelog='.$eval->get_id().'&selectcat='.$selectcat.' &'.$courseParams.'">'.
328
                    Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>';
329
            }
330
331
            if ($is_locked && !api_is_platform_admin()) {
332
                $modify_icons .= '&nbsp;'.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
333
            } else {
334
                $modify_icons .= '&nbsp;<a href="'.api_get_self().'?deleteeval='.$eval->get_id().'&selectcat='.$selectcat.' &'.$courseParams.'" onclick="return confirmation();">'.
335
                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
336
            }
337
            return $modify_icons;
@@ 348-388 (lines=41) @@
345
     *
346
     * @return string
347
     */
348
    public static function build_edit_icons_link($link, $selectcat)
349
    {
350
        $cat = new Category();
351
        $message_link = $cat->show_message_resource_delete($link->getCourseId());
352
        $is_locked = $link->is_locked();
353
354
        $modify_icons = null;
355
356
        if (!api_is_allowed_to_edit(null, true)) {
357
            return null;
358
        }
359
360
        $courseParams = api_get_cidreq_params($link->get_course_code(), $link->get_session_id());
361
362
        if ($message_link === false) {
363
            $visibility_icon = ($link->is_visible() == 0) ? 'invisible' : 'visible';
364
            $visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible';
365
366
            if ($is_locked && !api_is_platform_admin()) {
367
                $modify_icons = Display::return_icon(
368
                    'edit_na.png',
369
                    get_lang('Modify'),
370
                    '',
371
                    ICON_SIZE_SMALL
372
                );
373
            } else {
374
                $modify_icons = '<a href="gradebook_edit_link.php?editlink='.$link->get_id().'&'.$courseParams.'">'.
375
                    Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>';
376
            }
377
            $modify_icons .= '&nbsp;<a href="'.api_get_self().'?visiblelink='.$link->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&'.$courseParams.' ">'.
378
                Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>';
379
            $modify_icons .= '&nbsp;<a href="gradebook_showlog_link.php?visiblelink='.$link->get_id().'&selectcat='.$selectcat.'&'.$courseParams.'">'.
380
                Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>';
381
382
            //If a work is added in a gradebook you can only delete the link in the work tool
383
384
            if ($is_locked && !api_is_platform_admin()) {
385
                $modify_icons .= '&nbsp;'.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
386
            } else {
387
                $modify_icons .= '&nbsp;<a href="'.api_get_self().'?deletelink='.$link->get_id().'&selectcat='.$selectcat.' &'.$courseParams.'" onclick="return confirmation();">'.
388
                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
389
            }
390
391
            return $modify_icons;