1 | <?php |
||||||
2 | /* For licensing terms, see /license.txt */ |
||||||
3 | |||||||
4 | use ChamiloSession as Session; |
||||||
5 | use Chamilo\CoreBundle\Component\Utils\ActionIcon; |
||||||
6 | |||||||
7 | /** |
||||||
8 | * @author Christian Fasanando, initial version |
||||||
9 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium, |
||||||
10 | * refactoring and tighter integration |
||||||
11 | */ |
||||||
12 | require_once __DIR__.'/../inc/global.inc.php'; |
||||||
13 | |||||||
14 | $current_course_tool = TOOL_NOTEBOOK; |
||||||
15 | |||||||
16 | // The section (tabs) |
||||||
17 | $this_section = SECTION_COURSES; |
||||||
18 | |||||||
19 | // Notice for unauthorized people. |
||||||
20 | api_protect_course_script(true); |
||||||
21 | |||||||
22 | // Additional javascript |
||||||
23 | $htmlHeadXtra[] = NotebookManager::javascript_notebook(); |
||||||
24 | $htmlHeadXtra[] = '<script> |
||||||
25 | function setFocus(){ |
||||||
26 | $("#note_title").focus(); |
||||||
27 | } |
||||||
28 | $(function() { |
||||||
29 | setFocus(); |
||||||
30 | }); |
||||||
31 | </script>'; |
||||||
32 | |||||||
33 | // Setting the tool constants |
||||||
34 | $tool = TOOL_NOTEBOOK; |
||||||
35 | |||||||
36 | // Tracking |
||||||
37 | Event::event_access_tool(TOOL_NOTEBOOK); |
||||||
0 ignored issues
–
show
|
|||||||
38 | |||||||
39 | $action = isset($_GET['action']) ? $_GET['action'] : ''; |
||||||
40 | |||||||
41 | $logInfo = [ |
||||||
42 | 'tool' => TOOL_NOTEBOOK, |
||||||
43 | 'tool_id' => 0, |
||||||
44 | 'tool_id_detail' => 0, |
||||||
45 | 'action' => $action, |
||||||
46 | 'action_details' => '', |
||||||
47 | ]; |
||||||
48 | Event::registerLog($logInfo); |
||||||
0 ignored issues
–
show
The method
registerLog() does not exist on Event .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
49 | |||||||
50 | // Tool name |
||||||
51 | if ('addnote' === $action) { |
||||||
52 | $tool = 'Add new note in my personal notebook'; |
||||||
53 | $interbreadcrumb[] = [ |
||||||
54 | 'url' => 'index.php?'.api_get_cidreq(), |
||||||
55 | 'name' => get_lang('Notebook'), |
||||||
56 | ]; |
||||||
57 | } |
||||||
58 | if ('editnote' === $action) { |
||||||
59 | $tool = 'Edit my personal note'; |
||||||
60 | $interbreadcrumb[] = [ |
||||||
61 | 'url' => 'index.php?'.api_get_cidreq(), |
||||||
62 | 'name' => get_lang('Notebook'), |
||||||
63 | ]; |
||||||
64 | } |
||||||
65 | |||||||
66 | // Displaying the header |
||||||
67 | Display::display_header(get_lang(ucfirst($tool))); |
||||||
68 | |||||||
69 | // Tool introduction |
||||||
70 | Display::display_introduction_section(TOOL_NOTEBOOK); |
||||||
71 | |||||||
72 | // Action handling: Adding a note |
||||||
73 | if ('addnote' === $action) { |
||||||
74 | if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { |
||||||
75 | api_not_allowed(); |
||||||
76 | } |
||||||
77 | |||||||
78 | if (!empty($_GET['isStudentView'])) { |
||||||
79 | NotebookManager::display_notes(); |
||||||
80 | exit; |
||||||
81 | } |
||||||
82 | |||||||
83 | Session::write('notebook_view', 'creation_date'); |
||||||
84 | |||||||
85 | $form = new FormValidator( |
||||||
86 | 'note', |
||||||
87 | 'post', |
||||||
88 | api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq() |
||||||
89 | ); |
||||||
90 | // Setting the form elements |
||||||
91 | $form->addElement('header', '', get_lang('Add new note in my personal notebook')); |
||||||
92 | $form->addElement('text', 'note_title', get_lang('Note title'), ['id' => 'note_title']); |
||||||
93 | $form->applyFilter('note_title', 'html_filter'); |
||||||
94 | $form->addElement( |
||||||
95 | 'html_editor', |
||||||
96 | 'note_comment', |
||||||
97 | get_lang('Note details'), |
||||||
98 | null, |
||||||
99 | api_is_allowed_to_edit() ? ['ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300'] : ['ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'] |
||||||
100 | ); |
||||||
101 | $form->addButtonCreate(get_lang('Create note'), 'SubmitNote'); |
||||||
102 | |||||||
103 | // Setting the rules |
||||||
104 | $form->addRule('note_title', get_lang('Required field'), 'required'); |
||||||
105 | |||||||
106 | // The validation or display |
||||||
107 | if ($form->validate()) { |
||||||
108 | $check = Security::check_token('post'); |
||||||
109 | if ($check) { |
||||||
110 | $values = $form->exportValues(); |
||||||
111 | $res = NotebookManager::saveNote($values); |
||||||
112 | if ($res) { |
||||||
113 | echo Display::return_message(get_lang('Note added'), 'confirmation'); |
||||||
114 | } |
||||||
115 | } |
||||||
116 | Security::clear_token(); |
||||||
117 | NotebookManager::display_notes(); |
||||||
118 | } else { |
||||||
119 | echo Display::toolbarAction( |
||||||
120 | 'add_glossary', |
||||||
121 | [ |
||||||
122 | Display::url( |
||||||
123 | Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back')), |
||||||
124 | api_get_self().'?'.api_get_cidreq() |
||||||
125 | ), |
||||||
126 | ] |
||||||
127 | ); |
||||||
128 | $token = Security::get_token(); |
||||||
129 | $form->addElement('hidden', 'sec_token'); |
||||||
130 | $form->setConstants(['sec_token' => $token]); |
||||||
131 | $form->display(); |
||||||
132 | } |
||||||
133 | } elseif ('editnote' === $action && is_numeric($_GET['notebook_id'])) { |
||||||
134 | // Action handling: Editing a note |
||||||
135 | |||||||
136 | if (!empty($_GET['isStudentView'])) { |
||||||
137 | NotebookManager::display_notes(); |
||||||
138 | exit; |
||||||
139 | } |
||||||
140 | |||||||
141 | // Initialize the object |
||||||
142 | $form = new FormValidator( |
||||||
143 | 'note', |
||||||
144 | 'post', |
||||||
145 | api_get_self().'?action='.Security::remove_XSS($_GET['action']).'¬ebook_id='.intval($_GET['notebook_id']).'&'.api_get_cidreq() |
||||||
146 | ); |
||||||
147 | // Setting the form elements |
||||||
148 | $form->addElement('header', '', get_lang('Edit my personal note')); |
||||||
149 | $form->addElement('hidden', 'notebook_id'); |
||||||
150 | $form->addElement('text', 'note_title', get_lang('Note title'), ['size' => '100']); |
||||||
151 | $form->applyFilter('note_title', 'html_filter'); |
||||||
152 | $form->addElement( |
||||||
153 | 'html_editor', |
||||||
154 | 'note_comment', |
||||||
155 | get_lang('Note details'), |
||||||
156 | null, |
||||||
157 | api_is_allowed_to_edit() |
||||||
158 | ? ['ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300'] |
||||||
159 | : ['ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'] |
||||||
160 | ); |
||||||
161 | $form->addButtonUpdate(get_lang('Edit my personal note'), 'SubmitNote'); |
||||||
162 | |||||||
163 | // Setting the defaults |
||||||
164 | $defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id'])); |
||||||
165 | $form->setDefaults($defaults); |
||||||
166 | |||||||
167 | // Setting the rules |
||||||
168 | $form->addRule('note_title', get_lang('Required field'), 'required'); |
||||||
169 | |||||||
170 | // The validation or display |
||||||
171 | if ($form->validate()) { |
||||||
172 | $check = Security::check_token('post'); |
||||||
173 | if ($check) { |
||||||
174 | $values = $form->exportValues(); |
||||||
175 | $res = NotebookManager::updateNote($values); |
||||||
176 | if ($res) { |
||||||
177 | echo Display::return_message(get_lang('Note updated'), 'confirmation'); |
||||||
178 | } |
||||||
179 | } |
||||||
180 | Security::clear_token(); |
||||||
181 | NotebookManager::display_notes(); |
||||||
182 | } else { |
||||||
183 | echo Display::toolbarAction( |
||||||
184 | 'add_glossary', |
||||||
185 | [ |
||||||
186 | Display::url( |
||||||
187 | Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back')), |
||||||
188 | api_get_self().'?'.api_get_cidreq() |
||||||
189 | ), |
||||||
190 | ] |
||||||
191 | ); |
||||||
192 | $token = Security::get_token(); |
||||||
193 | $form->addElement('hidden', 'sec_token'); |
||||||
194 | $form->setConstants(['sec_token' => $token]); |
||||||
195 | $form->display(); |
||||||
196 | } |
||||||
197 | } elseif ('deletenote' === $action && is_numeric($_GET['notebook_id'])) { |
||||||
198 | // Action handling: deleting a note |
||||||
199 | $res = NotebookManager::delete_note($_GET['notebook_id']); |
||||||
200 | if ($res) { |
||||||
201 | echo Display::return_message(get_lang('Note deleted'), 'confirmation'); |
||||||
202 | } |
||||||
203 | |||||||
204 | NotebookManager::display_notes(); |
||||||
205 | } elseif ('changeview' === $action && |
||||||
206 | in_array($_GET['view'], ['creation_date', 'update_date', 'title']) |
||||||
207 | ) { |
||||||
208 | // Action handling: changing the view (sorting order) |
||||||
209 | switch ($_GET['view']) { |
||||||
210 | case 'creation_date': |
||||||
211 | if (!$_GET['direction'] || 'ASC' == $_GET['direction']) { |
||||||
212 | echo Display::return_message( |
||||||
213 | get_lang('Notes sorted by creation date ascendant'), |
||||||
214 | 'confirmation' |
||||||
215 | ); |
||||||
216 | } else { |
||||||
217 | echo Display::return_message( |
||||||
218 | get_lang('Notes sorted by creation date downward'), |
||||||
219 | 'confirmation' |
||||||
220 | ); |
||||||
221 | } |
||||||
222 | break; |
||||||
223 | case 'update_date': |
||||||
224 | if (!$_GET['direction'] || 'ASC' == $_GET['direction']) { |
||||||
225 | echo Display::return_message( |
||||||
226 | get_lang('Notes sorted by update date ascendant'), |
||||||
227 | 'confirmation' |
||||||
228 | ); |
||||||
229 | } else { |
||||||
230 | echo Display::return_message( |
||||||
231 | get_lang('Notes sorted by update date downward'), |
||||||
232 | 'confirmation' |
||||||
233 | ); |
||||||
234 | } |
||||||
235 | break; |
||||||
236 | case 'title': |
||||||
237 | if (!$_GET['direction'] || 'ASC' == $_GET['direction']) { |
||||||
238 | echo Display::return_message( |
||||||
239 | get_lang('Notes sorted by title ascendant'), |
||||||
240 | 'confirmation' |
||||||
241 | ); |
||||||
242 | } else { |
||||||
243 | echo Display::return_message( |
||||||
244 | get_lang('Notes sorted by title downward'), |
||||||
245 | 'confirmation' |
||||||
246 | ); |
||||||
247 | } |
||||||
248 | break; |
||||||
249 | } |
||||||
250 | Session::write('notebook_view', $_GET['view']); |
||||||
251 | NotebookManager::display_notes(); |
||||||
252 | } else { |
||||||
253 | NotebookManager::display_notes(); |
||||||
254 | } |
||||||
255 | |||||||
256 | Display::display_footer(); |
||||||
257 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.