aboutsummaryrefslogtreecommitdiff
path: root/app/views/file/choose_file_from_course.php
blob: 6de5332ee787909ade9e1fba97b22678fc88db1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
$options = [];
if (Request::get('to_plugin')) {
    $options['to_plugin'] = Request::get('to_plugin');
}
if (Request::get('from_plugin')) {
    $options['from_plugin'] = Request::get('from_plugin');
}
if (Request::get('range_type')) {
    $options['range_type'] = Request::get('range_type');
}
?>

<? if ($GLOBALS['perm']->have_perm('admin')) : ?>
    <form id="filechooser_course_search"
          action="<?= $controller->link_for('file/choose_file_from_course/' . $folder_id) ?>"
          data-dialog>
        <?= QuickSearch::get('course_id', new MyCoursesSearch('AnySeminar_id', $GLOBALS['perm']->get_perm(),
            [
                'userid'     => $GLOBALS['user']->id,
                'exclude'    => Request::submitted('cid') ? [Request::get('cid')] : [],
                'institutes' => array_column(Institute::getMyInstitutes(), 'Institut_id')
            ]))
            ->fireJSFunctionOnSelect("function () { jQuery('#filechooser_course_search').submit(); }")
            ->setInputStyle('width: calc(100% - 40px); margin: 20px;')
            ->render() ?>
    </form>
<? else : ?>
    <table class="default">
        <thead>
            <tr>
                <th><?= _('Bild') ?></th>
                <th><?= _('Name') ?></th>
                <th><?= _('Semester') ?></th>
                <th class="actions"><?= _('Zum Dateibereich') ?></th>
            </tr>
        </thead>
        <tbody>
        <? foreach ($courses as $course) : ?>
            <tr>
                <td class="avatar">
                    <a href="<?= $controller->link_for('file/choose_file_from_course/' . $folder_id, array_merge($options, ['course_id' => $course->id])) ?>" data-dialog>
                        <? if ($course->isStudygroup()) : ?>
                            <?= StudygroupAvatar::getAvatar($course->id)->getImageTag(Avatar::MEDIUM, ['style' => 'width: 50px; height: 50px;']) ?>
                        <? else : ?>
                            <?= CourseAvatar::getAvatar($course->id)->getImageTag(Avatar::MEDIUM, ['style' => 'width: 50px; height: 50px;']) ?>
                        <? endif ?>
                    </a>
                </td>
                <td>
                    <a href="<?= $controller->link_for('file/choose_file_from_course/' . $folder_id, array_merge($options, ['course_id' => $course->id])) ?>" data-dialog>
                        <?= htmlReady($course->getFullName()) ?>
                    </a>
                </td>
                <td>
                    <?= htmlReady($course->getTextualSemester()) ?>
                </td>
                <td class="actions">
                    <a href="<?= $controller->link_for('file/choose_file_from_course/' . $folder_id, array_merge($options, ['course_id' => $course->id])) ?>" data-dialog>
                        <?= Icon::create('folder-full')->asImg(30) ?>
                    </a>
                </td>
            </tr>
        <? endforeach; ?>
        </tbody>
    </table>
<? endif; ?>

<footer data-dialog-button>
    <?= Studip\LinkButton::create(
        _('Zurück'),
         $controller->action_url('add_files_window/' . Request::get('to_folder_id'), $options),
         ['data-dialog' => '']
    ) ?>
</footer>