Newer
Older
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
<?php
/**
* RootFolder.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 André Noack <noack@data-quest.de>
* @copyright 2017 Stud.IP Core-Group
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class RootFolder extends StandardFolder
{
/**
* @return string
*/
public static function getTypeName()
{
return _('Hauptordner');
}
public static function availableInRange($range_id_or_object, $user_id)
{
return false;
}
/**
* @param string $attribute
* @return mixed
*/
public function __get($attribute)
{
if ($attribute === 'name') {
$range = $this->getRangeObject();
return isset($range) ? $range->getFullname('short') : '';
}
return $this->folderdata[$attribute];
}
/**
* @param string $user_id
* @return bool
*/
public function isWritable($user_id)
{
return ($this->range_type === 'user' && $this->range_id === $user_id)
|| $this->isEditable($user_id)
|| (
Seminar_Perm::get()->have_studip_perm('autor', $this->range_id, $user_id)
&& (
!$this->folderdata['data_content']
|| !$this->folderdata['data_content']['locked']
)
);
}
/**
* @param string $user_id
* @return bool
*/
public function isEditable($user_id)
{
return Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id, $user_id);
}
/**
* Returns the parent-folder as a StandardFolder
* @return FolderType
*/
public function getParent()
{
return null;
}
/**
* @return bool|number
*/
public function store()
{
$this->folderdata['parent_id'] = '';
return $this->folderdata->store();
}
/**
* @return Flexi_Template
*/
public function getEditTemplate()
{
$template = $GLOBALS['template_factory']->open('filesystem/root_folder/edit');
$template->folder = $this;
return $template;
}
/**
* @param array $request
* @return FolderType|MessageBox
*/
public function setDataFromEditTemplate($request)
{
$this->folderdata['data_content'] = [
'locked' => $request['locked'] ? 1 : 0
];
return parent::setDataFromEditTemplate($request);
}
}