|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
namespace Chamilo\CoreBundle\Tool; |
|
5
|
|
|
|
|
6
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class AbstractTool. |
|
10
|
|
|
*/ |
|
11
|
|
|
abstract class AbstractTool implements ToolInterface |
|
12
|
|
|
{ |
|
13
|
|
|
protected $name; |
|
14
|
|
|
protected $category; |
|
15
|
|
|
protected $link; |
|
16
|
|
|
protected $image; |
|
17
|
|
|
protected $admin; |
|
18
|
|
|
protected $courseSettings; |
|
19
|
|
|
protected $resourceTypes; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
* |
|
24
|
|
|
* 00 disabled tool |
|
25
|
|
|
* 01 course tool |
|
26
|
|
|
* 10 global tool |
|
27
|
|
|
* 11 global or course or both |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $scope; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param string $name |
|
33
|
|
|
* @param string $category |
|
34
|
|
|
* @param string $link |
|
35
|
|
|
* @param $courseSettings |
|
36
|
|
|
* @param array $resourceTypes |
|
37
|
|
|
* @param string $scope |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct($name, $category, $link, $courseSettings, $resourceTypes, $scope) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->name = $name; |
|
42
|
|
|
$this->category = $category; |
|
43
|
|
|
$this->link = $link; |
|
44
|
|
|
$this->image = $name.'.png'; |
|
45
|
|
|
$this->courseSettings = $courseSettings; |
|
46
|
|
|
$this->resourceTypes = $resourceTypes; |
|
47
|
|
|
$this->scope = $scope; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function isCourseTool() |
|
51
|
|
|
{ |
|
52
|
|
|
$value = bindec($this->scope); |
|
53
|
|
|
return $value === 1 || $value === 3; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function isGlobal() |
|
57
|
|
|
{ |
|
58
|
|
|
return bindec($this->scope) === 2; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getName() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->name; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getLink() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->link ? $this->link : ''; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getCategory() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->category; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* {@inheritdoc} |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getTarget() |
|
89
|
|
|
{ |
|
90
|
|
|
return '_self'; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* {@inheritdoc} |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getImage() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->image; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param $settings |
|
103
|
|
|
* |
|
104
|
|
|
* @return int |
|
105
|
|
|
*/ |
|
106
|
|
|
public function setCourseSettings($settings) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->courseSettings = $settings; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @return SchemaInterface |
|
113
|
|
|
*/ |
|
114
|
|
|
public function getCourseSettings() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->courseSettings; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return array |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getResourceTypes() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->resourceTypes; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function setResourceTypes(array $resourceTypes): AbstractTool |
|
128
|
|
|
{ |
|
129
|
|
|
$this->resourceTypes = $resourceTypes; |
|
130
|
|
|
|
|
131
|
|
|
return $this; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|