aboutsummaryrefslogtreecommitdiff
path: root/lib/filesystem/MaterialFolder.php
blob: 9996701396b76d3e8c783b32f76df304a29432c8 (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
76
77
78
79
<?php
/**
 * HiddenFolder.php
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author    Dominik Feldschnieders <dofeldsc@uos.de>
 * @copyright 2016 Stud.IP Core-Group
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category  Stud.IP
 */
class MaterialFolder extends PermissionEnabledFolder
{

    public static $sorter = 3;

    public static function availableInRange($range_id_or_object, $user_id)
    {
        $range_id = is_object($range_id_or_object) ? $range_id_or_object->id : $range_id_or_object;
        return Seminar_Perm::get()->have_studip_perm('tutor', $range_id, $user_id);
    }

    /**
     * MaterialFolder constructor.
     */
    public function __construct($folderdata = null)
    {
        parent::__construct($folderdata);

        $this->permission = 5;
    }

    /**
     * This function returns the suitable Icon for this folder type (GroupFolder)
     *
     * @return Icon The icon object for this folder type
     */
    public function getIcon($role = Icon::DEFAULT_ROLE)
    {
        return Icon::create('download', $role);
    }

    /**
     * Returns the name of the MaterialFolder type.
     *
     * @return string the name of the MaterialFolder type
     */
    static public function getTypeName()
    {
        return _('Materialordner zum Anbieten von Inhalten zum Download');
    }

    /**
     * There is nothing special you can edit at this folder
     */
    public function getEditTemplate()
    {
        return '';
    }

    /**
     * Returns the description template for a instance of a MaterialFolder type
     *
     * @return mixed A description template for a instance of the type MaterialFolder
     */
    public function getDescriptionTemplate()
    {
        $template = $GLOBALS['template_factory']->open('filesystem/material_folder/description.php');

        $template->type       = self::getTypeName();
        $template->folder     = $this;
        $template->folderdata = $this->folderdata;

        return $template;
    }
}