|
31 | 31 | * @copyright 2024 Catalyst IT
|
32 | 32 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
33 | 33 | */
|
34 |
| -class cmsfield extends \core_search\base_activity { |
35 |
| - |
36 |
| - /** |
37 |
| - * @var array Internal quick static cache. |
38 |
| - */ |
39 |
| - protected $cmsdata = []; |
40 |
| - |
41 |
| - /** |
42 |
| - * @var array Internal quick static cache. |
43 |
| - */ |
44 |
| - protected $defaultvalues = null; |
| 34 | +class activity extends \core_search\base_activity { |
45 | 35 |
|
46 | 36 | /**
|
47 | 37 | * Returns the document associated with this data id.
|
@@ -89,76 +79,6 @@ public function get_document($record, $options = []) {
|
89 | 79 | return $doc;
|
90 | 80 | }
|
91 | 81 |
|
92 |
| - /** |
93 |
| - * Whether the user can access the document or not. |
94 |
| - * |
95 |
| - * @param int $id data id |
96 |
| - * @return bool |
97 |
| - */ |
98 |
| - public function check_access($id) { |
99 |
| - try { |
100 |
| - $data = $this->get_data($id); |
101 |
| - $cminfo = $this->get_cm('cms', $data->id, $data->courseid); |
102 |
| - $context = \context_module::instance($cminfo->id); |
103 |
| - } catch (\dml_missing_record_exception $ex) { |
104 |
| - return \core_search\manager::ACCESS_DELETED; |
105 |
| - } catch (\dml_exception $ex) { |
106 |
| - return \core_search\manager::ACCESS_DENIED; |
107 |
| - } |
108 |
| - |
109 |
| - // Recheck uservisible although it should have already been checked in core_search. |
110 |
| - if ($cminfo->uservisible === false) { |
111 |
| - return \core_search\manager::ACCESS_DENIED; |
112 |
| - } |
113 |
| - |
114 |
| - if (!has_capability('mod/cms:view', $context)) { |
115 |
| - return \core_search\manager::ACCESS_DENIED; |
116 |
| - } |
117 |
| - |
118 |
| - return \core_search\manager::ACCESS_GRANTED; |
119 |
| - } |
120 |
| - |
121 |
| - /** |
122 |
| - * Link to the cms. |
123 |
| - * |
124 |
| - * @param \core_search\document $doc |
125 |
| - * @return \moodle_url |
126 |
| - */ |
127 |
| - public function get_doc_url(\core_search\document $doc) { |
128 |
| - $contextmodule = \context::instance_by_id($doc->get('contextid')); |
129 |
| - $cm = get_coursemodule_from_id('cms', $contextmodule->instanceid, $doc->get('courseid'), true); |
130 |
| - return new \moodle_url('/course/view.php', ['id' => $doc->get('courseid'), 'section' => $cm->sectionnum]); |
131 |
| - } |
132 |
| - |
133 |
| - /** |
134 |
| - * Link to the cms. |
135 |
| - * |
136 |
| - * @param \core_search\document $doc |
137 |
| - * @return \moodle_url |
138 |
| - */ |
139 |
| - public function get_context_url(\core_search\document $doc) { |
140 |
| - $contextmodule = \context::instance_by_id($doc->get('contextid')); |
141 |
| - return new \moodle_url('/mod/cms/view.php', ['id' => $contextmodule->instanceid]); |
142 |
| - } |
143 |
| - |
144 |
| - /** |
145 |
| - * Returns the specified data from its internal cache. |
146 |
| - * |
147 |
| - * @throws \dml_missing_record_exception |
148 |
| - * @param int $id |
149 |
| - * @return stdClass |
150 |
| - */ |
151 |
| - protected function get_data($id) { |
152 |
| - global $DB; |
153 |
| - if (empty($this->cmsdata[$id])) { |
154 |
| - $sql = "SELECT mc.id, mc.course AS courseid |
155 |
| - FROM {cms} mc |
156 |
| - WHERE mc.id = :id"; |
157 |
| - $this->cmsdata[$id] = $DB->get_record_sql($sql, ['id' => $id], MUST_EXIST); |
158 |
| - } |
159 |
| - return $this->cmsdata[$id]; |
160 |
| - } |
161 |
| - |
162 | 82 | /**
|
163 | 83 | * Returns true if this area uses file indexing.
|
164 | 84 | *
|
|
0 commit comments